[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/jit-spell b1853af396 1/3: Minor refactoring
From: |
ELPA Syncer |
Subject: |
[elpa] externals/jit-spell b1853af396 1/3: Minor refactoring |
Date: |
Sat, 25 Mar 2023 08:58:06 -0400 (EDT) |
branch: externals/jit-spell
commit b1853af3965c0f74e058a541065a50d68061d91a
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>
Minor refactoring
---
jit-spell.el | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/jit-spell.el b/jit-spell.el
index 6caa5dc569..d41ea954f9 100644
--- a/jit-spell.el
+++ b/jit-spell.el
@@ -180,19 +180,17 @@ character offset from START, and a list of corrections."
(defun jit-spell--search-overlay (pos count)
"Return the COUNT jit-spell overlay from POS."
- (let* ((limit (if (> count 0) (window-end) (window-start)))
- (searchfn (if (> count 0)
+ (let* ((limit (if (cl-plusp count) (window-end) (window-start)))
+ (searchfn (if (cl-plusp count)
#'next-single-char-property-change
#'previous-single-char-property-change))
(i (abs count)))
(catch 'jit-spell
(while (/= pos limit)
(setq pos (funcall searchfn pos 'category nil limit))
- (dolist (ov (overlays-at pos))
- (when (eq (overlay-get ov 'category) 'jit-spell)
- (cl-decf i)
- (unless (< 0 i)
- (throw 'jit-spell ov))))))))
+ (when-let ((ov (jit-spell--overlay-at pos)))
+ (unless (cl-plusp (cl-decf i))
+ (throw 'jit-spell ov)))))))
(defun jit-spell--remove-overlays (start end &optional gaps)
"Remove all `jit-spell' overlays between START and END, skipping GAPS.
@@ -397,14 +395,14 @@ Otherwise, only such regions are kept."
(lambda (faces v) (not (jit-spell--has-face-p faces v))))))
(lambda (regions)
(mapcan
- (pcase-lambda (`(,i . ,limit)) ;; Refine one region
+ (pcase-lambda (`(,start . ,end)) ;; Refine one region
(let (result)
- (with-restriction i limit
- (goto-char i)
+ (with-restriction start end
+ (goto-char start)
(while-let ((prop (text-property-search-forward 'face faces
pred)))
(push `(,(prop-match-beginning prop) . ,(prop-match-end prop))
result)))
- (jit-spell--remove-overlays i limit result)
+ (jit-spell--remove-overlays start end result)
result))
regions))))