2007/11/19
Screen に表示されている文字列を Emacs で補完する
元ネタ:
http://d.hatena.ne.jp/secondlife/20060108/1136650653
screen に hardcopy させたファイルをバッファに読みこんでおいて、 hippie-expand の try-expand-dabbrev-all-buffers を使ってバッファ内の文字列を参考にさせつつ補完を実行します。
(defun screen-get-hardcopy ()
(let ((file (expand-file-name "~/tmp/screen-hardcopy")))
(if (= (call-process "screen" nil nil nil "-X" "hardcopy" file) 0)
file
nil)))
(defun screen-read-hardcopy ()
(let ((file (screen-get-hardcopy)))
(if file
(let ((buf (get-buffer-create "*Screen Hardcopy*")))
(with-current-buffer buf
(buffer-disable-undo)
(erase-buffer)
(insert-file-contents file))))))
(defadvice try-expand-dabbrev-all-buffers (before try-expand-dabbrev-screen-hardcopy activate)
(screen-read-hardcopy))
(setq hippie-expand-try-functions-list
'(...
try-expand-dabbrev-all-buffers # これがあるのを確認
...))
上を実行して hippie-expand してやれば screen に表示されている文字列も補完できるようになるはずです。
ちなみに --no-window ユーザーには全く恩恵がありません。あと screen の log を使う手もありますが、丁寧に作らないとメモリを食いまくります。
- Category(s)
- emacs
- The URL to Trackback this entry is:
- http://dev.ariel-networks.com/Members/matsuyama/complete-string-within-screen/tbping