[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-surround 1d6b1bac4e 027/175: Add wrap in function cal
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-surround 1d6b1bac4e 027/175: Add wrap in function call |
Date: |
Mon, 9 Oct 2023 13:01:01 -0400 (EDT) |
branch: elpa/evil-surround
commit 1d6b1bac4e63cee94599ccf91fddec4034465f0d
Author: IsoLinearCHiP <isolin.chip@gmail.com>
Commit: Tim Harper <timcharper@gmail.com>
Add wrap in function call
- new modifier "f" after cs , ys or v[sS] . Prompts for function name and
then wraps it as fname(selection)
- docs
TODO?
- use "F" to make (e)lisp style function calls?
- do mode detection?
---
README.md | 12 ++++++++++++
surround.el | 9 ++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fd9a68deab..a01aca40cb 100644
--- a/README.md
+++ b/README.md
@@ -114,3 +114,15 @@ visual mode) followed by `S<p class="important">`.
<p class="important">
<em>Hello</em> world!
</p>
+
+Suppose you want to call a function on your visual selection or a text
+object. You can simply press `f` instead of the aforementioned keys
+and are then prompted for a functionname in the minibuffer, like with
+the tags. So with:
+
+ "Hello world!"
+
+... after selecting the string, then pressing `sf`, entering `print`
+and pressing return you would get
+
+ print("Hello world!")
diff --git a/surround.el b/surround.el
index 746462b54c..72d726df7f 100644
--- a/surround.el
+++ b/surround.el
@@ -54,7 +54,8 @@
(?B . ("{" . "}"))
(?> . ("<" . ">"))
(?t . surround-read-tag)
- (?< . surround-read-tag))
+ (?< . surround-read-tag)
+ (?f . surround-function))
"Association list of surround items.
Each item is of the form (TRIGGER . (LEFT . RIGHT)), all strings.
Alternatively, a function can be put in place of (LEFT . RIGHT).
@@ -70,6 +71,12 @@ This only affects inserting pairs, not deleting or changing
them."
map)
"Keymap used by `surround-read-tag'.")
+(defun surround-function ()
+ "Read a functionname from the minibuffer and wrap selection in function call"
+ (let ((fname (read-from-minibuffer "" "" )))
+ (cons (format "%s(" (or fname ""))
+ ")")))
+
(defun surround-read-tag ()
"Read a XML tag from the minibuffer."
(let* ((input (read-from-minibuffer "<" "" surround-read-tag-map))
- [nongnu] elpa/evil-surround 31cc1da60c 026/175: Merge pull request #14 from milkypostman/master, (continued)
- [nongnu] elpa/evil-surround 31cc1da60c 026/175: Merge pull request #14 from milkypostman/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 0c503fc994 033/175: Merge branch 'master' of https://github.com/lyro/evil-surround, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 8b59d17d5c 038/175: Merge pull request #32 from Silex/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 77e7cd8de0 045/175: bring back the evil-Surround-region; make it work with yS, also, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 6f290e0270 048/175: Implement block-wise surround, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 7a2e79d7a8 039/175: Fix forgotten leftovers when renaming, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 72d35afc40 051/175: Fix surrounding with invalid chars, like ESC (Fix #51), ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 7cad34b28a 005/175: 'S' causes normal region to end up on it's own line, as in surround.vim, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround c43dfec32c 011/175: Update `interactive' forms, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 2f49c479bf 016/175: Merge pull request #6 from cofi/buffer-local, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 1d6b1bac4e 027/175: Add wrap in function call,
ELPA Syncer <=
- [nongnu] elpa/evil-surround 7f8f950985 037/175: Rename surround* to evil-surround*, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 28466957f9 044/175: Update README.md, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 9508236d8e 052/175: Merge branch 'fix-esc-surround' of github.com:hlissner/evil-surround into fix-esc-surround, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 430c81f2a1 071/175: Fix #71, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 8c03039e0e 073/175: Merge pull request #73 from hlissner/linewise-surround-fix, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 277759d894 074/175: Fix repeat action (.) for ys and yS operators., ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround c99ca440df 057/175: I changed all references of "surround-pairs-alist" to, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 3812140e11 086/175: Merge pull request #83 from wbolster/use-explicit-autoload-definitions, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 00f70acfff 083/175: Merge pull request #81 from wbolster/read-keys-with-translation, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround f448455313 097/175: add credits to Tim Harper, ELPA Syncer, 2023/10/09