aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.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/editfns.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/editfns.c')
-rw-r--r--src/editfns.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/editfns.c b/src/editfns.c
index be1062dbbc5..376d8e3a0ea 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -787,26 +787,17 @@ boundaries, bind `inhibit-field-text-motion' to t.
787This function does not move point. */) 787This function does not move point. */)
788 (Lisp_Object n) 788 (Lisp_Object n)
789{ 789{
790 ptrdiff_t orig, orig_byte, end; 790 ptrdiff_t charpos, bytepos;
791 ptrdiff_t count = SPECPDL_INDEX ();
792 specbind (Qinhibit_point_motion_hooks, Qt);
793 791
794 if (NILP (n)) 792 if (NILP (n))
795 XSETFASTINT (n, 1); 793 XSETFASTINT (n, 1);
796 else 794 else
797 CHECK_NUMBER (n); 795 CHECK_NUMBER (n);
798 796
799 orig = PT; 797 scan_newline_from_point (XINT (n) - 1, &charpos, &bytepos);
800 orig_byte = PT_BYTE;
801 Fforward_line (make_number (XINT (n) - 1));
802 end = PT;
803
804 SET_PT_BOTH (orig, orig_byte);
805
806 unbind_to (count, Qnil);
807 798
808 /* Return END constrained to the current input field. */ 799 /* Return END constrained to the current input field. */
809 return Fconstrain_to_field (make_number (end), make_number (orig), 800 return Fconstrain_to_field (make_number (charpos), make_number (PT),
810 XINT (n) != 1 ? Qt : Qnil, 801 XINT (n) != 1 ? Qt : Qnil,
811 Qt, Qnil); 802 Qt, Qnil);
812} 803}