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

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

[nongnu] elpa/with-simulated-input 14f3d86cb3 071/134: Fix tests


From: ELPA Syncer
Subject: [nongnu] elpa/with-simulated-input 14f3d86cb3 071/134: Fix tests
Date: Mon, 10 Jan 2022 23:00:06 -0500 (EST)

branch: elpa/with-simulated-input
commit 14f3d86cb3e76ff017a9c84b07352440d3956c89
Author: Nikita Bloshchanevich <nikblos@outlook.com>
Commit: Nikita Bloshchanevich <nikblos@outlook.com>

    Fix tests
    
    Add a Caskfile.
    
    Add the old `switch-to-buffer' workaround.
    
    Add UNBOUND-KEY to the end of the `kbd' list, so that the "End of input" 
error
    can be thrown.
    
    Refactor: Move the `error' above into a lambda instead of checking ACTIONS 
every
    time in the next-form keybinding.
---
 Cask                    |  7 +++++++
 with-simulated-input.el | 22 ++++++++++++----------
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/Cask b/Cask
new file mode 100644
index 0000000000..f1dc54d301
--- /dev/null
+++ b/Cask
@@ -0,0 +1,7 @@
+(source gnu)
+(source melpa)
+
+(package-file "with-simulated-input.el")
+
+(development
+ (depends-on "buttercup"))
diff --git a/with-simulated-input.el b/with-simulated-input.el
index 21f671d57b..8af260d445 100644
--- a/with-simulated-input.el
+++ b/with-simulated-input.el
@@ -108,9 +108,13 @@ the body form as a function."
          ;; Ensure we don't interfere with any outside catching.
          (result-sym (make-symbol "result"))
          (error-sym (make-symbol "error"))
-         (actions (cons (lambda ()
-                          (throw result-sym (funcall main)))
-                        (cl-remove-if-not #'functionp keys)))
+         (orig-buf (current-buffer))
+         (actions (nconc (list (lambda ()
+                                 (switch-to-buffer orig-buf)
+                                 (throw result-sym (funcall main))))
+                         (cl-remove-if-not #'functionp keys)
+                         (list (lambda ()
+                                 (error "Reached end of simulated input while 
simulating body")))))
          (overriding-terminal-local-map
           (if overriding-terminal-local-map
               (copy-keymap overriding-terminal-local-map)
@@ -119,10 +123,7 @@ the body form as a function."
       (lambda ()
         (interactive)
         (condition-case data
-            (progn
-              (unless actions
-                (error "Reached end of simulated input while simulating body"))
-              (funcall (pop actions)))
+            (funcall (pop actions))
           (t (throw error-sym data)))))
     (catch result-sym
       ;; Signals are not passed trough `read-from-minibuffer'.
@@ -130,9 +131,10 @@ the body form as a function."
                    (execute-kbd-macro
                     (kbd (mapconcat
                           #'identity
-                          (cons unbound-key
-                                (cl-loop for key in keys collect
-                                         (if (stringp key) key unbound-key)))
+                          (nconc (list unbound-key)
+                                 (cl-loop for key in keys collect
+                                          (if (stringp key) key unbound-key))
+                                 (list unbound-key))
                           " "))))))
         (signal (car err) (cdr err))))))
 



reply via email to

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