Commit 76f2d19e authored by Samer Masterson's avatar Samer Masterson

* lisp/eshell/em-term.el (eshell-term-sentinel):

No-op by default, only kills term buffer if
`eshell-destroy-buffer-when-process-dies' is non-nil.  (Bug#18108)
(eshell-destroy-buffer-when-process-dies): New custom to preserve
previous behavior.
parent e37da5a4
......@@ -681,6 +681,14 @@ buffers from eshell more convenient. Custom variable
`eshell-buffer-shorthand', which has been broken for a while, has been
removed.
*** By default, eshell "visual" program buffers (created by
`eshell-visual-commands' and similar custom vars) are no longer killed
when their processes die. This fixes issues with short-lived commands
and makes visual programs more useful in general. For example, if
"git log" is a visual command, it will always show the visual command
buffer, even if the "git log" process dies. For the old behavior,
make the new option `eshell-destroy-buffer-when-process-dies' non-nil.
** Browse-url
*** Support for the Conkeror web browser.
......
......@@ -132,6 +132,13 @@ character to the invoked process."
:type 'boolean
:group 'eshell-term)
(defcustom eshell-destroy-buffer-when-process-dies nil
"If non-nil, term buffers are destroyed after their processes die.
WARNING: Setting this to non-nil may result in unexpected
behavior for short-lived processes, see bug#18108."
:type 'boolean
:group 'eshell-term)
;;; Internal Variables:
(defvar eshell-parent-buffer)
......@@ -190,20 +197,24 @@ allowed."
nil)
;; Process sentinels receive two arguments.
(defun eshell-term-sentinel (proc _string)
"Destroy the buffer visiting PROC."
(let ((proc-buf (process-buffer proc)))
(when (and proc-buf (buffer-live-p proc-buf)
(not (eq 'run (process-status proc)))
(= (process-exit-status proc) 0))
(if (eq (current-buffer) proc-buf)
(let ((buf (and (boundp 'eshell-parent-buffer)
eshell-parent-buffer
(buffer-live-p eshell-parent-buffer)
eshell-parent-buffer)))
(if buf
(switch-to-buffer buf))))
(kill-buffer proc-buf))))
(defun eshell-term-sentinel (proc msg)
"Clean up the buffer visiting PROC.
If `eshell-destroy-buffer-when-process-dies' is non-nil, destroy
the buffer."
(term-sentinel proc msg) ;; First call the normal term sentinel.
(when eshell-destroy-buffer-when-process-dies
(let ((proc-buf (process-buffer proc)))
(when (and proc-buf (buffer-live-p proc-buf)
(not (eq 'run (process-status proc)))
(= (process-exit-status proc) 0))
(if (eq (current-buffer) proc-buf)
(let ((buf (and (boundp 'eshell-parent-buffer)
eshell-parent-buffer
(buffer-live-p eshell-parent-buffer)
eshell-parent-buffer)))
(if buf
(switch-to-buffer buf))))
(kill-buffer proc-buf)))))
;; jww (1999-09-17): The code below will allow Eshell to send input
;; characters directly to the currently running interactive process.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment