summaryrefslogtreecommitdiff
path: root/cape.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2022-02-09 17:22:44 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2022-02-09 17:22:44 +0100
commit45dee1156393ab2ea52eff206f942eac5cd9cce1 (patch)
treead72ecae4589dfc2b11813e4e67d7b8ae1810d92 /cape.el
parent46d8aaab10bc63def92b9d17caf4d09d18a992c3 (diff)
Experiment with a different synchronization method (See #25)
Diffstat (limited to 'cape.el')
-rw-r--r--cape.el28
1 files changed, 11 insertions, 17 deletions
diff --git a/cape.el b/cape.el
index 5fcaafa..d000bd5 100644
--- a/cape.el
+++ b/cape.el
@@ -879,23 +879,17 @@ If INTERACTIVE is nil the function acts like a capf."
(if toi
(unwind-protect
(progn
- (funcall fetch (lambda (arg)
- (when (eq res 'cape--waiting)
- (push 'cape--done unread-command-events))
- (setq res arg)))
- ;; Force synchronization, interruptible!
- (while (eq res 'cape--waiting)
- ;; When we've got input, interrupt the computation.
- (when unread-command-events (throw toi nil))
- (sit-for 0.1 'noredisplay)))
- ;; Remove cape--done introduced by future callback.
- ;; NOTE: `sit-for' converts cape--done to (t . cape--done).
- ;; It seems that `sit-for' does not use a robust method to
- ;; reinject inputs, maybe the implementation will change in
- ;; the future.
- (setq unread-command-events (delq 'cape--done
- (delete '(t . cape--done)
- unread-command-events))))
+ (funcall fetch
+ (lambda (arg)
+ (when (eq res 'cape--waiting)
+ (push 'cape--done unread-command-events))
+ (setq res arg)))
+ (let ((input-method-function nil))
+ (read-event nil t))
+ (when (eq res 'cape--waiting)
+ (throw toi nil)))
+ (setq unread-command-events
+ (delq 'cape--done unread-command-events)))
(funcall fetch (lambda (arg) (setq res arg)))
;; Force synchronization, not interruptible! We use polling
;; here and ignore pending input since we don't use