diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/describing-characters.html | |
new repository
Diffstat (limited to 'devdocs/elisp/describing-characters.html')
| -rw-r--r-- | devdocs/elisp/describing-characters.html | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/devdocs/elisp/describing-characters.html b/devdocs/elisp/describing-characters.html new file mode 100644 index 00000000..0c584729 --- /dev/null +++ b/devdocs/elisp/describing-characters.html @@ -0,0 +1,45 @@ + <h3 class="section">Describing Characters for Help Messages</h3> <p>These functions convert events, key sequences, or characters to textual descriptions. These descriptions are useful for including arbitrary text characters or key sequences in messages, because they convert non-printing and whitespace characters to sequences of printing characters. The description of a non-whitespace printing character is the character itself. </p> <dl> <dt id="key-description">Function: <strong>key-description</strong> <em>sequence &optional prefix</em> +</dt> <dd> + <p>This function returns a string containing the Emacs standard notation for the input events in <var>sequence</var>. If <var>prefix</var> is non-<code>nil</code>, it is a sequence of input events leading up to <var>sequence</var> and is included in the return value. Both arguments may be strings, vectors or lists. See <a href="input-events">Input Events</a>, for more information about valid events. </p> <div class="example"> <pre class="example">(key-description [?\M-3 delete]) + ⇒ "M-3 <delete>" +</pre> +<pre class="example">(key-description [delete] "\M-3") + ⇒ "M-3 <delete>" +</pre> +</div> <p>See also the examples for <code>single-key-description</code>, below. </p> +</dd> +</dl> <dl> <dt id="single-key-description">Function: <strong>single-key-description</strong> <em>event &optional no-angles</em> +</dt> <dd> + <p>This function returns a string describing <var>event</var> in the standard Emacs notation for keyboard input. A normal printing character appears as itself, but a control character turns into a string starting with ‘<samp>C-</samp>’, a meta character turns into a string starting with ‘<samp>M-</samp>’, and space, tab, etc., appear as ‘<samp>SPC</samp>’, ‘<samp>TAB</samp>’, etc. A function key symbol appears inside angle brackets ‘<samp><…></samp>’. An event that is a list appears as the name of the symbol in the <small>CAR</small> of the list, inside angle brackets. </p> <p>If the optional argument <var>no-angles</var> is non-<code>nil</code>, the angle brackets around function keys and event symbols are omitted; this is for compatibility with old versions of Emacs which didn’t use the brackets. </p> <div class="example"> <pre class="example">(single-key-description ?\C-x) + ⇒ "C-x" +</pre> +<pre class="example">(key-description "\C-x \M-y \n \t \r \f123") + ⇒ "C-x SPC M-y SPC C-j SPC TAB SPC RET SPC C-l 1 2 3" +</pre> +<pre class="example">(single-key-description 'delete) + ⇒ "<delete>" +</pre> +<pre class="example">(single-key-description 'C-mouse-1) + ⇒ "C-<mouse-1>" +</pre> +<pre class="example">(single-key-description 'C-mouse-1 t) + ⇒ "C-mouse-1" +</pre> +</div> </dd> +</dl> <dl> <dt id="text-char-description">Function: <strong>text-char-description</strong> <em>character</em> +</dt> <dd> +<p>This function returns a string describing <var>character</var> in the standard Emacs notation for characters that can appear in text—similar to <code>single-key-description</code>, except that the argument must be a valid character code that passes a <code>characterp</code> test (see <a href="character-codes">Character Codes</a>). The function produces descriptions of control characters with a leading caret (which is how Emacs usually displays control characters in buffers). Characters with modifier bits will cause this function to signal an error (<acronym>ASCII</acronym> characters with the Control modifier are an exception, they are represented as control characters). </p> <div class="example"> <pre class="example">(text-char-description ?\C-c) + ⇒ "^C" +</pre> +<pre class="example">(text-char-description ?\M-m) + error→ Wrong type argument: characterp, 134217837 +</pre> +</div> </dd> +</dl> <dl> <dt id="read-kbd-macro">Command: <strong>read-kbd-macro</strong> <em>string &optional need-vector</em> +</dt> <dd><p>This function is used mainly for operating on keyboard macros, but it can also be used as a rough inverse for <code>key-description</code>. You call it with a string containing key descriptions, separated by spaces; it returns a string or vector containing the corresponding events. (This may or may not be a single valid key sequence, depending on what events you use; see <a href="key-sequences">Key Sequences</a>.) If <var>need-vector</var> is non-<code>nil</code>, the return value is always a vector. </p></dd> +</dl><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 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/Describing-Characters.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Describing-Characters.html</a> + </p> +</div> |
