branch: elpa/evil-numbers
commit 984126654414e2631cac6f61bcc34ed9a951e361
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>
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