]> git.eshelyaron.com Git - dict.git/commitdiff
ENHANCED: only fontify visible sweeprolog-mode buffers on idle
authorEshel Yaron <me@eshelyaron.com>
Thu, 29 Sep 2022 17:38:58 +0000 (20:38 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 29 Sep 2022 17:38:58 +0000 (20:38 +0300)
sweeprolog.el

index 03593e4cd3c1db57046132d6f371c1e0202f353e..1f03c2cb6d957c4d9e64ef4f7cbf0e37e1d69b17 100644 (file)
@@ -2143,14 +2143,18 @@ Interactively, POINT is set to the current point."
   (add-hook 'file-name-at-point-functions #'sweeprolog-file-at-point nil t)
   (add-hook 'completion-at-point-functions #'sweeprolog-completion-at-point-function nil t)
   (when sweeprolog-colourise-buffer-on-idle
-    (setq sweeprolog--timer (run-with-idle-timer (max sweeprolog-colourise-buffer-min-interval
-                                                 (* 10 sweeprolog--colourise-buffer-duration))
-                                            t
-                                            (let ((buffer (current-buffer)))
-                                              (lambda ()
-                                                (unless (< sweeprolog-colourise-buffer-max-size
-                                                           (buffer-size buffer))
-                                                  (sweeprolog-colourise-buffer buffer))))))
+    (setq sweeprolog--timer
+          (run-with-idle-timer
+           (max sweeprolog-colourise-buffer-min-interval
+                (* 10 sweeprolog--colourise-buffer-duration))
+           t
+           (let ((buffer (current-buffer)))
+             (lambda ()
+               (when (and (buffer-live-p buffer)
+                          (not (< sweeprolog-colourise-buffer-max-size
+                                  (buffer-size buffer)))
+                          (get-buffer-window buffer))
+                 (sweeprolog-colourise-buffer buffer))))))
     (add-hook 'kill-buffer-hook
               (lambda ()
                 (when (timerp sweeprolog--timer)