Eli Zaretskii writes: >> From: Philip Kaludercic >> 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." ^ I replaced this with "a", to avoid confusion as to what specific shell buffer is meant (not only *shell*, but any shell-mode buffer). >> + (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. Eli Zaretskii writes: >> Cc: 55426@debbugs.gnu.org >> Date: Sun, 15 May 2022 11:30:17 +0300 >> From: Eli Zaretskii >> >> > From: Philip Kaludercic >> > 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. > > Oh, and one more: I think this change warrants a NEWS entry.