[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/spell-fu 8f780a874c 66/86: Reduce idle overlay fragmentati
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/spell-fu 8f780a874c 66/86: Reduce idle overlay fragmentation |
Date: |
Thu, 7 Jul 2022 12:03:44 -0400 (EDT) |
branch: elpa/spell-fu
commit 8f780a874c9c6672442a917ec2e1b11fd424a890
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Reduce idle overlay fragmentation
---
changelog.rst | 1 +
spell-fu.el | 38 ++++++++++++++++++++++++++++++++------
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/changelog.rst b/changelog.rst
index 54c3e6ef4d..302fffa020 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -4,6 +4,7 @@ Change Log
##########
- In development.
+ - Reduce idle overlay fragmentation.
- Idle timers now update buffers that have lost focus.
- Fix for disabling ``spell-fu-mode`` preventing other buffers that have
``spell-fu-mode`` enabled from updating.
- Changes to the face are now treated as word separators.
diff --git a/spell-fu.el b/spell-fu.el
index 764a8b3483..c6da6c642a 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -153,6 +153,11 @@ Notes:
;; Note that this is typically the same dictionary shared across all buffers.
(defvar-local spell-fu--cache-table nil)
+;; Keep track of the last overlay, this allows expanding the existing overlay
where possible.
+;; Useful since font-locking often uses multiple smaller ranges which can be
merged into one range.
+;; Always check this has not been deleted (has a valid buffer) before use.
+(defvar-local spell-fu--idle-overlay-last nil)
+
;; ---------------------------------------------------------------------------
;; Dictionary Utility Functions
@@ -768,11 +773,31 @@ when checking the entire buffer for example."
(defun spell-fu--idle-font-lock-region-pending (point-start point-end)
"Track the range to spell check, adding POINT-START & POINT-END to the
queue."
- (let ((item-ov (make-overlay point-start point-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)))
+ (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 point-start (overlay-end
spell-fu--idle-overlay-last)))
+ (move-overlay
+ spell-fu--idle-overlay-last
+ (overlay-start spell-fu--idle-overlay-last)
+ point-end))
+ ;; Extend backwards.
+ ((and spell-fu--idle-overlay-last (eq point-end (overlay-start
spell-fu--idle-overlay-last)))
+ (move-overlay
+ spell-fu--idle-overlay-last
+ point-start
+ (overlay-end spell-fu--idle-overlay-last)))
+ (t
+ (let ((item-ov (make-overlay point-start point-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)))))
;; ---------------------------------------------------------------------------
;; Internal Timer Management
@@ -891,7 +916,8 @@ when checking the entire buffer for example."
(jit-lock-unregister #'spell-fu--idle-font-lock-region-pending)
(spell-fu--overlays-remove)
(spell-fu--idle-overlays-remove)
- (spell-fu--time-buffer-local-disable))
+ (spell-fu--time-buffer-local-disable)
+ (kill-local-variable 'spell-fu--idle-overlay-last))
;; ---------------------------------------------------------------------------
;; Public Functions
- [nongnu] branch elpa/spell-fu created (now cbe5cd84c3), ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu eeda8ef28e 06/86: Cleanup: minor non-functional changes, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 676498f757 13/86: Support buffer local dictionaries, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 073932be78 16/86: Cleanup: replace '(nth 5 ...' with file-attribute-modification-time, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 2c792330ac 18/86: Case insensitive sort lines as a list (not in the buffer), ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 03114080c8 20/86: Add requirements at the top of the file, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu fe557e3dff 21/86: Be explicit about using macro that sets values in-place, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 33a28e0df5 41/86: fix: encode word to utf-8 generating the cache, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 7770c005c4 47/86: Cleanup minor name change for spell-fu function name, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 866044304f 50/86: Check if faces can be used on property change, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 8f780a874c 66/86: Reduce idle overlay fragmentation,
ELPA Syncer <=
- [nongnu] elpa/spell-fu 4fc84a9028 69/86: Fix spell-fu-directory's documentation, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 53bd2b24c6 81/86: Cleanup: add spell-fu--canonicalize-word utility function, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu a5a06e150a 02/86: Fix error comparing times of cache to word-list, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu bd00417a0e 09/86: Improve status messages when generating word-list & cache, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu afeb1fd46f 10/86: readme: add some TODO's, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu b7e5cf3d73 11/86: Fix missing checks that ispell variables are bound before use, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 30be3683b2 12/86: readme: update settings docs, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 18724c2e53 14/86: Avoid potentially accessing the same files time multiple times, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 8e8711f1fa 22/86: Add TODO's to the readme, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 88d803e994 26/86: Cleanup: use updated auto-formatting results, ELPA Syncer, 2022/07/07