1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<h4 class="subsection">Motion by Text Lines</h4> <p>Text lines are portions of the buffer delimited by newline characters, which are regarded as part of the previous line. The first text line begins at the beginning of the buffer, and the last text line ends at the end of the buffer whether or not the last character is a newline. The division of the buffer into text lines is not affected by the width of the window, by line continuation in display, or by how tabs and control characters are displayed. </p> <dl> <dt id="beginning-of-line">Command: <strong>beginning-of-line</strong> <em>&optional count</em>
</dt> <dd>
<p>This function moves point to the beginning of the current line. With an argument <var>count</var> not <code>nil</code> or 1, it moves forward <var>count</var>-1 lines and then to the beginning of the line. </p> <p>This function does not move point across a field boundary (see <a href="fields">Fields</a>) unless doing so would move beyond there to a different line; therefore, if <var>count</var> is <code>nil</code> or 1, and point starts at a field boundary, point does not move. To ignore field boundaries, either bind <code>inhibit-field-text-motion</code> to <code>t</code>, or use the <code>forward-line</code> function instead. For instance, <code>(forward-line 0)</code> does the same thing as <code>(beginning-of-line)</code>, except that it ignores field boundaries. </p> <p>If this function reaches the end of the buffer (or of the accessible portion, if narrowing is in effect), it positions point there. No error is signaled. </p>
</dd>
</dl> <dl> <dt id="line-beginning-position">Function: <strong>line-beginning-position</strong> <em>&optional count</em>
</dt> <dd><p>Return the position that <code>(beginning-of-line <var>count</var>)</code> would move to. </p></dd>
</dl> <dl> <dt id="end-of-line">Command: <strong>end-of-line</strong> <em>&optional count</em>
</dt> <dd>
<p>This function moves point to the end of the current line. With an argument <var>count</var> not <code>nil</code> or 1, it moves forward <var>count</var>-1 lines and then to the end of the line. </p> <p>This function does not move point across a field boundary (see <a href="fields">Fields</a>) unless doing so would move beyond there to a different line; therefore, if <var>count</var> is <code>nil</code> or 1, and point starts at a field boundary, point does not move. To ignore field boundaries, bind <code>inhibit-field-text-motion</code> to <code>t</code>. </p> <p>If this function reaches the end of the buffer (or of the accessible portion, if narrowing is in effect), it positions point there. No error is signaled. </p>
</dd>
</dl> <dl> <dt id="line-end-position">Function: <strong>line-end-position</strong> <em>&optional count</em>
</dt> <dd><p>Return the position that <code>(end-of-line <var>count</var>)</code> would move to. </p></dd>
</dl> <dl> <dt id="forward-line">Command: <strong>forward-line</strong> <em>&optional count</em>
</dt> <dd>
<p>This function moves point forward <var>count</var> lines, to the beginning of the line following that. If <var>count</var> is negative, it moves point -<var>count</var> lines backward, to the beginning of a line preceding that. If <var>count</var> is zero, it moves point to the beginning of the current line. If <var>count</var> is <code>nil</code>, that means 1. </p> <p>If <code>forward-line</code> encounters the beginning or end of the buffer (or of the accessible portion) before finding that many lines, it sets point there. No error is signaled. </p> <p><code>forward-line</code> returns the difference between <var>count</var> and the number of lines actually moved. If you attempt to move down five lines from the beginning of a buffer that has only three lines, point stops at the end of the last line, and the value will be 2. As an explicit exception, if the last accessible line is non-empty, but has no newline (e.g., if the buffer ends without a newline), the function sets point to the end of that line, and the value returned by the function counts that line as one line successfully moved. </p> <p>In an interactive call, <var>count</var> is the numeric prefix argument. </p>
</dd>
</dl> <dl> <dt id="count-lines">Function: <strong>count-lines</strong> <em>start end &optional ignore-invisible-lines</em>
</dt> <dd>
<p>This function returns the number of lines between the positions <var>start</var> and <var>end</var> in the current buffer. If <var>start</var> and <var>end</var> are equal, then it returns 0. Otherwise it returns at least 1, even if <var>start</var> and <var>end</var> are on the same line. This is because the text between them, considered in isolation, must contain at least one line unless it is empty. </p> <p>If the optional <var>ignore-invisible-lines</var> is non-<code>nil</code>, invisible lines will not be included in the count. </p>
</dd>
</dl> <dl> <dt id="count-words">Command: <strong>count-words</strong> <em>start end</em>
</dt> <dd>
<p>This function returns the number of words between the positions <var>start</var> and <var>end</var> in the current buffer. </p> <p>This function can also be called interactively. In that case, it prints a message reporting the number of lines, words, and characters in the buffer, or in the region if the region is active. </p>
</dd>
</dl> <dl> <dt id="line-number-at-pos">Function: <strong>line-number-at-pos</strong> <em>&optional pos absolute</em>
</dt> <dd>
<p>This function returns the line number in the current buffer corresponding to the buffer position <var>pos</var>. If <var>pos</var> is <code>nil</code> or omitted, the current buffer position is used. If <var>absolute</var> is <code>nil</code>, the default, counting starts at <code>(point-min)</code>, so the value refers to the contents of the accessible portion of the (potentially narrowed) buffer. If <var>absolute</var> is non-<code>nil</code>, ignore any narrowing and return the absolute line number. </p>
</dd>
</dl> <p>Also see the functions <code>bolp</code> and <code>eolp</code> in <a href="near-point">Near Point</a>. These functions do not move point, but test whether it is already at the beginning or end of a line. </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/Text-Lines.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Text-Lines.html</a>
</p>
</div>
|