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

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

[nongnu] elpa/symbol-overlay 4a70f6d999 075/152: When renaming, don't ad


From: ELPA Syncer
Subject: [nongnu] elpa/symbol-overlay 4a70f6d999 075/152: When renaming, don't add coloured highlight if there wasn't previously one
Date: Thu, 7 Jul 2022 12:04:16 -0400 (EDT)

branch: elpa/symbol-overlay
commit 4a70f6d999450b8ae5a83af71ef2f6b82428a9ed
Author: Steve Purcell <steve@sanityinc.com>
Commit: GitHub <noreply@github.com>

    When renaming, don't add coloured highlight if there wasn't previously one
    
    I don't use coloured symbol overlays, but I use lazy highlighting and 
`symbol-overlay-rename`. After renaming, that function adds a coloured overlay, 
where none previously existed. With this commit, a new coloured overlay is 
added only if there was one prior to renaming, which reduces the friction of 
this function in my use case.
---
 symbol-overlay.el | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/symbol-overlay.el b/symbol-overlay.el
index e986e71609..b4b759ba82 100644
--- a/symbol-overlay.el
+++ b/symbol-overlay.el
@@ -520,14 +520,16 @@ DIR must be 1 or -1."
                              (substring symbol 3 -3))
            new (symbol-overlay-get-symbol txt))
       (unless (string= new symbol)
-       (symbol-overlay-maybe-remove (symbol-overlay-assoc new))
-       (save-excursion
-         (save-restriction
-           (symbol-overlay-narrow scope)
-           (goto-char (point-min))
-           (let ((inhibit-modification-hooks t))
-             (while (re-search-forward symbol nil t) (replace-match txt t)))))
-       (setq keyword (symbol-overlay-put-all new scope keyword)))
+        (let ((prev-overlay (symbol-overlay-assoc new)))
+         (symbol-overlay-maybe-remove prev-overlay)
+         (save-excursion
+           (save-restriction
+             (symbol-overlay-narrow scope)
+             (goto-char (point-min))
+             (let ((inhibit-modification-hooks t))
+               (while (re-search-forward symbol nil t) (replace-match txt 
t)))))
+          (when prev-overlay
+           (setq keyword (symbol-overlay-put-all new scope keyword)))))
       (when (string= new (symbol-overlay-get-symbol nil t))
        (symbol-overlay-maybe-count keyword)))))
 



reply via email to

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