如果async命令终止,Emacs不会终止*Async Shell Command*
缓冲区。我该怎么强迫这种行为?
答案 0 :(得分:4)
您要找的是Process Sentinels。
*Async Shell Command*
的哨兵是shell-command-sentinel
。
你可以advise:
(defun my-kill-buffer-when-done (process signal)
(when (and (process-buffer process)
(memq (process-status process) '(exit signal)))
(kill-buffer (process-buffer process))))
(defun my-kill-async-buffer-when-done ()
(let ((process (get-buffer-process "*Async Shell Command*")))
(add-function :after (process-sentinel process) #'kill-buffer-when-done)))
(add-function :after #'async-shell-command #'my-kill-async-buffer-when-done)
PS。我没有测试上面的代码,主要是因为我认为这是一个可怕的想法:你想要在杀死它之前检查*Async Shell Command*
的内容。
但是,我希望阅读上面的代码和链接可以帮助您成为更熟练的Emacs用户。