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

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

[nongnu] elpa/evil-numbers 8b59acf267 059/145: fix: handle hyphen-separa


From: ELPA Syncer
Subject: [nongnu] elpa/evil-numbers 8b59acf267 059/145: fix: handle hyphen-separated numbers correctly
Date: Thu, 6 Jan 2022 03:00:18 -0500 (EST)

branch: elpa/evil-numbers
commit 8b59acf2678b29e726eb9a8d3cbd487135b241c9
Author: midchildan <git@midchildan.org>
Commit: midchildan <git@midchildan.org>

    fix: handle hyphen-separated numbers correctly
    
    Imagine we're editing hyphen-separated numbers like the following:
    
        cursor:          v
        text:   2020-01-02
    
    When we invoke 'inc-at-pt', we want the last number to change:
    
        cursor:          v
        text:   2020-01-01
    
    (Note that the number is decremented instead of being incremented due to
    the leading '-'. This also matches Vim behavior)
    
    However, evil-numbers currently change the first number instead:
    
        cursor:    v
        text:   2021-01-02
    
    This patch fixes evil-numbers to match the expected behavior.
---
 evil-numbers.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/evil-numbers.el b/evil-numbers.el
index fa5a2941c1..76a52a27d3 100644
--- a/evil-numbers.el
+++ b/evil-numbers.el
@@ -168,7 +168,9 @@ number with a + sign.
                   (replace-with
                    (lambda (from to)
                      (skip-chars-backward
-                      (funcall from "+-0123456789"))
+                      (funcall from "0123456789"))
+                     (skip-chars-backward
+                      (funcall from "+-") (- (point) 1))
                      (when (looking-at
                             (format
                              "[%s]?\\([%s]+\\)"



reply via email to

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