anything-describe-function
まだちょっと、重い。
anythingを初期値をとる様にしてみた。
describe-function(C-h f)は、現在のカーソル位置の関数を初期値としてとっているので、それを真似したかった。
anything.elのread-stringのところを変更。
(anything-initial-inputの値を初期値としてとる様に変更)
(defun anything () ;... (let ((minibuffer-local-map anything-map)) ;(read-string "pattern: "))) ;;変更前 (read-string "pattern: " anything-initial-input))) ;;変更後 ;
どこかで初期化
(defvar anything-initial-input "")
.emacsに追加
(defun my-elisp-current-function () (let ((end (point)) (syntax "w_")) (skip-syntax-backward syntax) (let ((start (point))) (buffer-substring-no-properties start end)))) (defun anything-describe-function () (interactive) (let ((anything-sources (list anything-c-source-emacs-functions)) (anything-initial-input (my-elisp-current-function))) (anything))) ;;少し遅い。 (global-set-key "\C-hf" 'anything-describe-function)
dic-search
以下の様な単語を調べるコマンドがあるとして
$ dic_search.rb -r <word1> <word2> "<phrase>"
.emacsに以下の様な設定を加えると楽に単語を調べられる。
(defun my-dic-search () (interactive) (let ((word (current-word))) (shell-command (concat "dic_search.rb -r " word)))) (defun my-dic-search-region (beg end) (interactive "r") (shell-command-on-region beg end "cat | xargs dic_search.rb -r")) (global-set-key "\C-c\C-e" 'my-dic-search-region) (global-set-key [f4] 'my-dic-search)
例えば(単語を調べるコマンドの例)
class Caller def initialize useja if self.respond_to? :useja raise "create_url method is not found." unless self.respond_to? :create_url end def get_mean word @content = create_url word system("firefox --new-tab #{@content}") self end alias run get_mean end class EtoJ < Caller def create_url x url=%W{http://eow.alc.co.jp/ /UTF-8/} url.join(x).gsub(' ','%20') end end require 'optparse' dic = nil ARGV.options do |opt| #他にも色々 opt.on('-r', '--entoja', 'EIGRO on THE WEB'){ dic = EtoJ } opt.parse! end ARGV.inject(dic.send(:new)){ |d, e| p(e); d.run(e); sleep(0.1); d}