diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2013-03-28 18:04:49 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2013-03-28 18:04:49 +0400 |
commit | e74aeda863cd6896e06e92586f87b45d63d67d15 (patch) | |
tree | b6a57d0d39f085274c0953623f7d2924f4813db4 /src | |
parent | 9d42d31f24040706fe965e7c586b640471b12861 (diff) | |
download | emacs-e74aeda863cd6896e06e92586f87b45d63d67d15.tar.gz |
* window.h (struct window): Replace hchild, vchild and buffer slots
with the only contents slot. This is possible because each valid
window may have either the child window (in vertical or horizontal
combination) or buffer to display (for the leaf window). Using that,
a lof of operations to traverse and/or change window hierarchies may
be simplified. New member horizontal is used to distinguish between
horizontal and vertical combinations of internal windows.
(WINDOW_LEAF_P, WINDOW_HORIZONTAL_COMBINATION_P)
(WINDOW_VERTICAL_COMBINATION_P): New macros.
(WINDOW_VALID_P, WINDOW_LIVE_P): Adjust to match struct window changes.
* window.c (wset_hchild, wset_vchild): Remove. Adjust all users.
Use contents slot, not buffer, where appropriate.
(wset_combination): New function.
(wset_buffer): Add eassert.
(Fframe_first_window): Simplify the loop reaching first window.
(Fwindow_buffer): Use WINDOW_LEAF_P.
(Fwindow_top_child): Use WINDOW_VERTICAL_COMBINATION_P.
(Fwindow_left_child): Use WINDOW_HORIZONTAL_COMBINATION_P.
(unshow_buffer): Convert initial debugging check to eassert.
(replace_window, recombine_windows, Fdelete_other_windows_internal)
(make_parent_window, window_resize_check, window_resize_apply)
(resize_frame_windows, Fsplit_window_internal, Fdelete_window_internal)
(Fset_window_configuration, delete_all_child_windows, save_window_save):
Adjust to match struct window changes.
(window_loop): Check for broken markers in CHECK_ALL_WINDOWS.
(mark_window_cursors_off, count_windows, get_leaf_windows)
(foreach_window_1): Simplify the loop.
* alloc.c (mark_object): Do not check for the leaf window because
internal windows has no glyph matrices anyway.
* dispnew.c (clear_window_matrices, showing_window_margins_p)
(allocate_matrices_for_window_redisplay, fake_current_matrices)
(allocate_matrices_for_frame_redisplay, free_window_matrices)
(build_frame_matrix_from_window_tree, mirror_make_current)
(frame_row_to_window, mirror_line_dance, check_window_matrix_pointers)
(update_window_tree, set_window_update_flags): Simplify the loop.
(sync_window_with_frame_matrix_rows): Enforce live window.
Use contents slot, not buffer, where appropriate.
* frame.c (set_menu_bar_lines_1): Use WINDOW_VERTICAL_COMBINATION_P
and WINDOW_HORIZONTAL_COMBINATION_P.
(make_frame_visible_1): Simplify the loop.
Use contents slot, not buffer, where appropriate.
* xdisp.c (hscroll_window_tree, mark_window_display_accurate)
(redisplay_windows, redisplay_mode_lines, update_cursor_in_window_tree)
(expose_window_tree): Likewise.
Use contents slot, not buffer, where appropriate.
* textprop.c (get_char_property_and_overlay): Add CHECK_LIVE_WINDOW
to avoid deleted windows. Use contents slot instead of buffer.
* buffer.c, dispextern.h, editfns.c, fileio.c, font.c, fringe.c:
* indent.c, insdel.c, keyboard.c, keymap.c, minibuf.c, msdos.c:
* nsfns.m, nsmenu.m, nsterm.m, print.c, w32fns.c, w32menu.c, xfaces.c:
* xfns.c, xmenu.c: Use contents slot, not buffer, where appropriate.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 54 | ||||
-rw-r--r-- | src/alloc.c | 5 | ||||
-rw-r--r-- | src/buffer.c | 22 | ||||
-rw-r--r-- | src/dispextern.h | 31 | ||||
-rw-r--r-- | src/dispnew.c | 113 | ||||
-rw-r--r-- | src/editfns.c | 6 | ||||
-rw-r--r-- | src/fileio.c | 4 | ||||
-rw-r--r-- | src/font.c | 2 | ||||
-rw-r--r-- | src/frame.c | 40 | ||||
-rw-r--r-- | src/fringe.c | 12 | ||||
-rw-r--r-- | src/indent.c | 12 | ||||
-rw-r--r-- | src/insdel.c | 2 | ||||
-rw-r--r-- | src/keyboard.c | 24 | ||||
-rw-r--r-- | src/keymap.c | 6 | ||||
-rw-r--r-- | src/minibuf.c | 4 | ||||
-rw-r--r-- | src/msdos.c | 6 | ||||
-rw-r--r-- | src/nsfns.m | 2 | ||||
-rw-r--r-- | src/nsmenu.m | 2 | ||||
-rw-r--r-- | src/nsterm.m | 2 | ||||
-rw-r--r-- | src/print.c | 4 | ||||
-rw-r--r-- | src/textprop.c | 3 | ||||
-rw-r--r-- | src/w32fns.c | 2 | ||||
-rw-r--r-- | src/w32menu.c | 2 | ||||
-rw-r--r-- | src/window.c | 486 | ||||
-rw-r--r-- | src/window.h | 58 | ||||
-rw-r--r-- | src/xdisp.c | 191 | ||||
-rw-r--r-- | src/xfaces.c | 12 | ||||
-rw-r--r-- | src/xfns.c | 2 | ||||
-rw-r--r-- | src/xmenu.c | 2 |
29 files changed, 526 insertions, 585 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index baa40ffd237..77338e6c46f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,57 @@ +2013-03-28 Dmitry Antipov <dmantipov@yandex.ru> + + * window.h (struct window): Replace hchild, vchild and buffer slots + with the only contents slot. This is possible because each valid + window may have either the child window (in vertical or horizontal + combination) or buffer to display (for the leaf window). Using that, + a lof of operations to traverse and/or change window hierarchies may + be simplified. New member horizontal is used to distinguish between + horizontal and vertical combinations of internal windows. + (WINDOW_LEAF_P, WINDOW_HORIZONTAL_COMBINATION_P) + (WINDOW_VERTICAL_COMBINATION_P): New macros. + (WINDOW_VALID_P, WINDOW_LIVE_P): Adjust to match struct window changes. + * window.c (wset_hchild, wset_vchild): Remove. Adjust all users. + Use contents slot, not buffer, where appropriate. + (wset_combination): New function. + (wset_buffer): Add eassert. + (Fframe_first_window): Simplify the loop reaching first window. + (Fwindow_buffer): Use WINDOW_LEAF_P. + (Fwindow_top_child): Use WINDOW_VERTICAL_COMBINATION_P. + (Fwindow_left_child): Use WINDOW_HORIZONTAL_COMBINATION_P. + (unshow_buffer): Convert initial debugging check to eassert. + (replace_window, recombine_windows, Fdelete_other_windows_internal) + (make_parent_window, window_resize_check, window_resize_apply) + (resize_frame_windows, Fsplit_window_internal, Fdelete_window_internal) + (Fset_window_configuration, delete_all_child_windows, save_window_save): + Adjust to match struct window changes. + (window_loop): Check for broken markers in CHECK_ALL_WINDOWS. + (mark_window_cursors_off, count_windows, get_leaf_windows) + (foreach_window_1): Simplify the loop. + * alloc.c (mark_object): Do not check for the leaf window because + internal windows has no glyph matrices anyway. + * dispnew.c (clear_window_matrices, showing_window_margins_p) + (allocate_matrices_for_window_redisplay, fake_current_matrices) + (allocate_matrices_for_frame_redisplay, free_window_matrices) + (build_frame_matrix_from_window_tree, mirror_make_current) + (frame_row_to_window, mirror_line_dance, check_window_matrix_pointers) + (update_window_tree, set_window_update_flags): Simplify the loop. + (sync_window_with_frame_matrix_rows): Enforce live window. + Use contents slot, not buffer, where appropriate. + * frame.c (set_menu_bar_lines_1): Use WINDOW_VERTICAL_COMBINATION_P + and WINDOW_HORIZONTAL_COMBINATION_P. + (make_frame_visible_1): Simplify the loop. + Use contents slot, not buffer, where appropriate. + * xdisp.c (hscroll_window_tree, mark_window_display_accurate) + (redisplay_windows, redisplay_mode_lines, update_cursor_in_window_tree) + (expose_window_tree): Likewise. + Use contents slot, not buffer, where appropriate. + * textprop.c (get_char_property_and_overlay): Add CHECK_LIVE_WINDOW + to avoid deleted windows. Use contents slot instead of buffer. + * buffer.c, dispextern.h, editfns.c, fileio.c, font.c, fringe.c: + * indent.c, insdel.c, keyboard.c, keymap.c, minibuf.c, msdos.c: + * nsfns.m, nsmenu.m, nsterm.m, print.c, w32fns.c, w32menu.c, xfaces.c: + * xfns.c, xmenu.c: Use contents slot, not buffer, where appropriate. + 2013-03-28 Eli Zaretskii <eliz@gnu.org> * w32fns.c (w32_wnd_proc) [ENABLE_CHECKING]: Add code to help diff --git a/src/alloc.c b/src/alloc.c index ea833c62b94..0a7950273f6 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5810,14 +5810,13 @@ mark_object (Lisp_Object arg) case PVEC_WINDOW: { struct window *w = (struct window *) ptr; - bool leaf = NILP (w->hchild) && NILP (w->vchild); mark_vectorlike (ptr); - /* Mark glyphs for leaf windows. Marking window + /* Mark glyph matrices, if any. Marking window matrices is sufficient because frame matrices use the same glyph memory. */ - if (leaf && w->current_matrix) + if (w->current_matrix) { mark_glyph_matrix (w->current_matrix); mark_glyph_matrix (w->desired_matrix); diff --git a/src/buffer.c b/src/buffer.c index d02bcf7eceb..8728b418812 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1769,7 +1769,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) since anything can happen within do_yes_or_no_p. */ /* Don't kill the minibuffer now current. */ - if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) + if (EQ (buffer, XWINDOW (minibuf_window)->contents)) return Qnil; /* When we kill an ordinary buffer which shares it's buffer text @@ -1820,7 +1820,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) /* If the buffer now current is shown in the minibuffer and our buffer is the sole other buffer give up. */ XSETBUFFER (tem, current_buffer); - if (EQ (tem, XWINDOW (minibuf_window)->buffer) + if (EQ (tem, XWINDOW (minibuf_window)->contents) && EQ (buffer, Fother_buffer (buffer, Qnil, Qnil))) return Qnil; @@ -2406,19 +2406,19 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, { ws = Fcons (w, ws); if (MARKERP (XWINDOW (w)->pointm) - && (EQ (XWINDOW (w)->buffer, buf1) - || EQ (XWINDOW (w)->buffer, buf2))) + && (EQ (XWINDOW (w)->contents, buf1) + || EQ (XWINDOW (w)->contents, buf2))) Fset_marker (XWINDOW (w)->pointm, make_number - (BUF_BEGV (XBUFFER (XWINDOW (w)->buffer))), - XWINDOW (w)->buffer); + (BUF_BEGV (XBUFFER (XWINDOW (w)->contents))), + XWINDOW (w)->contents); if (MARKERP (XWINDOW (w)->start) - && (EQ (XWINDOW (w)->buffer, buf1) - || EQ (XWINDOW (w)->buffer, buf2))) + && (EQ (XWINDOW (w)->contents, buf1) + || EQ (XWINDOW (w)->contents, buf2))) Fset_marker (XWINDOW (w)->start, make_number - (XBUFFER (XWINDOW (w)->buffer)->last_window_start), - XWINDOW (w)->buffer); + (XBUFFER (XWINDOW (w)->contents)->last_window_start), + XWINDOW (w)->contents); w = Fnext_window (w, Qt, Qt); } } @@ -3901,7 +3901,7 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end) if (buffer_window_count (buf) > 0) { /* ... it's visible in other window than selected, */ - if (buf != XBUFFER (XWINDOW (selected_window)->buffer)) + if (buf != XBUFFER (XWINDOW (selected_window)->contents)) windows_or_buffers_changed = 1; /* ... or if we modify an overlay at the end of the buffer and so we cannot be sure that window end is still valid. */ diff --git a/src/dispextern.h b/src/dispextern.h index 1f269902435..cb2e944d1cc 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -1412,25 +1412,24 @@ struct glyph_string /* Value is non-zero if window W wants a mode line. */ -#define WINDOW_WANTS_MODELINE_P(W) \ - (!MINI_WINDOW_P ((W)) \ - && !(W)->pseudo_window_p \ - && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \ - && BUFFERP (W->buffer) \ - && !NILP (BVAR (XBUFFER (W->buffer), mode_line_format)) \ - && WINDOW_TOTAL_LINES (W) > 1) +#define WINDOW_WANTS_MODELINE_P(W) \ + (!MINI_WINDOW_P ((W)) \ + && !(W)->pseudo_window_p \ + && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \ + && BUFFERP (W->contents) \ + && !NILP (BVAR (XBUFFER (W->contents), mode_line_format)) \ + && WINDOW_TOTAL_LINES (W) > 1) /* Value is true if window W wants a header line. */ -#define WINDOW_WANTS_HEADER_LINE_P(W) \ - (!MINI_WINDOW_P ((W)) \ - && !(W)->pseudo_window_p \ - && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \ - && BUFFERP (W->buffer) \ - && !NILP (BVAR (XBUFFER (W->buffer), header_line_format)) \ - && WINDOW_TOTAL_LINES (W) > 1 \ - + !NILP (BVAR (XBUFFER (W->buffer), mode_line_format))) - +#define WINDOW_WANTS_HEADER_LINE_P(W) \ + (!MINI_WINDOW_P ((W)) \ + && !(W)->pseudo_window_p \ + && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \ + && BUFFERP (W->contents) \ + && !NILP (BVAR (XBUFFER (W->contents), header_line_format)) \ + && WINDOW_TOTAL_LINES (W) > 1 \ + + !NILP (BVAR (XBUFFER (W->contents), mode_line_format))) /* Return proper value to be used as baseline offset of font that has ASCENT and DESCENT to draw characters by the font at the vertical diff --git a/src/dispnew.c b/src/dispnew.c index 852598d2dc8..836c0f91020 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -223,9 +223,9 @@ add_window_display_history (struct window *w, const char *msg, bool paused_p) "%"pMu": window %p (`%s')%s\n%s", history_tick++, w, - ((BUFFERP (w->buffer) - && STRINGP (BVAR (XBUFFER (w->buffer), name))) - ? SSDATA (BVAR (XBUFFER (w->buffer), name)) + ((BUFFERP (w->contents) + && STRINGP (BVAR (XBUFFER (w->contents), name))) + ? SSDATA (BVAR (XBUFFER (w->contents), name)) : "???"), paused_p ? " ***paused***" : "", msg); @@ -842,16 +842,8 @@ clear_window_matrices (struct window *w, bool desired_p) { while (w) { - if (!NILP (w->hchild)) - { - eassert (WINDOWP (w->hchild)); - clear_window_matrices (XWINDOW (w->hchild), desired_p); - } - else if (!NILP (w->vchild)) - { - eassert (WINDOWP (w->vchild)); - clear_window_matrices (XWINDOW (w->vchild), desired_p); - } + if (WINDOWP (w->contents)) + clear_window_matrices (XWINDOW (w->contents), desired_p); else { if (desired_p) @@ -1472,7 +1464,7 @@ check_matrix_invariants (struct window *w) struct glyph_row *row = matrix->rows; struct glyph_row *last_text_row = NULL; struct buffer *saved = current_buffer; - struct buffer *buffer = XBUFFER (w->buffer); + struct buffer *buffer = XBUFFER (w->contents); int c; /* This can sometimes happen for a fresh window. */ @@ -1636,7 +1628,7 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y, vertically below other windows. */ in_horz_combination_p = (!NILP (XWINDOW (window)->parent) - && !NILP (XWINDOW (XWINDOW (window)->parent)->hchild)); + && WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (XWINDOW (window)->parent))); /* For WINDOW and all windows on the same level. */ do @@ -1645,12 +1637,8 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y, /* Get the dimension of the window sub-matrix for W, depending on whether this is a combination or a leaf window. */ - if (!NILP (w->hchild)) - dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y, - dim_only_p, - window_change_flags); - else if (!NILP (w->vchild)) - dim = allocate_matrices_for_frame_redisplay (w->vchild, x, y, + if (WINDOWP (w->contents)) + dim = allocate_matrices_for_frame_redisplay (w->contents, x, y, dim_only_p, window_change_flags); else @@ -1792,10 +1780,8 @@ allocate_matrices_for_window_redisplay (struct window *w) { while (w) { - if (!NILP (w->vchild)) - allocate_matrices_for_window_redisplay (XWINDOW (w->vchild)); - else if (!NILP (w->hchild)) - allocate_matrices_for_window_redisplay (XWINDOW (w->hchild)); + if (WINDOWP (w->contents)) + allocate_matrices_for_window_redisplay (XWINDOW (w->contents)); else { /* W is a leaf window. */ @@ -1867,18 +1853,12 @@ showing_window_margins_p (struct window *w) { while (w) { - if (!NILP (w->hchild)) + if (WINDOWP (w->contents)) { - if (showing_window_margins_p (XWINDOW (w->hchild))) + if (showing_window_margins_p (XWINDOW (w->contents))) return 1; } - else if (!NILP (w->vchild)) - { - if (showing_window_margins_p (XWINDOW (w->vchild))) - return 1; - } - else if (!NILP (w->left_margin_cols) - || !NILP (w->right_margin_cols)) + else if (!NILP (w->left_margin_cols) || !NILP (w->right_margin_cols)) return 1; w = NILP (w->next) ? 0 : XWINDOW (w->next); @@ -1899,10 +1879,8 @@ fake_current_matrices (Lisp_Object window) { w = XWINDOW (window); - if (!NILP (w->hchild)) - fake_current_matrices (w->hchild); - else if (!NILP (w->vchild)) - fake_current_matrices (w->vchild); + if (WINDOWP (w->contents)) + fake_current_matrices (w->contents); else { int i; @@ -2242,10 +2220,8 @@ free_window_matrices (struct window *w) { while (w) { - if (!NILP (w->hchild)) - free_window_matrices (XWINDOW (w->hchild)); - else if (!NILP (w->vchild)) - free_window_matrices (XWINDOW (w->vchild)); + if (WINDOWP (w->contents)) + free_window_matrices (XWINDOW (w->contents)); else { /* This is a leaf window. Free its memory and reset fields @@ -2378,10 +2354,8 @@ build_frame_matrix_from_window_tree (struct glyph_matrix *matrix, struct window { while (w) { - if (!NILP (w->hchild)) - build_frame_matrix_from_window_tree (matrix, XWINDOW (w->hchild)); - else if (!NILP (w->vchild)) - build_frame_matrix_from_window_tree (matrix, XWINDOW (w->vchild)); + if (WINDOWP (w->contents)) + build_frame_matrix_from_window_tree (matrix, XWINDOW (w->contents)); else build_frame_matrix_from_leaf_window (matrix, w); @@ -2645,10 +2619,8 @@ mirror_make_current (struct window *w, int frame_row) { while (w) { - if (!NILP (w->hchild)) - mirror_make_current (XWINDOW (w->hchild), frame_row); - else if (!NILP (w->vchild)) - mirror_make_current (XWINDOW (w->vchild), frame_row); + if (WINDOWP (w->contents)) + mirror_make_current (XWINDOW (w->contents), frame_row); else { /* Row relative to window W. Don't use FRAME_TO_WINDOW_VPOS @@ -2744,8 +2716,8 @@ sync_window_with_frame_matrix_rows (struct window *w) struct glyph_row *window_row, *window_row_end, *frame_row; int left, right, x, width; - /* Preconditions: W must be a leaf window on a tty frame. */ - eassert (NILP (w->hchild) && NILP (w->vchild)); + /* Preconditions: W must be a live window on a tty frame. */ + eassert (BUFFERP (w->contents)); eassert (!FRAME_WINDOW_P (f)); left = margin_glyphs_to_reserve (w, 1, w->left_margin_cols); @@ -2781,10 +2753,8 @@ frame_row_to_window (struct window *w, int row) while (w && !found) { - if (!NILP (w->hchild)) - found = frame_row_to_window (XWINDOW (w->hchild), row); - else if (!NILP (w->vchild)) - found = frame_row_to_window (XWINDOW (w->vchild), row); + if (WINDOWP (w->contents)) + found = frame_row_to_window (XWINDOW (w->contents), row); else if (row >= WINDOW_TOP_EDGE_LINE (w) && row < WINDOW_BOTTOM_EDGE_LINE (w)) found = w; @@ -2812,11 +2782,8 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy { while (w) { - if (!NILP (w->hchild)) - mirror_line_dance (XWINDOW (w->hchild), unchanged_at_top, - nlines, copy_from, retained_p); - else if (!NILP (w->vchild)) - mirror_line_dance (XWINDOW (w->vchild), unchanged_at_top, + if (WINDOWP (w->contents)) + mirror_line_dance (XWINDOW (w->contents), unchanged_at_top, nlines, copy_from, retained_p); else { @@ -2925,10 +2892,8 @@ check_window_matrix_pointers (struct window *w) { while (w) { - if (!NILP (w->hchild)) - check_window_matrix_pointers (XWINDOW (w->hchild)); - else if (!NILP (w->vchild)) - check_window_matrix_pointers (XWINDOW (w->vchild)); + if (WINDOWP (w->contents)) + check_window_matrix_pointers (XWINDOW (w->contents)); else { struct frame *f = XFRAME (w->frame); @@ -3194,10 +3159,8 @@ update_window_tree (struct window *w, bool force_p) while (w && !paused_p) { - if (!NILP (w->hchild)) - paused_p |= update_window_tree (XWINDOW (w->hchild), force_p); - else if (!NILP (w->vchild)) - paused_p |= update_window_tree (XWINDOW (w->vchild), force_p); + if (WINDOWP (w->contents)) + paused_p |= update_window_tree (XWINDOW (w->contents), force_p); else if (w->must_be_updated_p) paused_p |= update_window (w, force_p); @@ -3975,10 +3938,8 @@ set_window_update_flags (struct window *w, bool on_p) { while (w) { - if (!NILP (w->hchild)) - set_window_update_flags (XWINDOW (w->hchild), on_p); - else if (!NILP (w->vchild)) - set_window_update_flags (XWINDOW (w->vchild), on_p); + if (WINDOWP (w->contents)) + set_window_update_flags (XWINDOW (w->contents), on_p); else w->must_be_updated_p = on_p; @@ -5125,7 +5086,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p /* We used to set current_buffer directly here, but that does the wrong thing with `face-remapping-alist' (bug#2044). */ - Fset_buffer (w->buffer); + Fset_buffer (w->contents); itdata = bidi_shelve_cache (); SET_TEXT_POS_FROM_MARKER (startp, w->start); CHARPOS (startp) = min (ZV, max (BEGV, CHARPOS (startp))); @@ -5171,7 +5132,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p *dx = x0 + it.first_visible_x - it.current_x; *dy = *y - it.current_y; - string = w->buffer; + string = w->contents; if (STRINGP (it.string)) string = it.string; *pos = it.current; @@ -5189,7 +5150,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p if (STRINGP (it.string)) BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos)); else - BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->buffer), + BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->contents), CHARPOS (pos->pos)); } diff --git a/src/editfns.c b/src/editfns.c index 0ab7c143c99..d0cca6f3d7b 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -373,7 +373,7 @@ get_pos_property (Lisp_Object position, register Lisp_Object prop, Lisp_Object o if (NILP (object)) XSETBUFFER (object, current_buffer); else if (WINDOWP (object)) - object = XWINDOW (object)->buffer; + object = XWINDOW (object)->contents; if (!BUFFERP (object)) /* pos-property only makes sense in buffers right now, since strings @@ -846,7 +846,7 @@ save_excursion_save (void) ? Fcopy_marker (BVAR (current_buffer, mark), Qnil) : Qnil), /* Selected window if current buffer is shown in it, nil otherwise. */ - (EQ (XWINDOW (selected_window)->buffer, Fcurrent_buffer ()) + (EQ (XWINDOW (selected_window)->contents, Fcurrent_buffer ()) ? selected_window : Qnil), BVAR (current_buffer, mark_active)); } @@ -915,7 +915,7 @@ save_excursion_restore (Lisp_Object info) tem = XSAVE_OBJECT (info, 2); if (WINDOWP (tem) && !EQ (tem, selected_window) - && (tem1 = XWINDOW (tem)->buffer, + && (tem1 = XWINDOW (tem)->contents, (/* Window is live... */ BUFFERP (tem1) /* ...and it shows the current buffer. */ diff --git a/src/fileio.c b/src/fileio.c index 1919768d98a..d7c476172cb 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3958,7 +3958,7 @@ by calling `format-decode', which see. */) /* If display currently starts at beginning of line, keep it that way. */ - if (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer) + if (XBUFFER (XWINDOW (selected_window)->contents) == current_buffer) XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ()); replace_handled = 1; @@ -4108,7 +4108,7 @@ by calling `format-decode', which see. */) /* If display currently starts at beginning of line, keep it that way. */ - if (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer) + if (XBUFFER (XWINDOW (selected_window)->contents) == current_buffer) XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ()); /* Replace the chars that we need to replace, diff --git a/src/font.c b/src/font.c index 357f8483b14..d66620bffbc 100644 --- a/src/font.c +++ b/src/font.c @@ -4761,7 +4761,7 @@ character at index specified by POSITION. */) if (NILP (string)) { - if (XBUFFER (w->buffer) != current_buffer) + if (XBUFFER (w->contents) != current_buffer) error ("Specified window is not displaying the current buffer."); CHECK_NUMBER_COERCE_MARKER (position); if (! (BEGV <= XINT (position) && XINT (position) < ZV)) diff --git a/src/frame.c b/src/frame.c index cea39144cef..970e40b5175 100644 --- a/src/frame.c +++ b/src/frame.c @@ -159,15 +159,15 @@ set_menu_bar_lines_1 (Lisp_Object window, int n) w->total_lines -= n; /* Handle just the top child in a vertical split. */ - if (!NILP (w->vchild)) - set_menu_bar_lines_1 (w->vchild, n); - - /* Adjust all children in a horizontal split. */ - for (window = w->hchild; !NILP (window); window = w->next) - { - w = XWINDOW (window); - set_menu_bar_lines_1 (window, n); - } + if (WINDOW_VERTICAL_COMBINATION_P (w)) + set_menu_bar_lines_1 (w->contents, n); + else if (WINDOW_HORIZONTAL_COMBINATION_P (w)) + /* Adjust all children in a horizontal split. */ + for (window = w->contents; !NILP (window); window = w->next) + { + w = XWINDOW (window); + set_menu_bar_lines_1 (window, n); + } } void @@ -421,7 +421,7 @@ make_frame_without_minibuffer (register Lisp_Object mini_window, KBOARD *kb, Lis /* Make the chosen minibuffer window display the proper minibuffer, unless it is already showing a minibuffer. */ - if (NILP (Fmemq (XWINDOW (mini_window)->buffer, Vminibuffer_list))) + if (NILP (Fmemq (XWINDOW (mini_window)->contents, Vminibuffer_list))) /* Use set_window_buffer instead of Fset_window_buffer (see discussion of bug#11984, bug#12025, bug#12026). */ set_window_buffer (mini_window, @@ -1189,7 +1189,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) /* Use set_window_buffer instead of Fset_window_buffer (see discussion of bug#11984, bug#12025, bug#12026). */ set_window_buffer (sf->minibuffer_window, - XWINDOW (minibuf_window)->buffer, 0, 0); + XWINDOW (minibuf_window)->contents, 0, 0); minibuf_window = sf->minibuffer_window; /* If the dying minibuffer window was selected, @@ -1593,17 +1593,13 @@ make_frame_visible_1 (Lisp_Object window) { struct window *w; - for (;!NILP (window); window = w->next) + for (; !NILP (window); window = w->next) { w = XWINDOW (window); - - if (!NILP (w->buffer)) - bset_display_time (XBUFFER (w->buffer), Fcurrent_time ()); - - if (!NILP (w->vchild)) - make_frame_visible_1 (w->vchild); - if (!NILP (w->hchild)) - make_frame_visible_1 (w->hchild); + if (WINDOWP (w->contents)) + make_frame_visible_1 (w->contents); + else + bset_display_time (XBUFFER (w->contents), Fcurrent_time ()); } } @@ -1634,7 +1630,7 @@ displayed in the terminal. */) /* Use set_window_buffer instead of Fset_window_buffer (see discussion of bug#11984, bug#12025, bug#12026). */ set_window_buffer (sf->minibuffer_window, - XWINDOW (minibuf_window)->buffer, 0, 0); + XWINDOW (minibuf_window)->contents, 0, 0); minibuf_window = sf->minibuffer_window; } @@ -1665,7 +1661,7 @@ If omitted, FRAME defaults to the currently selected frame. */) /* Use set_window_buffer instead of Fset_window_buffer (see discussion of bug#11984, bug#12025, bug#12026). */ set_window_buffer (sf->minibuffer_window, - XWINDOW (minibuf_window)->buffer, 0, 0); + XWINDOW (minibuf_window)->contents, 0, 0); minibuf_window = sf->minibuffer_window; } diff --git a/src/fringe.c b/src/fringe.c index fa6f889ba69..f728cd6d5ff 100644 --- a/src/fringe.c +++ b/src/fringe.c @@ -699,7 +699,7 @@ get_logical_cursor_bitmap (struct window *w, Lisp_Object cursor) { Lisp_Object cmap, bm = Qnil; - if ((cmap = BVAR (XBUFFER (w->buffer), fringe_cursor_alist)), !NILP (cmap)) + if ((cmap = BVAR (XBUFFER (w->contents), fringe_cursor_alist)), !NILP (cmap)) { bm = Fassq (cursor, cmap); if (CONSP (bm)) @@ -736,7 +736,7 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in If partial, lookup partial bitmap in default value if not found here. If not partial, or no partial spec is present, use non-partial bitmap. */ - if ((cmap = BVAR (XBUFFER (w->buffer), fringe_indicator_alist)), !NILP (cmap)) + if ((cmap = BVAR (XBUFFER (w->contents), fringe_indicator_alist)), !NILP (cmap)) { bm1 = Fassq (bitmap, cmap); if (CONSP (bm1)) @@ -963,7 +963,7 @@ update_window_fringes (struct window *w, int keep_current_p) return 0; if (!MINI_WINDOW_P (w) - && (ind = BVAR (XBUFFER (w->buffer), indicate_buffer_boundaries), !NILP (ind))) + && (ind = BVAR (XBUFFER (w->contents), indicate_buffer_boundaries), !NILP (ind))) { if (EQ (ind, Qleft) || EQ (ind, Qright)) boundary_top = boundary_bot = arrow_top = arrow_bot = ind; @@ -1004,7 +1004,7 @@ update_window_fringes (struct window *w, int keep_current_p) { if (top_ind_rn < 0 && row->visible_height > 0) { - if (MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer)) + if (MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->contents)) && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row)) row->indicate_bob_p = !NILP (boundary_top); else @@ -1014,7 +1014,7 @@ update_window_fringes (struct window *w, int keep_current_p) if (bot_ind_rn < 0) { - if (MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer)) + if (MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->contents)) && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P (w, row)) row->indicate_eob_p = !NILP (boundary_bot), bot_ind_rn = rn; else if (y + row->height >= yb) @@ -1024,7 +1024,7 @@ update_window_fringes (struct window *w, int keep_current_p) } } - empty_pos = BVAR (XBUFFER (w->buffer), indicate_empty_lines); + empty_pos = BVAR (XBUFFER (w->contents), indicate_empty_lines); if (!NILP (empty_pos) && !EQ (empty_pos, Qright)) empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft; diff --git a/src/indent.c b/src/indent.c index b662b3bbaa0..1493e1d5ee5 100644 --- a/src/indent.c +++ b/src/indent.c @@ -254,7 +254,7 @@ skip_invisible (ptrdiff_t pos, ptrdiff_t *next_boundary_p, ptrdiff_t to, Lisp_Ob the next property change */ prop = Fget_char_property (position, Qinvisible, (!NILP (window) - && EQ (XWINDOW (window)->buffer, buffer)) + && EQ (XWINDOW (window)->contents, buffer)) ? window : buffer); inv_p = TEXT_PROP_MEANS_INVISIBLE (prop); /* When counting columns (window == nil), don't skip over ellipsis text. */ @@ -1826,7 +1826,7 @@ vmotion (register ptrdiff_t from, register ptrdiff_t from_byte, /* If the window contains this buffer, use it for getting text properties. Otherwise use the current buffer as arg for doing that. */ - if (EQ (w->buffer, Fcurrent_buffer ())) + if (EQ (w->contents, Fcurrent_buffer ())) text_prop_object = window; else text_prop_object = Fcurrent_buffer (); @@ -1979,14 +1979,14 @@ whether or not it is currently displayed in some window. */) old_buffer = Qnil; GCPRO1 (old_buffer); - if (XBUFFER (w->buffer) != current_buffer) + if (XBUFFER (w->contents) != current_buffer) { /* Set the window's buffer temporarily to the current buffer. */ - old_buffer = w->buffer; + old_buffer = w->contents; old_charpos = marker_position (w->pointm); old_bytepos = marker_byte_position (w->pointm); wset_buffer (w, Fcurrent_buffer ()); - set_marker_both (w->pointm, w->buffer, + set_marker_both (w->pointm, w->contents, BUF_PT (current_buffer), BUF_PT_BYTE (current_buffer)); } @@ -2139,7 +2139,7 @@ whether or not it is currently displayed in some window. */) if (BUFFERP (old_buffer)) { wset_buffer (w, old_buffer); - set_marker_both (w->pointm, w->buffer, + set_marker_both (w->pointm, w->contents, old_charpos, old_bytepos); } diff --git a/src/insdel.c b/src/insdel.c index a60fed0c32e..246ba80f290 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -1798,7 +1798,7 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end, /* If we're modifying the buffer other than shown in a selected window, let redisplay consider other windows if this buffer is visible. */ - if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer + if (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer && buffer_window_count (current_buffer)) ++windows_or_buffers_changed; diff --git a/src/keyboard.c b/src/keyboard.c index d9187cd96b4..5b2eb8c7cd2 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -833,7 +833,7 @@ This function is called by the editor initialization to begin editing. */) update_mode_lines = 1; if (command_loop_level - && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer)) + && current_buffer != XBUFFER (XWINDOW (selected_window)->contents)) buffer = Fcurrent_buffer (); else buffer = Qnil; @@ -1395,7 +1395,7 @@ command_loop_1 (void) Fkill_emacs (Qnil); /* Make sure the current window's buffer is selected. */ - set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); + set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents)); /* Display any malloc warning that just came out. Use while because displaying one warning can cause another. */ @@ -1461,7 +1461,7 @@ command_loop_1 (void) /* A filter may have run while we were reading the input. */ if (! FRAME_LIVE_P (XFRAME (selected_frame))) Fkill_emacs (Qnil); - set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); + set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents)); ++num_input_keys; @@ -1492,7 +1492,7 @@ command_loop_1 (void) { struct buffer *b; XWINDOW (selected_window)->force_start = 0; - b = XBUFFER (XWINDOW (selected_window)->buffer); + b = XBUFFER (XWINDOW (selected_window)->contents); BUF_BEG_UNCHANGED (b) = BUF_END_UNCHANGED (b) = 0; } @@ -5142,7 +5142,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y, if (STRINGP (string)) string_info = Fcons (string, make_number (charpos)); textpos = (w == XWINDOW (selected_window) - && current_buffer == XBUFFER (w->buffer)) + && current_buffer == XBUFFER (w->contents)) ? PT : marker_position (w->pointm); xret = wx; @@ -9145,9 +9145,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, { if (! FRAME_LIVE_P (XFRAME (selected_frame))) Fkill_emacs (Qnil); - if (XBUFFER (XWINDOW (selected_window)->buffer) + if (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer) - Fset_buffer (XWINDOW (selected_window)->buffer); + Fset_buffer (XWINDOW (selected_window)->contents); } goto replay_sequence; @@ -9195,9 +9195,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, special-event-map, ...) might have switched the current buffer or the selected window from under us in the mean time. */ if (fix_current_buffer - && (XBUFFER (XWINDOW (selected_window)->buffer) + && (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer)) - Fset_buffer (XWINDOW (selected_window)->buffer); + Fset_buffer (XWINDOW (selected_window)->contents); current_binding = active_maps (first_event); } @@ -9246,8 +9246,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, not the current buffer. If we're at the beginning of a key sequence, switch buffers. */ if (WINDOWP (window) - && BUFFERP (XWINDOW (window)->buffer) - && XBUFFER (XWINDOW (window)->buffer) != current_buffer) + && BUFFERP (XWINDOW (window)->contents) + && XBUFFER (XWINDOW (window)->contents) != current_buffer) { ASET (raw_keybuf, raw_keybuf_count, key); raw_keybuf_count++; @@ -9268,7 +9268,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, if (! FRAME_LIVE_P (XFRAME (selected_frame))) Fkill_emacs (Qnil); - set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); + set_buffer_internal (XBUFFER (XWINDOW (window)->contents)); goto replay_sequence; } } diff --git a/src/keymap.c b/src/keymap.c index 110c8f43729..e759214fa33 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -1556,8 +1556,8 @@ like in the respective argument of `key-binding'. */) window = POSN_WINDOW (position); if (WINDOWP (window) - && BUFFERP (XWINDOW (window)->buffer) - && XBUFFER (XWINDOW (window)->buffer) != current_buffer) + && BUFFERP (XWINDOW (window)->contents) + && XBUFFER (XWINDOW (window)->contents) != current_buffer) { /* Arrange to go back to the original buffer once we're done processing the key sequence. We don't use @@ -1567,7 +1567,7 @@ like in the respective argument of `key-binding'. */) things the same. */ record_unwind_current_buffer (); - set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); + set_buffer_internal (XBUFFER (XWINDOW (window)->contents)); } } diff --git a/src/minibuf.c b/src/minibuf.c index 56459353714..75e54789912 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -114,7 +114,7 @@ choose_minibuf_frame (void) /* Under X, we come here with minibuf_window being the minibuffer window of the unused termcap window created in init_window_once. That window doesn't have a buffer. */ - buffer = XWINDOW (minibuf_window)->buffer; + buffer = XWINDOW (minibuf_window)->contents; if (BUFFERP (buffer)) /* Use set_window_buffer instead of Fset_window_buffer (see discussion of bug#11984, bug#12025, bug#12026). */ @@ -844,7 +844,7 @@ read_minibuf_unwind (Lisp_Object data) window = minibuf_window; /* To keep things predictable, in case it matters, let's be in the minibuffer when we reset the relevant variables. */ - Fset_buffer (XWINDOW (window)->buffer); + Fset_buffer (XWINDOW (window)->contents); /* Restore prompt, etc, from outer minibuffer level. */ minibuf_prompt = Fcar (minibuf_save_list); diff --git a/src/msdos.c b/src/msdos.c index ee47109d5f2..695cca60728 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -1261,7 +1261,7 @@ IT_update_begin (struct frame *f) /* If the mouse highlight is in the window that was deleted (e.g., if it was popped by completion), clear highlight unconditionally. */ - if (NILP (w->buffer)) + if (NILP (w->contents)) hlinfo->mouse_face_window = Qnil; else { @@ -1271,7 +1271,7 @@ IT_update_begin (struct frame *f) break; } - if (NILP (w->buffer) || i < w->desired_matrix->nrows) + if (NILP (w->contents) || i < w->desired_matrix->nrows) clear_mouse_face (hlinfo); } } @@ -1321,7 +1321,7 @@ IT_frame_up_to_date (struct frame *f) new_cursor = frame_desired_cursor; else { - struct buffer *b = XBUFFER (sw->buffer); + struct buffer *b = XBUFFER (sw->contents); if (EQ (BVAR (b,cursor_type), Qt)) new_cursor = frame_desired_cursor; diff --git a/src/nsfns.m b/src/nsfns.m index 9c3051a8c6a..17f27910ca2 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -619,7 +619,7 @@ ns_set_name_as_filename (struct frame *f) { NSView *view; Lisp_Object name, filename; - Lisp_Object buf = XWINDOW (f->selected_window)->buffer; + Lisp_Object buf = XWINDOW (f->selected_window)->contents; const char *title; NSAutoreleasePool *pool; struct gcpro gcpro1; diff --git a/src/nsmenu.m b/src/nsmenu.m index 22ff4dd0b53..b764d3f5951 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -191,7 +191,7 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu) = alloca (previous_menu_items_used * sizeof *previous_items); /* lisp preliminaries */ - buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; + buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents; specbind (Qinhibit_quit, Qt); specbind (Qdebug_on_next_call, Qnil); record_unwind_save_match_data (); diff --git a/src/nsterm.m b/src/nsterm.m index 40e506eab27..c75167d7531 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6532,7 +6532,7 @@ not_in_argv (NSString *arg) { Lisp_Object str = Qnil; struct frame *f = SELECTED_FRAME (); - struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->buffer); + struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->contents); if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) return NSAccessibilityTextFieldRole; diff --git a/src/print.c b/src/print.c index ce10d6295e6..811ab5011ce 100644 --- a/src/print.c +++ b/src/print.c @@ -1769,10 +1769,10 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) strout ("#<window ", -1, -1, printcharfun); len = sprintf (buf, "%p", XWINDOW (obj)); strout (buf, len, len, printcharfun); - if (!NILP (XWINDOW (obj)->buffer)) + if (BUFFERP (XWINDOW (obj)->contents)) { strout (" on ", -1, -1, printcharfun); - print_string (BVAR (XBUFFER (XWINDOW (obj)->buffer), name), + print_string (BVAR (XBUFFER (XWINDOW (obj)->contents), name), printcharfun); } PRINTCHAR ('>'); diff --git a/src/textprop.c b/src/textprop.c index 2b454485370..cc364d5a38c 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -597,8 +597,9 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop, if (WINDOWP (object)) { + CHECK_LIVE_WINDOW (object); w = XWINDOW (object); - object = w->buffer; + object = w->contents; } if (BUFFERP (object)) { diff --git a/src/w32fns.c b/src/w32fns.c index bb640ffcb8c..bd54e990efc 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -5816,7 +5816,7 @@ Text larger than the specified size is clipped. */) /* Display the tooltip text in a temporary buffer. */ old_buffer = current_buffer; - set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); + set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->contents)); bset_truncate_lines (current_buffer, Qnil); clear_glyph_matrix (w->desired_matrix); clear_glyph_matrix (w->current_matrix); diff --git a/src/w32menu.c b/src/w32menu.c index 03904cf20b8..60ef6d2cfb5 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -396,7 +396,7 @@ set_frame_menubar (FRAME_PTR f, bool first_time, bool deep_p) if (! menubar_widget) previous_menu_items_used = 0; - buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; + buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents; specbind (Qinhibit_quit, Qt); /* Don't let the debugger step into this code because it is not reentrant. */ diff --git a/src/window.c b/src/window.c index 1784b38ba6d..b66111a5605 100644 --- a/src/window.c +++ b/src/window.c @@ -147,11 +147,6 @@ wset_display_table (struct window *w, Lisp_Object val) w->display_table = val; } static void -wset_hchild (struct window *w, Lisp_Object val) -{ - w->hchild = val; -} -static void wset_left_fringe_width (struct window *w, Lisp_Object val) { w->left_fringe_width = val; @@ -217,11 +212,6 @@ wset_temslot (struct window *w, Lisp_Object val) w->temslot = val; } static void -wset_vchild (struct window *w, Lisp_Object val) -{ - w->vchild = val; -} -static void wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val) { w->vertical_scroll_bar_type = val; @@ -231,6 +221,18 @@ wset_window_parameters (struct window *w, Lisp_Object val) { w->window_parameters = val; } +static void +wset_combination (struct window *w, bool horflag, Lisp_Object val) +{ + /* Since leaf windows never becomes non-leaf, there should + be no buffer and markers in start and pointm fields of W. */ + eassert (!BUFFERP (w->contents) && NILP (w->start) && NILP (w->pointm)); + w->contents = val; + /* When an internal window is deleted and VAL is nil, HORFLAG + is meaningless. */ + if (!NILP (val)) + w->horizontal = horflag; +} struct window * decode_live_window (register Lisp_Object window) @@ -275,9 +277,9 @@ static void adjust_window_count (struct window *w, int arg) { eassert (eabs (arg) == 1); - if (BUFFERP (w->buffer)) + if (BUFFERP (w->contents)) { - struct buffer *b = XBUFFER (w->buffer); + struct buffer *b = XBUFFER (w->contents); if (b->base_buffer) b = b->base_buffer; @@ -296,7 +298,11 @@ void wset_buffer (struct window *w, Lisp_Object val) { adjust_window_count (w, -1); - w->buffer = val; + if (BUFFERP (val)) + /* Make sure that we do not assign the buffer + to an internal window. */ + eassert (MARKERP (w->start) && MARKERP (w->pointm)); + w->contents = val; adjust_window_count (w, 1); } @@ -394,15 +400,8 @@ the first window of that frame. */) window = XFRAME (frame_or_window)->root_window; } - while (NILP (XWINDOW (window)->buffer)) - { - if (! NILP (XWINDOW (window)->hchild)) - window = XWINDOW (window)->hchild; - else if (! NILP (XWINDOW (window)->vchild)) - window = XWINDOW (window)->vchild; - else - emacs_abort (); - } + while (WINDOWP (XWINDOW (window)->contents)) + window = XWINDOW (window)->contents; return window; } @@ -489,11 +488,11 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) if (NILP (norecord)) { w->use_time = ++window_select_count; - record_buffer (w->buffer); + record_buffer (w->contents); } /* Make the selected window's buffer current. */ - Fset_buffer (w->buffer); + Fset_buffer (w->contents); if (EQ (window, selected_window) && !inhibit_point_swap) return window; @@ -516,7 +515,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) select_window_1 (window, inhibit_point_swap); - bset_last_selected_window (XBUFFER (w->buffer), window); + bset_last_selected_window (XBUFFER (w->contents), window); windows_or_buffers_changed++; return window; } @@ -533,10 +532,10 @@ select_window_1 (Lisp_Object window, bool inhibit_point_swap) if (!inhibit_point_swap) { struct window *ow = XWINDOW (selected_window); - if (! NILP (ow->buffer)) - set_marker_both (ow->pointm, ow->buffer, - BUF_PT (XBUFFER (ow->buffer)), - BUF_PT_BYTE (XBUFFER (ow->buffer))); + if (BUFFERP (ow->contents)) + set_marker_both (ow->pointm, ow->contents, + BUF_PT (XBUFFER (ow->contents)), + BUF_PT_BYTE (XBUFFER (ow->contents))); } selected_window = window; @@ -581,7 +580,8 @@ If WINDOW is omitted or nil, it defaults to the selected window. Return nil for an internal window or a deleted window. */) (Lisp_Object window) { - return decode_any_window (window)->buffer; + struct window *w = decode_any_window (window); + return WINDOW_LEAF_P (w) ? w->contents : Qnil; } DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, @@ -601,7 +601,8 @@ Return nil if WINDOW is an internal window whose children form a horizontal combination. */) (Lisp_Object window) { - return decode_valid_window (window)->vchild; + struct window *w = decode_valid_window (window); + return WINDOW_VERTICAL_COMBINATION_P (w) ? w->contents : Qnil; } DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 0, 1, 0, @@ -612,7 +613,8 @@ Return nil if WINDOW is an internal window whose children form a vertical combination. */) (Lisp_Object window) { - return decode_valid_window (window)->hchild; + struct window *w = decode_valid_window (window); + return WINDOW_HORIZONTAL_COMBINATION_P (w) ? w->contents : Qnil; } DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0, @@ -645,9 +647,9 @@ WINDOW are never \(re-)combined with WINDOW's siblings. */) CHECK_VALID_WINDOW (window); w = XWINDOW (window); - if (!NILP (w->buffer)) + if (WINDOW_LEAF_P (w)) error ("Combination limit is meaningful for internal windows only"); - return XWINDOW (window)->combination_limit; + return w->combination_limit; } DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, @@ -663,7 +665,7 @@ future use. */) CHECK_VALID_WINDOW (window); w = XWINDOW (window); - if (!NILP (w->buffer)) + if (WINDOW_LEAF_P (w)) error ("Combination limit is meaningful for internal windows only"); wset_combination_limit (w, limit); return limit; @@ -860,7 +862,7 @@ set_window_hscroll (struct window *w, EMACS_INT hscroll) /* Prevent redisplay shortcuts when changing the hscroll. */ if (w->hscroll != new_hscroll) - XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; + XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; w->hscroll = new_hscroll; return make_number (new_hscroll); @@ -1441,7 +1443,7 @@ correct to return the top-level value of `point', outside of any register struct window *w = decode_live_window (window); if (w == XWINDOW (selected_window)) - return make_number (BUF_PT (XBUFFER (w->buffer))); + return make_number (BUF_PT (XBUFFER (w->contents))); else return Fmarker_position (w->pointm); } @@ -1483,7 +1485,7 @@ if it isn't already recorded. */) Lisp_Object buf; struct buffer *b; - buf = w->buffer; + buf = w->contents; CHECK_BUFFER (buf); b = XBUFFER (buf); @@ -1546,7 +1548,7 @@ Return POS. */) if (w == XWINDOW (selected_window)) { - if (XBUFFER (w->buffer) == current_buffer) + if (XBUFFER (w->contents) == current_buffer) Fgoto_char (pos); else { @@ -1554,14 +1556,14 @@ Return POS. */) /* ... but here we want to catch type error before buffer change. */ CHECK_NUMBER_COERCE_MARKER (pos); - set_buffer_internal (XBUFFER (w->buffer)); + set_buffer_internal (XBUFFER (w->contents)); Fgoto_char (pos); set_buffer_internal (old_buffer); } } else { - set_marker_restricted (w->pointm, pos, w->buffer); + set_marker_restricted (w->pointm, pos, w->contents); /* We have to make sure that redisplay updates the window to show the new value of point. */ ++windows_or_buffers_changed; @@ -1579,7 +1581,7 @@ overriding motion of point in order to display at this exact start. */) { register struct window *w = decode_live_window (window); - set_marker_restricted (w->start, pos, w->buffer); + set_marker_restricted (w->start, pos, w->contents); /* This is not right, but much easier than doing what is right. */ w->start_at_line_beg = 0; if (NILP (noforce)) @@ -1623,7 +1625,7 @@ display row, and VPOS is the row number (0-based) containing POS. */) int x, y; w = decode_live_window (window); - buf = XBUFFER (w->buffer); + buf = XBUFFER (w->contents); SET_TEXT_POS_FROM_MARKER (top, w->start); if (EQ (pos, Qt)) @@ -1692,8 +1694,8 @@ Return nil if window display is not up-to-date. In that case, use if (noninteractive || w->pseudo_window_p) return Qnil; - CHECK_BUFFER (w->buffer); - b = XBUFFER (w->buffer); + CHECK_BUFFER (w->contents); + b = XBUFFER (w->contents); /* Fail if current matrix is not up-to-date. */ if (!w->window_end_valid @@ -1919,9 +1921,9 @@ window_display_table (struct window *w) if (DISP_TABLE_P (w->display_table)) dp = XCHAR_TABLE (w->display_table); - else if (BUFFERP (w->buffer)) + else if (BUFFERP (w->contents)) { - struct buffer *b = XBUFFER (w->buffer); + struct buffer *b = XBUFFER (w->contents); if (DISP_TABLE_P (BVAR (b, display_table))) dp = XCHAR_TABLE (BVAR (b, display_table)); @@ -1946,17 +1948,14 @@ WINDOW must be a live window and defaults to the selected one. */) static void unshow_buffer (register struct window *w) { - Lisp_Object buf; - struct buffer *b; + Lisp_Object buf = w->contents; + struct buffer *b = XBUFFER (buf); - buf = w->buffer; - b = XBUFFER (buf); - if (b != XMARKER (w->pointm)->buffer) - emacs_abort (); + eassert (b == XMARKER (w->pointm)->buffer); #if 0 if (w == XWINDOW (selected_window) - || ! EQ (buf, XWINDOW (selected_window)->buffer)) + || ! EQ (buf, XWINDOW (selected_window)->contents)) /* Do this except when the selected window's buffer is being removed from some other window. */ #endif @@ -1972,14 +1971,14 @@ unshow_buffer (register struct window *w) /* Point in the selected window's buffer is actually stored in that buffer, and the window's pointm isn't used. So don't clobber point in that buffer. */ - if (! EQ (buf, XWINDOW (selected_window)->buffer) + if (! EQ (buf, XWINDOW (selected_window)->contents) /* Don't clobber point in current buffer either (this could be useful in connection with bug#12208). && XBUFFER (buf) != current_buffer */ /* This line helps to fix Horsley's testbug.el bug. */ && !(WINDOWP (BVAR (b, last_selected_window)) && w != XWINDOW (BVAR (b, last_selected_window)) - && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->buffer))) + && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->contents))) temp_set_point_both (b, clip_to_bounds (BUF_BEGV (b), marker_position (w->pointm), @@ -2044,13 +2043,8 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag) tem = o->parent; wset_parent (n, tem); - if (!NILP (tem)) - { - if (EQ (XWINDOW (tem)->vchild, old)) - wset_vchild (XWINDOW (tem), new); - if (EQ (XWINDOW (tem)->hchild, old)) - wset_hchild (XWINDOW (tem), new); - } + if (!NILP (tem) && EQ (XWINDOW (tem)->contents, old)) + wset_combination (XWINDOW (tem), XWINDOW (tem)->horizontal, new); } /* If window WINDOW and its parent window are iso-combined, merge @@ -2069,22 +2063,19 @@ recombine_windows (Lisp_Object window) if (!NILP (parent) && NILP (w->combination_limit)) { p = XWINDOW (parent); - if (((!NILP (p->vchild) && !NILP (w->vchild)) - || (!NILP (p->hchild) && !NILP (w->hchild)))) + if (WINDOWP (p->contents) && WINDOWP (w->contents) + && p->horizontal == w->horizontal) /* WINDOW and PARENT are both either a vertical or a horizontal combination. */ { - horflag = NILP (w->vchild); - child = horflag ? w->hchild : w->vchild; + horflag = WINDOW_HORIZONTAL_COMBINATION_P (w); + child = w->contents; c = XWINDOW (child); /* Splice WINDOW's children into its parent's children and assign new normal sizes. */ if (NILP (w->prev)) - if (horflag) - wset_hchild (p, child); - else - wset_vchild (p, child); + wset_combination (p, horflag, child); else { wset_prev (c, w->prev); @@ -2122,8 +2113,7 @@ recombine_windows (Lisp_Object window) } /* WINDOW can be deleted now. */ - wset_vchild (w, Qnil); - wset_hchild (w, Qnil); + wset_combination (w, 0, Qnil); } } } @@ -2209,7 +2199,7 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf struct frame *f = XFRAME (w->frame); int candidate_p = 1; - if (!BUFFERP (w->buffer)) + if (!BUFFERP (w->contents)) candidate_p = 0; else if (MINI_WINDOW_P (w) && (EQ (minibuf, Qlambda) @@ -2549,7 +2539,7 @@ enum window_loop GET_BUFFER_WINDOW, /* Arg is buffer */ REPLACE_BUFFER_IN_WINDOWS_SAFELY, /* Arg is buffer */ REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */ - CHECK_ALL_WINDOWS + CHECK_ALL_WINDOWS /* Arg is ignored */ }; static Lisp_Object @@ -2613,7 +2603,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame switch (type) { case GET_BUFFER_WINDOW: - if (EQ (w->buffer, obj) + if (EQ (w->contents, obj) /* Don't find any minibuffer window except the one that is currently in use. */ && (MINI_WINDOW_P (w) ? EQ (window, minibuf_window) : 1)) @@ -2637,25 +2627,25 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame case REPLACE_BUFFER_IN_WINDOWS_SAFELY: /* We could simply check whether the buffer shown by window is live, and show another buffer in case it isn't. */ - if (EQ (w->buffer, obj)) + if (EQ (w->contents, obj)) { /* Undedicate WINDOW. */ wset_dedicated (w, Qnil); /* Make WINDOW show the buffer returned by other_buffer_safely, don't run any hooks. */ set_window_buffer - (window, other_buffer_safely (w->buffer), 0, 0); + (window, other_buffer_safely (w->contents), 0, 0); /* If WINDOW is the selected window, make its buffer current. But do so only if the window shows the current buffer (Bug#6454). */ if (EQ (window, selected_window) - && XBUFFER (w->buffer) == current_buffer) - Fset_buffer (w->buffer); + && XBUFFER (w->contents) == current_buffer) + Fset_buffer (w->contents); } break; case REDISPLAY_BUFFER_WINDOWS: - if (EQ (w->buffer, obj)) + if (EQ (w->contents, obj)) { mark_window_display_accurate (window, 0); w->update_mode_line = 1; @@ -2665,11 +2655,20 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame } break; - /* Check for a window that has a killed buffer. */ + /* Check for a leaf window that has a killed buffer + or broken markers. */ case CHECK_ALL_WINDOWS: - if (! NILP (w->buffer) - && !BUFFER_LIVE_P (XBUFFER (w->buffer))) - emacs_abort (); + if (BUFFERP (w->contents)) + { + struct buffer *b = XBUFFER (w->contents); + + if (!BUFFER_LIVE_P (b)) + emacs_abort (); + if (!MARKERP (w->start) || XMARKER (w->start)->buffer != b) + emacs_abort (); + if (!MARKERP (w->pointm) || XMARKER (w->pointm)->buffer != b) + emacs_abort (); + } break; case WINDOW_LOOP_UNUSED: @@ -2786,7 +2785,7 @@ window-start value is reasonable when this function is called. */) else if (MINI_WINDOW_P (w)) /* && top > 0) */ error ("Can't expand minibuffer to full frame"); - if (!NILP (w->buffer)) + if (BUFFERP (w->contents)) { startpos = marker_position (w->start); startbyte = marker_byte_position (w->start); @@ -2858,7 +2857,7 @@ window-start value is reasonable when this function is called. */) FRAME_WINDOW_SIZES_CHANGED (f) = 1; resize_failed = 0; - if (NILP (w->buffer)) + if (!WINDOW_LEAF_P (w)) { /* Resize child windows vertically. */ XSETINT (delta, r->total_lines - w->total_lines); @@ -2917,28 +2916,21 @@ window-start value is reasonable when this function is called. */) sibling = w->next; s = XWINDOW (sibling); wset_prev (s, Qnil); - if (!NILP (XWINDOW (w->parent)->vchild)) - wset_vchild (XWINDOW (w->parent), sibling); - else - wset_hchild (XWINDOW (w->parent), sibling); + wset_combination (XWINDOW (w->parent), + XWINDOW (w->parent)->horizontal, sibling); } /* Delete ROOT and all child windows of ROOT. */ - if (!NILP (r->vchild)) + if (WINDOWP (r->contents)) { - delete_all_child_windows (r->vchild); - wset_vchild (r, Qnil); - } - else if (!NILP (r->hchild)) - { - delete_all_child_windows (r->hchild); - wset_hchild (r, Qnil); + delete_all_child_windows (r->contents); + wset_combination (r, 0, Qnil); } replace_window (root, window, 1); /* This must become SWINDOW anyway ....... */ - if (!NILP (w->buffer) && !resize_failed) + if (BUFFERP (w->contents) && !resize_failed) { /* Try to minimize scrolling, by setting the window start to the point will cause the text at the old window start to be at the @@ -2947,18 +2939,18 @@ window-start value is reasonable when this function is called. */) when the display is not current, due to typeahead). */ new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); if (new_top != top - && startpos >= BUF_BEGV (XBUFFER (w->buffer)) - && startpos <= BUF_ZV (XBUFFER (w->buffer))) + && startpos >= BUF_BEGV (XBUFFER (w->contents)) + && startpos <= BUF_ZV (XBUFFER (w->contents))) { struct position pos; struct buffer *obuf = current_buffer; - Fset_buffer (w->buffer); + Fset_buffer (w->contents); /* This computation used to temporarily move point, but that can have unwanted side effects due to text properties. */ pos = *vmotion (startpos, startbyte, -top, w); - set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); + set_marker_both (w->start, w->contents, pos.bufpos, pos.bytepos); w->window_end_valid = 0; w->start_at_line_beg = (pos.bytepos == BEGV_BYTE || FETCH_BYTE (pos.bytepos - 1) == '\n'); @@ -3158,7 +3150,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, struct window *w = XWINDOW (window); struct buffer *b = XBUFFER (buffer); ptrdiff_t count = SPECPDL_INDEX (); - int samebuf = EQ (buffer, w->buffer); + int samebuf = EQ (buffer, w->contents); wset_buffer (w, buffer); @@ -3277,7 +3269,7 @@ This function runs `window-scroll-functions' before running if (!BUFFER_LIVE_P (XBUFFER (buffer))) error ("Attempt to display deleted buffer"); - tem = w->buffer; + tem = w->contents; if (NILP (tem)) error ("Window is deleted"); else @@ -3330,8 +3322,8 @@ displaying that buffer. */) struct window *w = XWINDOW (object); mark_window_display_accurate (object, 0); w->update_mode_line = 1; - if (BUFFERP (w->buffer)) - XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; + if (BUFFERP (w->contents)) + XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; ++update_mode_lines; return Qt; } @@ -3400,7 +3392,7 @@ temp_output_buffer_show (register Lisp_Object buf) record_unwind_protect (Fset_buffer, prev_buffer); record_unwind_protect (select_window_norecord, prev_window); Fselect_window (window, Qt); - Fset_buffer (w->buffer); + Fset_buffer (w->contents); Frun_hooks (1, &Qtemp_buffer_show_hook); unbind_to (count, Qnil); } @@ -3421,7 +3413,7 @@ make_parent_window (Lisp_Object window, bool horflag) memcpy ((char *) p + sizeof (struct vectorlike_header), (char *) o + sizeof (struct vectorlike_header), word_size * VECSIZE (struct window)); - /* P's buffer slot may change from nil to a buffer. */ + /* P's buffer slot may change from nil to a buffer... */ adjust_window_count (p, 1); XSETWINDOW (parent, p); @@ -3430,12 +3422,11 @@ make_parent_window (Lisp_Object window, bool horflag) wset_next (o, Qnil); wset_prev (o, Qnil); wset_parent (o, parent); - - wset_hchild (p, horflag ? window : Qnil); - wset_vchild (p, horflag ? Qnil : window); + /* ...but now P becomes an internal window. */ wset_start (p, Qnil); wset_pointm (p, Qnil); wset_buffer (p, Qnil); + wset_combination (p, horflag, window); wset_combination_limit (p, Qnil); wset_window_parameters (p, Qnil); } @@ -3524,10 +3515,10 @@ window_resize_check (struct window *w, bool horflag) { struct window *c; - if (!NILP (w->vchild)) + if (WINDOW_VERTICAL_COMBINATION_P (w)) /* W is a vertical combination. */ { - c = XWINDOW (w->vchild); + c = XWINDOW (w->contents); if (horflag) /* All child windows of W must have the same width as W. */ { @@ -3555,10 +3546,10 @@ window_resize_check (struct window *w, bool horflag) return (sum_of_sizes == XINT (w->new_total)); } } - else if (!NILP (w->hchild)) + else if (WINDOW_HORIZONTAL_COMBINATION_P (w)) /* W is a horizontal combination. */ { - c = XWINDOW (w->hchild); + c = XWINDOW (w->contents); if (horflag) /* The sum of the widths of the child windows of W must equal W's width. */ @@ -3625,10 +3616,10 @@ window_resize_apply (struct window *w, bool horflag) pos = w->top_line; } - if (!NILP (w->vchild)) + if (WINDOW_VERTICAL_COMBINATION_P (w)) /* W is a vertical combination. */ { - c = XWINDOW (w->vchild); + c = XWINDOW (w->contents); while (c) { if (horflag) @@ -3641,10 +3632,10 @@ window_resize_apply (struct window *w, bool horflag) c = NILP (c->next) ? 0 : XWINDOW (c->next); } } - else if (!NILP (w->hchild)) + else if (WINDOW_HORIZONTAL_COMBINATION_P (w)) /* W is a horizontal combination. */ { - c = XWINDOW (w->hchild); + c = XWINDOW (w->contents); while (c) { if (horflag) @@ -3727,7 +3718,7 @@ resize_frame_windows (struct frame *f, int size, bool horflag) ? 1 : 0))); r->top_line = FRAME_TOP_MARGIN (f); - if (NILP (r->vchild) && NILP (r->hchild)) + if (WINDOW_LEAF_P (r)) /* For a leaf root window just set the size. */ if (horflag) r->total_cols = new_size; @@ -3842,9 +3833,9 @@ set correctly. See the code of `split-window' for how this is done. */) combination_limit = EQ (Vwindow_combination_limit, Qt) || NILP (o->parent) - || NILP (horflag - ? (XWINDOW (o->parent)->hchild) - : (XWINDOW (o->parent)->vchild)); + || (horflag + ? WINDOW_VERTICAL_COMBINATION_P (XWINDOW (o->parent)) + : WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (o->parent))); /* We need a live reference window to initialize some parameters. */ if (WINDOW_LIVE_P (old)) @@ -3914,17 +3905,12 @@ set correctly. See the code of `split-window' for how this is done. */) n = XWINDOW (new); wset_frame (n, frame); wset_parent (n, o->parent); - wset_vchild (n, Qnil); - wset_hchild (n, Qnil); if (EQ (side, Qabove) || EQ (side, Qleft)) { wset_prev (n, o->prev); if (NILP (n->prev)) - if (horflag) - wset_hchild (p, new); - else - wset_vchild (p, new); + wset_combination (p, horflag, new); else wset_next (XWINDOW (n->prev), new); wset_next (n, old); @@ -3973,7 +3959,7 @@ set correctly. See the code of `split-window' for how this is done. */) adjust_glyphs (f); /* Set buffer of NEW to buffer of reference window. Don't run any hooks. */ - set_window_buffer (new, r->buffer, 0, 1); + set_window_buffer (new, r->contents, 0, 1); unblock_input (); /* Maybe we should run the scroll functions in Elisp (which already @@ -3995,13 +3981,11 @@ Signal an error when WINDOW is the only window on its frame. */) register Lisp_Object parent, sibling, frame, root; struct window *w, *p, *s, *r; struct frame *f; - bool horflag; - int before_sibling = 0; + bool horflag, before_sibling = 0; w = decode_any_window (window); XSETWINDOW (window, w); - if (NILP (w->buffer) - && NILP (w->hchild) && NILP (w->vchild)) + if (NILP (w->contents)) /* It's a no-op to delete an already deleted window. */ return Qnil; @@ -4015,7 +3999,7 @@ Signal an error when WINDOW is the only window on its frame. */) error ("Attempt to delete sole window of parent"); p = XWINDOW (parent); - horflag = NILP (p->vchild); + horflag = WINDOW_HORIZONTAL_COMBINATION_P (p); frame = WINDOW_FRAME (w); f = XFRAME (frame); @@ -4033,10 +4017,7 @@ Signal an error when WINDOW is the only window on its frame. */) sibling = w->next; s = XWINDOW (sibling); wset_prev (s, Qnil); - if (horflag) - wset_hchild (p, sibling); - else - wset_vchild (p, sibling); + wset_combination (p, horflag, sibling); } else /* Get SIBLING above (on the left of) WINDOW. */ @@ -4075,17 +4056,12 @@ Signal an error when WINDOW is the only window on its frame. */) wset_next (w, Qnil); /* Don't delete w->next too. */ free_window_matrices (w); - if (!NILP (w->vchild)) + if (WINDOWP (w->contents)) { - delete_all_child_windows (w->vchild); - wset_vchild (w, Qnil); + delete_all_child_windows (w->contents); + wset_combination (w, 0, Qnil); } - else if (!NILP (w->hchild)) - { - delete_all_child_windows (w->hchild); - wset_hchild (w, Qnil); - } - else if (!NILP (w->buffer)) + else { unshow_buffer (w); unchain_marker (XMARKER (w->pointm)); @@ -4104,8 +4080,7 @@ Signal an error when WINDOW is the only window on its frame. */) wset_normal_cols (s, p->normal_cols); wset_normal_lines (s, p->normal_lines); /* Mark PARENT as deleted. */ - wset_vchild (p, Qnil); - wset_hchild (p, Qnil); + wset_combination (p, 0, Qnil); /* Try to merge SIBLING into its new parent. */ recombine_windows (sibling); } @@ -4153,10 +4128,7 @@ Signal an error when WINDOW is the only window on its frame. */) if (before_sibling) { wset_prev (s, window); - if (horflag) - wset_hchild (p, window); - else - wset_vchild (p, window); + wset_combination (p, horflag, window); } else { @@ -4299,10 +4271,8 @@ mark_window_cursors_off (struct window *w) { while (w) { - if (!NILP (w->hchild)) - mark_window_cursors_off (XWINDOW (w->hchild)); - else if (!NILP (w->vchild)) - mark_window_cursors_off (XWINDOW (w->vchild)); + if (WINDOWP (w->contents)) + mark_window_cursors_off (XWINDOW (w->contents)); else w->phys_cursor_on_p = 0; @@ -4321,8 +4291,7 @@ window_internal_height (struct window *w) if (!MINI_WINDOW_P (w)) { if (!NILP (w->parent) - || !NILP (w->vchild) - || !NILP (w->hchild) + || WINDOWP (w->contents) || !NILP (w->next) || !NILP (w->prev) || WINDOW_WANTS_MODELINE_P (w)) @@ -4461,7 +4430,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) else spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV); set_marker_restricted (w->start, make_number (spos), - w->buffer); + w->contents); w->start_at_line_beg = 1; w->update_mode_line = 1; w->last_modified = 0; @@ -4585,7 +4554,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) /* If control gets here, then we vscrolled. */ - XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; + XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; /* Don't try to change the window start below. */ vscrolled = 1; @@ -4605,7 +4574,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) } /* Set the window start, and set up the window for redisplay. */ - set_marker_restricted_both (w->start, w->buffer, IT_CHARPOS (it), + set_marker_restricted_both (w->start, w->contents, IT_CHARPOS (it), IT_BYTEPOS (it)); bytepos = marker_byte_position (w->start); w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); @@ -4805,7 +4774,7 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) int this_scroll_margin = max (0, min (scroll_margin, w->total_lines / 4)); - set_marker_restricted_both (w->start, w->buffer, pos, pos_byte); + set_marker_restricted_both (w->start, w->contents, pos, pos_byte); w->start_at_line_beg = !NILP (bolp); w->update_mode_line = 1; w->last_modified = 0; @@ -4899,10 +4868,10 @@ scroll_command (Lisp_Object n, int direction) /* If selected window's buffer isn't current, make it current for the moment. But don't screw up if window_scroll gets an error. */ - if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) + if (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer) { record_unwind_protect (save_excursion_restore, save_excursion_save ()); - Fset_buffer (XWINDOW (selected_window)->buffer); + Fset_buffer (XWINDOW (selected_window)->contents); /* Make redisplay consider other windows than just selected_window. */ ++windows_or_buffers_changed; @@ -5017,7 +4986,7 @@ specifies the window to scroll. This takes precedence over record_unwind_protect (save_excursion_restore, save_excursion_save ()); ++windows_or_buffers_changed; - Fset_buffer (w->buffer); + Fset_buffer (w->contents); SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm)); if (NILP (arg)) @@ -5111,10 +5080,10 @@ displayed_window_lines (struct window *w) int bottom_y; void *itdata = NULL; - if (XBUFFER (w->buffer) != current_buffer) + if (XBUFFER (w->contents) != current_buffer) { old_buffer = current_buffer; - set_buffer_internal (XBUFFER (w->buffer)); + set_buffer_internal (XBUFFER (w->contents)); } else old_buffer = NULL; @@ -5176,7 +5145,7 @@ and redisplay normally--don't erase and redraw the frame. */) (register Lisp_Object arg) { struct window *w = XWINDOW (selected_window); - struct buffer *buf = XBUFFER (w->buffer); + struct buffer *buf = XBUFFER (w->contents); struct buffer *obuf = current_buffer; int center_p = 0; ptrdiff_t charpos, bytepos; @@ -5342,7 +5311,7 @@ and redisplay normally--don't erase and redraw the frame. */) } /* Set the new window start. */ - set_marker_both (w->start, w->buffer, charpos, bytepos); + set_marker_both (w->start, w->contents, charpos, bytepos); w->window_end_valid = 0; w->optional_new_start = 1; @@ -5386,9 +5355,8 @@ zero means top of window, negative means relative to bottom of window. */) int this_scroll_margin; #endif - if (!(BUFFERP (w->buffer) - && XBUFFER (w->buffer) == current_buffer)) - /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer + if (!(BUFFERP (w->contents) && XBUFFER (w->contents) == current_buffer)) + /* This test is needed to make sure PT/PT_BYTE make sense in w->contents when passed below to set_marker_both. */ error ("move-to-window-line called from unrelated buffer"); @@ -5398,7 +5366,7 @@ zero means top of window, negative means relative to bottom of window. */) { int height = window_internal_height (w); Fvertical_motion (make_number (- (height / 2)), window); - set_marker_both (w->start, w->buffer, PT, PT_BYTE); + set_marker_both (w->start, w->contents, PT, PT_BYTE); w->start_at_line_beg = !NILP (Fbolp ()); w->force_start = 1; } @@ -5548,9 +5516,9 @@ the return value is nil. Otherwise the value is t. */) window-point of the final-selected-window to the window-point of the current-selected-window. So we have to be careful which point of the current-buffer we copy into old_point. */ - if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) + if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer) && WINDOWP (selected_window) - && EQ (XWINDOW (selected_window)->buffer, new_current_buffer) + && EQ (XWINDOW (selected_window)->contents, new_current_buffer) && !EQ (selected_window, data->current_window)) old_point = marker_position (XWINDOW (data->current_window)->pointm); else @@ -5564,7 +5532,7 @@ the return value is nil. Otherwise the value is t. */) So if possible we want this arbitrary choice of "which point" to be the one from the to-be-selected-window so as to prevent this window's cursor from being copied from another window. */ - if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) + if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer) /* If current_window = selected_window, its point is in BUF_PT. */ && !EQ (selected_window, data->current_window)) old_point = marker_position (XWINDOW (data->current_window)->pointm); @@ -5606,8 +5574,8 @@ the return value is nil. Otherwise the value is t. */) p = SAVED_WINDOW_N (saved_windows, k); window = p->window; w = XWINDOW (window); - if (!NILP (w->buffer) - && !EQ (w->buffer, p->buffer) + if (BUFFERP (w->contents) + && !EQ (w->contents, p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer))) /* If a window we restore gets another buffer, record the window's old buffer. */ @@ -5640,13 +5608,13 @@ the return value is nil. Otherwise the value is t. */) window holds garbage.) We do this now, before restoring the window contents, and prevent it from being done later on when we select a new window. */ - if (! NILP (XWINDOW (selected_window)->buffer)) + if (! NILP (XWINDOW (selected_window)->contents)) { w = XWINDOW (selected_window); set_marker_both (w->pointm, - w->buffer, - BUF_PT (XBUFFER (w->buffer)), - BUF_PT_BYTE (XBUFFER (w->buffer))); + w->contents, + BUF_PT (XBUFFER (w->contents)), + BUF_PT_BYTE (XBUFFER (w->contents))); } windows_or_buffers_changed++; @@ -5693,18 +5661,10 @@ the return value is nil. Otherwise the value is t. */) { wset_prev (w, Qnil); if (!NILP (w->parent)) - { - if (XINT (p->total_cols) == XWINDOW (w->parent)->total_cols) - { - wset_vchild (XWINDOW (w->parent), p->window); - wset_hchild (XWINDOW (w->parent), Qnil); - } - else - { - wset_hchild (XWINDOW (w->parent), p->window); - wset_vchild (XWINDOW (w->parent), Qnil); - } - } + wset_combination (XWINDOW (w->parent), + (XINT (p->total_cols) + != XWINDOW (w->parent)->total_cols), + p->window); } /* If we squirreled away the buffer, restore it now. */ @@ -5753,20 +5713,16 @@ the return value is nil. Otherwise the value is t. */) w->last_modified = 0; w->last_overlay_modified = 0; - /* Reinstall the saved buffer and pointers into it. */ - if (NILP (p->buffer)) - /* An internal window. */ - wset_buffer (w, p->buffer); - else if (BUFFER_LIVE_P (XBUFFER (p->buffer))) + if (BUFFERP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer))) /* If saved buffer is alive, install it. */ { wset_buffer (w, p->buffer); w->start_at_line_beg = !NILP (p->start_at_line_beg); - set_marker_restricted (w->start, p->start, w->buffer); + set_marker_restricted (w->start, p->start, w->contents); set_marker_restricted (w->pointm, p->pointm, - w->buffer); - Fset_marker (BVAR (XBUFFER (w->buffer), mark), - p->mark, w->buffer); + w->contents); + Fset_marker (BVAR (XBUFFER (w->contents), mark), + p->mark, w->contents); /* As documented in Fcurrent_window_configuration, don't restore the location of point in the buffer which was @@ -5775,23 +5731,21 @@ the return value is nil. Otherwise the value is t. */) && XBUFFER (p->buffer) == current_buffer) Fgoto_char (w->pointm); } - else if (!NILP (w->buffer) - && BUFFER_LIVE_P (XBUFFER (w->buffer))) - /* Keep window's old buffer; make sure the markers are - real. */ - { - /* Set window markers at start of visible range. */ - if (XMARKER (w->start)->buffer == 0) - set_marker_restricted_both (w->start, w->buffer, 0, 0); - if (XMARKER (w->pointm)->buffer == 0) - set_marker_restricted_both - (w->pointm, w->buffer, - BUF_PT (XBUFFER (w->buffer)), - BUF_PT_BYTE (XBUFFER (w->buffer))); - w->start_at_line_beg = 1; - } - else - /* Window has no live buffer, get one. */ + else if (BUFFERP (w->contents) && BUFFER_LIVE_P (XBUFFER (w->contents))) + /* Keep window's old buffer; make sure the markers are real. */ + { + /* Set window markers at start of visible range. */ + if (XMARKER (w->start)->buffer == 0) + set_marker_restricted_both (w->start, w->contents, 0, 0); + if (XMARKER (w->pointm)->buffer == 0) + set_marker_restricted_both + (w->pointm, w->contents, + BUF_PT (XBUFFER (w->contents)), + BUF_PT_BYTE (XBUFFER (w->contents))); + w->start_at_line_beg = 1; + } + else if (!NILP (w->start)) + /* Leaf window has no live buffer, get one. */ { /* Get the buffer via other_buffer_safely in order to avoid showing an unimportant buffer and, if necessary, to @@ -5800,8 +5754,8 @@ the return value is nil. Otherwise the value is t. */) wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); /* This will set the markers to beginning of visible range. */ - set_marker_restricted_both (w->start, w->buffer, 0, 0); - set_marker_restricted_both (w->pointm, w->buffer, 0, 0); + set_marker_restricted_both (w->start, w->contents, 0, 0); + set_marker_restricted_both (w->pointm, w->contents, 0, 0); w->start_at_line_beg = 1; if (!NILP (w->dedicated)) /* Record this window as dead. */ @@ -5814,17 +5768,17 @@ the return value is nil. Otherwise the value is t. */) fset_root_window (f, data->root_window); /* Arrange *not* to restore point in the buffer that was current when the window configuration was saved. */ - if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) + if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer)) set_marker_restricted (XWINDOW (data->current_window)->pointm, make_number (old_point), - XWINDOW (data->current_window)->buffer); + XWINDOW (data->current_window)->contents); /* In the following call to `select-window', prevent "swapping out point" in the old selected window using the buffer that has been restored into it. We already swapped out that point from that window's old buffer. */ select_window (data->current_window, Qnil, 1); - BVAR (XBUFFER (XWINDOW (selected_window)->buffer), last_selected_window) + BVAR (XBUFFER (XWINDOW (selected_window)->contents), last_selected_window) = selected_window; if (NILP (data->focus_frame) @@ -5851,14 +5805,9 @@ the return value is nil. Otherwise the value is t. */) /* Now, free glyph matrices in windows that were not reused. */ for (i = n = 0; i < n_leaf_windows; ++i) { - if (NILP (leaf_windows[i]->buffer)) - { - /* Assert it's not reused as a combination. */ - eassert (NILP (leaf_windows[i]->hchild) - && NILP (leaf_windows[i]->vchild)); - free_window_matrices (leaf_windows[i]); - } - else if (EQ (leaf_windows[i]->buffer, new_current_buffer)) + if (NILP (leaf_windows[i]->contents)) + free_window_matrices (leaf_windows[i]); + else if (EQ (leaf_windows[i]->contents, new_current_buffer)) ++n; } @@ -5889,7 +5838,7 @@ the return value is nil. Otherwise the value is t. */) Fset_buffer (new_current_buffer); /* If the new current buffer doesn't appear in the selected window, go to its old point (see bug#12208). */ - if (!EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) + if (!EQ (XWINDOW (data->current_window)->contents, new_current_buffer)) Fgoto_char (make_number (old_point)); } @@ -5900,8 +5849,10 @@ the return value is nil. Otherwise the value is t. */) } -/* Recursively delete all child windows reachable via the next, vchild, - and hchild slots of WINDOW. */ +/* If WINDOW is an internal window, recursively delete all child windows + reachable via the next and contents slots of WINDOW. Otherwise setup + WINDOW to not show any buffer. */ + void delete_all_child_windows (Lisp_Object window) { @@ -5913,17 +5864,12 @@ delete_all_child_windows (Lisp_Object window) /* Delete WINDOW's siblings (we traverse postorderly). */ delete_all_child_windows (w->next); - if (!NILP (w->vchild)) - { - delete_all_child_windows (w->vchild); - wset_vchild (w, Qnil); - } - else if (!NILP (w->hchild)) + if (WINDOWP (w->contents)) { - delete_all_child_windows (w->hchild); - wset_hchild (w, Qnil); + delete_all_child_windows (w->contents); + wset_combination (w, 0, Qnil); } - else if (!NILP (w->buffer)) + else if (BUFFERP (w->contents)) { unshow_buffer (w); unchain_marker (XMARKER (w->pointm)); @@ -5931,7 +5877,7 @@ delete_all_child_windows (Lisp_Object window) /* Since combination limit makes sense for an internal windows only, we use this slot to save the buffer for the sake of possible resurrection in Fset_window_configuration. */ - wset_combination_limit (w, w->buffer); + wset_combination_limit (w, w->contents); wset_buffer (w, Qnil); } @@ -5944,10 +5890,8 @@ count_windows (register struct window *window) register int count = 1; if (!NILP (window->next)) count += count_windows (XWINDOW (window->next)); - if (!NILP (window->vchild)) - count += count_windows (XWINDOW (window->vchild)); - if (!NILP (window->hchild)) - count += count_windows (XWINDOW (window->hchild)); + if (WINDOWP (window->contents)) + count += count_windows (XWINDOW (window->contents)); return count; } @@ -5959,10 +5903,8 @@ get_leaf_windows (struct window *w, struct window **flat, int i) { while (w) { - if (!NILP (w->hchild)) - i = get_leaf_windows (XWINDOW (w->hchild), flat, i); - else if (!NILP (w->vchild)) - i = get_leaf_windows (XWINDOW (w->vchild), flat, i); + if (WINDOWP (w->contents)) + i = get_leaf_windows (XWINDOW (w->contents), flat, i); else flat[i++] = w; @@ -6018,14 +5960,14 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) register struct window *w; register Lisp_Object tem, pers, par; - for (;!NILP (window); window = w->next) + for (; !NILP (window); window = w->next) { p = SAVED_WINDOW_N (vector, i); w = XWINDOW (window); wset_temslot (w, make_number (i)); i++; p->window = window; - p->buffer = w->buffer; + p->buffer = (WINDOW_LEAF_P (w) ? w->contents : Qnil); p->left_col = make_number (w->left_col); p->top_line = make_number (w->top_line); p->total_cols = make_number (w->total_cols); @@ -6092,15 +6034,15 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) } } - if (!NILP (w->buffer)) + if (BUFFERP (w->contents)) { /* Save w's value of point in the window configuration. If w is the selected window, then get the value of point from the buffer; pointm is garbage in the selected window. */ if (EQ (window, selected_window)) - p->pointm = build_marker (XBUFFER (w->buffer), - BUF_PT (XBUFFER (w->buffer)), - BUF_PT_BYTE (XBUFFER (w->buffer))); + p->pointm = build_marker (XBUFFER (w->contents), + BUF_PT (XBUFFER (w->contents)), + BUF_PT_BYTE (XBUFFER (w->contents))); else p->pointm = Fcopy_marker (w->pointm, Qnil); XMARKER (p->pointm)->insertion_type @@ -6109,7 +6051,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) p->start = Fcopy_marker (w->start, Qnil); p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil; - tem = BVAR (XBUFFER (w->buffer), mark); + tem = BVAR (XBUFFER (w->contents), mark); p->mark = Fcopy_marker (tem, Qnil); } else @@ -6130,10 +6072,8 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) else p->prev = XWINDOW (w->prev)->temslot; - if (!NILP (w->vchild)) - i = save_window_save (w->vchild, vector, i); - if (!NILP (w->hchild)) - i = save_window_save (w->hchild, vector, i); + if (WINDOWP (w->contents)) + i = save_window_save (w->contents, vector, i); } return i; @@ -6450,7 +6390,7 @@ If PIXELS-P is non-nil, the return value is VSCROLL. */) adjust_glyphs (f); /* Prevent redisplay shortcuts. */ - XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; + XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; } } @@ -6484,10 +6424,8 @@ foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *u for (cont = 1; w && cont;) { - if (!NILP (w->hchild)) - cont = foreach_window_1 (XWINDOW (w->hchild), fn, user_data); - else if (!NILP (w->vchild)) - cont = foreach_window_1 (XWINDOW (w->vchild), fn, user_data); + if (WINDOWP (w->contents)) + cont = foreach_window_1 (XWINDOW (w->contents), fn, user_data); else cont = fn (w, user_data); diff --git a/src/window.h b/src/window.h index 71c438ff7f2..411756f045e 100644 --- a/src/window.h +++ b/src/window.h @@ -41,14 +41,13 @@ They are deleted only by calling delete-window on them (but this can be done implicitly). Combination windows can be created and deleted at any time. -A leaf window has a non-nil buffer field, and also - has markers in its start and pointm fields. Non-leaf windows - have nil in these fields. +A leaf window has a buffer stored in contents field and markers in its start +and pointm fields. Non-leaf windows have nil in the latter two fields. Non-leaf windows are either vertical or horizontal combinations. A vertical combination window has children that are arranged on the frame -one above the next. Its vchild field points to the uppermost child. +one above the next. Its contents field points to the uppermost child. The parent field of each of the children points to the vertical combination window. The next field of each child points to the child below it, or is nil for the lowest child. The prev field @@ -56,7 +55,7 @@ of each child points to the child above it, or is nil for the highest child. A horizontal combination window has children that are side by side. -Its hchild field points to the leftmost child. In each child +Its contents field points to the leftmost child. In each child the next field points to the child to the right and the prev field points to the child to the left. @@ -78,7 +77,7 @@ the root window is the minibuf window. On minibufferless screens or minibuffer-only screens, the root window and the minibuffer window are one and the same, so its prev and next members are nil. -A dead window has its buffer, hchild, and vchild windows all nil. */ +A dead window has its contents field set to nil. */ struct cursor_pos { @@ -102,13 +101,6 @@ struct window Lisp_Object next; Lisp_Object prev; - /* First child of this window: vchild is used if this is a vertical - combination, hchild if this is a horizontal combination. Of the - fields vchild, hchild and buffer, one and only one is non-nil - unless the window is dead. */ - Lisp_Object hchild; - Lisp_Object vchild; - /* The window this one is a child of. */ Lisp_Object parent; @@ -123,10 +115,8 @@ struct window Lisp_Object new_total; Lisp_Object new_normal; - /* The buffer displayed in this window. Of the fields vchild, - hchild and buffer, one and only one is non-nil unless the window - is dead. */ - Lisp_Object buffer; + /* May be buffer, window, or nil. */ + Lisp_Object contents; /* A marker pointing to where in the text to start displaying. BIDI Note: This is the _logical-order_ start, i.e. the smallest @@ -282,6 +272,10 @@ struct window /* Non-zero if this window is a minibuffer window. */ unsigned mini : 1; + /* Meaningful only if contents is a window, non-zero if this + internal window is used in horizontal combination. */ + unsigned horizontal : 1; + /* Non-zero means must regenerate mode line of this window. */ unsigned update_mode_line : 1; @@ -428,6 +422,21 @@ wset_next_buffers (struct window *w, Lisp_Object val) /* A handy macro. */ +/* Non-zero if W is leaf (carry the buffer). */ + +#define WINDOW_LEAF_P(W) \ + (BUFFERP ((W)->contents)) + +/* Non-zero if W is a member of horizontal combination. */ + +#define WINDOW_HORIZONTAL_COMBINATION_P(W) \ + (WINDOWP ((W)->contents) && (W)->horizontal) + +/* Non-zero if W is a member of vertical combination. */ + +#define WINDOW_VERTICAL_COMBINATION_P(W) \ + (WINDOWP ((W)->contents) && !(W)->horizontal) + #define WINDOW_XFRAME(W) \ (XFRAME (WINDOW_FRAME ((W)))) @@ -931,20 +940,17 @@ extern void check_frame_size (struct frame *frame, int *rows, int *cols); struct glyph *get_phys_cursor_glyph (struct window *w); /* Value is non-zero if WINDOW is a valid window. */ -#define WINDOW_VALID_P(WINDOW) \ - (WINDOWP (WINDOW) \ - && (!NILP (XWINDOW (WINDOW)->buffer) \ - || !NILP (XWINDOW (WINDOW)->vchild) \ - || !NILP (XWINDOW (WINDOW)->hchild))) - -/* A window of any sort, leaf or interior, is "valid" if one - of its buffer, vchild, or hchild members is non-nil. */ +#define WINDOW_VALID_P(WINDOW) \ + (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents)) \ + +/* A window of any sort, leaf or interior, is "valid" if its + contents slot is non-nil. */ #define CHECK_VALID_WINDOW(WINDOW) \ CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW) /* Value is non-zero if WINDOW is a live window. */ #define WINDOW_LIVE_P(WINDOW) \ - (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer)) + (WINDOWP (WINDOW) && BUFFERP (XWINDOW (WINDOW)->contents)) /* A window is "live" if and only if it shows a buffer. */ #define CHECK_LIVE_WINDOW(WINDOW) \ diff --git a/src/xdisp.c b/src/xdisp.c index dff8f719c0d..27987c69b19 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1283,10 +1283,10 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, if (FRAME_INITIAL_P (XFRAME (WINDOW_FRAME (w)))) return visible_p; - if (XBUFFER (w->buffer) != current_buffer) + if (XBUFFER (w->contents) != current_buffer) { old_buffer = current_buffer; - set_buffer_internal_1 (XBUFFER (w->buffer)); + set_buffer_internal_1 (XBUFFER (w->contents)); } SET_TEXT_POS_FROM_MARKER (top, w->start); @@ -4458,7 +4458,7 @@ handle_display_prop (struct it *it) if it was a text property. */ if (!STRINGP (it->string)) - object = it->w->buffer; + object = it->w->contents; display_replaced_p = handle_display_spec (it, propval, object, overlay, position, bufpos, @@ -4866,7 +4866,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, it->what = IT_IMAGE; it->image_id = -1; /* no image */ it->position = start_pos; - it->object = NILP (object) ? it->w->buffer : object; + it->object = NILP (object) ? it->w->contents : object; it->method = GET_FROM_IMAGE; it->from_overlay = Qnil; it->face_id = face_id; @@ -5012,7 +5012,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object, it->what = IT_IMAGE; it->image_id = lookup_image (it->f, value); it->position = start_pos; - it->object = NILP (object) ? it->w->buffer : object; + it->object = NILP (object) ? it->w->contents : object; it->method = GET_FROM_IMAGE; /* Say that we haven't consumed the characters with @@ -5836,7 +5836,7 @@ pop_it (struct it *it) it->object = p->u.stretch.object; break; case GET_FROM_BUFFER: - it->object = it->w->buffer; + it->object = it->w->contents; break; case GET_FROM_STRING: it->object = it->string; @@ -5849,7 +5849,7 @@ pop_it (struct it *it) else { it->method = GET_FROM_BUFFER; - it->object = it->w->buffer; + it->object = it->w->contents; } } it->end_charpos = p->end_charpos; @@ -6290,7 +6290,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p) IT_STRING_BYTEPOS (*it) = -1; it->string = Qnil; it->method = GET_FROM_BUFFER; - it->object = it->w->buffer; + it->object = it->w->contents; it->area = TEXT_AREA; it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); it->sp = 0; @@ -7141,7 +7141,7 @@ set_iterator_to_next (struct it *it, int reseat_p) else { it->method = GET_FROM_BUFFER; - it->object = it->w->buffer; + it->object = it->w->contents; } it->dpvec = NULL; @@ -7714,7 +7714,7 @@ next_element_from_ellipsis (struct it *it) setting face_before_selective_p. */ it->saved_face_id = it->face_id; it->method = GET_FROM_BUFFER; - it->object = it->w->buffer; + it->object = it->w->contents; reseat_at_next_visible_line_start (it, 1); it->face_before_selective_p = 1; } @@ -7978,7 +7978,7 @@ next_element_from_buffer (struct it *it) /* Record what we have and where it came from. */ it->what = IT_CHARACTER; - it->object = it->w->buffer; + it->object = it->w->contents; it->position = it->current.pos; /* Normally we return the character found above, except when we @@ -8084,7 +8084,7 @@ next_element_from_composition (struct it *it) return 0; } it->position = it->current.pos; - it->object = it->w->buffer; + it->object = it->w->contents; it->c = composition_update_it (&it->cmp_it, IT_CHARPOS (*it), IT_BYTEPOS (*it), Qnil); } @@ -10003,7 +10003,7 @@ with_echo_area_buffer_unwind_data (struct window *w) if (w) { XSETWINDOW (tmp, w); ASET (vector, i, tmp); ++i; - ASET (vector, i, w->buffer); ++i; + ASET (vector, i, w->contents); ++i; ASET (vector, i, make_number (marker_position (w->pointm))); ++i; ASET (vector, i, make_number (marker_byte_position (w->pointm))); ++i; ASET (vector, i, make_number (marker_position (w->start))); ++i; @@ -10259,9 +10259,9 @@ resize_mini_window (struct window *w, int exact_p) eassert (MINI_WINDOW_P (w)); /* By default, start display at the beginning. */ - set_marker_both (w->start, w->buffer, - BUF_BEGV (XBUFFER (w->buffer)), - BUF_BEGV_BYTE (XBUFFER (w->buffer))); + set_marker_both (w->start, w->contents, + BUF_BEGV (XBUFFER (w->contents)), + BUF_BEGV_BYTE (XBUFFER (w->contents))); /* Don't resize windows while redisplaying a window; it would confuse redisplay functions when the size of the window they are @@ -10288,10 +10288,10 @@ resize_mini_window (struct window *w, int exact_p) struct text_pos start; struct buffer *old_current_buffer = NULL; - if (current_buffer != XBUFFER (w->buffer)) + if (current_buffer != XBUFFER (w->contents)) { old_current_buffer = current_buffer; - set_buffer_internal (XBUFFER (w->buffer)); + set_buffer_internal (XBUFFER (w->contents)); } init_iterator (&it, w, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID); @@ -10740,7 +10740,7 @@ buffer_shared_and_changed (void) /* Nonzero if W doesn't reflect the actual state of current buffer due to its text or overlays change. FIXME: this may be called when - XBUFFER (w->buffer) != current_buffer, which looks suspicious. */ + XBUFFER (w->contents) != current_buffer, which looks suspicious. */ static int window_outdated (struct window *w) @@ -10755,7 +10755,7 @@ window_outdated (struct window *w) static int window_buffer_changed (struct window *w) { - struct buffer *b = XBUFFER (w->buffer); + struct buffer *b = XBUFFER (w->contents); eassert (BUFFER_LIVE_P (b)); @@ -11009,7 +11009,7 @@ x_consider_frame_title (Lisp_Object frame) Fselect_window (f->selected_window, Qt); set_buffer_internal_1 - (XBUFFER (XWINDOW (f->selected_window)->buffer)); + (XBUFFER (XWINDOW (f->selected_window)->contents)); fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; mode_line_target = MODE_LINE_TITLE; @@ -11128,7 +11128,7 @@ prepare_menu_bars (void) if (windows_or_buffers_changed && FRAME_NS_P (f)) ns_set_doc_edited - (f, Fbuffer_modified_p (XWINDOW (f->selected_window)->buffer)); + (f, Fbuffer_modified_p (XWINDOW (f->selected_window)->contents)); #endif UNGCPRO; } @@ -11200,7 +11200,7 @@ update_menu_bar (struct frame *f, int save_match_data, int hooks_run) specbind (Qinhibit_menubar_update, Qt); - set_buffer_internal_1 (XBUFFER (w->buffer)); + set_buffer_internal_1 (XBUFFER (w->contents)); if (save_match_data) record_unwind_save_match_data (); if (NILP (Voverriding_local_map_menu_flag)) @@ -11404,7 +11404,7 @@ update_tool_bar (struct frame *f, int save_match_data) /* Set current_buffer to the buffer of the selected window of the frame, so that we get the right local keymaps. */ - set_buffer_internal_1 (XBUFFER (w->buffer)); + set_buffer_internal_1 (XBUFFER (w->contents)); /* Save match data, if we must. */ if (save_match_data) @@ -12271,10 +12271,8 @@ hscroll_window_tree (Lisp_Object window) { struct window *w = XWINDOW (window); - if (WINDOWP (w->hchild)) - hscrolled_p |= hscroll_window_tree (w->hchild); - else if (WINDOWP (w->vchild)) - hscrolled_p |= hscroll_window_tree (w->vchild); + if (WINDOWP (w->contents)) + hscrolled_p |= hscroll_window_tree (w->contents); else if (w->cursor.vpos >= 0) { int h_margin; @@ -12294,7 +12292,7 @@ hscroll_window_tree (Lisp_Object window) /* Scroll when cursor is inside this scroll margin. */ h_margin = hscroll_margin * WINDOW_FRAME_COLUMN_WIDTH (w); - if (!NILP (Fbuffer_local_value (Qauto_hscroll_mode, w->buffer)) + if (!NILP (Fbuffer_local_value (Qauto_hscroll_mode, w->contents)) /* For left-to-right rows, hscroll when cursor is either (i) inside the right hscroll margin, or (ii) if it is inside the left margin and the window is already @@ -12329,7 +12327,7 @@ hscroll_window_tree (Lisp_Object window) /* Find point in a display of infinite width. */ saved_current_buffer = current_buffer; - current_buffer = XBUFFER (w->buffer); + current_buffer = XBUFFER (w->contents); if (w == XWINDOW (selected_window)) pt = PT; @@ -12382,7 +12380,7 @@ hscroll_window_tree (Lisp_Object window) redisplay. */ if (w->hscroll != hscroll) { - XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; + XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; w->hscroll = hscroll; hscrolled_p = 1; } @@ -12471,9 +12469,9 @@ debug_method_add (struct window *w, char const *fmt, ...) if (trace_redisplay_p) fprintf (stderr, "%p (%s): %s\n", w, - ((BUFFERP (w->buffer) - && STRINGP (BVAR (XBUFFER (w->buffer), name))) - ? SSDATA (BVAR (XBUFFER (w->buffer), name)) + ((BUFFERP (w->contents) + && STRINGP (BVAR (XBUFFER (w->contents), name))) + ? SSDATA (BVAR (XBUFFER (w->contents), name)) : "no buffer"), method + len); } @@ -12537,8 +12535,8 @@ text_outside_line_unchanged_p (struct window *w, require to redisplay the whole paragraph. It might be worthwhile to find the paragraph limits and widen the range of redisplayed lines to that, but for now just give up this optimization. */ - if (!NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering)) - && NILP (BVAR (XBUFFER (w->buffer), bidi_paragraph_direction))) + if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)) + && NILP (BVAR (XBUFFER (w->contents), bidi_paragraph_direction))) unchanged_p = 0; } @@ -12761,7 +12759,7 @@ reconsider_clip_changes (struct window *w, struct buffer *b) we set b->clip_changed to 1 to force updating the screen. If b->clip_changed has already been set to 1, we can skip this check. */ - if (!b->clip_changed && BUFFERP (w->buffer) && w->window_end_valid) + if (!b->clip_changed && BUFFERP (w->contents) && w->window_end_valid) { ptrdiff_t pt; @@ -12770,11 +12768,11 @@ reconsider_clip_changes (struct window *w, struct buffer *b) else pt = marker_position (w->pointm); - if ((w->current_matrix->buffer != XBUFFER (w->buffer) + if ((w->current_matrix->buffer != XBUFFER (w->contents) || pt != w->last_point) && check_point_in_composition (w->current_matrix->buffer, w->last_point, - XBUFFER (w->buffer), pt)) + XBUFFER (w->contents), pt)) b->clip_changed = 1; } } @@ -13029,11 +13027,11 @@ redisplay_internal (void) the whole window. The assignment to this_line_start_pos prevents the optimization directly below this if-statement. */ if (((!NILP (Vtransient_mark_mode) - && !NILP (BVAR (XBUFFER (w->buffer), mark_active))) + && !NILP (BVAR (XBUFFER (w->contents), mark_active))) != (w->region_showing > 0)) || (w->region_showing && w->region_showing - != XINT (Fmarker_position (BVAR (XBUFFER (w->buffer), mark))))) + != XINT (Fmarker_position (BVAR (XBUFFER (w->contents), mark))))) CHARPOS (this_line_start_pos) = 0; /* Optimize the case that only the line containing the cursor in the @@ -13051,7 +13049,7 @@ redisplay_internal (void) && !FRAME_OBSCURED_P (XFRAME (w->frame)) /* Make sure recorded data applies to current buffer, etc. */ && this_line_buffer == current_buffer - && current_buffer == XBUFFER (w->buffer) + && current_buffer == XBUFFER (w->contents) && !w->force_start && !w->optional_new_start /* Point must be on the line that we have info recorded about. */ @@ -13342,7 +13340,7 @@ redisplay_internal (void) Lisp_Object mini_window = FRAME_MINIBUF_WINDOW (sf); struct frame *mini_frame; - displayed_buffer = XBUFFER (XWINDOW (selected_window)->buffer); + displayed_buffer = XBUFFER (XWINDOW (selected_window)->contents); /* Use list_of_error, not Qerror, so that we catch only errors and don't run the debugger. */ internal_condition_case_1 (redisplay_window_1, selected_window, @@ -13552,7 +13550,7 @@ unwind_redisplay (Lisp_Object old_frame) static void mark_window_display_accurate_1 (struct window *w, int accurate_p) { - struct buffer *b = XBUFFER (w->buffer); + struct buffer *b = XBUFFER (w->contents); w->last_modified = accurate_p ? BUF_MODIFF (b) : 0; w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF (b) : 0; @@ -13599,11 +13597,9 @@ mark_window_display_accurate (Lisp_Object window, int accurate_p) for (; !NILP (window); window = w->next) { w = XWINDOW (window); - if (!NILP (w->vchild)) - mark_window_display_accurate (w->vchild, accurate_p); - else if (!NILP (w->hchild)) - mark_window_display_accurate (w->hchild, accurate_p); - else if (BUFFERP (w->buffer)) + if (WINDOWP (w->contents)) + mark_window_display_accurate (w->contents, accurate_p); + else mark_window_display_accurate_1 (w, accurate_p); } @@ -13660,13 +13656,11 @@ redisplay_windows (Lisp_Object window) { struct window *w = XWINDOW (window); - if (!NILP (w->hchild)) - redisplay_windows (w->hchild); - else if (!NILP (w->vchild)) - redisplay_windows (w->vchild); - else if (!NILP (w->buffer)) + if (WINDOWP (w->contents)) + redisplay_windows (w->contents); + else if (BUFFERP (w->contents)) { - displayed_buffer = XBUFFER (w->buffer); + displayed_buffer = XBUFFER (w->contents); /* Use list_of_error, not Qerror, so that we catch only errors and don't run the debugger. */ internal_condition_case_1 (redisplay_window_0, window, @@ -14313,7 +14307,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, && !MATRIX_ROW_CONTINUATION_LINE_P (row) && row->x == 0) { - this_line_buffer = XBUFFER (w->buffer); + this_line_buffer = XBUFFER (w->contents); CHARPOS (this_line_start_pos) = MATRIX_ROW_START_CHARPOS (row) + delta; @@ -14349,7 +14343,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp) struct window *w = XWINDOW (window); SET_MARKER_FROM_TEXT_POS (w->start, startp); - if (current_buffer != XBUFFER (w->buffer)) + if (current_buffer != XBUFFER (w->contents)) emacs_abort (); if (!NILP (Vwindow_scroll_functions)) @@ -14358,7 +14352,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp) make_number (CHARPOS (startp))); SET_TEXT_POS_FROM_MARKER (startp, w->start); /* In case the hook functions switch buffers. */ - set_buffer_internal (XBUFFER (w->buffer)); + set_buffer_internal (XBUFFER (w->contents)); } return startp; @@ -15009,7 +15003,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste must_scroll = 1; } else if (rc != CURSOR_MOVEMENT_SUCCESS - && !NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering))) + && !NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))) { struct glyph_row *row1; @@ -15072,7 +15066,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste else if (scroll_p) rc = CURSOR_MOVEMENT_MUST_SCROLL; else if (rc != CURSOR_MOVEMENT_SUCCESS - && !NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering))) + && !NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))) { /* With bidi-reordered rows, there could be more than one candidate row whose start and end positions @@ -15179,7 +15173,7 @@ set_vertical_scroll_bar (struct window *w) || (w == XWINDOW (minibuf_window) && NILP (echo_area_buffer[0]))) { - struct buffer *buf = XBUFFER (w->buffer); + struct buffer *buf = XBUFFER (w->contents); whole = BUF_ZV (buf) - BUF_BEGV (buf); start = marker_position (w->start) - BUF_BEGV (buf); /* I don't think this is guaranteed to be right. For the @@ -15213,7 +15207,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) { struct window *w = XWINDOW (window); struct frame *f = XFRAME (w->frame); - struct buffer *buffer = XBUFFER (w->buffer); + struct buffer *buffer = XBUFFER (w->contents); struct buffer *old = current_buffer; struct text_pos lpoint, opoint, startp; int update_mode_line; @@ -15268,10 +15262,10 @@ redisplay_window (Lisp_Object window, int just_this_one_p) else if ((w != XWINDOW (minibuf_window) || minibuf_level == 0) /* When buffer is nonempty, redisplay window normally. */ - && BUF_Z (XBUFFER (w->buffer)) == BUF_BEG (XBUFFER (w->buffer)) + && BUF_Z (XBUFFER (w->contents)) == BUF_BEG (XBUFFER (w->contents)) /* Quail displays non-mini buffers in minibuffer window. In that case, redisplay the window normally. */ - && !NILP (Fmemq (w->buffer, Vminibuffer_list))) + && !NILP (Fmemq (w->contents, Vminibuffer_list))) { /* W is a mini-buffer window, but it's not active, so clear it. */ @@ -15293,7 +15287,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) value. */ /* Really select the buffer, for the sake of buffer-local variables. */ - set_buffer_internal_1 (XBUFFER (w->buffer)); + set_buffer_internal_1 (XBUFFER (w->contents)); current_matrix_up_to_date_p = (w->window_end_valid @@ -16584,7 +16578,7 @@ try_window_reusing_current_matrix (struct window *w) bidi-reordered glyph rows. Let set_cursor_from_row figure out where to put the cursor, and if it fails, give up. */ - if (!NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering))) + if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))) { if (!set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0)) @@ -16835,7 +16829,7 @@ sync_frame_with_window_matrix_rows (struct window *w) /* Preconditions: W must be a leaf window and full-width. Its frame must have a frame matrix. */ - eassert (NILP (w->hchild) && NILP (w->vchild)); + eassert (BUFFERP (w->contents)); eassert (WINDOW_FULL_WIDTH_P (w)); eassert (!FRAME_WINDOW_P (f)); @@ -16877,7 +16871,7 @@ row_containing_pos (struct window *w, ptrdiff_t charpos, { struct glyph_row *row = start; struct glyph_row *best_row = NULL; - ptrdiff_t mindif = BUF_ZV (XBUFFER (w->buffer)) + 1; + ptrdiff_t mindif = BUF_ZV (XBUFFER (w->contents)) + 1; int last_y; /* If we happen to start on a header-line, skip that. */ @@ -16913,7 +16907,7 @@ row_containing_pos (struct window *w, ptrdiff_t charpos, { struct glyph *g; - if (NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering)) + if (NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)) || (!best_row && !row->continued_p)) return row; /* In bidi-reordered rows, there could be several rows @@ -17079,7 +17073,7 @@ try_window_id (struct window *w) wrapped line can change the wrap position, altering the line above it. It might be worthwhile to handle this more intelligently, but for now just redisplay from scratch. */ - if (!NILP (BVAR (XBUFFER (w->buffer), word_wrap))) + if (!NILP (BVAR (XBUFFER (w->contents), word_wrap))) GIVE_UP (21); /* Under bidi reordering, adding or deleting a character in the @@ -17090,8 +17084,8 @@ try_window_id (struct window *w) to find the paragraph limits and widen the range of redisplayed lines to that, but for now just give up this optimization and redisplay from scratch. */ - if (!NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering)) - && NILP (BVAR (XBUFFER (w->buffer), bidi_paragraph_direction))) + if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)) + && NILP (BVAR (XBUFFER (w->contents), bidi_paragraph_direction))) GIVE_UP (22); /* Make sure beg_unchanged and end_unchanged are up to date. Do it @@ -17956,7 +17950,7 @@ glyphs in short form, otherwise show glyphs in long form. */) (Lisp_Object glyphs) { struct window *w = XWINDOW (selected_window); - struct buffer *buffer = XBUFFER (w->buffer); + struct buffer *buffer = XBUFFER (w->contents); fprintf (stderr, "PT = %"pI"d, BEGV = %"pI"d. ZV = %"pI"d\n", BUF_PT (buffer), BUF_BEGV (buffer), BUF_ZV (buffer)); @@ -18062,7 +18056,7 @@ static struct glyph_row * get_overlay_arrow_glyph_row (struct window *w, Lisp_Object overlay_arrow_string) { struct frame *f = XFRAME (WINDOW_FRAME (w)); - struct buffer *buffer = XBUFFER (w->buffer); + struct buffer *buffer = XBUFFER (w->contents); struct buffer *old = current_buffer; const unsigned char *arrow_string = SDATA (overlay_arrow_string); int arrow_len = SCHARS (overlay_arrow_string); @@ -19269,7 +19263,7 @@ display_line (struct it *it) row->glyphs[TEXT_AREA]->charpos = -1; row->displays_text_p = 0; - if (!NILP (BVAR (XBUFFER (it->w->buffer), indicate_empty_lines)) + if (!NILP (BVAR (XBUFFER (it->w->contents), indicate_empty_lines)) && (!MINI_WINDOW_P (it->w) || (minibuf_level && EQ (it->window, minibuf_window)))) row->indicate_empty_line_p = 1; @@ -20084,10 +20078,8 @@ redisplay_mode_lines (Lisp_Object window, int force) { struct window *w = XWINDOW (window); - if (WINDOWP (w->hchild)) - nwindows += redisplay_mode_lines (w->hchild, force); - else if (WINDOWP (w->vchild)) - nwindows += redisplay_mode_lines (w->vchild, force); + if (WINDOWP (w->contents)) + nwindows += redisplay_mode_lines (w->contents, force); else if (force || FRAME_GARBAGED_P (XFRAME (w->frame)) || !MATRIX_MODE_LINE_ROW (w->current_matrix)->enabled_p) @@ -20097,7 +20089,7 @@ redisplay_mode_lines (Lisp_Object window, int force) /* Set the window's buffer for the mode line display. */ SET_TEXT_POS (lpoint, PT, PT_BYTE); - set_buffer_internal_1 (XBUFFER (w->buffer)); + set_buffer_internal_1 (XBUFFER (w->contents)); /* Point refers normally to the selected window. For any other window, set up appropriate value. */ @@ -20879,7 +20871,7 @@ are the selected window and the WINDOW's buffer). */) XSETWINDOW (window, w); if (NILP (buffer)) - buffer = w->buffer; + buffer = w->contents; CHECK_BUFFER (buffer); /* Make formatting the modeline a non-op when noninteractive, otherwise @@ -22185,7 +22177,7 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop, return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w)); } - prop = buffer_local_value_1 (prop, it->w->buffer); + prop = buffer_local_value_1 (prop, it->w->contents); if (EQ (prop, Qunbound)) prop = Qnil; } @@ -22237,7 +22229,7 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop, return OK_PIXELS (pixels); } - car = buffer_local_value_1 (car, it->w->buffer); + car = buffer_local_value_1 (car, it->w->contents); if (EQ (car, Qunbound)) car = Qnil; } @@ -24089,7 +24081,7 @@ produce_stretch_glyph (struct it *it) int n = width; if (!STRINGP (object)) - object = it->w->buffer; + object = it->w->contents; #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (it->f)) append_stretch_glyph (it, object, width, height, ascent); @@ -25485,7 +25477,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width, int *active_cursor) { struct frame *f = XFRAME (w->frame); - struct buffer *b = XBUFFER (w->buffer); + struct buffer *b = XBUFFER (w->contents); int cursor_type = DEFAULT_CURSOR; Lisp_Object alt_cursor; int non_selected = 0; @@ -26036,10 +26028,8 @@ update_cursor_in_window_tree (struct window *w, int on_p) { while (w) { - if (!NILP (w->hchild)) - update_cursor_in_window_tree (XWINDOW (w->hchild), on_p); - else if (!NILP (w->vchild)) - update_cursor_in_window_tree (XWINDOW (w->vchild), on_p); + if (WINDOWP (w->contents)) + update_cursor_in_window_tree (XWINDOW (w->contents), on_p); else update_window_cursor (w, on_p); @@ -27285,7 +27275,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y, { help_echo_string = help; XSETWINDOW (help_echo_window, w); - help_echo_object = w->buffer; + help_echo_object = w->contents; help_echo_pos = charpos; } } @@ -27321,7 +27311,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y, { Lisp_Object default_help = buffer_local_value_1 (Qmode_line_default_help_echo, - w->buffer); + w->contents); if (STRINGP (default_help)) { @@ -27596,7 +27586,7 @@ note_mouse_highlight (struct frame *f, int x, int y) /* Are we in a window whose display is up to date? And verify the buffer's text has not changed. */ - b = XBUFFER (w->buffer); + b = XBUFFER (w->contents); if (part == ON_TEXT && w->window_end_valid && w->last_modified == BUF_MODIFF (b) @@ -27805,8 +27795,8 @@ note_mouse_highlight (struct frame *f, int x, int y) if (pos > 0) { mouse_face = get_char_property_and_overlay - (make_number (pos), Qmouse_face, w->buffer, &overlay); - buffer = w->buffer; + (make_number (pos), Qmouse_face, w->contents, &overlay); + buffer = w->contents; disp_string = object; } } @@ -27919,11 +27909,11 @@ note_mouse_highlight (struct frame *f, int x, int y) if (p > 0) { help = Fget_char_property (make_number (p), - Qhelp_echo, w->buffer); + Qhelp_echo, w->contents); if (!NILP (help)) { charpos = p; - obj = w->buffer; + obj = w->contents; } } } @@ -27974,7 +27964,7 @@ note_mouse_highlight (struct frame *f, int x, int y) ptrdiff_t p = string_buffer_position (obj, start); if (p > 0) pointer = Fget_char_property (make_number (p), - Qpointer, w->buffer); + Qpointer, w->contents); } } else if (BUFFERP (obj) @@ -28417,12 +28407,9 @@ expose_window_tree (struct window *w, XRectangle *r) while (w && !FRAME_GARBAGED_P (f)) { - if (!NILP (w->hchild)) - mouse_face_overwritten_p - |= expose_window_tree (XWINDOW (w->hchild), r); - else if (!NILP (w->vchild)) + if (WINDOWP (w->contents)) mouse_face_overwritten_p - |= expose_window_tree (XWINDOW (w->vchild), r); + |= expose_window_tree (XWINDOW (w->contents), r); else mouse_face_overwritten_p |= expose_window (w, r); diff --git a/src/xfaces.c b/src/xfaces.c index 6db6ac7683f..b988295e9b6 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -5964,7 +5964,7 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos, /* W must display the current buffer. We could write this function to use the frame and buffer of W, but right now it doesn't. */ - /* eassert (XBUFFER (w->buffer) == current_buffer); */ + /* eassert (XBUFFER (w->contents) == current_buffer); */ XSETFASTINT (position, pos); @@ -5974,9 +5974,9 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos, /* Get the `face' or `mouse_face' text property at POS, and determine the next position at which the property changes. */ - prop = Fget_text_property (position, propname, w->buffer); + prop = Fget_text_property (position, propname, w->contents); XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); - end = Fnext_single_property_change (position, propname, w->buffer, limit1); + end = Fnext_single_property_change (position, propname, w->contents, limit1); if (INTEGERP (end)) endpos = XINT (end); @@ -6072,7 +6072,7 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos, /* W must display the current buffer. We could write this function to use the frame and buffer of W, but right now it doesn't. */ - /* eassert (XBUFFER (w->buffer) == current_buffer); */ + /* eassert (XBUFFER (w->contents) == current_buffer); */ XSETFASTINT (position, pos); @@ -6082,9 +6082,9 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos, /* Get the `face' or `mouse_face' text property at POS, and determine the next position at which the property changes. */ - prop = Fget_text_property (position, propname, w->buffer); + prop = Fget_text_property (position, propname, w->contents); XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); - end = Fnext_single_property_change (position, propname, w->buffer, limit1); + end = Fnext_single_property_change (position, propname, w->contents, limit1); if (INTEGERP (end)) endpos = XINT (end); diff --git a/src/xfns.c b/src/xfns.c index e24d3981a09..b39b78004a4 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5043,7 +5043,7 @@ Text larger than the specified size is clipped. */) /* Display the tooltip text in a temporary buffer. */ old_buffer = current_buffer; - set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); + set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->contents)); bset_truncate_lines (current_buffer, Qnil); clear_glyph_matrix (w->desired_matrix); clear_glyph_matrix (w->current_matrix); diff --git a/src/xmenu.c b/src/xmenu.c index af08eeb657c..2042699f48c 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -976,7 +976,7 @@ set_frame_menubar (FRAME_PTR f, bool first_time, bool deep_p) if (! menubar_widget) previous_menu_items_used = 0; - buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; + buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents; specbind (Qinhibit_quit, Qt); /* Don't let the debugger step into this code because it is not reentrant. */ |