[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu aec861d832: Try to reuse timer (see #404)
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu aec861d832: Try to reuse timer (see #404) |
Date: |
Fri, 29 Dec 2023 06:57:34 -0500 (EST) |
branch: externals/corfu
commit aec861d832236dd35969c50930f1c9f6ea5fb122
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Try to reuse timer (see #404)
With this change the Corfu PCH doesn't appear anymore in the profile as
long as
auto completion doesn't trigger, for example when repeatedly pressing a DEL
a
DEL a DEL...
---
corfu.el | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/corfu.el b/corfu.el
index ca9598f309..34c22d1007 100644
--- a/corfu.el
+++ b/corfu.el
@@ -984,20 +984,24 @@ See `completion-in-region' for the arguments BEG, END,
TABLE, PRED."
(defun corfu--auto-post-command ()
"Post command hook which initiates auto completion."
(when corfu--auto-timer
- (cancel-timer corfu--auto-timer)
- (setq corfu--auto-timer nil))
- (when (and (not completion-in-region-mode)
- (not defining-kbd-macro)
- (not buffer-read-only)
- (corfu--match-symbol-p corfu-auto-commands this-command)
- (corfu--popup-support-p))
- (if (<= corfu-auto-delay 0)
- (corfu--auto-complete-deferred)
- ;; Do not use idle timer since this leads to unpredictable pauses, in
- ;; particular with `flyspell-mode'.
- (setq corfu--auto-timer
- (run-at-time corfu-auto-delay nil
- #'corfu--auto-complete-deferred
(corfu--auto-tick))))))
+ (cancel-timer corfu--auto-timer))
+ (if (and (not completion-in-region-mode)
+ (not defining-kbd-macro)
+ (not buffer-read-only)
+ (corfu--match-symbol-p corfu-auto-commands this-command)
+ (corfu--popup-support-p))
+ (if (<= corfu-auto-delay 0)
+ (corfu--auto-complete-deferred)
+ ;; Do not use `timer-set-idle-time' since this leads to
+ ;; unpredictable pauses, in particular with `flyspell-mode'.
+ (unless corfu--auto-timer
+ (setq corfu--auto-timer (timer-create)))
+ (timer-set-time corfu--auto-timer
+ (timer-relative-time nil corfu-auto-delay))
+ (timer-set-function corfu--auto-timer #'corfu--auto-complete-deferred
+ (list (corfu--auto-tick)))
+ (unless (memq corfu--auto-timer timer-list)
+ (timer-activate corfu--auto-timer)))))
(defun corfu--auto-tick ()
"Return the current tick/status of the buffer.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/corfu aec861d832: Try to reuse timer (see #404),
ELPA Syncer <=