[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/with-simulated-input ea6735cf1b 083/134: KEYS: support a s
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/with-simulated-input ea6735cf1b 083/134: KEYS: support a single variable |
Date: |
Mon, 10 Jan 2022 23:00:07 -0500 (EST) |
branch: elpa/with-simulated-input
commit ea6735cf1b4c55d4eac165059fba662086aeca6e
Author: Nikita Bloshchanevich <nikblos@outlook.com>
Commit: Nikita Bloshchanevich <nikblos@outlook.com>
KEYS: support a single variable
`with-simulated-input' now supports a symbol for KEYS, handled like a single
string. The variable will be checked to be a string before being passed on
to
`with-simulated-input-1' (lambdas would be silently called).
---
tests/test-with-simulated-input.el | 10 ++++++++++
with-simulated-input.el | 24 ++++++++++++++++--------
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/tests/test-with-simulated-input.el
b/tests/test-with-simulated-input.el
index 058df890ed..b175de53a9 100644
--- a/tests/test-with-simulated-input.el
+++ b/tests/test-with-simulated-input.el
@@ -122,6 +122,16 @@
(read-string "Say hello: "))
:to-equal "hello world")))
+ (it "should allow a variable for KEYS"
+ (let ((keys "hello RET"))
+ (expect (with-simulated-input keys (read-string "Say hello: "))
+ :to-equal "hello")))
+
+ (it "should error for non-string variable KEYS"
+ (let ((keys (lambda () (insert "X"))))
+ (expect (with-simulated-input keys (read-string "Input: "))
+ :to-throw)))
+
(it "should allow lisp forms to throw errors"
(expect
diff --git a/with-simulated-input.el b/with-simulated-input.el
index 608c5950dd..afa7863529 100644
--- a/with-simulated-input.el
+++ b/with-simulated-input.el
@@ -176,15 +176,23 @@ are propagated normally.
The return value is the last form in BODY, as if it was wrapped
in `progn'."
(declare (indent 1) (debug ([&or ("quote" (&rest &or stringp def-form))
- (&rest &or stringp def-form)]
+ (&rest &or stringp def-form)
+ stringp symbolp]
def-body)))
- (pcase keys
- (`(quote ,x) (setq keys x))
- ((guard (not (listp keys))) (cl-callf list keys)))
- `(with-simulated-input-1
- (lambda ()
- ,@body)
- ,@(cl-loop for key in keys collect (if (stringp key) key `(lambda ()
,key)))))
+ (if (and (symbolp keys) keys)
+ `(progn
+ (cl-check-type ,keys string)
+ (with-simulated-input-1
+ (lambda ()
+ ,@body)
+ ,keys))
+ (pcase keys
+ (`(quote ,x) (setq keys x))
+ ((guard (not (listp keys))) (cl-callf list keys)))
+ `(with-simulated-input-1
+ (lambda ()
+ ,@body)
+ ,@(cl-loop for key in keys collect (if (stringp key) key `(lambda ()
,key))))))
(defvar wsi-simulated-idle-time nil
"The current simulated idle time.
- [nongnu] branch elpa/with-simulated-input created (now 0f43fe46d4), ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 568bfb8e1d 015/134: Version 2.0, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 5bdbde591d 058/134: Eliminate spurious warning in test file, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 433ee087ce 066/134: Test: handle `undercover' not being installed, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input ea6735cf1b 083/134: KEYS: support a single variable,
ELPA Syncer <=
- [nongnu] elpa/with-simulated-input d32cbc3ac9 093/134: Revert "Remove interpolation test", ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 39dbadff0b 120/134: Update the README to reflect current supported syntax, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input e7a7a6c39d 109/134: Don't use "define-advice" in tests, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 334f9f244f 119/134: Implement support for characters in KEYS, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 00209c2be3 128/134: Test on 27.2 instead of 27.1, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 1006e93000 125/134: Add more tests to improve coverage, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 9c160b2d81 106/134: Add warnings for quoted list KEYS and nil/constant BODY, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 4eedb0eee8 126/134: Use an alternate method to disable eager macro-expansion for testing, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 9d082a372a 113/134: Be more selective about which file changes trigger a CI run, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 681397b90d 130/134: Also test variables containing characters, ELPA Syncer, 2022/01/10