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

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

[elpa] externals/cape b3e2850fcf 108/146: Add unwind-protect


From: ELPA Syncer
Subject: [elpa] externals/cape b3e2850fcf 108/146: Add unwind-protect
Date: Sun, 9 Jan 2022 20:57:46 -0500 (EST)

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

    Add unwind-protect
---
 cape.el | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/cape.el b/cape.el
index 6251e114f5..d653593af5 100644
--- a/cape.el
+++ b/cape.el
@@ -744,20 +744,22 @@ If INTERACTIVE is nil the function acts like a capf."
       (`(:async . ,future)
        (let ((res 'cape--waiting)
              (start (time-to-seconds)))
-         (funcall future (lambda (arg)
-                           (when (eq res 'cape--waiting)
-                             (push 'cape--event unread-command-events))
-                           (setq res arg)))
-         ;; Force synchronization.
-         (while (eq res 'cape--waiting)
-           ;; When we've got input, interrupt the computation.
-           (when (and unread-command-events toi)
-             (throw toi nil))
-           (when (> (- (time-to-seconds) start) cape-company-timeout)
-             (error "Cape company backend async timeout"))
-           (sit-for 0.1 'noredisplay))
-         ;; Remove cape--events introduced by future callback
-         (setq unread-command-events (delq 'cape--event unread-command-events))
+         (unwind-protect
+             (progn
+               (funcall future (lambda (arg)
+                                 (when (eq res 'cape--waiting)
+                                   (push 'cape--event unread-command-events))
+                                 (setq res arg)))
+               ;; Force synchronization.
+               (while (eq res 'cape--waiting)
+                 ;; When we've got input, interrupt the computation.
+                 (when (and unread-command-events toi)
+                   (throw toi nil))
+                 (when (> (- (time-to-seconds) start) cape-company-timeout)
+                   (error "Cape company backend async timeout"))
+                 (sit-for 0.1 'noredisplay)))
+           ;; Remove cape--events introduced by future callback
+           (setq unread-command-events (delq 'cape--event 
unread-command-events)))
          res))
       (res res))))
 



reply via email to

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