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

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

[nongnu] elpa/evil-surround 822a0f61c3 111/175: Make `ysw` work like `cw


From: ELPA Syncer
Subject: [nongnu] elpa/evil-surround 822a0f61c3 111/175: Make `ysw` work like `cw`, not `ce`
Date: Mon, 9 Oct 2023 13:01:07 -0400 (EDT)

branch: elpa/evil-surround
commit 822a0f61c3fd7c55cda4e04c8590ae5144401c26
Author: Evgeni Kolev <evgenysw@gmail.com>
Commit: Filipe Silva <ninrod@users.noreply.github.com>

    Make `ysw` work like `cw`, not `ce`
---
 evil-surround.el           | 14 ++++++++++++--
 test/evil-surround-test.el | 31 ++++++++++++++++++++++++++++++-
 test/make-test.el          |  1 +
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/evil-surround.el b/evil-surround.el
index bfe6056c34..5a6db9a650 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)))))
 
diff --git a/test/evil-surround-test.el b/test/evil-surround-test.el
index b0c363f8eb..c2028dee9b 100644
--- a/test/evil-surround-test.el
+++ b/test/evil-surround-test.el
@@ -96,4 +96,33 @@
       "111 222 333\n[1]11 222 333\n111 222 333\n111 222 333\n"
       (turn-on-evil-surround-mode)
       ("ysjb")
-      "111 222 333\n(\n111 222 333\n111 222 333\n)\n111 222 333\n")))
+      "111 222 333\n(\n111 222 333\n111 222 333\n)\n111 222 333\n"))
+  (ert-info ("test with evil-want-change-word-to-end")
+    (evil-test-buffer
+      "[o]ne    two  three"
+      (setq evil-want-change-word-to-end nil)
+      (turn-on-evil-surround-mode)
+      ("yswb")
+      "[(]one    )two  three"
+      ("dsb")
+      "[o]ne    two  three"
+      ("ys2wb")
+      "[(]one    two  )three"
+      ("dsb")
+      "[o]ne    two  three"
+      ("ys3wb")
+      "[(]one    two  three)")
+    (evil-test-buffer
+      "[o]ne    two  three"
+      (setq evil-want-change-word-to-end t)
+      (turn-on-evil-surround-mode)
+      ("yswb")
+      "[(]one)    two  three"
+      ("dsb")
+      "[o]ne    two  three"
+      ("ys2wb")
+      "[(]one    two)  three"
+      ("dsb")
+      "[o]ne    two  three"
+      ("ys3wb")
+      "[(]one    two  three)")))
diff --git a/test/make-test.el b/test/make-test.el
index fb487b1c12..1964641d82 100644
--- a/test/make-test.el
+++ b/test/make-test.el
@@ -1,3 +1,4 @@
+(setq load-prefer-newer t)
 
 (let ((current-directory (file-name-directory load-file-name)))
   (setq evil-surround-test-path (expand-file-name "." current-directory))



reply via email to

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