Subject: bug#18108: [PATCH] 24.3.92 : eshell-visual-options fails with some output.

From: Samer Masterson <[email-masked]>
Date: Tue, 24 Feb 2015 02:54:34 -0800

Hi,

My copyright papers have been processed. Can we apply this to master?

Best,
Samer

Patch below:

Changes in 3e0d44a..b9f2247
2 files changed, 14 insertions(+), 37 deletions(-)
 ChangeLog | 6 ++++++
 lisp/eshell/em-term.el | 45
++++++++-------------------------------------

 Modified ChangeLog
diff --git a/ChangeLog b/ChangeLog
index 36edfe6..d09380a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-01-19 Samer Masterson <samer <at> samertm.com>
+
+	* eshell/em-term.el (eshell-exec-visual, eshell-term-sentinel):
+	Remove eshell-term-sentinel, show term-mode buffer regardless of
+	whether the process has died (bug#18108).
+
 2015-01-04 Paul Eggert <eggert <at> cs.ucla.edu>

  * INSTALL: Mention 'make WERROR_CFLAGS='.
 Modified lisp/eshell/em-term.el
diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el
index 4a6ac23..6870a6d 100644
--- a/lisp/eshell/em-term.el
+++ b/lisp/eshell/em-term.el
@@ -132,10 +132,6 @@ character to the invoked process."
   :type 'boolean
   :group 'eshell-term)

-;;; Internal Variables:
-
-(defvar eshell-parent-buffer)
-
 ;;; Functions:

 (defun eshell-term-initialize ()
@@ -171,39 +167,14 @@ allowed."
             (cdr args)))))
   (term-buf
    (generate-new-buffer
-	 (concat "*" (file-name-nondirectory program) "*")))
-	 (eshell-buf (current-buffer)))
- (save-current-buffer
- (switch-to-buffer term-buf)
- (term-mode)
- (set (make-local-variable 'term-term-name) eshell-term-name)
- (make-local-variable 'eshell-parent-buffer)
- (setq eshell-parent-buffer eshell-buf)
- (term-exec term-buf program program nil args)
- (let ((proc (get-buffer-process term-buf)))
-	(if (and proc (eq 'run (process-status proc)))
-	 (set-process-sentinel proc 'eshell-term-sentinel)
-	 (error "Failed to invoke visual command")))
- (term-char-mode)
- (if eshell-escape-control-x
-	 (term-set-escape-char ?\C-x))))
- 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))))
+	 (concat "*" (file-name-nondirectory program) "*"))))
+ (switch-to-buffer term-buf)
+ (term-mode)
+ (set (make-local-variable 'term-term-name) eshell-term-name)
+ (term-exec term-buf program program nil args)
+ (term-char-mode)
+ (if eshell-escape-control-x
+ (term-set-escape-char ?\C-x))))

 ;; jww (1999-09-17): The code below will allow Eshell to send input
 ;; characters directly to the currently running interactive process.