unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61310: Eshell modifying and running output regression
@ 2023-02-06  4:18 Morgan Smith
  2023-02-06  5:51 ` Jim Porter
  0 siblings, 1 reply; 7+ messages in thread
From: Morgan Smith @ 2023-02-06  4:18 UTC (permalink / raw)
  To: jporterbugs, 61310

Hello,

eshell allows you to modify the output of a command and run it.  It is a
beautiful thing.

Example:

$ ls
file.el
$

now go up and append "file" to the output and hit enter.

$ ls
file file.el
$ file file.el
color.el: Lisp/Scheme program, Unicode text, UTF-8 text
$


The ability is currently broken because "file.el" has the field property
set to "command-output" and the "file" command that I added has no
property field.  So currently the previous interaction would actually
yield:

$ ls
file file.el
$ file.el
file.el: command not found
$


This was broken in commit 558f04c39e036d2f681f72556627768d7bee9ab5.  Now
adding the field to eshell prompt makes a lot of sense and I like that.
I don't know much about fields but it looks like it is not necessary to
have a command-output field at all.  I propose we get rid of that.  If
you want to keep the field, can we make it sticky or something?  I just
want the above usecase fixed.


Thanks,

Morgan





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#61310: Eshell modifying and running output regression
  2023-02-06  4:18 bug#61310: Eshell modifying and running output regression Morgan Smith
@ 2023-02-06  5:51 ` Jim Porter
  2023-02-06  5:59   ` Jim Porter
  0 siblings, 1 reply; 7+ messages in thread
From: Jim Porter @ 2023-02-06  5:51 UTC (permalink / raw)
  To: Morgan Smith, 61310

[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]

On 2/5/2023 8:18 PM, Morgan Smith wrote:
> eshell allows you to modify the output of a command and run it.  It is a
> beautiful thing.

Interesting. I didn't realize this was possible in Eshell (I only 
thought you could re-run old *inputs*).

> I don't know much about fields but it looks like it is not necessary to
> have a command-output field at all.  I propose we get rid of that.  If
> you want to keep the field, can we make it sticky or something? 

The output field is actually necessary (or else Eshell would need to be 
cleverer about some things). The main issue is that if a command doesn't 
output a newline, the command's output can end up on the same line as 
the prompt:

   ~ $ *echo -n [output]
   [output]~ $

If the output had no field, C-a would move to the very beginning of the 
line, not to the beginning of the input field. Maybe this is a bug in 
how fields are handled, but changing field handling in general is 
probably too risky.

So instead, let's make the output field sticky as you say. Here's a fix 
for that plus regression tests so this won't break in the future.

[-- Attachment #2: 0001-Ensure-that-Eshell-users-can-run-lines-of-command-ou.patch --]
[-- Type: text/plain, Size: 5184 bytes --]

From a0f49108386500f66e55a605497dee94dbd788d6 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 5 Feb 2023 21:37:08 -0800
Subject: [PATCH] Ensure that Eshell users can run lines of command output as
 input

Previously, this failed to work properly because any additional input
the user entered would have no 'field' property, confusing
'eshell-get-old-input'.  To fix this, we simply ensure that any
user-entered text in the output field retains said output field
(bug#61310).

* lisp/eshell/esh-util.el (eshell-command-output-properties): New
variable...
* lisp/eshell/esh-proc.el (eshell-interactive-process-filter):
* lisp/eshell/esh-mode.el (eshell-interactive-print): ... use it.
(eshell-get-old-input): Remove properties from the returned string
just to be safe.

* test/lisp/eshell/eshell-tests.el (eshell-test-value): New variable.
(eshell-test/get-old-input/rerun-command)
(eshell-test/get-old-input/run-output): New tests.
---
 lisp/eshell/esh-mode.el          |  5 ++---
 lisp/eshell/esh-proc.el          |  4 ++--
 lisp/eshell/esh-util.el          |  4 ++++
 test/lisp/eshell/eshell-tests.el | 28 ++++++++++++++++++++++++++++
 4 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 503d9ba1b63..e7ccf2b3aef 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -526,8 +526,7 @@ eshell-interactive-print
   "Print STRING to the eshell display buffer."
   (when string
     (add-text-properties 0 (length string)
-                         '(field command-output rear-nonsticky (field))
-                         string)
+                         eshell-command-output-properties string)
     (eshell-interactive-filter nil string)))
 
 (defsubst eshell-begin-on-new-line ()
@@ -891,7 +890,7 @@ eshell-get-old-input
       (let ((inhibit-field-text-motion)
             (end (point)))
         (beginning-of-line)
-        (buffer-substring (point) end)))))
+        (buffer-substring-no-properties (point) end)))))
 
 (defun eshell-copy-old-input ()
   "Insert after prompt old input at point as new input to be edited."
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index 27cd521e82e..02de619864a 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -24,6 +24,7 @@
 ;;; Code:
 
 (require 'esh-io)
+(require 'esh-util)
 
 (defgroup eshell-proc nil
   "When Eshell invokes external commands, it always does so
@@ -412,8 +413,7 @@ eshell-interactive-process-filter
 This is done after all necessary filtering has been done."
   (when string
     (add-text-properties 0 (length string)
-                         '(field command-output rear-nonsticky (field))
-                         string)
+                         eshell-command-output-properties string)
     (require 'esh-mode)
     (declare-function eshell-interactive-filter "esh-mode" (buffer string))
     (eshell-interactive-filter (if process (process-buffer process)
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 9549e7f1a10..fc0aee22f33 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -132,6 +132,10 @@ eshell-user-names
 (defvar eshell-user-timestamp nil
   "A timestamp of when the user file was read.")
 
+(defvar eshell-command-output-properties
+  '(field command-output front-sticky (field) rear-nonsticky (field))
+  "A list of text properties to apply to command output.")
+
 ;;; Obsolete variables:
 
 (define-obsolete-variable-alias 'eshell-host-names
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index 776cfb9b92f..f6a688b1b56 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -34,6 +34,8 @@
                            (file-name-directory (or load-file-name
                                                     default-directory))))
 
+(defvar eshell-test-value nil)
+
 ;;; Tests:
 
 (ert-deftest eshell-test/pipe-headproc ()
@@ -160,6 +162,32 @@ eshell-test/get-old-input
      (beginning-of-line))
    (should (string= (eshell-get-old-input) "echo alpha"))))
 
+(ert-deftest eshell-test/get-old-input/rerun-command ()
+  "Test that we can rerun an old command when point is on it."
+  (with-temp-eshell
+   (let ((eshell-test-value "first"))
+     (eshell-match-command-output "echo $eshell-test-value" "first"))
+   ;; Go to the previous prompt.
+   (forward-line -2)
+   (let ((inhibit-field-text-motion t))
+     (end-of-line))
+   ;; Rerun the command, but with a different variable value.
+   (let ((eshell-test-value "second"))
+     (eshell-send-input))
+   (eshell-match-output "second")))
+
+(ert-deftest eshell-test/get-old-input/run-output ()
+  "Test that we can run a line of output as a command when point is on it."
+  (with-temp-eshell
+   (eshell-match-command-output "echo \"echo there\"" "echo there")
+   ;; Go to the output, and insert "hello" after "echo".
+   (forward-line -1)
+   (forward-word)
+   (insert-and-inherit " hello")
+   ;; Run the line as a command.
+   (eshell-send-input)
+   (eshell-match-output "(\"hello\" \"there\")")))
+
 (provide 'eshell-tests)
 
 ;;; eshell-tests.el ends here
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#61310: Eshell modifying and running output regression
  2023-02-06  5:51 ` Jim Porter
@ 2023-02-06  5:59   ` Jim Porter
  2023-02-07 18:20     ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 7+ messages in thread
From: Jim Porter @ 2023-02-06  5:59 UTC (permalink / raw)
  To: Morgan Smith, 61310

[-- Attachment #1: Type: text/plain, Size: 267 bytes --]

On 2/5/2023 9:51 PM, Jim Porter wrote:
> So instead, let's make the output field sticky as you say. Here's a fix 
> for that plus regression tests so this won't break in the future.

... and here's a fixed patch that un-breaks a couple other Eshell 
regression tests.

[-- Attachment #2: 0001-Ensure-that-Eshell-users-can-run-lines-of-command-ou.patch --]
[-- Type: text/plain, Size: 6567 bytes --]

From a754e711e21cd306e7c4307d8f86819b6e8c672c Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 5 Feb 2023 21:37:08 -0800
Subject: [PATCH] Ensure that Eshell users can run lines of command output as
 input

Previously, this failed to work properly because any additional input
the user entered would have no 'field' property, confusing
'eshell-get-old-input'.  To fix this, we simply ensure that any
user-entered text in the output field retains said output field
(bug#61310).

* lisp/eshell/esh-util.el (eshell-command-output-properties): New
variable...
* lisp/eshell/esh-proc.el (eshell-interactive-process-filter):
* lisp/eshell/esh-mode.el (eshell-interactive-print): ... use it.
(eshell-get-old-input): Remove properties from the returned string
just to be safe.

* test/lisp/eshell/eshell-tests.el (eshell-test-value): New variable.
(eshell-test/get-old-input/rerun-command)
(eshell-test/get-old-input/run-output): New tests.

* test/lisp/eshell/em-prompt-tests.el
(em-prompt-test/field-properties)
(em-prompt-test/field-properties/no-highlight): Check for new
'front-sticky' property on output.
---
 lisp/eshell/esh-mode.el             |  5 ++---
 lisp/eshell/esh-proc.el             |  4 ++--
 lisp/eshell/esh-util.el             |  4 ++++
 test/lisp/eshell/em-prompt-tests.el |  6 ++++--
 test/lisp/eshell/eshell-tests.el    | 28 ++++++++++++++++++++++++++++
 5 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 503d9ba1b63..e7ccf2b3aef 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -526,8 +526,7 @@ eshell-interactive-print
   "Print STRING to the eshell display buffer."
   (when string
     (add-text-properties 0 (length string)
-                         '(field command-output rear-nonsticky (field))
-                         string)
+                         eshell-command-output-properties string)
     (eshell-interactive-filter nil string)))
 
 (defsubst eshell-begin-on-new-line ()
@@ -891,7 +890,7 @@ eshell-get-old-input
       (let ((inhibit-field-text-motion)
             (end (point)))
         (beginning-of-line)
-        (buffer-substring (point) end)))))
+        (buffer-substring-no-properties (point) end)))))
 
 (defun eshell-copy-old-input ()
   "Insert after prompt old input at point as new input to be edited."
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index 27cd521e82e..02de619864a 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -24,6 +24,7 @@
 ;;; Code:
 
 (require 'esh-io)
+(require 'esh-util)
 
 (defgroup eshell-proc nil
   "When Eshell invokes external commands, it always does so
@@ -412,8 +413,7 @@ eshell-interactive-process-filter
 This is done after all necessary filtering has been done."
   (when string
     (add-text-properties 0 (length string)
-                         '(field command-output rear-nonsticky (field))
-                         string)
+                         eshell-command-output-properties string)
     (require 'esh-mode)
     (declare-function eshell-interactive-filter "esh-mode" (buffer string))
     (eshell-interactive-filter (if process (process-buffer process)
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 9549e7f1a10..fc0aee22f33 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -132,6 +132,10 @@ eshell-user-names
 (defvar eshell-user-timestamp nil
   "A timestamp of when the user file was read.")
 
+(defvar eshell-command-output-properties
+  '(field command-output front-sticky (field) rear-nonsticky (field))
+  "A list of text properties to apply to command output.")
+
 ;;; Obsolete variables:
 
 (define-obsolete-variable-alias 'eshell-host-names
diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prompt-tests.el
index db45e2ae3a7..c4cdc2dffc5 100644
--- a/test/lisp/eshell/em-prompt-tests.el
+++ b/test/lisp/eshell/em-prompt-tests.el
@@ -54,7 +54,8 @@ em-prompt-test/field-properties
      (should (equal last-input "echo hello\n"))
      (should (equal-including-properties
               last-output
-              (propertize "hello\n" 'rear-nonsticky '(field)
+              (propertize "hello\n" 'front-sticky '(field)
+                          'rear-nonsticky '(field)
                           'field 'command-output))))))
 
 (ert-deftest em-prompt-test/field-properties/no-highlight ()
@@ -77,7 +78,8 @@ em-prompt-test/field-properties/no-highlight
        (should (equal last-input "echo hello\n"))
        (should (equal-including-properties
                 last-output
-                (propertize "hello\n" 'rear-nonsticky '(field)
+                (propertize "hello\n" 'front-sticky '(field)
+                            'rear-nonsticky '(field)
                             'field 'command-output)))))))
 
 (ert-deftest em-prompt-test/next-previous-prompt ()
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index 776cfb9b92f..f6a688b1b56 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -34,6 +34,8 @@
                            (file-name-directory (or load-file-name
                                                     default-directory))))
 
+(defvar eshell-test-value nil)
+
 ;;; Tests:
 
 (ert-deftest eshell-test/pipe-headproc ()
@@ -160,6 +162,32 @@ eshell-test/get-old-input
      (beginning-of-line))
    (should (string= (eshell-get-old-input) "echo alpha"))))
 
+(ert-deftest eshell-test/get-old-input/rerun-command ()
+  "Test that we can rerun an old command when point is on it."
+  (with-temp-eshell
+   (let ((eshell-test-value "first"))
+     (eshell-match-command-output "echo $eshell-test-value" "first"))
+   ;; Go to the previous prompt.
+   (forward-line -2)
+   (let ((inhibit-field-text-motion t))
+     (end-of-line))
+   ;; Rerun the command, but with a different variable value.
+   (let ((eshell-test-value "second"))
+     (eshell-send-input))
+   (eshell-match-output "second")))
+
+(ert-deftest eshell-test/get-old-input/run-output ()
+  "Test that we can run a line of output as a command when point is on it."
+  (with-temp-eshell
+   (eshell-match-command-output "echo \"echo there\"" "echo there")
+   ;; Go to the output, and insert "hello" after "echo".
+   (forward-line -1)
+   (forward-word)
+   (insert-and-inherit " hello")
+   ;; Run the line as a command.
+   (eshell-send-input)
+   (eshell-match-output "(\"hello\" \"there\")")))
+
 (provide 'eshell-tests)
 
 ;;; eshell-tests.el ends here
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#61310: Eshell modifying and running output regression
  2023-02-06  5:59   ` Jim Porter
@ 2023-02-07 18:20     ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-02-07 23:37       ` Jim Porter
  0 siblings, 1 reply; 7+ messages in thread
From: miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-02-07 18:20 UTC (permalink / raw)
  To: Jim Porter, Morgan Smith, 61310

[-- Attachment #1: Type: text/plain, Size: 224 bytes --]

You might also be interested in how comint deals with this. It can
handle the case when the user yanks something in the middle of output as
well. See function comint--mark-as-output, bug#3735 and bug#18135 for
more details.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#61310: Eshell modifying and running output regression
  2023-02-07 18:20     ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-02-07 23:37       ` Jim Porter
  2023-02-10  6:39         ` Jim Porter
  0 siblings, 1 reply; 7+ messages in thread
From: Jim Porter @ 2023-02-07 23:37 UTC (permalink / raw)
  To: miha, Morgan Smith, 61310

[-- Attachment #1: Type: text/plain, Size: 425 bytes --]

On 2/7/2023 10:20 AM, miha--- via Bug reports for GNU Emacs, the Swiss 
army knife of text editors wrote:
> You might also be interested in how comint deals with this. It can
> handle the case when the user yanks something in the middle of output as
> well. See function comint--mark-as-output, bug#3735 and bug#18135 for
> more details.

Good call. Here's a patch that (mostly) copies those comint functions 
over to Eshell.

[-- Attachment #2: 0001-Ensure-that-Eshell-users-can-run-lines-of-command-ou.patch --]
[-- Type: text/plain, Size: 8508 bytes --]

From bd3bc93e00056241968cc6710e0864eafe8d709a Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 5 Feb 2023 21:37:08 -0800
Subject: [PATCH] Ensure that Eshell users can run lines of command output as
 input

Previously, this failed to work properly because any additional input
the user entered would have no 'field' property, confusing
'eshell-get-old-input'.  To fix this, we simply ensure that any
user-entered text in the output field retains said output field
(bug#61310).

* lisp/eshell/esh-util.el (eshell-command-output-properties): New
variable.
(eshell--mark-as-output, eshell--mark-yanked-as-output): New
functions, mostly copied from comint.

* lisp/eshell/esh-proc.el (eshell-interactive-process-filter):
* lisp/eshell/esh-mode.el (eshell-interactive-print): Call
'eshell--mark-as-output'.
(eshell-get-old-input): Remove properties from the returned string
just to be safe.

* test/lisp/eshell/eshell-tests.el (eshell-test-value): New variable.
(eshell-test/get-old-input/rerun-command)
(eshell-test/get-old-input/run-output): New tests.

* test/lisp/eshell/em-prompt-tests.el
(em-prompt-test/field-properties)
(em-prompt-test/field-properties/no-highlight): Use
'eshell-command-output-properties'.
---
 lisp/eshell/esh-mode.el             |  6 ++---
 lisp/eshell/esh-proc.el             |  5 ++---
 lisp/eshell/esh-util.el             | 34 +++++++++++++++++++++++++++++
 test/lisp/eshell/em-prompt-tests.el |  8 +++----
 test/lisp/eshell/eshell-tests.el    | 28 ++++++++++++++++++++++++
 5 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 503d9ba1b63..654e26777e0 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -525,9 +525,7 @@ eshell-goto-input-start
 (defun eshell-interactive-print (string)
   "Print STRING to the eshell display buffer."
   (when string
-    (add-text-properties 0 (length string)
-                         '(field command-output rear-nonsticky (field))
-                         string)
+    (eshell--mark-as-output 0 (length string) string)
     (eshell-interactive-filter nil string)))
 
 (defsubst eshell-begin-on-new-line ()
@@ -891,7 +889,7 @@ eshell-get-old-input
       (let ((inhibit-field-text-motion)
             (end (point)))
         (beginning-of-line)
-        (buffer-substring (point) end)))))
+        (buffer-substring-no-properties (point) end)))))
 
 (defun eshell-copy-old-input ()
   "Insert after prompt old input at point as new input to be edited."
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index 27cd521e82e..a86e7502795 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -24,6 +24,7 @@
 ;;; Code:
 
 (require 'esh-io)
+(require 'esh-util)
 
 (defgroup eshell-proc nil
   "When Eshell invokes external commands, it always does so
@@ -411,9 +412,7 @@ eshell-interactive-process-filter
   "Send the output from PROCESS (STRING) to the interactive display.
 This is done after all necessary filtering has been done."
   (when string
-    (add-text-properties 0 (length string)
-                         '(field command-output rear-nonsticky (field))
-                         string)
+    (eshell--mark-as-output 0 (length string) string)
     (require 'esh-mode)
     (declare-function eshell-interactive-filter "esh-mode" (buffer string))
     (eshell-interactive-filter (if process (process-buffer process)
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 9549e7f1a10..c0685757789 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -132,6 +132,19 @@ eshell-user-names
 (defvar eshell-user-timestamp nil
   "A timestamp of when the user file was read.")
 
+(defvar eshell-command-output-properties
+  `( field command-output
+     front-sticky (field)
+     rear-nonsticky (field)
+     ;; Text inserted by a user in the middle of process output
+     ;; should be marked as output.  This is needed for commands
+     ;; such as `yank' or `just-one-space' which don't use
+     ;; `insert-and-inherit' and thus bypass default text property
+     ;; inheritance.
+     insert-in-front-hooks (,#'eshell--mark-as-output
+                            ,#'eshell--mark-yanked-as-output))
+  "A list of text properties to apply to command output.")
+
 ;;; Obsolete variables:
 
 (define-obsolete-variable-alias 'eshell-host-names
@@ -157,6 +170,27 @@ eshell-condition-case
 	 ,@handlers)
     form))
 
+(defun eshell--mark-as-output (start end &optional object)
+  "Mark the text from START to END as Eshell output.
+OBJECT can be a buffer or string.  If nil, mark the text in the
+current buffer."
+  (with-silent-modifications
+    (add-text-properties start end eshell-command-output-properties
+                         object)))
+
+(defun eshell--mark-yanked-as-output (start end)
+  "Mark yanked text from START to END as Eshell output."
+  ;; `yank' removes the field text property from the text it inserts
+  ;; due to `yank-excluded-properties', so arrange for this text
+  ;; property to be reapplied in the `after-change-functions'.
+  (letrec ((hook
+            (lambda (start1 end1 _len1)
+              (remove-hook 'after-change-functions hook t)
+              (when (and (= start start1)
+                         (= end end1))
+                (eshell--mark-as-output start1 end1)))))
+    (add-hook 'after-change-functions hook nil t)))
+
 (defun eshell-find-delimiter
   (open close &optional bound reverse-p backslash-p)
   "From point, find the CLOSE delimiter corresponding to OPEN.
diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prompt-tests.el
index db45e2ae3a7..257549e40fb 100644
--- a/test/lisp/eshell/em-prompt-tests.el
+++ b/test/lisp/eshell/em-prompt-tests.el
@@ -54,8 +54,8 @@ em-prompt-test/field-properties
      (should (equal last-input "echo hello\n"))
      (should (equal-including-properties
               last-output
-              (propertize "hello\n" 'rear-nonsticky '(field)
-                          'field 'command-output))))))
+              (apply #'propertize "hello\n"
+                     eshell-command-output-properties))))))
 
 (ert-deftest em-prompt-test/field-properties/no-highlight ()
   "Check that field properties are properly set on Eshell output/prompts.
@@ -77,8 +77,8 @@ em-prompt-test/field-properties/no-highlight
        (should (equal last-input "echo hello\n"))
        (should (equal-including-properties
                 last-output
-                (propertize "hello\n" 'rear-nonsticky '(field)
-                            'field 'command-output)))))))
+                (apply #'propertize "hello\n"
+                       eshell-command-output-properties)))))))
 
 (ert-deftest em-prompt-test/next-previous-prompt ()
   "Check that navigating forward/backward through old prompts works correctly."
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index 776cfb9b92f..743cc28b9b5 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -34,6 +34,8 @@
                            (file-name-directory (or load-file-name
                                                     default-directory))))
 
+(defvar eshell-test-value nil)
+
 ;;; Tests:
 
 (ert-deftest eshell-test/pipe-headproc ()
@@ -160,6 +162,32 @@ eshell-test/get-old-input
      (beginning-of-line))
    (should (string= (eshell-get-old-input) "echo alpha"))))
 
+(ert-deftest eshell-test/get-old-input/rerun-command ()
+  "Test that we can rerun an old command when point is on it."
+  (with-temp-eshell
+   (let ((eshell-test-value "first"))
+     (eshell-match-command-output "echo $eshell-test-value" "first"))
+   ;; Go to the previous prompt.
+   (forward-line -2)
+   (let ((inhibit-field-text-motion t))
+     (end-of-line))
+   ;; Rerun the command, but with a different variable value.
+   (let ((eshell-test-value "second"))
+     (eshell-send-input))
+   (eshell-match-output "second")))
+
+(ert-deftest eshell-test/get-old-input/run-output ()
+  "Test that we can run a line of output as a command when point is on it."
+  (with-temp-eshell
+   (eshell-match-command-output "echo \"echo there\"" "echo there")
+   ;; Go to the output, and insert "hello" after "echo".
+   (forward-line -1)
+   (forward-word)
+   (insert " hello")
+   ;; Run the line as a command.
+   (eshell-send-input)
+   (eshell-match-output "(\"hello\" \"there\")")))
+
 (provide 'eshell-tests)
 
 ;;; eshell-tests.el ends here
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#61310: Eshell modifying and running output regression
  2023-02-07 23:37       ` Jim Porter
@ 2023-02-10  6:39         ` Jim Porter
  2023-02-24 17:59           ` Jim Porter
  0 siblings, 1 reply; 7+ messages in thread
From: Jim Porter @ 2023-02-10  6:39 UTC (permalink / raw)
  To: miha, Morgan Smith, 61310

On 2/7/2023 3:37 PM, Jim Porter wrote:
> Good call. Here's a patch that (mostly) copies those comint functions 
> over to Eshell.

Ok, pushed this as ab7c2f8092.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#61310: Eshell modifying and running output regression
  2023-02-10  6:39         ` Jim Porter
@ 2023-02-24 17:59           ` Jim Porter
  0 siblings, 0 replies; 7+ messages in thread
From: Jim Porter @ 2023-02-24 17:59 UTC (permalink / raw)
  To: miha, Morgan Smith, 61310-done

On 2/9/2023 10:39 PM, Jim Porter wrote:
> On 2/7/2023 3:37 PM, Jim Porter wrote:
>> Good call. Here's a patch that (mostly) copies those comint functions 
>> over to Eshell.
> 
> Ok, pushed this as ab7c2f8092.

Since no one has complained that my fix didn't work in the past couple 
weeks, I'm assuming all is well here. Closing. (But if it's still 
broken, just let me know.)





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-02-24 17:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06  4:18 bug#61310: Eshell modifying and running output regression Morgan Smith
2023-02-06  5:51 ` Jim Porter
2023-02-06  5:59   ` Jim Porter
2023-02-07 18:20     ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-07 23:37       ` Jim Porter
2023-02-10  6:39         ` Jim Porter
2023-02-24 17:59           ` Jim Porter

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).