Hatena::ブログ(Diary)

trotrの日記

2009-08-12

[][]method一覧 02:15

以下の方法が一番楽かもしれない。

準備

qriを使えるようにする。*1

sudo gem install fastri
fastri-server -b

.emacs

(require 'ansi-color)
(require 'anything)

(unless (fboundp 'rlet1) 
  (defmacro let1 (var val &rest action)
    `(let ((,var ,val))
       ,@action))
  (put 'let1 'lisp-indent-function 2)

  (defmacro rlet1 (var val &rest action)
    `(let1 ,var ,val
       (progn ,@action ,var)))
  (put 'rlet1 'lisp-indent-function 2)
)

(defvar tiny-ruby-reference-source-buffer "*TRS*")
(defvar tiny-ruby-reference-output "*qri-output*")

(setq tiny-ruby-reference-source
      '((name . "ruby method")
	(init . (lambda () 
		  (unless (anything-candidate-buffer)
		    (anything-candidate-buffer 
		     (tiny-ruby-reference-source-activate)))))
	(candidates-in-buffer)
	(action . tiny-ruby-reference-qri)))

(defun tiny-ruby-reference-qri (cand)
  (let* ((cand* (replace-regexp-in-string "#" "." cand))
	 (cand** (replace-regexp-in-string "\?" "\\\\?" cand*)))
    (let1 buf (get-buffer-create tiny-ruby-reference-output)
      (with-current-buffer buf
	(erase-buffer)
	(call-process-shell-command (concat "qri " cand**) nil buf)
	(ansi-color-apply-on-region (point-min) (point-max)))
      (display-buffer buf))))

(defun tiny-ruby-reference-source-activate ()
  (or (get-buffer tiny-ruby-reference-source-buffer)
      (rlet1 buf (get-buffer-create tiny-ruby-reference-source-buffer)
	(call-process-shell-command "qri -l" nil buf))))

(defun tiny-ruby-reference () (interactive)
  (anything '(tiny-ruby-reference-source)))

あとは、M-x tiny-ruby-referenceで

*1:friはserverが立ち上がっていないと利用できないので面倒

だしゃーし!!!!!!だしゃーし!!!!!! 2009/08/16 11:49
ぜっぷる!ぜっぷーる!!ぴゃひぃぃ!!!!!
ちょっと!落ち着け!!!いや、俺が落ち着く!!!!!!!!

なんかよくわからんが濡れ濡れオ マ ン 湖にカチカチの俺様を挿入しただけで
5 万貰えた!!! ナニこれww ちょっと今からもっかい行ってくるwwwwww

http://yuzo.plusnote.net/MCKEntF/

トラックバック - http://d.hatena.ne.jp/trotr/20090812
Connection: close