branch: elpa/spell-fu commit aed6e87aa31013534b7a6cbedb26e4f29ccea735 Author: Campbell Barton <ideasma...@gmail.com> Commit: Campbell Barton <ideasma...@gmail.com>
spell-fu: improve overlay extending to support non-exact overlaps --- spell-fu.el | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/spell-fu.el b/spell-fu.el index d29ddc25ab..2c6ebc3a04 100644 --- a/spell-fu.el +++ b/spell-fu.el @@ -791,22 +791,25 @@ when checking the entire buffer for example." (when (and spell-fu--idle-overlay-last (not (overlay-buffer spell-fu--idle-overlay-last))) (setq spell-fu--idle-overlay-last nil)) - (cond - ;; Extend forwards. - ((and spell-fu--idle-overlay-last (eq pos-beg (overlay-end spell-fu--idle-overlay-last))) - (move-overlay spell-fu--idle-overlay-last (overlay-start spell-fu--idle-overlay-last) pos-end)) - ;; Extend backwards. - ((and spell-fu--idle-overlay-last (eq pos-end (overlay-start spell-fu--idle-overlay-last))) - (move-overlay spell-fu--idle-overlay-last pos-beg (overlay-end spell-fu--idle-overlay-last))) - (t + (unless (and spell-fu--idle-overlay-last + (let ((last-beg (overlay-start spell-fu--idle-overlay-last)) + (last-end (overlay-end spell-fu--idle-overlay-last))) + (cond + ((> last-beg pos-end) + nil) + ((< last-end pos-beg) + nil) + (t ; Extend when overlap. + (move-overlay + spell-fu--idle-overlay-last (min pos-beg last-beg) (max pos-end last-end)) + t)))) + (let ((item-ov (make-overlay pos-beg pos-end))) ;; Handy for debugging pending regions to be checked. ;; (overlay-put item-ov 'face '(:background "#000000" :extend t)) - (overlay-put item-ov 'spell-fu-pending t) (overlay-put item-ov 'evaporate 't) - - (setq spell-fu--idle-overlay-last item-ov)))) + (setq spell-fu--idle-overlay-last item-ov))) ;; Use `inhibit-quit' as a way to check if `jit-lock-stealth' is in use. (when inhibit-quit