Ruby リファレンスマニュアルを Emacs で参照・ anything.el との連携(改訂版)
前回の Ruby リファレンスマニュアル(通称るりま)と ReFe2 をインストール・ Emacs で参照する・ anything.el との連携 - http://rubikitch.com/に移転しました では欠点があったのでより強化してみた。
- ライブラリのリファレンスが見られるようになった
- 「 Enumerable#map 」などの別名のエントリも作るようになった
- ライブラリ名、クラス名、メソッド名が一箇所になるように目次を作成した
refe2x コマンド
ReFe2 よりも bitclust コマンドを使う方がより詳細な説明が出ることが判明。それに ReFe2 だとライブラリのリファレンスが見られないようだ。 bitclust ならば見られる。なので、拙作 refe2 コマンドを改訂して refe2x コマンドを作成した。以下からもってけ! refe2x コマンドの BITCLUST_DIR と COLUMNS は適当に書き換えてね。
http://www.rubyist.net/~rubikitch/archive/refe2x
refe2x コマンドの使い方は少しかわっている。以下のように prefix がついている。「 c/ 」がクラス、「 l/ 」がライブラリ、「 m/ 」がメソッドのリファレンスを引く。
$ refe2x c/Abbrev 略 $ refe2x l/abbrev 略 $ refe2x m/Abbrev.#abbrev 略
生成された総目次
さて、次は総目次を作成だ。
生成物は例によって refe2x.e は以下に置いたからもってけ!
http://www.rubyist.net/~rubikitch/archive/refe2x.e
自分で総目次を作成したい人は次の項目へ。
bc-index コマンドで総目次を作成
総目次を作成するコマンド bc-index を作成した。こんな感じに実行する。以下からもってけ!
http://www.rubyist.net/~rubikitch/archive/bc-index
$ bc-index -d ~/compile/ruby-refm-1.9.0-dynamic/db-1_9_0/ l/_builtin c/Abbrev l/abbrev m/Abbrev.#abbrev c/ACL m/ACL#allow_addr? m/ACL#allow_socket? m/ACL#install_list m/ACL.new c/Arc $ bc-index --sexp -d ~/compile/ruby-refm-1.9.0-dynamic/db-1_9_0/ # (refe2x "l/_builtin") # (refe2x "c/Abbrev") # (refe2x "l/abbrev") # (refe2x "m/Abbrev.#abbrev") # (refe2x "c/ACL") # (refe2x "m/ACL#allow_addr?") # (refe2x "m/ACL#allow_socket?") # (refe2x "m/ACL#install_list") # (refe2x "m/ACL.new") # (refe2x "c/Arc") (略)
Emacs 使いにとって必要なのは--sexp をつけた方だ。
$ cd ~/compile/ruby-refm-1.9.0-dynamic/bitclust $ bc-index --sexp -d ~/compile/ruby-refm-1.9.0-dynamic/db-1_9_0/ > refe2x.e
これで refe2x.e ができあがった。
Emacs で refe2 コマンドを使う。
ここから後は以前の設定とほとんど一緒。 s/2/sx/g しただけ。
(defun refe2x (kw) (interactive "sReFe2x: ") (let ((coding-system-for-read 'euc-japan)) (with-current-buffer (get-buffer-create (concat "*refe2x:" kw "*")) (when (zerop (buffer-size)) (call-process "refe2x" nil t t kw) (diff-mode)) (setq minibuffer-scroll-window (get-buffer-window (current-buffer) t)) (goto-char (point-min)) (display-buffer (current-buffer)))))
anything.el との連携
anything-c-source-static-escript は以前とまったく同じ。 s/2/sx/g しただけ。
(defun anything-c-source-static-escript (symbol desc filename &rest other-attrib) `((name . ,desc) (candidates . ,symbol) ,@other-attrib (init . (lambda () (unless (and (boundp ',symbol) ,symbol) (with-current-buffer (find-file-noselect ,filename) (setq ,symbol (split-string (buffer-string) "\n" t)))))) (action ("Eval it" . (lambda (cand) (with-temp-buffer (insert cand) (cd ,(file-name-directory filename)) (backward-sexp 1) (eval (read (current-buffer))))))))) (setq anything-c-source-refe2x (anything-c-source-static-escript 'anything-c-refe2x-candidates "ReFe2x" "~/compile/ruby-refm-1.9.0-dynamic/bitclust/refe2x.e" '(delayed) '(requires-pattern . 3))) (setq anything-sources (list anything-c-source-refe2))