1
2
3
4
5
6
7
8
9
10
|
<h4 class="subsubsection">Control-Character Syntax</h4> <p>Control characters can be represented using yet another read syntax. This consists of a question mark followed by a backslash, caret, and the corresponding non-control character, in either upper or lower case. For example, both ‘<samp>?\^I</samp>’ and ‘<samp>?\^i</samp>’ are valid read syntax for the character <kbd>C-i</kbd>, the character whose value is 9. </p> <p>Instead of the ‘<samp>^</samp>’, you can use ‘<samp>C-</samp>’; thus, ‘<samp>?\C-i</samp>’ is equivalent to ‘<samp>?\^I</samp>’ and to ‘<samp>?\^i</samp>’: </p> <div class="example"> <pre class="example">?\^I ⇒ 9 ?\C-I ⇒ 9
</pre>
</div> <p>In strings and buffers, the only control characters allowed are those that exist in <acronym>ASCII</acronym>; but for keyboard input purposes, you can turn any character into a control character with ‘<samp>C-</samp>’. The character codes for these non-<acronym>ASCII</acronym> control characters include the 2**26 bit as well as the code for the corresponding non-control character. Not all text terminals can generate non-<acronym>ASCII</acronym> control characters, but it is straightforward to generate them using X and other window systems. </p> <p>For historical reasons, Emacs treats the <tt class="key">DEL</tt> character as the control equivalent of <kbd>?</kbd>: </p> <div class="example"> <pre class="example">?\^? ⇒ 127 ?\C-? ⇒ 127
</pre>
</div> <p>As a result, it is currently not possible to represent the character <kbd>Control-?</kbd>, which is a meaningful input character under X, using ‘<samp>\C-</samp>’. It is not easy to change this, as various Lisp files refer to <tt class="key">DEL</tt> in this way. </p> <p>For representing control characters to be found in files or strings, we recommend the ‘<samp>^</samp>’ syntax; for control characters in keyboard input, we prefer the ‘<samp>C-</samp>’ syntax. Which one you use does not affect the meaning of the program, but may guide the understanding of people who read it. </p><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/Ctl_002dChar-Syntax.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Ctl_002dChar-Syntax.html</a>
</p>
</div>
|