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

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

[nongnu] elpa/evil-numbers 9841266544 113/145: Cleanup: replace catch/th


From: ELPA Syncer
Subject: [nongnu] elpa/evil-numbers 9841266544 113/145: Cleanup: replace catch/throw with a 'found' variable
Date: Thu, 6 Jan 2022 03:00:23 -0500 (EST)

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

    Cleanup: replace catch/throw with a 'found' variable
---
 evil-numbers.el | 58 +++++++++++++++++++++++++++++----------------------------
 1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/evil-numbers.el b/evil-numbers.el
index 87e7723706..8ec10e1615 100644
--- a/evil-numbers.el
+++ b/evil-numbers.el
@@ -400,35 +400,37 @@ Return non-nil on success, leaving the point at the end 
of the number."
 Keep padding when PADDED is non-nil.
 
 Return non-nil on success, leaving the point at the end of the number."
-  (catch 'result
+  (let ((found nil))
     (save-match-data
-      (let ((point-last (1- (point))))
-        ;; Search for any text that might be part of a number,
-        ;; if `evil-numbers--search-and-replace' cannot parse it - that's fine,
-        ;; keep searching until `end'
-        ;; This avoids doubling up on number parsing logic.
-        (while (< point-last (point))
-          (when (evil-numbers--inc-at-pt-impl
-                 amount
-                 ;; Clamp limits to line bounds.
-                 ;; The caller may use a range that spans lines to
-                 ;; allow searching and finding items across
-                 ;; multiple lines (currently used for selection).
-                 (max beg (point-at-bol))
-                 (min end (point-at-eol))
-                 padded)
-            (throw 'result t))
-
-          (setq point-last (point))
-          (unless (re-search-forward
-                   (concat "["
-                           "[:xdigit:]"
-                           evil-numbers--chars-superscript
-                           evil-numbers--chars-subscript
-                           "]")
-                   end t)
-            (throw 'result nil)))))))
-
+      ;; Search for any text that might be part of a number,
+      ;; if `evil-numbers--search-and-replace' cannot parse it - that's fine,
+      ;; keep searching until `end'
+      ;; This avoids doubling up on number parsing logic.
+      (while (and
+              ;; Found item, exit the loop.
+              (null
+               (when (evil-numbers--inc-at-pt-impl
+                      amount
+                      ;; Clamp limits to line bounds.
+                      ;; The caller may use a range that spans lines to
+                      ;; allow searching and finding items across
+                      ;; multiple lines (currently used for selection).
+                      (max beg (point-at-bol))
+                      (min end (point-at-eol))
+                      padded)
+                 (setq found t)))
+
+              ;; Search failed, exit the loop.
+              (re-search-forward
+               (concat "["
+                       "[:xdigit:]"
+                       evil-numbers--chars-superscript
+                       evil-numbers--chars-subscript
+                       "]")
+               end t))
+        ;; Empty while body.
+        nil))
+    found))
 
 ;; ---------------------------------------------------------------------------
 ;; Public Functions



reply via email to

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