如何在Emacs中自动终止终端进程退出时的缓冲区

时间:2012-09-27 15:23:10

标签: emacs process exit kill

当与其关联的进程结束时,如何自动终止终端缓冲区。

2 个答案:

答案 0 :(得分:4)

我找到了更简单的方法,在term-handle-exit

上定义了一个建议
(defadvice term-handle-exit
  (after term-kill-buffer-on-exit activate)
(kill-buffer))

答案 1 :(得分:1)

我发现我可以使用进程标记并使用term-exec-hook

进行设置
(add-hook 'term-exec-hook (lambda ()
            (let* ((buff (current-buffer))
                 (proc (get-buffer-process buff)))
            (lexical-let ((buff buff))
               (set-process-sentinel proc (lambda (process event)
                            (if (string= event "finished\n")
                                       (kill-buffer buff))))))))