diff options
| author | Jakob L. Kreuze | 2020-07-23 19:35:49 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze | 2020-07-23 19:35:49 -0400 |
| commit | 7f4783ae3b09ec670586adee8bdffd925f550cd9 (patch) | |
| tree | 192c8fadb6032e0292b69850bf43d9e84678874f | |
| parent | 3c43f715618968c18c6264b159bc03cec8387baa (diff) | |
[shell] Close the buffer upon quitting with C-d.
| -rw-r--r-- | lisp/shell.el | 17 |
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) |