[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog d1a2913f75 115/166: ENHANCED: Update semantic h
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sweeprolog d1a2913f75 115/166: ENHANCED: Update semantic highlighting on idle timer in sweep-mode |
Date: |
Fri, 30 Sep 2022 04:59:30 -0400 (EDT) |
branch: elpa/sweeprolog
commit d1a2913f75385914c880ea3533108e6a77085494
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
ENHANCED: Update semantic highlighting on idle timer in sweep-mode
(sweep-colourise-buffer-max-size): new user option
(sweep-colourise-buffer-min-interval): new user option
(sweep-mode): setup highlighting on idle timer
---
sweep.el | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/sweep.el b/sweep.el
index f3b192942c..addc416481 100644
--- a/sweep.el
+++ b/sweep.el
@@ -32,6 +32,18 @@
"SWI-Prolog Embedded in Emacs."
:group 'prolog)
+(defcustom sweep-colourise-buffer-max-size 100000
+ "Maximum buffer size to recolourise on idle."
+ :package-version '((sweep . "0.2.0"))
+ :type 'integer
+ :group 'sweep)
+
+(defcustom sweep-colourise-buffer-min-interval 2
+ "Minimum idle time to wait before recolourising the buffer."
+ :package-version '((sweep . "0.2.0"))
+ :type 'float
+ :group 'sweep)
+
(defcustom sweep-swipl-path nil
"Path to the swipl executable.
When non-nil, this is used by the embedded SWI-Prolog runtime to
@@ -961,9 +973,9 @@ Interactively, a prefix arg means to prompt for BUFFER."
comint-delimiter-argument-list '(?,)
comment-start "%")
(add-hook 'post-self-insert-hook
#'sweep-top-level--post-self-insert-function nil t)
- (setq sweep-top-level-timer (run-with-idle-timer 0.2 t
#'sweep-colourise-query (current-buffer)))
- (add-hook 'completion-at-point-functions
#'sweep-completion-at-point-function nil t)
(setq sweep-buffer-module "user")
+ (add-hook 'completion-at-point-functions
#'sweep-completion-at-point-function nil t)
+ (setq sweep-top-level-timer (run-with-idle-timer 0.2 t
#'sweep-colourise-query (current-buffer)))
(add-hook 'kill-buffer-hook
(lambda ()
(when (timerp sweep-top-level-timer)
@@ -1305,6 +1317,9 @@ Interactively, POINT is set to the current point."
(xref-make-file-location path line 0))))
matches)))
+(defvar-local sweep--timer nil)
+(defvar-local sweep--colourise-buffer-duration 0.2)
+
;;;###autoload
(define-derived-mode sweep-mode prog-mode "sweep"
"Major mode for reading and editing Prolog code."
@@ -1323,11 +1338,25 @@ Interactively, POINT is set to the current point."
nil
nil
(font-lock-fontify-region-function .
sweep-colourise-some-terms)))
- (sweep-colourise-buffer)
+ (let ((time (current-time)))
+ (sweep-colourise-buffer)
+ (setq sweep--colourise-buffer-duration (float-time (time-since time))))
(sweep--set-buffer-module)
(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))
+ (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)))))
;;;; Testing:
- [nongnu] elpa/sweeprolog b2838d5477 004/166: Cleanup, (continued)
- [nongnu] elpa/sweeprolog b2838d5477 004/166: Cleanup, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 4f96499382 011/166: DOC: expand README.org, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 5c4aef50f2 041/166: Run `ninja install` as root in CI, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a6e37f306b 069/166: ENHANCED: fontify mutlifile predicate calls in a dedicated face, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 4299c39d62 070/166: ENHANCED: indentation edge cases handling, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1a19f7b3be 074/166: DOC: document font-lock and xref integration for sweep-mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1c6d2e96a8 078/166: ENHANCED: allow user to specify location of swipl binary, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 5a8f70149f 099/166: FIXED: (sweep-load-buffer): error after prompting for a buffer, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 7327016d15 095/166: FIXED: sweep_predicates_collection/2: include preds defined in user, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a70a730f48 087/166: PORT: don't use the 2nd arg to looking-at, added only in Emacs 29, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog d1a2913f75 115/166: ENHANCED: Update semantic highlighting on idle timer in sweep-mode,
ELPA Syncer <=
- [nongnu] elpa/sweeprolog b168465391 098/166: FIXED: sweep_load_buffer/3: load files in the context of "user", ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog db7ef44a61 083/166: DOC: add manual section about setting Prolog flags, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 521a4bfde5 132/166: BUILD: replaced Makefile with CMakeLists.txt, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog ecf601dd54 133/166: FIXED: indentation error when typing at end of buffer, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 7bca15bd1e 141/166: DOC: fix copy-paste error in README.org, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 83bbd58031 153/166: ADDED: new command sweeprolog-restart for resetting sweep, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a369e46143 160/166: ENHANCED: underline occurrences of the variable at point, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 8d13f21c0d 162/166: ADDED: new command sweeprolog-highlight-variable, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 3d5d0deda5 161/166: ADDED: new user option sweeprolog-enable-cursor-sensor, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 8f0e4a644d 164/166: FIXED: error on interactively removing variable highlighting, ELPA Syncer, 2022/09/30