summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2022-01-22 23:15:50 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2022-01-22 23:15:50 +0100
commit641ea484628f12aa56515792ce4f9012c2e23b1c (patch)
treea982e28d257de1e6cc29ebb619ec9a56bbfa161b
parentbb877881b357627536b14a380bca5f5f4e75afe7 (diff)
Introduce `corfu--auto-tick' which captures the buffer tick/status (Fix #107)
If Corfu is used in conjunction with multiple-cursors one has to overwrite `corfu--auto-tick', such that it captures less information.
-rw-r--r--corfu.el17
1 files changed, 10 insertions, 7 deletions
diff --git a/corfu.el b/corfu.el
index a0b07b3..10516a4 100644
--- a/corfu.el
+++ b/corfu.el
@@ -1119,11 +1119,10 @@ See `completion-in-region' for the arguments BEG, END, TABLE, PRED."
(define-key map (vector last-command-event) replace)
(funcall replace)))
-(defun corfu--auto-complete (buf tick pt)
- "Initiate auto completion if BUF, TICK and PT did not change."
+(defun corfu--auto-complete (tick)
+ "Initiate auto completion if TICK did not change."
(setq corfu--auto-timer nil)
- (when (and (not completion-in-region-mode) (eq buf (current-buffer))
- (eq tick (buffer-chars-modified-tick)) (eq pt (point)))
+ (when (and (not completion-in-region-mode) (equal tick (corfu--auto-tick)))
(pcase (while-no-input ;; Interruptible capf query
(run-hook-wrapped 'completion-at-point-functions #'corfu--capf-wrapper))
((and `(,fun ,beg ,end ,table . ,plist)
@@ -1154,9 +1153,13 @@ See `completion-in-region' for the arguments BEG, END, TABLE, PRED."
;; NOTE: Do not use idle timer since this leads to unacceptable slowdowns,
;; in particular if flyspell-mode is enabled.
(setq corfu--auto-timer
- (run-at-time
- corfu-auto-delay nil #'corfu--auto-complete
- (current-buffer) (buffer-chars-modified-tick) (point)))))
+ (run-at-time corfu-auto-delay nil
+ #'corfu--auto-complete (corfu--auto-tick)))))
+
+(defun corfu--auto-tick ()
+ "Return the current tick/status of the buffer.
+Auto completion is only performed if the tick did not change."
+ (list (current-buffer) (buffer-chars-modified-tick) (point)))
;;;###autoload
(define-minor-mode corfu-mode