summaryrefslogtreecommitdiff
path: root/lisp/shell.el
diff options
context:
space:
mode:
authorJakob L. Kreuze2020-07-23 19:35:49 -0400
committerJakob L. Kreuze2020-07-23 19:35:49 -0400
commit7f4783ae3b09ec670586adee8bdffd925f550cd9 (patch)
tree192c8fadb6032e0292b69850bf43d9e84678874f /lisp/shell.el
parent3c43f715618968c18c6264b159bc03cec8387baa (diff)
[shell] Close the buffer upon quitting with C-d.
Diffstat (limited to 'lisp/shell.el')
-rw-r--r--lisp/shell.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/shell.el b/lisp/shell.el
index 3d58519..0449be2 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -171,3 +171,20 @@
(bind-key "C-c C-s" 'comint-history-isearch shell-mode-map)
(bind-key "C-c C-r" 'comint-history-isearch-backward shell-mode-map)
+
+;; Close the buffer upon quitting with C-d.
+
+(defun shell-kill-buffer-on-quit (process event)
+ "Called when the shell process is stopped.
+
+Kills the buffer when the shell program quits."
+ (comint-write-input-ring)
+ (let ((buf (process-buffer process)))
+ (when (buffer-live-p buf)
+ (with-current-buffer buf (kill-buffer)))))
+
+(defun add-shell-sentinel (&rest args)
+ (set-process-sentinel (get-buffer-process (current-buffer))
+ #'shell-test-sentinel))
+
+(add-hook 'shell-mode-hook #'add-shell-sentinel)

© 2015 - 2026 Jakob L. Kreuze