[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/highlight-parentheses 8869fba 21/49: Fix slowdown by movin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/highlight-parentheses 8869fba 21/49: Fix slowdown by moving overlays less often. |
Date: |
Sun, 15 Aug 2021 03:57:45 -0400 (EDT) |
branch: elpa/highlight-parentheses
commit 8869fba83d2939ce32e21be39ebc182c8a414851
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>
Fix slowdown by moving overlays less often.
Now a new function `hl-paren-initiate-highlight` is in `post-command-hook`
instead of `hl-paren-highlight` itself. The new function uses a timer to
skip
calls to `hl-paren-highlight` in case those come faster than about one in a
quarter of a second. That easily happens when scrolling by pressing and
holding
`C-n`.
Fixes issue #8.
In contrast to the subject of the issue, I don't use an idle timer but a
normal
one to ensure that the hl-paren updates are immediately visible from a
user's
point of view.
---
highlight-parentheses.el | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/highlight-parentheses.el b/highlight-parentheses.el
index 0597721..eeee89f 100644
--- a/highlight-parentheses.el
+++ b/highlight-parentheses.el
@@ -96,6 +96,9 @@ Color attributes might be overriden by `hl-paren-colors' and
This is used to prevent analyzing the same context over and over.")
(make-variable-buffer-local 'hl-paren-last-point)
+(defvar hl-paren-timer nil
+ "A timer initiating the movement of the `hl-paren-overlays'.")
+
(defun hl-paren-highlight ()
"Highlight the parentheses around point."
(unless (= (point) hl-paren-last-point)
@@ -109,13 +112,18 @@ This is used to prevent analyzing the same context over
and over.")
(cdr overlays))
(move-overlay (pop overlays) pos1 (1+ pos1))
(when (setq pos2 (scan-sexps pos1 1))
- (move-overlay (pop overlays) (1- pos2) pos2)
- ))
+ (move-overlay (pop overlays) (1- pos2) pos2)))
(error nil))
(goto-char pos))
(dolist (ov overlays)
(move-overlay ov 1 1)))))
+(defun hl-paren-initiate-highlight ()
+ "Move the `hl-paren-overlays' after a short fraction of time."
+ (when hl-paren-timer
+ (cancel-timer hl-paren-timer))
+ (setq hl-paren-timer (run-at-time 0.23 nil #'hl-paren-highlight)))
+
;;;###autoload
(define-minor-mode highlight-parentheses-mode
"Minor mode to highlight the surrounding parentheses."
@@ -123,10 +131,10 @@ This is used to prevent analyzing the same context over
and over.")
(mapc 'delete-overlay hl-paren-overlays)
(kill-local-variable 'hl-paren-overlays)
(kill-local-variable 'hl-paren-last-point)
- (remove-hook 'post-command-hook 'hl-paren-highlight t)
+ (remove-hook 'post-command-hook 'hl-paren-initiate-highlight t)
(when highlight-parentheses-mode
(hl-paren-create-overlays)
- (add-hook 'post-command-hook 'hl-paren-highlight nil t)))
+ (add-hook 'post-command-hook 'hl-paren-initiate-highlight nil t)))
;;;###autoload
(define-globalized-minor-mode global-highlight-parentheses-mode
- [nongnu] elpa/highlight-parentheses 5aa800a 26/49: Release version 1.1.0, (continued)
- [nongnu] elpa/highlight-parentheses 5aa800a 26/49: Release version 1.1.0, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 52a8d36 33/49: Added other brackets, so it works with other languages., ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses a5eace2 32/49: Added option for highlighting adjacent parens., ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 891538d 48/49: Squash emacs 28 define-minor-mode warning; release 2.0.3, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses fdabfda 47/49: Remove cl-lib dependency since it's included in Emacs 24.3 anyhow; release 2.0.2, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 9a99a4b 42/49: Fix custom type error of highlight-parentheses-attributes, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 3b4d2c6 46/49: Add .elpaignore, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses bef1bc2 14/49: Add configuration for travis-ci., ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses e653594 15/49: Add README with travis build state., ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses d421e15 17/49: Add globalized highlight-parentheses-mode, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 8869fba 21/49: Fix slowdown by moving overlays less often.,
ELPA Syncer <=
- [nongnu] elpa/highlight-parentheses 5e1fa9d 22/49: Make overlays front-advancing, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 9b9137b 24/49: New defcustom: hl-paren-delay (see issue #12), ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses ebf8827 25/49: Fix Travis build incidator, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses c38885b 31/49: Merge pull request #18 from Bad-ptr/master, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 73b4aa7 34/49: Added angle brackets!, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 69c694a 30/49: Allow hl-paren- -[background-]colors, -attributes to be functions, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses f0bd58c 35/49: Merge pull request #20 from tprk77/master, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 21fd617 41/49: Update README, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses b335e9e 49/49: Don't exclude README.md from ELPA package, ELPA Syncer, 2021/08/15
- [nongnu] elpa/highlight-parentheses 59ff08a 23/49: Merge pull request #11 from tsdh/master, ELPA Syncer, 2021/08/15