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

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

[nongnu] elpa/with-simulated-input ad9eaf2252 014/134: Add info on idle


From: ELPA Syncer
Subject: [nongnu] elpa/with-simulated-input ad9eaf2252 014/134: Add info on idle simulation to README
Date: Mon, 10 Jan 2022 23:00:00 -0500 (EST)

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

    Add info on idle simulation to README
---
 README.md | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 08b6d2d42c..b670322549 100644
--- a/README.md
+++ b/README.md
@@ -3,13 +3,12 @@
 [![Build 
Status](https://travis-ci.org/DarwinAwardWinner/with-simulated-input.svg?branch=master)](https://travis-ci.org/DarwinAwardWinner/with-simulated-input)
 <!-- (Not in MELPA yet) [![MELPA 
Stable](https://stable.melpa.org/packages/with-simulated-input-badge.svg)](https://stable.melpa.org/#/with-simulated-input)
 -->
 
-This package provides a single Emacs Lisp macro,
-`with-simulated-input`, which evaluates one or more forms while
-simulating a sequence of input events for those forms to read. The
-result is the same as if you had evaluated the forms and then manually
-typed in the same input. This macro is useful for non-interactive
-testing of normally interactive commands and functions, such as
-`completing-read`.
+This package provides an Emacs Lisp macro, `with-simulated-input`,
+which evaluates one or more forms while simulating a sequence of input
+events for those forms to read. The result is the same as if you had
+evaluated the forms and then manually typed in the same input. This
+macro is useful for non-interactive testing of normally interactive
+commands and functions, such as `completing-read`.
 
 For example:
 
@@ -21,6 +20,29 @@ For example:
 
 This would return the string `"hello world"`.
 
+## Simulating idleness
+
+Some interactive functions rely on idle timers to do their work, so
+you might need a way to simulate idleness. For that, there is the
+`wsi-simulate-idle-time` function. You can insert calls to this
+function in between input strings. For example, the following code
+will return `"hello world"`.
+
+```elisp
+;; Insert "world" after 500 seconds
+(run-with-idle-timer 500 nil 'insert "world")
+(with-simulated-input
+    ;; Type "hello ", then "wait" 501 seconds, then type "RET"
+    '("hello SPC" (wsi-simulate-idle-time 501) "RET")
+  (read-string "Enter a string: "))
+```
+
+Note that this code only *pretends* to be idle for 501 seconds. It
+actually runs immediately.
+
+In fact, you can put any lisp code in between input strings
+in this way.
+
 <!-- Get it from MELPA: https://stable.melpa.org/#/with-simulated-input -->
 
 ## Running the tests



reply via email to

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