* Proposal: 'struct window' cleanup
@ 2012-05-21 14:25 Dmitry Antipov
2012-05-21 14:37 ` Davis Herring
2012-05-22 3:30 ` Stefan Monnier
0 siblings, 2 replies; 11+ messages in thread
From: Dmitry Antipov @ 2012-05-21 14:25 UTC (permalink / raw
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 306 bytes --]
This patch drops some Lisp_Object fields (used only as booleans with Qt or Qnil values)
from 'struct window', replacing them with bitfields. This is proposed to 1) shrink the
memory footprint of the structure and 2) get a tiny speedup of GC by reducing the
number of fields to trace at mark phase.
Dmitry
[-- Attachment #2: window_cleanup.patch --]
[-- Type: text/plain, Size: 25435 bytes --]
=== modified file 'src/fileio.c'
--- src/fileio.c 2012-05-04 23:16:47 +0000
+++ src/fileio.c 2012-05-21 14:16:09 +0000
@@ -3732,7 +3732,7 @@
/* If display currently starts at beginning of line,
keep it that way. */
if (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer)
- XWINDOW (selected_window)->start_at_line_beg = Fbolp ();
+ XWINDOW (selected_window)->start_at_line_beg_p = !NILP (Fbolp ());
replace_handled = 1;
}
@@ -3890,7 +3890,7 @@
/* If display currently starts at beginning of line,
keep it that way. */
if (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer)
- XWINDOW (selected_window)->start_at_line_beg = Fbolp ();
+ XWINDOW (selected_window)->start_at_line_beg_p = !NILP (Fbolp ());
/* Replace the chars that we need to replace,
and update INSERTED to equal the number of bytes
=== modified file 'src/frame.c'
--- src/frame.c 2012-03-10 07:46:07 +0000
+++ src/frame.c 2012-05-21 14:16:09 +0000
@@ -331,7 +331,7 @@
mini_window = make_window ();
XWINDOW (root_window)->next = mini_window;
XWINDOW (mini_window)->prev = root_window;
- XWINDOW (mini_window)->mini_p = Qt;
+ XWINDOW (mini_window)->mini_p = 1;
XWINDOW (mini_window)->frame = frame;
f->minibuffer_window = mini_window;
}
@@ -480,7 +480,7 @@
as nil. */
mini_window = f->minibuffer_window = f->root_window;
- XWINDOW (mini_window)->mini_p = Qt;
+ XWINDOW (mini_window)->mini_p = 1;
XWINDOW (mini_window)->next = Qnil;
XWINDOW (mini_window)->prev = Qnil;
XWINDOW (mini_window)->frame = frame;
=== modified file 'src/keyboard.c'
--- src/keyboard.c 2012-05-14 15:22:29 +0000
+++ src/keyboard.c 2012-05-21 14:16:09 +0000
@@ -1486,10 +1486,10 @@
from that position. But also throw away beg_unchanged and
end_unchanged information in that case, so that redisplay will
update the whole window properly. */
- if (!NILP (XWINDOW (selected_window)->force_start))
+ if (XWINDOW (selected_window)->force_start_p)
{
struct buffer *b;
- XWINDOW (selected_window)->force_start = Qnil;
+ XWINDOW (selected_window)->force_start_p = 0;
b = XBUFFER (XWINDOW (selected_window)->buffer);
BUF_BEG_UNCHANGED (b) = BUF_END_UNCHANGED (b) = 0;
}
=== modified file 'src/window.c'
--- src/window.c 2012-04-27 03:10:38 +0000
+++ src/window.c 2012-05-21 14:16:09 +0000
@@ -1393,10 +1393,10 @@
CHECK_NUMBER_COERCE_MARKER (pos);
set_marker_restricted (w->start, pos, w->buffer);
/* this is not right, but much easier than doing what is right. */
- w->start_at_line_beg = Qnil;
+ w->start_at_line_beg_p = 0;
if (NILP (noforce))
- w->force_start = Qt;
- w->update_mode_line = Qt;
+ w->force_start_p = 1;
+ w->update_mode_line_p = 1;
XSETFASTINT (w->last_modified, 0);
XSETFASTINT (w->last_overlay_modified, 0);
if (!EQ (window, selected_window))
@@ -1599,7 +1599,7 @@
is the value returned by `window-dedicated-p' is t. */)
(Lisp_Object window)
{
- return decode_window (window)->dedicated;
+ return decode_window (window)->dedicated_p ? Qt : Qnil;
}
DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p,
@@ -1625,8 +1625,8 @@
{
register struct window *w = decode_window (window);
- w->dedicated = flag;
- return w->dedicated;
+ w->dedicated_p = !NILP (flag);
+ return flag;
}
DEFUN ("window-prev-buffers", Fwindow_prev_buffers, Swindow_prev_buffers,
@@ -2453,7 +2453,7 @@
if (EQ (w->buffer, obj))
{
/* Undedicate WINDOW. */
- w->dedicated = Qnil;
+ w->dedicated_p = 0;
/* Make WINDOW show the buffer returned by
other_buffer_safely, don't run any hooks. */
set_window_buffer
@@ -2471,7 +2471,7 @@
if (EQ (w->buffer, obj))
{
mark_window_display_accurate (window, 0);
- w->update_mode_line = Qt;
+ w->update_mode_line_p = 1;
XBUFFER (obj)->prevent_redisplay_optimizations_p = 1;
++update_mode_lines;
best_window = window;
@@ -2770,12 +2770,11 @@
set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos);
w->window_end_valid = Qnil;
- w->start_at_line_beg = ((pos.bytepos == BEGV_BYTE
- || FETCH_BYTE (pos.bytepos - 1) == '\n') ? Qt
- : Qnil);
+ w->start_at_line_beg_p = (pos.bytepos == BEGV_BYTE
+ || FETCH_BYTE (pos.bytepos - 1) == '\n');
/* We need to do this, so that the window-scroll-functions
get called. */
- w->optional_new_start = Qt;
+ w->optional_new_start_p = 1;
set_buffer_internal (obuf);
}
@@ -3005,8 +3004,8 @@
set_marker_restricted (w->start,
make_number (b->last_window_start),
buffer);
- w->start_at_line_beg = Qnil;
- w->force_start = Qnil;
+ w->start_at_line_beg_p = 0;
+ w->force_start_p = 0;
XSETFASTINT (w->last_modified, 0);
XSETFASTINT (w->last_overlay_modified, 0);
}
@@ -3097,14 +3096,14 @@
{
if (!EQ (tem, buffer))
{
- if (EQ (w->dedicated, Qt))
+ if (w->dedicated_p)
/* WINDOW is strongly dedicated to its buffer, signal an
error. */
error ("Window is dedicated to `%s'", SDATA (BVAR (XBUFFER (tem), name)));
else
/* WINDOW is weakly dedicated to its buffer, reset
dedication. */
- w->dedicated = Qnil;
+ w->dedicated_p = 0;
call1 (Qrecord_window_buffer, window);
}
@@ -3142,7 +3141,7 @@
{
struct window *w = XWINDOW (object);
mark_window_display_accurate (object, 0);
- w->update_mode_line = Qt;
+ w->update_mode_line_p = 1;
if (BUFFERP (w->buffer))
XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
++update_mode_lines;
@@ -3274,7 +3273,8 @@
w = allocate_window ();
/* Initialize all Lisp data. */
- w->frame = w->mini_p = Qnil;
+ w->frame = Qnil;
+ w->mini_p = 0;
w->next = w->prev = w->hchild = w->vchild = w->parent = Qnil;
XSETFASTINT (w->left_col, 0);
XSETFASTINT (w->top_line, 0);
@@ -3287,7 +3287,7 @@
w->buffer = Qnil;
w->start = Fmake_marker ();
w->pointm = Fmake_marker ();
- w->force_start = w->optional_new_start = Qnil;
+ w->force_start_p = w->optional_new_start_p = 0;
XSETFASTINT (w->hscroll, 0);
XSETFASTINT (w->min_hscroll, 0);
XSETFASTINT (w->use_time, 0);
@@ -3295,17 +3295,17 @@
XSETFASTINT (w->sequence_number, sequence_number);
w->temslot = w->last_modified = w->last_overlay_modified = Qnil;
XSETFASTINT (w->last_point, 0);
- w->last_had_star = w->vertical_scroll_bar = Qnil;
+ w->last_had_star_p = 0;
+ w->vertical_scroll_bar = Qnil;
w->left_margin_cols = w->right_margin_cols = Qnil;
w->left_fringe_width = w->right_fringe_width = Qnil;
w->fringes_outside_margins = Qnil;
w->scroll_bar_width = Qnil;
w->vertical_scroll_bar_type = Qt;
- w->last_mark_x = w->last_mark_y = Qnil;
XSETFASTINT (w->window_end_pos, 0);
XSETFASTINT (w->window_end_vpos, 0);
- w->window_end_valid = w->update_mode_line = Qnil;
- w->start_at_line_beg = w->display_table = w->dedicated = Qnil;
+ w->window_end_valid = w->display_table = Qnil;
+ w->update_mode_line_p = w->start_at_line_beg_p = w->dedicated_p = 0;
w->base_line_number = w->base_line_pos = w->region_showing = Qnil;
w->column_number_displayed = w->redisplay_end_trigger = Qnil;
w->combination_limit = w->window_parameters = Qnil;
@@ -4303,13 +4303,13 @@
spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV);
set_marker_restricted (w->start, make_number (spos),
w->buffer);
- w->start_at_line_beg = Qt;
- w->update_mode_line = Qt;
+ w->start_at_line_beg_p = 1;
+ w->update_mode_line_p = 1;
XSETFASTINT (w->last_modified, 0);
XSETFASTINT (w->last_overlay_modified, 0);
/* Set force_start so that redisplay_window will run the
window-scroll-functions. */
- w->force_start = Qt;
+ w->force_start_p = 1;
return;
}
}
@@ -4449,14 +4449,13 @@
set_marker_restricted (w->start, make_number (pos),
w->buffer);
bytepos = XMARKER (w->start)->bytepos;
- w->start_at_line_beg = ((pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n')
- ? Qt : Qnil);
- w->update_mode_line = Qt;
+ w->start_at_line_beg_p = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
+ w->update_mode_line_p = 1;
XSETFASTINT (w->last_modified, 0);
XSETFASTINT (w->last_overlay_modified, 0);
/* Set force_start so that redisplay_window will run the
window-scroll-functions. */
- w->force_start = Qt;
+ w->force_start_p = 1;
}
/* The rest of this function uses current_y in a nonstandard way,
@@ -4649,13 +4648,13 @@
max (0, min (scroll_margin, XINT (w->total_lines) / 4));
set_marker_restricted_both (w->start, w->buffer, pos, pos_byte);
- w->start_at_line_beg = bolp;
- w->update_mode_line = Qt;
+ w->start_at_line_beg_p = !NILP (bolp);
+ w->update_mode_line_p = 1;
XSETFASTINT (w->last_modified, 0);
XSETFASTINT (w->last_overlay_modified, 0);
/* Set force_start so that redisplay_window will run
the window-scroll-functions. */
- w->force_start = Qt;
+ w->force_start_p = 1;
if (!NILP (Vscroll_preserve_screen_position)
&& (whole || !EQ (Vscroll_preserve_screen_position, Qt)))
@@ -5199,12 +5198,10 @@
set_marker_both (w->start, w->buffer, charpos, bytepos);
w->window_end_valid = Qnil;
- w->optional_new_start = Qt;
+ w->optional_new_start_p = 1;
- if (bytepos == BEGV_BYTE || FETCH_BYTE (bytepos - 1) == '\n')
- w->start_at_line_beg = Qt;
- else
- w->start_at_line_beg = Qnil;
+ w->start_at_line_beg_p = (bytepos == BEGV_BYTE ||
+ FETCH_BYTE (bytepos - 1) == '\n');
set_buffer_internal (obuf);
return Qnil;
@@ -5255,8 +5252,8 @@
int height = window_internal_height (w);
Fvertical_motion (make_number (- (height / 2)), window);
set_marker_both (w->start, w->buffer, PT, PT_BYTE);
- w->start_at_line_beg = Fbolp ();
- w->force_start = Qt;
+ w->start_at_line_beg_p = !NILP (Fbolp ());
+ w->force_start_p = 1;
}
else
Fgoto_char (w->start);
@@ -5570,7 +5567,7 @@
w->fringes_outside_margins = p->fringes_outside_margins;
w->scroll_bar_width = p->scroll_bar_width;
w->vertical_scroll_bar_type = p->vertical_scroll_bar_type;
- w->dedicated = p->dedicated;
+ w->dedicated_p = !NILP (p->dedicated);
w->combination_limit = p->combination_limit;
/* Restore any window parameters that have been saved.
Parameters that have not been saved are left alone. */
@@ -5605,7 +5602,7 @@
/* If saved buffer is alive, install it. */
{
w->buffer = p->buffer;
- w->start_at_line_beg = p->start_at_line_beg;
+ w->start_at_line_beg_p = !NILP (p->start_at_line_beg);
set_marker_restricted (w->start, p->start, w->buffer);
set_marker_restricted (w->pointm, p->pointm, w->buffer);
Fset_marker (BVAR (XBUFFER (w->buffer), mark),
@@ -5630,7 +5627,7 @@
set_marker_restricted_both (w->pointm, w->buffer,
BUF_PT (XBUFFER (w->buffer)),
BUF_PT_BYTE (XBUFFER (w->buffer)));
- w->start_at_line_beg = Qt;
+ w->start_at_line_beg_p = 1;
}
else if (STRINGP (auto_buffer_name =
Fwindow_parameter (window, Qauto_buffer_name))
@@ -5639,7 +5636,7 @@
{
set_marker_restricted (w->start, make_number (0), w->buffer);
set_marker_restricted (w->pointm, make_number (0), w->buffer);
- w->start_at_line_beg = Qt;
+ w->start_at_line_beg_p = 1;
}
else
/* Window has no live buffer, get one. */
@@ -5653,12 +5650,12 @@
range. */
set_marker_restricted (w->start, make_number (0), w->buffer);
set_marker_restricted (w->pointm, make_number (0), w->buffer);
- w->start_at_line_beg = Qt;
- if (!NILP (w->dedicated))
+ w->start_at_line_beg_p = 1;
+ if (w->dedicated_p)
/* Record this window as dead. */
dead_windows = Fcons (window, dead_windows);
/* Make sure window is no more dedicated. */
- w->dedicated = Qnil;
+ w->dedicated_p = 0;
}
}
@@ -5886,7 +5883,7 @@
p->fringes_outside_margins = w->fringes_outside_margins;
p->scroll_bar_width = w->scroll_bar_width;
p->vertical_scroll_bar_type = w->vertical_scroll_bar_type;
- p->dedicated = w->dedicated;
+ p->dedicated = w->dedicated_p ? Qt : Qnil;
p->combination_limit = w->combination_limit;
p->window_parameters = Qnil;
@@ -5954,7 +5951,7 @@
= !NILP (Vwindow_point_insertion_type);
p->start = Fcopy_marker (w->start, Qnil);
- p->start_at_line_beg = w->start_at_line_beg;
+ p->start_at_line_beg = w->start_at_line_beg_p ? Qt : Qnil;
tem = BVAR (XBUFFER (w->buffer), mark);
p->mark = Fcopy_marker (tem, Qnil);
=== modified file 'src/window.h'
--- src/window.h 2012-03-12 06:34:32 +0000
+++ src/window.h 2012-05-21 14:16:09 +0000
@@ -94,9 +94,6 @@
/* The frame this window is on. */
Lisp_Object frame;
- /* t if this window is a minibuffer window. */
- Lisp_Object mini_p;
-
/* Following (to right or down) and preceding (to left or up) child
at same level of tree. */
Lisp_Object next, prev;
@@ -144,15 +141,6 @@
each one can have its own value of point. */
Lisp_Object pointm;
- /* Non-nil means next redisplay must use the value of start
- set up for it in advance. Set by scrolling commands. */
- Lisp_Object force_start;
- /* Non-nil means we have explicitly changed the value of start,
- but that the next redisplay is not obliged to use the new value.
- This is used in Fdelete_other_windows to force a call to
- Vwindow_scroll_functions; also by Frecenter with argument. */
- Lisp_Object optional_new_start;
-
/* Number of columns display within the window is scrolled to the left. */
Lisp_Object hscroll;
/* Minimum hscroll for automatic hscrolling. This is the value
@@ -176,9 +164,6 @@
Lisp_Object last_overlay_modified;
/* Value of point at that time. */
Lisp_Object last_point;
- /* Non-nil if the buffer was "modified" when the window
- was last updated. */
- Lisp_Object last_had_star;
/* This window's vertical scroll bar. This field is only for use
by the window-system-dependent code which implements the
@@ -206,11 +191,6 @@
no scroll bar. A value of t means use frame value. */
Lisp_Object vertical_scroll_bar_type;
- /* Frame coords of mark as of last time display completed */
- /* May be nil if mark does not exist or was not on frame */
- Lisp_Object last_mark_x;
- Lisp_Object last_mark_y;
-
/* Z - the buffer position of the last glyph in the current matrix
of W. Only valid if WINDOW_END_VALID is not nil. */
Lisp_Object window_end_pos;
@@ -223,20 +203,10 @@
did not get onto the frame. */
Lisp_Object window_end_valid;
- /* Non-nil means must regenerate mode line of this window */
- Lisp_Object update_mode_line;
-
- /* Non-nil means current value of `start'
- was the beginning of a line when it was chosen. */
- Lisp_Object start_at_line_beg;
-
/* Display-table to use for displaying chars in this window.
Nil means use the buffer's own display-table. */
Lisp_Object display_table;
- /* Non-nil means window is marked as dedicated. */
- Lisp_Object dedicated;
-
/* Line number and position of a line somewhere above the top of the
screen. If this field is nil, it means we don't have a base
line. */
@@ -302,6 +272,33 @@
/* This is handy for undrawing the cursor. */
int phys_cursor_ascent, phys_cursor_height;
+ /* Non-zero if this window is a minibuffer window. */
+ unsigned mini_p : 1;
+
+ /* Non-zero means must regenerate mode line of this window */
+ unsigned update_mode_line_p : 1;
+
+ /* Non-nil if the buffer was "modified" when the window
+ was last updated. */
+ unsigned last_had_star_p : 1;
+
+ /* Non-zero means current value of `start'
+ was the beginning of a line when it was chosen. */
+ unsigned start_at_line_beg_p : 1;
+
+ /* Non-zero means window is marked as dedicated. */
+ unsigned dedicated_p : 1;
+
+ /* Non-zero means next redisplay must use the value of start
+ set up for it in advance. Set by scrolling commands. */
+ unsigned force_start_p : 1;
+
+ /* Non-zero means we have explicitly changed the value of start,
+ but that the next redisplay is not obliged to use the new value.
+ This is used in Fdelete_other_windows to force a call to
+ Vwindow_scroll_functions; also by Frecenter with argument. */
+ unsigned optional_new_start_p : 1;
+
/* Non-zero means the cursor is currently displayed. This can be
set to zero by functions overpainting the cursor image. */
unsigned phys_cursor_on_p : 1;
@@ -337,7 +334,7 @@
/* 1 if W is a minibuffer window. */
-#define MINI_WINDOW_P(W) (!NILP ((W)->mini_p))
+#define MINI_WINDOW_P(W) ((W)->mini_p)
/* General window layout:
=== modified file 'src/xdisp.c'
--- src/xdisp.c 2012-05-14 11:59:28 +0000
+++ src/xdisp.c 2012-05-21 14:16:09 +0000
@@ -11152,7 +11152,7 @@
|| update_mode_lines
|| ((BUF_SAVE_MODIFF (XBUFFER (w->buffer))
< BUF_MODIFF (XBUFFER (w->buffer)))
- != !NILP (w->last_had_star))
+ != w->last_had_star_p)
|| ((!NILP (Vtransient_mark_mode)
&& !NILP (BVAR (XBUFFER (w->buffer), mark_active)))
!= !NILP (w->region_showing)))
@@ -11204,11 +11204,11 @@
else
/* On a terminal screen, the menu bar is an ordinary screen
line, and this makes it get updated. */
- w->update_mode_line = Qt;
+ w->update_mode_line_p = 1;
#else /* ! (USE_X_TOOLKIT || HAVE_NTGUI || HAVE_NS || USE_GTK) */
/* In the non-toolkit version, the menu bar is an ordinary screen
line, and this makes it get updated. */
- w->update_mode_line = Qt;
+ w->update_mode_line_p = 1;
#endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI || HAVE_NS || USE_GTK) */
unbind_to (count, Qnil);
@@ -11346,11 +11346,11 @@
the rest of the redisplay algorithm is about the same as
windows_or_buffers_changed anyway. */
if (windows_or_buffers_changed
- || !NILP (w->update_mode_line)
+ || w->update_mode_line_p
|| update_mode_lines
|| ((BUF_SAVE_MODIFF (XBUFFER (w->buffer))
< BUF_MODIFF (XBUFFER (w->buffer)))
- != !NILP (w->last_had_star))
+ != w->last_had_star_p)
|| ((!NILP (Vtransient_mark_mode)
&& !NILP (BVAR (XBUFFER (w->buffer), mark_active)))
!= !NILP (w->region_showing)))
@@ -11401,7 +11401,7 @@
BLOCK_INPUT;
f->tool_bar_items = new_tool_bar;
f->n_tool_bar_items = new_n_tool_bar;
- w->update_mode_line = Qt;
+ w->update_mode_line_p = 1;
UNBLOCK_INPUT;
}
@@ -12950,9 +12950,9 @@
update_mode_lines++;
/* Detect case that we need to write or remove a star in the mode line. */
- if ((SAVE_MODIFF < MODIFF) != !NILP (w->last_had_star))
+ if ((SAVE_MODIFF < MODIFF) != w->last_had_star_p)
{
- w->update_mode_line = Qt;
+ w->update_mode_line_p = 1;
if (buffer_shared > 1)
update_mode_lines++;
}
@@ -12969,7 +12969,7 @@
&& XFASTINT (w->last_modified) >= MODIFF
&& XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
&& (XFASTINT (w->column_number_displayed) != current_column ()))
- w->update_mode_line = Qt;
+ w->update_mode_line_p = 1;
unbind_to (count1, Qnil);
@@ -13072,7 +13072,7 @@
tlendpos = this_line_end_pos;
if (!consider_all_windows_p
&& CHARPOS (tlbufpos) > 0
- && NILP (w->update_mode_line)
+ && !w->update_mode_line_p
&& !current_buffer->clip_changed
&& !current_buffer->prevent_redisplay_optimizations_p
&& FRAME_VISIBLE_P (XFRAME (w->frame))
@@ -13080,8 +13080,8 @@
/* Make sure recorded data applies to current buffer, etc. */
&& this_line_buffer == current_buffer
&& current_buffer == XBUFFER (w->buffer)
- && NILP (w->force_start)
- && NILP (w->optional_new_start)
+ && !w->force_start_p
+ && !w->optional_new_start_p
/* Point must be on the line that we have info recorded about. */
&& PT >= CHARPOS (tlbufpos)
&& PT <= Z - CHARPOS (tlendpos)
@@ -13615,8 +13615,8 @@
= make_number (accurate_p ? BUF_MODIFF (b) : 0);
w->last_overlay_modified
= make_number (accurate_p ? BUF_OVERLAY_MODIFF (b) : 0);
- w->last_had_star
- = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b) ? Qt : Qnil;
+ w->last_had_star_p
+ = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b);
if (accurate_p)
{
@@ -13645,7 +13645,7 @@
if (accurate_p)
{
w->window_end_valid = w->buffer;
- w->update_mode_line = Qnil;
+ w->update_mode_line_p = 0;
}
}
@@ -15274,7 +15274,7 @@
reconsider_clip_changes (w, buffer);
/* Has the mode line to be updated? */
- update_mode_line = (!NILP (w->update_mode_line)
+ update_mode_line = (w->update_mode_line_p
|| update_mode_lines
|| buffer->clip_changed
|| buffer->prevent_redisplay_optimizations_p);
@@ -15446,32 +15446,31 @@
/* If someone specified a new starting point but did not insist,
check whether it can be used. */
- if (!NILP (w->optional_new_start)
+ if (w->optional_new_start_p
&& CHARPOS (startp) >= BEGV
&& CHARPOS (startp) <= ZV)
{
- w->optional_new_start = Qnil;
+ w->optional_new_start_p = 0;
start_display (&it, w, startp);
move_it_to (&it, PT, 0, it.last_visible_y, -1,
MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
if (IT_CHARPOS (it) == PT)
- w->force_start = Qt;
+ w->force_start_p = 1;
/* IT may overshoot PT if text at PT is invisible. */
else if (IT_CHARPOS (it) > PT && CHARPOS (startp) <= PT)
- w->force_start = Qt;
+ w->force_start_p = 1;
}
force_start:
/* Handle case where place to start displaying has been specified,
unless the specified location is outside the accessible range. */
- if (!NILP (w->force_start)
- || w->frozen_window_start_p)
+ if (w->force_start_p || w->frozen_window_start_p)
{
/* We set this later on if we have to adjust point. */
int new_vpos = -1;
- w->force_start = Qnil;
+ w->force_start_p = 0;
w->vscroll = 0;
w->window_end_valid = Qnil;
@@ -15490,7 +15489,7 @@
|| ! NILP (Vwindow_scroll_functions))
{
update_mode_line = 1;
- w->update_mode_line = Qt;
+ w->update_mode_line_p = 1;
startp = run_window_scroll_functions (window, startp);
}
@@ -15508,7 +15507,7 @@
the scroll margin (bug#148) -- cyd */
if (!try_window (window, startp, 0))
{
- w->force_start = Qt;
+ w->force_start_p = 1;
clear_glyph_matrix (w->desired_matrix);
goto need_larger_matrices;
}
@@ -15587,7 +15586,7 @@
}
/* If current starting point was originally the beginning of a line
but no longer is, find a new starting point. */
- else if (!NILP (w->start_at_line_beg)
+ else if (w->start_at_line_beg_p
&& !(CHARPOS (startp) <= BEGV
|| FETCH_BYTE (BYTEPOS (startp) - 1) == '\n'))
{
@@ -15634,7 +15633,7 @@
new window start, since that would change the position under
the mouse, resulting in an unwanted mouse-movement rather
than a simple mouse-click. */
- if (NILP (w->start_at_line_beg)
+ if (!w->start_at_line_beg_p
&& NILP (do_mouse_tracking)
&& CHARPOS (startp) > BEGV
&& CHARPOS (startp) > BEG + beg_unchanged
@@ -15654,7 +15653,7 @@
See bug#9324. */
&& pos_visible_p (w, PT, &d1, &d2, &d3, &d4, &d5, &d6))
{
- w->force_start = Qt;
+ w->force_start_p = 1;
SET_TEXT_POS_FROM_MARKER (startp, w->start);
goto force_start;
}
@@ -15715,7 +15714,7 @@
if (!update_mode_line)
{
update_mode_line = 1;
- w->update_mode_line = Qt;
+ w->update_mode_line_p = 1;
}
/* Try to scroll by specified few lines. */
@@ -15970,9 +15969,8 @@
done:
SET_TEXT_POS_FROM_MARKER (startp, w->start);
- w->start_at_line_beg = ((CHARPOS (startp) == BEGV
- || FETCH_BYTE (BYTEPOS (startp) - 1) == '\n')
- ? Qt : Qnil);
+ w->start_at_line_beg_p = (CHARPOS (startp) == BEGV
+ || FETCH_BYTE (BYTEPOS (startp) - 1) == '\n');
/* Display the mode line, if we must. */
if ((update_mode_line
@@ -16189,7 +16187,7 @@
/* If bottom moved off end of frame, change mode line percentage. */
if (XFASTINT (w->window_end_pos) <= 0
&& Z != IT_CHARPOS (it))
- w->update_mode_line = Qt;
+ w->update_mode_line_p = 1;
/* Set window_end_pos to the offset of the last character displayed
on the window from the end of current_buffer. Set
=== modified file 'src/xfns.c'
--- src/xfns.c 2012-05-19 21:46:43 +0000
+++ src/xfns.c 2012-05-21 14:16:09 +0000
@@ -1215,7 +1215,7 @@
FRAME_EXTERNAL_MENU_BAR (f) = 1;
if (FRAME_X_P (f) && f->output_data.x->menubar_widget == 0)
/* Make sure next redisplay shows the menu bar. */
- XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
+ XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line_p = 1;
}
else
{
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal: 'struct window' cleanup
2012-05-21 14:25 Proposal: 'struct window' cleanup Dmitry Antipov
@ 2012-05-21 14:37 ` Davis Herring
2012-05-22 3:30 ` Stefan Monnier
1 sibling, 0 replies; 11+ messages in thread
From: Davis Herring @ 2012-05-21 14:37 UTC (permalink / raw
To: Dmitry Antipov; +Cc: emacs-devel
> @@ -3097,14 +3096,14 @@
> {
> if (!EQ (tem, buffer))
> {
> - if (EQ (w->dedicated, Qt))
> + if (w->dedicated_p)
> /* WINDOW is strongly dedicated to its buffer, signal an
> error. */
> error ("Window is dedicated to `%s'", SDATA (BVAR (XBUFFER (tem), name)));
> else
> /* WINDOW is weakly dedicated to its buffer, reset
> dedication. */
> - w->dedicated = Qnil;
> + w->dedicated_p = 0;
>
> call1 (Qrecord_window_buffer, window);
w->dedicated is not merely a boolean, as seen here; it can be set other
than to t.
> @@ -206,11 +191,6 @@
> no scroll bar. A value of t means use frame value. */
> Lisp_Object vertical_scroll_bar_type;
>
> - /* Frame coords of mark as of last time display completed */
> - /* May be nil if mark does not exist or was not on frame */
> - Lisp_Object last_mark_x;
> - Lisp_Object last_mark_y;
> -
> /* Z - the buffer position of the last glyph in the current matrix
> of W. Only valid if WINDOW_END_VALID is not nil. */
> Lisp_Object window_end_pos;
I guess these weren't used at all? They were never booleans.
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal: 'struct window' cleanup
2012-05-21 14:25 Proposal: 'struct window' cleanup Dmitry Antipov
2012-05-21 14:37 ` Davis Herring
@ 2012-05-22 3:30 ` Stefan Monnier
2012-05-22 7:08 ` Dmitry Antipov
1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2012-05-22 3:30 UTC (permalink / raw
To: Dmitry Antipov; +Cc: emacs-devel
> + XWINDOW (selected_window)->start_at_line_beg_p = !NILP (Fbolp ());
I generally like the idea. But please don't use "_p" suffixes
for variables. The "p" stands for "predicate" and a predicate is a kind
of function, so that's not the right way to say that something is
a boolean value.
And as someone else mentioned, `dedicated' can take more values than just
t and nil, so it's not a candidate for the rewrite you suggest.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal: 'struct window' cleanup
2012-05-22 3:30 ` Stefan Monnier
@ 2012-05-22 7:08 ` Dmitry Antipov
2012-05-22 7:40 ` Thien-Thi Nguyen
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Dmitry Antipov @ 2012-05-22 7:08 UTC (permalink / raw
To: Stefan Monnier; +Cc: emacs-devel
On 05/22/2012 07:30 AM, Stefan Monnier wrote:
> I generally like the idea. But please don't use "_p" suffixes
> for variables. The "p" stands for "predicate" and a predicate is a kind
> of function, so that's not the right way to say that something is
> a boolean value.
OK, but what about other "struct window" bitfield members whose names
ends with "_p"? Should we also rename it to obey this naming convention?
Also this kind of patch proposes a lot of small and simple changes.
Is there a convenient way to document them in ChangeLog?
Dmitry
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal: 'struct window' cleanup
2012-05-22 7:08 ` Dmitry Antipov
@ 2012-05-22 7:40 ` Thien-Thi Nguyen
2012-05-22 12:39 ` Stefan Monnier
2012-05-22 16:15 ` Eli Zaretskii
2 siblings, 0 replies; 11+ messages in thread
From: Thien-Thi Nguyen @ 2012-05-22 7:40 UTC (permalink / raw
To: Dmitry Antipov; +Cc: emacs-devel
() Dmitry Antipov <dmantipov@yandex.ru>
() Tue, 22 May 2012 11:08:18 +0400
[...] a lot of small and simple changes.
Is there a convenient way to document them in ChangeLog?
Perhaps you could say:
TITLE
* window.h (struct window): Rename member OLD-NAME-1 to NEW-NAME-1,
converting its type to NEW-TYPE, and moving it to NEW-PLACE.
Likewise for OLD-NAME-2 -> NEW-NAME-2, ...
* FILE-1.c (first_func): Use new names, adjusting for NEW-TYPE.
(second_func, third_func, fourth_func, ...)
(penultimate_func, nth_func): Likewise.
* FILE-2.c (first_func, second_func, third_func, fourth_func, ...)
(penultimate_func, nth_func): Likewise.
where TITLE is the optional (but recommended) one-line description
of the change. This way is most concise, if not completely convenient.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal: 'struct window' cleanup
2012-05-22 7:08 ` Dmitry Antipov
2012-05-22 7:40 ` Thien-Thi Nguyen
@ 2012-05-22 12:39 ` Stefan Monnier
2012-05-23 4:49 ` Dmitry Antipov
2012-05-22 16:15 ` Eli Zaretskii
2 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2012-05-22 12:39 UTC (permalink / raw
To: Dmitry Antipov; +Cc: emacs-devel
>> I generally like the idea. But please don't use "_p" suffixes
>> for variables. The "p" stands for "predicate" and a predicate is a kind
>> of function, so that's not the right way to say that something is
>> a boolean value.
> OK, but what about other "struct window" bitfield members whose names
> ends with "_p"?
Yes, I know, just like many Elisp packages use vars with names ending in
"-p" for the same mistaken reason.
> Should we also rename it to obey this naming convention?
No, it's not worth the trouble.
> Also this kind of patch proposes a lot of small and simple changes.
> Is there a convenient way to document them in ChangeLog?
I'd do it like
* foo.h (struct bar): Use bitfields for field1, field2, field3.
Adjust users accordingly.
-- Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal: 'struct window' cleanup
2012-05-22 7:08 ` Dmitry Antipov
2012-05-22 7:40 ` Thien-Thi Nguyen
2012-05-22 12:39 ` Stefan Monnier
@ 2012-05-22 16:15 ` Eli Zaretskii
2 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2012-05-22 16:15 UTC (permalink / raw
To: Dmitry Antipov; +Cc: monnier, emacs-devel
> Date: Tue, 22 May 2012 11:08:18 +0400
> From: Dmitry Antipov <dmantipov@yandex.ru>
> Cc: emacs-devel@gnu.org
>
> Also this kind of patch proposes a lot of small and simple changes.
> Is there a convenient way to document them in ChangeLog?
Something like this should do:
* window.h (struct window) <start_at_line_beg_p, foo_p>
<bar_p>: Convert to bitfields. All uses changed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal: 'struct window' cleanup
2012-05-22 12:39 ` Stefan Monnier
@ 2012-05-23 4:49 ` Dmitry Antipov
2012-05-23 14:23 ` Stefan Monnier
0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Antipov @ 2012-05-23 4:49 UTC (permalink / raw
To: Stefan Monnier; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 221 bytes --]
On 05/22/2012 04:39 PM, Stefan Monnier wrote:
> I'd do it like
>
> * foo.h (struct bar): Use bitfields for field1, field2, field3.
> Adjust users accordingly.
OK, I try to make it not too confusing.
Dmitry
[-- Attachment #2: window_cleanup.patch --]
[-- Type: text/plain, Size: 24928 bytes --]
=== modified file 'src/ChangeLog'
--- src/ChangeLog 2012-05-22 18:31:19 +0000
+++ src/ChangeLog 2012-05-23 04:38:27 +0000
@@ -1,3 +1,38 @@
+2012-05-23 Dmitry Antipov <dmantipov@yandex.ru>
+
+ For a 'struct window', replace some Lisp_Object fields to
+ bitfields where appropriate, remove unused fields.
+ * window.h (struct window): remove unused 'last_mark_x' and
+ 'last_mark_y' fields.
+ * window.h (struct window): rename 'mini_p' field to 'mini',
+ change it's type from Lisp_Object to bitfield.
+ * window.h (struct window): change type of 'force_start',
+ 'optional_new_start', 'last_had_star', 'update_mode_line'
+ and 'start_at_line_beg' fields from Lisp_Object to bitfield.
+ * fileio.c (Finsert_file_contents): adjusted for a new
+ type of 'start_at_line_beg'.
+ * frame.c (make_frame, make_minibuffer_frame): adjusted for
+ a new type of 'mini'.
+ * keyboard.c (command_loop_1): adjusted for a new type
+ of 'force_start'.
+ * window.c (Fset_window_start, window_loop)
+ (Fdelete_other_windows_internal, set_window_buffer)
+ (Fforce_window_update, make_window, window_scroll_pixel_based)
+ (window_scroll_line_based, Frecenter, Fmove_to_window_line)
+ (Fset_window_configuration, save_window_save): adjusted for
+ a type changes in 'struct window'.
+ * xdisp.c (update_menu_bar, update_tool_bar): adjusted for
+ a new type of 'last_had_star' and 'update_mode_line'.
+ * xdisp.c (redisplay_internal): adjusted for a new type
+ of 'update_mode_line', 'force_start' and 'optional_new_start'.
+ * xdisp.c (mark_window_display_accurate_1): adjusted for
+ a new type of 'last_had_star' and 'update_mode_line'.
+ * xdisp.c (redisplay_window): adjusted for
+ a type changes in 'struct window'.
+ * xdisp.c (try_window): adjusted for a new type of 'update_mode_line'.
+ * xfns.c (x_set_menu_bar_lines): adjusted for a new type
+ of 'update_mode_line'.
+
2012-05-22 Juanma Barranquero <lekktu@gmail.com>
* makefile.w32-in: Follow-up to revno:108341.
=== modified file 'src/fileio.c'
--- src/fileio.c 2012-05-04 23:16:47 +0000
+++ src/fileio.c 2012-05-23 03:50:52 +0000
@@ -3732,7 +3732,7 @@
/* If display currently starts at beginning of line,
keep it that way. */
if (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer)
- XWINDOW (selected_window)->start_at_line_beg = Fbolp ();
+ XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ());
replace_handled = 1;
}
@@ -3890,7 +3890,7 @@
/* If display currently starts at beginning of line,
keep it that way. */
if (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer)
- XWINDOW (selected_window)->start_at_line_beg = Fbolp ();
+ XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ());
/* Replace the chars that we need to replace,
and update INSERTED to equal the number of bytes
=== modified file 'src/frame.c'
--- src/frame.c 2012-03-10 07:46:07 +0000
+++ src/frame.c 2012-05-23 03:44:10 +0000
@@ -331,7 +331,7 @@
mini_window = make_window ();
XWINDOW (root_window)->next = mini_window;
XWINDOW (mini_window)->prev = root_window;
- XWINDOW (mini_window)->mini_p = Qt;
+ XWINDOW (mini_window)->mini = 1;
XWINDOW (mini_window)->frame = frame;
f->minibuffer_window = mini_window;
}
@@ -480,7 +480,7 @@
as nil. */
mini_window = f->minibuffer_window = f->root_window;
- XWINDOW (mini_window)->mini_p = Qt;
+ XWINDOW (mini_window)->mini = 1;
XWINDOW (mini_window)->next = Qnil;
XWINDOW (mini_window)->prev = Qnil;
XWINDOW (mini_window)->frame = frame;
=== modified file 'src/keyboard.c'
--- src/keyboard.c 2012-05-14 15:22:29 +0000
+++ src/keyboard.c 2012-05-23 03:50:31 +0000
@@ -1486,10 +1486,10 @@
from that position. But also throw away beg_unchanged and
end_unchanged information in that case, so that redisplay will
update the whole window properly. */
- if (!NILP (XWINDOW (selected_window)->force_start))
+ if (XWINDOW (selected_window)->force_start)
{
struct buffer *b;
- XWINDOW (selected_window)->force_start = Qnil;
+ XWINDOW (selected_window)->force_start = 0;
b = XBUFFER (XWINDOW (selected_window)->buffer);
BUF_BEG_UNCHANGED (b) = BUF_END_UNCHANGED (b) = 0;
}
=== modified file 'src/window.c'
--- src/window.c 2012-04-27 03:10:38 +0000
+++ src/window.c 2012-05-23 03:58:44 +0000
@@ -1393,10 +1393,10 @@
CHECK_NUMBER_COERCE_MARKER (pos);
set_marker_restricted (w->start, pos, w->buffer);
/* this is not right, but much easier than doing what is right. */
- w->start_at_line_beg = Qnil;
+ w->start_at_line_beg = 0;
if (NILP (noforce))
- w->force_start = Qt;
- w->update_mode_line = Qt;
+ w->force_start = 1;
+ w->update_mode_line = 1;
XSETFASTINT (w->last_modified, 0);
XSETFASTINT (w->last_overlay_modified, 0);
if (!EQ (window, selected_window))
@@ -2471,7 +2471,7 @@
if (EQ (w->buffer, obj))
{
mark_window_display_accurate (window, 0);
- w->update_mode_line = Qt;
+ w->update_mode_line = 1;
XBUFFER (obj)->prevent_redisplay_optimizations_p = 1;
++update_mode_lines;
best_window = window;
@@ -2770,12 +2770,11 @@
set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos);
w->window_end_valid = Qnil;
- w->start_at_line_beg = ((pos.bytepos == BEGV_BYTE
- || FETCH_BYTE (pos.bytepos - 1) == '\n') ? Qt
- : Qnil);
+ w->start_at_line_beg = (pos.bytepos == BEGV_BYTE
+ || FETCH_BYTE (pos.bytepos - 1) == '\n');
/* We need to do this, so that the window-scroll-functions
get called. */
- w->optional_new_start = Qt;
+ w->optional_new_start = 1;
set_buffer_internal (obuf);
}
@@ -3005,8 +3004,8 @@
set_marker_restricted (w->start,
make_number (b->last_window_start),
buffer);
- w->start_at_line_beg = Qnil;
- w->force_start = Qnil;
+ w->start_at_line_beg = 0;
+ w->force_start = 0;
XSETFASTINT (w->last_modified, 0);
XSETFASTINT (w->last_overlay_modified, 0);
}
@@ -3142,7 +3141,7 @@
{
struct window *w = XWINDOW (object);
mark_window_display_accurate (object, 0);
- w->update_mode_line = Qt;
+ w->update_mode_line = 1;
if (BUFFERP (w->buffer))
XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
++update_mode_lines;
@@ -3274,7 +3273,8 @@
w = allocate_window ();
/* Initialize all Lisp data. */
- w->frame = w->mini_p = Qnil;
+ w->frame = Qnil;
+ w->mini = 0;
w->next = w->prev = w->hchild = w->vchild = w->parent = Qnil;
XSETFASTINT (w->left_col, 0);
XSETFASTINT (w->top_line, 0);
@@ -3287,7 +3287,7 @@
w->buffer = Qnil;
w->start = Fmake_marker ();
w->pointm = Fmake_marker ();
- w->force_start = w->optional_new_start = Qnil;
+ w->force_start = w->optional_new_start = 0;
XSETFASTINT (w->hscroll, 0);
XSETFASTINT (w->min_hscroll, 0);
XSETFASTINT (w->use_time, 0);
@@ -3295,17 +3295,18 @@
XSETFASTINT (w->sequence_number, sequence_number);
w->temslot = w->last_modified = w->last_overlay_modified = Qnil;
XSETFASTINT (w->last_point, 0);
- w->last_had_star = w->vertical_scroll_bar = Qnil;
+ w->last_had_star = 0;
+ w->vertical_scroll_bar = Qnil;
w->left_margin_cols = w->right_margin_cols = Qnil;
w->left_fringe_width = w->right_fringe_width = Qnil;
w->fringes_outside_margins = Qnil;
w->scroll_bar_width = Qnil;
w->vertical_scroll_bar_type = Qt;
- w->last_mark_x = w->last_mark_y = Qnil;
XSETFASTINT (w->window_end_pos, 0);
XSETFASTINT (w->window_end_vpos, 0);
- w->window_end_valid = w->update_mode_line = Qnil;
- w->start_at_line_beg = w->display_table = w->dedicated = Qnil;
+ w->window_end_valid = w->display_table = Qnil;
+ w->update_mode_line = w->start_at_line_beg = 0;
+ w->dedicated = Qnil;
w->base_line_number = w->base_line_pos = w->region_showing = Qnil;
w->column_number_displayed = w->redisplay_end_trigger = Qnil;
w->combination_limit = w->window_parameters = Qnil;
@@ -4303,13 +4304,13 @@
spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV);
set_marker_restricted (w->start, make_number (spos),
w->buffer);
- w->start_at_line_beg = Qt;
- w->update_mode_line = Qt;
+ w->start_at_line_beg = 1;
+ w->update_mode_line = 1;
XSETFASTINT (w->last_modified, 0);
XSETFASTINT (w->last_overlay_modified, 0);
/* Set force_start so that redisplay_window will run the
window-scroll-functions. */
- w->force_start = Qt;
+ w->force_start = 1;
return;
}
}
@@ -4449,14 +4450,13 @@
set_marker_restricted (w->start, make_number (pos),
w->buffer);
bytepos = XMARKER (w->start)->bytepos;
- w->start_at_line_beg = ((pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n')
- ? Qt : Qnil);
- w->update_mode_line = Qt;
+ w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
+ w->update_mode_line = 1;
XSETFASTINT (w->last_modified, 0);
XSETFASTINT (w->last_overlay_modified, 0);
/* Set force_start so that redisplay_window will run the
window-scroll-functions. */
- w->force_start = Qt;
+ w->force_start = 1;
}
/* The rest of this function uses current_y in a nonstandard way,
@@ -4649,13 +4649,13 @@
max (0, min (scroll_margin, XINT (w->total_lines) / 4));
set_marker_restricted_both (w->start, w->buffer, pos, pos_byte);
- w->start_at_line_beg = bolp;
- w->update_mode_line = Qt;
+ w->start_at_line_beg = !NILP (bolp);
+ w->update_mode_line = 1;
XSETFASTINT (w->last_modified, 0);
XSETFASTINT (w->last_overlay_modified, 0);
/* Set force_start so that redisplay_window will run
the window-scroll-functions. */
- w->force_start = Qt;
+ w->force_start = 1;
if (!NILP (Vscroll_preserve_screen_position)
&& (whole || !EQ (Vscroll_preserve_screen_position, Qt)))
@@ -5199,12 +5199,10 @@
set_marker_both (w->start, w->buffer, charpos, bytepos);
w->window_end_valid = Qnil;
- w->optional_new_start = Qt;
+ w->optional_new_start = 1;
- if (bytepos == BEGV_BYTE || FETCH_BYTE (bytepos - 1) == '\n')
- w->start_at_line_beg = Qt;
- else
- w->start_at_line_beg = Qnil;
+ w->start_at_line_beg = (bytepos == BEGV_BYTE ||
+ FETCH_BYTE (bytepos - 1) == '\n');
set_buffer_internal (obuf);
return Qnil;
@@ -5255,8 +5253,8 @@
int height = window_internal_height (w);
Fvertical_motion (make_number (- (height / 2)), window);
set_marker_both (w->start, w->buffer, PT, PT_BYTE);
- w->start_at_line_beg = Fbolp ();
- w->force_start = Qt;
+ w->start_at_line_beg = !NILP (Fbolp ());
+ w->force_start = 1;
}
else
Fgoto_char (w->start);
@@ -5605,7 +5603,7 @@
/* If saved buffer is alive, install it. */
{
w->buffer = p->buffer;
- w->start_at_line_beg = p->start_at_line_beg;
+ w->start_at_line_beg = !NILP (p->start_at_line_beg);
set_marker_restricted (w->start, p->start, w->buffer);
set_marker_restricted (w->pointm, p->pointm, w->buffer);
Fset_marker (BVAR (XBUFFER (w->buffer), mark),
@@ -5630,7 +5628,7 @@
set_marker_restricted_both (w->pointm, w->buffer,
BUF_PT (XBUFFER (w->buffer)),
BUF_PT_BYTE (XBUFFER (w->buffer)));
- w->start_at_line_beg = Qt;
+ w->start_at_line_beg = 1;
}
else if (STRINGP (auto_buffer_name =
Fwindow_parameter (window, Qauto_buffer_name))
@@ -5639,7 +5637,7 @@
{
set_marker_restricted (w->start, make_number (0), w->buffer);
set_marker_restricted (w->pointm, make_number (0), w->buffer);
- w->start_at_line_beg = Qt;
+ w->start_at_line_beg = 1;
}
else
/* Window has no live buffer, get one. */
@@ -5653,7 +5651,7 @@
range. */
set_marker_restricted (w->start, make_number (0), w->buffer);
set_marker_restricted (w->pointm, make_number (0), w->buffer);
- w->start_at_line_beg = Qt;
+ w->start_at_line_beg = 1;
if (!NILP (w->dedicated))
/* Record this window as dead. */
dead_windows = Fcons (window, dead_windows);
@@ -5954,7 +5952,7 @@
= !NILP (Vwindow_point_insertion_type);
p->start = Fcopy_marker (w->start, Qnil);
- p->start_at_line_beg = w->start_at_line_beg;
+ p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil;
tem = BVAR (XBUFFER (w->buffer), mark);
p->mark = Fcopy_marker (tem, Qnil);
=== modified file 'src/window.h'
--- src/window.h 2012-03-12 06:34:32 +0000
+++ src/window.h 2012-05-23 03:43:50 +0000
@@ -94,9 +94,6 @@
/* The frame this window is on. */
Lisp_Object frame;
- /* t if this window is a minibuffer window. */
- Lisp_Object mini_p;
-
/* Following (to right or down) and preceding (to left or up) child
at same level of tree. */
Lisp_Object next, prev;
@@ -144,15 +141,6 @@
each one can have its own value of point. */
Lisp_Object pointm;
- /* Non-nil means next redisplay must use the value of start
- set up for it in advance. Set by scrolling commands. */
- Lisp_Object force_start;
- /* Non-nil means we have explicitly changed the value of start,
- but that the next redisplay is not obliged to use the new value.
- This is used in Fdelete_other_windows to force a call to
- Vwindow_scroll_functions; also by Frecenter with argument. */
- Lisp_Object optional_new_start;
-
/* Number of columns display within the window is scrolled to the left. */
Lisp_Object hscroll;
/* Minimum hscroll for automatic hscrolling. This is the value
@@ -176,9 +164,6 @@
Lisp_Object last_overlay_modified;
/* Value of point at that time. */
Lisp_Object last_point;
- /* Non-nil if the buffer was "modified" when the window
- was last updated. */
- Lisp_Object last_had_star;
/* This window's vertical scroll bar. This field is only for use
by the window-system-dependent code which implements the
@@ -206,11 +191,6 @@
no scroll bar. A value of t means use frame value. */
Lisp_Object vertical_scroll_bar_type;
- /* Frame coords of mark as of last time display completed */
- /* May be nil if mark does not exist or was not on frame */
- Lisp_Object last_mark_x;
- Lisp_Object last_mark_y;
-
/* Z - the buffer position of the last glyph in the current matrix
of W. Only valid if WINDOW_END_VALID is not nil. */
Lisp_Object window_end_pos;
@@ -223,18 +203,13 @@
did not get onto the frame. */
Lisp_Object window_end_valid;
- /* Non-nil means must regenerate mode line of this window */
- Lisp_Object update_mode_line;
-
- /* Non-nil means current value of `start'
- was the beginning of a line when it was chosen. */
- Lisp_Object start_at_line_beg;
-
/* Display-table to use for displaying chars in this window.
Nil means use the buffer's own display-table. */
Lisp_Object display_table;
- /* Non-nil means window is marked as dedicated. */
+ /* Non-nil usually means window is marked as dedicated.
+ Note Lisp code may set this to something beyond Qnil
+ and Qt, so bitfield can't be used here. */
Lisp_Object dedicated;
/* Line number and position of a line somewhere above the top of the
@@ -302,6 +277,30 @@
/* This is handy for undrawing the cursor. */
int phys_cursor_ascent, phys_cursor_height;
+ /* Non-zero if this window is a minibuffer window. */
+ unsigned mini : 1;
+
+ /* Non-zero means must regenerate mode line of this window */
+ unsigned update_mode_line : 1;
+
+ /* Non-nil if the buffer was "modified" when the window
+ was last updated. */
+ unsigned last_had_star : 1;
+
+ /* Non-zero means current value of `start'
+ was the beginning of a line when it was chosen. */
+ unsigned start_at_line_beg : 1;
+
+ /* Non-zero means next redisplay must use the value of start
+ set up for it in advance. Set by scrolling commands. */
+ unsigned force_start : 1;
+
+ /* Non-zero means we have explicitly changed the value of start,
+ but that the next redisplay is not obliged to use the new value.
+ This is used in Fdelete_other_windows to force a call to
+ Vwindow_scroll_functions; also by Frecenter with argument. */
+ unsigned optional_new_start : 1;
+
/* Non-zero means the cursor is currently displayed. This can be
set to zero by functions overpainting the cursor image. */
unsigned phys_cursor_on_p : 1;
@@ -337,7 +336,7 @@
/* 1 if W is a minibuffer window. */
-#define MINI_WINDOW_P(W) (!NILP ((W)->mini_p))
+#define MINI_WINDOW_P(W) ((W)->mini)
/* General window layout:
=== modified file 'src/xdisp.c'
--- src/xdisp.c 2012-05-14 11:59:28 +0000
+++ src/xdisp.c 2012-05-23 04:26:46 +0000
@@ -11152,7 +11152,7 @@
|| update_mode_lines
|| ((BUF_SAVE_MODIFF (XBUFFER (w->buffer))
< BUF_MODIFF (XBUFFER (w->buffer)))
- != !NILP (w->last_had_star))
+ != w->last_had_star)
|| ((!NILP (Vtransient_mark_mode)
&& !NILP (BVAR (XBUFFER (w->buffer), mark_active)))
!= !NILP (w->region_showing)))
@@ -11204,11 +11204,11 @@
else
/* On a terminal screen, the menu bar is an ordinary screen
line, and this makes it get updated. */
- w->update_mode_line = Qt;
+ w->update_mode_line = 1;
#else /* ! (USE_X_TOOLKIT || HAVE_NTGUI || HAVE_NS || USE_GTK) */
/* In the non-toolkit version, the menu bar is an ordinary screen
line, and this makes it get updated. */
- w->update_mode_line = Qt;
+ w->update_mode_line = 1;
#endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI || HAVE_NS || USE_GTK) */
unbind_to (count, Qnil);
@@ -11346,11 +11346,11 @@
the rest of the redisplay algorithm is about the same as
windows_or_buffers_changed anyway. */
if (windows_or_buffers_changed
- || !NILP (w->update_mode_line)
+ || w->update_mode_line
|| update_mode_lines
|| ((BUF_SAVE_MODIFF (XBUFFER (w->buffer))
< BUF_MODIFF (XBUFFER (w->buffer)))
- != !NILP (w->last_had_star))
+ != w->last_had_star)
|| ((!NILP (Vtransient_mark_mode)
&& !NILP (BVAR (XBUFFER (w->buffer), mark_active)))
!= !NILP (w->region_showing)))
@@ -11401,7 +11401,7 @@
BLOCK_INPUT;
f->tool_bar_items = new_tool_bar;
f->n_tool_bar_items = new_n_tool_bar;
- w->update_mode_line = Qt;
+ w->update_mode_line = 1;
UNBLOCK_INPUT;
}
@@ -12950,9 +12950,9 @@
update_mode_lines++;
/* Detect case that we need to write or remove a star in the mode line. */
- if ((SAVE_MODIFF < MODIFF) != !NILP (w->last_had_star))
+ if ((SAVE_MODIFF < MODIFF) != w->last_had_star)
{
- w->update_mode_line = Qt;
+ w->update_mode_line = 1;
if (buffer_shared > 1)
update_mode_lines++;
}
@@ -12969,7 +12969,7 @@
&& XFASTINT (w->last_modified) >= MODIFF
&& XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
&& (XFASTINT (w->column_number_displayed) != current_column ()))
- w->update_mode_line = Qt;
+ w->update_mode_line = 1;
unbind_to (count1, Qnil);
@@ -13072,7 +13072,7 @@
tlendpos = this_line_end_pos;
if (!consider_all_windows_p
&& CHARPOS (tlbufpos) > 0
- && NILP (w->update_mode_line)
+ && !w->update_mode_line
&& !current_buffer->clip_changed
&& !current_buffer->prevent_redisplay_optimizations_p
&& FRAME_VISIBLE_P (XFRAME (w->frame))
@@ -13080,8 +13080,8 @@
/* Make sure recorded data applies to current buffer, etc. */
&& this_line_buffer == current_buffer
&& current_buffer == XBUFFER (w->buffer)
- && NILP (w->force_start)
- && NILP (w->optional_new_start)
+ && !w->force_start
+ && !w->optional_new_start
/* Point must be on the line that we have info recorded about. */
&& PT >= CHARPOS (tlbufpos)
&& PT <= Z - CHARPOS (tlendpos)
@@ -13616,7 +13616,7 @@
w->last_overlay_modified
= make_number (accurate_p ? BUF_OVERLAY_MODIFF (b) : 0);
w->last_had_star
- = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b) ? Qt : Qnil;
+ = BUF_MODIFF (b) > BUF_SAVE_MODIFF (b);
if (accurate_p)
{
@@ -13645,7 +13645,7 @@
if (accurate_p)
{
w->window_end_valid = w->buffer;
- w->update_mode_line = Qnil;
+ w->update_mode_line = 0;
}
}
@@ -15274,7 +15274,7 @@
reconsider_clip_changes (w, buffer);
/* Has the mode line to be updated? */
- update_mode_line = (!NILP (w->update_mode_line)
+ update_mode_line = (w->update_mode_line
|| update_mode_lines
|| buffer->clip_changed
|| buffer->prevent_redisplay_optimizations_p);
@@ -15446,32 +15446,31 @@
/* If someone specified a new starting point but did not insist,
check whether it can be used. */
- if (!NILP (w->optional_new_start)
+ if (w->optional_new_start
&& CHARPOS (startp) >= BEGV
&& CHARPOS (startp) <= ZV)
{
- w->optional_new_start = Qnil;
+ w->optional_new_start = 0;
start_display (&it, w, startp);
move_it_to (&it, PT, 0, it.last_visible_y, -1,
MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
if (IT_CHARPOS (it) == PT)
- w->force_start = Qt;
+ w->force_start = 1;
/* IT may overshoot PT if text at PT is invisible. */
else if (IT_CHARPOS (it) > PT && CHARPOS (startp) <= PT)
- w->force_start = Qt;
+ w->force_start = 1;
}
force_start:
/* Handle case where place to start displaying has been specified,
unless the specified location is outside the accessible range. */
- if (!NILP (w->force_start)
- || w->frozen_window_start_p)
+ if (w->force_start || w->frozen_window_start_p)
{
/* We set this later on if we have to adjust point. */
int new_vpos = -1;
- w->force_start = Qnil;
+ w->force_start = 0;
w->vscroll = 0;
w->window_end_valid = Qnil;
@@ -15490,7 +15489,7 @@
|| ! NILP (Vwindow_scroll_functions))
{
update_mode_line = 1;
- w->update_mode_line = Qt;
+ w->update_mode_line = 1;
startp = run_window_scroll_functions (window, startp);
}
@@ -15508,7 +15507,7 @@
the scroll margin (bug#148) -- cyd */
if (!try_window (window, startp, 0))
{
- w->force_start = Qt;
+ w->force_start = 1;
clear_glyph_matrix (w->desired_matrix);
goto need_larger_matrices;
}
@@ -15587,7 +15586,7 @@
}
/* If current starting point was originally the beginning of a line
but no longer is, find a new starting point. */
- else if (!NILP (w->start_at_line_beg)
+ else if (w->start_at_line_beg
&& !(CHARPOS (startp) <= BEGV
|| FETCH_BYTE (BYTEPOS (startp) - 1) == '\n'))
{
@@ -15634,7 +15633,7 @@
new window start, since that would change the position under
the mouse, resulting in an unwanted mouse-movement rather
than a simple mouse-click. */
- if (NILP (w->start_at_line_beg)
+ if (!w->start_at_line_beg
&& NILP (do_mouse_tracking)
&& CHARPOS (startp) > BEGV
&& CHARPOS (startp) > BEG + beg_unchanged
@@ -15654,7 +15653,7 @@
See bug#9324. */
&& pos_visible_p (w, PT, &d1, &d2, &d3, &d4, &d5, &d6))
{
- w->force_start = Qt;
+ w->force_start = 1;
SET_TEXT_POS_FROM_MARKER (startp, w->start);
goto force_start;
}
@@ -15715,7 +15714,7 @@
if (!update_mode_line)
{
update_mode_line = 1;
- w->update_mode_line = Qt;
+ w->update_mode_line = 1;
}
/* Try to scroll by specified few lines. */
@@ -15970,9 +15969,8 @@
done:
SET_TEXT_POS_FROM_MARKER (startp, w->start);
- w->start_at_line_beg = ((CHARPOS (startp) == BEGV
- || FETCH_BYTE (BYTEPOS (startp) - 1) == '\n')
- ? Qt : Qnil);
+ w->start_at_line_beg = (CHARPOS (startp) == BEGV
+ || FETCH_BYTE (BYTEPOS (startp) - 1) == '\n');
/* Display the mode line, if we must. */
if ((update_mode_line
@@ -16189,7 +16187,7 @@
/* If bottom moved off end of frame, change mode line percentage. */
if (XFASTINT (w->window_end_pos) <= 0
&& Z != IT_CHARPOS (it))
- w->update_mode_line = Qt;
+ w->update_mode_line = 1;
/* Set window_end_pos to the offset of the last character displayed
on the window from the end of current_buffer. Set
=== modified file 'src/xfns.c'
--- src/xfns.c 2012-05-19 21:46:43 +0000
+++ src/xfns.c 2012-05-23 03:50:16 +0000
@@ -1215,7 +1215,7 @@
FRAME_EXTERNAL_MENU_BAR (f) = 1;
if (FRAME_X_P (f) && f->output_data.x->menubar_widget == 0)
/* Make sure next redisplay shows the menu bar. */
- XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
+ XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = 1;
}
else
{
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal: 'struct window' cleanup
2012-05-23 4:49 ` Dmitry Antipov
@ 2012-05-23 14:23 ` Stefan Monnier
2012-06-01 3:46 ` Dmitry Antipov
0 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2012-05-23 14:23 UTC (permalink / raw
To: Dmitry Antipov; +Cc: emacs-devel
> === modified file 'src/ChangeLog'
> --- src/ChangeLog 2012-05-22 18:31:19 +0000
> +++ src/ChangeLog 2012-05-23 04:38:27 +0000
> @@ -1,3 +1,38 @@
> +2012-05-23 Dmitry Antipov <dmantipov@yandex.ru>
> +
> + For a 'struct window', replace some Lisp_Object fields to
> + bitfields where appropriate, remove unused fields.
> + * window.h (struct window): remove unused 'last_mark_x' and
> + 'last_mark_y' fields.
> + * window.h (struct window): rename 'mini_p' field to 'mini',
> + change it's type from Lisp_Object to bitfield.
> + * window.h (struct window): change type of 'force_start',
> + 'optional_new_start', 'last_had_star', 'update_mode_line'
> + and 'start_at_line_beg' fields from Lisp_Object to bitfield.
Please capitalize your sentences. And you can merge those three:
For a 'struct window', replace some Lisp_Object fields to
bitfields where appropriate, remove unused fields.
* window.h (struct window): Remove unused 'last_mark_x' and
'last_mark_y' fields. Rename 'mini_p' field to 'mini',
change it's type from Lisp_Object to bitfield.
Change type of 'force_start', 'optional_new_start',
'last_had_star', 'update_mode_line' and 'start_at_line_beg'
fields from Lisp_Object to bitfield.
> + * fileio.c (Finsert_file_contents): adjusted for a new
> + type of 'start_at_line_beg'.
> + * frame.c (make_frame, make_minibuffer_frame): adjusted for
> + a new type of 'mini'.
> + * keyboard.c (command_loop_1): adjusted for a new type
> + of 'force_start'.
> + * window.c (Fset_window_start, window_loop)
> + (Fdelete_other_windows_internal, set_window_buffer)
> + (Fforce_window_update, make_window, window_scroll_pixel_based)
> + (window_scroll_line_based, Frecenter, Fmove_to_window_line)
> + (Fset_window_configuration, save_window_save): adjusted for
> + a type changes in 'struct window'.
> + * xdisp.c (update_menu_bar, update_tool_bar): adjusted for
> + a new type of 'last_had_star' and 'update_mode_line'.
> + * xdisp.c (redisplay_internal): adjusted for a new type
> + of 'update_mode_line', 'force_start' and 'optional_new_start'.
> + * xdisp.c (mark_window_display_accurate_1): adjusted for
> + a new type of 'last_had_star' and 'update_mode_line'.
> + * xdisp.c (redisplay_window): adjusted for
> + a type changes in 'struct window'.
> + * xdisp.c (try_window): adjusted for a new type of 'update_mode_line'.
> + * xfns.c (x_set_menu_bar_lines): adjusted for a new type
> + of 'update_mode_line'.
All these can be summarized by "Adjust users accordingly" in the
"* window.h (struct window):" entry.
The rest of the patch looks ready for installation. IOW, please install
it, and thank you,
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal: 'struct window' cleanup
2012-05-23 14:23 ` Stefan Monnier
@ 2012-06-01 3:46 ` Dmitry Antipov
2012-06-01 17:29 ` Stefan Monnier
0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Antipov @ 2012-06-01 3:46 UTC (permalink / raw
To: Stefan Monnier; +Cc: emacs-devel
On 05/23/2012 06:23 PM, Stefan Monnier wrote:
> The rest of the patch looks ready for installation. IOW, please install
> it, and thank you,
It should be installed as 108441.
Dmitry
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal: 'struct window' cleanup
2012-06-01 3:46 ` Dmitry Antipov
@ 2012-06-01 17:29 ` Stefan Monnier
0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2012-06-01 17:29 UTC (permalink / raw
To: Dmitry Antipov; +Cc: emacs-devel
> It should be installed as 108441.
Thank you Dmitry,
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-06-01 17:29 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-21 14:25 Proposal: 'struct window' cleanup Dmitry Antipov
2012-05-21 14:37 ` Davis Herring
2012-05-22 3:30 ` Stefan Monnier
2012-05-22 7:08 ` Dmitry Antipov
2012-05-22 7:40 ` Thien-Thi Nguyen
2012-05-22 12:39 ` Stefan Monnier
2012-05-23 4:49 ` Dmitry Antipov
2012-05-23 14:23 ` Stefan Monnier
2012-06-01 3:46 ` Dmitry Antipov
2012-06-01 17:29 ` Stefan Monnier
2012-05-22 16:15 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.