summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--evil-surround.el15
-rw-r--r--test/evil-surround-test.el10
2 files changed, 23 insertions, 2 deletions
diff --git a/evil-surround.el b/evil-surround.el
index 5fbbc73..0fd2cad 100644
--- a/evil-surround.el
+++ b/evil-surround.el
@@ -5,7 +5,10 @@
;; Author: Tim Harper <timcharper at gmail dot com>
;; Vegard Øye <vegard_oye at hotmail dot com>
-;; Current Maintainer: ninrod (github.com/ninrod)
+;;
+;; The following line is included for NonGNU ELPA's build script:
+;; Maintainer: Tom Dalziel <tom.dalziel@gmail.com>
+;;
;; Created: July 23 2011
;; Version: 1.0.4
;; Package-Requires: ((evil "1.2.12"))
@@ -74,6 +77,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.
@@ -142,6 +146,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.")
@@ -416,7 +427,7 @@ Becomes this:
(setq beg-pos (point))
(insert open)
(when force-new-line (newline-and-indent))
- (evil-end-of-visual-line)
+ (goto-char (overlay-end overlay))
(if force-new-line
(when (eobp)
(newline-and-indent))
diff --git a/test/evil-surround-test.el b/test/evil-surround-test.el
index 1da5d37..44662f5 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