]> git.eshelyaron.com Git - dict.git/commitdiff
ADDED: sweep-colourise-buffer-on-idle user option, on by default
authorEshel Yaron <me@eshelyaron.com>
Mon, 12 Sep 2022 15:42:24 +0000 (18:42 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 12 Sep 2022 15:42:24 +0000 (18:42 +0300)
NEWS.org
README.org
sweep.el

index d8d2628106b4fec1c28686d8786383cd2e0aa0f7..0e459a18d228918dfadf5468dc2ede5fa0388816 100644 (file)
--- a/NEWS.org
+++ b/NEWS.org
@@ -2,14 +2,14 @@
 #+author:                Eshel Yaron
 #+email:                 me@eshelyaron.com
 #+language:              en
-#+options:               ':t toc:nil num:nil
+#+options:               ':t toc:nil num:nil ^:{}
 #+startup:               content indent
 #+MACRO: version (eval (mapconcat #'number-to-string (save-current-buffer (with-current-buffer (find-file (expand-file-name "sweep.el" (file-name-directory $1))) (package-desc-version (package-buffer-info)))) "."))
 
 This file is about changes in =sweep= up to version
 {{{version({{{input-file}}})}}}.
 
-* New commands available in sweep {{{version({{{input-file}}})}}}
+* New commands available in =sweep= {{{version({{{input-file}}})}}}
 
 ** New command =sweep-load-buffer=.
 
@@ -20,12 +20,31 @@ the current buffer by default.
 
 Follows file specifications in =sweep-mode= buffers.
 
+
 * New keybindings in =sweep-mode= buffers
 
 ** =C-c C-l= is now bound to =sweep-load-buffer=.
 
 ** =C-c C-o= is now bound to =sweep-find-file-at-point=.
 
+* New user options available in =sweep= {{{version({{{input-file}}})}}}
+
+** New user option =sweep-colourise-buffer-on-idle=
+
+This option is a boolean flag that determines whether to enable
+automatic updating of semantic highlighting in =sweep-mode= buffers.
+
+** New user option =sweep-colourise-buffer-min-interval=
+
+This option determines the minimum number of idle seconds that =sweep=
+will wait before updating semantic highlighting in a =sweep-mode=
+buffer.
+
+** New user option =sweep-colourise-buffer-max-size=
+
+This option determines the maximum size of a =sweep-mode= buffer for
+which =sweep= will periodically update semantic highlighting on idle.
+
 
 * New keybindings in =sweep-prefix-map=
 
index ac95947936ffe21d9f793daf655b705d8d500591..58d396f5571a0089ab65d78af3b35d49abaff230 100644 (file)
@@ -292,7 +292,8 @@ is performed on demand.  When a buffer is first opened in =sweep-mode=,
 its entire contents are analyzed to collect and cache cross reference
 data, and the buffer is highlighted accordingly.  In contrast, when
 editing and moving around the buffer, a faster, local analysis is
-invoked to updated the semantic highlighting.
+invoked to updated the semantic highlighting in response to changes in
+the buffer.
 
 #+FINDEX: sweep-colourise-buffer
 At any point in a =sweep-mode= buffer, the command =C-c C-c= (or =M-x
@@ -300,6 +301,18 @@ sweep-colourise-buffer=) can be used to update the cross reference
 cache and highlight the buffer accordingly.  This may be useful
 e.g. after defining a new predicate.
 
+#+VINDEX: sweep-colourise-buffer-on-idle
+#+VINDEX: sweep-colourise-buffer-max-size
+#+VINDEX: sweep-colourise-buffer-min-interval
+If the user option =sweep-colourise-buffer-on-idle= is set to non-nil
+(as it is by default), =sweep-mode= also updates semantic highlighting
+in the buffer whenever Emacs is idle for a reasonable amount of time,
+unless the buffer is larger than the value of the
+=sweep-colourise-buffer-max-size= user option ( 100,000 by default).
+The minimum idle time to wait before automatically updating semantic
+highlighting can be set via the user option
+=sweep-colourise-buffer-min-interval=.
+
 #+CINDEX: sweep-faces
 =sweep= defines more than 60 different faces (named sets of properties
 that determine the appearance of a specific text in Emacs buffers, see
index addc4164810f6564ad5c6668a5d7a732b3e00558..8a30ea68310c9e3242d5eb53b89b64aff00a2238 100644 (file)
--- a/sweep.el
+++ b/sweep.el
   "SWI-Prolog Embedded in Emacs."
   :group 'prolog)
 
+(defcustom sweep-colourise-buffer-on-idle t
+  "If non-nil, update highlighting of `sweep-mode' buffers on idle."
+  :package-version '((sweep . "0.2.0"))
+  :type 'boolean
+  :group 'sweep)
+
 (defcustom sweep-colourise-buffer-max-size 100000
   "Maximum buffer size to recolourise on idle."
   :package-version '((sweep . "0.2.0"))
@@ -1345,18 +1351,19 @@ Interactively, POINT is set to the current point."
   (add-hook 'xref-backend-functions #'sweep--xref-backend nil t)
   (add-hook 'file-name-at-point-functions #'sweep-file-at-point nil t)
   (add-hook 'completion-at-point-functions #'sweep-completion-at-point-function nil t)
-  (setq sweep--timer (run-with-idle-timer (max sweep-colourise-buffer-min-interval
-                                               (* 10 sweep--colourise-buffer-duration))
-                                          t
-                                          (let ((buffer (current-buffer)))
-                                            (lambda ()
-                                              (unless (< sweep-colourise-buffer-max-size
-                                                         (buffer-size buffer))
-                                                (sweep-colourise-buffer buffer))))))
-  (add-hook 'kill-buffer-hook
-            (lambda ()
-              (when (timerp sweep--timer)
-                (cancel-timer sweep--timer)))))
+  (when sweep-colourise-buffer-on-idle
+    (setq sweep--timer (run-with-idle-timer (max sweep-colourise-buffer-min-interval
+                                                 (* 10 sweep--colourise-buffer-duration))
+                                            t
+                                            (let ((buffer (current-buffer)))
+                                              (lambda ()
+                                                (unless (< sweep-colourise-buffer-max-size
+                                                           (buffer-size buffer))
+                                                  (sweep-colourise-buffer buffer))))))
+    (add-hook 'kill-buffer-hook
+              (lambda ()
+                (when (timerp sweep--timer)
+                  (cancel-timer sweep--timer))))))
 
 ;;;; Testing: