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

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

[nongnu] elpa/symbol-overlay 39f772b531 137/152: Prefer to check for sel


From: ELPA Syncer
Subject: [nongnu] elpa/symbol-overlay 39f772b531 137/152: Prefer to check for selected window in timer callback
Date: Thu, 7 Jul 2022 12:04:22 -0400 (EDT)

branch: elpa/symbol-overlay
commit 39f772b531117edba596e7a1210b3dbb87d56adb
Author: Steve Purcell <steve@sanityinc.com>
Commit: Steve Purcell <steve@sanityinc.com>

    Prefer to check for selected window in timer callback
    
    This way we can avoid any work at all when the buffer whose timer is
    triggering is not visible.
---
 symbol-overlay.el | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/symbol-overlay.el b/symbol-overlay.el
index a1fcc3e629..28f7753364 100644
--- a/symbol-overlay.el
+++ b/symbol-overlay.el
@@ -339,18 +339,21 @@ This only affects symbols in the current displayed window 
if
   (when symbol-overlay-timer
     (cancel-timer symbol-overlay-timer)))
 
+(defun symbol-overlay-idle-timer (buf)
+  "Idle timer callback for BUF.
+This is used to maybe highlight the symbol at point, but only if
+the buffer is visible in the currently-selected window at the
+time."
+  (when (and (buffer-live-p buf) (eq (window-buffer) buf))
+    (with-current-buffer buf
+      (symbol-overlay-maybe-put-temp))))
+
 (defun symbol-overlay-update-timer (value)
   "Update `symbol-overlay-timer' with new idle-time VALUE."
   (symbol-overlay-cancel-timer)
   (setq symbol-overlay-timer
         (and value (> value 0)
-             (run-with-idle-timer
-              value t
-              (lambda (buf)
-                (when (buffer-live-p buf)
-                  (with-current-buffer buf
-                    (symbol-overlay-maybe-put-temp))))
-              (current-buffer)))))
+             (run-with-idle-timer value t 'symbol-overlay-idle-timer 
(current-buffer)))))
 
 (defun symbol-overlay-post-command ()
   "Installed on `post-command-hook'."



reply via email to

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