summaryrefslogtreecommitdiff
path: root/devdocs/elisp/input-functions.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/input-functions.html
new repository
Diffstat (limited to 'devdocs/elisp/input-functions.html')
-rw-r--r--devdocs/elisp/input-functions.html37
1 files changed, 37 insertions, 0 deletions
diff --git a/devdocs/elisp/input-functions.html b/devdocs/elisp/input-functions.html
new file mode 100644
index 00000000..706da04c
--- /dev/null
+++ b/devdocs/elisp/input-functions.html
@@ -0,0 +1,37 @@
+ <h3 class="section">Input Functions</h3> <p>This section describes the Lisp functions and variables that pertain to reading. </p> <p>In the functions below, <var>stream</var> stands for an input stream (see the previous section). If <var>stream</var> is <code>nil</code> or omitted, it defaults to the value of <code>standard-input</code>. </p> <p>An <code>end-of-file</code> error is signaled if reading encounters an unterminated list, vector, or string. </p> <dl> <dt id="read">Function: <strong>read</strong> <em>&amp;optional stream</em>
+</dt> <dd><p>This function reads one textual Lisp expression from <var>stream</var>, returning it as a Lisp object. This is the basic Lisp input function. </p></dd>
+</dl> <dl> <dt id="read-from-string">Function: <strong>read-from-string</strong> <em>string &amp;optional start end</em>
+</dt> <dd>
+ <p>This function reads the first textual Lisp expression from the text in <var>string</var>. It returns a cons cell whose <small>CAR</small> is that expression, and whose <small>CDR</small> is an integer giving the position of the next remaining character in the string (i.e., the first one not read). </p> <p>If <var>start</var> is supplied, then reading begins at index <var>start</var> in the string (where the first character is at index 0). If you specify <var>end</var>, then reading is forced to stop just before that index, as if the rest of the string were not there. </p> <p>For example: </p> <div class="example"> <pre class="example">(read-from-string "(setq x 55) (setq y 5)")
+ ⇒ ((setq x 55) . 11)
+</pre>
+<pre class="example">(read-from-string "\"A short string\"")
+ ⇒ ("A short string" . 16)
+</pre>
+
+<pre class="example">;; <span class="roman">Read starting at the first character.</span>
+(read-from-string "(list 112)" 0)
+ ⇒ ((list 112) . 10)
+</pre>
+<pre class="example">;; <span class="roman">Read starting at the second character.</span>
+(read-from-string "(list 112)" 1)
+ ⇒ (list . 5)
+</pre>
+<pre class="example">;; <span class="roman">Read starting at the seventh character,</span>
+;; <span class="roman">and stopping at the ninth.</span>
+(read-from-string "(list 112)" 6 8)
+ ⇒ (11 . 8)
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="standard-input">Variable: <strong>standard-input</strong>
+</dt> <dd><p>This variable holds the default input stream—the stream that <code>read</code> uses when the <var>stream</var> argument is <code>nil</code>. The default is <code>t</code>, meaning use the minibuffer. </p></dd>
+</dl> <dl> <dt id="read-circle">Variable: <strong>read-circle</strong>
+</dt> <dd><p>If non-<code>nil</code>, this variable enables the reading of circular and shared structures. See <a href="circular-objects">Circular Objects</a>. Its default value is <code>t</code>. </p></dd>
+</dl> <p>When reading or writing from the standard input/output streams of the Emacs process in batch mode, it is sometimes required to make sure any arbitrary binary data will be read/written verbatim, and/or that no translation of newlines to or from CR-LF pairs is performed. This issue does not exist on POSIX hosts, only on MS-Windows and MS-DOS. The following function allows you to control the I/O mode of any standard stream of the Emacs process. </p> <dl> <dt id="set-binary-mode">Function: <strong>set-binary-mode</strong> <em>stream mode</em>
+</dt> <dd><p>Switch <var>stream</var> into binary or text I/O mode. If <var>mode</var> is non-<code>nil</code>, switch to binary mode, otherwise switch to text mode. The value of <var>stream</var> can be one of <code>stdin</code>, <code>stdout</code>, or <code>stderr</code>. This function flushes any pending output data of <var>stream</var> as a side effect, and returns the previous value of I/O mode for <var>stream</var>. On POSIX hosts, it always returns a non-<code>nil</code> value and does nothing except flushing pending output. </p></dd>
+</dl><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Input-Functions.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Input-Functions.html</a>
+ </p>
+</div>