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

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

[nongnu] elpa/hl-block-mode e7b5b014c9 10/64: Fix: localize hook & timer


From: ELPA Syncer
Subject: [nongnu] elpa/hl-block-mode e7b5b014c9 10/64: Fix: localize hook & timer running when it shouldn't
Date: Thu, 7 Jul 2022 12:00:01 -0400 (EDT)

branch: elpa/hl-block-mode
commit e7b5b014c9d18cf87930d58dce2836b03de64b49
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Fix: localize hook & timer running when it shouldn't
---
 hl-block-mode.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/hl-block-mode.el b/hl-block-mode.el
index 685d833ff4..83a9eade1c 100644
--- a/hl-block-mode.el
+++ b/hl-block-mode.el
@@ -124,6 +124,11 @@ Inverse of `color-values'."
                  (setq end-prev end)))
              (cdr block-list))))))
 
+(defun hl-block--overlay-refresh-from-timer ()
+  "Ensure this mode has not been disabled
+(from switching buffers for eg) before highlighting."
+  (when hl-block-mode (hl-block--overlay-refresh)))
+
 ;; Timer
 (defvar hl-block--delay-timer nil)
 
@@ -133,22 +138,23 @@ Inverse of `color-values'."
     (cancel-timer hl-block--delay-timer))
   (setq hl-block--delay-timer
         (run-with-idle-timer hl-block-delay t
-                             'hl-block--overlay-refresh)))
+                             'hl-block--overlay-refresh-from-timer)))
 
 (defun hl-block-mode-enable ()
   "Turn on 'hl-block-mode' for the current buffer."
-  (add-hook 'post-command-hook 'hl-block--overlay-delay))
+  (add-hook 'post-command-hook #'hl-block--overlay-delay nil t))
 
 (defun hl-block-mode-disable ()
   "Turn off 'hl-block-mode' for the current buffer."
   (hl-block--overlay-clear)
   (when (timerp hl-block--delay-timer)
     (cancel-timer hl-block--delay-timer))
-  (remove-hook 'post-command-hook 'hl-block--overlay-delay))
+  (remove-hook 'post-command-hook #'hl-block--overlay-delay t))
 
 ;;;###autoload
 (define-minor-mode hl-block-mode
   "Highlight block under the cursor."
+  :global nil
   :lighter ""
   (cond (hl-block-mode
          (jit-lock-unregister 'hl-block-mode-enable)



reply via email to

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