emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil e7c019291b 1/2: evil-read: Perform % and # substituti


From: ELPA Syncer
Subject: [nongnu] elpa/evil e7c019291b 1/2: evil-read: Perform % and # substitutions for shell cmds
Date: Sun, 13 Feb 2022 18:57:54 -0500 (EST)

branch: elpa/evil
commit e7c019291bb2746fc8243e140dc95229728aee50
Author: Brian Leung <leungbk@posteo.net>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>

    evil-read: Perform % and # substitutions for shell cmds
---
 evil-commands.el | 18 +++++++++++-------
 evil-tests.el    | 12 ++++++++++++
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/evil-commands.el b/evil-commands.el
index d09da35fe8..7c6a299b3d 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -3195,15 +3195,19 @@ If no FILE is specified, reload the current buffer from 
disk."
     (when (or (not (zerop (forward-line (or count 1))))
               (not (bolp)))
       (insert "\n"))
-    (if (/= (aref file 0) ?!)
-        (let ((result (insert-file-contents file)))
-          (save-excursion
-            (forward-char (cadr result))
-            (unless (bolp) (insert "\n"))))
-      (shell-command (substring file 1) t)
+    (cond
+     ((/= (aref file 0) ?!)
+      (when (member file '("#" "%"))
+        (setq file (evil-ex-replace-special-filenames file)))
+      (let ((result (insert-file-contents file)))
+        (save-excursion
+          (forward-char (cadr result))
+          (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"))))))
+        (unless (bolp) (insert "\n")))))))
 
 (evil-define-command evil-show-files ()
   "Shows the file-list.
diff --git a/evil-tests.el b/evil-tests.el
index 73eed9e902..eb638cf074 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -8137,6 +8137,18 @@ maybe we need one line more with some text\n")
           "[l]line 1\nline 2"
           (":read!echo cmd line 1" [return])
           "line 1\n[c]md line 1\nline 2")))
+    (ert-info ("Test substitution of % in shell commands")
+      (evil-with-temp-file name
+          "3\n2\n1\n"
+        (evil-test-buffer
+          ((vconcat ":e " name [return]))
+          "[3]\n2\n1\n"
+          ((vconcat ":read !echo %" [return]))
+          ((vconcat ":w " [return]))
+          (file name (concat "3\n"
+                             (buffer-file-name) "\n"
+                             "2\n"
+                             "1\n")))))
     (ert-info ("Test insertion of shell command without trailing newline")
       (ert-info ("with space")
         (evil-test-buffer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]