aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c488
1 files changed, 213 insertions, 275 deletions
diff --git a/src/window.c b/src/window.c
index a2e6a5a0602..77604f4ee19 100644
--- a/src/window.c
+++ b/src/window.c
@@ -148,11 +148,6 @@ wset_display_table (struct window *w, Lisp_Object val)
148 w->display_table = val; 148 w->display_table = val;
149} 149}
150static void 150static void
151wset_hchild (struct window *w, Lisp_Object val)
152{
153 w->hchild = val;
154}
155static void
156wset_left_fringe_width (struct window *w, Lisp_Object val) 151wset_left_fringe_width (struct window *w, Lisp_Object val)
157{ 152{
158 w->left_fringe_width = val; 153 w->left_fringe_width = val;
@@ -218,11 +213,6 @@ wset_temslot (struct window *w, Lisp_Object val)
218 w->temslot = val; 213 w->temslot = val;
219} 214}
220static void 215static void
221wset_vchild (struct window *w, Lisp_Object val)
222{
223 w->vchild = val;
224}
225static void
226wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val) 216wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val)
227{ 217{
228 w->vertical_scroll_bar_type = val; 218 w->vertical_scroll_bar_type = val;
@@ -232,6 +222,18 @@ wset_window_parameters (struct window *w, Lisp_Object val)
232{ 222{
233 w->window_parameters = val; 223 w->window_parameters = val;
234} 224}
225static void
226wset_combination (struct window *w, bool horflag, Lisp_Object val)
227{
228 /* Since leaf windows never becomes non-leaf, there should
229 be no buffer and markers in start and pointm fields of W. */
230 eassert (!BUFFERP (w->contents) && NILP (w->start) && NILP (w->pointm));
231 w->contents = val;
232 /* When an internal window is deleted and VAL is nil, HORFLAG
233 is meaningless. */
234 if (!NILP (val))
235 w->horizontal = horflag;
236}
235 237
236struct window * 238struct window *
237decode_live_window (register Lisp_Object window) 239decode_live_window (register Lisp_Object window)
@@ -276,9 +278,9 @@ static void
276adjust_window_count (struct window *w, int arg) 278adjust_window_count (struct window *w, int arg)
277{ 279{
278 eassert (eabs (arg) == 1); 280 eassert (eabs (arg) == 1);
279 if (BUFFERP (w->buffer)) 281 if (BUFFERP (w->contents))
280 { 282 {
281 struct buffer *b = XBUFFER (w->buffer); 283 struct buffer *b = XBUFFER (w->contents);
282 284
283 if (b->base_buffer) 285 if (b->base_buffer)
284 b = b->base_buffer; 286 b = b->base_buffer;
@@ -297,7 +299,11 @@ void
297wset_buffer (struct window *w, Lisp_Object val) 299wset_buffer (struct window *w, Lisp_Object val)
298{ 300{
299 adjust_window_count (w, -1); 301 adjust_window_count (w, -1);
300 w->buffer = val; 302 if (BUFFERP (val))
303 /* Make sure that we do not assign the buffer
304 to an internal window. */
305 eassert (MARKERP (w->start) && MARKERP (w->pointm));
306 w->contents = val;
301 adjust_window_count (w, 1); 307 adjust_window_count (w, 1);
302} 308}
303 309
@@ -395,15 +401,8 @@ the first window of that frame. */)
395 window = XFRAME (frame_or_window)->root_window; 401 window = XFRAME (frame_or_window)->root_window;
396 } 402 }
397 403
398 while (NILP (XWINDOW (window)->buffer)) 404 while (WINDOWP (XWINDOW (window)->contents))
399 { 405 window = XWINDOW (window)->contents;
400 if (! NILP (XWINDOW (window)->hchild))
401 window = XWINDOW (window)->hchild;
402 else if (! NILP (XWINDOW (window)->vchild))
403 window = XWINDOW (window)->vchild;
404 else
405 emacs_abort ();
406 }
407 406
408 return window; 407 return window;
409} 408}
@@ -490,11 +489,11 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
490 if (NILP (norecord)) 489 if (NILP (norecord))
491 { 490 {
492 w->use_time = ++window_select_count; 491 w->use_time = ++window_select_count;
493 record_buffer (w->buffer); 492 record_buffer (w->contents);
494 } 493 }
495 494
496 /* Make the selected window's buffer current. */ 495 /* Make the selected window's buffer current. */
497 Fset_buffer (w->buffer); 496 Fset_buffer (w->contents);
498 497
499 if (EQ (window, selected_window) && !inhibit_point_swap) 498 if (EQ (window, selected_window) && !inhibit_point_swap)
500 return window; 499 return window;
@@ -517,7 +516,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
517 516
518 select_window_1 (window, inhibit_point_swap); 517 select_window_1 (window, inhibit_point_swap);
519 518
520 bset_last_selected_window (XBUFFER (w->buffer), window); 519 bset_last_selected_window (XBUFFER (w->contents), window);
521 windows_or_buffers_changed++; 520 windows_or_buffers_changed++;
522 return window; 521 return window;
523} 522}
@@ -534,10 +533,10 @@ select_window_1 (Lisp_Object window, bool inhibit_point_swap)
534 if (!inhibit_point_swap) 533 if (!inhibit_point_swap)
535 { 534 {
536 struct window *ow = XWINDOW (selected_window); 535 struct window *ow = XWINDOW (selected_window);
537 if (! NILP (ow->buffer)) 536 if (BUFFERP (ow->contents))
538 set_marker_both (ow->pointm, ow->buffer, 537 set_marker_both (ow->pointm, ow->contents,
539 BUF_PT (XBUFFER (ow->buffer)), 538 BUF_PT (XBUFFER (ow->contents)),
540 BUF_PT_BYTE (XBUFFER (ow->buffer))); 539 BUF_PT_BYTE (XBUFFER (ow->contents)));
541 } 540 }
542 541
543 selected_window = window; 542 selected_window = window;
@@ -582,7 +581,8 @@ If WINDOW is omitted or nil, it defaults to the selected window.
582Return nil for an internal window or a deleted window. */) 581Return nil for an internal window or a deleted window. */)
583 (Lisp_Object window) 582 (Lisp_Object window)
584{ 583{
585 return decode_any_window (window)->buffer; 584 struct window *w = decode_any_window (window);
585 return WINDOW_LEAF_P (w) ? w->contents : Qnil;
586} 586}
587 587
588DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, 588DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0,
@@ -602,7 +602,8 @@ Return nil if WINDOW is an internal window whose children form a
602horizontal combination. */) 602horizontal combination. */)
603 (Lisp_Object window) 603 (Lisp_Object window)
604{ 604{
605 return decode_valid_window (window)->vchild; 605 struct window *w = decode_valid_window (window);
606 return WINDOW_VERTICAL_COMBINATION_P (w) ? w->contents : Qnil;
606} 607}
607 608
608DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 0, 1, 0, 609DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 0, 1, 0,
@@ -613,7 +614,8 @@ Return nil if WINDOW is an internal window whose children form a
613vertical combination. */) 614vertical combination. */)
614 (Lisp_Object window) 615 (Lisp_Object window)
615{ 616{
616 return decode_valid_window (window)->hchild; 617 struct window *w = decode_valid_window (window);
618 return WINDOW_HORIZONTAL_COMBINATION_P (w) ? w->contents : Qnil;
617} 619}
618 620
619DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0, 621DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0,
@@ -646,9 +648,9 @@ WINDOW are never \(re-)combined with WINDOW's siblings. */)
646 648
647 CHECK_VALID_WINDOW (window); 649 CHECK_VALID_WINDOW (window);
648 w = XWINDOW (window); 650 w = XWINDOW (window);
649 if (!NILP (w->buffer)) 651 if (WINDOW_LEAF_P (w))
650 error ("Combination limit is meaningful for internal windows only"); 652 error ("Combination limit is meaningful for internal windows only");
651 return XWINDOW (window)->combination_limit; 653 return w->combination_limit;
652} 654}
653 655
654DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0, 656DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0,
@@ -664,7 +666,7 @@ future use. */)
664 666
665 CHECK_VALID_WINDOW (window); 667 CHECK_VALID_WINDOW (window);
666 w = XWINDOW (window); 668 w = XWINDOW (window);
667 if (!NILP (w->buffer)) 669 if (WINDOW_LEAF_P (w))
668 error ("Combination limit is meaningful for internal windows only"); 670 error ("Combination limit is meaningful for internal windows only");
669 wset_combination_limit (w, limit); 671 wset_combination_limit (w, limit);
670 return limit; 672 return limit;
@@ -861,7 +863,7 @@ set_window_hscroll (struct window *w, EMACS_INT hscroll)
861 863
862 /* Prevent redisplay shortcuts when changing the hscroll. */ 864 /* Prevent redisplay shortcuts when changing the hscroll. */
863 if (w->hscroll != new_hscroll) 865 if (w->hscroll != new_hscroll)
864 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 866 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
865 867
866 w->hscroll = new_hscroll; 868 w->hscroll = new_hscroll;
867 return make_number (new_hscroll); 869 return make_number (new_hscroll);
@@ -1442,7 +1444,7 @@ correct to return the top-level value of `point', outside of any
1442 register struct window *w = decode_live_window (window); 1444 register struct window *w = decode_live_window (window);
1443 1445
1444 if (w == XWINDOW (selected_window)) 1446 if (w == XWINDOW (selected_window))
1445 return make_number (BUF_PT (XBUFFER (w->buffer))); 1447 return make_number (BUF_PT (XBUFFER (w->contents)));
1446 else 1448 else
1447 return Fmarker_position (w->pointm); 1449 return Fmarker_position (w->pointm);
1448} 1450}
@@ -1484,7 +1486,7 @@ if it isn't already recorded. */)
1484 Lisp_Object buf; 1486 Lisp_Object buf;
1485 struct buffer *b; 1487 struct buffer *b;
1486 1488
1487 buf = w->buffer; 1489 buf = w->contents;
1488 CHECK_BUFFER (buf); 1490 CHECK_BUFFER (buf);
1489 b = XBUFFER (buf); 1491 b = XBUFFER (buf);
1490 1492
@@ -1547,7 +1549,7 @@ Return POS. */)
1547 1549
1548 if (w == XWINDOW (selected_window)) 1550 if (w == XWINDOW (selected_window))
1549 { 1551 {
1550 if (XBUFFER (w->buffer) == current_buffer) 1552 if (XBUFFER (w->contents) == current_buffer)
1551 Fgoto_char (pos); 1553 Fgoto_char (pos);
1552 else 1554 else
1553 { 1555 {
@@ -1555,14 +1557,14 @@ Return POS. */)
1555 1557
1556 /* ... but here we want to catch type error before buffer change. */ 1558 /* ... but here we want to catch type error before buffer change. */
1557 CHECK_NUMBER_COERCE_MARKER (pos); 1559 CHECK_NUMBER_COERCE_MARKER (pos);
1558 set_buffer_internal (XBUFFER (w->buffer)); 1560 set_buffer_internal (XBUFFER (w->contents));
1559 Fgoto_char (pos); 1561 Fgoto_char (pos);
1560 set_buffer_internal (old_buffer); 1562 set_buffer_internal (old_buffer);
1561 } 1563 }
1562 } 1564 }
1563 else 1565 else
1564 { 1566 {
1565 set_marker_restricted (w->pointm, pos, w->buffer); 1567 set_marker_restricted (w->pointm, pos, w->contents);
1566 /* We have to make sure that redisplay updates the window to show 1568 /* We have to make sure that redisplay updates the window to show
1567 the new value of point. */ 1569 the new value of point. */
1568 ++windows_or_buffers_changed; 1570 ++windows_or_buffers_changed;
@@ -1580,7 +1582,7 @@ overriding motion of point in order to display at this exact start. */)
1580{ 1582{
1581 register struct window *w = decode_live_window (window); 1583 register struct window *w = decode_live_window (window);
1582 1584
1583 set_marker_restricted (w->start, pos, w->buffer); 1585 set_marker_restricted (w->start, pos, w->contents);
1584 /* This is not right, but much easier than doing what is right. */ 1586 /* This is not right, but much easier than doing what is right. */
1585 w->start_at_line_beg = 0; 1587 w->start_at_line_beg = 0;
1586 if (NILP (noforce)) 1588 if (NILP (noforce))
@@ -1624,7 +1626,7 @@ display row, and VPOS is the row number (0-based) containing POS. */)
1624 int x, y; 1626 int x, y;
1625 1627
1626 w = decode_live_window (window); 1628 w = decode_live_window (window);
1627 buf = XBUFFER (w->buffer); 1629 buf = XBUFFER (w->contents);
1628 SET_TEXT_POS_FROM_MARKER (top, w->start); 1630 SET_TEXT_POS_FROM_MARKER (top, w->start);
1629 1631
1630 if (EQ (pos, Qt)) 1632 if (EQ (pos, Qt))
@@ -1693,8 +1695,8 @@ Return nil if window display is not up-to-date. In that case, use
1693 if (noninteractive || w->pseudo_window_p) 1695 if (noninteractive || w->pseudo_window_p)
1694 return Qnil; 1696 return Qnil;
1695 1697
1696 CHECK_BUFFER (w->buffer); 1698 CHECK_BUFFER (w->contents);
1697 b = XBUFFER (w->buffer); 1699 b = XBUFFER (w->contents);
1698 1700
1699 /* Fail if current matrix is not up-to-date. */ 1701 /* Fail if current matrix is not up-to-date. */
1700 if (!w->window_end_valid 1702 if (!w->window_end_valid
@@ -1920,9 +1922,9 @@ window_display_table (struct window *w)
1920 1922
1921 if (DISP_TABLE_P (w->display_table)) 1923 if (DISP_TABLE_P (w->display_table))
1922 dp = XCHAR_TABLE (w->display_table); 1924 dp = XCHAR_TABLE (w->display_table);
1923 else if (BUFFERP (w->buffer)) 1925 else if (BUFFERP (w->contents))
1924 { 1926 {
1925 struct buffer *b = XBUFFER (w->buffer); 1927 struct buffer *b = XBUFFER (w->contents);
1926 1928
1927 if (DISP_TABLE_P (BVAR (b, display_table))) 1929 if (DISP_TABLE_P (BVAR (b, display_table)))
1928 dp = XCHAR_TABLE (BVAR (b, display_table)); 1930 dp = XCHAR_TABLE (BVAR (b, display_table));
@@ -1947,17 +1949,14 @@ WINDOW must be a live window and defaults to the selected one. */)
1947static void 1949static void
1948unshow_buffer (register struct window *w) 1950unshow_buffer (register struct window *w)
1949{ 1951{
1950 Lisp_Object buf; 1952 Lisp_Object buf = w->contents;
1951 struct buffer *b; 1953 struct buffer *b = XBUFFER (buf);
1952 1954
1953 buf = w->buffer; 1955 eassert (b == XMARKER (w->pointm)->buffer);
1954 b = XBUFFER (buf);
1955 if (b != XMARKER (w->pointm)->buffer)
1956 emacs_abort ();
1957 1956
1958#if 0 1957#if 0
1959 if (w == XWINDOW (selected_window) 1958 if (w == XWINDOW (selected_window)
1960 || ! EQ (buf, XWINDOW (selected_window)->buffer)) 1959 || ! EQ (buf, XWINDOW (selected_window)->contents))
1961 /* Do this except when the selected window's buffer 1960 /* Do this except when the selected window's buffer
1962 is being removed from some other window. */ 1961 is being removed from some other window. */
1963#endif 1962#endif
@@ -1973,14 +1972,14 @@ unshow_buffer (register struct window *w)
1973 /* Point in the selected window's buffer 1972 /* Point in the selected window's buffer
1974 is actually stored in that buffer, and the window's pointm isn't used. 1973 is actually stored in that buffer, and the window's pointm isn't used.
1975 So don't clobber point in that buffer. */ 1974 So don't clobber point in that buffer. */
1976 if (! EQ (buf, XWINDOW (selected_window)->buffer) 1975 if (! EQ (buf, XWINDOW (selected_window)->contents)
1977 /* Don't clobber point in current buffer either (this could be 1976 /* Don't clobber point in current buffer either (this could be
1978 useful in connection with bug#12208). 1977 useful in connection with bug#12208).
1979 && XBUFFER (buf) != current_buffer */ 1978 && XBUFFER (buf) != current_buffer */
1980 /* This line helps to fix Horsley's testbug.el bug. */ 1979 /* This line helps to fix Horsley's testbug.el bug. */
1981 && !(WINDOWP (BVAR (b, last_selected_window)) 1980 && !(WINDOWP (BVAR (b, last_selected_window))
1982 && w != XWINDOW (BVAR (b, last_selected_window)) 1981 && w != XWINDOW (BVAR (b, last_selected_window))
1983 && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->buffer))) 1982 && EQ (buf, XWINDOW (BVAR (b, last_selected_window))->contents)))
1984 temp_set_point_both (b, 1983 temp_set_point_both (b,
1985 clip_to_bounds (BUF_BEGV (b), 1984 clip_to_bounds (BUF_BEGV (b),
1986 marker_position (w->pointm), 1985 marker_position (w->pointm),
@@ -2045,13 +2044,8 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag)
2045 2044
2046 tem = o->parent; 2045 tem = o->parent;
2047 wset_parent (n, tem); 2046 wset_parent (n, tem);
2048 if (!NILP (tem)) 2047 if (!NILP (tem) && EQ (XWINDOW (tem)->contents, old))
2049 { 2048 wset_combination (XWINDOW (tem), XWINDOW (tem)->horizontal, new);
2050 if (EQ (XWINDOW (tem)->vchild, old))
2051 wset_vchild (XWINDOW (tem), new);
2052 if (EQ (XWINDOW (tem)->hchild, old))
2053 wset_hchild (XWINDOW (tem), new);
2054 }
2055} 2049}
2056 2050
2057/* If window WINDOW and its parent window are iso-combined, merge 2051/* If window WINDOW and its parent window are iso-combined, merge
@@ -2070,22 +2064,19 @@ recombine_windows (Lisp_Object window)
2070 if (!NILP (parent) && NILP (w->combination_limit)) 2064 if (!NILP (parent) && NILP (w->combination_limit))
2071 { 2065 {
2072 p = XWINDOW (parent); 2066 p = XWINDOW (parent);
2073 if (((!NILP (p->vchild) && !NILP (w->vchild)) 2067 if (WINDOWP (p->contents) && WINDOWP (w->contents)
2074 || (!NILP (p->hchild) && !NILP (w->hchild)))) 2068 && p->horizontal == w->horizontal)
2075 /* WINDOW and PARENT are both either a vertical or a horizontal 2069 /* WINDOW and PARENT are both either a vertical or a horizontal
2076 combination. */ 2070 combination. */
2077 { 2071 {
2078 horflag = NILP (w->vchild); 2072 horflag = WINDOW_HORIZONTAL_COMBINATION_P (w);
2079 child = horflag ? w->hchild : w->vchild; 2073 child = w->contents;
2080 c = XWINDOW (child); 2074 c = XWINDOW (child);
2081 2075
2082 /* Splice WINDOW's children into its parent's children and 2076 /* Splice WINDOW's children into its parent's children and
2083 assign new normal sizes. */ 2077 assign new normal sizes. */
2084 if (NILP (w->prev)) 2078 if (NILP (w->prev))
2085 if (horflag) 2079 wset_combination (p, horflag, child);
2086 wset_hchild (p, child);
2087 else
2088 wset_vchild (p, child);
2089 else 2080 else
2090 { 2081 {
2091 wset_prev (c, w->prev); 2082 wset_prev (c, w->prev);
@@ -2123,8 +2114,7 @@ recombine_windows (Lisp_Object window)
2123 } 2114 }
2124 2115
2125 /* WINDOW can be deleted now. */ 2116 /* WINDOW can be deleted now. */
2126 wset_vchild (w, Qnil); 2117 wset_combination (w, 0, Qnil);
2127 wset_hchild (w, Qnil);
2128 } 2118 }
2129 } 2119 }
2130} 2120}
@@ -2210,7 +2200,7 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf
2210 struct frame *f = XFRAME (w->frame); 2200 struct frame *f = XFRAME (w->frame);
2211 int candidate_p = 1; 2201 int candidate_p = 1;
2212 2202
2213 if (!BUFFERP (w->buffer)) 2203 if (!BUFFERP (w->contents))
2214 candidate_p = 0; 2204 candidate_p = 0;
2215 else if (MINI_WINDOW_P (w) 2205 else if (MINI_WINDOW_P (w)
2216 && (EQ (minibuf, Qlambda) 2206 && (EQ (minibuf, Qlambda)
@@ -2550,7 +2540,7 @@ enum window_loop
2550 GET_BUFFER_WINDOW, /* Arg is buffer */ 2540 GET_BUFFER_WINDOW, /* Arg is buffer */
2551 REPLACE_BUFFER_IN_WINDOWS_SAFELY, /* Arg is buffer */ 2541 REPLACE_BUFFER_IN_WINDOWS_SAFELY, /* Arg is buffer */
2552 REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */ 2542 REDISPLAY_BUFFER_WINDOWS, /* Arg is buffer */
2553 CHECK_ALL_WINDOWS 2543 CHECK_ALL_WINDOWS /* Arg is ignored */
2554}; 2544};
2555 2545
2556static Lisp_Object 2546static Lisp_Object
@@ -2614,7 +2604,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2614 switch (type) 2604 switch (type)
2615 { 2605 {
2616 case GET_BUFFER_WINDOW: 2606 case GET_BUFFER_WINDOW:
2617 if (EQ (w->buffer, obj) 2607 if (EQ (w->contents, obj)
2618 /* Don't find any minibuffer window except the one that 2608 /* Don't find any minibuffer window except the one that
2619 is currently in use. */ 2609 is currently in use. */
2620 && (MINI_WINDOW_P (w) ? EQ (window, minibuf_window) : 1)) 2610 && (MINI_WINDOW_P (w) ? EQ (window, minibuf_window) : 1))
@@ -2638,25 +2628,25 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2638 case REPLACE_BUFFER_IN_WINDOWS_SAFELY: 2628 case REPLACE_BUFFER_IN_WINDOWS_SAFELY:
2639 /* We could simply check whether the buffer shown by window 2629 /* We could simply check whether the buffer shown by window
2640 is live, and show another buffer in case it isn't. */ 2630 is live, and show another buffer in case it isn't. */
2641 if (EQ (w->buffer, obj)) 2631 if (EQ (w->contents, obj))
2642 { 2632 {
2643 /* Undedicate WINDOW. */ 2633 /* Undedicate WINDOW. */
2644 wset_dedicated (w, Qnil); 2634 wset_dedicated (w, Qnil);
2645 /* Make WINDOW show the buffer returned by 2635 /* Make WINDOW show the buffer returned by
2646 other_buffer_safely, don't run any hooks. */ 2636 other_buffer_safely, don't run any hooks. */
2647 set_window_buffer 2637 set_window_buffer
2648 (window, other_buffer_safely (w->buffer), 0, 0); 2638 (window, other_buffer_safely (w->contents), 0, 0);
2649 /* If WINDOW is the selected window, make its buffer 2639 /* If WINDOW is the selected window, make its buffer
2650 current. But do so only if the window shows the 2640 current. But do so only if the window shows the
2651 current buffer (Bug#6454). */ 2641 current buffer (Bug#6454). */
2652 if (EQ (window, selected_window) 2642 if (EQ (window, selected_window)
2653 && XBUFFER (w->buffer) == current_buffer) 2643 && XBUFFER (w->contents) == current_buffer)
2654 Fset_buffer (w->buffer); 2644 Fset_buffer (w->contents);
2655 } 2645 }
2656 break; 2646 break;
2657 2647
2658 case REDISPLAY_BUFFER_WINDOWS: 2648 case REDISPLAY_BUFFER_WINDOWS:
2659 if (EQ (w->buffer, obj)) 2649 if (EQ (w->contents, obj))
2660 { 2650 {
2661 mark_window_display_accurate (window, 0); 2651 mark_window_display_accurate (window, 0);
2662 w->update_mode_line = 1; 2652 w->update_mode_line = 1;
@@ -2666,11 +2656,20 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
2666 } 2656 }
2667 break; 2657 break;
2668 2658
2669 /* Check for a window that has a killed buffer. */ 2659 /* Check for a leaf window that has a killed buffer
2660 or broken markers. */
2670 case CHECK_ALL_WINDOWS: 2661 case CHECK_ALL_WINDOWS:
2671 if (! NILP (w->buffer) 2662 if (BUFFERP (w->contents))
2672 && !BUFFER_LIVE_P (XBUFFER (w->buffer))) 2663 {
2673 emacs_abort (); 2664 struct buffer *b = XBUFFER (w->contents);
2665
2666 if (!BUFFER_LIVE_P (b))
2667 emacs_abort ();
2668 if (!MARKERP (w->start) || XMARKER (w->start)->buffer != b)
2669 emacs_abort ();
2670 if (!MARKERP (w->pointm) || XMARKER (w->pointm)->buffer != b)
2671 emacs_abort ();
2672 }
2674 break; 2673 break;
2675 2674
2676 case WINDOW_LOOP_UNUSED: 2675 case WINDOW_LOOP_UNUSED:
@@ -2787,7 +2786,7 @@ window-start value is reasonable when this function is called. */)
2787 else if (MINI_WINDOW_P (w)) /* && top > 0) */ 2786 else if (MINI_WINDOW_P (w)) /* && top > 0) */
2788 error ("Can't expand minibuffer to full frame"); 2787 error ("Can't expand minibuffer to full frame");
2789 2788
2790 if (!NILP (w->buffer)) 2789 if (BUFFERP (w->contents))
2791 { 2790 {
2792 startpos = marker_position (w->start); 2791 startpos = marker_position (w->start);
2793 startbyte = marker_byte_position (w->start); 2792 startbyte = marker_byte_position (w->start);
@@ -2859,7 +2858,7 @@ window-start value is reasonable when this function is called. */)
2859 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 2858 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
2860 resize_failed = 0; 2859 resize_failed = 0;
2861 2860
2862 if (NILP (w->buffer)) 2861 if (!WINDOW_LEAF_P (w))
2863 { 2862 {
2864 /* Resize child windows vertically. */ 2863 /* Resize child windows vertically. */
2865 XSETINT (delta, r->total_lines - w->total_lines); 2864 XSETINT (delta, r->total_lines - w->total_lines);
@@ -2918,28 +2917,21 @@ window-start value is reasonable when this function is called. */)
2918 sibling = w->next; 2917 sibling = w->next;
2919 s = XWINDOW (sibling); 2918 s = XWINDOW (sibling);
2920 wset_prev (s, Qnil); 2919 wset_prev (s, Qnil);
2921 if (!NILP (XWINDOW (w->parent)->vchild)) 2920 wset_combination (XWINDOW (w->parent),
2922 wset_vchild (XWINDOW (w->parent), sibling); 2921 XWINDOW (w->parent)->horizontal, sibling);
2923 else
2924 wset_hchild (XWINDOW (w->parent), sibling);
2925 } 2922 }
2926 2923
2927 /* Delete ROOT and all child windows of ROOT. */ 2924 /* Delete ROOT and all child windows of ROOT. */
2928 if (!NILP (r->vchild)) 2925 if (WINDOWP (r->contents))
2929 { 2926 {
2930 delete_all_child_windows (r->vchild); 2927 delete_all_child_windows (r->contents);
2931 wset_vchild (r, Qnil); 2928 wset_combination (r, 0, Qnil);
2932 }
2933 else if (!NILP (r->hchild))
2934 {
2935 delete_all_child_windows (r->hchild);
2936 wset_hchild (r, Qnil);
2937 } 2929 }
2938 2930
2939 replace_window (root, window, 1); 2931 replace_window (root, window, 1);
2940 2932
2941 /* This must become SWINDOW anyway ....... */ 2933 /* This must become SWINDOW anyway ....... */
2942 if (!NILP (w->buffer) && !resize_failed) 2934 if (BUFFERP (w->contents) && !resize_failed)
2943 { 2935 {
2944 /* Try to minimize scrolling, by setting the window start to the 2936 /* Try to minimize scrolling, by setting the window start to the
2945 point will cause the text at the old window start to be at the 2937 point will cause the text at the old window start to be at the
@@ -2948,18 +2940,18 @@ window-start value is reasonable when this function is called. */)
2948 when the display is not current, due to typeahead). */ 2940 when the display is not current, due to typeahead). */
2949 new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); 2941 new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w)));
2950 if (new_top != top 2942 if (new_top != top
2951 && startpos >= BUF_BEGV (XBUFFER (w->buffer)) 2943 && startpos >= BUF_BEGV (XBUFFER (w->contents))
2952 && startpos <= BUF_ZV (XBUFFER (w->buffer))) 2944 && startpos <= BUF_ZV (XBUFFER (w->contents)))
2953 { 2945 {
2954 struct position pos; 2946 struct position pos;
2955 struct buffer *obuf = current_buffer; 2947 struct buffer *obuf = current_buffer;
2956 2948
2957 Fset_buffer (w->buffer); 2949 Fset_buffer (w->contents);
2958 /* This computation used to temporarily move point, but that 2950 /* This computation used to temporarily move point, but that
2959 can have unwanted side effects due to text properties. */ 2951 can have unwanted side effects due to text properties. */
2960 pos = *vmotion (startpos, startbyte, -top, w); 2952 pos = *vmotion (startpos, startbyte, -top, w);
2961 2953
2962 set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); 2954 set_marker_both (w->start, w->contents, pos.bufpos, pos.bytepos);
2963 w->window_end_valid = 0; 2955 w->window_end_valid = 0;
2964 w->start_at_line_beg = (pos.bytepos == BEGV_BYTE 2956 w->start_at_line_beg = (pos.bytepos == BEGV_BYTE
2965 || FETCH_BYTE (pos.bytepos - 1) == '\n'); 2957 || FETCH_BYTE (pos.bytepos - 1) == '\n');
@@ -3159,7 +3151,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3159 struct window *w = XWINDOW (window); 3151 struct window *w = XWINDOW (window);
3160 struct buffer *b = XBUFFER (buffer); 3152 struct buffer *b = XBUFFER (buffer);
3161 ptrdiff_t count = SPECPDL_INDEX (); 3153 ptrdiff_t count = SPECPDL_INDEX ();
3162 int samebuf = EQ (buffer, w->buffer); 3154 int samebuf = EQ (buffer, w->contents);
3163 3155
3164 wset_buffer (w, buffer); 3156 wset_buffer (w, buffer);
3165 3157
@@ -3278,7 +3270,7 @@ This function runs `window-scroll-functions' before running
3278 if (!BUFFER_LIVE_P (XBUFFER (buffer))) 3270 if (!BUFFER_LIVE_P (XBUFFER (buffer)))
3279 error ("Attempt to display deleted buffer"); 3271 error ("Attempt to display deleted buffer");
3280 3272
3281 tem = w->buffer; 3273 tem = w->contents;
3282 if (NILP (tem)) 3274 if (NILP (tem))
3283 error ("Window is deleted"); 3275 error ("Window is deleted");
3284 else 3276 else
@@ -3331,8 +3323,8 @@ displaying that buffer. */)
3331 struct window *w = XWINDOW (object); 3323 struct window *w = XWINDOW (object);
3332 mark_window_display_accurate (object, 0); 3324 mark_window_display_accurate (object, 0);
3333 w->update_mode_line = 1; 3325 w->update_mode_line = 1;
3334 if (BUFFERP (w->buffer)) 3326 if (BUFFERP (w->contents))
3335 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 3327 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
3336 ++update_mode_lines; 3328 ++update_mode_lines;
3337 return Qt; 3329 return Qt;
3338 } 3330 }
@@ -3401,7 +3393,7 @@ temp_output_buffer_show (register Lisp_Object buf)
3401 record_unwind_protect (Fset_buffer, prev_buffer); 3393 record_unwind_protect (Fset_buffer, prev_buffer);
3402 record_unwind_protect (select_window_norecord, prev_window); 3394 record_unwind_protect (select_window_norecord, prev_window);
3403 Fselect_window (window, Qt); 3395 Fselect_window (window, Qt);
3404 Fset_buffer (w->buffer); 3396 Fset_buffer (w->contents);
3405 Frun_hooks (1, &Qtemp_buffer_show_hook); 3397 Frun_hooks (1, &Qtemp_buffer_show_hook);
3406 unbind_to (count, Qnil); 3398 unbind_to (count, Qnil);
3407 } 3399 }
@@ -3422,7 +3414,7 @@ make_parent_window (Lisp_Object window, bool horflag)
3422 memcpy ((char *) p + sizeof (struct vectorlike_header), 3414 memcpy ((char *) p + sizeof (struct vectorlike_header),
3423 (char *) o + sizeof (struct vectorlike_header), 3415 (char *) o + sizeof (struct vectorlike_header),
3424 word_size * VECSIZE (struct window)); 3416 word_size * VECSIZE (struct window));
3425 /* P's buffer slot may change from nil to a buffer. */ 3417 /* P's buffer slot may change from nil to a buffer... */
3426 adjust_window_count (p, 1); 3418 adjust_window_count (p, 1);
3427 XSETWINDOW (parent, p); 3419 XSETWINDOW (parent, p);
3428 3420
@@ -3431,12 +3423,11 @@ make_parent_window (Lisp_Object window, bool horflag)
3431 wset_next (o, Qnil); 3423 wset_next (o, Qnil);
3432 wset_prev (o, Qnil); 3424 wset_prev (o, Qnil);
3433 wset_parent (o, parent); 3425 wset_parent (o, parent);
3434 3426 /* ...but now P becomes an internal window. */
3435 wset_hchild (p, horflag ? window : Qnil);
3436 wset_vchild (p, horflag ? Qnil : window);
3437 wset_start (p, Qnil); 3427 wset_start (p, Qnil);
3438 wset_pointm (p, Qnil); 3428 wset_pointm (p, Qnil);
3439 wset_buffer (p, Qnil); 3429 wset_buffer (p, Qnil);
3430 wset_combination (p, horflag, window);
3440 wset_combination_limit (p, Qnil); 3431 wset_combination_limit (p, Qnil);
3441 wset_window_parameters (p, Qnil); 3432 wset_window_parameters (p, Qnil);
3442} 3433}
@@ -3525,10 +3516,10 @@ window_resize_check (struct window *w, bool horflag)
3525{ 3516{
3526 struct window *c; 3517 struct window *c;
3527 3518
3528 if (!NILP (w->vchild)) 3519 if (WINDOW_VERTICAL_COMBINATION_P (w))
3529 /* W is a vertical combination. */ 3520 /* W is a vertical combination. */
3530 { 3521 {
3531 c = XWINDOW (w->vchild); 3522 c = XWINDOW (w->contents);
3532 if (horflag) 3523 if (horflag)
3533 /* All child windows of W must have the same width as W. */ 3524 /* All child windows of W must have the same width as W. */
3534 { 3525 {
@@ -3556,10 +3547,10 @@ window_resize_check (struct window *w, bool horflag)
3556 return (sum_of_sizes == XINT (w->new_total)); 3547 return (sum_of_sizes == XINT (w->new_total));
3557 } 3548 }
3558 } 3549 }
3559 else if (!NILP (w->hchild)) 3550 else if (WINDOW_HORIZONTAL_COMBINATION_P (w))
3560 /* W is a horizontal combination. */ 3551 /* W is a horizontal combination. */
3561 { 3552 {
3562 c = XWINDOW (w->hchild); 3553 c = XWINDOW (w->contents);
3563 if (horflag) 3554 if (horflag)
3564 /* The sum of the widths of the child windows of W must equal W's 3555 /* The sum of the widths of the child windows of W must equal W's
3565 width. */ 3556 width. */
@@ -3626,10 +3617,10 @@ window_resize_apply (struct window *w, bool horflag)
3626 pos = w->top_line; 3617 pos = w->top_line;
3627 } 3618 }
3628 3619
3629 if (!NILP (w->vchild)) 3620 if (WINDOW_VERTICAL_COMBINATION_P (w))
3630 /* W is a vertical combination. */ 3621 /* W is a vertical combination. */
3631 { 3622 {
3632 c = XWINDOW (w->vchild); 3623 c = XWINDOW (w->contents);
3633 while (c) 3624 while (c)
3634 { 3625 {
3635 if (horflag) 3626 if (horflag)
@@ -3642,10 +3633,10 @@ window_resize_apply (struct window *w, bool horflag)
3642 c = NILP (c->next) ? 0 : XWINDOW (c->next); 3633 c = NILP (c->next) ? 0 : XWINDOW (c->next);
3643 } 3634 }
3644 } 3635 }
3645 else if (!NILP (w->hchild)) 3636 else if (WINDOW_HORIZONTAL_COMBINATION_P (w))
3646 /* W is a horizontal combination. */ 3637 /* W is a horizontal combination. */
3647 { 3638 {
3648 c = XWINDOW (w->hchild); 3639 c = XWINDOW (w->contents);
3649 while (c) 3640 while (c)
3650 { 3641 {
3651 if (horflag) 3642 if (horflag)
@@ -3728,7 +3719,7 @@ resize_frame_windows (struct frame *f, int size, bool horflag)
3728 ? 1 : 0))); 3719 ? 1 : 0)));
3729 3720
3730 r->top_line = FRAME_TOP_MARGIN (f); 3721 r->top_line = FRAME_TOP_MARGIN (f);
3731 if (NILP (r->vchild) && NILP (r->hchild)) 3722 if (WINDOW_LEAF_P (r))
3732 /* For a leaf root window just set the size. */ 3723 /* For a leaf root window just set the size. */
3733 if (horflag) 3724 if (horflag)
3734 r->total_cols = new_size; 3725 r->total_cols = new_size;
@@ -3843,9 +3834,9 @@ set correctly. See the code of `split-window' for how this is done. */)
3843 combination_limit = 3834 combination_limit =
3844 EQ (Vwindow_combination_limit, Qt) 3835 EQ (Vwindow_combination_limit, Qt)
3845 || NILP (o->parent) 3836 || NILP (o->parent)
3846 || NILP (horflag 3837 || (horflag
3847 ? (XWINDOW (o->parent)->hchild) 3838 ? WINDOW_VERTICAL_COMBINATION_P (XWINDOW (o->parent))
3848 : (XWINDOW (o->parent)->vchild)); 3839 : WINDOW_HORIZONTAL_COMBINATION_P (XWINDOW (o->parent)));
3849 3840
3850 /* We need a live reference window to initialize some parameters. */ 3841 /* We need a live reference window to initialize some parameters. */
3851 if (WINDOW_LIVE_P (old)) 3842 if (WINDOW_LIVE_P (old))
@@ -3915,17 +3906,12 @@ set correctly. See the code of `split-window' for how this is done. */)
3915 n = XWINDOW (new); 3906 n = XWINDOW (new);
3916 wset_frame (n, frame); 3907 wset_frame (n, frame);
3917 wset_parent (n, o->parent); 3908 wset_parent (n, o->parent);
3918 wset_vchild (n, Qnil);
3919 wset_hchild (n, Qnil);
3920 3909
3921 if (EQ (side, Qabove) || EQ (side, Qleft)) 3910 if (EQ (side, Qabove) || EQ (side, Qleft))
3922 { 3911 {
3923 wset_prev (n, o->prev); 3912 wset_prev (n, o->prev);
3924 if (NILP (n->prev)) 3913 if (NILP (n->prev))
3925 if (horflag) 3914 wset_combination (p, horflag, new);
3926 wset_hchild (p, new);
3927 else
3928 wset_vchild (p, new);
3929 else 3915 else
3930 wset_next (XWINDOW (n->prev), new); 3916 wset_next (XWINDOW (n->prev), new);
3931 wset_next (n, old); 3917 wset_next (n, old);
@@ -3974,7 +3960,7 @@ set correctly. See the code of `split-window' for how this is done. */)
3974 adjust_glyphs (f); 3960 adjust_glyphs (f);
3975 /* Set buffer of NEW to buffer of reference window. Don't run 3961 /* Set buffer of NEW to buffer of reference window. Don't run
3976 any hooks. */ 3962 any hooks. */
3977 set_window_buffer (new, r->buffer, 0, 1); 3963 set_window_buffer (new, r->contents, 0, 1);
3978 unblock_input (); 3964 unblock_input ();
3979 3965
3980 /* Maybe we should run the scroll functions in Elisp (which already 3966 /* Maybe we should run the scroll functions in Elisp (which already
@@ -3996,13 +3982,11 @@ Signal an error when WINDOW is the only window on its frame. */)
3996 register Lisp_Object parent, sibling, frame, root; 3982 register Lisp_Object parent, sibling, frame, root;
3997 struct window *w, *p, *s, *r; 3983 struct window *w, *p, *s, *r;
3998 struct frame *f; 3984 struct frame *f;
3999 bool horflag; 3985 bool horflag, before_sibling = 0;
4000 int before_sibling = 0;
4001 3986
4002 w = decode_any_window (window); 3987 w = decode_any_window (window);
4003 XSETWINDOW (window, w); 3988 XSETWINDOW (window, w);
4004 if (NILP (w->buffer) 3989 if (NILP (w->contents))
4005 && NILP (w->hchild) && NILP (w->vchild))
4006 /* It's a no-op to delete an already deleted window. */ 3990 /* It's a no-op to delete an already deleted window. */
4007 return Qnil; 3991 return Qnil;
4008 3992
@@ -4016,7 +4000,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4016 error ("Attempt to delete sole window of parent"); 4000 error ("Attempt to delete sole window of parent");
4017 4001
4018 p = XWINDOW (parent); 4002 p = XWINDOW (parent);
4019 horflag = NILP (p->vchild); 4003 horflag = WINDOW_HORIZONTAL_COMBINATION_P (p);
4020 4004
4021 frame = WINDOW_FRAME (w); 4005 frame = WINDOW_FRAME (w);
4022 f = XFRAME (frame); 4006 f = XFRAME (frame);
@@ -4034,10 +4018,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4034 sibling = w->next; 4018 sibling = w->next;
4035 s = XWINDOW (sibling); 4019 s = XWINDOW (sibling);
4036 wset_prev (s, Qnil); 4020 wset_prev (s, Qnil);
4037 if (horflag) 4021 wset_combination (p, horflag, sibling);
4038 wset_hchild (p, sibling);
4039 else
4040 wset_vchild (p, sibling);
4041 } 4022 }
4042 else 4023 else
4043 /* Get SIBLING above (on the left of) WINDOW. */ 4024 /* Get SIBLING above (on the left of) WINDOW. */
@@ -4079,17 +4060,12 @@ Signal an error when WINDOW is the only window on its frame. */)
4079 wset_next (w, Qnil); /* Don't delete w->next too. */ 4060 wset_next (w, Qnil); /* Don't delete w->next too. */
4080 free_window_matrices (w); 4061 free_window_matrices (w);
4081 4062
4082 if (!NILP (w->vchild)) 4063 if (WINDOWP (w->contents))
4083 { 4064 {
4084 delete_all_child_windows (w->vchild); 4065 delete_all_child_windows (w->contents);
4085 wset_vchild (w, Qnil); 4066 wset_combination (w, 0, Qnil);
4086 } 4067 }
4087 else if (!NILP (w->hchild)) 4068 else
4088 {
4089 delete_all_child_windows (w->hchild);
4090 wset_hchild (w, Qnil);
4091 }
4092 else if (!NILP (w->buffer))
4093 { 4069 {
4094 unshow_buffer (w); 4070 unshow_buffer (w);
4095 unchain_marker (XMARKER (w->pointm)); 4071 unchain_marker (XMARKER (w->pointm));
@@ -4108,8 +4084,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4108 wset_normal_cols (s, p->normal_cols); 4084 wset_normal_cols (s, p->normal_cols);
4109 wset_normal_lines (s, p->normal_lines); 4085 wset_normal_lines (s, p->normal_lines);
4110 /* Mark PARENT as deleted. */ 4086 /* Mark PARENT as deleted. */
4111 wset_vchild (p, Qnil); 4087 wset_combination (p, 0, Qnil);
4112 wset_hchild (p, Qnil);
4113 /* Try to merge SIBLING into its new parent. */ 4088 /* Try to merge SIBLING into its new parent. */
4114 recombine_windows (sibling); 4089 recombine_windows (sibling);
4115 } 4090 }
@@ -4157,10 +4132,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4157 if (before_sibling) 4132 if (before_sibling)
4158 { 4133 {
4159 wset_prev (s, window); 4134 wset_prev (s, window);
4160 if (horflag) 4135 wset_combination (p, horflag, window);
4161 wset_hchild (p, window);
4162 else
4163 wset_vchild (p, window);
4164 } 4136 }
4165 else 4137 else
4166 { 4138 {
@@ -4303,10 +4275,8 @@ mark_window_cursors_off (struct window *w)
4303{ 4275{
4304 while (w) 4276 while (w)
4305 { 4277 {
4306 if (!NILP (w->hchild)) 4278 if (WINDOWP (w->contents))
4307 mark_window_cursors_off (XWINDOW (w->hchild)); 4279 mark_window_cursors_off (XWINDOW (w->contents));
4308 else if (!NILP (w->vchild))
4309 mark_window_cursors_off (XWINDOW (w->vchild));
4310 else 4280 else
4311 w->phys_cursor_on_p = 0; 4281 w->phys_cursor_on_p = 0;
4312 4282
@@ -4325,8 +4295,7 @@ window_internal_height (struct window *w)
4325 if (!MINI_WINDOW_P (w)) 4295 if (!MINI_WINDOW_P (w))
4326 { 4296 {
4327 if (!NILP (w->parent) 4297 if (!NILP (w->parent)
4328 || !NILP (w->vchild) 4298 || WINDOWP (w->contents)
4329 || !NILP (w->hchild)
4330 || !NILP (w->next) 4299 || !NILP (w->next)
4331 || !NILP (w->prev) 4300 || !NILP (w->prev)
4332 || WINDOW_WANTS_MODELINE_P (w)) 4301 || WINDOW_WANTS_MODELINE_P (w))
@@ -4465,7 +4434,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4465 else 4434 else
4466 spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV); 4435 spos = min (XINT (Fline_end_position (Qnil)) + 1, ZV);
4467 set_marker_restricted (w->start, make_number (spos), 4436 set_marker_restricted (w->start, make_number (spos),
4468 w->buffer); 4437 w->contents);
4469 w->start_at_line_beg = 1; 4438 w->start_at_line_beg = 1;
4470 w->update_mode_line = 1; 4439 w->update_mode_line = 1;
4471 w->last_modified = 0; 4440 w->last_modified = 0;
@@ -4589,7 +4558,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4589 4558
4590 /* If control gets here, then we vscrolled. */ 4559 /* If control gets here, then we vscrolled. */
4591 4560
4592 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 4561 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
4593 4562
4594 /* Don't try to change the window start below. */ 4563 /* Don't try to change the window start below. */
4595 vscrolled = 1; 4564 vscrolled = 1;
@@ -4609,7 +4578,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4609 } 4578 }
4610 4579
4611 /* Set the window start, and set up the window for redisplay. */ 4580 /* Set the window start, and set up the window for redisplay. */
4612 set_marker_restricted_both (w->start, w->buffer, IT_CHARPOS (it), 4581 set_marker_restricted_both (w->start, w->contents, IT_CHARPOS (it),
4613 IT_BYTEPOS (it)); 4582 IT_BYTEPOS (it));
4614 bytepos = marker_byte_position (w->start); 4583 bytepos = marker_byte_position (w->start);
4615 w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); 4584 w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
@@ -4809,7 +4778,7 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror)
4809 int this_scroll_margin = 4778 int this_scroll_margin =
4810 max (0, min (scroll_margin, w->total_lines / 4)); 4779 max (0, min (scroll_margin, w->total_lines / 4));
4811 4780
4812 set_marker_restricted_both (w->start, w->buffer, pos, pos_byte); 4781 set_marker_restricted_both (w->start, w->contents, pos, pos_byte);
4813 w->start_at_line_beg = !NILP (bolp); 4782 w->start_at_line_beg = !NILP (bolp);
4814 w->update_mode_line = 1; 4783 w->update_mode_line = 1;
4815 w->last_modified = 0; 4784 w->last_modified = 0;
@@ -4903,10 +4872,10 @@ scroll_command (Lisp_Object n, int direction)
4903 4872
4904 /* If selected window's buffer isn't current, make it current for 4873 /* If selected window's buffer isn't current, make it current for
4905 the moment. But don't screw up if window_scroll gets an error. */ 4874 the moment. But don't screw up if window_scroll gets an error. */
4906 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 4875 if (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer)
4907 { 4876 {
4908 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 4877 record_unwind_protect (save_excursion_restore, save_excursion_save ());
4909 Fset_buffer (XWINDOW (selected_window)->buffer); 4878 Fset_buffer (XWINDOW (selected_window)->contents);
4910 4879
4911 /* Make redisplay consider other windows than just selected_window. */ 4880 /* Make redisplay consider other windows than just selected_window. */
4912 ++windows_or_buffers_changed; 4881 ++windows_or_buffers_changed;
@@ -5021,7 +4990,7 @@ specifies the window to scroll. This takes precedence over
5021 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 4990 record_unwind_protect (save_excursion_restore, save_excursion_save ());
5022 ++windows_or_buffers_changed; 4991 ++windows_or_buffers_changed;
5023 4992
5024 Fset_buffer (w->buffer); 4993 Fset_buffer (w->contents);
5025 SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm)); 4994 SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm));
5026 4995
5027 if (NILP (arg)) 4996 if (NILP (arg))
@@ -5115,10 +5084,10 @@ displayed_window_lines (struct window *w)
5115 int bottom_y; 5084 int bottom_y;
5116 void *itdata = NULL; 5085 void *itdata = NULL;
5117 5086
5118 if (XBUFFER (w->buffer) != current_buffer) 5087 if (XBUFFER (w->contents) != current_buffer)
5119 { 5088 {
5120 old_buffer = current_buffer; 5089 old_buffer = current_buffer;
5121 set_buffer_internal (XBUFFER (w->buffer)); 5090 set_buffer_internal (XBUFFER (w->contents));
5122 } 5091 }
5123 else 5092 else
5124 old_buffer = NULL; 5093 old_buffer = NULL;
@@ -5180,7 +5149,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5180 (register Lisp_Object arg) 5149 (register Lisp_Object arg)
5181{ 5150{
5182 struct window *w = XWINDOW (selected_window); 5151 struct window *w = XWINDOW (selected_window);
5183 struct buffer *buf = XBUFFER (w->buffer); 5152 struct buffer *buf = XBUFFER (w->contents);
5184 struct buffer *obuf = current_buffer; 5153 struct buffer *obuf = current_buffer;
5185 int center_p = 0; 5154 int center_p = 0;
5186 ptrdiff_t charpos, bytepos; 5155 ptrdiff_t charpos, bytepos;
@@ -5346,7 +5315,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5346 } 5315 }
5347 5316
5348 /* Set the new window start. */ 5317 /* Set the new window start. */
5349 set_marker_both (w->start, w->buffer, charpos, bytepos); 5318 set_marker_both (w->start, w->contents, charpos, bytepos);
5350 w->window_end_valid = 0; 5319 w->window_end_valid = 0;
5351 5320
5352 w->optional_new_start = 1; 5321 w->optional_new_start = 1;
@@ -5390,9 +5359,8 @@ zero means top of window, negative means relative to bottom of window. */)
5390 int this_scroll_margin; 5359 int this_scroll_margin;
5391#endif 5360#endif
5392 5361
5393 if (!(BUFFERP (w->buffer) 5362 if (!(BUFFERP (w->contents) && XBUFFER (w->contents) == current_buffer))
5394 && XBUFFER (w->buffer) == current_buffer)) 5363 /* This test is needed to make sure PT/PT_BYTE make sense in w->contents
5395 /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer
5396 when passed below to set_marker_both. */ 5364 when passed below to set_marker_both. */
5397 error ("move-to-window-line called from unrelated buffer"); 5365 error ("move-to-window-line called from unrelated buffer");
5398 5366
@@ -5402,7 +5370,7 @@ zero means top of window, negative means relative to bottom of window. */)
5402 { 5370 {
5403 int height = window_internal_height (w); 5371 int height = window_internal_height (w);
5404 Fvertical_motion (make_number (- (height / 2)), window); 5372 Fvertical_motion (make_number (- (height / 2)), window);
5405 set_marker_both (w->start, w->buffer, PT, PT_BYTE); 5373 set_marker_both (w->start, w->contents, PT, PT_BYTE);
5406 w->start_at_line_beg = !NILP (Fbolp ()); 5374 w->start_at_line_beg = !NILP (Fbolp ());
5407 w->force_start = 1; 5375 w->force_start = 1;
5408 } 5376 }
@@ -5552,9 +5520,9 @@ the return value is nil. Otherwise the value is t. */)
5552 window-point of the final-selected-window to the window-point of 5520 window-point of the final-selected-window to the window-point of
5553 the current-selected-window. So we have to be careful which 5521 the current-selected-window. So we have to be careful which
5554 point of the current-buffer we copy into old_point. */ 5522 point of the current-buffer we copy into old_point. */
5555 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) 5523 if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer)
5556 && WINDOWP (selected_window) 5524 && WINDOWP (selected_window)
5557 && EQ (XWINDOW (selected_window)->buffer, new_current_buffer) 5525 && EQ (XWINDOW (selected_window)->contents, new_current_buffer)
5558 && !EQ (selected_window, data->current_window)) 5526 && !EQ (selected_window, data->current_window))
5559 old_point = marker_position (XWINDOW (data->current_window)->pointm); 5527 old_point = marker_position (XWINDOW (data->current_window)->pointm);
5560 else 5528 else
@@ -5568,7 +5536,7 @@ the return value is nil. Otherwise the value is t. */)
5568 So if possible we want this arbitrary choice of "which point" to 5536 So if possible we want this arbitrary choice of "which point" to
5569 be the one from the to-be-selected-window so as to prevent this 5537 be the one from the to-be-selected-window so as to prevent this
5570 window's cursor from being copied from another window. */ 5538 window's cursor from being copied from another window. */
5571 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer) 5539 if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer)
5572 /* If current_window = selected_window, its point is in BUF_PT. */ 5540 /* If current_window = selected_window, its point is in BUF_PT. */
5573 && !EQ (selected_window, data->current_window)) 5541 && !EQ (selected_window, data->current_window))
5574 old_point = marker_position (XWINDOW (data->current_window)->pointm); 5542 old_point = marker_position (XWINDOW (data->current_window)->pointm);
@@ -5610,8 +5578,8 @@ the return value is nil. Otherwise the value is t. */)
5610 p = SAVED_WINDOW_N (saved_windows, k); 5578 p = SAVED_WINDOW_N (saved_windows, k);
5611 window = p->window; 5579 window = p->window;
5612 w = XWINDOW (window); 5580 w = XWINDOW (window);
5613 if (!NILP (w->buffer) 5581 if (BUFFERP (w->contents)
5614 && !EQ (w->buffer, p->buffer) 5582 && !EQ (w->contents, p->buffer)
5615 && BUFFER_LIVE_P (XBUFFER (p->buffer))) 5583 && BUFFER_LIVE_P (XBUFFER (p->buffer)))
5616 /* If a window we restore gets another buffer, record the 5584 /* If a window we restore gets another buffer, record the
5617 window's old buffer. */ 5585 window's old buffer. */
@@ -5644,13 +5612,13 @@ the return value is nil. Otherwise the value is t. */)
5644 window holds garbage.) We do this now, before 5612 window holds garbage.) We do this now, before
5645 restoring the window contents, and prevent it from 5613 restoring the window contents, and prevent it from
5646 being done later on when we select a new window. */ 5614 being done later on when we select a new window. */
5647 if (! NILP (XWINDOW (selected_window)->buffer)) 5615 if (! NILP (XWINDOW (selected_window)->contents))
5648 { 5616 {
5649 w = XWINDOW (selected_window); 5617 w = XWINDOW (selected_window);
5650 set_marker_both (w->pointm, 5618 set_marker_both (w->pointm,
5651 w->buffer, 5619 w->contents,
5652 BUF_PT (XBUFFER (w->buffer)), 5620 BUF_PT (XBUFFER (w->contents)),
5653 BUF_PT_BYTE (XBUFFER (w->buffer))); 5621 BUF_PT_BYTE (XBUFFER (w->contents)));
5654 } 5622 }
5655 5623
5656 windows_or_buffers_changed++; 5624 windows_or_buffers_changed++;
@@ -5697,18 +5665,10 @@ the return value is nil. Otherwise the value is t. */)
5697 { 5665 {
5698 wset_prev (w, Qnil); 5666 wset_prev (w, Qnil);
5699 if (!NILP (w->parent)) 5667 if (!NILP (w->parent))
5700 { 5668 wset_combination (XWINDOW (w->parent),
5701 if (XINT (p->total_cols) == XWINDOW (w->parent)->total_cols) 5669 (XINT (p->total_cols)
5702 { 5670 != XWINDOW (w->parent)->total_cols),
5703 wset_vchild (XWINDOW (w->parent), p->window); 5671 p->window);
5704 wset_hchild (XWINDOW (w->parent), Qnil);
5705 }
5706 else
5707 {
5708 wset_hchild (XWINDOW (w->parent), p->window);
5709 wset_vchild (XWINDOW (w->parent), Qnil);
5710 }
5711 }
5712 } 5672 }
5713 5673
5714 /* If we squirreled away the buffer, restore it now. */ 5674 /* If we squirreled away the buffer, restore it now. */
@@ -5757,20 +5717,16 @@ the return value is nil. Otherwise the value is t. */)
5757 w->last_modified = 0; 5717 w->last_modified = 0;
5758 w->last_overlay_modified = 0; 5718 w->last_overlay_modified = 0;
5759 5719
5760 /* Reinstall the saved buffer and pointers into it. */ 5720 if (BUFFERP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
5761 if (NILP (p->buffer))
5762 /* An internal window. */
5763 wset_buffer (w, p->buffer);
5764 else if (BUFFER_LIVE_P (XBUFFER (p->buffer)))
5765 /* If saved buffer is alive, install it. */ 5721 /* If saved buffer is alive, install it. */
5766 { 5722 {
5767 wset_buffer (w, p->buffer); 5723 wset_buffer (w, p->buffer);
5768 w->start_at_line_beg = !NILP (p->start_at_line_beg); 5724 w->start_at_line_beg = !NILP (p->start_at_line_beg);
5769 set_marker_restricted (w->start, p->start, w->buffer); 5725 set_marker_restricted (w->start, p->start, w->contents);
5770 set_marker_restricted (w->pointm, p->pointm, 5726 set_marker_restricted (w->pointm, p->pointm,
5771 w->buffer); 5727 w->contents);
5772 Fset_marker (BVAR (XBUFFER (w->buffer), mark), 5728 Fset_marker (BVAR (XBUFFER (w->contents), mark),
5773 p->mark, w->buffer); 5729 p->mark, w->contents);
5774 5730
5775 /* As documented in Fcurrent_window_configuration, don't 5731 /* As documented in Fcurrent_window_configuration, don't
5776 restore the location of point in the buffer which was 5732 restore the location of point in the buffer which was
@@ -5779,23 +5735,21 @@ the return value is nil. Otherwise the value is t. */)
5779 && XBUFFER (p->buffer) == current_buffer) 5735 && XBUFFER (p->buffer) == current_buffer)
5780 Fgoto_char (w->pointm); 5736 Fgoto_char (w->pointm);
5781 } 5737 }
5782 else if (!NILP (w->buffer) 5738 else if (BUFFERP (w->contents) && BUFFER_LIVE_P (XBUFFER (w->contents)))
5783 && BUFFER_LIVE_P (XBUFFER (w->buffer))) 5739 /* Keep window's old buffer; make sure the markers are real. */
5784 /* Keep window's old buffer; make sure the markers are 5740 {
5785 real. */ 5741 /* Set window markers at start of visible range. */
5786 { 5742 if (XMARKER (w->start)->buffer == 0)
5787 /* Set window markers at start of visible range. */ 5743 set_marker_restricted_both (w->start, w->contents, 0, 0);
5788 if (XMARKER (w->start)->buffer == 0) 5744 if (XMARKER (w->pointm)->buffer == 0)
5789 set_marker_restricted_both (w->start, w->buffer, 0, 0); 5745 set_marker_restricted_both
5790 if (XMARKER (w->pointm)->buffer == 0) 5746 (w->pointm, w->contents,
5791 set_marker_restricted_both 5747 BUF_PT (XBUFFER (w->contents)),
5792 (w->pointm, w->buffer, 5748 BUF_PT_BYTE (XBUFFER (w->contents)));
5793 BUF_PT (XBUFFER (w->buffer)), 5749 w->start_at_line_beg = 1;
5794 BUF_PT_BYTE (XBUFFER (w->buffer))); 5750 }
5795 w->start_at_line_beg = 1; 5751 else if (!NILP (w->start))
5796 } 5752 /* Leaf window has no live buffer, get one. */
5797 else
5798 /* Window has no live buffer, get one. */
5799 { 5753 {
5800 /* Get the buffer via other_buffer_safely in order to 5754 /* Get the buffer via other_buffer_safely in order to
5801 avoid showing an unimportant buffer and, if necessary, to 5755 avoid showing an unimportant buffer and, if necessary, to
@@ -5804,8 +5758,8 @@ the return value is nil. Otherwise the value is t. */)
5804 wset_buffer (w, other_buffer_safely (Fcurrent_buffer ())); 5758 wset_buffer (w, other_buffer_safely (Fcurrent_buffer ()));
5805 /* This will set the markers to beginning of visible 5759 /* This will set the markers to beginning of visible
5806 range. */ 5760 range. */
5807 set_marker_restricted_both (w->start, w->buffer, 0, 0); 5761 set_marker_restricted_both (w->start, w->contents, 0, 0);
5808 set_marker_restricted_both (w->pointm, w->buffer, 0, 0); 5762 set_marker_restricted_both (w->pointm, w->contents, 0, 0);
5809 w->start_at_line_beg = 1; 5763 w->start_at_line_beg = 1;
5810 if (!NILP (w->dedicated)) 5764 if (!NILP (w->dedicated))
5811 /* Record this window as dead. */ 5765 /* Record this window as dead. */
@@ -5818,17 +5772,17 @@ the return value is nil. Otherwise the value is t. */)
5818 fset_root_window (f, data->root_window); 5772 fset_root_window (f, data->root_window);
5819 /* Arrange *not* to restore point in the buffer that was 5773 /* Arrange *not* to restore point in the buffer that was
5820 current when the window configuration was saved. */ 5774 current when the window configuration was saved. */
5821 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) 5775 if (EQ (XWINDOW (data->current_window)->contents, new_current_buffer))
5822 set_marker_restricted (XWINDOW (data->current_window)->pointm, 5776 set_marker_restricted (XWINDOW (data->current_window)->pointm,
5823 make_number (old_point), 5777 make_number (old_point),
5824 XWINDOW (data->current_window)->buffer); 5778 XWINDOW (data->current_window)->contents);
5825 5779
5826 /* In the following call to `select-window', prevent "swapping out 5780 /* In the following call to `select-window', prevent "swapping out
5827 point" in the old selected window using the buffer that has 5781 point" in the old selected window using the buffer that has
5828 been restored into it. We already swapped out that point from 5782 been restored into it. We already swapped out that point from
5829 that window's old buffer. */ 5783 that window's old buffer. */
5830 select_window (data->current_window, Qnil, 1); 5784 select_window (data->current_window, Qnil, 1);
5831 BVAR (XBUFFER (XWINDOW (selected_window)->buffer), last_selected_window) 5785 BVAR (XBUFFER (XWINDOW (selected_window)->contents), last_selected_window)
5832 = selected_window; 5786 = selected_window;
5833 5787
5834 if (NILP (data->focus_frame) 5788 if (NILP (data->focus_frame)
@@ -5855,14 +5809,9 @@ the return value is nil. Otherwise the value is t. */)
5855 /* Now, free glyph matrices in windows that were not reused. */ 5809 /* Now, free glyph matrices in windows that were not reused. */
5856 for (i = n = 0; i < n_leaf_windows; ++i) 5810 for (i = n = 0; i < n_leaf_windows; ++i)
5857 { 5811 {
5858 if (NILP (leaf_windows[i]->buffer)) 5812 if (NILP (leaf_windows[i]->contents))
5859 { 5813 free_window_matrices (leaf_windows[i]);
5860 /* Assert it's not reused as a combination. */ 5814 else if (EQ (leaf_windows[i]->contents, new_current_buffer))
5861 eassert (NILP (leaf_windows[i]->hchild)
5862 && NILP (leaf_windows[i]->vchild));
5863 free_window_matrices (leaf_windows[i]);
5864 }
5865 else if (EQ (leaf_windows[i]->buffer, new_current_buffer))
5866 ++n; 5815 ++n;
5867 } 5816 }
5868 5817
@@ -5893,7 +5842,7 @@ the return value is nil. Otherwise the value is t. */)
5893 Fset_buffer (new_current_buffer); 5842 Fset_buffer (new_current_buffer);
5894 /* If the new current buffer doesn't appear in the selected 5843 /* If the new current buffer doesn't appear in the selected
5895 window, go to its old point (see bug#12208). */ 5844 window, go to its old point (see bug#12208). */
5896 if (!EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)) 5845 if (!EQ (XWINDOW (data->current_window)->contents, new_current_buffer))
5897 Fgoto_char (make_number (old_point)); 5846 Fgoto_char (make_number (old_point));
5898 } 5847 }
5899 5848
@@ -5904,8 +5853,10 @@ the return value is nil. Otherwise the value is t. */)
5904} 5853}
5905 5854
5906 5855
5907/* Recursively delete all child windows reachable via the next, vchild, 5856/* If WINDOW is an internal window, recursively delete all child windows
5908 and hchild slots of WINDOW. */ 5857 reachable via the next and contents slots of WINDOW. Otherwise setup
5858 WINDOW to not show any buffer. */
5859
5909void 5860void
5910delete_all_child_windows (Lisp_Object window) 5861delete_all_child_windows (Lisp_Object window)
5911{ 5862{
@@ -5917,17 +5868,12 @@ delete_all_child_windows (Lisp_Object window)
5917 /* Delete WINDOW's siblings (we traverse postorderly). */ 5868 /* Delete WINDOW's siblings (we traverse postorderly). */
5918 delete_all_child_windows (w->next); 5869 delete_all_child_windows (w->next);
5919 5870
5920 if (!NILP (w->vchild)) 5871 if (WINDOWP (w->contents))
5921 {
5922 delete_all_child_windows (w->vchild);
5923 wset_vchild (w, Qnil);
5924 }
5925 else if (!NILP (w->hchild))
5926 { 5872 {
5927 delete_all_child_windows (w->hchild); 5873 delete_all_child_windows (w->contents);
5928 wset_hchild (w, Qnil); 5874 wset_combination (w, 0, Qnil);
5929 } 5875 }
5930 else if (!NILP (w->buffer)) 5876 else if (BUFFERP (w->contents))
5931 { 5877 {
5932 unshow_buffer (w); 5878 unshow_buffer (w);
5933 unchain_marker (XMARKER (w->pointm)); 5879 unchain_marker (XMARKER (w->pointm));
@@ -5935,7 +5881,7 @@ delete_all_child_windows (Lisp_Object window)
5935 /* Since combination limit makes sense for an internal windows 5881 /* Since combination limit makes sense for an internal windows
5936 only, we use this slot to save the buffer for the sake of 5882 only, we use this slot to save the buffer for the sake of
5937 possible resurrection in Fset_window_configuration. */ 5883 possible resurrection in Fset_window_configuration. */
5938 wset_combination_limit (w, w->buffer); 5884 wset_combination_limit (w, w->contents);
5939 wset_buffer (w, Qnil); 5885 wset_buffer (w, Qnil);
5940 } 5886 }
5941 5887
@@ -5948,10 +5894,8 @@ count_windows (register struct window *window)
5948 register int count = 1; 5894 register int count = 1;
5949 if (!NILP (window->next)) 5895 if (!NILP (window->next))
5950 count += count_windows (XWINDOW (window->next)); 5896 count += count_windows (XWINDOW (window->next));
5951 if (!NILP (window->vchild)) 5897 if (WINDOWP (window->contents))
5952 count += count_windows (XWINDOW (window->vchild)); 5898 count += count_windows (XWINDOW (window->contents));
5953 if (!NILP (window->hchild))
5954 count += count_windows (XWINDOW (window->hchild));
5955 return count; 5899 return count;
5956} 5900}
5957 5901
@@ -5963,10 +5907,8 @@ get_leaf_windows (struct window *w, struct window **flat, int i)
5963{ 5907{
5964 while (w) 5908 while (w)
5965 { 5909 {
5966 if (!NILP (w->hchild)) 5910 if (WINDOWP (w->contents))
5967 i = get_leaf_windows (XWINDOW (w->hchild), flat, i); 5911 i = get_leaf_windows (XWINDOW (w->contents), flat, i);
5968 else if (!NILP (w->vchild))
5969 i = get_leaf_windows (XWINDOW (w->vchild), flat, i);
5970 else 5912 else
5971 flat[i++] = w; 5913 flat[i++] = w;
5972 5914
@@ -6006,7 +5948,7 @@ get_phys_cursor_glyph (struct window *w)
6006 hpos = row->used[TEXT_AREA] - 1; 5948 hpos = row->used[TEXT_AREA] - 1;
6007 } 5949 }
6008 5950
6009 if (hpos >= 0 && hpos < row->used[TEXT_AREA]) 5951 if (0 <= hpos && hpos < row->used[TEXT_AREA])
6010 glyph = row->glyphs[TEXT_AREA] + hpos; 5952 glyph = row->glyphs[TEXT_AREA] + hpos;
6011 else 5953 else
6012 glyph = NULL; 5954 glyph = NULL;
@@ -6022,14 +5964,14 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6022 register struct window *w; 5964 register struct window *w;
6023 register Lisp_Object tem, pers, par; 5965 register Lisp_Object tem, pers, par;
6024 5966
6025 for (;!NILP (window); window = w->next) 5967 for (; !NILP (window); window = w->next)
6026 { 5968 {
6027 p = SAVED_WINDOW_N (vector, i); 5969 p = SAVED_WINDOW_N (vector, i);
6028 w = XWINDOW (window); 5970 w = XWINDOW (window);
6029 5971
6030 wset_temslot (w, make_number (i)); i++; 5972 wset_temslot (w, make_number (i)); i++;
6031 p->window = window; 5973 p->window = window;
6032 p->buffer = w->buffer; 5974 p->buffer = (WINDOW_LEAF_P (w) ? w->contents : Qnil);
6033 p->left_col = make_number (w->left_col); 5975 p->left_col = make_number (w->left_col);
6034 p->top_line = make_number (w->top_line); 5976 p->top_line = make_number (w->top_line);
6035 p->total_cols = make_number (w->total_cols); 5977 p->total_cols = make_number (w->total_cols);
@@ -6096,15 +6038,15 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6096 } 6038 }
6097 } 6039 }
6098 6040
6099 if (!NILP (w->buffer)) 6041 if (BUFFERP (w->contents))
6100 { 6042 {
6101 /* Save w's value of point in the window configuration. If w 6043 /* Save w's value of point in the window configuration. If w
6102 is the selected window, then get the value of point from 6044 is the selected window, then get the value of point from
6103 the buffer; pointm is garbage in the selected window. */ 6045 the buffer; pointm is garbage in the selected window. */
6104 if (EQ (window, selected_window)) 6046 if (EQ (window, selected_window))
6105 p->pointm = build_marker (XBUFFER (w->buffer), 6047 p->pointm = build_marker (XBUFFER (w->contents),
6106 BUF_PT (XBUFFER (w->buffer)), 6048 BUF_PT (XBUFFER (w->contents)),
6107 BUF_PT_BYTE (XBUFFER (w->buffer))); 6049 BUF_PT_BYTE (XBUFFER (w->contents)));
6108 else 6050 else
6109 p->pointm = Fcopy_marker (w->pointm, Qnil); 6051 p->pointm = Fcopy_marker (w->pointm, Qnil);
6110 XMARKER (p->pointm)->insertion_type 6052 XMARKER (p->pointm)->insertion_type
@@ -6113,7 +6055,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6113 p->start = Fcopy_marker (w->start, Qnil); 6055 p->start = Fcopy_marker (w->start, Qnil);
6114 p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil; 6056 p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil;
6115 6057
6116 tem = BVAR (XBUFFER (w->buffer), mark); 6058 tem = BVAR (XBUFFER (w->contents), mark);
6117 p->mark = Fcopy_marker (tem, Qnil); 6059 p->mark = Fcopy_marker (tem, Qnil);
6118 } 6060 }
6119 else 6061 else
@@ -6134,10 +6076,8 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
6134 else 6076 else
6135 p->prev = XWINDOW (w->prev)->temslot; 6077 p->prev = XWINDOW (w->prev)->temslot;
6136 6078
6137 if (!NILP (w->vchild)) 6079 if (WINDOWP (w->contents))
6138 i = save_window_save (w->vchild, vector, i); 6080 i = save_window_save (w->contents, vector, i);
6139 if (!NILP (w->hchild))
6140 i = save_window_save (w->hchild, vector, i);
6141 } 6081 }
6142 6082
6143 return i; 6083 return i;
@@ -6454,7 +6394,7 @@ If PIXELS-P is non-nil, the return value is VSCROLL. */)
6454 adjust_glyphs (f); 6394 adjust_glyphs (f);
6455 6395
6456 /* Prevent redisplay shortcuts. */ 6396 /* Prevent redisplay shortcuts. */
6457 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 6397 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
6458 } 6398 }
6459 } 6399 }
6460 6400
@@ -6488,10 +6428,8 @@ foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *u
6488 6428
6489 for (cont = 1; w && cont;) 6429 for (cont = 1; w && cont;)
6490 { 6430 {
6491 if (!NILP (w->hchild)) 6431 if (WINDOWP (w->contents))
6492 cont = foreach_window_1 (XWINDOW (w->hchild), fn, user_data); 6432 cont = foreach_window_1 (XWINDOW (w->contents), fn, user_data);
6493 else if (!NILP (w->vchild))
6494 cont = foreach_window_1 (XWINDOW (w->vchild), fn, user_data);
6495 else 6433 else
6496 cont = fn (w, user_data); 6434 cont = fn (w, user_data);
6497 6435