summaryrefslogtreecommitdiff
path: root/evil-surround.el
diff options
context:
space:
mode:
authorEvgeni Kolev <evgenysw@gmail.com>2017-10-03 08:55:14 +0300
committerFilipe Silva <ninrod@users.noreply.github.com>2017-10-04 10:00:39 -0300
commit822a0f61c3fd7c55cda4e04c8590ae5144401c26 (patch)
tree0e71eca1d17f077f1c61bf42667beed8c61edf84 /evil-surround.el
parent853b9fdf117b1de665b02c7b3c978ce2a51f52e7 (diff)
Make `ysw` work like `cw`, not `ce`
Diffstat (limited to 'evil-surround.el')
-rw-r--r--evil-surround.el14
1 files changed, 12 insertions, 2 deletions
diff --git a/evil-surround.el b/evil-surround.el
index bfe6056..5a6db9a 100644
--- a/evil-surround.el
+++ b/evil-surround.el
@@ -44,6 +44,10 @@
:prefix "surround-"
:group 'evil)
+;; make surround's `ysw' work like `cw', not `ce'
+(when (boundp 'evil-change-commands)
+ (add-to-list 'evil-change-commands 'evil-surround-region))
+
(defcustom evil-surround-pairs-alist
'((?\( . ("( " . " )"))
(?\[ . ("[ " . " ]"))
@@ -245,6 +249,12 @@ This is necessary because `evil-yank' operator is not repeatable (:repeat nil)"
(evil-repeat-start)
(evil-repeat-record "y")
(evil-repeat-record (this-command-keys))
+
+ ;; set `this-command-keys' to the command that will be executed
+ ;; interactively; as a result, `evil-this-operator' will be
+ ;; correctly set to, for example, `evil-surround-region' instead of
+ ;; `evil-yank' when surround has been invoked by `ys'
+ (setq this-command callback)
(call-interactively callback)
(evil-repeat-keystrokes 'post)
(evil-repeat-stop))
@@ -309,8 +319,8 @@ Becomes this:
((eq type 'line)
(setq force-new-line
(or force-new-line
- ;; Force newline if not invoked from an operator, e.g. VS)
- (eq evil-this-operator 'evil-surround-region)
+ ;; Force newline if not invoked from an operator, e.g. visual line mode with VS)
+ (evil-visual-state-p)
;; Or on multi-line operator surrounds (like 'ysj]')
(/= (line-number-at-pos) (line-number-at-pos (1- end)))))