branch: externals/shift-number
commit b25fc4fc02a0755c1f5bd6483a65c970fbd30190
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>

    Cleanup: de-duplicate context checks
---
 shift-number.el | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/shift-number.el b/shift-number.el
index 815c19fc58..534869c0ca 100644
--- a/shift-number.el
+++ b/shift-number.el
@@ -253,6 +253,16 @@ REGION-BEG & REGION-END define the region."
      (region-beginning)
      (region-end))))
 
+(defun shift-number--on-context (n)
+  "Manipulate numbers in the current region or line by N."
+  (cond
+   ((bound-and-true-p rectangle-mark-mode)
+    (shift-number--on-rectangle n))
+   ((region-active-p)
+    (shift-number--on-region n))
+   (t
+    (shift-number--on-line n))))
+
 
 ;; ---------------------------------------------------------------------------
 ;; Public Functions
@@ -261,25 +271,13 @@ REGION-BEG & REGION-END define the region."
 (defun shift-number-up (&optional arg)
   "Increase the number at point (or on the current line) by ARG."
   (interactive "p")
-  (cond
-   ((bound-and-true-p rectangle-mark-mode)
-    (shift-number--on-rectangle arg))
-   ((region-active-p)
-    (shift-number--on-region arg))
-   (t
-    (shift-number--on-line arg))))
+  (shift-number--on-context arg))
 
 ;;;###autoload
 (defun shift-number-down (&optional arg)
   "Decrease the number at point (or on the current line) by ARG."
   (interactive "p")
-  (cond
-   ((bound-and-true-p rectangle-mark-mode)
-    (shift-number--on-rectangle (- arg)))
-   ((region-active-p)
-    (shift-number--on-region (- arg)))
-   (t
-    (shift-number--on-line (- arg)))))
+  (shift-number--on-context (- arg)))
 
 (provide 'shift-number)
 ;; Local Variables:

Reply via email to