GNU bug report logs - #42870
[PATCH] Change eshell-output-filter to match the behavior of comint-output-filter

Previous Next

Package: emacs;

Reported by: Steven Allen <steven <at> stebalien.com>

Date: Sat, 15 Aug 2020 14:58:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 42870 in the body.
You can then email your comments to 42870 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#42870; Package emacs. (Sat, 15 Aug 2020 14:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Steven Allen <steven <at> stebalien.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 15 Aug 2020 14:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Steven Allen <steven <at> stebalien.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Change eshell-output-filter to match the behavior of
 comint-output-filter
Date: Fri, 14 Aug 2020 14:20:38 -0700
This change (a) sets the current buffer to the process-buffer when
invoking preoutput filter functions and (b) only invokes them when the
process-buffer is live. Otherwise, the preoutput filter functions be
invoked in whatever buffer happens to be focused, breaking hooks that
read buffer-local variables.

* lisp/eshell/esh-mode.el: (eshell-output-filter): Match
current-buffer behavior of comint-output-filter.
---
 lisp/eshell/esh-mode.el | 75 +++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 37 deletions(-)

diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index d0147b345aa..8799007c596 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -690,46 +690,47 @@ eshell-output-filter
   "Send the output from PROCESS (STRING) to the interactive display.
 This is done after all necessary filtering has been done."
   (let ((oprocbuf (if process (process-buffer process)
-		    (current-buffer)))
-	(inhibit-point-motion-hooks t)
-	(inhibit-modification-hooks t))
-    (let ((functions eshell-preoutput-filter-functions))
-      (while (and functions string)
-	(setq string (funcall (car functions) string))
-	(setq functions (cdr functions))))
-    (if (and string oprocbuf (buffer-name oprocbuf))
-	(let (opoint obeg oend)
-	  (with-current-buffer oprocbuf
-	    (setq opoint (point))
-	    (setq obeg (point-min))
-	    (setq oend (point-max))
-	    (let ((buffer-read-only nil)
-		  (nchars (length string))
-		  (ostart nil))
-	      (widen)
-	      (goto-char eshell-last-output-end)
-	      (setq ostart (point))
-	      (if (<= (point) opoint)
-		  (setq opoint (+ opoint nchars)))
-	      (if (< (point) obeg)
-		  (setq obeg (+ obeg nchars)))
-	      (if (<= (point) oend)
-		  (setq oend (+ oend nchars)))
+                    (current-buffer)))
+        (inhibit-point-motion-hooks t)
+        (inhibit-modification-hooks t))
+    (when (and string oprocbuf (buffer-name oprocbuf))
+      (with-current-buffer oprocbuf
+        (let ((functions eshell-preoutput-filter-functions))
+          (while (and functions string)
+            (setq string (funcall (car functions) string))
+            (setq functions (cdr functions))))
+        (when string
+          (let (opoint obeg oend)
+            (setq opoint (point))
+            (setq obeg (point-min))
+            (setq oend (point-max))
+            (let ((buffer-read-only nil)
+                  (nchars (length string))
+                  (ostart nil))
+              (widen)
+              (goto-char eshell-last-output-end)
+              (setq ostart (point))
+              (if (<= (point) opoint)
+                  (setq opoint (+ opoint nchars)))
+              (if (< (point) obeg)
+                  (setq obeg (+ obeg nchars)))
+              (if (<= (point) oend)
+                  (setq oend (+ oend nchars)))
               ;; Let the ansi-color overlay hooks run.
               (let ((inhibit-modification-hooks nil))
                 (insert-before-markers string))
-	      (if (= (window-start) (point))
-		  (set-window-start (selected-window)
-				    (- (point) nchars)))
-	      (if (= (point) eshell-last-input-end)
-		  (set-marker eshell-last-input-end
-			      (- eshell-last-input-end nchars)))
-	      (set-marker eshell-last-output-start ostart)
-	      (set-marker eshell-last-output-end (point))
-	      (force-mode-line-update))
-	    (narrow-to-region obeg oend)
-	    (goto-char opoint)
-	    (eshell-run-output-filters))))))
+              (if (= (window-start) (point))
+                  (set-window-start (selected-window)
+                                    (- (point) nchars)))
+              (if (= (point) eshell-last-input-end)
+                  (set-marker eshell-last-input-end
+                              (- eshell-last-input-end nchars)))
+              (set-marker eshell-last-output-start ostart)
+              (set-marker eshell-last-output-end (point))
+              (force-mode-line-update))
+            (narrow-to-region obeg oend)
+            (goto-char opoint)
+            (eshell-run-output-filters)))))))
 
 (defun eshell-run-output-filters ()
   "Run the `eshell-output-filter-functions' on the current output."
-- 
2.28.0





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42870; Package emacs. (Sun, 16 Aug 2020 12:33:02 GMT) Full text and rfc822 format available.

Message #8 received at 42870 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Steven Allen <steven <at> stebalien.com>
Cc: 42870 <at> debbugs.gnu.org
Subject: Re: bug#42870: [PATCH] Change eshell-output-filter to match the
 behavior of comint-output-filter
Date: Sun, 16 Aug 2020 14:32:38 +0200
Steven Allen <steven <at> stebalien.com> writes:

> This change (a) sets the current buffer to the process-buffer when
> invoking preoutput filter functions and (b) only invokes them when the
> process-buffer is live. Otherwise, the preoutput filter functions be
> invoked in whatever buffer happens to be focused, breaking hooks that
> read buffer-local variables.
>
> * lisp/eshell/esh-mode.el: (eshell-output-filter): Match
> current-buffer behavior of comint-output-filter.

There we a lot of unavoidable whitespace changes in the patch, so but if
I read it correctly, this sounds like the correct fix, so I've applied
your patch to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 16 Aug 2020 12:33:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 42870 <at> debbugs.gnu.org and Steven Allen <steven <at> stebalien.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 16 Aug 2020 12:33:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42870; Package emacs. (Sun, 16 Aug 2020 19:44:01 GMT) Full text and rfc822 format available.

Message #15 received at 42870 <at> debbugs.gnu.org (full text, mbox):

From: Steven Allen <steven <at> stebalien.com>
To: 42870 <at> debbugs.gnu.org
Subject: Re: bug#42870 acknowledged by developer         (control message
 for bug #42870)
Date: Sun, 16 Aug 2020 12:43:33 -0700
Thanks!

(FYI, `git show --word-diff` helps quite a bit)




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 14 Sep 2020 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 277 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.