[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/with-simulated-input 73fa2256df 123/134: Move helper funct
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/with-simulated-input 73fa2256df 123/134: Move helper function next to macro |
Date: |
Mon, 10 Jan 2022 23:00:12 -0500 (EST) |
branch: elpa/with-simulated-input
commit 73fa2256df67e81e94a31c69d5c7b49ae69a6a6a
Author: Ryan C. Thompson <rct@thompsonclan.org>
Commit: Ryan C. Thompson <rct@thompsonclan.org>
Move helper function next to macro
---
with-simulated-input.el | 89 +++++++++++++++++++++++++------------------------
1 file changed, 45 insertions(+), 44 deletions(-)
diff --git a/with-simulated-input.el b/with-simulated-input.el
index 94295bd15e..a59a5e5784 100644
--- a/with-simulated-input.el
+++ b/with-simulated-input.el
@@ -114,50 +114,6 @@ given the value of MODIFIERS and KEYS."
(setq wsi-last-used-next-action-bind bind)))
finally do (error "Could not find an unbound key with the specified
modifiers"))))
-;;;###autoload
-(defun with-simulated-input-1 (main &rest keys)
- "Internal `with-simulated-input' helper.
-
-MAIN is a zero-argument function containing the body forms to be
-evaluated, and KEYS is a list of key sequences (as strings) or
-other actions to simulate user interaction (as zero-argument
-functions, which are called only for their side effects)."
- (let* ((next-action-key (wsi-get-unbound-key))
- ;; Ensure we don't interfere with any outside catching.
- (result-sym (make-symbol "result"))
- (error-sym (make-symbol "error"))
- (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 "Aborted evaluation of BODY after reaching end of
KEYS without returning")))))
- (overriding-terminal-local-map
- (if overriding-terminal-local-map
- (copy-keymap overriding-terminal-local-map)
- (make-sparse-keymap))))
- (define-key overriding-terminal-local-map (kbd next-action-key)
- (lambda ()
- (interactive)
- (condition-case data
- (funcall (pop actions))
- (error (throw error-sym data)))))
- (catch result-sym
- ;; Signals are not passed through `read-from-minibuffer'.
- (let ((err (catch error-sym
- (execute-kbd-macro
- (kbd (mapconcat
- #'identity
- (nconc (list next-action-key)
- (cl-loop for key in keys collect
- (if (stringp key) key
next-action-key))
- (list next-action-key))
- " "))))))
- (signal (car err) (cdr err))))))
-
(defsubst wsi--looks-constant-p (expr)
"Return non-nil if EXPR looks like a constant expression.
@@ -185,6 +141,7 @@ In this context, \"pure\" means that the expression has no
side
effects and its value depends only on its arguments. In general,
this means that EXPR consists only of calls to pure functions,
constants, and variables. In particular, any constant expression
+is pure.
This function may return nil for some pure expressions, but if it
returns non-nil, then EXPR is definitely pure."
@@ -240,6 +197,50 @@ generated for each one unless QUIET is non-nil."
;; Anything else might be an expression with side effects.
else collect key))
+;;;###autoload
+(defun with-simulated-input-1 (main &rest keys)
+ "Internal `with-simulated-input' helper.
+
+MAIN is a zero-argument function containing the body forms to be
+evaluated, and KEYS is a list of key sequences (as strings) or
+other actions to simulate user interaction (as zero-argument
+functions, which are called only for their side effects)."
+ (let* ((next-action-key (wsi-get-unbound-key))
+ ;; Ensure we don't interfere with any outside catching.
+ (result-sym (make-symbol "result"))
+ (error-sym (make-symbol "error"))
+ (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 "Aborted evaluation of BODY after reaching end of
KEYS without returning")))))
+ (overriding-terminal-local-map
+ (if overriding-terminal-local-map
+ (copy-keymap overriding-terminal-local-map)
+ (make-sparse-keymap))))
+ (define-key overriding-terminal-local-map (kbd next-action-key)
+ (lambda ()
+ (interactive)
+ (condition-case data
+ (funcall (pop actions))
+ (error (throw error-sym data)))))
+ (catch result-sym
+ ;; Signals are not passed through `read-from-minibuffer'.
+ (let ((err (catch error-sym
+ (execute-kbd-macro
+ (kbd (mapconcat
+ #'identity
+ (nconc (list next-action-key)
+ (cl-loop for key in keys collect
+ (if (stringp key) key
next-action-key))
+ (list next-action-key))
+ " "))))))
+ (signal (car err) (cdr err))))))
+
;;;###autoload
(defmacro with-simulated-input (keys &rest body)
"Eval BODY forms with KEYS as simulated input.
- [nongnu] elpa/with-simulated-input 14f3d86cb3 071/134: Fix tests, (continued)
- [nongnu] elpa/with-simulated-input 14f3d86cb3 071/134: Fix tests, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 02b5d2c77f 072/134: Fix checkdoc warnings, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 4e45836cc0 078/134: Autoload `with-simulated-input--1', ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 89e63ebf6a 073/134: Fix tests for older Emacsen, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 0aeff5f17f 079/134: `with-simulated-input': remove legacy syntax, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 6f7787df80 082/134: Add an unload function, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 26fc928f42 092/134: Work around an incompatibility in Emacs 24 in tests, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input ef9d5164ca 094/134: Fix interpolation test, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input d3696fb04c 098/134: Check errors more strictly in tests, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 703fc3c9ec 118/134: Update the docstring for "with-simulated-input", ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 73fa2256df 123/134: Move helper function next to macro,
ELPA Syncer <=
- [nongnu] elpa/with-simulated-input 708051c57f 105/134: Improve error messages for invalid/incomplete KEYS, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input e7cc96e7df 102/134: Update the debug declaration for "with-simulated-input" macro, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 2f54a2550b 117/134: Clean up code for "with-simulated-input" macro, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input a86f35f3b0 100/134: Add tests for un-quoted lists, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 07bdfbe9ab 124/134: Increment version to 3.0, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 670c23e615 004/134: Update minimum Emacs version to 24.4, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input c97f27da20 005/134: Autoload the macro, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 369ca97402 006/134: Fix issues found by package-lint, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 00ed837502 012/134: Standardize on internal Emacs time type, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input f0dbf2fdd9 017/134: Fix a typo, ELPA Syncer, 2022/01/10