encap.l を使ってみる

以前 trace を見つけたときにインストールした、encap.l を使ってみる。
既存の関数を簡単にラップできるみたい。

簡単そうなのを試す。

describe-function したとき、ポイント付近の単語をデフォルト文字列として与える。

(encapsulate 'describe-function
             'word-near-point
             '((interactive "SApropos(Regexp): " :default0 (word-near-point))
               (apply basic-definition argument-list)))

(defun word-near-point ()
  "ポイント付近の単語を取得する"
  (save-excursion
    (buffer-substring (progn (skip-syntax-spec-forward "w_") (point))
                      (progn (skip-syntax-spec-backward "w_") (point)))))

xyzzy の場合は、 emacs に比べると describe-function の利用価値は少ないから、あんまり便利になるとは思えないけど、まあいいや。

なんか、やってることは emacs の defadvice と変わらない気がしてきた。