ace-window 命名有3种功能:
- 默认情况下,通过指定数字 switch window
- Prefixed with one C-u, does a swap between the selected window and the current window, so that the selected buffer moves to current window (and current buffer moves to selected window).
- Prefixed with two C-u’s, deletes the selected window.
第3种挺好用的,但是有时候我只想杀掉 buffer 并不想关掉 window ,当前未支持(似乎不打算支持,见 https://github.com/abo-abo/ace-window/issues/146 )。
最后想出以下 advice 可以实现:
(advice-add #'ace-window :around
(lambda (oldfun &rest arg)
"Prefixed with three C-u's, kill the buffer of that window."
(if (/= 64 (car arg))
(apply oldfun arg)
(save-window-excursion
(apply oldfun arg)
(kill-buffer))))
'((name . kill-buffer)))
ace-window 代码仓库: