branch: elpa/evil-numbers
commit 6fa8e02e3bd8d21c0c1406554e23bc98df18ad83
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>

    Cleanup: avoid right shift
    
    Move the 't' condition onto the next line to avoid right shift.
---
 evil-numbers.el | 151 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 76 insertions(+), 75 deletions(-)

diff --git a/evil-numbers.el b/evil-numbers.el
index 5d1b615eac..6502d832d7 100644
--- a/evil-numbers.el
+++ b/evil-numbers.el
@@ -154,81 +154,82 @@ number with a + sign."
                    (if incremental (setq count (+ count 1)))
                    ;; Undo VIM compatibility.
                    (forward-char 1)))))))))
-     (t (save-match-data
-          ;; forward-char, so that we do not match the number directly behind 
us.
-          (forward-char)
-          (if (not (evil-numbers/search-number))
-              (error "No number at point or until end of line")
-            (let ((replace-with
-                   (lambda (from to)
-                     (skip-chars-backward
-                      (funcall from "0123456789"))
-                     (skip-chars-backward
-                      (funcall from "+-") (- (point) 1))
-                     (when (looking-at
-                            (format
-                             "[%s]?\\([%s]+\\)"
-                             (funcall from "-+")
-                             (funcall from "0123456789")))
-                       (replace-match
-                        (funcall
-                         from
-                         (let* ((padded
-                                 (or padded
-                                     (eq ?0 (string-to-char (match-string 
1)))))
-                                (input (string-to-number
-                                        (funcall to (match-string 0))))
-                                (output (+ amount input))
-                                (len (- (match-end 0) (match-beginning 0)))
-                                (signed (and
-                                         (memq (string-to-char (match-string 
0))
-                                               (funcall from '(?+ ?-)))
-                                         (or padded (>= input 0)))))
-                           (format
-                            (format "%%%s0%dd"
-                                    (if signed "+" "")
-                                    (if padded len 0))
-                            output))))
-                       ;; Moves point one position back to conform with VIM
-                       (forward-char -1)
-                       t))))
-              (or
-               ;; Find binary literals.
-               (evil-numbers/search-and-replace "0[bB][01]+" "01" 
"\\([01]+\\)" amount 2)
-
-               ;; Find octal literals.
-               (evil-numbers/search-and-replace "0[oO][0-7]+" "01234567" 
"\\([0-7]+\\)" amount 8)
-
-               ;; Find hex literals.
-               (evil-numbers/search-and-replace "0[xX][0-9a-fA-F]*"
-                                                "0123456789abcdefABCDEF"
-                                                "\\([0-9a-fA-F]+\\)" amount 16)
-
-               ;; Find superscript literals.
-               (funcall
-                replace-with
-                (lambda (x)
-                  (evil-numbers/translate-with-alist
-                   evil-numbers/superscript-alist x))
-                (lambda (x)
-                  (evil-numbers/translate-with-alist
-                   (evil-numbers/swap-alist evil-numbers/superscript-alist)
-                   x)))
-
-               ;; Find subscript literals.
-               (funcall
-                replace-with
-                (lambda (x)
-                  (evil-numbers/translate-with-alist
-                   evil-numbers/subscript-alist x))
-                (lambda (x)
-                  (evil-numbers/translate-with-alist
-                   (evil-numbers/swap-alist evil-numbers/subscript-alist)
-                   x)))
-
-               ;; Find normal decimal literals.
-               (funcall replace-with (lambda (x) x) (lambda (x) x))
-               (error "No number at point or until end of line")))))))))
+     (t
+      (save-match-data
+        ;; forward-char, so that we do not match the number directly behind us.
+        (forward-char)
+        (if (not (evil-numbers/search-number))
+            (error "No number at point or until end of line")
+          (let ((replace-with
+                 (lambda (from to)
+                   (skip-chars-backward
+                    (funcall from "0123456789"))
+                   (skip-chars-backward
+                    (funcall from "+-") (- (point) 1))
+                   (when (looking-at
+                          (format
+                           "[%s]?\\([%s]+\\)"
+                           (funcall from "-+")
+                           (funcall from "0123456789")))
+                     (replace-match
+                      (funcall
+                       from
+                       (let* ((padded
+                               (or padded
+                                   (eq ?0 (string-to-char (match-string 1)))))
+                              (input (string-to-number
+                                      (funcall to (match-string 0))))
+                              (output (+ amount input))
+                              (len (- (match-end 0) (match-beginning 0)))
+                              (signed (and
+                                       (memq (string-to-char (match-string 0))
+                                             (funcall from '(?+ ?-)))
+                                       (or padded (>= input 0)))))
+                         (format
+                          (format "%%%s0%dd"
+                                  (if signed "+" "")
+                                  (if padded len 0))
+                          output))))
+                     ;; Moves point one position back to conform with VIM
+                     (forward-char -1)
+                     t))))
+            (or
+             ;; Find binary literals.
+             (evil-numbers/search-and-replace "0[bB][01]+" "01" "\\([01]+\\)" 
amount 2)
+
+             ;; Find octal literals.
+             (evil-numbers/search-and-replace "0[oO][0-7]+" "01234567" 
"\\([0-7]+\\)" amount 8)
+
+             ;; Find hex literals.
+             (evil-numbers/search-and-replace "0[xX][0-9a-fA-F]*"
+                                              "0123456789abcdefABCDEF"
+                                              "\\([0-9a-fA-F]+\\)" amount 16)
+
+             ;; Find superscript literals.
+             (funcall
+              replace-with
+              (lambda (x)
+                (evil-numbers/translate-with-alist
+                 evil-numbers/superscript-alist x))
+              (lambda (x)
+                (evil-numbers/translate-with-alist
+                 (evil-numbers/swap-alist evil-numbers/superscript-alist)
+                 x)))
+
+             ;; Find subscript literals.
+             (funcall
+              replace-with
+              (lambda (x)
+                (evil-numbers/translate-with-alist
+                 evil-numbers/subscript-alist x))
+              (lambda (x)
+                (evil-numbers/translate-with-alist
+                 (evil-numbers/swap-alist evil-numbers/subscript-alist)
+                 x)))
+
+             ;; Find normal decimal literals.
+             (funcall replace-with (lambda (x) x) (lambda (x) x))
+             (error "No number at point or until end of line")))))))))
 
 ;;;###autoload (autoload 'evil-numbers/dec-at-pt "evil-numbers" nil t)
 (evil-define-operator evil-numbers/dec-at-pt (amount beg end type &optional 
incremental padded)

Reply via email to