[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r118120: Avoid unwanted point motion in Fline_beginn
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] trunk r118120: Avoid unwanted point motion in Fline_beginning_position. |
Date: |
Wed, 15 Oct 2014 13:37:54 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 118120
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Wed 2014-10-15 17:37:10 +0400
message:
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.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/cmds.c cmds.c-20091113204419-o5vbwnq5f7feedwu-214
src/editfns.c editfns.c-20091113204419-o5vbwnq5f7feedwu-255
src/lisp.h lisp.h-20091113204419-o5vbwnq5f7feedwu-253
src/search.c search.c-20091113204419-o5vbwnq5f7feedwu-473
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2014-10-14 12:45:41 +0000
+++ b/src/ChangeLog 2014-10-15 13:37:10 +0000
@@ -1,3 +1,12 @@
+2014-10-15 Dmitry Antipov <address@hidden>
+
+ 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.
+
2014-10-14 Dmitry Antipov <address@hidden>
Cleanup terminal handling code.
=== modified file 'src/cmds.c'
--- a/src/cmds.c 2014-06-23 04:11:29 +0000
+++ b/src/cmds.c 2014-10-15 13:37:10 +0000
@@ -131,12 +131,7 @@
count = XINT (n);
}
- if (count <= 0)
- pos = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1,
- &shortage, &pos_byte, 1);
- else
- pos = find_newline (PT, PT_BYTE, ZV, ZV_BYTE, count,
- &shortage, &pos_byte, 1);
+ shortage = scan_newline_from_point (count, &pos, &pos_byte);
SET_PT_BOTH (pos, pos_byte);
=== modified file 'src/editfns.c'
--- a/src/editfns.c 2014-10-12 20:36:49 +0000
+++ b/src/editfns.c 2014-10-15 13:37:10 +0000
@@ -787,26 +787,17 @@
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);
}
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2014-10-12 06:09:50 +0000
+++ b/src/lisp.h 2014-10-15 13:37:10 +0000
@@ -4066,6 +4066,7 @@
ptrdiff_t, ptrdiff_t *, ptrdiff_t *, bool);
extern ptrdiff_t scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
ptrdiff_t, bool);
+extern ptrdiff_t scan_newline_from_point (ptrdiff_t, ptrdiff_t *, ptrdiff_t *);
extern ptrdiff_t find_newline_no_quit (ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t *);
extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t,
=== modified file 'src/search.c'
--- a/src/search.c 2014-09-07 07:04:01 +0000
+++ b/src/search.c 2014-10-15 13:37:10 +0000
@@ -985,6 +985,24 @@
return shortage;
}
+/* Like above, but always scan from point and report the
+ resulting position in *CHARPOS and *BYTEPOS. */
+
+ptrdiff_t
+scan_newline_from_point (ptrdiff_t count, ptrdiff_t *charpos,
+ ptrdiff_t *bytepos)
+{
+ ptrdiff_t shortage;
+
+ if (count <= 0)
+ *charpos = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1,
+ &shortage, bytepos, 1);
+ else
+ *charpos = find_newline (PT, PT_BYTE, ZV, ZV_BYTE, count,
+ &shortage, bytepos, 1);
+ return shortage;
+}
+
/* Like find_newline, but doesn't allow QUITting and doesn't return
SHORTAGE. */
ptrdiff_t
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r118120: Avoid unwanted point motion in Fline_beginning_position.,
Dmitry Antipov <=