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

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

[nongnu] elpa/evil 26168f1972: Update ] and [ markers when doing operato


From: ELPA Syncer
Subject: [nongnu] elpa/evil 26168f1972: Update ] and [ markers when doing operator
Date: Sun, 30 Oct 2022 18:58:27 -0400 (EDT)

branch: elpa/evil
commit 26168f1972fdf263d964715862cb782b9b33b71d
Author: Tom Dalziel <tom_dl@hotmail.com>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>

    Update ] and [ markers when doing operator
---
 evil-macros.el | 11 +++++++++--
 evil-tests.el  | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/evil-macros.el b/evil-macros.el
index 71bf122706..4ee9ec693f 100644
--- a/evil-macros.el
+++ b/evil-macros.el
@@ -497,6 +497,7 @@ Optional keyword arguments are:
                    `(,(nth 0 args) ,(nth 1 args)
                      &optional ,@(nthcdr 2 args))
                  args))
+         (end-marker (make-symbol "end-marker"))
          arg doc key keys visual)
     ;; collect docstring
     (when (and (> (length body) 1)
@@ -557,10 +558,16 @@ Optional keyword arguments are:
              (t
               (goto-char orig))))))
        (unwind-protect
-           (let ((evil-inhibit-operator evil-inhibit-operator-value))
+           (let ((evil-inhibit-operator evil-inhibit-operator-value)
+                 (,end-marker (make-marker)))
+             (set-marker ,end-marker ,(cadr args))
              (unless (and evil-inhibit-operator
                           (called-interactively-p 'any))
-               ,@body))
+               ,@body)
+             (evil-set-marker ?\[ (or ,(car args) (point-max)))
+             (evil-set-marker ?\] (max (or ,(car args) (point-max))
+                                       (1- (or (marker-position ,end-marker) 
(point-max)))))
+             (set-marker ,end-marker nil))
          (setq evil-inhibit-operator-value nil)))))
 
 ;; this is used in the `interactive' specification of an operator command
diff --git a/evil-tests.el b/evil-tests.el
index 388d5be699..f2a7e866ec 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -2461,6 +2461,41 @@ Below some empty line")))
         ("a" "somemore" "0\C-d")
         "line1\nsometext somemore[]"))))
 
+(ert-deftest evil-test-operator-set-marks ()
+  "Test `[ and `] are set by operators."
+  :tags '(evil operator)
+  (ert-info ("Can go to end of last operated text")
+    (evil-test-buffer
+      "alpha br[a]vo charlie"
+      ("gUiw")
+      "alpha [B]RAVO charlie"
+      ("`]")
+      "alpha BRAV[O] charlie"))
+  (ert-info ("Can go to end of last operated text")
+    (evil-test-buffer
+      "alpha br[a]vo charlie"
+      ("g?iw$")
+      "alpha oenib charli[e]"
+      ("`[")
+      "alpha [o]enib charlie"))
+  (ert-info ("Marks are correct after deletion")
+    (evil-test-buffer
+      "alpha br[a]vo charlie"
+      ("daw^")
+      "[a]lpha charlie"
+      ("`]")
+      "alpha [c]harlie"
+      ("^`[")
+      "alpha [c]harlie")
+    (evil-test-buffer
+      "alpha br[a]vo charlie"
+      ("D^")
+      "[a]lpha br"
+      ("`]")
+      "alpha b[r]"
+      ("^`[")
+      "alpha b[r]")))
+
 ;;; Paste
 
 (ert-deftest evil-test-paste-before ()



reply via email to

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