branch: externals/cape
commit fd8828cff312e3294b158118ddaee89c0b30036b
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
Make cape--company-call more robust
---
cape.el | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/cape.el b/cape.el
index 3a90031b6b..d0a1bcd5a7 100644
--- a/cape.el
+++ b/cape.el
@@ -738,19 +738,21 @@ If INTERACTIVE is nil the function acts like a capf."
(defun cape--company-call (backend &rest args)
"Call Company BACKEND with ARGS."
;; Company backends are non-interruptible.
- (pcase (let (throw-on-input) (apply backend args))
- (`(:async . ,fetcher)
- (let ((res 'trash)
- (start (time-to-seconds)))
- ;; Company backends are non-interruptible.
- (let (throw-on-input) (funcall fetcher (lambda (arg) (setq res arg))))
- ;; Force synchronization. The synchronization is interruptible!
- (while (eq res 'trash)
- (sleep-for cape-company-async-wait)
- (when (> (- (time-to-seconds) start) cape-company-async-timeout)
- (error "Cape company backend async timeout")))
- res))
- (res res)))
+ (let ((old-toi throw-on-input)
+ (throw-on-input nil))
+ (pcase (apply backend args)
+ (`(:async . ,fetcher)
+ (let ((res 'trash)
+ (start (time-to-seconds)))
+ (funcall fetcher (lambda (arg) (setq res arg)))
+ ;; Force synchronization. The synchronization is interruptible!
+ (let ((throw-on-input old-toi))
+ (while (eq res 'trash)
+ (sleep-for cape-company-async-wait)
+ (when (> (- (time-to-seconds) start) cape-company-async-timeout)
+ (error "Cape company backend async timeout"))))
+ res))
+ (res res))))
;;;###autoload
(defun cape-company-to-capf (backend &optional valid)