emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/cape da32e232d6 093/146: cape--company-call: Cheaper ti


From: ELPA Syncer
Subject: [elpa] externals/cape da32e232d6 093/146: cape--company-call: Cheaper timeout checking, throw error
Date: Sun, 9 Jan 2022 20:57:45 -0500 (EST)

branch: externals/cape
commit da32e232d6a983c1e2de836c0a6e4f544f1b45bf
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    cape--company-call: Cheaper timeout checking, throw error
---
 cape.el | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/cape.el b/cape.el
index e4c3386043..7985f62429 100644
--- a/cape.el
+++ b/cape.el
@@ -42,14 +42,6 @@
   "Dictionary word list file."
   :type 'string)
 
-(defcustom cape-company-async-timeout 1.0
-  "Company asynchronous timeout."
-  :type 'float)
-
-(defcustom cape-company-async-wait 0.02
-  "Company asynchronous busy waiting time."
-  :type 'float)
-
 (defcustom cape-dabbrev-min-length 4
   "Minimum length of dabbrev expansions."
   :type 'integer)
@@ -723,16 +715,21 @@ If INTERACTIVE is nil the function acts like a capf."
               :annotation-function (funcall extra-fun :annotation-function)
               :exit-function (lambda (x _status) (funcall (funcall extra-fun 
:exit-function) x)))))))
 
+(defvar company-async-wait)
+(defvar company-async-timeout)
+
 (defun cape--company-call (backend &rest args)
   "Call Company BACKEND with ARGS."
   (pcase (apply backend args)
     (`(:async . ,fetcher)
-     (let ((res 'trash))
-       ;; Force synchronization
+     (let ((res 'trash)
+           (start (time-to-seconds)))
        (funcall fetcher (lambda (arg) (setq res arg)))
-       (with-timeout (cape-company-async-timeout (setq res nil))
-         (while (eq res 'trash)
-           (sleep-for cape-company-async-wait)))
+       ;; Force synchronization
+       (while (eq res 'trash)
+         (sleep-for company-async-wait)
+         (when (> (- (time-to-seconds) start) company-async-timeout)
+           (error "Cape company backend async timeout")))
        res))
     (res res)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]