From 13c75510158faffc45e5391a77a6b077ee26e8dc Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Thu, 29 Sep 2022 20:38:58 +0300 Subject: [PATCH] ENHANCED: only fontify visible sweeprolog-mode buffers on idle --- sweeprolog.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sweeprolog.el b/sweeprolog.el index 03593e4..1f03c2c 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -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) -- 2.39.2