anything.elとプラグイン等をリリース
次世代anything.elとプラグインをリリース!候補選択は是非anythingを - http://rubikitch.com/に移転しましたから更新しました。
anything.elのリリースノートは
http://d.hatena.ne.jp/rubikitch/searchdiary?word=%2a%5banything%2drelease%5d
から辿れます。
anything.el
M-x install-elisp http://www.emacswiki.org/cgi-bin/wiki/download/anything.el
- anything-current-buffer-is-modifiedの実装にバグがあったので修正。
- anything-read-string-modeはanything-complete.elに移動。
- anything-after-persistent-action-hookを新設。persistent-actionで開いたファイルをハイライトする等お好きなように。
- anythingの省略可能引数を増やした。
- anything起動中にC-gが押されたらnilを返すようにした。
- search-from-end属性を新設。candidates-in-bufferでファイルの末尾から候補を拾うように。
- persistent-actionでバッファを表示するとき、*anything*バッファの隣のウィンドウに表示するように。
- Emacs22.1で動くように、buffer-chars-modified-tickを定義。これは22.2以降の関数なので。
anything-match-plugin.el
素のanything.elだと候補の絞り込みに正規表現をひとつしか指定できないものを、複数個の正規表現を書けるようにしました。しかも、完全一致候補→先頭一致候補→その他の順で候補を表示するので目的の候補を探しやすくなっています。anythingユーザーは入れておくと幸せになれるでしょう。どんどん絞り込みましょう。
M-x install-elisp http://www.emacswiki.org/cgi-bin/wiki/download/anything-match-plugin.el
アルゴリズム変更でバージョン1.12以降より格段と高速になりました。
anything-gtags.el
GNU GLOBALのタグ選択をanythingに置き換えたものです。コードリーディングにおいては当たりをつけたところからターゲットを絞り込んでいかないといけないので、絞り込み検索は必須です。
M-x install-elisp http://www.emacswiki.org/cgi-bin/wiki/download/anything-gtags.el
- ファイルごとに情報源の分けるようにした。これで候補がどのファイルにあるかを俯瞰することができる。
実現にいたっては、meta-sourceというテクニックを使いました。meta-sourceはnameとinitしか定義されていない情報源で、initの中でanything-set-sourcesを使うことで動的に情報源を組み立てるものです。候補のカテゴリ分けに便利です。
anything-complete.el
新作です。
様々な補完をanything.elのインターフェースで行うものです。
Emacs Lispシンボルを集めるのは時間がかかるので、150秒アイドル状態が続いたらLispシンボルを更新します。
(require 'anything-complete) (anything-lisp-complete-symbol-set-timer 150)
以下のコマンドは元のコマンドをanythingのインターフェースに置き換えたものです。Lisp補完コマンドのpersistent-actionはdescribe-*となっています。
- anything-lisp-complete-symbol
- anything-lisp-complete-symbol-partial-match
- anything-apropos
- anything-read-file-name
- anything-read-buffer
- anything-read-variable
- anything-read-command
- anything-completing-read
anything-read-string-modeはread-*, completing-readをanythingのものに置き換えます。まだ実験段階ですが僕はiciclesを捨ててこれに置き換えています。completing-readの置き換えはまだ完全ではありません。物好きな人はどうぞ。
anything-complete-shell-historyは .bash_history や .zsh_history からの履歴をコピーするものです。shell-modeやshell-command等にどうぞ。この関数を使うときは shell-history.el が必要です。
定義している情報源は以下のものです。
- anything-c-source-complete-emacs-functions
- anything-c-source-complete-emacs-commands
- anything-c-source-complete-emacs-variables
- anything-c-source-complete-emacs-other-symbols
- anything-c-source-complete-emacs-functions-partial-match
- anything-c-source-complete-emacs-commands-partial-match
- anything-c-source-complete-emacs-variables-partial-match
- anything-c-source-apropos-emacs-functions
- anything-c-source-apropos-emacs-commands
- anything-c-source-apropos-emacs-variables
- anything-c-source-emacs-function-at-point
- anything-c-source-emacs-variable-at-point
- anything-c-source-complete-shell-history
anything-c-source-complete-shell-historyでは新たに導入したsearch-from-end属性を使用しています。.*sh_historyは新しいものが下に来るからです。
shell-command.elとanything-complete-shell-historyを併用する設定
ミニバッファ内でM-TabかC-oでanything-complete-shell-historyが起動します。
anything-read-file-nameが安定し次第、anything-complete-shell-historyとファイル名補完同時に行えるようにすると思います。
(require 'shell-command) (shell-command-completion-mode) ;; REDEFINED! (defun shell-command-read-minibuffer (format-string current-directory &optional initial-contents user-keymap read hist) "Read a command string in the minibuffer, with completion." (let ((keymap (make-sparse-keymap)) (prompt (shell-command-make-prompt-string format-string current-directory))) (set-keymap-parent keymap (or user-keymap minibuffer-local-map)) (define-key keymap "\C-\M-i" 'anything-complete-shell-history) (define-key keymap "\C-o" 'anything-complete-shell-history) (define-key keymap "\t" (lambda () (interactive) (let ((orig-function (symbol-function 'message))) (unwind-protect (progn (defun message (string &rest arguments) (let* ((s1 (concat prompt (buffer-substring (shell-command/minibuffer-prompt-end) (point-max)))) (s2 (apply (function format) string arguments)) (w (- (window-width) (string-width s1) (string-width s2) 1))) (funcall orig-function (if (>= w 0) (concat s1 (make-string w ?\ ) s2) s2)) (if (sit-for 0.3) (funcall orig-function s1)) s2)) (require 'shell) (require 'comint) (run-hook-with-args-until-success 'shell-command-complete-functions)) (fset 'message orig-function))))) (read-from-minibuffer prompt initial-contents keymap read hist)))
shell-history.elとの併用
shell-history.elはshell-command, shell-command-on-region, compile, grep, executable-interpret, backgroundでコマンドを実行したときに、そのコマンドを.bash_historyや.zsh_historyに加えるものです。これを使うとシェルの履歴をEmacsとシェルで共有できます。requireするだけで使えます。
これはanything.elとは独立していますが、anything-complete-shell-historyはshell-history.elに依存しています。
M-x install-elisp http://www.emacswiki.org/cgi-bin/wiki/download/shell-history.el
後で気付いたのですがanything-c-shell-history.elというものがありました。紛らわしくてすみません。
anything.elの設定ファイル
http://www.emacswiki.org/cgi-bin/wiki/download/RubikitchAnythingConfiguration
僕の設定はEmacsWikiで公開しています。設定例、情報源の作成方法、実験的なコードなどが含まれています。適当にコピペしちゃってください。