summaryrefslogtreecommitdiff
path: root/lisp/eshell
diff options
context:
space:
mode:
authorMiha Rihtaršič <miha@kamnitnik.top>2021-11-08 00:10:03 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-11-08 00:10:03 +0100
commit4268d9a2b6bc96c0ae2448c6694bbd765fc577a7 (patch)
tree635a5716671301718d8459698fb8f2dee879aa4a /lisp/eshell
parent5f70682d7b8a3550bf6b9366329ad3418ab0a95f (diff)
downloademacs-4268d9a2b6bc96c0ae2448c6694bbd765fc577a7.tar.gz
emacs-4268d9a2b6bc96c0ae2448c6694bbd765fc577a7.tar.bz2
emacs-4268d9a2b6bc96c0ae2448c6694bbd765fc577a7.zip
Improve undoing of RET in comint and eshell
* lisp/comint.el (comint-send-input): (comint-accumulate): * lisp/eshell/esh-mode.el (eshell-send-input): Before sending input to the process, delete it and reinsert it again. Undoing this insertion with 'C-/' will delete the region, moving the process mark back to its original position (bug#49484).
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/esh-mode.el8
1 files changed, 8 insertions, 0 deletions
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 2b5a4647e06..a054cd66e27 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -616,6 +616,14 @@ newline."
(and eshell-send-direct-to-subprocesses
proc-running-p))
(insert-before-markers-and-inherit ?\n))
+ ;; Delete and reinsert input. This seems like a no-op, except
+ ;; for the resulting entries in the undo list: undoing this
+ ;; insertion will delete the region, moving the process mark
+ ;; back to its original position.
+ (let ((text (buffer-substring eshell-last-output-end (point)))
+ (inhibit-read-only t))
+ (delete-region eshell-last-output-end (point))
+ (insert text))
(if proc-running-p
(progn
(eshell-update-markers eshell-last-output-end)