From 4ed0543c9235f97748d4a4913cfdce03fee0e17c Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Thu, 10 Feb 2022 19:54:28 -0800 Subject: evil-read: Make point end up at the last line of any shell output --- evil-commands.el | 6 +++--- evil-tests.el | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index 7c6a299..ff8ee3f 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -3205,9 +3205,9 @@ If no FILE is specified, reload the current buffer from disk." (unless (bolp) (insert "\n"))))) (t (shell-command (evil-ex-replace-special-filenames (substring file 1)) t) - (save-excursion - (goto-char (mark)) - (unless (bolp) (insert "\n"))))))) + (goto-char (mark)) + (unless (bolp) (insert "\n")) + (forward-line -1))))) (evil-define-command evil-show-files () "Shows the file-list. diff --git a/evil-tests.el b/evil-tests.el index eb638cf..0e313b5 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -8149,6 +8149,13 @@ maybe we need one line more with some text\n") (buffer-file-name) "\n" "2\n" "1\n"))))) + (ert-info ("Ensure that point ends up at the last line of shell output, if any") + (evil-with-temp-file name + "3\n2\n1\n" + (evil-test-buffer + "[l]ine 1\nline 2" + ((vconcat ":read !cat " name [return])) + "line 1\n3\n2\n[1]\nline 2"))) (ert-info ("Test insertion of shell command without trailing newline") (ert-info ("with space") (evil-test-buffer -- cgit v1.0