diff options
| author | Samer Masterson | 2015-05-17 14:55:16 -0700 |
|---|---|---|
| committer | Samer Masterson | 2015-05-17 14:57:13 -0700 |
| commit | 76f2d19edd7180874f9539897f674ae05d892419 (patch) | |
| tree | a338d5412064e49c47b652cee119cae97ce3d505 | |
| parent | e37da5a4a8055826f0fc1051083495a828509672 (diff) | |
| download | emacs-76f2d19edd7180874f9539897f674ae05d892419.tar.gz emacs-76f2d19edd7180874f9539897f674ae05d892419.zip | |
* 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.
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/eshell/em-term.el | 39 |
2 files changed, 33 insertions, 14 deletions
| @@ -681,6 +681,14 @@ buffers from eshell more convenient. Custom variable | |||
| 681 | `eshell-buffer-shorthand', which has been broken for a while, has been | 681 | `eshell-buffer-shorthand', which has been broken for a while, has been |
| 682 | removed. | 682 | removed. |
| 683 | 683 | ||
| 684 | *** By default, eshell "visual" program buffers (created by | ||
| 685 | `eshell-visual-commands' and similar custom vars) are no longer killed | ||
| 686 | when their processes die. This fixes issues with short-lived commands | ||
| 687 | and makes visual programs more useful in general. For example, if | ||
| 688 | "git log" is a visual command, it will always show the visual command | ||
| 689 | buffer, even if the "git log" process dies. For the old behavior, | ||
| 690 | make the new option `eshell-destroy-buffer-when-process-dies' non-nil. | ||
| 691 | |||
| 684 | ** Browse-url | 692 | ** Browse-url |
| 685 | 693 | ||
| 686 | *** Support for the Conkeror web browser. | 694 | *** Support for the Conkeror web browser. |
diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el index 4a6ac235449..9ac281372cf 100644 --- a/lisp/eshell/em-term.el +++ b/lisp/eshell/em-term.el | |||
| @@ -132,6 +132,13 @@ character to the invoked process." | |||
| 132 | :type 'boolean | 132 | :type 'boolean |
| 133 | :group 'eshell-term) | 133 | :group 'eshell-term) |
| 134 | 134 | ||
| 135 | (defcustom eshell-destroy-buffer-when-process-dies nil | ||
| 136 | "If non-nil, term buffers are destroyed after their processes die. | ||
| 137 | WARNING: Setting this to non-nil may result in unexpected | ||
| 138 | behavior for short-lived processes, see bug#18108." | ||
| 139 | :type 'boolean | ||
| 140 | :group 'eshell-term) | ||
| 141 | |||
| 135 | ;;; Internal Variables: | 142 | ;;; Internal Variables: |
| 136 | 143 | ||
| 137 | (defvar eshell-parent-buffer) | 144 | (defvar eshell-parent-buffer) |
| @@ -190,20 +197,24 @@ allowed." | |||
| 190 | nil) | 197 | nil) |
| 191 | 198 | ||
| 192 | ;; Process sentinels receive two arguments. | 199 | ;; Process sentinels receive two arguments. |
| 193 | (defun eshell-term-sentinel (proc _string) | 200 | (defun eshell-term-sentinel (proc msg) |
| 194 | "Destroy the buffer visiting PROC." | 201 | "Clean up the buffer visiting PROC. |
| 195 | (let ((proc-buf (process-buffer proc))) | 202 | If `eshell-destroy-buffer-when-process-dies' is non-nil, destroy |
| 196 | (when (and proc-buf (buffer-live-p proc-buf) | 203 | the buffer." |
| 197 | (not (eq 'run (process-status proc))) | 204 | (term-sentinel proc msg) ;; First call the normal term sentinel. |
| 198 | (= (process-exit-status proc) 0)) | 205 | (when eshell-destroy-buffer-when-process-dies |
| 199 | (if (eq (current-buffer) proc-buf) | 206 | (let ((proc-buf (process-buffer proc))) |
| 200 | (let ((buf (and (boundp 'eshell-parent-buffer) | 207 | (when (and proc-buf (buffer-live-p proc-buf) |
| 201 | eshell-parent-buffer | 208 | (not (eq 'run (process-status proc))) |
| 202 | (buffer-live-p eshell-parent-buffer) | 209 | (= (process-exit-status proc) 0)) |
| 203 | eshell-parent-buffer))) | 210 | (if (eq (current-buffer) proc-buf) |
| 204 | (if buf | 211 | (let ((buf (and (boundp 'eshell-parent-buffer) |
| 205 | (switch-to-buffer buf)))) | 212 | eshell-parent-buffer |
| 206 | (kill-buffer proc-buf)))) | 213 | (buffer-live-p eshell-parent-buffer) |
| 214 | eshell-parent-buffer))) | ||
| 215 | (if buf | ||
| 216 | (switch-to-buffer buf)))) | ||
| 217 | (kill-buffer proc-buf))))) | ||
| 207 | 218 | ||
| 208 | ;; jww (1999-09-17): The code below will allow Eshell to send input | 219 | ;; jww (1999-09-17): The code below will allow Eshell to send input |
| 209 | ;; characters directly to the currently running interactive process. | 220 | ;; characters directly to the currently running interactive process. |