]> code.delx.au - gnu-emacs/blobdiff - src/editfns.c
Avoid unwanted point motion in Fline_beginning_position.
[gnu-emacs] / src / editfns.c
index be1062dbbc55ac8699be3afd90692d20b7032dcc..376d8e3a0eae779e84a12143bea43468dcac5bb0 100644 (file)
@@ -787,26 +787,17 @@ boundaries, bind `inhibit-field-text-motion' to t.
 This function does not move point.  */)
   (Lisp_Object n)
 {
-  ptrdiff_t orig, orig_byte, end;
-  ptrdiff_t count = SPECPDL_INDEX ();
-  specbind (Qinhibit_point_motion_hooks, Qt);
+  ptrdiff_t charpos, bytepos;
 
   if (NILP (n))
     XSETFASTINT (n, 1);
   else
     CHECK_NUMBER (n);
 
-  orig = PT;
-  orig_byte = PT_BYTE;
-  Fforward_line (make_number (XINT (n) - 1));
-  end = PT;
-
-  SET_PT_BOTH (orig, orig_byte);
-
-  unbind_to (count, Qnil);
+  scan_newline_from_point (XINT (n) - 1, &charpos, &bytepos);
 
   /* Return END constrained to the current input field.  */
-  return Fconstrain_to_field (make_number (end), make_number (orig),
+  return Fconstrain_to_field (make_number (charpos), make_number (PT),
                              XINT (n) != 1 ? Qt : Qnil,
                              Qt, Qnil);
 }