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

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

[nongnu] elpa/idle-highlight-mode 1e0b38c09f 02/59: [Refactor] Save the


From: ELPA Syncer
Subject: [nongnu] elpa/idle-highlight-mode 1e0b38c09f 02/59: [Refactor] Save the last highlighted regexp in a variable for easier unhighlighting.
Date: Thu, 7 Jul 2022 12:00:28 -0400 (EDT)

branch: elpa/idle-highlight-mode
commit 1e0b38c09f4616e31217a4493dd3e45ea07a3874
Author: Cornelius Mika <cornelius.mika@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    [Refactor] Save the last highlighted regexp in a variable for easier 
unhighlighting.
---
 idle-highlight.el | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/idle-highlight.el b/idle-highlight.el
index 9cdd700db8..6f67fe7bbb 100755
--- a/idle-highlight.el
+++ b/idle-highlight.el
@@ -62,7 +62,7 @@
   "Face used to highlight other occurrences of the word at point."
   :group 'idle-highlight)
 
-(defvar idle-highlight-last-word nil "Last word to be idle-highlighted.")
+(defvar idle-highlight-last-regexp nil "Last regexp to be idle-highlighted.")
 
 (defvar idle-highlight-timer nil "Timer to activate re-highlighting.")
 
@@ -72,15 +72,15 @@
     (
       (target-symbol (symbol-at-point))
       (target (symbol-name target-symbol)))
-    (when idle-highlight-last-word
-      (unhighlight-regexp (concat "\\<" (regexp-quote 
idle-highlight-last-word) "\\>")))
+    (if idle-highlight-last-regexp
+      (unhighlight-regexp idle-highlight-last-regexp))
     (when
       (and
         idle-highlight-timer target target-symbol
         ;; TODO: no need to highlight keywords like if
         (not (in-string-p)) (not (equal target "end")))
-      (highlight-regexp (concat "\\<" (regexp-quote target) "\\>") 
'idle-highlight)
-      (setq idle-highlight-last-word target))))
+      (setq idle-highlight-last-regexp (concat "\\<" (regexp-quote target) 
"\\>"))
+      (highlight-regexp idle-highlight-last-regexp 'idle-highlight))))
 
 ;;;###autoload
 (defun idle-highlight (&optional arg)
@@ -90,7 +90,7 @@
     (progn
       (cancel-timer idle-highlight-timer)
       (setq idle-highlight-timer nil))
-    (set (make-local-variable 'idle-highlight-last-word) nil)
+    (set (make-local-variable 'idle-highlight-last-regexp) nil)
     (set
       (make-local-variable 'idle-highlight-timer)
       (run-with-idle-timer 0.5 :repeat 'idle-highlight-word-at-point))))



reply via email to

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