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/near-point.html | |
new repository
Diffstat (limited to 'devdocs/elisp/near-point.html')
| -rw-r--r-- | devdocs/elisp/near-point.html | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/devdocs/elisp/near-point.html b/devdocs/elisp/near-point.html new file mode 100644 index 00000000..87941f11 --- /dev/null +++ b/devdocs/elisp/near-point.html @@ -0,0 +1,38 @@ + <h3 class="section">Examining Text Near Point</h3> <p>Many functions are provided to look at the characters around point. Several simple functions are described here. See also <code>looking-at</code> in <a href="regexp-search">Regexp Search</a>. </p> <p>In the following four functions, “beginning” or “end” of buffer refers to the beginning or end of the accessible portion. </p> <dl> <dt id="char-after">Function: <strong>char-after</strong> <em>&optional position</em> +</dt> <dd> +<p>This function returns the character in the current buffer at (i.e., immediately after) position <var>position</var>. If <var>position</var> is out of range for this purpose, either before the beginning of the buffer, or at or beyond the end, then the value is <code>nil</code>. The default for <var>position</var> is point. </p> <p>In the following example, assume that the first character in the buffer is ‘<samp>@</samp>’: </p> <div class="example"> <pre class="example">(string (char-after 1)) + ⇒ "@" +</pre> +</div> </dd> +</dl> <dl> <dt id="char-before">Function: <strong>char-before</strong> <em>&optional position</em> +</dt> <dd><p>This function returns the character in the current buffer immediately before position <var>position</var>. If <var>position</var> is out of range for this purpose, either at or before the beginning of the buffer, or beyond the end, then the value is <code>nil</code>. The default for <var>position</var> is point. </p></dd> +</dl> <dl> <dt id="following-char">Function: <strong>following-char</strong> +</dt> <dd> +<p>This function returns the character following point in the current buffer. This is similar to <code>(char-after (point))</code>. However, if point is at the end of the buffer, then <code>following-char</code> returns 0. </p> <p>Remember that point is always between characters, and the cursor normally appears over the character following point. Therefore, the character returned by <code>following-char</code> is the character the cursor is over. </p> <p>In this example, point is between the ‘<samp>a</samp>’ and the ‘<samp>c</samp>’. </p> <div class="example"> <pre class="example">---------- Buffer: foo ---------- +Gentlemen may cry ``Pea∗ce! Peace!,'' +but there is no peace. +---------- Buffer: foo ---------- +</pre> + +<pre class="example">(string (preceding-char)) + ⇒ "a" +(string (following-char)) + ⇒ "c" +</pre> +</div> </dd> +</dl> <dl> <dt id="preceding-char">Function: <strong>preceding-char</strong> +</dt> <dd><p>This function returns the character preceding point in the current buffer. See above, under <code>following-char</code>, for an example. If point is at the beginning of the buffer, <code>preceding-char</code> returns 0. </p></dd> +</dl> <dl> <dt id="bobp">Function: <strong>bobp</strong> +</dt> <dd><p>This function returns <code>t</code> if point is at the beginning of the buffer. If narrowing is in effect, this means the beginning of the accessible portion of the text. See also <code>point-min</code> in <a href="point">Point</a>. </p></dd> +</dl> <dl> <dt id="eobp">Function: <strong>eobp</strong> +</dt> <dd><p>This function returns <code>t</code> if point is at the end of the buffer. If narrowing is in effect, this means the end of accessible portion of the text. See also <code>point-max</code> in See <a href="point">Point</a>. </p></dd> +</dl> <dl> <dt id="bolp">Function: <strong>bolp</strong> +</dt> <dd><p>This function returns <code>t</code> if point is at the beginning of a line. See <a href="text-lines">Text Lines</a>. The beginning of the buffer (or of its accessible portion) always counts as the beginning of a line. </p></dd> +</dl> <dl> <dt id="eolp">Function: <strong>eolp</strong> +</dt> <dd><p>This function returns <code>t</code> if point is at the end of a line. The end of the buffer (or of its accessible portion) is always considered the end of a line. </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/Near-Point.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Near-Point.html</a> + </p> +</div> |
