[emacs][haskell] anything.elでhrefを引けるようにした
id:rubikitchさんのRuby リファレンスマニュアルを Emacs で参照・ anything.el との連携(改訂版) - http://rubikitch.com/に移転しましたを参考にして、Haskellの日本語マニュアルhrefをanything.elで使えるようにしてみました。
.emacsに以下のように書いて
(defun href (kw) (interactive "shref: ") (with-current-buffer (get-buffer-create (concat "*href:" kw "*")) (when (zerop (buffer-size)) (let ((kws (split-string kw))) (call-process "href" nil t t (car kws) (concat (cadr kws) "")))) (setq minibuffer-scroll-window (get-buffer-window (current-buffer) t)) (goto-char (point-min)) (display-buffer (current-buffer)))) (setq anything-c-source-href (anything-c-source-static-escript 'anything-c-href-candidates "href" "/$HOME_DIR/.emacs.d/href.e" ;$HOME_DIRは自分の環境に合わせてください '(delayed) '(requires-pattern . 3))) (setq anything-sources (cons anything-c-source-href anything-sources))
以下のスクリプトを走らせてindexを作成すれば
#!/bin/ruby require 'uri' index_file = ENV['HOME'] + "/.emacs.d/href.e" href_datadir = ENV['HREF_DATADIR'] products = [] Dir.glob(href_datadir + '/**/*') do |file| file.gsub!(/#{href_datadir}\//, '') (module_name, function) = URI.decode(file).split('/') products << %|(href "#{module_name} #{function}")| if function end File.open(index_file, 'w') do |f| f.write(products.join("\n")) end
こんな感じになった。