別のPCにrubyの環境を作った。

friが動けばいい。

install

sudo gem install fastri -y

emacsの設定

"fri -l"でmethodの一覧がとれるのでcandidates-in-bufferを使うと楽に候補が設定できる。
fastri-serverはemacsの中で立ち上げることにした。
出力結果をansi-color-apply-on-regionで強引に修正。

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

(setq anything-c-source-ruby-method-reference
      '((name . "Ruby Mehtod")
	(init . (lambda ()
		  (let ((buf "*ruby-all-methods*"))
		    (unless (get-process ruby-ri-server-name)
		      (ruby-setup-ri-server))
		    (unless (get-buffer buf)
		      (call-process-shell-command "fri -l" nil buf)
	              (anything-candidate-buffer (get-buffer buf)))
		    (set-buffer buf))))
	(candidates-in-buffer)
	(action . (("RI" . (lambda (c) (shell-command (format "fri %S" c))
			     (with-current-buffer (get-buffer "*Shell Command Output*")
			       (ansi-color-apply-on-region (point-min) (point-max)))
			     ))
		   ))
	))

(defvar ruby-ri-server-name "fastri-server")

(defun ruby-setup-ri-server () 
  (start-process-shell-command ruby-ri-server-name
			       nil ;(format "*%s*" ruby-ri-server-name)
			       ruby-ri-server-name))

(defun anything-ruby-method-reference () (interactive)
  (anything (list anything-c-source-ruby-method-reference)))