1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-23 10:34:07 +00:00

Fix behavior of Eshell prompt when yanking output into it

* lisp/eshell/esh-util.el (eshell--unmark-string-as-output): New
function...

* lisp/eshell/esh-mode.el (eshell-mode): ... use it.

* test/lisp/eshell/eshell-tests.el (eshell-test/yank-output): New test
(bug#66469).
This commit is contained in:
Jim Porter 2023-10-11 11:38:27 -07:00
parent cfed3bb395
commit 60f6952853
3 changed files with 30 additions and 0 deletions

View File

@ -361,6 +361,9 @@ and the hook `eshell-exit-hook'."
(setq-local eshell-last-output-end (point-marker))
(setq-local eshell-last-output-block-begin (point))
(add-function :filter-return (local 'filter-buffer-substring-function)
#'eshell--unmark-string-as-output)
(let ((modules-list (copy-sequence eshell-modules-list)))
(setq-local eshell-modules-list modules-list))

View File

@ -234,6 +234,14 @@ current buffer."
(eshell--mark-as-output start1 end1)))))
(add-hook 'after-change-functions hook nil t)))
(defun eshell--unmark-string-as-output (string)
"Unmark STRING as Eshell output."
(remove-list-of-text-properties
0 (length string)
'(rear-nonsticky front-sticky field insert-in-front-hooks)
string)
string)
(defun eshell-find-delimiter
(open close &optional bound reverse-p backslash-p)
"From point, find the CLOSE delimiter corresponding to OPEN.

View File

@ -195,6 +195,25 @@ insert the queued one at the next prompt, and finally run it."
(eshell-send-input)
(eshell-match-output "(\"hello\" \"there\")")))
(ert-deftest eshell-test/yank-output ()
"Test that yanking a line of output into the next prompt works (bug#66469)."
(with-temp-eshell
(eshell-insert-command "echo hello")
;; Go to the output and kill the line of text.
(forward-line -1)
(kill-line)
;; Go to the last prompt and yank the previous output.
(goto-char (point-max))
(yank)
;; Go to the beginning of the prompt and add some text.
(move-beginning-of-line 1)
(insert-and-inherit "echo ")
;; Make sure when we go to the beginning of the line, we go to the
;; right spot (before the "echo").
(move-end-of-line 1)
(move-beginning-of-line 1)
(should (looking-at "echo hello"))))
(provide 'eshell-tests)
;;; eshell-tests.el ends here