aboutsummaryrefslogtreecommitdiffstats
path: root/src/search.c
diff options
context:
space:
mode:
authorDmitry Antipov2014-10-15 17:37:10 +0400
committerDmitry Antipov2014-10-15 17:37:10 +0400
commit0b4d6d30be2822df7d6b086bbab32b8ff419ed5d (patch)
treebb4d69129f2dc53af8736945bfdaf8bd22dbf966 /src/search.c
parent73d4c39e1519a5fec742686e3c81941113d41448 (diff)
downloademacs-0b4d6d30be2822df7d6b086bbab32b8ff419ed5d.tar.gz
emacs-0b4d6d30be2822df7d6b086bbab32b8ff419ed5d.zip
Avoid unwanted point motion in Fline_beginning_position.
* lisp.h (scan_newline_from_point): Add prototype. * search.c (scan_newline_from_point): New function, refactored from... * cmds.c (Fforward_line): ...adjusted user. * editfns.c (Fline_beginning_position): Use scan_newline_from_point and simplify the former since the latter doesn't move point.
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/search.c b/src/search.c
index 9eed390244f..c6ae9d7e922 100644
--- a/src/search.c
+++ b/src/search.c
@@ -985,6 +985,24 @@ scan_newline (ptrdiff_t start, ptrdiff_t start_byte,
985 return shortage; 985 return shortage;
986} 986}
987 987
988/* Like above, but always scan from point and report the
989 resulting position in *CHARPOS and *BYTEPOS. */
990
991ptrdiff_t
992scan_newline_from_point (ptrdiff_t count, ptrdiff_t *charpos,
993 ptrdiff_t *bytepos)
994{
995 ptrdiff_t shortage;
996
997 if (count <= 0)
998 *charpos = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1,
999 &shortage, bytepos, 1);
1000 else
1001 *charpos = find_newline (PT, PT_BYTE, ZV, ZV_BYTE, count,
1002 &shortage, bytepos, 1);
1003 return shortage;
1004}
1005
988/* Like find_newline, but doesn't allow QUITting and doesn't return 1006/* Like find_newline, but doesn't allow QUITting and doesn't return
989 SHORTAGE. */ 1007 SHORTAGE. */
990ptrdiff_t 1008ptrdiff_t