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/skipping-characters.html | |
new repository
Diffstat (limited to 'devdocs/elisp/skipping-characters.html')
| -rw-r--r-- | devdocs/elisp/skipping-characters.html | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/devdocs/elisp/skipping-characters.html b/devdocs/elisp/skipping-characters.html new file mode 100644 index 00000000..af77c1e3 --- /dev/null +++ b/devdocs/elisp/skipping-characters.html @@ -0,0 +1,27 @@ + <h4 class="subsection">Skipping Characters</h4> <p>The following two functions move point over a specified set of characters. For example, they are often used to skip whitespace. For related functions, see <a href="motion-and-syntax">Motion and Syntax</a>. </p> <p>These functions convert the set string to multibyte if the buffer is multibyte, and they convert it to unibyte if the buffer is unibyte, as the search functions do (see <a href="searching-and-matching">Searching and Matching</a>). </p> <dl> <dt id="skip-chars-forward">Function: <strong>skip-chars-forward</strong> <em>character-set &optional limit</em> +</dt> <dd> +<p>This function moves point in the current buffer forward, skipping over a given set of characters. It examines the character following point, then advances point if the character matches <var>character-set</var>. This continues until it reaches a character that does not match. The function returns the number of characters moved over. </p> <p>The argument <var>character-set</var> is a string, like the inside of a ‘<samp>[…]</samp>’ in a regular expression except that ‘<samp>]</samp>’ does not terminate it, and ‘<samp>\</samp>’ quotes ‘<samp>^</samp>’, ‘<samp>-</samp>’ or ‘<samp>\</samp>’. Thus, <code>"a-zA-Z"</code> skips over all letters, stopping before the first nonletter, and <code>"^a-zA-Z"</code> skips nonletters stopping before the first letter (see <a href="regular-expressions">Regular Expressions</a>). Character classes can also be used, e.g., <code>"[:alnum:]"</code> (see <a href="char-classes">Char Classes</a>). </p> <p>If <var>limit</var> is supplied (it must be a number or a marker), it specifies the maximum position in the buffer that point can be skipped to. Point will stop at or before <var>limit</var>. </p> <p>In the following example, point is initially located directly before the ‘<samp>T</samp>’. After the form is evaluated, point is located at the end of that line (between the ‘<samp>t</samp>’ of ‘<samp>hat</samp>’ and the newline). The function skips all letters and spaces, but not newlines. </p> <div class="example"> <pre class="example">---------- Buffer: foo ---------- +I read "∗The cat in the hat +comes back" twice. +---------- Buffer: foo ---------- +</pre> + +<pre class="example">(skip-chars-forward "a-zA-Z ") + ⇒ 18 + +---------- Buffer: foo ---------- +I read "The cat in the hat∗ +comes back" twice. +---------- Buffer: foo ---------- +</pre> +</div> </dd> +</dl> <dl> <dt id="skip-chars-backward">Function: <strong>skip-chars-backward</strong> <em>character-set &optional limit</em> +</dt> <dd> +<p>This function moves point backward, skipping characters that match <var>character-set</var>, until <var>limit</var>. It is just like <code>skip-chars-forward</code> except for the direction of motion. </p> <p>The return value indicates the distance traveled. It is an integer that is zero or less. </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/Skipping-Characters.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Skipping-Characters.html</a> + </p> +</div> |
