bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55426: [PATCH] Add option to kill a shell buffer when the process en


From: Eli Zaretskii
Subject: bug#55426: [PATCH] Add option to kill a shell buffer when the process ends
Date: Sun, 15 May 2022 11:30:17 +0300

> From: Philip Kaludercic <philipk@posteo.net>
> Date: Sun, 15 May 2022 08:13:49 +0000
> 
> The below patch adds an option that has a *shell* buffer automatically
> killed when a shell process terminates.  I find this useful, because it
> helps to avoid re-activating old shell buffers in the wrong
> `default-directory'.

Thanks, a few comments below.

> +(defcustom shell-kill-buffer-on-quit t

I think a better name is shell-kill-shell-buffer-on-exit.

> +  "Kill shell buffer after the process terminates."

"Kill the shell buffer when the shell process terminates."

> +  (when shell-kill-buffer-on-quit
> +    (let* ((buffer (current-buffer))
> +           (sentinel (process-sentinel (get-buffer-process buffer))))
> +      (set-process-sentinel
> +       (get-buffer-process (current-buffer))
> +       (lambda (proc event)
> +         (unless (buffer-live-p proc)
> +           (kill-buffer buffer))
> +         (when sentinel
> +           (funcall sentinel proc event))))))

Shouldn't we call the previous sentinel before killing the buffer?
That sentinel could not be prepared to the buffer being dead.

Also, can you modify the code to call get-buffer-process only once?

> If this patch is merged, perhaps something similar for term could be
> done too?

I'm not sure, but I don't use term frequently enough for my opinion to
matter.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]