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

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

[elpa] externals/jit-spell 2736376ab8: Make sure to remove stray overlay


From: ELPA Syncer
Subject: [elpa] externals/jit-spell 2736376ab8: Make sure to remove stray overlays
Date: Wed, 8 Mar 2023 06:58:47 -0500 (EST)

branch: externals/jit-spell
commit 2736376ab87444d65ac2f3b4e2873d95a0743f5c
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>

    Make sure to remove stray overlays
---
 jit-spell.el | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/jit-spell.el b/jit-spell.el
index d624afef6c..d2b20ef06c 100644
--- a/jit-spell.el
+++ b/jit-spell.el
@@ -152,8 +152,6 @@ move the point with impunity.")
                        face)
            (memq face jit-spell-prog-mode-faces)))))
 
-;; TODO: jit-spell--org-ignored-p, etc.
-
 ;;; Overlays
 
 (put 'jit-spell 'evaporate t)
@@ -181,7 +179,7 @@ character offset from START, and a list of corrections."
   (with-current-buffer buffer
     (with-silent-modifications
       (remove-list-of-text-properties start end '(jit-spell-pending))
-      (remove-overlays start end 'category 'jit-spell)
+      (jit-spell--remove-overlays start end)
       (pcase-dolist (`(,word ,offset ,corrections) misspellings)
         (let* ((wstart (+ start offset -1))
                (wend (+ wstart (length word))))
@@ -210,6 +208,19 @@ character offset from START, and a list of corrections."
             (unless (< 0 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.
+GAPS must be an ordered list of conses, with the intervals closer
+to END coming first."
+  (pcase-dolist (`(,i . ,j) gaps)
+    (dolist (ov (overlays-in j end))
+      (when (eq 'jit-spell (overlay-get ov 'category))
+        (delete-overlay ov))
+      (setq end i)))
+  (dolist (ov (overlays-in start end))
+    (when (eq 'jit-spell (overlay-get ov 'category))
+      (delete-overlay ov))))
+
 (defun jit-spell--apply-correction (ov text)
   "Replace region spanned by OV with TEXT."
   (save-excursion
@@ -255,7 +266,7 @@ Force refontification of the region, unless LAX is non-nil."
   (without-restriction
     (setq start (or start (point-min)))
     (setq end (or end (point-max)))
-    (remove-overlays start end 'category 'jit-spell)
+    (jit-spell--remove-overlays start end)
     (remove-list-of-text-properties start end '(jit-spell-pending))
     (unless lax (jit-lock-refontify start end))))
 
@@ -412,7 +423,8 @@ Otherwise, only such regions are kept."
              (goto-char i)
              (while-let ((prop (text-property-search-forward 'face faces 
pred)))
                (push `(,(prop-match-beginning prop) . ,(prop-match-end prop))
-                   result)))
+                     result)))
+           (jit-spell--remove-overlays i limit result)
            result))
        regions))))
 



reply via email to

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