APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1550501614 0
# Mon Feb 18 14:53:34 2019 +0000
# Node ID cc27eb6f808b9fe3055bd866e521f2646b2556b2
# Parent f1c4035664d73d7e5d0332811a402981461b87c2
Prefer byte_beginning_of_line_p() throughout the C code.
2019-02-18 Aidan Kehoe <kehoea(a)parhasard.net>
Prefer byte_beginning_of_line_p() throughout the C code.
* buffer.h:
Make byte_beginning_of_line_p() inline, given its short length and
its use in redisplay.
Move it to this file from editfns.c given it needs access to
buffer internals.
* editfns.c (beginning_of_line_p): Remove this entirely.
* lisp.h: Remove its declaration from lisp.h.
* redisplay.c (create_text_block):
Correct some BUF_FETCH_CHAR vs. BYTE_BUF_FETCH_CHAR confusion.
* redisplay.c (redisplay_window):
Call byte_beginning_of_line_p() in this function.
* window.c (Fset_window_start):
Leave the POSITION munging to set_marker_restricted(), something
it's better at, anyway.
Call byte_beginning_of_line_p() here.
* window.c (Fdelete_other_windows):
* window.c (Fset_window_buffer):
* window.c (window_scroll):
* window.c (Fcenter_to_window_line):
* window.c (Fmove_to_window_line):
Call byte_beginning_of_line_p() in these other functions too.
diff -r f1c4035664d7 -r cc27eb6f808b src/ChangeLog
--- a/src/ChangeLog Mon Feb 18 13:08:54 2019 +0000
+++ b/src/ChangeLog Mon Feb 18 14:53:34 2019 +0000
@@ -1,3 +1,28 @@
+2019-02-18 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ Prefer byte_beginning_of_line_p() throughout the C code.
+ * buffer.h:
+ Make byte_beginning_of_line_p() inline, given its short length and
+ its use in redisplay.
+ Move it to this file from editfns.c given it needs access to
+ buffer internals.
+ * editfns.c (beginning_of_line_p): Remove this entirely.
+ * lisp.h: Remove its declaration from lisp.h.
+ * redisplay.c (create_text_block):
+ Correct some BUF_FETCH_CHAR vs. BYTE_BUF_FETCH_CHAR confusion.
+ * redisplay.c (redisplay_window):
+ Call byte_beginning_of_line_p() in this function.
+ * window.c (Fset_window_start):
+ Leave the POSITION munging to set_marker_restricted(), something
+ it's better at, anyway.
+ Call byte_beginning_of_line_p() here.
+ * window.c (Fdelete_other_windows):
+ * window.c (Fset_window_buffer):
+ * window.c (window_scroll):
+ * window.c (Fcenter_to_window_line):
+ * window.c (Fmove_to_window_line):
+ Call byte_beginning_of_line_p() in these other functions too.
+
2019-02-18 Aidan Kehoe <kehoea(a)parhasard.net>
* menubar-x.c (menu_item_descriptor_to_widget_value_1):
diff -r f1c4035664d7 -r cc27eb6f808b src/buffer.h
--- a/src/buffer.h Mon Feb 18 13:08:54 2019 +0000
+++ b/src/buffer.h Mon Feb 18 14:53:34 2019 +0000
@@ -1312,4 +1312,21 @@
#endif /* !REL_ALLOC */
+/* This gets to go here because it's used enough in redisplay that it's worth
+ making it inline, and because lisp.h doesn't have access to the
+ buffer.h-internal macros. */
+DECLARE_INLINE_HEADER (
+Boolint
+byte_beginning_of_line_p (struct buffer *b, Bytebpos bpt)
+)
+{
+ if (bpt <= BYTE_BUF_BEGV (b))
+ {
+ return 1;
+ }
+
+ DEC_BYTEBPOS (b, bpt);
+ return BYTE_BUF_FETCH_CHAR (b, bpt) == '\n';
+}
+
#endif /* INCLUDED_buffer_h_ */
diff -r f1c4035664d7 -r cc27eb6f808b src/editfns.c
--- a/src/editfns.c Mon Feb 18 13:08:54 2019 +0000
+++ b/src/editfns.c Mon Feb 18 14:53:34 2019 +0000
@@ -515,26 +515,6 @@
return BYTE_BUF_PT (b) == BYTE_BUF_ZV (b) ? Qt : Qnil;
}
-static Boolint
-byte_beginning_of_line_p (struct buffer *b, Bytebpos bpt)
-{
- if (bpt <= BYTE_BUF_BEGV (b))
- {
- return 1;
- }
-
- DEC_BYTEBPOS (b, bpt);
- return BYTE_BUF_FETCH_CHAR (b, bpt) == '\n';
-}
-
-/* #### Rework redisplay.c and the window code to use
- byte_beginning_of_line_p() instead of this! */
-Boolint
-beginning_of_line_p (struct buffer *b, Charbpos pt)
-{
- return pt <= BUF_BEGV (b) || BUF_FETCH_CHAR (b, pt - 1) == '\n';
-}
-
DEFUN ("bolp", Fbolp, 0, 1, 0, /*
Return t if point is at the beginning of a line.
If BUFFER is nil, the current buffer is assumed.
diff -r f1c4035664d7 -r cc27eb6f808b src/lisp.h
--- a/src/lisp.h Mon Feb 18 13:08:54 2019 +0000
+++ b/src/lisp.h Mon Feb 18 14:53:34 2019 +0000
@@ -4835,7 +4835,6 @@
Lisp_Object save_excursion_restore (Lisp_Object);
Lisp_Object save_restriction_restore (Lisp_Object);
void widen_buffer (struct buffer *b, int no_clip);
-Boolint beginning_of_line_p (struct buffer *, Charbpos);
Lisp_Object save_current_buffer_restore (Lisp_Object);
extern Lisp_Object Qformat;
diff -r f1c4035664d7 -r cc27eb6f808b src/redisplay.c
--- a/src/redisplay.c Mon Feb 18 13:08:54 2019 +0000
+++ b/src/redisplay.c Mon Feb 18 14:53:34 2019 +0000
@@ -2314,7 +2314,8 @@
supposed to display. */
if (selective > 0
&& (data.byte_charpos == BYTE_BUF_BEGV (b)
- || BUF_FETCH_CHAR (b, prev_bytebpos (b, data.byte_charpos)) == '\n'))
+ || BYTE_BUF_FETCH_CHAR (b, prev_bytebpos (b, data.byte_charpos))
+ == '\n'))
{
while (byte_spaces_at_point (b, data.byte_charpos) >= selective)
{
@@ -6498,7 +6499,9 @@
&& !f->frame_changed
&& !truncation_changed
/* check whether start is really at the beginning of a line GE */
- && (!w->start_at_line_beg || beginning_of_line_p (b, startp))
+ && (!w->start_at_line_beg ||
+ byte_beginning_of_line_p (b, byte_marker_position
+ (w->start[DESIRED_DISP])))
)
{
/* Check if the cursor has actually moved. */
@@ -6574,11 +6577,12 @@
if our start position is equal to point-max. Otherwise we'll end
up with a blank window. */
else if (((w->start_at_line_beg || MINI_WINDOW_P (w))
- && !(startp == BUF_BEGV (b)
- || BUF_FETCH_CHAR (b, startp - 1) == '\n'))
+ && !(byte_beginning_of_line_p
+ (b, byte_marker_position (w->start[DESIRED_DISP]))))
|| (pointm == startp &&
EQ (Fmarker_buffer (w->last_start[CURRENT_DISP]), w->buffer) &&
- startp < marker_position (w->last_start[CURRENT_DISP]))
+ byte_marker_position (w->start[DESIRED_DISP])
+ < byte_marker_position (w->last_start[CURRENT_DISP]))
|| (startp == BUF_ZV (b)))
{
startp = regenerate_window_point_center (w, pointm, DESIRED_DISP);
diff -r f1c4035664d7 -r cc27eb6f808b src/window.c
--- a/src/window.c Mon Feb 18 13:08:54 2019 +0000
+++ b/src/window.c Mon Feb 18 14:53:34 2019 +0000
@@ -1994,13 +1994,13 @@
{
struct window *w = decode_window (window);
- CHECK_FIXNUM_COERCE_MARKER (pos);
set_marker_restricted (w->start[CURRENT_DISP], pos, w->buffer);
/* this is not right, but much easier than doing what is right. */
/* w->start_at_line_beg = 0; */
/* WTF is the above supposed to mean? GE */
- w->start_at_line_beg = beginning_of_line_p (XBUFFER (w->buffer),
- marker_position (w->start[CURRENT_DISP]));
+ w->start_at_line_beg
+ = byte_beginning_of_line_p (XBUFFER (w->buffer),
+ byte_marker_position (w->start[CURRENT_DISP]));
if (NILP (noforce))
w->force_start = 1;
w->redo_modeline = 1;
@@ -3324,7 +3324,9 @@
{
Fset_marker (w->start[CURRENT_DISP], make_fixnum (new_start),
w->buffer);
- w->start_at_line_beg = beginning_of_line_p (b, new_start);
+ w->start_at_line_beg
+ = byte_beginning_of_line_p
+ (b, byte_marker_position (w->start[CURRENT_DISP]));
}
/* We need to do this, so that the window-scroll-functions
get called. */
@@ -3796,8 +3798,8 @@
Fset_marker (w->sb_point, w->start[CURRENT_DISP], buffer);
/* set start_at_line_beg correctly. GE */
w->start_at_line_beg =
- beginning_of_line_p (XBUFFER (buffer),
- marker_position (w->start[CURRENT_DISP]));
+ byte_beginning_of_line_p (XBUFFER (buffer),
+ byte_marker_position (w->start[CURRENT_DISP]));
w->force_start = 0; /* XEmacs fix */
SET_LAST_MODIFIED (w, 1);
SET_LAST_FACECHANGE (w);
@@ -4636,7 +4638,9 @@
Fvertical_motion (make_fixnum (-window_char_height (w, 0) / 2),
window, Qnil);
Fset_marker (w->start[CURRENT_DISP], point, w->buffer);
- w->start_at_line_beg = beginning_of_line_p (b, XFIXNUM (point));
+ w->start_at_line_beg
+ = byte_beginning_of_line_p
+ (b, byte_marker_position (w->start[CURRENT_DISP]));
WINDOW_TEXT_TOP_CLIP (w) = 0;
MARK_WINDOWS_CHANGED (w);
}
@@ -4732,10 +4736,13 @@
}
else
{
- set_marker_restricted (w->start[CURRENT_DISP], make_fixnum (startp),
+ set_marker_restricted (w->start[CURRENT_DISP],
+ make_fixnum (startp),
w->buffer);
w->force_start = 1;
- w->start_at_line_beg = beginning_of_line_p (b, startp);
+ w->start_at_line_beg
+ = byte_beginning_of_line_p
+ (b, byte_marker_position (w->start[CURRENT_DISP]));
MARK_WINDOWS_CHANGED (w);
if (!point_would_be_visible (w, startp, XFIXNUM (point), 0))
@@ -4785,7 +4792,9 @@
set_marker_restricted (w->start[CURRENT_DISP], make_fixnum (startp),
w->buffer);
w->force_start = 1;
- w->start_at_line_beg = beginning_of_line_p (b, startp);
+ w->start_at_line_beg
+ = byte_beginning_of_line_p
+ (b, byte_marker_position (w->start[CURRENT_DISP]));
MARK_WINDOWS_CHANGED (w);
/* #### Scroll back by less than a line. This code was
@@ -4848,7 +4857,9 @@
set_marker_restricted (w->start[CURRENT_DISP], make_fixnum (startp),
w->buffer);
w->force_start = 1;
- w->start_at_line_beg = beginning_of_line_p (b, startp);
+ w->start_at_line_beg
+ = byte_beginning_of_line_p
+ (b, byte_marker_position (w->start[CURRENT_DISP]));
MARK_WINDOWS_CHANGED (w);
if (!point_would_be_visible (w, startp, XFIXNUM (point), 0))
@@ -5026,7 +5037,9 @@
Fset_marker (w->start[CURRENT_DISP], make_fixnum (startp), w->buffer);
- w->start_at_line_beg = beginning_of_line_p (b, startp);
+ w->start_at_line_beg
+ = byte_beginning_of_line_p (b,
+ byte_marker_position (w->start[CURRENT_DISP]));
w->force_start = 1;
MARK_WINDOWS_CHANGED (w);
return Qnil;
@@ -5128,7 +5141,9 @@
Fset_marker (w->start[CURRENT_DISP], make_fixnum (new_point),
w->buffer);
- w->start_at_line_beg = beginning_of_line_p (b, new_point);
+ w->start_at_line_beg
+ = byte_beginning_of_line_p
+ (b, byte_marker_position (w->start[CURRENT_DISP]));
w->force_start = 1;
}
else
--
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after forty pints of stout’
(C. Moore)