GNU bug report logs -
#55426
[PATCH] Add option to kill a shell buffer when the process ends
Previous Next
Reported by: Philip Kaludercic <philipk <at> posteo.net>
Date: Sun, 15 May 2022 08:15:01 UTC
Severity: normal
Tags: patch
Done: Philip Kaludercic <philipk <at> posteo.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Fixed both here:
[0001-Add-option-to-kill-a-shell-buffer-when-the-process-e.patch (text/x-diff, inline)]
From 6db6675c1f931b0eed6606227ecd4919a7052afd Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk <at> posteo.net>
Date: Sun, 15 May 2022 02:09:46 +0200
Subject: [PATCH] Add option to kill a shell buffer when the process ends
* shell.el (shell-kill-buffer-on-quit): Add new option (bug#55426).
(shell): Respect 'shell-kill-buffer-on-quit'.
* NEWS: Mention 'shell-kill-buffer-on-quit'.
---
etc/NEWS | 7 +++++++
lisp/shell.el | 17 +++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index a0164bbf3f..27772dc54e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1544,6 +1544,13 @@ values passed as a single token, such as '-oVALUE' or
'eshell-eval-using-options' macro. See "Defining new built-in
commands" in the "(eshell) Built-ins" node of the Eshell manual.
+** Shell
+
+---
+*** New user option 'shell-kill-buffer-on-exit'
+Enabling this will automatically kill a *shell* buffer as soon as the
+shell session terminates.
+
** Calc
+++
diff --git a/lisp/shell.el b/lisp/shell.el
index 47887433d9..4e65fccf9e 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -331,6 +331,12 @@ shell-has-auto-cd
:group 'shell-directories
:version "28.1")
+(defcustom shell-kill-buffer-on-exit nil
+ "Kill a shell buffer after the shell process terminates."
+ :type 'boolean
+ :group 'shell
+ :version "29.1")
+
(defvar shell-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c\C-f" 'shell-forward-command)
@@ -818,6 +824,17 @@ shell
(with-temp-buffer
(insert-file-contents startfile)
(buffer-string)))))))
+ (when shell-kill-buffer-on-exit
+ (let* ((buffer (current-buffer))
+ (process (get-buffer-process buffer))
+ (sentinel (process-sentinel process)))
+ (set-process-sentinel
+ process
+ (lambda (proc event)
+ (when sentinel
+ (funcall sentinel proc event))
+ (unless (buffer-live-p proc)
+ (kill-buffer buffer))))))
buffer)
;;; Directory tracking
--
2.30.2
[Message part 3 (text/plain, inline)]
Should it push it?
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Philip Kaludercic <philipk <at> posteo.net>
>> Cc: 55426 <at> debbugs.gnu.org
>> Date: Sun, 15 May 2022 11:06:42 +0000
>>
>> Thank you for your comments, here is an improved version:
>
> Thanks. One nit:
>
>> +** Shell
>> +
>> +---
>> +*** New user option 'shell-kill-buffer-on-exit'
>> +Enabling this open will automatically kill a *shell* buffer as soon as
> ^^^^
> Seems like a leftover from a different version?
Andreas Schwab <schwab <at> linux-m68k.org> writes:
> On Mai 15 2022, Philip Kaludercic wrote:
>
>> diff --git a/lisp/shell.el b/lisp/shell.el
>> index 47887433d9..7000d38255 100644
>> --- a/lisp/shell.el
>> +++ b/lisp/shell.el
>> @@ -331,6 +331,12 @@ shell-has-auto-cd
>> :group 'shell-directories
>> :version "28.1")
>>
>> +(defcustom shell-kill-buffer-on-exit t
>
> That should default to nil.
This bug report was last modified 3 years and 1 day ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.