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

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

[nongnu] elpa/evil-numbers f93258b706: Fix cursor placement when switchi


From: ELPA Syncer
Subject: [nongnu] elpa/evil-numbers f93258b706: Fix cursor placement when switching to negative & workaround emacs bug
Date: Tue, 3 Dec 2024 21:59:36 -0500 (EST)

branch: elpa/evil-numbers
commit f93258b706fa5cf9259e815c2d8258fcc6262804
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Fix cursor placement when switching to negative & workaround emacs bug
    
    Workaround emacs bug #74666 by swapping the order replace is called.
---
 evil-numbers.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/evil-numbers.el b/evil-numbers.el
index 613114281b..7bb964cc59 100644
--- a/evil-numbers.el
+++ b/evil-numbers.el
@@ -435,7 +435,6 @@ replacing it by the result of NUMBER-XFORM-FN and return 
non-nil."
                (or (null range-check-fn)
                    (funcall range-check-fn (match-beginning 0) (match-end 0))))
 
-      (goto-char (match-end num-group))
       (let* ((sep-char (nth 2 (nth (1- num-group) match-chars)))
              (str-prev
               (funcall decode-fn
@@ -480,6 +479,13 @@ replacing it by the result of NUMBER-XFORM-FN and return 
non-nil."
                   (evil-numbers--strip-chars-apply
                    str-prev str-next sep-char))))
 
+        ;; Replace number then sign, workaround emacs bug #74666.
+        ;; The order replace runs isn't really important anyway,
+        ;; the order may be restored once the bug is resolved in emacs.
+
+        ;; Replace the number.
+        (replace-match (funcall encode-fn str-next) t t nil num-group)
+
         ;; Replace the sign (as needed).
         (cond
          ;; From negative to positive.
@@ -489,8 +495,7 @@ replacing it by the result of NUMBER-XFORM-FN and return 
non-nil."
          ((and (not (< num-prev 0)) (< num-next 0))
           (replace-match (funcall encode-fn "-") t t nil sign-group)))
 
-        ;; Replace the number.
-        (replace-match (funcall encode-fn str-next) t t nil num-group))
+        (goto-char (match-end num-group)))
 
       t)))
 



reply via email to

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