diff options
| author | Eli Zaretskii | 2015-05-23 11:03:30 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2015-05-23 11:03:30 +0300 |
| commit | d6dfefe40528a6a9ab6d0cbc5f1a450075241141 (patch) | |
| tree | ae719c9189c8933a946627130a0b19ca731e19c9 | |
| parent | a89ea17be3b589274527bbee6d3c96ff66a226b7 (diff) | |
| download | emacs-d6dfefe40528a6a9ab6d0cbc5f1a450075241141.tar.gz emacs-d6dfefe40528a6a9ab6d0cbc5f1a450075241141.zip | |
Fix documentation of forward-line
* src/cmds.c (Fforward_line): Clarify the return value if the line
at end of accessible portion of the buffer has no newline.
* doc/lispref/positions.texi (Text Lines): Document what happens
if the line at end of accessible portion of buffer has no newline.
(Bug#20587)
| -rw-r--r-- | doc/lispref/positions.texi | 15 | ||||
| -rw-r--r-- | src/cmds.c | 13 |
2 files changed, 20 insertions, 8 deletions
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index e7c79d58241..c972bbb2e43 100644 --- a/doc/lispref/positions.texi +++ b/doc/lispref/positions.texi | |||
| @@ -350,10 +350,11 @@ would move to. | |||
| 350 | @deffn Command forward-line &optional count | 350 | @deffn Command forward-line &optional count |
| 351 | @cindex beginning of line | 351 | @cindex beginning of line |
| 352 | This function moves point forward @var{count} lines, to the beginning of | 352 | This function moves point forward @var{count} lines, to the beginning of |
| 353 | the line. If @var{count} is negative, it moves point | 353 | the line following that. If @var{count} is negative, it moves point |
| 354 | @minus{}@var{count} lines backward, to the beginning of a line. If | 354 | @minus{}@var{count} lines backward, to the beginning of a line |
| 355 | @var{count} is zero, it moves point to the beginning of the current | 355 | preceding that. If @var{count} is zero, it moves point to the |
| 356 | line. If @var{count} is @code{nil}, that means 1. | 356 | beginning of the current line. If @var{count} is @code{nil}, that |
| 357 | means 1. | ||
| 357 | 358 | ||
| 358 | If @code{forward-line} encounters the beginning or end of the buffer (or | 359 | If @code{forward-line} encounters the beginning or end of the buffer (or |
| 359 | of the accessible portion) before finding that many lines, it sets point | 360 | of the accessible portion) before finding that many lines, it sets point |
| @@ -362,7 +363,11 @@ there. No error is signaled. | |||
| 362 | @code{forward-line} returns the difference between @var{count} and the | 363 | @code{forward-line} returns the difference between @var{count} and the |
| 363 | number of lines actually moved. If you attempt to move down five lines | 364 | number of lines actually moved. If you attempt to move down five lines |
| 364 | from the beginning of a buffer that has only three lines, point stops at | 365 | from the beginning of a buffer that has only three lines, point stops at |
| 365 | the end of the last line, and the value will be 2. | 366 | the end of the last line, and the value will be 2. As an explicit |
| 367 | exception, if the last accessible line is non-empty, but has no | ||
| 368 | newline (e.g., if the buffer ends without a newline), the function | ||
| 369 | sets point to the end of that line, and the value returned by the | ||
| 370 | function counts that line as one line successfully moved. | ||
| 366 | 371 | ||
| 367 | In an interactive call, @var{count} is the numeric prefix argument. | 372 | In an interactive call, @var{count} is the numeric prefix argument. |
| 368 | @end deffn | 373 | @end deffn |
diff --git a/src/cmds.c b/src/cmds.c index b590805ea8a..6f9982eebb2 100644 --- a/src/cmds.c +++ b/src/cmds.c | |||
| @@ -110,10 +110,17 @@ DEFUN ("forward-line", Fforward_line, Sforward_line, 0, 1, "^p", | |||
| 110 | Precisely, if point is on line I, move to the start of line I + N | 110 | Precisely, if point is on line I, move to the start of line I + N |
| 111 | \("start of line" in the logical order). | 111 | \("start of line" in the logical order). |
| 112 | If there isn't room, go as far as possible (no error). | 112 | If there isn't room, go as far as possible (no error). |
| 113 | |||
| 113 | Returns the count of lines left to move. If moving forward, | 114 | Returns the count of lines left to move. If moving forward, |
| 114 | that is N - number of lines moved; if backward, N + number moved. | 115 | that is N minus number of lines moved; if backward, N plus number |
| 115 | With positive N, a non-empty line at the end counts as one line | 116 | moved. |
| 116 | successfully moved (for the return value). */) | 117 | |
| 118 | Exception: With positive N, a non-empty line at the end of the | ||
| 119 | buffer, or of its accessible portion, counts as one line | ||
| 120 | successfully moved (for the return value). This means that the | ||
| 121 | function will move point to the end of such a line and will count | ||
| 122 | it as a line moved across, even though there is no next line to | ||
| 123 | go to its beginning. */) | ||
| 117 | (Lisp_Object n) | 124 | (Lisp_Object n) |
| 118 | { | 125 | { |
| 119 | ptrdiff_t opoint = PT, pos, pos_byte, shortage, count; | 126 | ptrdiff_t opoint = PT, pos, pos_byte, shortage, count; |