Reputation: 66480
How can I automatically kill the terminal buffer when the process associated with it ends.
Upvotes: 6
Views: 1076
Reputation: 3179
I found much simpler method, define an advice on term-handle-exit
(defadvice term-handle-exit
(after term-kill-buffer-on-exit activate)
(kill-buffer))
Upvotes: 6
Reputation: 66480
I found that I can use process sentinels for that and set it using 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))))))))
Upvotes: 1