]> git.eshelyaron.com Git - emacs.git/commitdiff
; Mark interactive Eshell output as such after inserting into the buffer
authorJim Porter <jporterbugs@gmail.com>
Thu, 17 Oct 2024 21:30:31 +0000 (14:30 -0700)
committerEshel Yaron <me@eshelyaron.com>
Tue, 22 Oct 2024 18:51:04 +0000 (20:51 +0200)
This avoids adding the "output" text properties to strings that may live
past the call to 'eshell-interactive-filter'.

* lisp/eshell/esh-mode.el (eshell-interactive-output-filter): New
function...
(eshell-interactive-print): ... call it.
(eshell-interactive-filter): Update docstring.

* lisp/eshell/esh-proc.el (eshell-interactive-process-filter)
(eshell-sentinel): Call 'eshell-interactive-output-filter'.

(cherry picked from commit 83e3ed651dca46214855552aa062cfbde019b04a)

lisp/eshell/esh-mode.el
lisp/eshell/esh-proc.el

index 34ce82cfbc427d385b0445263cfaaf38fab705dc..ead5a20bec82cf1a2b071f62d92806171ecd5de4 100644 (file)
@@ -530,8 +530,7 @@ Putting this function on `eshell-pre-command-hook' will mimic Plan 9's
 (defun eshell-interactive-print (string)
   "Print STRING to the eshell display buffer."
   (when string
-    (eshell--mark-as-output 0 (length string) string)
-    (eshell-interactive-filter nil string)))
+    (eshell-interactive-output-filter nil string)))
 
 (defsubst eshell-begin-on-new-line ()
   "This function outputs a newline if not at beginning of line."
@@ -685,7 +684,7 @@ newline."
 (custom-add-option 'eshell-input-filter-functions 'eshell-kill-new)
 
 (defun eshell-interactive-filter (buffer string)
-  "Send output (STRING) to the interactive display, using BUFFER.
+  "Send STRING to the interactive display, using BUFFER.
 This is done after all necessary filtering has been done."
   (unless buffer
     (setq buffer (current-buffer)))
@@ -725,6 +724,17 @@ This is done after all necessary filtering has been done."
           (goto-char opoint)
           (eshell-run-output-filters))))))
 
+(defun eshell-interactive-output-filter (buffer string)
+  "Send STRING to the interactive display as command output, using BUFFER.
+This is like `eshell-interactive-filter', but marks the inserted string
+as command output (see `eshell--mark-as-output')."
+  (let ((eshell-output-filter-functions
+         (cons (lambda ()
+                 (eshell--mark-as-output eshell-last-output-start
+                                         eshell-last-output-end))
+               eshell-output-filter-functions)))
+    (eshell-interactive-filter buffer string)))
+
 (defun eshell-run-output-filters ()
   "Run the `eshell-output-filter-functions' on the current output."
   (save-current-buffer
index b579a93e14c5a64d0c8db020ae3283e31f38f980..87c95d3960394e1f94fe0a871089abda17d8d9ef 100644 (file)
@@ -128,7 +128,7 @@ To add or remove elements of this list, see
 
 (declare-function eshell-reset "esh-mode" (&optional no-hooks))
 (declare-function eshell-send-eof-to-process "esh-mode")
-(declare-function eshell-interactive-filter "esh-mode" (buffer string))
+(declare-function eshell-interactive-output-filter "esh-mode" (buffer string))
 (declare-function eshell-set-exit-info "esh-cmd" (status result))
 (declare-function eshell-tail-process "esh-cmd")
 
@@ -483,10 +483,9 @@ This is done after all necessary filtering has been done."
   (when string
     (eshell-debug-command 'process
       "received output from process `%s'\n\n%s" process string)
-    (eshell--mark-as-output 0 (length string) string)
-    (eshell-interactive-filter (if process (process-buffer process)
-                                 (current-buffer))
-                               string)))
+    (eshell-interactive-output-filter (if process (process-buffer process)
+                                        (current-buffer))
+                                      string)))
 
 (define-obsolete-function-alias 'eshell-output-filter
   #'eshell-interactive-process-filter "30.1")
@@ -559,8 +558,7 @@ PROC is the process that's exiting.  STRING is the exit message."
                        (eshell-interactive-output-p eshell-error-handle handles)
                        (not (string-match "^\\(finished\\|exited\\)"
                                           string)))
-              (eshell--mark-as-output 0 (length string) string)
-              (eshell-interactive-filter (process-buffer proc) string))
+              (eshell-interactive-output-filter (process-buffer proc) string))
             (process-put proc :eshell-pending nil)
             ;; If we're in the middle of handling output from this
             ;; process then schedule the EOF for later.