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

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

[nongnu] elpa/evil-surround 2bc8aa6425 160/175: Merge pull request #186


From: ELPA Syncer
Subject: [nongnu] elpa/evil-surround 2bc8aa6425 160/175: Merge pull request #186 from leungbk/prefix-calls
Date: Mon, 9 Oct 2023 13:01:16 -0400 (EDT)

branch: elpa/evil-surround
commit 2bc8aa6425f1311e985cf51ea6b5233c1ee6ce1c
Merge: 648da3c544 191ad92fb8
Author: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #186 from leungbk/prefix-calls
    
    Add support for surrounding with function calls in prefix form
---
 evil-surround.el           |  8 ++++++++
 test/evil-surround-test.el | 10 ++++++++++
 2 files changed, 18 insertions(+)

diff --git a/evil-surround.el b/evil-surround.el
index 942e25209a..e20e0cd97a 100644
--- a/evil-surround.el
+++ b/evil-surround.el
@@ -64,6 +64,7 @@
     (?> . ("<" . ">"))
     (?t . evil-surround-read-tag)
     (?< . evil-surround-read-tag)
+    (?\C-f . evil-surround-prefix-function)
     (?f . evil-surround-function))
   "Association list of surround items.
 Each item is of the form (TRIGGER . (LEFT . RIGHT)), all strings.
@@ -132,6 +133,13 @@ Each item is of the form (OPERATOR . OPERATION)."
     (cons (format "%s(" (or fname ""))
           ")")))
 
+(defun evil-surround-prefix-function ()
+  "Read a function name from the minibuffer and wrap selection in a
+function call in prefixed form."
+  (let ((fname (evil-surround-read-from-minibuffer "prefix function: " "")))
+    (cons (format "(%s " (or fname ""))
+          ")")))
+
 (defconst evil-surround-tag-name-re "\\([0-9a-zA-Z\.-]+\\)"
   "Regexp matching an XML tag name.")
 
diff --git a/test/evil-surround-test.el b/test/evil-surround-test.el
index 1da5d37d8b..44662f580e 100644
--- a/test/evil-surround-test.el
+++ b/test/evil-surround-test.el
@@ -99,6 +99,16 @@
       "function(argument1) argument2"
       ("W.")
       "function(argument1) function(argument2)"))
+  (ert-info ("prefix-function surrounding with dot repeat")
+    (evil-test-buffer
+      :visual-start nil
+      :visual-end nil
+      "argument1 argument2"
+      (turn-on-evil-surround-mode)
+      ("ysiw\C-ffunction" [return])
+      "(function argument1) argument2"
+      ("WW.")
+      "(function argument1) (function argument2)"))
   (ert-info ("even more examples from readme: tag surrounding with dot repeat")
     (evil-test-buffer
       :visual-start nil



reply via email to

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