プログラム系統備忘録ブログ

記事中のコードは自己責任の下でご自由にどうぞ。

Emacsでanything-aproposの候補名をキルリングに追加する

defunやkbdやdolistなどの、関数でも変数でも無いものの名前も一覧してくれるanything-aproposですが、
anything-c-source-emacs-functionsやanything-c-source-emacs-variablesで出来た"Add command to kill ring"がなかったので追加したメモ。
anything-aproposで使っている情報源のtype属性を直接上書きして実現。
anything-comlete.elにそれらtype属性の定義があり、それぞれのaction属性の末尾に一行追加しただけのものを再定義しました。

(define-anything-type-attribute 'apropos-function
    '((filtered-candidate-transformer . alcs-sort-maybe)
      (header-name . alcs-header-name)
      (persistent-action . alcs-describe-function)
      (update . alcs-make-candidates)
      (action
       ("Describe Function" . alcs-describe-function)
       ("Find Function" . alcs-find-function)
       ("Add command to kill ring" . anything-c-kill-new)))) ;追加
(define-anything-type-attribute 'apropos-variable
  '((filtered-candidate-transformer . alcs-sort-maybe)
    (header-name . alcs-header-name)
    (persistent-action . alcs-describe-variable)
    (update . alcs-make-candidates)
    (action
     ("Describe Variable" . alcs-describe-variable)
     ("Find Variable" . alcs-find-variable)
     ("Add command to kill ring" . anything-c-kill-new)))) ;追加
(define-anything-type-attribute 'apropos-face
  '((filtered-candidate-transformer alcs-sort-maybe alcs-fontify-face)
    (get-line . buffer-substring)
    (header-name . alcs-header-name)
    (update . alcs-make-candidates)
    (persistent-action . alcs-describe-face)
    (action
     ("Customize Face" . alcs-customize-face)
     ("Describe Face" . alcs-describe-face)
     ("Add command to kill ring" . anything-c-kill-new)))) ;追加

もっと簡単かつ移植性のある方法があると思いますが、動いたのでとりあえずこれで。