aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2013-03-28 18:04:49 +0400
committerDmitry Antipov2013-03-28 18:04:49 +0400
commite74aeda863cd6896e06e92586f87b45d63d67d15 (patch)
treeb6a57d0d39f085274c0953623f7d2924f4813db4 /src
parent9d42d31f24040706fe965e7c586b640471b12861 (diff)
downloademacs-e74aeda863cd6896e06e92586f87b45d63d67d15.tar.gz
emacs-e74aeda863cd6896e06e92586f87b45d63d67d15.zip
* 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/ChangeLog54
-rw-r--r--src/alloc.c5
-rw-r--r--src/buffer.c22
-rw-r--r--src/dispextern.h31
-rw-r--r--src/dispnew.c113
-rw-r--r--src/editfns.c6
-rw-r--r--src/fileio.c4
-rw-r--r--src/font.c2
-rw-r--r--src/frame.c40
-rw-r--r--src/fringe.c12
-rw-r--r--src/indent.c12
-rw-r--r--src/insdel.c2
-rw-r--r--src/keyboard.c24
-rw-r--r--src/keymap.c6
-rw-r--r--src/minibuf.c4
-rw-r--r--src/msdos.c6
-rw-r--r--src/nsfns.m2
-rw-r--r--src/nsmenu.m2
-rw-r--r--src/nsterm.m2
-rw-r--r--src/print.c4
-rw-r--r--src/textprop.c3
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32menu.c2
-rw-r--r--src/window.c486
-rw-r--r--src/window.h58
-rw-r--r--src/xdisp.c191
-rw-r--r--src/xfaces.c12
-rw-r--r--src/xfns.c2
-rw-r--r--src/xmenu.c2
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 @@
12013-03-28 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * window.h (struct window): Replace hchild, vchild and buffer slots
4 with the only contents slot. This is possible because each valid
5 window may have either the child window (in vertical or horizontal
6 combination) or buffer to display (for the leaf window). Using that,
7 a lof of operations to traverse and/or change window hierarchies may
8 be simplified. New member horizontal is used to distinguish between
9 horizontal and vertical combinations of internal windows.
10 (WINDOW_LEAF_P, WINDOW_HORIZONTAL_COMBINATION_P)
11 (WINDOW_VERTICAL_COMBINATION_P): New macros.
12 (WINDOW_VALID_P, WINDOW_LIVE_P): Adjust to match struct window changes.
13 * window.c (wset_hchild, wset_vchild): Remove. Adjust all users.
14 Use contents slot, not buffer, where appropriate.
15 (wset_combination): New function.
16 (wset_buffer): Add eassert.
17 (Fframe_first_window): Simplify the loop reaching first window.
18 (Fwindow_buffer): Use WINDOW_LEAF_P.
19 (Fwindow_top_child): Use WINDOW_VERTICAL_COMBINATION_P.
20 (Fwindow_left_child): Use WINDOW_HORIZONTAL_COMBINATION_P.
21 (unshow_buffer): Convert initial debugging check to eassert.
22 (replace_window, recombine_windows, Fdelete_other_windows_internal)
23 (make_parent_window, window_resize_check, window_resize_apply)
24 (resize_frame_windows, Fsplit_window_internal, Fdelete_window_internal)
25 (Fset_window_configuration, delete_all_child_windows, save_window_save):
26 Adjust to match struct window changes.
27 (window_loop): Check for broken markers in CHECK_ALL_WINDOWS.
28 (mark_window_cursors_off, count_windows, get_leaf_windows)
29 (foreach_window_1): Simplify the loop.
30 * alloc.c (mark_object): Do not check for the leaf window because
31 internal windows has no glyph matrices anyway.
32 * dispnew.c (clear_window_matrices, showing_window_margins_p)
33 (allocate_matrices_for_window_redisplay, fake_current_matrices)
34 (allocate_matrices_for_frame_redisplay, free_window_matrices)
35 (build_frame_matrix_from_window_tree, mirror_make_current)
36 (frame_row_to_window, mirror_line_dance, check_window_matrix_pointers)
37 (update_window_tree, set_window_update_flags): Simplify the loop.
38 (sync_window_with_frame_matrix_rows): Enforce live window.
39 Use contents slot, not buffer, where appropriate.
40 * frame.c (set_menu_bar_lines_1): Use WINDOW_VERTICAL_COMBINATION_P
41 and WINDOW_HORIZONTAL_COMBINATION_P.
42 (make_frame_visible_1): Simplify the loop.
43 Use contents slot, not buffer, where appropriate.
44 * xdisp.c (hscroll_window_tree, mark_window_display_accurate)
45 (redisplay_windows, redisplay_mode_lines, update_cursor_in_window_tree)
46 (expose_window_tree): Likewise.
47 Use contents slot, not buffer, where appropriate.
48 * textprop.c (get_char_property_and_overlay): Add CHECK_LIVE_WINDOW
49 to avoid deleted windows. Use contents slot instead of buffer.
50 * buffer.c, dispextern.h, editfns.c, fileio.c, font.c, fringe.c:
51 * indent.c, insdel.c, keyboard.c, keymap.c, minibuf.c, msdos.c:
52 * nsfns.m, nsmenu.m, nsterm.m, print.c, w32fns.c, w32menu.c, xfaces.c:
53 * xfns.c, xmenu.c: Use contents slot, not buffer, where appropriate.
54
12013-03-28 Eli Zaretskii <eliz@gnu.org> 552013-03-28 Eli Zaretskii <eliz@gnu.org>
2 56
3 * w32fns.c (w32_wnd_proc) [ENABLE_CHECKING]: Add code to help 57 * 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)
5810 case PVEC_WINDOW: 5810 case PVEC_WINDOW:
5811 { 5811 {
5812 struct window *w = (struct window *) ptr; 5812 struct window *w = (struct window *) ptr;
5813 bool leaf = NILP (w->hchild) && NILP (w->vchild);
5814 5813
5815 mark_vectorlike (ptr); 5814 mark_vectorlike (ptr);
5816 5815
5817 /* Mark glyphs for leaf windows. Marking window 5816 /* Mark glyph matrices, if any. Marking window
5818 matrices is sufficient because frame matrices 5817 matrices is sufficient because frame matrices
5819 use the same glyph memory. */ 5818 use the same glyph memory. */
5820 if (leaf && w->current_matrix) 5819 if (w->current_matrix)
5821 { 5820 {
5822 mark_glyph_matrix (w->current_matrix); 5821 mark_glyph_matrix (w->current_matrix);
5823 mark_glyph_matrix (w->desired_matrix); 5822 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. */)
1769 since anything can happen within do_yes_or_no_p. */ 1769 since anything can happen within do_yes_or_no_p. */
1770 1770
1771 /* Don't kill the minibuffer now current. */ 1771 /* Don't kill the minibuffer now current. */
1772 if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) 1772 if (EQ (buffer, XWINDOW (minibuf_window)->contents))
1773 return Qnil; 1773 return Qnil;
1774 1774
1775 /* When we kill an ordinary buffer which shares it's buffer text 1775 /* 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. */)
1820 /* If the buffer now current is shown in the minibuffer and our buffer 1820 /* If the buffer now current is shown in the minibuffer and our buffer
1821 is the sole other buffer give up. */ 1821 is the sole other buffer give up. */
1822 XSETBUFFER (tem, current_buffer); 1822 XSETBUFFER (tem, current_buffer);
1823 if (EQ (tem, XWINDOW (minibuf_window)->buffer) 1823 if (EQ (tem, XWINDOW (minibuf_window)->contents)
1824 && EQ (buffer, Fother_buffer (buffer, Qnil, Qnil))) 1824 && EQ (buffer, Fother_buffer (buffer, Qnil, Qnil)))
1825 return Qnil; 1825 return Qnil;
1826 1826
@@ -2406,19 +2406,19 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2406 { 2406 {
2407 ws = Fcons (w, ws); 2407 ws = Fcons (w, ws);
2408 if (MARKERP (XWINDOW (w)->pointm) 2408 if (MARKERP (XWINDOW (w)->pointm)
2409 && (EQ (XWINDOW (w)->buffer, buf1) 2409 && (EQ (XWINDOW (w)->contents, buf1)
2410 || EQ (XWINDOW (w)->buffer, buf2))) 2410 || EQ (XWINDOW (w)->contents, buf2)))
2411 Fset_marker (XWINDOW (w)->pointm, 2411 Fset_marker (XWINDOW (w)->pointm,
2412 make_number 2412 make_number
2413 (BUF_BEGV (XBUFFER (XWINDOW (w)->buffer))), 2413 (BUF_BEGV (XBUFFER (XWINDOW (w)->contents))),
2414 XWINDOW (w)->buffer); 2414 XWINDOW (w)->contents);
2415 if (MARKERP (XWINDOW (w)->start) 2415 if (MARKERP (XWINDOW (w)->start)
2416 && (EQ (XWINDOW (w)->buffer, buf1) 2416 && (EQ (XWINDOW (w)->contents, buf1)
2417 || EQ (XWINDOW (w)->buffer, buf2))) 2417 || EQ (XWINDOW (w)->contents, buf2)))
2418 Fset_marker (XWINDOW (w)->start, 2418 Fset_marker (XWINDOW (w)->start,
2419 make_number 2419 make_number
2420 (XBUFFER (XWINDOW (w)->buffer)->last_window_start), 2420 (XBUFFER (XWINDOW (w)->contents)->last_window_start),
2421 XWINDOW (w)->buffer); 2421 XWINDOW (w)->contents);
2422 w = Fnext_window (w, Qt, Qt); 2422 w = Fnext_window (w, Qt, Qt);
2423 } 2423 }
2424 } 2424 }
@@ -3901,7 +3901,7 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
3901 if (buffer_window_count (buf) > 0) 3901 if (buffer_window_count (buf) > 0)
3902 { 3902 {
3903 /* ... it's visible in other window than selected, */ 3903 /* ... it's visible in other window than selected, */
3904 if (buf != XBUFFER (XWINDOW (selected_window)->buffer)) 3904 if (buf != XBUFFER (XWINDOW (selected_window)->contents))
3905 windows_or_buffers_changed = 1; 3905 windows_or_buffers_changed = 1;
3906 /* ... or if we modify an overlay at the end of the buffer 3906 /* ... or if we modify an overlay at the end of the buffer
3907 and so we cannot be sure that window end is still valid. */ 3907 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
1412 1412
1413/* Value is non-zero if window W wants a mode line. */ 1413/* Value is non-zero if window W wants a mode line. */
1414 1414
1415#define WINDOW_WANTS_MODELINE_P(W) \ 1415#define WINDOW_WANTS_MODELINE_P(W) \
1416 (!MINI_WINDOW_P ((W)) \ 1416 (!MINI_WINDOW_P ((W)) \
1417 && !(W)->pseudo_window_p \ 1417 && !(W)->pseudo_window_p \
1418 && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \ 1418 && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \
1419 && BUFFERP (W->buffer) \ 1419 && BUFFERP (W->contents) \
1420 && !NILP (BVAR (XBUFFER (W->buffer), mode_line_format)) \ 1420 && !NILP (BVAR (XBUFFER (W->contents), mode_line_format)) \
1421 && WINDOW_TOTAL_LINES (W) > 1) 1421 && WINDOW_TOTAL_LINES (W) > 1)
1422 1422
1423/* Value is true if window W wants a header line. */ 1423/* Value is true if window W wants a header line. */
1424 1424
1425#define WINDOW_WANTS_HEADER_LINE_P(W) \ 1425#define WINDOW_WANTS_HEADER_LINE_P(W) \
1426 (!MINI_WINDOW_P ((W)) \ 1426 (!MINI_WINDOW_P ((W)) \
1427 && !(W)->pseudo_window_p \ 1427 && !(W)->pseudo_window_p \
1428 && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \ 1428 && FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME ((W)))) \
1429 && BUFFERP (W->buffer) \ 1429 && BUFFERP (W->contents) \
1430 && !NILP (BVAR (XBUFFER (W->buffer), header_line_format)) \ 1430 && !NILP (BVAR (XBUFFER (W->contents), header_line_format)) \
1431 && WINDOW_TOTAL_LINES (W) > 1 \ 1431 && WINDOW_TOTAL_LINES (W) > 1 \
1432 + !NILP (BVAR (XBUFFER (W->buffer), mode_line_format))) 1432 + !NILP (BVAR (XBUFFER (W->contents), mode_line_format)))
1433
1434 1433
1435/* Return proper value to be used as baseline offset of font that has 1434/* Return proper value to be used as baseline offset of font that has
1436 ASCENT and DESCENT to draw characters by the font at the vertical 1435 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)
223 "%"pMu": window %p (`%s')%s\n%s", 223 "%"pMu": window %p (`%s')%s\n%s",
224 history_tick++, 224 history_tick++,
225 w, 225 w,
226 ((BUFFERP (w->buffer) 226 ((BUFFERP (w->contents)
227 && STRINGP (BVAR (XBUFFER (w->buffer), name))) 227 && STRINGP (BVAR (XBUFFER (w->contents), name)))
228 ? SSDATA (BVAR (XBUFFER (w->buffer), name)) 228 ? SSDATA (BVAR (XBUFFER (w->contents), name))
229 : "???"), 229 : "???"),
230 paused_p ? " ***paused***" : "", 230 paused_p ? " ***paused***" : "",
231 msg); 231 msg);
@@ -842,16 +842,8 @@ clear_window_matrices (struct window *w, bool desired_p)
842{ 842{
843 while (w) 843 while (w)
844 { 844 {
845 if (!NILP (w->hchild)) 845 if (WINDOWP (w->contents))
846 { 846 clear_window_matrices (XWINDOW (w->contents), desired_p);
847 eassert (WINDOWP (w->hchild));
848 clear_window_matrices (XWINDOW (w->hchild), desired_p);
849 }
850 else if (!NILP (w->vchild))
851 {
852 eassert (WINDOWP (w->vchild));
853 clear_window_matrices (XWINDOW (w->vchild), desired_p);
854 }
855 else 847 else
856 { 848 {
857 if (desired_p) 849 if (desired_p)
@@ -1472,7 +1464,7 @@ check_matrix_invariants (struct window *w)
1472 struct glyph_row *row = matrix->rows; 1464 struct glyph_row *row = matrix->rows;
1473 struct glyph_row *last_text_row = NULL; 1465 struct glyph_row *last_text_row = NULL;
1474 struct buffer *saved = current_buffer; 1466 struct buffer *saved = current_buffer;
1475 struct buffer *buffer = XBUFFER (w->buffer); 1467 struct buffer *buffer = XBUFFER (w->contents);
1476 int c; 1468 int c;
1477 1469
1478 /* This can sometimes happen for a fresh window. */ 1470 /* This can sometimes happen for a fresh window. */
@@ -1636,7 +1628,7 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
1636 vertically below other windows. */ 1628 vertically below other windows. */
1637 in_horz_combination_p 1629 in_horz_combination_p
1638 = (!NILP (XWINDOW (window)->parent) 1630 = (!NILP (XWINDOW (window)->parent)
1639 && !NILP (XWINDOW (XWINDOW (window)->parent)->hchild)); 1631 && WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (XWINDOW (window)->parent)));
1640 1632
1641 /* For WINDOW and all windows on the same level. */ 1633 /* For WINDOW and all windows on the same level. */
1642 do 1634 do
@@ -1645,12 +1637,8 @@ allocate_matrices_for_frame_redisplay (Lisp_Object window, int x, int y,
1645 1637
1646 /* Get the dimension of the window sub-matrix for W, depending 1638 /* Get the dimension of the window sub-matrix for W, depending
1647 on whether this is a combination or a leaf window. */ 1639 on whether this is a combination or a leaf window. */
1648 if (!NILP (w->hchild)) 1640 if (WINDOWP (w->contents))
1649 dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y, 1641 dim = allocate_matrices_for_frame_redisplay (w->contents, x, y,
1650 dim_only_p,
1651 window_change_flags);
1652 else if (!NILP (w->vchild))
1653 dim = allocate_matrices_for_frame_redisplay (w->vchild, x, y,
1654 dim_only_p, 1642 dim_only_p,
1655 window_change_flags); 1643 window_change_flags);
1656 else 1644 else
@@ -1792,10 +1780,8 @@ allocate_matrices_for_window_redisplay (struct window *w)
1792{ 1780{
1793 while (w) 1781 while (w)
1794 { 1782 {
1795 if (!NILP (w->vchild)) 1783 if (WINDOWP (w->contents))
1796 allocate_matrices_for_window_redisplay (XWINDOW (w->vchild)); 1784 allocate_matrices_for_window_redisplay (XWINDOW (w->contents));
1797 else if (!NILP (w->hchild))
1798 allocate_matrices_for_window_redisplay (XWINDOW (w->hchild));
1799 else 1785 else
1800 { 1786 {
1801 /* W is a leaf window. */ 1787 /* W is a leaf window. */
@@ -1867,18 +1853,12 @@ showing_window_margins_p (struct window *w)
1867{ 1853{
1868 while (w) 1854 while (w)
1869 { 1855 {
1870 if (!NILP (w->hchild)) 1856 if (WINDOWP (w->contents))
1871 { 1857 {
1872 if (showing_window_margins_p (XWINDOW (w->hchild))) 1858 if (showing_window_margins_p (XWINDOW (w->contents)))
1873 return 1; 1859 return 1;
1874 } 1860 }
1875 else if (!NILP (w->vchild)) 1861 else if (!NILP (w->left_margin_cols) || !NILP (w->right_margin_cols))
1876 {
1877 if (showing_window_margins_p (XWINDOW (w->vchild)))
1878 return 1;
1879 }
1880 else if (!NILP (w->left_margin_cols)
1881 || !NILP (w->right_margin_cols))
1882 return 1; 1862 return 1;
1883 1863
1884 w = NILP (w->next) ? 0 : XWINDOW (w->next); 1864 w = NILP (w->next) ? 0 : XWINDOW (w->next);
@@ -1899,10 +1879,8 @@ fake_current_matrices (Lisp_Object window)
1899 { 1879 {
1900 w = XWINDOW (window); 1880 w = XWINDOW (window);
1901 1881
1902 if (!NILP (w->hchild)) 1882 if (WINDOWP (w->contents))
1903 fake_current_matrices (w->hchild); 1883 fake_current_matrices (w->contents);
1904 else if (!NILP (w->vchild))
1905 fake_current_matrices (w->vchild);
1906 else 1884 else
1907 { 1885 {
1908 int i; 1886 int i;
@@ -2242,10 +2220,8 @@ free_window_matrices (struct window *w)
2242{ 2220{
2243 while (w) 2221 while (w)
2244 { 2222 {
2245 if (!NILP (w->hchild)) 2223 if (WINDOWP (w->contents))
2246 free_window_matrices (XWINDOW (w->hchild)); 2224 free_window_matrices (XWINDOW (w->contents));
2247 else if (!NILP (w->vchild))
2248 free_window_matrices (XWINDOW (w->vchild));
2249 else 2225 else
2250 { 2226 {
2251 /* This is a leaf window. Free its memory and reset fields 2227 /* 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
2378{ 2354{
2379 while (w) 2355 while (w)
2380 { 2356 {
2381 if (!NILP (w->hchild)) 2357 if (WINDOWP (w->contents))
2382 build_frame_matrix_from_window_tree (matrix, XWINDOW (w->hchild)); 2358 build_frame_matrix_from_window_tree (matrix, XWINDOW (w->contents));
2383 else if (!NILP (w->vchild))
2384 build_frame_matrix_from_window_tree (matrix, XWINDOW (w->vchild));
2385 else 2359 else
2386 build_frame_matrix_from_leaf_window (matrix, w); 2360 build_frame_matrix_from_leaf_window (matrix, w);
2387 2361
@@ -2645,10 +2619,8 @@ mirror_make_current (struct window *w, int frame_row)
2645{ 2619{
2646 while (w) 2620 while (w)
2647 { 2621 {
2648 if (!NILP (w->hchild)) 2622 if (WINDOWP (w->contents))
2649 mirror_make_current (XWINDOW (w->hchild), frame_row); 2623 mirror_make_current (XWINDOW (w->contents), frame_row);
2650 else if (!NILP (w->vchild))
2651 mirror_make_current (XWINDOW (w->vchild), frame_row);
2652 else 2624 else
2653 { 2625 {
2654 /* Row relative to window W. Don't use FRAME_TO_WINDOW_VPOS 2626 /* 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)
2744 struct glyph_row *window_row, *window_row_end, *frame_row; 2716 struct glyph_row *window_row, *window_row_end, *frame_row;
2745 int left, right, x, width; 2717 int left, right, x, width;
2746 2718
2747 /* Preconditions: W must be a leaf window on a tty frame. */ 2719 /* Preconditions: W must be a live window on a tty frame. */
2748 eassert (NILP (w->hchild) && NILP (w->vchild)); 2720 eassert (BUFFERP (w->contents));
2749 eassert (!FRAME_WINDOW_P (f)); 2721 eassert (!FRAME_WINDOW_P (f));
2750 2722
2751 left = margin_glyphs_to_reserve (w, 1, w->left_margin_cols); 2723 left = margin_glyphs_to_reserve (w, 1, w->left_margin_cols);
@@ -2781,10 +2753,8 @@ frame_row_to_window (struct window *w, int row)
2781 2753
2782 while (w && !found) 2754 while (w && !found)
2783 { 2755 {
2784 if (!NILP (w->hchild)) 2756 if (WINDOWP (w->contents))
2785 found = frame_row_to_window (XWINDOW (w->hchild), row); 2757 found = frame_row_to_window (XWINDOW (w->contents), row);
2786 else if (!NILP (w->vchild))
2787 found = frame_row_to_window (XWINDOW (w->vchild), row);
2788 else if (row >= WINDOW_TOP_EDGE_LINE (w) 2758 else if (row >= WINDOW_TOP_EDGE_LINE (w)
2789 && row < WINDOW_BOTTOM_EDGE_LINE (w)) 2759 && row < WINDOW_BOTTOM_EDGE_LINE (w))
2790 found = w; 2760 found = w;
@@ -2812,11 +2782,8 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
2812{ 2782{
2813 while (w) 2783 while (w)
2814 { 2784 {
2815 if (!NILP (w->hchild)) 2785 if (WINDOWP (w->contents))
2816 mirror_line_dance (XWINDOW (w->hchild), unchanged_at_top, 2786 mirror_line_dance (XWINDOW (w->contents), unchanged_at_top,
2817 nlines, copy_from, retained_p);
2818 else if (!NILP (w->vchild))
2819 mirror_line_dance (XWINDOW (w->vchild), unchanged_at_top,
2820 nlines, copy_from, retained_p); 2787 nlines, copy_from, retained_p);
2821 else 2788 else
2822 { 2789 {
@@ -2925,10 +2892,8 @@ check_window_matrix_pointers (struct window *w)
2925{ 2892{
2926 while (w) 2893 while (w)
2927 { 2894 {
2928 if (!NILP (w->hchild)) 2895 if (WINDOWP (w->contents))
2929 check_window_matrix_pointers (XWINDOW (w->hchild)); 2896 check_window_matrix_pointers (XWINDOW (w->contents));
2930 else if (!NILP (w->vchild))
2931 check_window_matrix_pointers (XWINDOW (w->vchild));
2932 else 2897 else
2933 { 2898 {
2934 struct frame *f = XFRAME (w->frame); 2899 struct frame *f = XFRAME (w->frame);
@@ -3194,10 +3159,8 @@ update_window_tree (struct window *w, bool force_p)
3194 3159
3195 while (w && !paused_p) 3160 while (w && !paused_p)
3196 { 3161 {
3197 if (!NILP (w->hchild)) 3162 if (WINDOWP (w->contents))
3198 paused_p |= update_window_tree (XWINDOW (w->hchild), force_p); 3163 paused_p |= update_window_tree (XWINDOW (w->contents), force_p);
3199 else if (!NILP (w->vchild))
3200 paused_p |= update_window_tree (XWINDOW (w->vchild), force_p);
3201 else if (w->must_be_updated_p) 3164 else if (w->must_be_updated_p)
3202 paused_p |= update_window (w, force_p); 3165 paused_p |= update_window (w, force_p);
3203 3166
@@ -3975,10 +3938,8 @@ set_window_update_flags (struct window *w, bool on_p)
3975{ 3938{
3976 while (w) 3939 while (w)
3977 { 3940 {
3978 if (!NILP (w->hchild)) 3941 if (WINDOWP (w->contents))
3979 set_window_update_flags (XWINDOW (w->hchild), on_p); 3942 set_window_update_flags (XWINDOW (w->contents), on_p);
3980 else if (!NILP (w->vchild))
3981 set_window_update_flags (XWINDOW (w->vchild), on_p);
3982 else 3943 else
3983 w->must_be_updated_p = on_p; 3944 w->must_be_updated_p = on_p;
3984 3945
@@ -5125,7 +5086,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5125 5086
5126 /* We used to set current_buffer directly here, but that does the 5087 /* We used to set current_buffer directly here, but that does the
5127 wrong thing with `face-remapping-alist' (bug#2044). */ 5088 wrong thing with `face-remapping-alist' (bug#2044). */
5128 Fset_buffer (w->buffer); 5089 Fset_buffer (w->contents);
5129 itdata = bidi_shelve_cache (); 5090 itdata = bidi_shelve_cache ();
5130 SET_TEXT_POS_FROM_MARKER (startp, w->start); 5091 SET_TEXT_POS_FROM_MARKER (startp, w->start);
5131 CHARPOS (startp) = min (ZV, max (BEGV, CHARPOS (startp))); 5092 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
5171 *dx = x0 + it.first_visible_x - it.current_x; 5132 *dx = x0 + it.first_visible_x - it.current_x;
5172 *dy = *y - it.current_y; 5133 *dy = *y - it.current_y;
5173 5134
5174 string = w->buffer; 5135 string = w->contents;
5175 if (STRINGP (it.string)) 5136 if (STRINGP (it.string))
5176 string = it.string; 5137 string = it.string;
5177 *pos = it.current; 5138 *pos = it.current;
@@ -5189,7 +5150,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5189 if (STRINGP (it.string)) 5150 if (STRINGP (it.string))
5190 BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos)); 5151 BYTEPOS (pos->pos) = string_char_to_byte (string, CHARPOS (pos->pos));
5191 else 5152 else
5192 BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->buffer), 5153 BYTEPOS (pos->pos) = buf_charpos_to_bytepos (XBUFFER (w->contents),
5193 CHARPOS (pos->pos)); 5154 CHARPOS (pos->pos));
5194 } 5155 }
5195 5156
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
373 if (NILP (object)) 373 if (NILP (object))
374 XSETBUFFER (object, current_buffer); 374 XSETBUFFER (object, current_buffer);
375 else if (WINDOWP (object)) 375 else if (WINDOWP (object))
376 object = XWINDOW (object)->buffer; 376 object = XWINDOW (object)->contents;
377 377
378 if (!BUFFERP (object)) 378 if (!BUFFERP (object))
379 /* pos-property only makes sense in buffers right now, since strings 379 /* pos-property only makes sense in buffers right now, since strings
@@ -846,7 +846,7 @@ save_excursion_save (void)
846 ? Fcopy_marker (BVAR (current_buffer, mark), Qnil) 846 ? Fcopy_marker (BVAR (current_buffer, mark), Qnil)
847 : Qnil), 847 : Qnil),
848 /* Selected window if current buffer is shown in it, nil otherwise. */ 848 /* Selected window if current buffer is shown in it, nil otherwise. */
849 (EQ (XWINDOW (selected_window)->buffer, Fcurrent_buffer ()) 849 (EQ (XWINDOW (selected_window)->contents, Fcurrent_buffer ())
850 ? selected_window : Qnil), 850 ? selected_window : Qnil),
851 BVAR (current_buffer, mark_active)); 851 BVAR (current_buffer, mark_active));
852} 852}
@@ -915,7 +915,7 @@ save_excursion_restore (Lisp_Object info)
915 tem = XSAVE_OBJECT (info, 2); 915 tem = XSAVE_OBJECT (info, 2);
916 if (WINDOWP (tem) 916 if (WINDOWP (tem)
917 && !EQ (tem, selected_window) 917 && !EQ (tem, selected_window)
918 && (tem1 = XWINDOW (tem)->buffer, 918 && (tem1 = XWINDOW (tem)->contents,
919 (/* Window is live... */ 919 (/* Window is live... */
920 BUFFERP (tem1) 920 BUFFERP (tem1)
921 /* ...and it shows the current buffer. */ 921 /* ...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. */)
3958 3958
3959 /* If display currently starts at beginning of line, 3959 /* If display currently starts at beginning of line,
3960 keep it that way. */ 3960 keep it that way. */
3961 if (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer) 3961 if (XBUFFER (XWINDOW (selected_window)->contents) == current_buffer)
3962 XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ()); 3962 XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ());
3963 3963
3964 replace_handled = 1; 3964 replace_handled = 1;
@@ -4108,7 +4108,7 @@ by calling `format-decode', which see. */)
4108 4108
4109 /* If display currently starts at beginning of line, 4109 /* If display currently starts at beginning of line,
4110 keep it that way. */ 4110 keep it that way. */
4111 if (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer) 4111 if (XBUFFER (XWINDOW (selected_window)->contents) == current_buffer)
4112 XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ()); 4112 XWINDOW (selected_window)->start_at_line_beg = !NILP (Fbolp ());
4113 4113
4114 /* Replace the chars that we need to replace, 4114 /* 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. */)
4761 4761
4762 if (NILP (string)) 4762 if (NILP (string))
4763 { 4763 {
4764 if (XBUFFER (w->buffer) != current_buffer) 4764 if (XBUFFER (w->contents) != current_buffer)
4765 error ("Specified window is not displaying the current buffer."); 4765 error ("Specified window is not displaying the current buffer.");
4766 CHECK_NUMBER_COERCE_MARKER (position); 4766 CHECK_NUMBER_COERCE_MARKER (position);
4767 if (! (BEGV <= XINT (position) && XINT (position) < ZV)) 4767 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)
159 w->total_lines -= n; 159 w->total_lines -= n;
160 160
161 /* Handle just the top child in a vertical split. */ 161 /* Handle just the top child in a vertical split. */
162 if (!NILP (w->vchild)) 162 if (WINDOW_VERTICAL_COMBINATION_P (w))
163 set_menu_bar_lines_1 (w->vchild, n); 163 set_menu_bar_lines_1 (w->contents, n);
164 164 else if (WINDOW_HORIZONTAL_COMBINATION_P (w))
165 /* Adjust all children in a horizontal split. */ 165 /* Adjust all children in a horizontal split. */
166 for (window = w->hchild; !NILP (window); window = w->next) 166 for (window = w->contents; !NILP (window); window = w->next)
167 { 167 {
168 w = XWINDOW (window); 168 w = XWINDOW (window);
169 set_menu_bar_lines_1 (window, n); 169 set_menu_bar_lines_1 (window, n);
170 } 170 }
171} 171}
172 172
173void 173void
@@ -421,7 +421,7 @@ make_frame_without_minibuffer (register Lisp_Object mini_window, KBOARD *kb, Lis
421 421
422 /* Make the chosen minibuffer window display the proper minibuffer, 422 /* Make the chosen minibuffer window display the proper minibuffer,
423 unless it is already showing a minibuffer. */ 423 unless it is already showing a minibuffer. */
424 if (NILP (Fmemq (XWINDOW (mini_window)->buffer, Vminibuffer_list))) 424 if (NILP (Fmemq (XWINDOW (mini_window)->contents, Vminibuffer_list)))
425 /* Use set_window_buffer instead of Fset_window_buffer (see 425 /* Use set_window_buffer instead of Fset_window_buffer (see
426 discussion of bug#11984, bug#12025, bug#12026). */ 426 discussion of bug#11984, bug#12025, bug#12026). */
427 set_window_buffer (mini_window, 427 set_window_buffer (mini_window,
@@ -1189,7 +1189,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1189 /* Use set_window_buffer instead of Fset_window_buffer (see 1189 /* Use set_window_buffer instead of Fset_window_buffer (see
1190 discussion of bug#11984, bug#12025, bug#12026). */ 1190 discussion of bug#11984, bug#12025, bug#12026). */
1191 set_window_buffer (sf->minibuffer_window, 1191 set_window_buffer (sf->minibuffer_window,
1192 XWINDOW (minibuf_window)->buffer, 0, 0); 1192 XWINDOW (minibuf_window)->contents, 0, 0);
1193 minibuf_window = sf->minibuffer_window; 1193 minibuf_window = sf->minibuffer_window;
1194 1194
1195 /* If the dying minibuffer window was selected, 1195 /* If the dying minibuffer window was selected,
@@ -1593,17 +1593,13 @@ make_frame_visible_1 (Lisp_Object window)
1593{ 1593{
1594 struct window *w; 1594 struct window *w;
1595 1595
1596 for (;!NILP (window); window = w->next) 1596 for (; !NILP (window); window = w->next)
1597 { 1597 {
1598 w = XWINDOW (window); 1598 w = XWINDOW (window);
1599 1599 if (WINDOWP (w->contents))
1600 if (!NILP (w->buffer)) 1600 make_frame_visible_1 (w->contents);
1601 bset_display_time (XBUFFER (w->buffer), Fcurrent_time ()); 1601 else
1602 1602 bset_display_time (XBUFFER (w->contents), Fcurrent_time ());
1603 if (!NILP (w->vchild))
1604 make_frame_visible_1 (w->vchild);
1605 if (!NILP (w->hchild))
1606 make_frame_visible_1 (w->hchild);
1607 } 1603 }
1608} 1604}
1609 1605
@@ -1634,7 +1630,7 @@ displayed in the terminal. */)
1634 /* Use set_window_buffer instead of Fset_window_buffer (see 1630 /* Use set_window_buffer instead of Fset_window_buffer (see
1635 discussion of bug#11984, bug#12025, bug#12026). */ 1631 discussion of bug#11984, bug#12025, bug#12026). */
1636 set_window_buffer (sf->minibuffer_window, 1632 set_window_buffer (sf->minibuffer_window,
1637 XWINDOW (minibuf_window)->buffer, 0, 0); 1633 XWINDOW (minibuf_window)->contents, 0, 0);
1638 minibuf_window = sf->minibuffer_window; 1634 minibuf_window = sf->minibuffer_window;
1639 } 1635 }
1640 1636
@@ -1665,7 +1661,7 @@ If omitted, FRAME defaults to the currently selected frame. */)
1665 /* Use set_window_buffer instead of Fset_window_buffer (see 1661 /* Use set_window_buffer instead of Fset_window_buffer (see
1666 discussion of bug#11984, bug#12025, bug#12026). */ 1662 discussion of bug#11984, bug#12025, bug#12026). */
1667 set_window_buffer (sf->minibuffer_window, 1663 set_window_buffer (sf->minibuffer_window,
1668 XWINDOW (minibuf_window)->buffer, 0, 0); 1664 XWINDOW (minibuf_window)->contents, 0, 0);
1669 minibuf_window = sf->minibuffer_window; 1665 minibuf_window = sf->minibuffer_window;
1670 } 1666 }
1671 1667
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)
699{ 699{
700 Lisp_Object cmap, bm = Qnil; 700 Lisp_Object cmap, bm = Qnil;
701 701
702 if ((cmap = BVAR (XBUFFER (w->buffer), fringe_cursor_alist)), !NILP (cmap)) 702 if ((cmap = BVAR (XBUFFER (w->contents), fringe_cursor_alist)), !NILP (cmap))
703 { 703 {
704 bm = Fassq (cursor, cmap); 704 bm = Fassq (cursor, cmap);
705 if (CONSP (bm)) 705 if (CONSP (bm))
@@ -736,7 +736,7 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in
736 If partial, lookup partial bitmap in default value if not found here. 736 If partial, lookup partial bitmap in default value if not found here.
737 If not partial, or no partial spec is present, use non-partial bitmap. */ 737 If not partial, or no partial spec is present, use non-partial bitmap. */
738 738
739 if ((cmap = BVAR (XBUFFER (w->buffer), fringe_indicator_alist)), !NILP (cmap)) 739 if ((cmap = BVAR (XBUFFER (w->contents), fringe_indicator_alist)), !NILP (cmap))
740 { 740 {
741 bm1 = Fassq (bitmap, cmap); 741 bm1 = Fassq (bitmap, cmap);
742 if (CONSP (bm1)) 742 if (CONSP (bm1))
@@ -963,7 +963,7 @@ update_window_fringes (struct window *w, int keep_current_p)
963 return 0; 963 return 0;
964 964
965 if (!MINI_WINDOW_P (w) 965 if (!MINI_WINDOW_P (w)
966 && (ind = BVAR (XBUFFER (w->buffer), indicate_buffer_boundaries), !NILP (ind))) 966 && (ind = BVAR (XBUFFER (w->contents), indicate_buffer_boundaries), !NILP (ind)))
967 { 967 {
968 if (EQ (ind, Qleft) || EQ (ind, Qright)) 968 if (EQ (ind, Qleft) || EQ (ind, Qright))
969 boundary_top = boundary_bot = arrow_top = arrow_bot = ind; 969 boundary_top = boundary_bot = arrow_top = arrow_bot = ind;
@@ -1004,7 +1004,7 @@ update_window_fringes (struct window *w, int keep_current_p)
1004 { 1004 {
1005 if (top_ind_rn < 0 && row->visible_height > 0) 1005 if (top_ind_rn < 0 && row->visible_height > 0)
1006 { 1006 {
1007 if (MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer)) 1007 if (MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->contents))
1008 && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row)) 1008 && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_TOP_P (w, row))
1009 row->indicate_bob_p = !NILP (boundary_top); 1009 row->indicate_bob_p = !NILP (boundary_top);
1010 else 1010 else
@@ -1014,7 +1014,7 @@ update_window_fringes (struct window *w, int keep_current_p)
1014 1014
1015 if (bot_ind_rn < 0) 1015 if (bot_ind_rn < 0)
1016 { 1016 {
1017 if (MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer)) 1017 if (MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->contents))
1018 && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P (w, row)) 1018 && !MATRIX_ROW_PARTIALLY_VISIBLE_AT_BOTTOM_P (w, row))
1019 row->indicate_eob_p = !NILP (boundary_bot), bot_ind_rn = rn; 1019 row->indicate_eob_p = !NILP (boundary_bot), bot_ind_rn = rn;
1020 else if (y + row->height >= yb) 1020 else if (y + row->height >= yb)
@@ -1024,7 +1024,7 @@ update_window_fringes (struct window *w, int keep_current_p)
1024 } 1024 }
1025 } 1025 }
1026 1026
1027 empty_pos = BVAR (XBUFFER (w->buffer), indicate_empty_lines); 1027 empty_pos = BVAR (XBUFFER (w->contents), indicate_empty_lines);
1028 if (!NILP (empty_pos) && !EQ (empty_pos, Qright)) 1028 if (!NILP (empty_pos) && !EQ (empty_pos, Qright))
1029 empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft; 1029 empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft;
1030 1030
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
254 the next property change */ 254 the next property change */
255 prop = Fget_char_property (position, Qinvisible, 255 prop = Fget_char_property (position, Qinvisible,
256 (!NILP (window) 256 (!NILP (window)
257 && EQ (XWINDOW (window)->buffer, buffer)) 257 && EQ (XWINDOW (window)->contents, buffer))
258 ? window : buffer); 258 ? window : buffer);
259 inv_p = TEXT_PROP_MEANS_INVISIBLE (prop); 259 inv_p = TEXT_PROP_MEANS_INVISIBLE (prop);
260 /* When counting columns (window == nil), don't skip over ellipsis text. */ 260 /* 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,
1826 1826
1827 /* If the window contains this buffer, use it for getting text properties. 1827 /* If the window contains this buffer, use it for getting text properties.
1828 Otherwise use the current buffer as arg for doing that. */ 1828 Otherwise use the current buffer as arg for doing that. */
1829 if (EQ (w->buffer, Fcurrent_buffer ())) 1829 if (EQ (w->contents, Fcurrent_buffer ()))
1830 text_prop_object = window; 1830 text_prop_object = window;
1831 else 1831 else
1832 text_prop_object = Fcurrent_buffer (); 1832 text_prop_object = Fcurrent_buffer ();
@@ -1979,14 +1979,14 @@ whether or not it is currently displayed in some window. */)
1979 1979
1980 old_buffer = Qnil; 1980 old_buffer = Qnil;
1981 GCPRO1 (old_buffer); 1981 GCPRO1 (old_buffer);
1982 if (XBUFFER (w->buffer) != current_buffer) 1982 if (XBUFFER (w->contents) != current_buffer)
1983 { 1983 {
1984 /* Set the window's buffer temporarily to the current buffer. */ 1984 /* Set the window's buffer temporarily to the current buffer. */
1985 old_buffer = w->buffer; 1985 old_buffer = w->contents;
1986 old_charpos = marker_position (w->pointm); 1986 old_charpos = marker_position (w->pointm);
1987 old_bytepos = marker_byte_position (w->pointm); 1987 old_bytepos = marker_byte_position (w->pointm);
1988 wset_buffer (w, Fcurrent_buffer ()); 1988 wset_buffer (w, Fcurrent_buffer ());
1989 set_marker_both (w->pointm, w->buffer, 1989 set_marker_both (w->pointm, w->contents,
1990 BUF_PT (current_buffer), BUF_PT_BYTE (current_buffer)); 1990 BUF_PT (current_buffer), BUF_PT_BYTE (current_buffer));
1991 } 1991 }
1992 1992
@@ -2139,7 +2139,7 @@ whether or not it is currently displayed in some window. */)
2139 if (BUFFERP (old_buffer)) 2139 if (BUFFERP (old_buffer))
2140 { 2140 {
2141 wset_buffer (w, old_buffer); 2141 wset_buffer (w, old_buffer);
2142 set_marker_both (w->pointm, w->buffer, 2142 set_marker_both (w->pointm, w->contents,
2143 old_charpos, old_bytepos); 2143 old_charpos, old_bytepos);
2144 } 2144 }
2145 2145
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,
1798 1798
1799 /* If we're modifying the buffer other than shown in a selected window, 1799 /* If we're modifying the buffer other than shown in a selected window,
1800 let redisplay consider other windows if this buffer is visible. */ 1800 let redisplay consider other windows if this buffer is visible. */
1801 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer 1801 if (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer
1802 && buffer_window_count (current_buffer)) 1802 && buffer_window_count (current_buffer))
1803 ++windows_or_buffers_changed; 1803 ++windows_or_buffers_changed;
1804 1804
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. */)
833 update_mode_lines = 1; 833 update_mode_lines = 1;
834 834
835 if (command_loop_level 835 if (command_loop_level
836 && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer)) 836 && current_buffer != XBUFFER (XWINDOW (selected_window)->contents))
837 buffer = Fcurrent_buffer (); 837 buffer = Fcurrent_buffer ();
838 else 838 else
839 buffer = Qnil; 839 buffer = Qnil;
@@ -1395,7 +1395,7 @@ command_loop_1 (void)
1395 Fkill_emacs (Qnil); 1395 Fkill_emacs (Qnil);
1396 1396
1397 /* Make sure the current window's buffer is selected. */ 1397 /* Make sure the current window's buffer is selected. */
1398 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); 1398 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents));
1399 1399
1400 /* Display any malloc warning that just came out. Use while because 1400 /* Display any malloc warning that just came out. Use while because
1401 displaying one warning can cause another. */ 1401 displaying one warning can cause another. */
@@ -1461,7 +1461,7 @@ command_loop_1 (void)
1461 /* A filter may have run while we were reading the input. */ 1461 /* A filter may have run while we were reading the input. */
1462 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 1462 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
1463 Fkill_emacs (Qnil); 1463 Fkill_emacs (Qnil);
1464 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); 1464 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents));
1465 1465
1466 ++num_input_keys; 1466 ++num_input_keys;
1467 1467
@@ -1492,7 +1492,7 @@ command_loop_1 (void)
1492 { 1492 {
1493 struct buffer *b; 1493 struct buffer *b;
1494 XWINDOW (selected_window)->force_start = 0; 1494 XWINDOW (selected_window)->force_start = 0;
1495 b = XBUFFER (XWINDOW (selected_window)->buffer); 1495 b = XBUFFER (XWINDOW (selected_window)->contents);
1496 BUF_BEG_UNCHANGED (b) = BUF_END_UNCHANGED (b) = 0; 1496 BUF_BEG_UNCHANGED (b) = BUF_END_UNCHANGED (b) = 0;
1497 } 1497 }
1498 1498
@@ -5142,7 +5142,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
5142 if (STRINGP (string)) 5142 if (STRINGP (string))
5143 string_info = Fcons (string, make_number (charpos)); 5143 string_info = Fcons (string, make_number (charpos));
5144 textpos = (w == XWINDOW (selected_window) 5144 textpos = (w == XWINDOW (selected_window)
5145 && current_buffer == XBUFFER (w->buffer)) 5145 && current_buffer == XBUFFER (w->contents))
5146 ? PT : marker_position (w->pointm); 5146 ? PT : marker_position (w->pointm);
5147 5147
5148 xret = wx; 5148 xret = wx;
@@ -9145,9 +9145,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9145 { 9145 {
9146 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9146 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9147 Fkill_emacs (Qnil); 9147 Fkill_emacs (Qnil);
9148 if (XBUFFER (XWINDOW (selected_window)->buffer) 9148 if (XBUFFER (XWINDOW (selected_window)->contents)
9149 != current_buffer) 9149 != current_buffer)
9150 Fset_buffer (XWINDOW (selected_window)->buffer); 9150 Fset_buffer (XWINDOW (selected_window)->contents);
9151 } 9151 }
9152 9152
9153 goto replay_sequence; 9153 goto replay_sequence;
@@ -9195,9 +9195,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9195 special-event-map, ...) might have switched the current buffer 9195 special-event-map, ...) might have switched the current buffer
9196 or the selected window from under us in the mean time. */ 9196 or the selected window from under us in the mean time. */
9197 if (fix_current_buffer 9197 if (fix_current_buffer
9198 && (XBUFFER (XWINDOW (selected_window)->buffer) 9198 && (XBUFFER (XWINDOW (selected_window)->contents)
9199 != current_buffer)) 9199 != current_buffer))
9200 Fset_buffer (XWINDOW (selected_window)->buffer); 9200 Fset_buffer (XWINDOW (selected_window)->contents);
9201 current_binding = active_maps (first_event); 9201 current_binding = active_maps (first_event);
9202 } 9202 }
9203 9203
@@ -9246,8 +9246,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9246 not the current buffer. If we're at the 9246 not the current buffer. If we're at the
9247 beginning of a key sequence, switch buffers. */ 9247 beginning of a key sequence, switch buffers. */
9248 if (WINDOWP (window) 9248 if (WINDOWP (window)
9249 && BUFFERP (XWINDOW (window)->buffer) 9249 && BUFFERP (XWINDOW (window)->contents)
9250 && XBUFFER (XWINDOW (window)->buffer) != current_buffer) 9250 && XBUFFER (XWINDOW (window)->contents) != current_buffer)
9251 { 9251 {
9252 ASET (raw_keybuf, raw_keybuf_count, key); 9252 ASET (raw_keybuf, raw_keybuf_count, key);
9253 raw_keybuf_count++; 9253 raw_keybuf_count++;
@@ -9268,7 +9268,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9268 9268
9269 if (! FRAME_LIVE_P (XFRAME (selected_frame))) 9269 if (! FRAME_LIVE_P (XFRAME (selected_frame)))
9270 Fkill_emacs (Qnil); 9270 Fkill_emacs (Qnil);
9271 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); 9271 set_buffer_internal (XBUFFER (XWINDOW (window)->contents));
9272 goto replay_sequence; 9272 goto replay_sequence;
9273 } 9273 }
9274 } 9274 }
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'. */)
1556 window = POSN_WINDOW (position); 1556 window = POSN_WINDOW (position);
1557 1557
1558 if (WINDOWP (window) 1558 if (WINDOWP (window)
1559 && BUFFERP (XWINDOW (window)->buffer) 1559 && BUFFERP (XWINDOW (window)->contents)
1560 && XBUFFER (XWINDOW (window)->buffer) != current_buffer) 1560 && XBUFFER (XWINDOW (window)->contents) != current_buffer)
1561 { 1561 {
1562 /* Arrange to go back to the original buffer once we're done 1562 /* Arrange to go back to the original buffer once we're done
1563 processing the key sequence. We don't use 1563 processing the key sequence. We don't use
@@ -1567,7 +1567,7 @@ like in the respective argument of `key-binding'. */)
1567 things the same. 1567 things the same.
1568 */ 1568 */
1569 record_unwind_current_buffer (); 1569 record_unwind_current_buffer ();
1570 set_buffer_internal (XBUFFER (XWINDOW (window)->buffer)); 1570 set_buffer_internal (XBUFFER (XWINDOW (window)->contents));
1571 } 1571 }
1572 } 1572 }
1573 1573
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)
114 /* Under X, we come here with minibuf_window being the 114 /* Under X, we come here with minibuf_window being the
115 minibuffer window of the unused termcap window created in 115 minibuffer window of the unused termcap window created in
116 init_window_once. That window doesn't have a buffer. */ 116 init_window_once. That window doesn't have a buffer. */
117 buffer = XWINDOW (minibuf_window)->buffer; 117 buffer = XWINDOW (minibuf_window)->contents;
118 if (BUFFERP (buffer)) 118 if (BUFFERP (buffer))
119 /* Use set_window_buffer instead of Fset_window_buffer (see 119 /* Use set_window_buffer instead of Fset_window_buffer (see
120 discussion of bug#11984, bug#12025, bug#12026). */ 120 discussion of bug#11984, bug#12025, bug#12026). */
@@ -844,7 +844,7 @@ read_minibuf_unwind (Lisp_Object data)
844 window = minibuf_window; 844 window = minibuf_window;
845 /* To keep things predictable, in case it matters, let's be in the 845 /* To keep things predictable, in case it matters, let's be in the
846 minibuffer when we reset the relevant variables. */ 846 minibuffer when we reset the relevant variables. */
847 Fset_buffer (XWINDOW (window)->buffer); 847 Fset_buffer (XWINDOW (window)->contents);
848 848
849 /* Restore prompt, etc, from outer minibuffer level. */ 849 /* Restore prompt, etc, from outer minibuffer level. */
850 minibuf_prompt = Fcar (minibuf_save_list); 850 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)
1261 /* If the mouse highlight is in the window that was deleted 1261 /* If the mouse highlight is in the window that was deleted
1262 (e.g., if it was popped by completion), clear highlight 1262 (e.g., if it was popped by completion), clear highlight
1263 unconditionally. */ 1263 unconditionally. */
1264 if (NILP (w->buffer)) 1264 if (NILP (w->contents))
1265 hlinfo->mouse_face_window = Qnil; 1265 hlinfo->mouse_face_window = Qnil;
1266 else 1266 else
1267 { 1267 {
@@ -1271,7 +1271,7 @@ IT_update_begin (struct frame *f)
1271 break; 1271 break;
1272 } 1272 }
1273 1273
1274 if (NILP (w->buffer) || i < w->desired_matrix->nrows) 1274 if (NILP (w->contents) || i < w->desired_matrix->nrows)
1275 clear_mouse_face (hlinfo); 1275 clear_mouse_face (hlinfo);
1276 } 1276 }
1277 } 1277 }
@@ -1321,7 +1321,7 @@ IT_frame_up_to_date (struct frame *f)
1321 new_cursor = frame_desired_cursor; 1321 new_cursor = frame_desired_cursor;
1322 else 1322 else
1323 { 1323 {
1324 struct buffer *b = XBUFFER (sw->buffer); 1324 struct buffer *b = XBUFFER (sw->contents);
1325 1325
1326 if (EQ (BVAR (b,cursor_type), Qt)) 1326 if (EQ (BVAR (b,cursor_type), Qt))
1327 new_cursor = frame_desired_cursor; 1327 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)
619{ 619{
620 NSView *view; 620 NSView *view;
621 Lisp_Object name, filename; 621 Lisp_Object name, filename;
622 Lisp_Object buf = XWINDOW (f->selected_window)->buffer; 622 Lisp_Object buf = XWINDOW (f->selected_window)->contents;
623 const char *title; 623 const char *title;
624 NSAutoreleasePool *pool; 624 NSAutoreleasePool *pool;
625 struct gcpro gcpro1; 625 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)
191 = alloca (previous_menu_items_used * sizeof *previous_items); 191 = alloca (previous_menu_items_used * sizeof *previous_items);
192 192
193 /* lisp preliminaries */ 193 /* lisp preliminaries */
194 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; 194 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents;
195 specbind (Qinhibit_quit, Qt); 195 specbind (Qinhibit_quit, Qt);
196 specbind (Qdebug_on_next_call, Qnil); 196 specbind (Qdebug_on_next_call, Qnil);
197 record_unwind_save_match_data (); 197 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)
6532{ 6532{
6533 Lisp_Object str = Qnil; 6533 Lisp_Object str = Qnil;
6534 struct frame *f = SELECTED_FRAME (); 6534 struct frame *f = SELECTED_FRAME ();
6535 struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->buffer); 6535 struct buffer *curbuf = XBUFFER (XWINDOW (f->selected_window)->contents);
6536 6536
6537 if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) 6537 if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
6538 return NSAccessibilityTextFieldRole; 6538 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)
1769 strout ("#<window ", -1, -1, printcharfun); 1769 strout ("#<window ", -1, -1, printcharfun);
1770 len = sprintf (buf, "%p", XWINDOW (obj)); 1770 len = sprintf (buf, "%p", XWINDOW (obj));
1771 strout (buf, len, len, printcharfun); 1771 strout (buf, len, len, printcharfun);
1772 if (!NILP (XWINDOW (obj)->buffer)) 1772 if (BUFFERP (XWINDOW (obj)->contents))
1773 { 1773 {
1774 strout (" on ", -1, -1, printcharfun); 1774 strout (" on ", -1, -1, printcharfun);
1775 print_string (BVAR (XBUFFER (XWINDOW (obj)->buffer), name), 1775 print_string (BVAR (XBUFFER (XWINDOW (obj)->contents), name),
1776 printcharfun); 1776 printcharfun);
1777 } 1777 }
1778 PRINTCHAR ('>'); 1778 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,
597 597
598 if (WINDOWP (object)) 598 if (WINDOWP (object))
599 { 599 {
600 CHECK_LIVE_WINDOW (object);
600 w = XWINDOW (object); 601 w = XWINDOW (object);
601 object = w->buffer; 602 object = w->contents;
602 } 603 }
603 if (BUFFERP (object)) 604 if (BUFFERP (object))
604 { 605 {
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. */)
5816 5816
5817 /* Display the tooltip text in a temporary buffer. */ 5817 /* Display the tooltip text in a temporary buffer. */
5818 old_buffer = current_buffer; 5818 old_buffer = current_buffer;
5819 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); 5819 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->contents));
5820 bset_truncate_lines (current_buffer, Qnil); 5820 bset_truncate_lines (current_buffer, Qnil);
5821 clear_glyph_matrix (w->desired_matrix); 5821 clear_glyph_matrix (w->desired_matrix);
5822 clear_glyph_matrix (w->current_matrix); 5822 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)
396 if (! menubar_widget) 396 if (! menubar_widget)
397 previous_menu_items_used = 0; 397 previous_menu_items_used = 0;
398 398
399 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; 399 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents;
400 specbind (Qinhibit_quit, Qt); 400 specbind (Qinhibit_quit, Qt);
401 /* Don't let the debugger step into this code 401 /* Don't let the debugger step into this code
402 because it is not reentrant. */ 402 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)
147 w->display_table = val; 147 w->display_table = val;
148} 148}
149static void 149static void
150wset_hchild (struct window *w, Lisp_Object val)
151{
152 w->hchild = val;
153}
154static void
155wset_left_fringe_width (struct window *w, Lisp_Object val) 150wset_left_fringe_width (struct window *w, Lisp_Object val)
156{ 151{
157 w->left_fringe_width = val; 152 w->left_fringe_width = val;
@@ -217,11 +212,6 @@ wset_temslot (struct window *w, Lisp_Object val)
217 w->temslot = val; 212 w->temslot = val;
218} 213}
219static void 214static void
220wset_vchild (struct window *w, Lisp_Object val)
221{
222 w->vchild = val;
223}
224static void
225wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val) 215wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val)
226{ 216{
227 w->vertical_scroll_bar_type = val; 217 w->vertical_scroll_bar_type = val;
@@ -231,6 +221,18 @@ wset_window_parameters (struct window *w, Lisp_Object val)
231{ 221{
232 w->window_parameters = val; 222 w->window_parameters = val;
233} 223}
224static void
225wset_combination (struct window *w, bool horflag, Lisp_Object val)
226{
227 /* Since leaf windows never becomes non-leaf, there should
228 be no buffer and markers in start and pointm fields of W. */
229 eassert (!BUFFERP (w->contents) && NILP (w->start) && NILP (w->pointm));
230 w->contents = val;
231 /* When an internal window is deleted and VAL is nil, HORFLAG
232 is meaningless. */
233 if (!NILP (val))
234 w->horizontal = horflag;
235}
234 236
235struct window * 237struct window *
236decode_live_window (register Lisp_Object window) 238decode_live_window (register Lisp_Object window)
@@ -275,9 +277,9 @@ static void
275adjust_window_count (struct window *w, int arg) 277adjust_window_count (struct window *w, int arg)
276{ 278{
277 eassert (eabs (arg) == 1); 279 eassert (eabs (arg) == 1);
278 if (BUFFERP (w->buffer)) 280 if (BUFFERP (w->contents))
279 { 281 {
280 struct buffer *b = XBUFFER (w->buffer); 282 struct buffer *b = XBUFFER (w->contents);
281 283
282 if (b->base_buffer) 284 if (b->base_buffer)
283 b = b->base_buffer; 285 b = b->base_buffer;
@@ -296,7 +298,11 @@ void
296wset_buffer (struct window *w, Lisp_Object val) 298wset_buffer (struct window *w, Lisp_Object val)
297{ 299{
298 adjust_window_count (w, -1); 300 adjust_window_count (w, -1);
299 w->buffer = val; 301 if (BUFFERP (val))
302 /* Make sure that we do not assign the buffer
303 to an internal window. */
304 eassert (MARKERP (w->start) && MARKERP (w->pointm));
305 w->contents = val;
300 adjust_window_count (w, 1); 306 adjust_window_count (w, 1);
301} 307}
302 308
@@ -394,15 +400,8 @@ the first window of that frame. */)
394 window = XFRAME (frame_or_window)->root_window; 400 window = XFRAME (frame_or_window)->root_window;
395 } 401 }
396 402
397 while (NILP (XWINDOW (window)->buffer)) 403 while (WINDOWP (XWINDOW (window)->contents))
398 { 404 window = XWINDOW (window)->contents;
399 if (! NILP (XWINDOW (window)->hchild))
400 window = XWINDOW (window)->hchild;
401 else if (! NILP (XWINDOW (window)->vchild))
402 window = XWINDOW (window)->vchild;
403 else
404 emacs_abort ();
405 }
406 405
407 return window; 406 return window;
408} 407}
@@ -489,11 +488,11 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
489 if (NILP (norecord)) 488 if (NILP (norecord))
490 { 489 {
491 w->use_time = ++window_select_count; 490 w->use_time = ++window_select_count;
492 record_buffer (w->buffer); 491 record_buffer (w->contents);
493 } 492 }
494 493
495 /* Make the selected window's buffer current. */ 494 /* Make the selected window's buffer current. */
496 Fset_buffer (w->buffer); 495 Fset_buffer (w->contents);
497 496
498 if (EQ (window, selected_window) && !inhibit_point_swap) 497 if (EQ (window, selected_window) && !inhibit_point_swap)
499 return window; 498 return window;
@@ -516,7 +515,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
516 515
517 select_window_1 (window, inhibit_point_swap); 516 select_window_1 (window, inhibit_point_swap);
518 517
519 bset_last_selected_window (XBUFFER (w->buffer), window); 518 bset_last_selected_window (XBUFFER (w->contents), window);
520 windows_or_buffers_changed++; 519 windows_or_buffers_changed++;
521 return window; 520 return window;
522} 521}
@@ -533,10 +532,10 @@ select_window_1 (Lisp_Object window, bool inhibit_point_swap)
533 if (!inhibit_point_swap) 532 if (!inhibit_point_swap)
534 { 533 {
535 struct window *ow = XWINDOW (selected_window); 534 struct window *ow = XWINDOW (selected_window);
536 if (! NILP (ow->buffer)) 535 if (BUFFERP (ow->contents))
537 set_marker_both (ow->pointm, ow->buffer, 536 set_marker_both (ow->pointm, ow->contents,
538 BUF_PT (XBUFFER (ow->buffer)), 537 BUF_PT (XBUFFER (ow->contents)),
539 BUF_PT_BYTE (XBUFFER (ow->buffer))); 538 BUF_PT_BYTE (XBUFFER (ow->contents)));
540 } 539 }
541 540
542 selected_window = window; 541 selected_window = window;
@@ -581,7 +580,8 @@ If WINDOW is omitted or nil, it defaults to the selected window.
581Return nil for an internal window or a deleted window. */) 580Return nil for an internal window or a deleted window. */)
582 (Lisp_Object window) 581 (Lisp_Object window)
583{ 582{
584 return decode_any_window (window)->buffer; 583 struct window *w = decode_any_window (window);
584 return WINDOW_LEAF_P (w) ? w->contents : Qnil;
585} 585}
586 586
587DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, 587DEFUN ("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
601horizontal combination. */) 601horizontal combination. */)
602 (Lisp_Object window) 602 (Lisp_Object window)
603{ 603{
604 return decode_valid_window (window)->vchild; 604 struct window *w = decode_valid_window (window);
605 return WINDOW_VERTICAL_COMBINATION_P (w) ? w->contents : Qnil;
605} 606}
606 607
607DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 0, 1, 0, 608DEFUN ("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
612vertical combination. */) 613vertical combination. */)
613 (Lisp_Object window) 614 (Lisp_Object window)
614{ 615{
615 return decode_valid_window (window)->hchild; 616 struct window *w = decode_valid_window (window);
617 return WINDOW_HORIZONTAL_COMBINATION_P (w) ? w->contents : Qnil;
616} 618}
617 619
618DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0, 620DEFUN ("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. */)
645 647
646 CHECK_VALID_WINDOW (window); 648 CHECK_VALID_WINDOW (window);
647 w = XWINDOW (window); 649 w = XWINDOW (window);
648 if (!NILP (w->buffer)) 650 if (WINDOW_LEAF_P (w))
649 error ("Combination limit is meaningful for internal windows only"); 651 error ("Combination limit is meaningful for internal windows only");
650 return XWINDOW (window)->combination_limit; 652 return w->combination_limit;
651} 653}
652 654
653DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, 655DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0,
@@ -663,7 +665,7 @@ future use. */)
663 665
664 CHECK_VALID_WINDOW (window); 666 CHECK_VALID_WINDOW (window);
665 w = XWINDOW (window); 667 w = XWINDOW (window);
666 if (!NILP (w->buffer)) 668 if (WINDOW_LEAF_P (w))
667 error ("Combination limit is meaningful for internal windows only"); 669 error ("Combination limit is meaningful for internal windows only");
668 wset_combination_limit (w, limit); 670 wset_combination_limit (w, limit);
669 return limit; 671 return limit;
@@ -860,7 +862,7 @@ set_window_hscroll (struct window *w, EMACS_INT hscroll)
860 862
861 /* Prevent redisplay shortcuts when changing the hscroll. */ 863 /* Prevent redisplay shortcuts when changing the hscroll. */
862 if (w->hscroll != new_hscroll) 864 if (w->hscroll != new_hscroll)
863 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 865 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
864 866
865 w->hscroll = new_hscroll; 867 w->hscroll = new_hscroll;
866 return make_number (new_hscroll); 868 return make_number (new_hscroll);
@@ -1441,7 +1443,7 @@ correct to return the top-level value of `point', outside of any
1441 register struct window *w = decode_live_window (window); 1443 register struct window *w = decode_live_window (window);
1442 1444
1443 if (w == XWINDOW (selected_window)) 1445 if (w == XWINDOW (selected_window))
1444 return make_number (BUF_PT (XBUFFER (w->buffer))); 1446 return make_number (BUF_PT (XBUFFER (w->contents)));
1445 else 1447 else
1446 return Fmarker_position (w->pointm); 1448 return Fmarker_position (w->pointm);
1447} 1449}
@@ -1483,7 +1485,7 @@ if it isn't already recorded. */)
1483 Lisp_Object buf; 1485 Lisp_Object buf;
1484 struct buffer *b; 1486 struct buffer *b;
1485 1487
1486 buf = w->buffer; 1488 buf = w->contents;
1487 CHECK_BUFFER (buf); 1489 CHECK_BUFFER (buf);
1488 b = XBUFFER (buf); 1490 b = XBUFFER (buf);
1489 1491
@@ -1546,7 +1548,7 @@ Return POS. */)
1546 1548
1547 if (w == XWINDOW (selected_window)) 1549 if (w == XWINDOW (selected_window))
1548 { 1550 {
1549 if (XBUFFER (w->buffer) == current_buffer) 1551 if (XBUFFER (w->contents) == current_buffer)
1550 Fgoto_char (pos); 1552 Fgoto_char (pos);
1551 else 1553 else
1552 { 1554 {
@@ -1554,14 +1556,14 @@ Return POS. */)
1554 1556
1555 /* ... but here we want to catch type error before buffer change. */ 1557 /* ... but here we want to catch type error before buffer change. */
1556 CHECK_NUMBER_COERCE_MARKER (pos); 1558 CHECK_NUMBER_COERCE_MARKER (pos);
1557 set_buffer_internal (XBUFFER (w->buffer)); 1559 set_buffer_internal (XBUFFER (w->contents));
1558 Fgoto_char (pos); 1560 Fgoto_char (pos);
1559 set_buffer_internal (old_buffer); 1561 set_buffer_internal (old_buffer);
1560 } 1562 }
1561 } 1563 }
1562 else 1564 else
1563 { 1565 {
1564 set_marker_restricted (w->pointm, pos, w->buffer); 1566 set_marker_restricted (w->pointm, pos, w->contents);
1565 /* We have to make sure that redisplay updates the window to show 1567 /* We have to make sure that redisplay updates the window to show
1566 the new value of point. */ 1568 the new value of point. */
1567 ++windows_or_buffers_changed; 1569 ++windows_or_buffers_changed;
@@ -1579,7 +1581,7 @@ overriding motion of point in order to display at this exact start. */)
1579{ 1581{
1580 register struct window *w = decode_live_window (window); 1582 register struct window *w = decode_live_window (window);
1581 1583
1582 set_marker_restricted (w->start, pos, w->buffer); 1584 set_marker_restricted (w->start, pos, w->contents);
1583 /* This is not right, but much easier than doing what is right. */ 1585 /* This is not right, but much easier than doing what is right. */
1584 w->start_at_line_beg = 0; 1586 w->start_at_line_beg = 0;
1585 if (NILP (noforce)) 1587 if (NILP (noforce))
@@ -1623,7 +1625,7 @@ display row, and VPOS is the row number (0-based) containing POS. */)
1623 int x, y; 1625 int x, y;
1624 1626
1625 w = decode_live_window (window); 1627 w = decode_live_window (window);
1626 buf = XBUFFER (w->buffer); 1628 buf = XBUFFER (w->contents);
1627 SET_TEXT_POS_FROM_MARKER (top, w->start); 1629 SET_TEXT_POS_FROM_MARKER (top, w->start);
1628 1630
1629 if (EQ (pos, Qt)) 1631 if (EQ (pos, Qt))
@@ -1692,8 +1694,8 @@ Return nil if window display is not up-to-date. In that case, use
1692 if (noninteractive || w->pseudo_window_p) 1694 if (noninteractive || w->pseudo_window_p)
1693 return Qnil; 1695 return Qnil;
1694 1696
1695 CHECK_BUFFER (w->buffer); 1697 CHECK_BUFFER (w->contents);
1696 b = XBUFFER (w->buffer); 1698 b = XBUFFER (w->contents);
1697 1699
1698 /* Fail if current matrix is not up-to-date. */ 1700 /* Fail if current matrix is not up-to-date. */
1699 if (!w->window_end_valid 1701 if (!w->window_end_valid
@@ -1919,9 +1921,9 @@ window_display_table (struct window *w)
1919 1921
1920 if (DISP_TABLE_P (w->display_table)) 1922 if (DISP_TABLE_P (w->display_table))
1921 dp = XCHAR_TABLE (w->display_table); 1923 dp = XCHAR_TABLE (w->display_table);
1922 else if (BUFFERP (w->buffer)) 1924 else if (BUFFERP (w->contents))
1923 { 1925 {
1924 struct buffer *b = XBUFFER (w->buffer); 1926 struct buffer *b = XBUFFER (w->contents);
1925 1927
1926 if (DISP_TABLE_P (BVAR (b, display_table))) 1928 if (DISP_TABLE_P (BVAR (b, display_table)))
1927 dp = XCHAR_TABLE (BVAR (b, display_table)); 1929 dp = XCHAR_TABLE (BVAR (b, display_table));
@@ -1946,17 +1948,14 @@ WINDOW must be a live window and defaults to the selected one. */)
1946static void 1948static void
1947unshow_buffer (register struct window *w) 1949unshow_buffer (register struct window *w)
1948{ 1950{
1949 Lisp_Object buf; 1951 Lisp_Object buf = w->contents;
1950 struct buffer *b; 1952 struct buffer *b = XBUFFER (buf);
1951 1953
1952 buf = w->buffer; 1954 eassert (b == XMARKER (w->pointm)->buffer);
1953 b = XBUFFER (buf);
1954 if (b != XMARKER (w->pointm)->buffer)
1955 emacs_abort ();
1956 1955
1957#if 0 1956#if 0
1958 if (w == XWINDOW (selected_window) 1957 if (w == XWINDOW (selected_window)
1959 || ! EQ (buf, XWINDOW (selected_window)->buffer)) 1958 || ! EQ (buf, XWINDOW (selected_window)->contents))
1960 /* Do this except when the selected window's buffer 1959 /* Do this except when the selected window's buffer
1961 is being removed from some other window. */ 1960 is being removed from some other window. */
1962#endif 1961#endif
@@ -1972,14 +1971,14 @@ unshow_buffer (register struct window *w)
1972 /* Point in the selected window's buffer 1971 /* Point in the selected window's buffer
1973 is actually stored in that buffer, and the window's pointm isn't used. 1972 is actually stored in that buffer, and the window's pointm isn't used.
1974 So don't clobber point in that buffer. */ 1973 So don't clobber point in that buffer. */
1975 if (! EQ (buf, XWINDOW (selected_window)->buffer) 1974 if (! EQ (buf, XWINDOW (selected_window)->contents)
1976 /* Don't clobber point in current buffer either (this could be 1975 /* Don't clobber point in current buffer either (this could be
1977 useful in connection with bug#12208). 1976 useful in connection with bug#12208).
1978 && XBUFFER (buf) != current_buffer */ 1977 && XBUFFER (buf) != current_buffer */
1979 /* This line helps to fix Horsley's testbug.el bug. */ 1978 /* This line helps to fix Horsley's testbug.el bug. */
1980 && !(WINDOWP (BVAR (b, last_selected_window)) 1979 && !(WINDOWP (BVAR (b, last_selected_window))
1981 && w != XWINDOW (BVAR (b, last_selected_window)) 1980 && w != XWINDOW (BVAR (b, last_selected_window))
1982 && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->buffer))) 1981 && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->contents)))
1983 temp_set_point_both (b, 1982 temp_set_point_both (b,
1984 clip_to_bounds (BUF_BEGV (b), 1983 clip_to_bounds (BUF_BEGV (b),
1985 marker_position (w->pointm), 1984 marker_position (w->pointm),
@@ -2044,13 +2043,8 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag)
2044 2043
2045 tem = o->parent; 2044 tem = o->parent;
2046 wset_parent (n, tem); 2045 wset_parent (n, tem);
2047 if (!NILP (tem)) 2046 if (!NILP (tem) && EQ (XWINDOW (tem)->contents, old))
2048 { 2047 wset_combination (XWINDOW (tem), XWINDOW (tem)->horizontal, new);
2049 if (EQ (XWINDOW (tem)->vchild, old))
2050 wset_vchild (XWINDOW (tem), new);
2051 if (EQ (XWINDOW (tem)->hchild, old))
2052 wset_hchild (XWINDOW (tem), new);
2053 }
2054} 2048}
2055 2049
2056/* If window WINDOW and its parent window are iso-combined, merge 2050/* If window WINDOW and its parent window are iso-combined, merge
@@ -2069,22 +2063,19 @@ recombine_windows (Lisp_Object window)
2069 if (!NILP (parent) && NILP (w->combination_limit)) 2063 if (!NILP (parent) && NILP (w->combination_limit))
2070 { 2064 {
2071 p = XWINDOW (parent); 2065 p = XWINDOW (parent);
2072 if (((!NILP (p->vchild) && !NILP (w->vchild)) 2066 if (WINDOWP (p->contents) && WINDOWP (w->contents)
2073 || (!NILP (p->hchild) && !NILP (w->hchild)))) 2067 && p->horizontal == w->horizontal)
2074 /* WINDOW and PARENT are both either a vertical or a horizontal 2068 /* WINDOW and PARENT are both either a vertical or a horizontal
2075 combination. */ 2069 combination. */
2076 { 2070 {
2077 horflag = NILP (w->vchild); 2071 horflag = WINDOW_HORIZONTAL_COMBINATION_P (w);
2078 child = horflag ? w->hchild : w->vchild; 2072 child = w->contents;
2079 c = XWINDOW (child); 2073 c = XWINDOW (child);
2080 2074
2081 /* Splice WINDOW's children into its parent's children and 2075 /* Splice WINDOW's children into its parent's children and
2082 assign new normal sizes. */ 2076 assign new normal sizes. */
2083 if (NILP (w->prev)) 2077 if (NILP (w->prev))
2084 if (horflag) 2078 wset_combination (p, horflag, child);
2085 wset_hchild (p, child);
2086 else
2087 wset_vchild (p, child);
2088 else 2079 else
2089 { 2080 {
2090 wset_prev (c, w->prev); 2081 wset_prev (c, w->prev);
@@ -2122,8 +2113,7 @@ recombine_windows (Lisp_Object window)
2122 } 2113 }
2123 2114
2124 /* WINDOW can be deleted now. */ 2115 /* WINDOW can be deleted now. */
2125 wset_vchild (w, Qnil); 2116 wset_combination (w, 0, Qnil);
2126 wset_hchild (w, Qnil);
2127 } 2117 }
2128 } 2118 }
2129} 2119}
@@ -2209,7 +2199,7 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf
2209 struct frame *f = XFRAME (w->frame); 2199 struct frame *f = XFRAME (w->frame);
2210 int candidate_p = 1; 2200 int candidate_p = 1;
2211 2201
2212 if (!BUFFERP (w->buffer)) 2202 if (!BUFFERP (w->contents))
2213 candidate_p = 0; 2203 candidate_p = 0;
2214 else if (MINI_WINDOW_P (w) 2204 else if (MINI_WINDOW_P (w)
2215 && (EQ (minibuf, Qlambda) 2205 && (EQ (minibuf, Qlambda)
@@ -2549,7 +2539,7 @@ enum window_loop
2549 GET_BUFFER_WINDOW, /* Arg is buffer */ 2539 GET_BUFFER_WINDOW, /* Arg is buffer */
2550 REPLACE_BUFFER_IN_WINDOWS_SAFELY, /* Arg is buffer */ 2540 REPLACE_BUFFER_IN_WINDOWS_SAFELY, /* Arg is buffer */
2551 REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */ 2541 REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */
2552 CHECK_ALL_WINDOWS 2542 CHECK_ALL_WINDOWS /* Arg is ignored */
2553}; 2543};
2554 2544
2555static Lisp_Object 2545static Lisp_Object
@@ -2613,7 +2603,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2613 switch (type) 2603 switch (type)
2614 { 2604 {
2615 case GET_BUFFER_WINDOW: 2605 case GET_BUFFER_WINDOW:
2616 if (EQ (w->buffer, obj) 2606 if (EQ (w->contents, obj)
2617 /* Don't find any minibuffer window except the one that 2607 /* Don't find any minibuffer window except the one that
2618 is currently in use. */ 2608 is currently in use. */
2619 && (MINI_WINDOW_P (w) ? EQ (window, minibuf_window) : 1)) 2609 && (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
2637 case REPLACE_BUFFER_IN_WINDOWS_SAFELY: 2627 case REPLACE_BUFFER_IN_WINDOWS_SAFELY:
2638 /* We could simply check whether the buffer shown by window 2628 /* We could simply check whether the buffer shown by window
2639 is live, and show another buffer in case it isn't. */ 2629 is live, and show another buffer in case it isn't. */
2640 if (EQ (w->buffer, obj)) 2630 if (EQ (w->contents, obj))
2641 { 2631 {
2642 /* Undedicate WINDOW. */ 2632 /* Undedicate WINDOW. */
2643 wset_dedicated (w, Qnil); 2633 wset_dedicated (w, Qnil);
2644 /* Make WINDOW show the buffer returned by 2634 /* Make WINDOW show the buffer returned by
2645 other_buffer_safely, don't run any hooks. */ 2635 other_buffer_safely, don't run any hooks. */
2646 set_window_buffer 2636 set_window_buffer
2647 (window, other_buffer_safely (w->buffer), 0, 0); 2637 (window, other_buffer_safely (w->contents), 0, 0);
2648 /* If WINDOW is the selected window, make its buffer 2638 /* If WINDOW is the selected window, make its buffer
2649 current. But do so only if the window shows the 2639 current. But do so only if the window shows the
2650 current buffer (Bug#6454). */ 2640 current buffer (Bug#6454). */
2651 if (EQ (window, selected_window) 2641 if (EQ (window, selected_window)
2652 && XBUFFER (w->buffer) == current_buffer) 2642 && XBUFFER (w->contents) == current_buffer)
2653 Fset_buffer (w->buffer); 2643 Fset_buffer (w->contents);
2654 } 2644 }
2655 break; 2645 break;
2656 2646
2657 case REDISPLAY_BUFFER_WINDOWS: 2647 case REDISPLAY_BUFFER_WINDOWS:
2658 if (EQ (w->buffer, obj)) 2648 if (EQ (w->contents, obj))
2659 { 2649 {
2660 mark_window_display_accurate (window, 0); 2650 mark_window_display_accurate (window, 0);
2661 w->update_mode_line = 1; 2651 w->update_mode_line = 1;
@@ -2665,11 +2655,20 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2665 } 2655 }
2666 break; 2656 break;
2667 2657
2668 /* Check for a window that has a killed buffer. */ 2658 /* Check for a leaf window that has a killed buffer
2659 or broken markers. */
2669 case CHECK_ALL_WINDOWS: 2660 case CHECK_ALL_WINDOWS:
2670 if (! NILP (w->buffer) 2661 if (BUFFERP (w->contents))
2671 && !BUFFER_LIVE_P (XBUFFER (w->buffer))) 2662 {
2672 emacs_abort (); 2663 struct buffer *b = XBUFFER (w->contents);
2664
2665 if (!BUFFER_LIVE_P (b))
2666 emacs_abort ();
2667 if (!MARKERP (w->start) || XMARKER (w->start)->buffer != b)
2668 emacs_abort ();
2669 if (!MARKERP (w->pointm) || XMARKER (w->pointm)->buffer != b)
2670 emacs_abort ();
2671 }
2673 break; 2672 break;
2674 2673
2675 case WINDOW_LOOP_UNUSED: 2674 case WINDOW_LOOP_UNUSED:
@@ -2786,7 +2785,7 @@ window-start value is reasonable when this function is called. */)
2786 else if (MINI_WINDOW_P (w)) /* && top > 0) */ 2785 else if (MINI_WINDOW_P (w)) /* && top > 0) */
2787 error ("Can't expand minibuffer to full frame"); 2786 error ("Can't expand minibuffer to full frame");
2788 2787
2789 if (!NILP (w->buffer)) 2788 if (BUFFERP (w->contents))
2790 { 2789 {
2791 startpos = marker_position (w->start); 2790 startpos = marker_position (w->start);
2792 startbyte = marker_byte_position (w->start); 2791 startbyte = marker_byte_position (w->start);
@@ -2858,7 +2857,7 @@ window-start value is reasonable when this function is called. */)
2858 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 2857 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
2859 resize_failed = 0; 2858 resize_failed = 0;
2860 2859
2861 if (NILP (w->buffer)) 2860 if (!WINDOW_LEAF_P (w))
2862 { 2861 {
2863 /* Resize child windows vertically. */ 2862 /* Resize child windows vertically. */
2864 XSETINT (delta, r->total_lines - w->total_lines); 2863 XSETINT (delta, r->total_lines - w->total_lines);
@@ -2917,28 +2916,21 @@ window-start value is reasonable when this function is called. */)
2917 sibling = w->next; 2916 sibling = w->next;
2918 s = XWINDOW (sibling); 2917 s = XWINDOW (sibling);
2919 wset_prev (s, Qnil); 2918 wset_prev (s, Qnil);
2920 if (!NILP (XWINDOW (w->parent)->vchild)) 2919 wset_combination (XWINDOW (w->parent),
2921 wset_vchild (XWINDOW (w->parent), sibling); 2920 XWINDOW (w->parent)->horizontal, sibling);
2922 else
2923 wset_hchild (XWINDOW (w->parent), sibling);
2924 } 2921 }
2925 2922
2926 /* Delete ROOT and all child windows of ROOT. */ 2923 /* Delete ROOT and all child windows of ROOT. */
2927 if (!NILP (r->vchild)) 2924 if (WINDOWP (r->contents))
2928 { 2925 {
2929 delete_all_child_windows (r->vchild); 2926 delete_all_child_windows (r->contents);
2930 wset_vchild (r, Qnil); 2927 wset_combination (r, 0, Qnil);
2931 }
2932 else if (!NILP (r->hchild))
2933 {
2934 delete_all_child_windows (r->hchild);
2935 wset_hchild (r, Qnil);
2936 } 2928 }
2937 2929
2938 replace_window (root, window, 1); 2930 replace_window (root, window, 1);
2939 2931
2940 /* This must become SWINDOW anyway ....... */ 2932 /* This must become SWINDOW anyway ....... */
2941 if (!NILP (w->buffer) && !resize_failed) 2933 if (BUFFERP (w->contents) && !resize_failed)
2942 { 2934 {
2943 /* Try to minimize scrolling, by setting the window start to the 2935 /* Try to minimize scrolling, by setting the window start to the
2944 point will cause the text at the old window start to be at the 2936 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. */)
2947 when the display is not current, due to typeahead). */ 2939 when the display is not current, due to typeahead). */
2948 new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); 2940 new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w)));
2949 if (new_top != top 2941 if (new_top != top
2950 && startpos >= BUF_BEGV (XBUFFER (w->buffer)) 2942 && startpos >= BUF_BEGV (XBUFFER (w->contents))
2951 && startpos <= BUF_ZV (XBUFFER (w->buffer))) 2943 && startpos <= BUF_ZV (XBUFFER (w->contents)))
2952 { 2944 {
2953 struct position pos; 2945 struct position pos;
2954 struct buffer *obuf = current_buffer; 2946 struct buffer *obuf = current_buffer;
2955 2947
2956 Fset_buffer (w->buffer); 2948 Fset_buffer (w->contents);
2957 /* This computation used to temporarily move point, but that 2949 /* This computation used to temporarily move point, but that
2958 can have unwanted side effects due to text properties. */ 2950 can have unwanted side effects due to text properties. */
2959 pos = *vmotion (startpos, startbyte, -top, w); 2951 pos = *vmotion (startpos, startbyte, -top, w);
2960 2952
2961 set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); 2953 set_marker_both (w->start, w->contents, pos.bufpos, pos.bytepos);
2962 w->window_end_valid = 0; 2954 w->window_end_valid = 0;
2963 w->start_at_line_beg = (pos.bytepos == BEGV_BYTE 2955 w->start_at_line_beg = (pos.bytepos == BEGV_BYTE
2964 || FETCH_BYTE (pos.bytepos - 1) == '\n'); 2956 || FETCH_BYTE (pos.bytepos - 1) == '\n');
@@ -3158,7 +3150,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3158 struct window *w = XWINDOW (window); 3150 struct window *w = XWINDOW (window);
3159 struct buffer *b = XBUFFER (buffer); 3151 struct buffer *b = XBUFFER (buffer);
3160 ptrdiff_t count = SPECPDL_INDEX (); 3152 ptrdiff_t count = SPECPDL_INDEX ();
3161 int samebuf = EQ (buffer, w->buffer); 3153 int samebuf = EQ (buffer, w->contents);
3162 3154
3163 wset_buffer (w, buffer); 3155 wset_buffer (w, buffer);
3164 3156
@@ -3277,7 +3269,7 @@ This function runs `window-scroll-functions' before running
3277 if (!BUFFER_LIVE_P (XBUFFER (buffer))) 3269 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
3278 error ("Attempt to display deleted buffer"); 3270 error ("Attempt to display deleted buffer");
3279 3271
3280 tem = w->buffer; 3272 tem = w->contents;
3281 if (NILP (tem)) 3273 if (NILP (tem))
3282 error ("Window is deleted"); 3274 error ("Window is deleted");
3283 else 3275 else
@@ -3330,8 +3322,8 @@ displaying that buffer. */)
3330 struct window *w = XWINDOW (object); 3322 struct window *w = XWINDOW (object);
3331 mark_window_display_accurate (object, 0); 3323 mark_window_display_accurate (object, 0);
3332 w->update_mode_line = 1; 3324 w->update_mode_line = 1;
3333 if (BUFFERP (w->buffer)) 3325 if (BUFFERP (w->contents))
3334 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 3326 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
3335 ++update_mode_lines; 3327 ++update_mode_lines;
3336 return Qt; 3328 return Qt;
3337 } 3329 }
@@ -3400,7 +3392,7 @@ temp_output_buffer_show (register Lisp_Object buf)
3400 record_unwind_protect (Fset_buffer, prev_buffer); 3392 record_unwind_protect (Fset_buffer, prev_buffer);
3401 record_unwind_protect (select_window_norecord, prev_window); 3393 record_unwind_protect (select_window_norecord, prev_window);
3402 Fselect_window (window, Qt); 3394 Fselect_window (window, Qt);
3403 Fset_buffer (w->buffer); 3395 Fset_buffer (w->contents);
3404 Frun_hooks (1, &Qtemp_buffer_show_hook); 3396 Frun_hooks (1, &Qtemp_buffer_show_hook);
3405 unbind_to (count, Qnil); 3397 unbind_to (count, Qnil);
3406 } 3398 }
@@ -3421,7 +3413,7 @@ make_parent_window (Lisp_Object window, bool horflag)
3421 memcpy ((char *) p + sizeof (struct vectorlike_header), 3413 memcpy ((char *) p + sizeof (struct vectorlike_header),
3422 (char *) o + sizeof (struct vectorlike_header), 3414 (char *) o + sizeof (struct vectorlike_header),
3423 word_size * VECSIZE (struct window)); 3415 word_size * VECSIZE (struct window));
3424 /* P's buffer slot may change from nil to a buffer. */ 3416 /* P's buffer slot may change from nil to a buffer... */
3425 adjust_window_count (p, 1); 3417 adjust_window_count (p, 1);
3426 XSETWINDOW (parent, p); 3418 XSETWINDOW (parent, p);
3427 3419
@@ -3430,12 +3422,11 @@ make_parent_window (Lisp_Object window, bool horflag)
3430 wset_next (o, Qnil); 3422 wset_next (o, Qnil);
3431 wset_prev (o, Qnil); 3423 wset_prev (o, Qnil);
3432 wset_parent (o, parent); 3424 wset_parent (o, parent);
3433 3425 /* ...but now P becomes an internal window. */
3434 wset_hchild (p, horflag ? window : Qnil);
3435 wset_vchild (p, horflag ? Qnil : window);
3436 wset_start (p, Qnil); 3426 wset_start (p, Qnil);
3437 wset_pointm (p, Qnil); 3427 wset_pointm (p, Qnil);
3438 wset_buffer (p, Qnil); 3428 wset_buffer (p, Qnil);
3429 wset_combination (p, horflag, window);
3439 wset_combination_limit (p, Qnil); 3430 wset_combination_limit (p, Qnil);
3440 wset_window_parameters (p, Qnil); 3431 wset_window_parameters (p, Qnil);
3441} 3432}
@@ -3524,10 +3515,10 @@ window_resize_check (struct window *w, bool horflag)
3524{ 3515{
3525 struct window *c; 3516 struct window *c;
3526 3517
3527 if (!NILP (w->vchild)) 3518 if (WINDOW_VERTICAL_COMBINATION_P (w))
3528 /* W is a vertical combination. */ 3519 /* W is a vertical combination. */
3529 { 3520 {
3530 c = XWINDOW (w->vchild); 3521 c = XWINDOW (w->contents);
3531 if (horflag) 3522 if (horflag)
3532 /* All child windows of W must have the same width as W. */ 3523 /* All child windows of W must have the same width as W. */
3533 { 3524 {
@@ -3555,10 +3546,10 @@ window_resize_check (struct window *w, bool horflag)
3555 return (sum_of_sizes == XINT (w->new_total)); 3546 return (sum_of_sizes == XINT (w->new_total));
3556 } 3547 }
3557 } 3548 }
3558 else if (!NILP (w->hchild)) 3549 else if (WINDOW_HORIZONTAL_COMBINATION_P (w))
3559 /* W is a horizontal combination. */ 3550 /* W is a horizontal combination. */
3560 { 3551 {
3561 c = XWINDOW (w->hchild); 3552 c = XWINDOW (w->contents);
3562 if (horflag) 3553 if (horflag)
3563 /* The sum of the widths of the child windows of W must equal W's 3554 /* The sum of the widths of the child windows of W must equal W's
3564 width. */ 3555 width. */
@@ -3625,10 +3616,10 @@ window_resize_apply (struct window *w, bool horflag)
3625 pos = w->top_line; 3616 pos = w->top_line;
3626 } 3617 }
3627 3618
3628 if (!NILP (w->vchild)) 3619 if (WINDOW_VERTICAL_COMBINATION_P (w))
3629 /* W is a vertical combination. */ 3620 /* W is a vertical combination. */
3630 { 3621 {
3631 c = XWINDOW (w->vchild); 3622 c = XWINDOW (w->contents);
3632 while (c) 3623 while (c)
3633 { 3624 {
3634 if (horflag) 3625 if (horflag)
@@ -3641,10 +3632,10 @@ window_resize_apply (struct window *w, bool horflag)
3641 c = NILP (c->next) ? 0 : XWINDOW (c->next); 3632 c = NILP (c->next) ? 0 : XWINDOW (c->next);
3642 } 3633 }
3643 } 3634 }
3644 else if (!NILP (w->hchild)) 3635 else if (WINDOW_HORIZONTAL_COMBINATION_P (w))
3645 /* W is a horizontal combination. */ 3636 /* W is a horizontal combination. */
3646 { 3637 {
3647 c = XWINDOW (w->hchild); 3638 c = XWINDOW (w->contents);
3648 while (c) 3639 while (c)
3649 { 3640 {
3650 if (horflag) 3641 if (horflag)
@@ -3727,7 +3718,7 @@ resize_frame_windows (struct frame *f, int size, bool horflag)
3727 ? 1 : 0))); 3718 ? 1 : 0)));
3728 3719
3729 r->top_line = FRAME_TOP_MARGIN (f); 3720 r->top_line = FRAME_TOP_MARGIN (f);
3730 if (NILP (r->vchild) && NILP (r->hchild)) 3721 if (WINDOW_LEAF_P (r))
3731 /* For a leaf root window just set the size. */ 3722 /* For a leaf root window just set the size. */
3732 if (horflag) 3723 if (horflag)
3733 r->total_cols = new_size; 3724 r->total_cols = new_size;
@@ -3842,9 +3833,9 @@ set correctly. See the code of `split-window' for how this is done. */)
3842 combination_limit = 3833 combination_limit =
3843 EQ (Vwindow_combination_limit, Qt) 3834 EQ (Vwindow_combination_limit, Qt)
3844 || NILP (o->parent) 3835 || NILP (o->parent)
3845 || NILP (horflag 3836 || (horflag
3846 ? (XWINDOW (o->parent)->hchild) 3837 ? WINDOW_VERTICAL_COMBINATION_P (XWINDOW (o->parent))
3847 : (XWINDOW (o->parent)->vchild)); 3838 : WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (o->parent)));
3848 3839
3849 /* We need a live reference window to initialize some parameters. */ 3840 /* We need a live reference window to initialize some parameters. */
3850 if (WINDOW_LIVE_P (old)) 3841 if (WINDOW_LIVE_P (old))
@@ -3914,17 +3905,12 @@ set correctly. See the code of `split-window' for how this is done. */)
3914 n = XWINDOW (new); 3905 n = XWINDOW (new);
3915 wset_frame (n, frame); 3906 wset_frame (n, frame);
3916 wset_parent (n, o->parent); 3907 wset_parent (n, o->parent);
3917 wset_vchild (n, Qnil);
3918 wset_hchild (n, Qnil);
3919 3908
3920 if (EQ (side, Qabove) || EQ (side, Qleft)) 3909 if (EQ (side, Qabove) || EQ (side, Qleft))
3921 { 3910 {
3922 wset_prev (n, o->prev); 3911 wset_prev (n, o->prev);
3923 if (NILP (n->prev)) 3912 if (NILP (n->prev))
3924 if (horflag) 3913 wset_combination (p, horflag, new);
3925 wset_hchild (p, new);
3926 else
3927 wset_vchild (p, new);
3928 else 3914 else
3929 wset_next (XWINDOW (n->prev), new); 3915 wset_next (XWINDOW (n->prev), new);
3930 wset_next (n, old); 3916 wset_next (n, old);
@@ -3973,7 +3959,7 @@ set correctly. See the code of `split-window' for how this is done. */)
3973 adjust_glyphs (f); 3959 adjust_glyphs (f);
3974 /* Set buffer of NEW to buffer of reference window. Don't run 3960 /* Set buffer of NEW to buffer of reference window. Don't run
3975 any hooks. */ 3961 any hooks. */
3976 set_window_buffer (new, r->buffer, 0, 1); 3962 set_window_buffer (new, r->contents, 0, 1);
3977 unblock_input (); 3963 unblock_input ();
3978 3964
3979 /* Maybe we should run the scroll functions in Elisp (which already 3965 /* 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. */)
3995 register Lisp_Object parent, sibling, frame, root; 3981 register Lisp_Object parent, sibling, frame, root;
3996 struct window *w, *p, *s, *r; 3982 struct window *w, *p, *s, *r;
3997 struct frame *f; 3983 struct frame *f;
3998 bool horflag; 3984 bool horflag, before_sibling = 0;
3999 int before_sibling = 0;
4000 3985
4001 w = decode_any_window (window); 3986 w = decode_any_window (window);
4002 XSETWINDOW (window, w); 3987 XSETWINDOW (window, w);
4003 if (NILP (w->buffer) 3988 if (NILP (w->contents))
4004 && NILP (w->hchild) && NILP (w->vchild))
4005 /* It's a no-op to delete an already deleted window. */ 3989 /* It's a no-op to delete an already deleted window. */
4006 return Qnil; 3990 return Qnil;
4007 3991
@@ -4015,7 +3999,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4015 error ("Attempt to delete sole window of parent"); 3999 error ("Attempt to delete sole window of parent");
4016 4000
4017 p = XWINDOW (parent); 4001 p = XWINDOW (parent);
4018 horflag = NILP (p->vchild); 4002 horflag = WINDOW_HORIZONTAL_COMBINATION_P (p);
4019 4003
4020 frame = WINDOW_FRAME (w); 4004 frame = WINDOW_FRAME (w);
4021 f = XFRAME (frame); 4005 f = XFRAME (frame);
@@ -4033,10 +4017,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4033 sibling = w->next; 4017 sibling = w->next;
4034 s = XWINDOW (sibling); 4018 s = XWINDOW (sibling);
4035 wset_prev (s, Qnil); 4019 wset_prev (s, Qnil);
4036 if (horflag) 4020 wset_combination (p, horflag, sibling);
4037 wset_hchild (p, sibling);
4038 else
4039 wset_vchild (p, sibling);
4040 } 4021 }
4041 else 4022 else
4042 /* Get SIBLING above (on the left of) WINDOW. */ 4023 /* Get SIBLING above (on the left of) WINDOW. */
@@ -4075,17 +4056,12 @@ Signal an error when WINDOW is the only window on its frame. */)
4075 wset_next (w, Qnil); /* Don't delete w->next too. */ 4056 wset_next (w, Qnil); /* Don't delete w->next too. */
4076 free_window_matrices (w); 4057 free_window_matrices (w);
4077 4058
4078 if (!NILP (w->vchild)) 4059 if (WINDOWP (w->contents))
4079 { 4060 {
4080 delete_all_child_windows (w->vchild); 4061 delete_all_child_windows (w->contents);
4081 wset_vchild (w, Qnil); 4062 wset_combination (w, 0, Qnil);
4082 } 4063 }
4083 else if (!NILP (w->hchild)) 4064 else
4084 {
4085 delete_all_child_windows (w->hchild);
4086 wset_hchild (w, Qnil);
4087 }
4088 else if (!NILP (w->buffer))
4089 { 4065 {
4090 unshow_buffer (w); 4066 unshow_buffer (w);
4091 unchain_marker (XMARKER (w->pointm)); 4067 unchain_marker (XMARKER (w->pointm));
@@ -4104,8 +4080,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4104 wset_normal_cols (s, p->normal_cols); 4080 wset_normal_cols (s, p->normal_cols);
4105 wset_normal_lines (s, p->normal_lines); 4081 wset_normal_lines (s, p->normal_lines);
4106 /* Mark PARENT as deleted. */ 4082 /* Mark PARENT as deleted. */
4107 wset_vchild (p, Qnil); 4083 wset_combination (p, 0, Qnil);
4108 wset_hchild (p, Qnil);
4109 /* Try to merge SIBLING into its new parent. */ 4084 /* Try to merge SIBLING into its new parent. */
4110 recombine_windows (sibling); 4085 recombine_windows (sibling);
4111 } 4086 }
@@ -4153,10 +4128,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4153 if (before_sibling) 4128 if (before_sibling)
4154 { 4129 {
4155 wset_prev (s, window); 4130 wset_prev (s, window);
4156 if (horflag) 4131 wset_combination (p, horflag, window);
4157 wset_hchild (p, window);
4158 else
4159 wset_vchild (p, window);
4160 } 4132 }
4161 else 4133 else
4162 { 4134 {
@@ -4299,10 +4271,8 @@ mark_window_cursors_off (struct window *w)
4299{ 4271{
4300 while (w) 4272 while (w)
4301 { 4273 {
4302 if (!NILP (w->hchild)) 4274 if (WINDOWP (w->contents))
4303 mark_window_cursors_off (XWINDOW (w->hchild)); 4275 mark_window_cursors_off (XWINDOW (w->contents));
4304 else if (!NILP (w->vchild))
4305 mark_window_cursors_off (XWINDOW (w->vchild));
4306 else 4276 else
4307 w->phys_cursor_on_p = 0; 4277 w->phys_cursor_on_p = 0;
4308 4278
@@ -4321,8 +4291,7 @@ window_internal_height (struct window *w)
4321 if (!MINI_WINDOW_P (w)) 4291 if (!MINI_WINDOW_P (w))
4322 { 4292 {
4323 if (!NILP (w->parent) 4293 if (!NILP (w->parent)
4324 || !NILP (w->vchild) 4294 || WINDOWP (w->contents)
4325 || !NILP (w->hchild)
4326 || !NILP (w->next) 4295 || !NILP (w->next)
4327 || !NILP (w->prev) 4296 || !NILP (w->prev)
4328 || WINDOW_WANTS_MODELINE_P (w)) 4297 || WINDOW_WANTS_MODELINE_P (w))
@@ -4461,7 +4430,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4461 else 4430 else
4462 spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV); 4431 spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV);
4463 set_marker_restricted (w->start, make_number (spos), 4432 set_marker_restricted (w->start, make_number (spos),
4464 w->buffer); 4433 w->contents);
4465 w->start_at_line_beg = 1; 4434 w->start_at_line_beg = 1;
4466 w->update_mode_line = 1; 4435 w->update_mode_line = 1;
4467 w->last_modified = 0; 4436 w->last_modified = 0;
@@ -4585,7 +4554,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4585 4554
4586 /* If control gets here, then we vscrolled. */ 4555 /* If control gets here, then we vscrolled. */
4587 4556
4588 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 4557 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
4589 4558
4590 /* Don't try to change the window start below. */ 4559 /* Don't try to change the window start below. */
4591 vscrolled = 1; 4560 vscrolled = 1;
@@ -4605,7 +4574,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4605 } 4574 }
4606 4575
4607 /* Set the window start, and set up the window for redisplay. */ 4576 /* Set the window start, and set up the window for redisplay. */
4608 set_marker_restricted_both (w->start, w->buffer, IT_CHARPOS (it), 4577 set_marker_restricted_both (w->start, w->contents, IT_CHARPOS (it),
4609 IT_BYTEPOS (it)); 4578 IT_BYTEPOS (it));
4610 bytepos = marker_byte_position (w->start); 4579 bytepos = marker_byte_position (w->start);
4611 w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); 4580 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)
4805 int this_scroll_margin = 4774 int this_scroll_margin =
4806 max (0, min (scroll_margin, w->total_lines / 4)); 4775 max (0, min (scroll_margin, w->total_lines / 4));
4807 4776
4808 set_marker_restricted_both (w->start, w->buffer, pos, pos_byte); 4777 set_marker_restricted_both (w->start, w->contents, pos, pos_byte);
4809 w->start_at_line_beg = !NILP (bolp); 4778 w->start_at_line_beg = !NILP (bolp);
4810 w->update_mode_line = 1; 4779 w->update_mode_line = 1;
4811 w->last_modified = 0; 4780 w->last_modified = 0;
@@ -4899,10 +4868,10 @@ scroll_command (Lisp_Object n, int direction)
4899 4868
4900 /* If selected window's buffer isn't current, make it current for 4869 /* If selected window's buffer isn't current, make it current for
4901 the moment. But don't screw up if window_scroll gets an error. */ 4870 the moment. But don't screw up if window_scroll gets an error. */
4902 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 4871 if (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer)
4903 { 4872 {
4904 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 4873 record_unwind_protect (save_excursion_restore, save_excursion_save ());
4905 Fset_buffer (XWINDOW (selected_window)->buffer); 4874 Fset_buffer (XWINDOW (selected_window)->contents);
4906 4875
4907 /* Make redisplay consider other windows than just selected_window. */ 4876 /* Make redisplay consider other windows than just selected_window. */
4908 ++windows_or_buffers_changed; 4877 ++windows_or_buffers_changed;
@@ -5017,7 +4986,7 @@ specifies the window to scroll. This takes precedence over
5017 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 4986 record_unwind_protect (save_excursion_restore, save_excursion_save ());
5018 ++windows_or_buffers_changed; 4987 ++windows_or_buffers_changed;
5019 4988
5020 Fset_buffer (w->buffer); 4989 Fset_buffer (w->contents);
5021 SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm)); 4990 SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm));
5022 4991
5023 if (NILP (arg)) 4992 if (NILP (arg))
@@ -5111,10 +5080,10 @@ displayed_window_lines (struct window *w)
5111 int bottom_y; 5080 int bottom_y;
5112 void *itdata = NULL; 5081 void *itdata = NULL;
5113 5082
5114 if (XBUFFER (w->buffer) != current_buffer) 5083 if (XBUFFER (w->contents) != current_buffer)
5115 { 5084 {
5116 old_buffer = current_buffer; 5085 old_buffer = current_buffer;
5117 set_buffer_internal (XBUFFER (w->buffer)); 5086 set_buffer_internal (XBUFFER (w->contents));
5118 } 5087 }
5119 else 5088 else
5120 old_buffer = NULL; 5089 old_buffer = NULL;
@@ -5176,7 +5145,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5176 (register Lisp_Object arg) 5145 (register Lisp_Object arg)
5177{ 5146{
5178 struct window *w = XWINDOW (selected_window); 5147 struct window *w = XWINDOW (selected_window);
5179 struct buffer *buf = XBUFFER (w->buffer); 5148 struct buffer *buf = XBUFFER (w->contents);
5180 struct buffer *obuf = current_buffer; 5149 struct buffer *obuf = current_buffer;
5181 int center_p = 0; 5150 int center_p = 0;
5182 ptrdiff_t charpos, bytepos; 5151 ptrdiff_t charpos, bytepos;
@@ -5342,7 +5311,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5342 } 5311 }
5343 5312
5344 /* Set the new window start. */ 5313 /* Set the new window start. */
5345 set_marker_both (w->start, w->buffer, charpos, bytepos); 5314 set_marker_both (w->start, w->contents, charpos, bytepos);
5346 w->window_end_valid = 0; 5315 w->window_end_valid = 0;
5347 5316
5348 w->optional_new_start = 1; 5317 w->optional_new_start = 1;
@@ -5386,9 +5355,8 @@ zero means top of window, negative means relative to bottom of window. */)
5386 int this_scroll_margin; 5355 int this_scroll_margin;
5387#endif 5356#endif
5388 5357
5389 if (!(BUFFERP (w->buffer) 5358 if (!(BUFFERP (w->contents) && XBUFFER (w->contents) == current_buffer))
5390 && XBUFFER (w->buffer) == current_buffer)) 5359 /* This test is needed to make sure PT/PT_BYTE make sense in w->contents
5391 /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer
5392 when passed below to set_marker_both. */ 5360 when passed below to set_marker_both. */
5393 error ("move-to-window-line called from unrelated buffer"); 5361 error ("move-to-window-line called from unrelated buffer");
5394 5362
@@ -5398,7 +5366,7 @@ zero means top of window, negative means relative to bottom of window. */)
5398 { 5366 {
5399 int height = window_internal_height (w); 5367 int height = window_internal_height (w);
5400 Fvertical_motion (make_number (- (height / 2)), window); 5368 Fvertical_motion (make_number (- (height / 2)), window);
5401 set_marker_both (w->start, w->buffer, PT, PT_BYTE); 5369 set_marker_both (w->start, w->contents, PT, PT_BYTE);
5402 w->start_at_line_beg = !NILP (Fbolp ()); 5370 w->start_at_line_beg = !NILP (Fbolp ());
5403 w->force_start = 1; 5371 w->force_start = 1;
5404 } 5372 }
@@ -5548,9 +5516,9 @@ the return value is nil. Otherwise the value is t. */)
5548 window-point of the final-selected-window to the window-point of 5516 window-point of the final-selected-window to the window-point of
5549 the current-selected-window. So we have to be careful which 5517 the current-selected-window. So we have to be careful which
5550 point of the current-buffer we copy into old_point. */ 5518 point of the current-buffer we copy into old_point. */
5551 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) 5519 if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer)
5552 && WINDOWP (selected_window) 5520 && WINDOWP (selected_window)
5553 && EQ (XWINDOW (selected_window)->buffer, new_current_buffer) 5521 && EQ (XWINDOW (selected_window)->contents, new_current_buffer)
5554 && !EQ (selected_window, data->current_window)) 5522 && !EQ (selected_window, data->current_window))
5555 old_point = marker_position (XWINDOW (data->current_window)->pointm); 5523 old_point = marker_position (XWINDOW (data->current_window)->pointm);
5556 else 5524 else
@@ -5564,7 +5532,7 @@ the return value is nil. Otherwise the value is t. */)
5564 So if possible we want this arbitrary choice of "which point" to 5532 So if possible we want this arbitrary choice of "which point" to
5565 be the one from the to-be-selected-window so as to prevent this 5533 be the one from the to-be-selected-window so as to prevent this
5566 window's cursor from being copied from another window. */ 5534 window's cursor from being copied from another window. */
5567 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) 5535 if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer)
5568 /* If current_window = selected_window, its point is in BUF_PT. */ 5536 /* If current_window = selected_window, its point is in BUF_PT. */
5569 && !EQ (selected_window, data->current_window)) 5537 && !EQ (selected_window, data->current_window))
5570 old_point = marker_position (XWINDOW (data->current_window)->pointm); 5538 old_point = marker_position (XWINDOW (data->current_window)->pointm);
@@ -5606,8 +5574,8 @@ the return value is nil. Otherwise the value is t. */)
5606 p = SAVED_WINDOW_N (saved_windows, k); 5574 p = SAVED_WINDOW_N (saved_windows, k);
5607 window = p->window; 5575 window = p->window;
5608 w = XWINDOW (window); 5576 w = XWINDOW (window);
5609 if (!NILP (w->buffer) 5577 if (BUFFERP (w->contents)
5610 && !EQ (w->buffer, p->buffer) 5578 && !EQ (w->contents, p->buffer)
5611 && BUFFER_LIVE_P (XBUFFER (p->buffer))) 5579 && BUFFER_LIVE_P (XBUFFER (p->buffer)))
5612 /* If a window we restore gets another buffer, record the 5580 /* If a window we restore gets another buffer, record the
5613 window's old buffer. */ 5581 window's old buffer. */
@@ -5640,13 +5608,13 @@ the return value is nil. Otherwise the value is t. */)
5640 window holds garbage.) We do this now, before 5608 window holds garbage.) We do this now, before
5641 restoring the window contents, and prevent it from 5609 restoring the window contents, and prevent it from
5642 being done later on when we select a new window. */ 5610 being done later on when we select a new window. */
5643 if (! NILP (XWINDOW (selected_window)->buffer)) 5611 if (! NILP (XWINDOW (selected_window)->contents))
5644 { 5612 {
5645 w = XWINDOW (selected_window); 5613 w = XWINDOW (selected_window);
5646 set_marker_both (w->pointm, 5614 set_marker_both (w->pointm,
5647 w->buffer, 5615 w->contents,
5648 BUF_PT (XBUFFER (w->buffer)), 5616 BUF_PT (XBUFFER (w->contents)),
5649 BUF_PT_BYTE (XBUFFER (w->buffer))); 5617 BUF_PT_BYTE (XBUFFER (w->contents)));
5650 } 5618 }
5651 5619
5652 windows_or_buffers_changed++; 5620 windows_or_buffers_changed++;
@@ -5693,18 +5661,10 @@ the return value is nil. Otherwise the value is t. */)
5693 { 5661 {
5694 wset_prev (w, Qnil); 5662 wset_prev (w, Qnil);
5695 if (!NILP (w->parent)) 5663 if (!NILP (w->parent))
5696 { 5664 wset_combination (XWINDOW (w->parent),
5697 if (XINT (p->total_cols) == XWINDOW (w->parent)->total_cols) 5665 (XINT (p->total_cols)
5698 { 5666 != XWINDOW (w->parent)->total_cols),
5699 wset_vchild (XWINDOW (w->parent), p->window); 5667 p->window);
5700 wset_hchild (XWINDOW (w->parent), Qnil);
5701 }
5702 else
5703 {
5704 wset_hchild (XWINDOW (w->parent), p->window);
5705 wset_vchild (XWINDOW (w->parent), Qnil);
5706 }
5707 }
5708 } 5668 }
5709 5669
5710 /* If we squirreled away the buffer, restore it now. */ 5670 /* If we squirreled away the buffer, restore it now. */
@@ -5753,20 +5713,16 @@ the return value is nil. Otherwise the value is t. */)
5753 w->last_modified = 0; 5713 w->last_modified = 0;
5754 w->last_overlay_modified = 0; 5714 w->last_overlay_modified = 0;
5755 5715
5756 /* Reinstall the saved buffer and pointers into it. */ 5716 if (BUFFERP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
5757 if (NILP (p->buffer))
5758 /* An internal window. */
5759 wset_buffer (w, p->buffer);
5760 else if (BUFFER_LIVE_P (XBUFFER (p->buffer)))
5761 /* If saved buffer is alive, install it. */ 5717 /* If saved buffer is alive, install it. */
5762 { 5718 {
5763 wset_buffer (w, p->buffer); 5719 wset_buffer (w, p->buffer);
5764 w->start_at_line_beg = !NILP (p->start_at_line_beg); 5720 w->start_at_line_beg = !NILP (p->start_at_line_beg);
5765 set_marker_restricted (w->start, p->start, w->buffer); 5721 set_marker_restricted (w->start, p->start, w->contents);
5766 set_marker_restricted (w->pointm, p->pointm, 5722 set_marker_restricted (w->pointm, p->pointm,
5767 w->buffer); 5723 w->contents);
5768 Fset_marker (BVAR (XBUFFER (w->buffer), mark), 5724 Fset_marker (BVAR (XBUFFER (w->contents), mark),
5769 p->mark, w->buffer); 5725 p->mark, w->contents);
5770 5726
5771 /* As documented in Fcurrent_window_configuration, don't 5727 /* As documented in Fcurrent_window_configuration, don't
5772 restore the location of point in the buffer which was 5728 restore the location of point in the buffer which was
@@ -5775,23 +5731,21 @@ the return value is nil. Otherwise the value is t. */)
5775 && XBUFFER (p->buffer) == current_buffer) 5731 && XBUFFER (p->buffer) == current_buffer)
5776 Fgoto_char (w->pointm); 5732 Fgoto_char (w->pointm);
5777 } 5733 }
5778 else if (!NILP (w->buffer) 5734 else if (BUFFERP (w->contents) && BUFFER_LIVE_P (XBUFFER (w->contents)))
5779 && BUFFER_LIVE_P (XBUFFER (w->buffer))) 5735 /* Keep window's old buffer; make sure the markers are real. */
5780 /* Keep window's old buffer; make sure the markers are 5736 {
5781 real. */ 5737 /* Set window markers at start of visible range. */
5782 { 5738 if (XMARKER (w->start)->buffer == 0)
5783 /* Set window markers at start of visible range. */ 5739 set_marker_restricted_both (w->start, w->contents, 0, 0);
5784 if (XMARKER (w->start)->buffer == 0) 5740 if (XMARKER (w->pointm)->buffer == 0)
5785 set_marker_restricted_both (w->start, w->buffer, 0, 0); 5741 set_marker_restricted_both
5786 if (XMARKER (w->pointm)->buffer == 0) 5742 (w->pointm, w->contents,
5787 set_marker_restricted_both 5743 BUF_PT (XBUFFER (w->contents)),
5788 (w->pointm, w->buffer, 5744 BUF_PT_BYTE (XBUFFER (w->contents)));
5789 BUF_PT (XBUFFER (w->buffer)), 5745 w->start_at_line_beg = 1;
5790 BUF_PT_BYTE (XBUFFER (w->buffer))); 5746 }
5791 w->start_at_line_beg = 1; 5747 else if (!NILP (w->start))
5792 } 5748 /* Leaf window has no live buffer, get one. */
5793 else
5794 /* Window has no live buffer, get one. */
5795 { 5749 {
5796 /* Get the buffer via other_buffer_safely in order to 5750 /* Get the buffer via other_buffer_safely in order to
5797 avoid showing an unimportant buffer and, if necessary, to 5751 avoid showing an unimportant buffer and, if necessary, to
@@ -5800,8 +5754,8 @@ the return value is nil. Otherwise the value is t. */)
5800 wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); 5754 wset_buffer (w, other_buffer_safely (Fcurrent_buffer ()));
5801 /* This will set the markers to beginning of visible 5755 /* This will set the markers to beginning of visible
5802 range. */ 5756 range. */
5803 set_marker_restricted_both (w->start, w->buffer, 0, 0); 5757 set_marker_restricted_both (w->start, w->contents, 0, 0);
5804 set_marker_restricted_both (w->pointm, w->buffer, 0, 0); 5758 set_marker_restricted_both (w->pointm, w->contents, 0, 0);
5805 w->start_at_line_beg = 1; 5759 w->start_at_line_beg = 1;
5806 if (!NILP (w->dedicated)) 5760 if (!NILP (w->dedicated))
5807 /* Record this window as dead. */ 5761 /* Record this window as dead. */
@@ -5814,17 +5768,17 @@ the return value is nil. Otherwise the value is t. */)
5814 fset_root_window (f, data->root_window); 5768 fset_root_window (f, data->root_window);
5815 /* Arrange *not* to restore point in the buffer that was 5769 /* Arrange *not* to restore point in the buffer that was
5816 current when the window configuration was saved. */ 5770 current when the window configuration was saved. */
5817 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) 5771 if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer))
5818 set_marker_restricted (XWINDOW (data->current_window)->pointm, 5772 set_marker_restricted (XWINDOW (data->current_window)->pointm,
5819 make_number (old_point), 5773 make_number (old_point),
5820 XWINDOW (data->current_window)->buffer); 5774 XWINDOW (data->current_window)->contents);
5821 5775
5822 /* In the following call to `select-window', prevent "swapping out 5776 /* In the following call to `select-window', prevent "swapping out
5823 point" in the old selected window using the buffer that has 5777 point" in the old selected window using the buffer that has
5824 been restored into it. We already swapped out that point from 5778 been restored into it. We already swapped out that point from
5825 that window's old buffer. */ 5779 that window's old buffer. */
5826 select_window (data->current_window, Qnil, 1); 5780 select_window (data->current_window, Qnil, 1);
5827 BVAR (XBUFFER (XWINDOW (selected_window)->buffer), last_selected_window) 5781 BVAR (XBUFFER (XWINDOW (selected_window)->contents), last_selected_window)
5828 = selected_window; 5782 = selected_window;
5829 5783
5830 if (NILP (data->focus_frame) 5784 if (NILP (data->focus_frame)
@@ -5851,14 +5805,9 @@ the return value is nil. Otherwise the value is t. */)
5851 /* Now, free glyph matrices in windows that were not reused. */ 5805 /* Now, free glyph matrices in windows that were not reused. */
5852 for (i = n = 0; i < n_leaf_windows; ++i) 5806 for (i = n = 0; i < n_leaf_windows; ++i)
5853 { 5807 {
5854 if (NILP (leaf_windows[i]->buffer)) 5808 if (NILP (leaf_windows[i]->contents))
5855 { 5809 free_window_matrices (leaf_windows[i]);
5856 /* Assert it's not reused as a combination. */ 5810 else if (EQ (leaf_windows[i]->contents, new_current_buffer))
5857 eassert (NILP (leaf_windows[i]->hchild)
5858 && NILP (leaf_windows[i]->vchild));
5859 free_window_matrices (leaf_windows[i]);
5860 }
5861 else if (EQ (leaf_windows[i]->buffer, new_current_buffer))
5862 ++n; 5811 ++n;
5863 } 5812 }
5864 5813
@@ -5889,7 +5838,7 @@ the return value is nil. Otherwise the value is t. */)
5889 Fset_buffer (new_current_buffer); 5838 Fset_buffer (new_current_buffer);
5890 /* If the new current buffer doesn't appear in the selected 5839 /* If the new current buffer doesn't appear in the selected
5891 window, go to its old point (see bug#12208). */ 5840 window, go to its old point (see bug#12208). */
5892 if (!EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) 5841 if (!EQ (XWINDOW (data->current_window)->contents, new_current_buffer))
5893 Fgoto_char (make_number (old_point)); 5842 Fgoto_char (make_number (old_point));
5894 } 5843 }
5895 5844
@@ -5900,8 +5849,10 @@ the return value is nil. Otherwise the value is t. */)
5900} 5849}
5901 5850
5902 5851
5903/* Recursively delete all child windows reachable via the next, vchild, 5852/* If WINDOW is an internal window, recursively delete all child windows
5904 and hchild slots of WINDOW. */ 5853 reachable via the next and contents slots of WINDOW. Otherwise setup
5854 WINDOW to not show any buffer. */
5855
5905void 5856void
5906delete_all_child_windows (Lisp_Object window) 5857delete_all_child_windows (Lisp_Object window)
5907{ 5858{
@@ -5913,17 +5864,12 @@ delete_all_child_windows (Lisp_Object window)
5913 /* Delete WINDOW's siblings (we traverse postorderly). */ 5864 /* Delete WINDOW's siblings (we traverse postorderly). */
5914 delete_all_child_windows (w->next); 5865 delete_all_child_windows (w->next);
5915 5866
5916 if (!NILP (w->vchild)) 5867 if (WINDOWP (w->contents))
5917 {
5918 delete_all_child_windows (w->vchild);
5919 wset_vchild (w, Qnil);
5920 }
5921 else if (!NILP (w->hchild))
5922 { 5868 {
5923 delete_all_child_windows (w->hchild); 5869 delete_all_child_windows (w->contents);
5924 wset_hchild (w, Qnil); 5870 wset_combination (w, 0, Qnil);
5925 } 5871 }
5926 else if (!NILP (w->buffer)) 5872 else if (BUFFERP (w->contents))
5927 { 5873 {
5928 unshow_buffer (w); 5874 unshow_buffer (w);
5929 unchain_marker (XMARKER (w->pointm)); 5875 unchain_marker (XMARKER (w->pointm));
@@ -5931,7 +5877,7 @@ delete_all_child_windows (Lisp_Object window)
5931 /* Since combination limit makes sense for an internal windows 5877 /* Since combination limit makes sense for an internal windows
5932 only, we use this slot to save the buffer for the sake of 5878 only, we use this slot to save the buffer for the sake of
5933 possible resurrection in Fset_window_configuration. */ 5879 possible resurrection in Fset_window_configuration. */
5934 wset_combination_limit (w, w->buffer); 5880 wset_combination_limit (w, w->contents);
5935 wset_buffer (w, Qnil); 5881 wset_buffer (w, Qnil);
5936 } 5882 }
5937 5883
@@ -5944,10 +5890,8 @@ count_windows (register struct window *window)
5944 register int count = 1; 5890 register int count = 1;
5945 if (!NILP (window->next)) 5891 if (!NILP (window->next))
5946 count += count_windows (XWINDOW (window->next)); 5892 count += count_windows (XWINDOW (window->next));
5947 if (!NILP (window->vchild)) 5893 if (WINDOWP (window->contents))
5948 count += count_windows (XWINDOW (window->vchild)); 5894 count += count_windows (XWINDOW (window->contents));
5949 if (!NILP (window->hchild))
5950 count += count_windows (XWINDOW (window->hchild));
5951 return count; 5895 return count;
5952} 5896}
5953 5897
@@ -5959,10 +5903,8 @@ get_leaf_windows (struct window *w, struct window **flat, int i)
5959{ 5903{
5960 while (w) 5904 while (w)
5961 { 5905 {
5962 if (!NILP (w->hchild)) 5906 if (WINDOWP (w->contents))
5963 i = get_leaf_windows (XWINDOW (w->hchild), flat, i); 5907 i = get_leaf_windows (XWINDOW (w->contents), flat, i);
5964 else if (!NILP (w->vchild))
5965 i = get_leaf_windows (XWINDOW (w->vchild), flat, i);
5966 else 5908 else
5967 flat[i++] = w; 5909 flat[i++] = w;
5968 5910
@@ -6018,14 +5960,14 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6018 register struct window *w; 5960 register struct window *w;
6019 register Lisp_Object tem, pers, par; 5961 register Lisp_Object tem, pers, par;
6020 5962
6021 for (;!NILP (window); window = w->next) 5963 for (; !NILP (window); window = w->next)
6022 { 5964 {
6023 p = SAVED_WINDOW_N (vector, i); 5965 p = SAVED_WINDOW_N (vector, i);
6024 w = XWINDOW (window); 5966 w = XWINDOW (window);
6025 5967
6026 wset_temslot (w, make_number (i)); i++; 5968 wset_temslot (w, make_number (i)); i++;
6027 p->window = window; 5969 p->window = window;
6028 p->buffer = w->buffer; 5970 p->buffer = (WINDOW_LEAF_P (w) ? w->contents : Qnil);
6029 p->left_col = make_number (w->left_col); 5971 p->left_col = make_number (w->left_col);
6030 p->top_line = make_number (w->top_line); 5972 p->top_line = make_number (w->top_line);
6031 p->total_cols = make_number (w->total_cols); 5973 p->total_cols = make_number (w->total_cols);
@@ -6092,15 +6034,15 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6092 } 6034 }
6093 } 6035 }
6094 6036
6095 if (!NILP (w->buffer)) 6037 if (BUFFERP (w->contents))
6096 { 6038 {
6097 /* Save w's value of point in the window configuration. If w 6039 /* Save w's value of point in the window configuration. If w
6098 is the selected window, then get the value of point from 6040 is the selected window, then get the value of point from
6099 the buffer; pointm is garbage in the selected window. */ 6041 the buffer; pointm is garbage in the selected window. */
6100 if (EQ (window, selected_window)) 6042 if (EQ (window, selected_window))
6101 p->pointm = build_marker (XBUFFER (w->buffer), 6043 p->pointm = build_marker (XBUFFER (w->contents),
6102 BUF_PT (XBUFFER (w->buffer)), 6044 BUF_PT (XBUFFER (w->contents)),
6103 BUF_PT_BYTE (XBUFFER (w->buffer))); 6045 BUF_PT_BYTE (XBUFFER (w->contents)));
6104 else 6046 else
6105 p->pointm = Fcopy_marker (w->pointm, Qnil); 6047 p->pointm = Fcopy_marker (w->pointm, Qnil);
6106 XMARKER (p->pointm)->insertion_type 6048 XMARKER (p->pointm)->insertion_type
@@ -6109,7 +6051,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6109 p->start = Fcopy_marker (w->start, Qnil); 6051 p->start = Fcopy_marker (w->start, Qnil);
6110 p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil; 6052 p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil;
6111 6053
6112 tem = BVAR (XBUFFER (w->buffer), mark); 6054 tem = BVAR (XBUFFER (w->contents), mark);
6113 p->mark = Fcopy_marker (tem, Qnil); 6055 p->mark = Fcopy_marker (tem, Qnil);
6114 } 6056 }
6115 else 6057 else
@@ -6130,10 +6072,8 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6130 else 6072 else
6131 p->prev = XWINDOW (w->prev)->temslot; 6073 p->prev = XWINDOW (w->prev)->temslot;
6132 6074
6133 if (!NILP (w->vchild)) 6075 if (WINDOWP (w->contents))
6134 i = save_window_save (w->vchild, vector, i); 6076 i = save_window_save (w->contents, vector, i);
6135 if (!NILP (w->hchild))
6136 i = save_window_save (w->hchild, vector, i);
6137 } 6077 }
6138 6078
6139 return i; 6079 return i;
@@ -6450,7 +6390,7 @@ If PIXELS-P is non-nil, the return value is VSCROLL. */)
6450 adjust_glyphs (f); 6390 adjust_glyphs (f);
6451 6391
6452 /* Prevent redisplay shortcuts. */ 6392 /* Prevent redisplay shortcuts. */
6453 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 6393 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
6454 } 6394 }
6455 } 6395 }
6456 6396
@@ -6484,10 +6424,8 @@ foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *u
6484 6424
6485 for (cont = 1; w && cont;) 6425 for (cont = 1; w && cont;)
6486 { 6426 {
6487 if (!NILP (w->hchild)) 6427 if (WINDOWP (w->contents))
6488 cont = foreach_window_1 (XWINDOW (w->hchild), fn, user_data); 6428 cont = foreach_window_1 (XWINDOW (w->contents), fn, user_data);
6489 else if (!NILP (w->vchild))
6490 cont = foreach_window_1 (XWINDOW (w->vchild), fn, user_data);
6491 else 6429 else
6492 cont = fn (w, user_data); 6430 cont = fn (w, user_data);
6493 6431
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
41this can be done implicitly). Combination windows can be created 41this can be done implicitly). Combination windows can be created
42and deleted at any time. 42and deleted at any time.
43 43
44A leaf window has a non-nil buffer field, and also 44A leaf window has a buffer stored in contents field and markers in its start
45 has markers in its start and pointm fields. Non-leaf windows 45and pointm fields. Non-leaf windows have nil in the latter two fields.
46 have nil in these fields.
47 46
48Non-leaf windows are either vertical or horizontal combinations. 47Non-leaf windows are either vertical or horizontal combinations.
49 48
50A vertical combination window has children that are arranged on the frame 49A vertical combination window has children that are arranged on the frame
51one above the next. Its vchild field points to the uppermost child. 50one above the next. Its contents field points to the uppermost child.
52The parent field of each of the children points to the vertical 51The parent field of each of the children points to the vertical
53combination window. The next field of each child points to the 52combination window. The next field of each child points to the
54child below it, or is nil for the lowest child. The prev field 53child 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
56highest child. 55highest child.
57 56
58A horizontal combination window has children that are side by side. 57A horizontal combination window has children that are side by side.
59Its hchild field points to the leftmost child. In each child 58Its contents field points to the leftmost child. In each child
60the next field points to the child to the right and the prev field 59the next field points to the child to the right and the prev field
61points to the child to the left. 60points to the child to the left.
62 61
@@ -78,7 +77,7 @@ the root window is the minibuf window. On minibufferless screens or
78minibuffer-only screens, the root window and the minibuffer window are 77minibuffer-only screens, the root window and the minibuffer window are
79one and the same, so its prev and next members are nil. 78one and the same, so its prev and next members are nil.
80 79
81A dead window has its buffer, hchild, and vchild windows all nil. */ 80A dead window has its contents field set to nil. */
82 81
83struct cursor_pos 82struct cursor_pos
84{ 83{
@@ -102,13 +101,6 @@ struct window
102 Lisp_Object next; 101 Lisp_Object next;
103 Lisp_Object prev; 102 Lisp_Object prev;
104 103
105 /* First child of this window: vchild is used if this is a vertical
106 combination, hchild if this is a horizontal combination. Of the
107 fields vchild, hchild and buffer, one and only one is non-nil
108 unless the window is dead. */
109 Lisp_Object hchild;
110 Lisp_Object vchild;
111
112 /* The window this one is a child of. */ 104 /* The window this one is a child of. */
113 Lisp_Object parent; 105 Lisp_Object parent;
114 106
@@ -123,10 +115,8 @@ struct window
123 Lisp_Object new_total; 115 Lisp_Object new_total;
124 Lisp_Object new_normal; 116 Lisp_Object new_normal;
125 117
126 /* The buffer displayed in this window. Of the fields vchild, 118 /* May be buffer, window, or nil. */
127 hchild and buffer, one and only one is non-nil unless the window 119 Lisp_Object contents;
128 is dead. */
129 Lisp_Object buffer;
130 120
131 /* A marker pointing to where in the text to start displaying. 121 /* A marker pointing to where in the text to start displaying.
132 BIDI Note: This is the _logical-order_ start, i.e. the smallest 122 BIDI Note: This is the _logical-order_ start, i.e. the smallest
@@ -282,6 +272,10 @@ struct window
282 /* Non-zero if this window is a minibuffer window. */ 272 /* Non-zero if this window is a minibuffer window. */
283 unsigned mini : 1; 273 unsigned mini : 1;
284 274
275 /* Meaningful only if contents is a window, non-zero if this
276 internal window is used in horizontal combination. */
277 unsigned horizontal : 1;
278
285 /* Non-zero means must regenerate mode line of this window. */ 279 /* Non-zero means must regenerate mode line of this window. */
286 unsigned update_mode_line : 1; 280 unsigned update_mode_line : 1;
287 281
@@ -428,6 +422,21 @@ wset_next_buffers (struct window *w, Lisp_Object val)
428 422
429/* A handy macro. */ 423/* A handy macro. */
430 424
425/* Non-zero if W is leaf (carry the buffer). */
426
427#define WINDOW_LEAF_P(W) \
428 (BUFFERP ((W)->contents))
429
430/* Non-zero if W is a member of horizontal combination. */
431
432#define WINDOW_HORIZONTAL_COMBINATION_P(W) \
433 (WINDOWP ((W)->contents) && (W)->horizontal)
434
435/* Non-zero if W is a member of vertical combination. */
436
437#define WINDOW_VERTICAL_COMBINATION_P(W) \
438 (WINDOWP ((W)->contents) && !(W)->horizontal)
439
431#define WINDOW_XFRAME(W) \ 440#define WINDOW_XFRAME(W) \
432 (XFRAME (WINDOW_FRAME ((W)))) 441 (XFRAME (WINDOW_FRAME ((W))))
433 442
@@ -931,20 +940,17 @@ extern void check_frame_size (struct frame *frame, int *rows, int *cols);
931struct glyph *get_phys_cursor_glyph (struct window *w); 940struct glyph *get_phys_cursor_glyph (struct window *w);
932 941
933/* Value is non-zero if WINDOW is a valid window. */ 942/* Value is non-zero if WINDOW is a valid window. */
934#define WINDOW_VALID_P(WINDOW) \ 943#define WINDOW_VALID_P(WINDOW) \
935 (WINDOWP (WINDOW) \ 944 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->contents)) \
936 && (!NILP (XWINDOW (WINDOW)->buffer) \ 945
937 || !NILP (XWINDOW (WINDOW)->vchild) \ 946/* A window of any sort, leaf or interior, is "valid" if its
938 || !NILP (XWINDOW (WINDOW)->hchild))) 947 contents slot is non-nil. */
939
940/* A window of any sort, leaf or interior, is "valid" if one
941 of its buffer, vchild, or hchild members is non-nil. */
942#define CHECK_VALID_WINDOW(WINDOW) \ 948#define CHECK_VALID_WINDOW(WINDOW) \
943 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW) 949 CHECK_TYPE (WINDOW_VALID_P (WINDOW), Qwindow_valid_p, WINDOW)
944 950
945/* Value is non-zero if WINDOW is a live window. */ 951/* Value is non-zero if WINDOW is a live window. */
946#define WINDOW_LIVE_P(WINDOW) \ 952#define WINDOW_LIVE_P(WINDOW) \
947 (WINDOWP (WINDOW) && !NILP (XWINDOW (WINDOW)->buffer)) 953 (WINDOWP (WINDOW) && BUFFERP (XWINDOW (WINDOW)->contents))
948 954
949/* A window is "live" if and only if it shows a buffer. */ 955/* A window is "live" if and only if it shows a buffer. */
950#define CHECK_LIVE_WINDOW(WINDOW) \ 956#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,
1283 if (FRAME_INITIAL_P (XFRAME (WINDOW_FRAME (w)))) 1283 if (FRAME_INITIAL_P (XFRAME (WINDOW_FRAME (w))))
1284 return visible_p; 1284 return visible_p;
1285 1285
1286 if (XBUFFER (w->buffer) != current_buffer) 1286 if (XBUFFER (w->contents) != current_buffer)
1287 { 1287 {
1288 old_buffer = current_buffer; 1288 old_buffer = current_buffer;
1289 set_buffer_internal_1 (XBUFFER (w->buffer)); 1289 set_buffer_internal_1 (XBUFFER (w->contents));
1290 } 1290 }
1291 1291
1292 SET_TEXT_POS_FROM_MARKER (top, w->start); 1292 SET_TEXT_POS_FROM_MARKER (top, w->start);
@@ -4458,7 +4458,7 @@ handle_display_prop (struct it *it)
4458 if it was a text property. */ 4458 if it was a text property. */
4459 4459
4460 if (!STRINGP (it->string)) 4460 if (!STRINGP (it->string))
4461 object = it->w->buffer; 4461 object = it->w->contents;
4462 4462
4463 display_replaced_p = handle_display_spec (it, propval, object, overlay, 4463 display_replaced_p = handle_display_spec (it, propval, object, overlay,
4464 position, bufpos, 4464 position, bufpos,
@@ -4866,7 +4866,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
4866 it->what = IT_IMAGE; 4866 it->what = IT_IMAGE;
4867 it->image_id = -1; /* no image */ 4867 it->image_id = -1; /* no image */
4868 it->position = start_pos; 4868 it->position = start_pos;
4869 it->object = NILP (object) ? it->w->buffer : object; 4869 it->object = NILP (object) ? it->w->contents : object;
4870 it->method = GET_FROM_IMAGE; 4870 it->method = GET_FROM_IMAGE;
4871 it->from_overlay = Qnil; 4871 it->from_overlay = Qnil;
4872 it->face_id = face_id; 4872 it->face_id = face_id;
@@ -5012,7 +5012,7 @@ handle_single_display_spec (struct it *it, Lisp_Object spec, Lisp_Object object,
5012 it->what = IT_IMAGE; 5012 it->what = IT_IMAGE;
5013 it->image_id = lookup_image (it->f, value); 5013 it->image_id = lookup_image (it->f, value);
5014 it->position = start_pos; 5014 it->position = start_pos;
5015 it->object = NILP (object) ? it->w->buffer : object; 5015 it->object = NILP (object) ? it->w->contents : object;
5016 it->method = GET_FROM_IMAGE; 5016 it->method = GET_FROM_IMAGE;
5017 5017
5018 /* Say that we haven't consumed the characters with 5018 /* Say that we haven't consumed the characters with
@@ -5836,7 +5836,7 @@ pop_it (struct it *it)
5836 it->object = p->u.stretch.object; 5836 it->object = p->u.stretch.object;
5837 break; 5837 break;
5838 case GET_FROM_BUFFER: 5838 case GET_FROM_BUFFER:
5839 it->object = it->w->buffer; 5839 it->object = it->w->contents;
5840 break; 5840 break;
5841 case GET_FROM_STRING: 5841 case GET_FROM_STRING:
5842 it->object = it->string; 5842 it->object = it->string;
@@ -5849,7 +5849,7 @@ pop_it (struct it *it)
5849 else 5849 else
5850 { 5850 {
5851 it->method = GET_FROM_BUFFER; 5851 it->method = GET_FROM_BUFFER;
5852 it->object = it->w->buffer; 5852 it->object = it->w->contents;
5853 } 5853 }
5854 } 5854 }
5855 it->end_charpos = p->end_charpos; 5855 it->end_charpos = p->end_charpos;
@@ -6290,7 +6290,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
6290 IT_STRING_BYTEPOS (*it) = -1; 6290 IT_STRING_BYTEPOS (*it) = -1;
6291 it->string = Qnil; 6291 it->string = Qnil;
6292 it->method = GET_FROM_BUFFER; 6292 it->method = GET_FROM_BUFFER;
6293 it->object = it->w->buffer; 6293 it->object = it->w->contents;
6294 it->area = TEXT_AREA; 6294 it->area = TEXT_AREA;
6295 it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 6295 it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters));
6296 it->sp = 0; 6296 it->sp = 0;
@@ -7141,7 +7141,7 @@ set_iterator_to_next (struct it *it, int reseat_p)
7141 else 7141 else
7142 { 7142 {
7143 it->method = GET_FROM_BUFFER; 7143 it->method = GET_FROM_BUFFER;
7144 it->object = it->w->buffer; 7144 it->object = it->w->contents;
7145 } 7145 }
7146 7146
7147 it->dpvec = NULL; 7147 it->dpvec = NULL;
@@ -7714,7 +7714,7 @@ next_element_from_ellipsis (struct it *it)
7714 setting face_before_selective_p. */ 7714 setting face_before_selective_p. */
7715 it->saved_face_id = it->face_id; 7715 it->saved_face_id = it->face_id;
7716 it->method = GET_FROM_BUFFER; 7716 it->method = GET_FROM_BUFFER;
7717 it->object = it->w->buffer; 7717 it->object = it->w->contents;
7718 reseat_at_next_visible_line_start (it, 1); 7718 reseat_at_next_visible_line_start (it, 1);
7719 it->face_before_selective_p = 1; 7719 it->face_before_selective_p = 1;
7720 } 7720 }
@@ -7978,7 +7978,7 @@ next_element_from_buffer (struct it *it)
7978 7978
7979 /* Record what we have and where it came from. */ 7979 /* Record what we have and where it came from. */
7980 it->what = IT_CHARACTER; 7980 it->what = IT_CHARACTER;
7981 it->object = it->w->buffer; 7981 it->object = it->w->contents;
7982 it->position = it->current.pos; 7982 it->position = it->current.pos;
7983 7983
7984 /* Normally we return the character found above, except when we 7984 /* Normally we return the character found above, except when we
@@ -8084,7 +8084,7 @@ next_element_from_composition (struct it *it)
8084 return 0; 8084 return 0;
8085 } 8085 }
8086 it->position = it->current.pos; 8086 it->position = it->current.pos;
8087 it->object = it->w->buffer; 8087 it->object = it->w->contents;
8088 it->c = composition_update_it (&it->cmp_it, IT_CHARPOS (*it), 8088 it->c = composition_update_it (&it->cmp_it, IT_CHARPOS (*it),
8089 IT_BYTEPOS (*it), Qnil); 8089 IT_BYTEPOS (*it), Qnil);
8090 } 8090 }
@@ -10003,7 +10003,7 @@ with_echo_area_buffer_unwind_data (struct window *w)
10003 if (w) 10003 if (w)
10004 { 10004 {
10005 XSETWINDOW (tmp, w); ASET (vector, i, tmp); ++i; 10005 XSETWINDOW (tmp, w); ASET (vector, i, tmp); ++i;
10006 ASET (vector, i, w->buffer); ++i; 10006 ASET (vector, i, w->contents); ++i;
10007 ASET (vector, i, make_number (marker_position (w->pointm))); ++i; 10007 ASET (vector, i, make_number (marker_position (w->pointm))); ++i;
10008 ASET (vector, i, make_number (marker_byte_position (w->pointm))); ++i; 10008 ASET (vector, i, make_number (marker_byte_position (w->pointm))); ++i;
10009 ASET (vector, i, make_number (marker_position (w->start))); ++i; 10009 ASET (vector, i, make_number (marker_position (w->start))); ++i;
@@ -10259,9 +10259,9 @@ resize_mini_window (struct window *w, int exact_p)
10259 eassert (MINI_WINDOW_P (w)); 10259 eassert (MINI_WINDOW_P (w));
10260 10260
10261 /* By default, start display at the beginning. */ 10261 /* By default, start display at the beginning. */
10262 set_marker_both (w->start, w->buffer, 10262 set_marker_both (w->start, w->contents,
10263 BUF_BEGV (XBUFFER (w->buffer)), 10263 BUF_BEGV (XBUFFER (w->contents)),
10264 BUF_BEGV_BYTE (XBUFFER (w->buffer))); 10264 BUF_BEGV_BYTE (XBUFFER (w->contents)));
10265 10265
10266 /* Don't resize windows while redisplaying a window; it would 10266 /* Don't resize windows while redisplaying a window; it would
10267 confuse redisplay functions when the size of the window they are 10267 confuse redisplay functions when the size of the window they are
@@ -10288,10 +10288,10 @@ resize_mini_window (struct window *w, int exact_p)
10288 struct text_pos start; 10288 struct text_pos start;
10289 struct buffer *old_current_buffer = NULL; 10289 struct buffer *old_current_buffer = NULL;
10290 10290
10291 if (current_buffer != XBUFFER (w->buffer)) 10291 if (current_buffer != XBUFFER (w->contents))
10292 { 10292 {
10293 old_current_buffer = current_buffer; 10293 old_current_buffer = current_buffer;
10294 set_buffer_internal (XBUFFER (w->buffer)); 10294 set_buffer_internal (XBUFFER (w->contents));
10295 } 10295 }
10296 10296
10297 init_iterator (&it, w, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID); 10297 init_iterator (&it, w, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID);
@@ -10740,7 +10740,7 @@ buffer_shared_and_changed (void)
10740 10740
10741/* Nonzero if W doesn't reflect the actual state of current buffer due 10741/* Nonzero if W doesn't reflect the actual state of current buffer due
10742 to its text or overlays change. FIXME: this may be called when 10742 to its text or overlays change. FIXME: this may be called when
10743 XBUFFER (w->buffer) != current_buffer, which looks suspicious. */ 10743 XBUFFER (w->contents) != current_buffer, which looks suspicious. */
10744 10744
10745static int 10745static int
10746window_outdated (struct window *w) 10746window_outdated (struct window *w)
@@ -10755,7 +10755,7 @@ window_outdated (struct window *w)
10755static int 10755static int
10756window_buffer_changed (struct window *w) 10756window_buffer_changed (struct window *w)
10757{ 10757{
10758 struct buffer *b = XBUFFER (w->buffer); 10758 struct buffer *b = XBUFFER (w->contents);
10759 10759
10760 eassert (BUFFER_LIVE_P (b)); 10760 eassert (BUFFER_LIVE_P (b));
10761 10761
@@ -11009,7 +11009,7 @@ x_consider_frame_title (Lisp_Object frame)
11009 11009
11010 Fselect_window (f->selected_window, Qt); 11010 Fselect_window (f->selected_window, Qt);
11011 set_buffer_internal_1 11011 set_buffer_internal_1
11012 (XBUFFER (XWINDOW (f->selected_window)->buffer)); 11012 (XBUFFER (XWINDOW (f->selected_window)->contents));
11013 fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; 11013 fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format;
11014 11014
11015 mode_line_target = MODE_LINE_TITLE; 11015 mode_line_target = MODE_LINE_TITLE;
@@ -11128,7 +11128,7 @@ prepare_menu_bars (void)
11128 if (windows_or_buffers_changed 11128 if (windows_or_buffers_changed
11129 && FRAME_NS_P (f)) 11129 && FRAME_NS_P (f))
11130 ns_set_doc_edited 11130 ns_set_doc_edited
11131 (f, Fbuffer_modified_p (XWINDOW (f->selected_window)->buffer)); 11131 (f, Fbuffer_modified_p (XWINDOW (f->selected_window)->contents));
11132#endif 11132#endif
11133 UNGCPRO; 11133 UNGCPRO;
11134 } 11134 }
@@ -11200,7 +11200,7 @@ update_menu_bar (struct frame *f, int save_match_data, int hooks_run)
11200 11200
11201 specbind (Qinhibit_menubar_update, Qt); 11201 specbind (Qinhibit_menubar_update, Qt);
11202 11202
11203 set_buffer_internal_1 (XBUFFER (w->buffer)); 11203 set_buffer_internal_1 (XBUFFER (w->contents));
11204 if (save_match_data) 11204 if (save_match_data)
11205 record_unwind_save_match_data (); 11205 record_unwind_save_match_data ();
11206 if (NILP (Voverriding_local_map_menu_flag)) 11206 if (NILP (Voverriding_local_map_menu_flag))
@@ -11404,7 +11404,7 @@ update_tool_bar (struct frame *f, int save_match_data)
11404 /* Set current_buffer to the buffer of the selected 11404 /* Set current_buffer to the buffer of the selected
11405 window of the frame, so that we get the right local 11405 window of the frame, so that we get the right local
11406 keymaps. */ 11406 keymaps. */
11407 set_buffer_internal_1 (XBUFFER (w->buffer)); 11407 set_buffer_internal_1 (XBUFFER (w->contents));
11408 11408
11409 /* Save match data, if we must. */ 11409 /* Save match data, if we must. */
11410 if (save_match_data) 11410 if (save_match_data)
@@ -12271,10 +12271,8 @@ hscroll_window_tree (Lisp_Object window)
12271 { 12271 {
12272 struct window *w = XWINDOW (window); 12272 struct window *w = XWINDOW (window);
12273 12273
12274 if (WINDOWP (w->hchild)) 12274 if (WINDOWP (w->contents))
12275 hscrolled_p |= hscroll_window_tree (w->hchild); 12275 hscrolled_p |= hscroll_window_tree (w->contents);
12276 else if (WINDOWP (w->vchild))
12277 hscrolled_p |= hscroll_window_tree (w->vchild);
12278 else if (w->cursor.vpos >= 0) 12276 else if (w->cursor.vpos >= 0)
12279 { 12277 {
12280 int h_margin; 12278 int h_margin;
@@ -12294,7 +12292,7 @@ hscroll_window_tree (Lisp_Object window)
12294 /* Scroll when cursor is inside this scroll margin. */ 12292 /* Scroll when cursor is inside this scroll margin. */
12295 h_margin = hscroll_margin * WINDOW_FRAME_COLUMN_WIDTH (w); 12293 h_margin = hscroll_margin * WINDOW_FRAME_COLUMN_WIDTH (w);
12296 12294
12297 if (!NILP (Fbuffer_local_value (Qauto_hscroll_mode, w->buffer)) 12295 if (!NILP (Fbuffer_local_value (Qauto_hscroll_mode, w->contents))
12298 /* For left-to-right rows, hscroll when cursor is either 12296 /* For left-to-right rows, hscroll when cursor is either
12299 (i) inside the right hscroll margin, or (ii) if it is 12297 (i) inside the right hscroll margin, or (ii) if it is
12300 inside the left margin and the window is already 12298 inside the left margin and the window is already
@@ -12329,7 +12327,7 @@ hscroll_window_tree (Lisp_Object window)
12329 12327
12330 /* Find point in a display of infinite width. */ 12328 /* Find point in a display of infinite width. */
12331 saved_current_buffer = current_buffer; 12329 saved_current_buffer = current_buffer;
12332 current_buffer = XBUFFER (w->buffer); 12330 current_buffer = XBUFFER (w->contents);
12333 12331
12334 if (w == XWINDOW (selected_window)) 12332 if (w == XWINDOW (selected_window))
12335 pt = PT; 12333 pt = PT;
@@ -12382,7 +12380,7 @@ hscroll_window_tree (Lisp_Object window)
12382 redisplay. */ 12380 redisplay. */
12383 if (w->hscroll != hscroll) 12381 if (w->hscroll != hscroll)
12384 { 12382 {
12385 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 12383 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
12386 w->hscroll = hscroll; 12384 w->hscroll = hscroll;
12387 hscrolled_p = 1; 12385 hscrolled_p = 1;
12388 } 12386 }
@@ -12471,9 +12469,9 @@ debug_method_add (struct window *w, char const *fmt, ...)
12471 if (trace_redisplay_p) 12469 if (trace_redisplay_p)
12472 fprintf (stderr, "%p (%s): %s\n", 12470 fprintf (stderr, "%p (%s): %s\n",
12473 w, 12471 w,
12474 ((BUFFERP (w->buffer) 12472 ((BUFFERP (w->contents)
12475 && STRINGP (BVAR (XBUFFER (w->buffer), name))) 12473 && STRINGP (BVAR (XBUFFER (w->contents), name)))
12476 ? SSDATA (BVAR (XBUFFER (w->buffer), name)) 12474 ? SSDATA (BVAR (XBUFFER (w->contents), name))
12477 : "no buffer"), 12475 : "no buffer"),
12478 method + len); 12476 method + len);
12479} 12477}
@@ -12537,8 +12535,8 @@ text_outside_line_unchanged_p (struct window *w,
12537 require to redisplay the whole paragraph. It might be worthwhile 12535 require to redisplay the whole paragraph. It might be worthwhile
12538 to find the paragraph limits and widen the range of redisplayed 12536 to find the paragraph limits and widen the range of redisplayed
12539 lines to that, but for now just give up this optimization. */ 12537 lines to that, but for now just give up this optimization. */
12540 if (!NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering)) 12538 if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
12541 && NILP (BVAR (XBUFFER (w->buffer), bidi_paragraph_direction))) 12539 && NILP (BVAR (XBUFFER (w->contents), bidi_paragraph_direction)))
12542 unchanged_p = 0; 12540 unchanged_p = 0;
12543 } 12541 }
12544 12542
@@ -12761,7 +12759,7 @@ reconsider_clip_changes (struct window *w, struct buffer *b)
12761 we set b->clip_changed to 1 to force updating the screen. If 12759 we set b->clip_changed to 1 to force updating the screen. If
12762 b->clip_changed has already been set to 1, we can skip this 12760 b->clip_changed has already been set to 1, we can skip this
12763 check. */ 12761 check. */
12764 if (!b->clip_changed && BUFFERP (w->buffer) && w->window_end_valid) 12762 if (!b->clip_changed && BUFFERP (w->contents) && w->window_end_valid)
12765 { 12763 {
12766 ptrdiff_t pt; 12764 ptrdiff_t pt;
12767 12765
@@ -12770,11 +12768,11 @@ reconsider_clip_changes (struct window *w, struct buffer *b)
12770 else 12768 else
12771 pt = marker_position (w->pointm); 12769 pt = marker_position (w->pointm);
12772 12770
12773 if ((w->current_matrix->buffer != XBUFFER (w->buffer) 12771 if ((w->current_matrix->buffer != XBUFFER (w->contents)
12774 || pt != w->last_point) 12772 || pt != w->last_point)
12775 && check_point_in_composition (w->current_matrix->buffer, 12773 && check_point_in_composition (w->current_matrix->buffer,
12776 w->last_point, 12774 w->last_point,
12777 XBUFFER (w->buffer), pt)) 12775 XBUFFER (w->contents), pt))
12778 b->clip_changed = 1; 12776 b->clip_changed = 1;
12779 } 12777 }
12780} 12778}
@@ -13029,11 +13027,11 @@ redisplay_internal (void)
13029 the whole window. The assignment to this_line_start_pos prevents 13027 the whole window. The assignment to this_line_start_pos prevents
13030 the optimization directly below this if-statement. */ 13028 the optimization directly below this if-statement. */
13031 if (((!NILP (Vtransient_mark_mode) 13029 if (((!NILP (Vtransient_mark_mode)
13032 && !NILP (BVAR (XBUFFER (w->buffer), mark_active))) 13030 && !NILP (BVAR (XBUFFER (w->contents), mark_active)))
13033 != (w->region_showing > 0)) 13031 != (w->region_showing > 0))
13034 || (w->region_showing 13032 || (w->region_showing
13035 && w->region_showing 13033 && w->region_showing
13036 != XINT (Fmarker_position (BVAR (XBUFFER (w->buffer), mark))))) 13034 != XINT (Fmarker_position (BVAR (XBUFFER (w->contents), mark)))))
13037 CHARPOS (this_line_start_pos) = 0; 13035 CHARPOS (this_line_start_pos) = 0;
13038 13036
13039 /* Optimize the case that only the line containing the cursor in the 13037 /* Optimize the case that only the line containing the cursor in the
@@ -13051,7 +13049,7 @@ redisplay_internal (void)
13051 && !FRAME_OBSCURED_P (XFRAME (w->frame)) 13049 && !FRAME_OBSCURED_P (XFRAME (w->frame))
13052 /* Make sure recorded data applies to current buffer, etc. */ 13050 /* Make sure recorded data applies to current buffer, etc. */
13053 && this_line_buffer == current_buffer 13051 && this_line_buffer == current_buffer
13054 && current_buffer == XBUFFER (w->buffer) 13052 && current_buffer == XBUFFER (w->contents)
13055 && !w->force_start 13053 && !w->force_start
13056 && !w->optional_new_start 13054 && !w->optional_new_start
13057 /* Point must be on the line that we have info recorded about. */ 13055 /* Point must be on the line that we have info recorded about. */
@@ -13342,7 +13340,7 @@ redisplay_internal (void)
13342 Lisp_Object mini_window = FRAME_MINIBUF_WINDOW (sf); 13340 Lisp_Object mini_window = FRAME_MINIBUF_WINDOW (sf);
13343 struct frame *mini_frame; 13341 struct frame *mini_frame;
13344 13342
13345 displayed_buffer = XBUFFER (XWINDOW (selected_window)->buffer); 13343 displayed_buffer = XBUFFER (XWINDOW (selected_window)->contents);
13346 /* Use list_of_error, not Qerror, so that 13344 /* Use list_of_error, not Qerror, so that
13347 we catch only errors and don't run the debugger. */ 13345 we catch only errors and don't run the debugger. */
13348 internal_condition_case_1 (redisplay_window_1, selected_window, 13346 internal_condition_case_1 (redisplay_window_1, selected_window,
@@ -13552,7 +13550,7 @@ unwind_redisplay (Lisp_Object old_frame)
13552static void 13550static void
13553mark_window_display_accurate_1 (struct window *w, int accurate_p) 13551mark_window_display_accurate_1 (struct window *w, int accurate_p)
13554{ 13552{
13555 struct buffer *b = XBUFFER (w->buffer); 13553 struct buffer *b = XBUFFER (w->contents);
13556 13554
13557 w->last_modified = accurate_p ? BUF_MODIFF (b) : 0; 13555 w->last_modified = accurate_p ? BUF_MODIFF (b) : 0;
13558 w->last_overlay_modified = accurate_p ? BUF_OVERLAY_MODIFF (b) : 0; 13556 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)
13599 for (; !NILP (window); window = w->next) 13597 for (; !NILP (window); window = w->next)
13600 { 13598 {
13601 w = XWINDOW (window); 13599 w = XWINDOW (window);
13602 if (!NILP (w->vchild)) 13600 if (WINDOWP (w->contents))
13603 mark_window_display_accurate (w->vchild, accurate_p); 13601 mark_window_display_accurate (w->contents, accurate_p);
13604 else if (!NILP (w->hchild)) 13602 else
13605 mark_window_display_accurate (w->hchild, accurate_p);
13606 else if (BUFFERP (w->buffer))
13607 mark_window_display_accurate_1 (w, accurate_p); 13603 mark_window_display_accurate_1 (w, accurate_p);
13608 } 13604 }
13609 13605
@@ -13660,13 +13656,11 @@ redisplay_windows (Lisp_Object window)
13660 { 13656 {
13661 struct window *w = XWINDOW (window); 13657 struct window *w = XWINDOW (window);
13662 13658
13663 if (!NILP (w->hchild)) 13659 if (WINDOWP (w->contents))
13664 redisplay_windows (w->hchild); 13660 redisplay_windows (w->contents);
13665 else if (!NILP (w->vchild)) 13661 else if (BUFFERP (w->contents))
13666 redisplay_windows (w->vchild);
13667 else if (!NILP (w->buffer))
13668 { 13662 {
13669 displayed_buffer = XBUFFER (w->buffer); 13663 displayed_buffer = XBUFFER (w->contents);
13670 /* Use list_of_error, not Qerror, so that 13664 /* Use list_of_error, not Qerror, so that
13671 we catch only errors and don't run the debugger. */ 13665 we catch only errors and don't run the debugger. */
13672 internal_condition_case_1 (redisplay_window_0, window, 13666 internal_condition_case_1 (redisplay_window_0, window,
@@ -14313,7 +14307,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
14313 && !MATRIX_ROW_CONTINUATION_LINE_P (row) 14307 && !MATRIX_ROW_CONTINUATION_LINE_P (row)
14314 && row->x == 0) 14308 && row->x == 0)
14315 { 14309 {
14316 this_line_buffer = XBUFFER (w->buffer); 14310 this_line_buffer = XBUFFER (w->contents);
14317 14311
14318 CHARPOS (this_line_start_pos) 14312 CHARPOS (this_line_start_pos)
14319 = MATRIX_ROW_START_CHARPOS (row) + delta; 14313 = MATRIX_ROW_START_CHARPOS (row) + delta;
@@ -14349,7 +14343,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp)
14349 struct window *w = XWINDOW (window); 14343 struct window *w = XWINDOW (window);
14350 SET_MARKER_FROM_TEXT_POS (w->start, startp); 14344 SET_MARKER_FROM_TEXT_POS (w->start, startp);
14351 14345
14352 if (current_buffer != XBUFFER (w->buffer)) 14346 if (current_buffer != XBUFFER (w->contents))
14353 emacs_abort (); 14347 emacs_abort ();
14354 14348
14355 if (!NILP (Vwindow_scroll_functions)) 14349 if (!NILP (Vwindow_scroll_functions))
@@ -14358,7 +14352,7 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp)
14358 make_number (CHARPOS (startp))); 14352 make_number (CHARPOS (startp)));
14359 SET_TEXT_POS_FROM_MARKER (startp, w->start); 14353 SET_TEXT_POS_FROM_MARKER (startp, w->start);
14360 /* In case the hook functions switch buffers. */ 14354 /* In case the hook functions switch buffers. */
14361 set_buffer_internal (XBUFFER (w->buffer)); 14355 set_buffer_internal (XBUFFER (w->contents));
14362 } 14356 }
14363 14357
14364 return startp; 14358 return startp;
@@ -15009,7 +15003,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
15009 must_scroll = 1; 15003 must_scroll = 1;
15010 } 15004 }
15011 else if (rc != CURSOR_MOVEMENT_SUCCESS 15005 else if (rc != CURSOR_MOVEMENT_SUCCESS
15012 && !NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering))) 15006 && !NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
15013 { 15007 {
15014 struct glyph_row *row1; 15008 struct glyph_row *row1;
15015 15009
@@ -15072,7 +15066,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
15072 else if (scroll_p) 15066 else if (scroll_p)
15073 rc = CURSOR_MOVEMENT_MUST_SCROLL; 15067 rc = CURSOR_MOVEMENT_MUST_SCROLL;
15074 else if (rc != CURSOR_MOVEMENT_SUCCESS 15068 else if (rc != CURSOR_MOVEMENT_SUCCESS
15075 && !NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering))) 15069 && !NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
15076 { 15070 {
15077 /* With bidi-reordered rows, there could be more than 15071 /* With bidi-reordered rows, there could be more than
15078 one candidate row whose start and end positions 15072 one candidate row whose start and end positions
@@ -15179,7 +15173,7 @@ set_vertical_scroll_bar (struct window *w)
15179 || (w == XWINDOW (minibuf_window) 15173 || (w == XWINDOW (minibuf_window)
15180 && NILP (echo_area_buffer[0]))) 15174 && NILP (echo_area_buffer[0])))
15181 { 15175 {
15182 struct buffer *buf = XBUFFER (w->buffer); 15176 struct buffer *buf = XBUFFER (w->contents);
15183 whole = BUF_ZV (buf) - BUF_BEGV (buf); 15177 whole = BUF_ZV (buf) - BUF_BEGV (buf);
15184 start = marker_position (w->start) - BUF_BEGV (buf); 15178 start = marker_position (w->start) - BUF_BEGV (buf);
15185 /* I don't think this is guaranteed to be right. For the 15179 /* 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)
15213{ 15207{
15214 struct window *w = XWINDOW (window); 15208 struct window *w = XWINDOW (window);
15215 struct frame *f = XFRAME (w->frame); 15209 struct frame *f = XFRAME (w->frame);
15216 struct buffer *buffer = XBUFFER (w->buffer); 15210 struct buffer *buffer = XBUFFER (w->contents);
15217 struct buffer *old = current_buffer; 15211 struct buffer *old = current_buffer;
15218 struct text_pos lpoint, opoint, startp; 15212 struct text_pos lpoint, opoint, startp;
15219 int update_mode_line; 15213 int update_mode_line;
@@ -15268,10 +15262,10 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15268 else if ((w != XWINDOW (minibuf_window) 15262 else if ((w != XWINDOW (minibuf_window)
15269 || minibuf_level == 0) 15263 || minibuf_level == 0)
15270 /* When buffer is nonempty, redisplay window normally. */ 15264 /* When buffer is nonempty, redisplay window normally. */
15271 && BUF_Z (XBUFFER (w->buffer)) == BUF_BEG (XBUFFER (w->buffer)) 15265 && BUF_Z (XBUFFER (w->contents)) == BUF_BEG (XBUFFER (w->contents))
15272 /* Quail displays non-mini buffers in minibuffer window. 15266 /* Quail displays non-mini buffers in minibuffer window.
15273 In that case, redisplay the window normally. */ 15267 In that case, redisplay the window normally. */
15274 && !NILP (Fmemq (w->buffer, Vminibuffer_list))) 15268 && !NILP (Fmemq (w->contents, Vminibuffer_list)))
15275 { 15269 {
15276 /* W is a mini-buffer window, but it's not active, so clear 15270 /* W is a mini-buffer window, but it's not active, so clear
15277 it. */ 15271 it. */
@@ -15293,7 +15287,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15293 value. */ 15287 value. */
15294 /* Really select the buffer, for the sake of buffer-local 15288 /* Really select the buffer, for the sake of buffer-local
15295 variables. */ 15289 variables. */
15296 set_buffer_internal_1 (XBUFFER (w->buffer)); 15290 set_buffer_internal_1 (XBUFFER (w->contents));
15297 15291
15298 current_matrix_up_to_date_p 15292 current_matrix_up_to_date_p
15299 = (w->window_end_valid 15293 = (w->window_end_valid
@@ -16584,7 +16578,7 @@ try_window_reusing_current_matrix (struct window *w)
16584 bidi-reordered glyph rows. Let set_cursor_from_row 16578 bidi-reordered glyph rows. Let set_cursor_from_row
16585 figure out where to put the cursor, and if it fails, 16579 figure out where to put the cursor, and if it fails,
16586 give up. */ 16580 give up. */
16587 if (!NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering))) 16581 if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
16588 { 16582 {
16589 if (!set_cursor_from_row (w, row, w->current_matrix, 16583 if (!set_cursor_from_row (w, row, w->current_matrix,
16590 0, 0, 0, 0)) 16584 0, 0, 0, 0))
@@ -16835,7 +16829,7 @@ sync_frame_with_window_matrix_rows (struct window *w)
16835 16829
16836 /* Preconditions: W must be a leaf window and full-width. Its frame 16830 /* Preconditions: W must be a leaf window and full-width. Its frame
16837 must have a frame matrix. */ 16831 must have a frame matrix. */
16838 eassert (NILP (w->hchild) && NILP (w->vchild)); 16832 eassert (BUFFERP (w->contents));
16839 eassert (WINDOW_FULL_WIDTH_P (w)); 16833 eassert (WINDOW_FULL_WIDTH_P (w));
16840 eassert (!FRAME_WINDOW_P (f)); 16834 eassert (!FRAME_WINDOW_P (f));
16841 16835
@@ -16877,7 +16871,7 @@ row_containing_pos (struct window *w, ptrdiff_t charpos,
16877{ 16871{
16878 struct glyph_row *row = start; 16872 struct glyph_row *row = start;
16879 struct glyph_row *best_row = NULL; 16873 struct glyph_row *best_row = NULL;
16880 ptrdiff_t mindif = BUF_ZV (XBUFFER (w->buffer)) + 1; 16874 ptrdiff_t mindif = BUF_ZV (XBUFFER (w->contents)) + 1;
16881 int last_y; 16875 int last_y;
16882 16876
16883 /* If we happen to start on a header-line, skip that. */ 16877 /* If we happen to start on a header-line, skip that. */
@@ -16913,7 +16907,7 @@ row_containing_pos (struct window *w, ptrdiff_t charpos,
16913 { 16907 {
16914 struct glyph *g; 16908 struct glyph *g;
16915 16909
16916 if (NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering)) 16910 if (NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
16917 || (!best_row && !row->continued_p)) 16911 || (!best_row && !row->continued_p))
16918 return row; 16912 return row;
16919 /* In bidi-reordered rows, there could be several rows 16913 /* In bidi-reordered rows, there could be several rows
@@ -17079,7 +17073,7 @@ try_window_id (struct window *w)
17079 wrapped line can change the wrap position, altering the line 17073 wrapped line can change the wrap position, altering the line
17080 above it. It might be worthwhile to handle this more 17074 above it. It might be worthwhile to handle this more
17081 intelligently, but for now just redisplay from scratch. */ 17075 intelligently, but for now just redisplay from scratch. */
17082 if (!NILP (BVAR (XBUFFER (w->buffer), word_wrap))) 17076 if (!NILP (BVAR (XBUFFER (w->contents), word_wrap)))
17083 GIVE_UP (21); 17077 GIVE_UP (21);
17084 17078
17085 /* Under bidi reordering, adding or deleting a character in the 17079 /* Under bidi reordering, adding or deleting a character in the
@@ -17090,8 +17084,8 @@ try_window_id (struct window *w)
17090 to find the paragraph limits and widen the range of redisplayed 17084 to find the paragraph limits and widen the range of redisplayed
17091 lines to that, but for now just give up this optimization and 17085 lines to that, but for now just give up this optimization and
17092 redisplay from scratch. */ 17086 redisplay from scratch. */
17093 if (!NILP (BVAR (XBUFFER (w->buffer), bidi_display_reordering)) 17087 if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
17094 && NILP (BVAR (XBUFFER (w->buffer), bidi_paragraph_direction))) 17088 && NILP (BVAR (XBUFFER (w->contents), bidi_paragraph_direction)))
17095 GIVE_UP (22); 17089 GIVE_UP (22);
17096 17090
17097 /* Make sure beg_unchanged and end_unchanged are up to date. Do it 17091 /* 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. */)
17956 (Lisp_Object glyphs) 17950 (Lisp_Object glyphs)
17957{ 17951{
17958 struct window *w = XWINDOW (selected_window); 17952 struct window *w = XWINDOW (selected_window);
17959 struct buffer *buffer = XBUFFER (w->buffer); 17953 struct buffer *buffer = XBUFFER (w->contents);
17960 17954
17961 fprintf (stderr, "PT = %"pI"d, BEGV = %"pI"d. ZV = %"pI"d\n", 17955 fprintf (stderr, "PT = %"pI"d, BEGV = %"pI"d. ZV = %"pI"d\n",
17962 BUF_PT (buffer), BUF_BEGV (buffer), BUF_ZV (buffer)); 17956 BUF_PT (buffer), BUF_BEGV (buffer), BUF_ZV (buffer));
@@ -18062,7 +18056,7 @@ static struct glyph_row *
18062get_overlay_arrow_glyph_row (struct window *w, Lisp_Object overlay_arrow_string) 18056get_overlay_arrow_glyph_row (struct window *w, Lisp_Object overlay_arrow_string)
18063{ 18057{
18064 struct frame *f = XFRAME (WINDOW_FRAME (w)); 18058 struct frame *f = XFRAME (WINDOW_FRAME (w));
18065 struct buffer *buffer = XBUFFER (w->buffer); 18059 struct buffer *buffer = XBUFFER (w->contents);
18066 struct buffer *old = current_buffer; 18060 struct buffer *old = current_buffer;
18067 const unsigned char *arrow_string = SDATA (overlay_arrow_string); 18061 const unsigned char *arrow_string = SDATA (overlay_arrow_string);
18068 int arrow_len = SCHARS (overlay_arrow_string); 18062 int arrow_len = SCHARS (overlay_arrow_string);
@@ -19269,7 +19263,7 @@ display_line (struct it *it)
19269 row->glyphs[TEXT_AREA]->charpos = -1; 19263 row->glyphs[TEXT_AREA]->charpos = -1;
19270 row->displays_text_p = 0; 19264 row->displays_text_p = 0;
19271 19265
19272 if (!NILP (BVAR (XBUFFER (it->w->buffer), indicate_empty_lines)) 19266 if (!NILP (BVAR (XBUFFER (it->w->contents), indicate_empty_lines))
19273 && (!MINI_WINDOW_P (it->w) 19267 && (!MINI_WINDOW_P (it->w)
19274 || (minibuf_level && EQ (it->window, minibuf_window)))) 19268 || (minibuf_level && EQ (it->window, minibuf_window))))
19275 row->indicate_empty_line_p = 1; 19269 row->indicate_empty_line_p = 1;
@@ -20084,10 +20078,8 @@ redisplay_mode_lines (Lisp_Object window, int force)
20084 { 20078 {
20085 struct window *w = XWINDOW (window); 20079 struct window *w = XWINDOW (window);
20086 20080
20087 if (WINDOWP (w->hchild)) 20081 if (WINDOWP (w->contents))
20088 nwindows += redisplay_mode_lines (w->hchild, force); 20082 nwindows += redisplay_mode_lines (w->contents, force);
20089 else if (WINDOWP (w->vchild))
20090 nwindows += redisplay_mode_lines (w->vchild, force);
20091 else if (force 20083 else if (force
20092 || FRAME_GARBAGED_P (XFRAME (w->frame)) 20084 || FRAME_GARBAGED_P (XFRAME (w->frame))
20093 || !MATRIX_MODE_LINE_ROW (w->current_matrix)->enabled_p) 20085 || !MATRIX_MODE_LINE_ROW (w->current_matrix)->enabled_p)
@@ -20097,7 +20089,7 @@ redisplay_mode_lines (Lisp_Object window, int force)
20097 20089
20098 /* Set the window's buffer for the mode line display. */ 20090 /* Set the window's buffer for the mode line display. */
20099 SET_TEXT_POS (lpoint, PT, PT_BYTE); 20091 SET_TEXT_POS (lpoint, PT, PT_BYTE);
20100 set_buffer_internal_1 (XBUFFER (w->buffer)); 20092 set_buffer_internal_1 (XBUFFER (w->contents));
20101 20093
20102 /* Point refers normally to the selected window. For any 20094 /* Point refers normally to the selected window. For any
20103 other window, set up appropriate value. */ 20095 other window, set up appropriate value. */
@@ -20879,7 +20871,7 @@ are the selected window and the WINDOW's buffer). */)
20879 XSETWINDOW (window, w); 20871 XSETWINDOW (window, w);
20880 20872
20881 if (NILP (buffer)) 20873 if (NILP (buffer))
20882 buffer = w->buffer; 20874 buffer = w->contents;
20883 CHECK_BUFFER (buffer); 20875 CHECK_BUFFER (buffer);
20884 20876
20885 /* Make formatting the modeline a non-op when noninteractive, otherwise 20877 /* 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,
22185 return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w)); 22177 return OK_PIXELS (WINDOW_SCROLL_BAR_AREA_WIDTH (it->w));
22186 } 22178 }
22187 22179
22188 prop = buffer_local_value_1 (prop, it->w->buffer); 22180 prop = buffer_local_value_1 (prop, it->w->contents);
22189 if (EQ (prop, Qunbound)) 22181 if (EQ (prop, Qunbound))
22190 prop = Qnil; 22182 prop = Qnil;
22191 } 22183 }
@@ -22237,7 +22229,7 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
22237 return OK_PIXELS (pixels); 22229 return OK_PIXELS (pixels);
22238 } 22230 }
22239 22231
22240 car = buffer_local_value_1 (car, it->w->buffer); 22232 car = buffer_local_value_1 (car, it->w->contents);
22241 if (EQ (car, Qunbound)) 22233 if (EQ (car, Qunbound))
22242 car = Qnil; 22234 car = Qnil;
22243 } 22235 }
@@ -24089,7 +24081,7 @@ produce_stretch_glyph (struct it *it)
24089 int n = width; 24081 int n = width;
24090 24082
24091 if (!STRINGP (object)) 24083 if (!STRINGP (object))
24092 object = it->w->buffer; 24084 object = it->w->contents;
24093#ifdef HAVE_WINDOW_SYSTEM 24085#ifdef HAVE_WINDOW_SYSTEM
24094 if (FRAME_WINDOW_P (it->f)) 24086 if (FRAME_WINDOW_P (it->f))
24095 append_stretch_glyph (it, object, width, height, ascent); 24087 append_stretch_glyph (it, object, width, height, ascent);
@@ -25485,7 +25477,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
25485 int *active_cursor) 25477 int *active_cursor)
25486{ 25478{
25487 struct frame *f = XFRAME (w->frame); 25479 struct frame *f = XFRAME (w->frame);
25488 struct buffer *b = XBUFFER (w->buffer); 25480 struct buffer *b = XBUFFER (w->contents);
25489 int cursor_type = DEFAULT_CURSOR; 25481 int cursor_type = DEFAULT_CURSOR;
25490 Lisp_Object alt_cursor; 25482 Lisp_Object alt_cursor;
25491 int non_selected = 0; 25483 int non_selected = 0;
@@ -26036,10 +26028,8 @@ update_cursor_in_window_tree (struct window *w, int on_p)
26036{ 26028{
26037 while (w) 26029 while (w)
26038 { 26030 {
26039 if (!NILP (w->hchild)) 26031 if (WINDOWP (w->contents))
26040 update_cursor_in_window_tree (XWINDOW (w->hchild), on_p); 26032 update_cursor_in_window_tree (XWINDOW (w->contents), on_p);
26041 else if (!NILP (w->vchild))
26042 update_cursor_in_window_tree (XWINDOW (w->vchild), on_p);
26043 else 26033 else
26044 update_window_cursor (w, on_p); 26034 update_window_cursor (w, on_p);
26045 26035
@@ -27285,7 +27275,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
27285 { 27275 {
27286 help_echo_string = help; 27276 help_echo_string = help;
27287 XSETWINDOW (help_echo_window, w); 27277 XSETWINDOW (help_echo_window, w);
27288 help_echo_object = w->buffer; 27278 help_echo_object = w->contents;
27289 help_echo_pos = charpos; 27279 help_echo_pos = charpos;
27290 } 27280 }
27291 } 27281 }
@@ -27321,7 +27311,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
27321 { 27311 {
27322 Lisp_Object default_help 27312 Lisp_Object default_help
27323 = buffer_local_value_1 (Qmode_line_default_help_echo, 27313 = buffer_local_value_1 (Qmode_line_default_help_echo,
27324 w->buffer); 27314 w->contents);
27325 27315
27326 if (STRINGP (default_help)) 27316 if (STRINGP (default_help))
27327 { 27317 {
@@ -27596,7 +27586,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
27596 27586
27597 /* Are we in a window whose display is up to date? 27587 /* Are we in a window whose display is up to date?
27598 And verify the buffer's text has not changed. */ 27588 And verify the buffer's text has not changed. */
27599 b = XBUFFER (w->buffer); 27589 b = XBUFFER (w->contents);
27600 if (part == ON_TEXT 27590 if (part == ON_TEXT
27601 && w->window_end_valid 27591 && w->window_end_valid
27602 && w->last_modified == BUF_MODIFF (b) 27592 && w->last_modified == BUF_MODIFF (b)
@@ -27805,8 +27795,8 @@ note_mouse_highlight (struct frame *f, int x, int y)
27805 if (pos > 0) 27795 if (pos > 0)
27806 { 27796 {
27807 mouse_face = get_char_property_and_overlay 27797 mouse_face = get_char_property_and_overlay
27808 (make_number (pos), Qmouse_face, w->buffer, &overlay); 27798 (make_number (pos), Qmouse_face, w->contents, &overlay);
27809 buffer = w->buffer; 27799 buffer = w->contents;
27810 disp_string = object; 27800 disp_string = object;
27811 } 27801 }
27812 } 27802 }
@@ -27919,11 +27909,11 @@ note_mouse_highlight (struct frame *f, int x, int y)
27919 if (p > 0) 27909 if (p > 0)
27920 { 27910 {
27921 help = Fget_char_property (make_number (p), 27911 help = Fget_char_property (make_number (p),
27922 Qhelp_echo, w->buffer); 27912 Qhelp_echo, w->contents);
27923 if (!NILP (help)) 27913 if (!NILP (help))
27924 { 27914 {
27925 charpos = p; 27915 charpos = p;
27926 obj = w->buffer; 27916 obj = w->contents;
27927 } 27917 }
27928 } 27918 }
27929 } 27919 }
@@ -27974,7 +27964,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
27974 ptrdiff_t p = string_buffer_position (obj, start); 27964 ptrdiff_t p = string_buffer_position (obj, start);
27975 if (p > 0) 27965 if (p > 0)
27976 pointer = Fget_char_property (make_number (p), 27966 pointer = Fget_char_property (make_number (p),
27977 Qpointer, w->buffer); 27967 Qpointer, w->contents);
27978 } 27968 }
27979 } 27969 }
27980 else if (BUFFERP (obj) 27970 else if (BUFFERP (obj)
@@ -28417,12 +28407,9 @@ expose_window_tree (struct window *w, XRectangle *r)
28417 28407
28418 while (w && !FRAME_GARBAGED_P (f)) 28408 while (w && !FRAME_GARBAGED_P (f))
28419 { 28409 {
28420 if (!NILP (w->hchild)) 28410 if (WINDOWP (w->contents))
28421 mouse_face_overwritten_p
28422 |= expose_window_tree (XWINDOW (w->hchild), r);
28423 else if (!NILP (w->vchild))
28424 mouse_face_overwritten_p 28411 mouse_face_overwritten_p
28425 |= expose_window_tree (XWINDOW (w->vchild), r); 28412 |= expose_window_tree (XWINDOW (w->contents), r);
28426 else 28413 else
28427 mouse_face_overwritten_p |= expose_window (w, r); 28414 mouse_face_overwritten_p |= expose_window (w, r);
28428 28415
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,
5964 5964
5965 /* W must display the current buffer. We could write this function 5965 /* W must display the current buffer. We could write this function
5966 to use the frame and buffer of W, but right now it doesn't. */ 5966 to use the frame and buffer of W, but right now it doesn't. */
5967 /* eassert (XBUFFER (w->buffer) == current_buffer); */ 5967 /* eassert (XBUFFER (w->contents) == current_buffer); */
5968 5968
5969 XSETFASTINT (position, pos); 5969 XSETFASTINT (position, pos);
5970 5970
@@ -5974,9 +5974,9 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
5974 5974
5975 /* Get the `face' or `mouse_face' text property at POS, and 5975 /* Get the `face' or `mouse_face' text property at POS, and
5976 determine the next position at which the property changes. */ 5976 determine the next position at which the property changes. */
5977 prop = Fget_text_property (position, propname, w->buffer); 5977 prop = Fget_text_property (position, propname, w->contents);
5978 XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); 5978 XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
5979 end = Fnext_single_property_change (position, propname, w->buffer, limit1); 5979 end = Fnext_single_property_change (position, propname, w->contents, limit1);
5980 if (INTEGERP (end)) 5980 if (INTEGERP (end))
5981 endpos = XINT (end); 5981 endpos = XINT (end);
5982 5982
@@ -6072,7 +6072,7 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
6072 6072
6073 /* W must display the current buffer. We could write this function 6073 /* W must display the current buffer. We could write this function
6074 to use the frame and buffer of W, but right now it doesn't. */ 6074 to use the frame and buffer of W, but right now it doesn't. */
6075 /* eassert (XBUFFER (w->buffer) == current_buffer); */ 6075 /* eassert (XBUFFER (w->contents) == current_buffer); */
6076 6076
6077 XSETFASTINT (position, pos); 6077 XSETFASTINT (position, pos);
6078 6078
@@ -6082,9 +6082,9 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
6082 6082
6083 /* Get the `face' or `mouse_face' text property at POS, and 6083 /* Get the `face' or `mouse_face' text property at POS, and
6084 determine the next position at which the property changes. */ 6084 determine the next position at which the property changes. */
6085 prop = Fget_text_property (position, propname, w->buffer); 6085 prop = Fget_text_property (position, propname, w->contents);
6086 XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); 6086 XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
6087 end = Fnext_single_property_change (position, propname, w->buffer, limit1); 6087 end = Fnext_single_property_change (position, propname, w->contents, limit1);
6088 if (INTEGERP (end)) 6088 if (INTEGERP (end))
6089 endpos = XINT (end); 6089 endpos = XINT (end);
6090 6090
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. */)
5043 5043
5044 /* Display the tooltip text in a temporary buffer. */ 5044 /* Display the tooltip text in a temporary buffer. */
5045 old_buffer = current_buffer; 5045 old_buffer = current_buffer;
5046 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); 5046 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->contents));
5047 bset_truncate_lines (current_buffer, Qnil); 5047 bset_truncate_lines (current_buffer, Qnil);
5048 clear_glyph_matrix (w->desired_matrix); 5048 clear_glyph_matrix (w->desired_matrix);
5049 clear_glyph_matrix (w->current_matrix); 5049 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)
976 if (! menubar_widget) 976 if (! menubar_widget)
977 previous_menu_items_used = 0; 977 previous_menu_items_used = 0;
978 978
979 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer; 979 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents;
980 specbind (Qinhibit_quit, Qt); 980 specbind (Qinhibit_quit, Qt);
981 /* Don't let the debugger step into this code 981 /* Don't let the debugger step into this code
982 because it is not reentrant. */ 982 because it is not reentrant. */