aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2015-05-23 11:03:30 +0300
committerEli Zaretskii2015-05-23 11:03:30 +0300
commitd6dfefe40528a6a9ab6d0cbc5f1a450075241141 (patch)
treeae719c9189c8933a946627130a0b19ca731e19c9
parenta89ea17be3b589274527bbee6d3c96ff66a226b7 (diff)
downloademacs-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.texi15
-rw-r--r--src/cmds.c13
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
352This function moves point forward @var{count} lines, to the beginning of 352This function moves point forward @var{count} lines, to the beginning of
353the line. If @var{count} is negative, it moves point 353the 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 355preceding that. If @var{count} is zero, it moves point to the
356line. If @var{count} is @code{nil}, that means 1. 356beginning of the current line. If @var{count} is @code{nil}, that
357means 1.
357 358
358If @code{forward-line} encounters the beginning or end of the buffer (or 359If @code{forward-line} encounters the beginning or end of the buffer (or
359of the accessible portion) before finding that many lines, it sets point 360of 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
363number of lines actually moved. If you attempt to move down five lines 364number of lines actually moved. If you attempt to move down five lines
364from the beginning of a buffer that has only three lines, point stops at 365from the beginning of a buffer that has only three lines, point stops at
365the end of the last line, and the value will be 2. 366the end of the last line, and the value will be 2. As an explicit
367exception, if the last accessible line is non-empty, but has no
368newline (e.g., if the buffer ends without a newline), the function
369sets point to the end of that line, and the value returned by the
370function counts that line as one line successfully moved.
366 371
367In an interactive call, @var{count} is the numeric prefix argument. 372In 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",
110Precisely, if point is on line I, move to the start of line I + N 110Precisely, 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).
112If there isn't room, go as far as possible (no error). 112If there isn't room, go as far as possible (no error).
113
113Returns the count of lines left to move. If moving forward, 114Returns the count of lines left to move. If moving forward,
114that is N - number of lines moved; if backward, N + number moved. 115that is N minus number of lines moved; if backward, N plus number
115With positive N, a non-empty line at the end counts as one line 116moved.
116successfully moved (for the return value). */) 117
118Exception: With positive N, a non-empty line at the end of the
119buffer, or of its accessible portion, counts as one line
120successfully moved (for the return value). This means that the
121function will move point to the end of such a line and will count
122it as a line moved across, even though there is no next line to
123go 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;