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

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

[nongnu] elpa/with-simulated-input a718d66c5d 039/134: Don't generate a


From: ELPA Syncer
Subject: [nongnu] elpa/with-simulated-input a718d66c5d 039/134: Don't generate a new canary for each call
Date: Mon, 10 Jan 2022 23:00:03 -0500 (EST)

branch: elpa/with-simulated-input
commit a718d66c5d45c7174554c321a56f97796925ffa8
Author: Ryan C. Thompson <rct@thompsonclan.org>
Commit: Ryan C. Thompson <rct@thompsonclan.org>

    Don't generate a new canary for each call
    
    A single canary value is sufficient for all calls to
    "with-simulated-input".
---
 with-simulated-input.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/with-simulated-input.el b/with-simulated-input.el
index a882084ef9..99c90aec45 100644
--- a/with-simulated-input.el
+++ b/with-simulated-input.el
@@ -121,6 +121,9 @@ environment."
       `(closure ,env () ,expr)
     `(lambda () ,expr)))
 
+(defconst wsi--canary-sym (cl-gensym "wsi-canary-")
+  "A unique symbol.")
+
 ;;;###autoload
 (defmacro with-simulated-input (keys &rest body)
   "Eval BODY forms with KEYS as simulated input.
@@ -160,15 +163,14 @@ in `progn'."
   `(cl-letf*
        ((lexenv (wsi-current-lexical-environment))
         (next-action-key (wsi-get-unbound-key))
-        (canary-sym ',(cl-gensym "wsi-canary-"))
-        (result canary-sym)
+        (result wsi--canary-sym)
         (thrown-error nil)
         (body-form
          '(throw 'wsi-body-finished (progn ,@body)))
         (end-of-actions-form
          (list 'throw
                '(quote wsi-body-finished)
-               (list 'quote canary-sym)))
+               (list 'quote wsi--canary-sym)))
         ;; Ensure KEYS is a list, and put the body form as the first
         ;; item and `C-g' as the last item
         (keylist ,keys)
@@ -233,7 +235,7 @@ in `progn'."
         (throw 'wsi-threw-error nil)))
      (when thrown-error
        (signal (car thrown-error) (cdr thrown-error)))
-     (if (eq result canary-sym)
+     (if (eq result wsi--canary-sym)
          (error "Reached end of simulated input while evaluating body")
        result)))
 



reply via email to

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