feat(emacs): Kill Comint buffers after exiting
This commit is contained in:
@@ -94,20 +94,27 @@
|
|||||||
(scroll-bar-mode -1)
|
(scroll-bar-mode -1)
|
||||||
(tool-bar-mode -1))
|
(tool-bar-mode -1))
|
||||||
|
|
||||||
(defun syd-init-kill-comint-on-exit ()
|
(defun syd-init-kill-process-buffer-on-exit ()
|
||||||
(defun syd-comint--kill-buffer-sentinel (process output)
|
(defun syd-comint--kill-buffer-sentinel (process _output)
|
||||||
"Process sentinel to auto kill associated buffer once PROCESS dies."
|
"Process sentinel to auto kill associated buffer once PROCESS dies."
|
||||||
(unless (process-live-p process)
|
;; Note that `process-exit-status' returns zero when the process has not yet
|
||||||
(kill-buffer (process-buffer process))))
|
;; died.
|
||||||
|
(unless (and process (zerop (process-exit-status process)))
|
||||||
|
(let ((buffer (process-buffer process)))
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(goto-char (point-max))
|
||||||
|
(insert (format "\n[Process exited with exit status %d]"
|
||||||
|
(process-exit-status process))))
|
||||||
|
(kill-buffer (process-buffer process)))))
|
||||||
|
|
||||||
(defun syd-comint--add-kill-on-exit-sentinel ()
|
(defun syd-comint--add-kill-on-exit-sentinel ()
|
||||||
"Replace current process sentinel with a new sentinel composed of the
|
"Replace current process sentinel with a new sentinel composed of the
|
||||||
current one and `syd-comint--kill-buffer-sentinel'."
|
current one and `syd-comint--kill-buffer-sentinel'."
|
||||||
(let* ((process (get-buffer-process (current-buffer)))
|
(let* ((process (get-buffer-process (current-buffer)))
|
||||||
(og-sentinel (process-sentinel process))
|
(original-sentinel (process-sentinel process))
|
||||||
(sentinel-list
|
(sentinel-list
|
||||||
(-remove #'null
|
(-remove #'null
|
||||||
(list og-sentinel #'syd-comint--kill-buffer-sentinel)))
|
(list original-sentinel #'syd-comint--kill-buffer-sentinel)))
|
||||||
(combined-sentinel
|
(combined-sentinel
|
||||||
(lambda (process line)
|
(lambda (process line)
|
||||||
(--each sentinel-list
|
(--each sentinel-list
|
||||||
@@ -143,8 +150,6 @@ for example when calling `shell'.")
|
|||||||
:background unspecified
|
:background unspecified
|
||||||
:weight bold))))
|
:weight bold))))
|
||||||
|
|
||||||
(syd-init-kill-comint-on-exit)
|
|
||||||
|
|
||||||
(general-def
|
(general-def
|
||||||
:keymaps 'comint-mode-map
|
:keymaps 'comint-mode-map
|
||||||
:states '(normal insert)
|
:states '(normal insert)
|
||||||
@@ -163,6 +168,7 @@ for example when calling `shell'.")
|
|||||||
(set-popup-rule! "*Messages*"
|
(set-popup-rule! "*Messages*"
|
||||||
:ttl nil
|
:ttl nil
|
||||||
:quit t)
|
:quit t)
|
||||||
|
(syd-init-kill-process-buffer-on-exit)
|
||||||
;; Required for :quit t to do anything.
|
;; Required for :quit t to do anything.
|
||||||
(evil-set-initial-state 'messages-buffer-mode 'motion)
|
(evil-set-initial-state 'messages-buffer-mode 'motion)
|
||||||
(evil-set-initial-state 'debugger-mode 'normal)
|
(evil-set-initial-state 'debugger-mode 'normal)
|
||||||
|
|||||||
Reference in New Issue
Block a user