aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorStefan Monnier2012-03-25 16:37:21 -0400
committerStefan Monnier2012-03-25 16:37:21 -0400
commit699c782b7668c44d0fa4446331b0590a6d5dac82 (patch)
tree5dcce364741d0761920a3d274b0fc8aba4103d45 /src/window.c
parent98fb480ee31bf74cf554044f60f21df16566dd7f (diff)
parente99a9b8bdccadded1f6fae88ee7a2a93dfd4eacf (diff)
downloademacs-pending.tar.gz
emacs-pending.zip
Merge from trunkpending
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c890
1 files changed, 489 insertions, 401 deletions
diff --git a/src/window.c b/src/window.c
index 154efe4a222..bcbf0ad2bde 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,6 +1,6 @@
1/* Window creation, deletion and examination for GNU Emacs. 1/* Window creation, deletion and examination for GNU Emacs.
2 Does not include redisplay. 2 Does not include redisplay.
3 Copyright (C) 1985-1987, 1993-1998, 2000-2011 3 Copyright (C) 1985-1987, 1993-1998, 2000-2012
4 Free Software Foundation, Inc. 4 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
@@ -57,7 +57,7 @@ static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window;
57static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; 57static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically;
58static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; 58static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
59static Lisp_Object Qsafe, Qabove, Qbelow; 59static Lisp_Object Qsafe, Qabove, Qbelow;
60static Lisp_Object Qauto_buffer_name; 60static Lisp_Object Qauto_buffer_name, Qclone_of;
61 61
62static int displayed_window_lines (struct window *); 62static int displayed_window_lines (struct window *);
63static struct window *decode_window (Lisp_Object); 63static struct window *decode_window (Lisp_Object);
@@ -159,7 +159,8 @@ DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0,
159 159
160DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0, 160DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0,
161 doc: /* Return t if OBJECT is a live window and nil otherwise. 161 doc: /* Return t if OBJECT is a live window and nil otherwise.
162A live window is a window that displays a buffer. */) 162A live window is a window that displays a buffer.
163Internal windows and deleted windows are not live. */)
163 (Lisp_Object object) 164 (Lisp_Object object)
164{ 165{
165 return WINDOW_LIVE_P (object) ? Qt : Qnil; 166 return WINDOW_LIVE_P (object) ? Qt : Qnil;
@@ -168,18 +169,17 @@ A live window is a window that displays a buffer. */)
168/* Frames and windows. */ 169/* Frames and windows. */
169DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, 170DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
170 doc: /* Return the frame that window WINDOW is on. 171 doc: /* Return the frame that window WINDOW is on.
171WINDOW can be any window and defaults to the selected one. */) 172If WINDOW is omitted or nil, it defaults to the selected window. */)
172 (Lisp_Object window) 173 (Lisp_Object window)
173{ 174{
174 return decode_any_window (window)->frame; 175 return decode_any_window (window)->frame;
175} 176}
176 177
177DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, 178DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
178 doc: /* Return the root window of FRAME_OR_WINDOW. 179 doc: /* Return the root window of FRAME-OR-WINDOW.
179If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. 180If omitted, FRAME-OR-WINDOW defaults to the currently selected frame.
180Else if FRAME_OR_WINDOW denotes any window, return the root window of 181With a frame argument, return that frame's root window.
181that window's frame. If FRAME_OR_WINDOW denotes a live frame, return 182With a window argument, return the root window of that window's frame. */)
182the root window of that frame. */)
183 (Lisp_Object frame_or_window) 183 (Lisp_Object frame_or_window)
184{ 184{
185 Lisp_Object window; 185 Lisp_Object window;
@@ -198,9 +198,8 @@ the root window of that frame. */)
198} 198}
199 199
200DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0, 200DEFUN ("minibuffer-window", Fminibuffer_window, Sminibuffer_window, 0, 1, 0,
201 doc: /* Return the window used now for minibuffers. 201 doc: /* Return the minibuffer window for frame FRAME.
202If the optional argument FRAME is specified, return the minibuffer window 202If FRAME is omitted or nil, it defaults to the selected frame. */)
203used by that frame. */)
204 (Lisp_Object frame) 203 (Lisp_Object frame)
205{ 204{
206 if (NILP (frame)) 205 if (NILP (frame))
@@ -212,7 +211,7 @@ used by that frame. */)
212DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, 211DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
213 Swindow_minibuffer_p, 0, 1, 0, 212 Swindow_minibuffer_p, 0, 1, 0,
214 doc: /* Return non-nil if WINDOW is a minibuffer window. 213 doc: /* Return non-nil if WINDOW is a minibuffer window.
215WINDOW can be any window and defaults to the selected one. */) 214If WINDOW is omitted or nil, it defaults to the selected window. */)
216 (Lisp_Object window) 215 (Lisp_Object window)
217{ 216{
218 return MINI_WINDOW_P (decode_any_window (window)) ? Qt : Qnil; 217 return MINI_WINDOW_P (decode_any_window (window)) ? Qt : Qnil;
@@ -220,10 +219,10 @@ WINDOW can be any window and defaults to the selected one. */)
220 219
221/* Don't move this to window.el - this must be a safe routine. */ 220/* Don't move this to window.el - this must be a safe routine. */
222DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, 221DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
223 doc: /* Return the topmost, leftmost live window on FRAME_OR_WINDOW. 222 doc: /* Return the topmost, leftmost live window on FRAME-OR-WINDOW.
224If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. 223If omitted, FRAME-OR-WINDOW defaults to the currently selected frame.
225Else if FRAME_OR_WINDOW denotes any window, return the first window of 224Else if FRAME-OR-WINDOW denotes any window, return the first window of
226that window's frame. If FRAME_OR_WINDOW denotes a live frame, return 225that window's frame. If FRAME-OR-WINDOW denotes a live frame, return
227the first window of that frame. */) 226the first window of that frame. */)
228 (Lisp_Object frame_or_window) 227 (Lisp_Object frame_or_window)
229{ 228{
@@ -254,10 +253,10 @@ the first window of that frame. */)
254 253
255DEFUN ("frame-selected-window", Fframe_selected_window, 254DEFUN ("frame-selected-window", Fframe_selected_window,
256 Sframe_selected_window, 0, 1, 0, 255 Sframe_selected_window, 0, 1, 0,
257 doc: /* Return the selected window of FRAME_OR_WINDOW. 256 doc: /* Return the selected window of FRAME-OR-WINDOW.
258If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. 257If omitted, FRAME-OR-WINDOW defaults to the currently selected frame.
259Else if FRAME_OR_WINDOW denotes any window, return the selected window 258Else if FRAME-OR-WINDOW denotes any window, return the selected window
260of that window's frame. If FRAME_OR_WINDOW denotes a live frame, return 259of that window's frame. If FRAME-OR-WINDOW denotes a live frame, return
261the selected window of that frame. */) 260the selected window of that frame. */)
262 (Lisp_Object frame_or_window) 261 (Lisp_Object frame_or_window)
263{ 262{
@@ -409,44 +408,48 @@ buffer of the selected window before each command. */)
409} 408}
410 409
411DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, 410DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0,
412 doc: /* Return the buffer that WINDOW is displaying. 411 doc: /* Return the buffer displayed in window WINDOW.
413WINDOW can be any window and defaults to the selected one. 412If WINDOW is omitted or nil, it defaults to the selected window.
414If WINDOW is an internal window return nil. */) 413Return nil for an internal window or a deleted window. */)
415 (Lisp_Object window) 414 (Lisp_Object window)
416{ 415{
417 return decode_any_window (window)->buffer; 416 return decode_any_window (window)->buffer;
418} 417}
419 418
420DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0, 419DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0,
421 doc: /* Return WINDOW's parent window. 420 doc: /* Return the parent window of window WINDOW.
422WINDOW can be any window and defaults to the selected one. 421If WINDOW is omitted or nil, it defaults to the selected window.
423Return nil if WINDOW has no parent. */) 422Return nil for a window with no parent (e.g. a root window). */)
424 (Lisp_Object window) 423 (Lisp_Object window)
425{ 424{
426 return decode_any_window (window)->parent; 425 return decode_any_window (window)->parent;
427} 426}
428 427
429DEFUN ("window-top-child", Fwindow_top_child, Swindow_top_child, 0, 1, 0, 428DEFUN ("window-top-child", Fwindow_top_child, Swindow_top_child, 1, 1, 0,
430 doc: /* Return WINDOW's topmost child window. 429 doc: /* Return the topmost child window of window WINDOW.
431WINDOW can be any window and defaults to the selected one. 430Return nil if WINDOW is a live window (live windows have no children).
432Return nil if WINDOW is not a vertical combination. */) 431Return nil if WINDOW is an internal window whose children form a
432horizontal combination. */)
433 (Lisp_Object window) 433 (Lisp_Object window)
434{ 434{
435 CHECK_WINDOW (window);
435 return decode_any_window (window)->vchild; 436 return decode_any_window (window)->vchild;
436} 437}
437 438
438DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 0, 1, 0, 439DEFUN ("window-left-child", Fwindow_left_child, Swindow_left_child, 1, 1, 0,
439 doc: /* Return WINDOW's leftmost child window. 440 doc: /* Return the leftmost child window of window WINDOW.
440WINDOW can be any window and defaults to the selected one. 441Return nil if WINDOW is a live window (live windows have no children).
441Return nil if WINDOW is not a horizontal combination. */) 442Return nil if WINDOW is an internal window whose children form a
443vertical combination. */)
442 (Lisp_Object window) 444 (Lisp_Object window)
443{ 445{
446 CHECK_WINDOW (window);
444 return decode_any_window (window)->hchild; 447 return decode_any_window (window)->hchild;
445} 448}
446 449
447DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0, 450DEFUN ("window-next-sibling", Fwindow_next_sibling, Swindow_next_sibling, 0, 1, 0,
448 doc: /* Return WINDOW's next sibling window. 451 doc: /* Return the next sibling window of window WINDOW.
449WINDOW can be any window and defaults to the selected one. 452If WINDOW is omitted or nil, it defaults to the selected window.
450Return nil if WINDOW has no next sibling. */) 453Return nil if WINDOW has no next sibling. */)
451 (Lisp_Object window) 454 (Lisp_Object window)
452{ 455{
@@ -454,123 +457,92 @@ Return nil if WINDOW has no next sibling. */)
454} 457}
455 458
456DEFUN ("window-prev-sibling", Fwindow_prev_sibling, Swindow_prev_sibling, 0, 1, 0, 459DEFUN ("window-prev-sibling", Fwindow_prev_sibling, Swindow_prev_sibling, 0, 1, 0,
457 doc: /* Return WINDOW's previous sibling window. 460 doc: /* Return the previous sibling window of window WINDOW.
458WINDOW can be any window and defaults to the selected one. 461If WINDOW is omitted or nil, it defaults to the selected window.
459Return nil if WINDOW has no previous sibling. */) 462Return nil if WINDOW has no previous sibling. */)
460 (Lisp_Object window) 463 (Lisp_Object window)
461{ 464{
462 return decode_any_window (window)->prev; 465 return decode_any_window (window)->prev;
463} 466}
464 467
465DEFUN ("window-splits", Fwindow_splits, Swindow_splits, 0, 1, 0, 468DEFUN ("window-combination-limit", Fwindow_combination_limit, Swindow_combination_limit, 1, 1, 0,
466 doc: /* Return splits status for WINDOW. 469 doc: /* Return combination limit of window WINDOW.
467WINDOW can be any window and defaults to the selected one. 470If the return value is nil, child windows of WINDOW can be recombined with
468 471WINDOW's siblings. A return value of t means that child windows of
469If the value returned by this function is nil and WINDOW is resized, the 472WINDOW are never \(re-)combined with WINDOW's siblings. */)
470corresponding space is preferably taken from (or given to) WINDOW's
471right sibling. When WINDOW is deleted, its space is given to its left
472sibling.
473
474If the value returned by this function is non-nil, resizing and deleting
475WINDOW may resize all windows in the same combination. */)
476 (Lisp_Object window) 473 (Lisp_Object window)
477{ 474{
478 return decode_any_window (window)->splits; 475 return decode_any_window (window)->combination_limit;
479} 476}
480 477
481DEFUN ("set-window-splits", Fset_window_splits, Sset_window_splits, 2, 2, 0, 478DEFUN ("set-window-combination-limit", Fset_window_combination_limit, Sset_window_combination_limit, 2, 2, 0,
482 doc: /* Set splits status of WINDOW to STATUS. 479 doc: /* Set combination limit of window WINDOW to LIMIT; return LIMIT.
483WINDOW can be any window and defaults to the selected one. Return 480If LIMIT is nil, child windows of WINDOW can be recombined with
484STATUS. 481WINDOW's siblings. LIMIT t means that child windows of WINDOW are
485 482never \(re-)combined with WINDOW's siblings. Other values are reserved
486If STATUS is nil and WINDOW is later resized, the corresponding space is 483for future use. */)
487preferably taken from (or given to) WINDOW's right sibling. When WINDOW 484 (Lisp_Object window, Lisp_Object limit)
488is deleted, its space is given to its left sibling.
489
490If STATUS is non-nil, resizing and deleting WINDOW may resize all
491windows in the same combination. */)
492 (Lisp_Object window, Lisp_Object status)
493{ 485{
494 register struct window *w = decode_any_window (window); 486 register struct window *w = decode_any_window (window);
495 487
496 w->splits = status; 488 w->combination_limit = limit;
497 489
498 return w->splits; 490 return w->combination_limit;
499} 491}
500 492
501DEFUN ("window-nest", Fwindow_nest, Swindow_nest, 0, 1, 0, 493DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0,
502 doc: /* Return nest status of WINDOW. 494 doc: /* Return the use time of window WINDOW.
503WINDOW can be any window and defaults to the selected one. 495If WINDOW is omitted or nil, it defaults to the selected window.
504 496The window with the highest use time is the most recently selected
505If the return value is nil, subwindows of WINDOW can be recombined with 497one. The window with the lowest use time is the least recently
506WINDOW's siblings. A return value of non-nil means that subwindows of 498selected one. */)
507WINDOW are never \(re-)combined with WINDOW's siblings. */)
508 (Lisp_Object window) 499 (Lisp_Object window)
509{ 500{
510 return decode_any_window (window)->nest; 501 return decode_window (window)->use_time;
511} 502}
503
504DEFUN ("window-total-height", Fwindow_total_height, Swindow_total_height, 0, 1, 0,
505 doc: /* Return the total height, in lines, of window WINDOW.
506If WINDOW is omitted or nil, it defaults to the selected window.
512 507
513DEFUN ("set-window-nest", Fset_window_nest, Sset_window_nest, 2, 2, 0, 508The return value includes the mode line and header line, if any.
514 doc: /* Set nest status of WINDOW to STATUS. 509If WINDOW is an internal window, the total height is the height
515WINDOW can be any window and defaults to the selected one. Return 510of the screen areas spanned by its children.
516STATUS.
517 511
518If STATUS is nil, subwindows of WINDOW can be recombined with WINDOW's 512On a graphical display, this total height is reported as an
519siblings. STATUS non-nil means that subwindows of WINDOW are never 513integer multiple of the default character height. */)
520\(re-)combined with WINDOW's siblings. */) 514 (Lisp_Object window)
521 (Lisp_Object window, Lisp_Object status)
522{ 515{
523 register struct window *w = decode_any_window (window); 516 return decode_any_window (window)->total_lines;
517}
524 518
525 w->nest = status; 519DEFUN ("window-total-width", Fwindow_total_width, Swindow_total_width, 0, 1, 0,
520 doc: /* Return the total width, in columns, of window WINDOW.
521If WINDOW is omitted or nil, it defaults to the selected window.
526 522
527 return w->nest; 523The return value includes any vertical dividers or scroll bars
528} 524belonging to WINDOW. If WINDOW is an internal window, the total width
525is the width of the screen areas spanned by its children.
529 526
530DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0, 527On a graphical display, this total width is reported as an
531 doc: /* Return WINDOW's use time. 528integer multiple of the default character width. */)
532WINDOW defaults to the selected window. The window with the highest use
533time is the most recently selected one. The window with the lowest use
534time is the least recently selected one. */)
535 (Lisp_Object window) 529 (Lisp_Object window)
536{ 530{
537 return decode_window (window)->use_time; 531 return decode_any_window (window)->total_cols;
538}
539
540DEFUN ("window-total-size", Fwindow_total_size, Swindow_total_size, 0, 2, 0,
541 doc: /* Return the total number of lines of WINDOW.
542WINDOW can be any window and defaults to the selected one. The return
543value includes WINDOW's mode line and header line, if any. If WINDOW
544is internal, the return value is the sum of the total number of lines
545of WINDOW's child windows if these are vertically combined and the
546height of WINDOW's first child otherwise.
547
548Optional argument HORIZONTAL non-nil means return the total number of
549columns of WINDOW. In this case the return value includes any vertical
550dividers or scrollbars of WINDOW. If WINDOW is internal, the return
551value is the sum of the total number of columns of WINDOW's child
552windows if they are horizontally combined and the width of WINDOW's
553first child otherwise. */)
554 (Lisp_Object window, Lisp_Object horizontal)
555{
556 if (NILP (horizontal))
557 return decode_any_window (window)->total_lines;
558 else
559 return decode_any_window (window)->total_cols;
560} 532}
561 533
562DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0, 534DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0,
563 doc: /* Return new total size of WINDOW. 535 doc: /* Return the new total size of window WINDOW.
564WINDOW defaults to the selected window. */) 536If WINDOW is omitted or nil, it defaults to the selected window. */)
565 (Lisp_Object window) 537 (Lisp_Object window)
566{ 538{
567 return decode_any_window (window)->new_total; 539 return decode_any_window (window)->new_total;
568} 540}
569 541
570DEFUN ("window-normal-size", Fwindow_normal_size, Swindow_normal_size, 0, 2, 0, 542DEFUN ("window-normal-size", Fwindow_normal_size, Swindow_normal_size, 0, 2, 0,
571 doc: /* Return normal height of WINDOW. 543 doc: /* Return the normal height of window WINDOW.
572WINDOW can be any window and defaults to the selected one. Optional 544If WINDOW is omitted or nil, it defaults to the selected window.
573argument HORIZONTAL non-nil means return normal width of WINDOW. */) 545If HORIZONTAL is non-nil, return the normal width of WINDOW. */)
574 (Lisp_Object window, Lisp_Object horizontal) 546 (Lisp_Object window, Lisp_Object horizontal)
575{ 547{
576 if (NILP (horizontal)) 548 if (NILP (horizontal))
@@ -580,24 +552,32 @@ argument HORIZONTAL non-nil means return normal width of WINDOW. */)
580} 552}
581 553
582DEFUN ("window-new-normal", Fwindow_new_normal, Swindow_new_normal, 0, 1, 0, 554DEFUN ("window-new-normal", Fwindow_new_normal, Swindow_new_normal, 0, 1, 0,
583 doc: /* Return new normal size of WINDOW. 555 doc: /* Return new normal size of window WINDOW.
584WINDOW can be any window and defaults to the selected one. */) 556If WINDOW is omitted or nil, it defaults to the selected window. */)
585 (Lisp_Object window) 557 (Lisp_Object window)
586{ 558{
587 return decode_any_window (window)->new_normal; 559 return decode_any_window (window)->new_normal;
588} 560}
589 561
590DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0, 562DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0,
591 doc: /* Return left column of WINDOW. 563 doc: /* Return left column of window WINDOW.
592WINDOW can be any window and defaults to the selected one. */) 564This is the distance, in columns, between the left edge of WINDOW and
565the left edge of the frame's window area. For instance, the return
566value is 0 if there is no window to the left of WINDOW.
567
568If WINDOW is omitted or nil, it defaults to the selected window. */)
593 (Lisp_Object window) 569 (Lisp_Object window)
594{ 570{
595 return decode_any_window (window)->left_col; 571 return decode_any_window (window)->left_col;
596} 572}
597 573
598DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0, 574DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0,
599 doc: /* Return top line of WINDOW. 575 doc: /* Return top line of window WINDOW.
600WINDOW can be any window and defaults to the selected one. */) 576This is the distance, in lines, between the top of WINDOW and the top
577of the frame's window area. For instance, the return value is 0 if
578there is no window above WINDOW.
579
580If WINDOW is omitted or nil, it defaults to the selected window. */)
601 (Lisp_Object window) 581 (Lisp_Object window)
602{ 582{
603 return decode_any_window (window)->top_line; 583 return decode_any_window (window)->top_line;
@@ -652,25 +632,34 @@ window_body_cols (struct window *w)
652 return width; 632 return width;
653} 633}
654 634
655DEFUN ("window-body-size", Fwindow_body_size, Swindow_body_size, 0, 2, 0, 635DEFUN ("window-body-height", Fwindow_body_height, Swindow_body_height, 0, 1, 0,
656 doc: /* Return the number of lines of WINDOW's body. 636 doc: /* Return the height, in lines, of WINDOW's text area.
657WINDOW must be a live window and defaults to the selected one. The 637If WINDOW is omitted or nil, it defaults to the selected window.
658return value does not include WINDOW's mode line and header line, if 638Signal an error if the window is not live.
659any. 639
660 640The returned height does not include the mode line or header line.
661Optional argument HORIZONTAL non-nil means return the number of columns 641On a graphical display, the height is expressed as an integer multiple
662of WINDOW's body. In this case, the return value does not include any 642of the default character height. If a line at the bottom of the text
663vertical dividers or scroll bars owned by WINDOW. On a window-system 643area is only partially visible, that counts as a whole line; to
664the return value does not include the number of columns used for 644exclude partially-visible lines, use `window-text-height'. */)
665WINDOW's fringes or display margins either. */) 645 (Lisp_Object window)
666 (Lisp_Object window, Lisp_Object horizontal)
667{ 646{
668 struct window *w = decode_any_window (window); 647 struct window *w = decode_window (window);
648 return make_number (window_body_lines (w));
649}
669 650
670 if (NILP (horizontal)) 651DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 1, 0,
671 return make_number (window_body_lines (w)); 652 doc: /* Return the width, in columns, of WINDOW's text area.
672 else 653If WINDOW is omitted or nil, it defaults to the selected window.
673 return make_number (window_body_cols (w)); 654Signal an error if the window is not live.
655
656The return value does not include any vertical dividers, fringe or
657marginal areas, or scroll bars. On a graphical display, the width is
658expressed as an integer multiple of the default character width. */)
659 (Lisp_Object window)
660{
661 struct window *w = decode_window (window);
662 return make_number (window_body_cols (w));
674} 663}
675 664
676DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, 665DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0,
@@ -683,6 +672,7 @@ WINDOW must be a live window and defaults to the selected one. */)
683 672
684DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0, 673DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0,
685 doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL. 674 doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL.
675If WINDOW is nil, the selected window is used.
686Return NCOL. NCOL should be zero or positive. 676Return NCOL. NCOL should be zero or positive.
687 677
688Note that if `automatic-hscrolling' is non-nil, you cannot scroll the 678Note that if `automatic-hscrolling' is non-nil, you cannot scroll the
@@ -774,7 +764,7 @@ of just the text area, use `window-inside-pixel-edges'. */)
774} 764}
775 765
776static void 766static void
777calc_absolute_offset(struct window *w, int *add_x, int *add_y) 767calc_absolute_offset (struct window *w, int *add_x, int *add_y)
778{ 768{
779 struct frame *f = XFRAME (w->frame); 769 struct frame *f = XFRAME (w->frame);
780 *add_y = f->top_pos; 770 *add_y = f->top_pos;
@@ -831,7 +821,7 @@ The inside edges do not include the space used by the WINDOW's scroll
831bar, display margins, fringes, header line, and/or mode line. */) 821bar, display margins, fringes, header line, and/or mode line. */)
832 (Lisp_Object window) 822 (Lisp_Object window)
833{ 823{
834 register struct window *w = decode_any_window (window); 824 register struct window *w = decode_window (window);
835 825
836 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_COL (w) 826 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_COL (w)
837 + WINDOW_LEFT_MARGIN_COLS (w) 827 + WINDOW_LEFT_MARGIN_COLS (w)
@@ -846,9 +836,9 @@ bar, display margins, fringes, header line, and/or mode line. */)
846} 836}
847 837
848DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0, 838DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges, Swindow_inside_pixel_edges, 0, 1, 0,
849 doc: /* Return a list of the edge pixel coordinates of WINDOW. 839 doc: /* Return a list of the edge pixel coordinates of WINDOW's text area.
850The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at 840The list has the form (LEFT TOP RIGHT BOTTOM), all relative to (0,0)
851the top left corner of the frame. 841at the top left corner of the frame's window area.
852 842
853RIGHT is one more than the rightmost x position of WINDOW's text area. 843RIGHT is one more than the rightmost x position of WINDOW's text area.
854BOTTOM is one more than the bottommost y position of WINDOW's text area. 844BOTTOM is one more than the bottommost y position of WINDOW's text area.
@@ -856,7 +846,7 @@ The inside edges do not include the space used by WINDOW's scroll bar,
856display margins, fringes, header line, and/or mode line. */) 846display margins, fringes, header line, and/or mode line. */)
857 (Lisp_Object window) 847 (Lisp_Object window)
858{ 848{
859 register struct window *w = decode_any_window (window); 849 register struct window *w = decode_window (window);
860 850
861 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w) 851 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w)
862 + WINDOW_LEFT_MARGIN_WIDTH (w) 852 + WINDOW_LEFT_MARGIN_WIDTH (w)
@@ -873,9 +863,9 @@ display margins, fringes, header line, and/or mode line. */)
873DEFUN ("window-inside-absolute-pixel-edges", 863DEFUN ("window-inside-absolute-pixel-edges",
874 Fwindow_inside_absolute_pixel_edges, 864 Fwindow_inside_absolute_pixel_edges,
875 Swindow_inside_absolute_pixel_edges, 0, 1, 0, 865 Swindow_inside_absolute_pixel_edges, 0, 1, 0,
876 doc: /* Return a list of the edge pixel coordinates of WINDOW. 866 doc: /* Return a list of the edge pixel coordinates of WINDOW's text area.
877The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at 867The list has the form (LEFT TOP RIGHT BOTTOM), all relative to (0,0)
878the top left corner of the display. 868at the top left corner of the frame's window area.
879 869
880RIGHT is one more than the rightmost x position of WINDOW's text area. 870RIGHT is one more than the rightmost x position of WINDOW's text area.
881BOTTOM is one more than the bottommost y position of WINDOW's text area. 871BOTTOM is one more than the bottommost y position of WINDOW's text area.
@@ -883,7 +873,7 @@ The inside edges do not include the space used by WINDOW's scroll bar,
883display margins, fringes, header line, and/or mode line. */) 873display margins, fringes, header line, and/or mode line. */)
884 (Lisp_Object window) 874 (Lisp_Object window)
885{ 875{
886 register struct window *w = decode_any_window (window); 876 register struct window *w = decode_window (window);
887 int add_x, add_y; 877 int add_x, add_y;
888 calc_absolute_offset (w, &add_x, &add_y); 878 calc_absolute_offset (w, &add_x, &add_y);
889 879
@@ -918,22 +908,45 @@ static enum window_part
918coordinates_in_window (register struct window *w, int x, int y) 908coordinates_in_window (register struct window *w, int x, int y)
919{ 909{
920 struct frame *f = XFRAME (WINDOW_FRAME (w)); 910 struct frame *f = XFRAME (WINDOW_FRAME (w));
921 int left_x, right_x;
922 enum window_part part; 911 enum window_part part;
923 int ux = FRAME_COLUMN_WIDTH (f); 912 int ux = FRAME_COLUMN_WIDTH (f);
924 int x0 = WINDOW_LEFT_EDGE_X (w); 913 int left_x = WINDOW_LEFT_EDGE_X (w);
925 int x1 = WINDOW_RIGHT_EDGE_X (w); 914 int right_x = WINDOW_RIGHT_EDGE_X (w);
915 int top_y = WINDOW_TOP_EDGE_Y (w);
916 int bottom_y = WINDOW_BOTTOM_EDGE_Y (w);
926 /* The width of the area where the vertical line can be dragged. 917 /* The width of the area where the vertical line can be dragged.
927 (Between mode lines for instance. */ 918 (Between mode lines for instance. */
928 int grabbable_width = ux; 919 int grabbable_width = ux;
929 int lmargin_width, rmargin_width, text_left, text_right; 920 int lmargin_width, rmargin_width, text_left, text_right;
930 int top_y = WINDOW_TOP_EDGE_Y (w);
931 int bottom_y = WINDOW_BOTTOM_EDGE_Y (w);
932 921
933 /* Outside any interesting row? */ 922 /* Outside any interesting row or column? */
934 if (y < top_y || y >= bottom_y) 923 if (y < top_y || y >= bottom_y || x < left_x || x >= right_x)
935 return ON_NOTHING; 924 return ON_NOTHING;
936 925
926 /* On the mode line or header line? */
927 if ((WINDOW_WANTS_MODELINE_P (w)
928 && y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w)
929 && (part = ON_MODE_LINE))
930 || (WINDOW_WANTS_HEADER_LINE_P (w)
931 && y < top_y + CURRENT_HEADER_LINE_HEIGHT (w)
932 && (part = ON_HEADER_LINE)))
933 {
934 /* If it's under/over the scroll bar portion of the mode/header
935 line, say it's on the vertical line. That's to be able to
936 resize windows horizontally in case we're using toolkit scroll
937 bars. Note: If scrollbars are on the left, the window that
938 must be eventually resized is that on the left of WINDOW. */
939 if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)
940 && !WINDOW_LEFTMOST_P (w)
941 && eabs (x - left_x) < grabbable_width)
942 || (!WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)
943 && !WINDOW_RIGHTMOST_P (w)
944 && eabs (x - right_x) < grabbable_width))
945 return ON_VERTICAL_BORDER;
946 else
947 return part;
948 }
949
937 /* In what's below, we subtract 1 when computing right_x because we 950 /* In what's below, we subtract 1 when computing right_x because we
938 want the rightmost pixel, which is given by left_pixel+width-1. */ 951 want the rightmost pixel, which is given by left_pixel+width-1. */
939 if (w->pseudo_window_p) 952 if (w->pseudo_window_p)
@@ -947,50 +960,6 @@ coordinates_in_window (register struct window *w, int x, int y)
947 right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1; 960 right_x = WINDOW_BOX_RIGHT_EDGE_X (w) - 1;
948 } 961 }
949 962
950 /* On the mode line or header line? If it's near the start of
951 the mode or header line of window that's has a horizontal
952 sibling, say it's on the vertical line. That's to be able
953 to resize windows horizontally in case we're using toolkit
954 scroll bars. */
955
956 if (WINDOW_WANTS_MODELINE_P (w)
957 && y >= bottom_y - CURRENT_MODE_LINE_HEIGHT (w))
958 {
959 part = ON_MODE_LINE;
960
961 header_vertical_border_check:
962 /* We're somewhere on the mode line. We consider the place
963 between mode lines of horizontally adjacent mode lines
964 as the vertical border. If scroll bars on the left,
965 return the right window. */
966 if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)
967 || WINDOW_RIGHTMOST_P (w))
968 && !WINDOW_LEFTMOST_P (w)
969 && eabs (x - x0) < grabbable_width)
970 return ON_VERTICAL_BORDER;
971
972 /* Make sure we're not at the rightmost position of a
973 mode-/header-line and there's yet another window on the
974 right. (Bug#1372) */
975 else if ((WINDOW_RIGHTMOST_P (w) || x < x1)
976 && eabs (x - x1) < grabbable_width)
977 return ON_VERTICAL_BORDER;
978
979 if (x < x0 || x >= x1)
980 return ON_NOTHING;
981
982 return part;
983 }
984
985 if (WINDOW_WANTS_HEADER_LINE_P (w)
986 && y < top_y + CURRENT_HEADER_LINE_HEIGHT (w))
987 {
988 part = ON_HEADER_LINE;
989 goto header_vertical_border_check;
990 }
991
992 if (x < x0 || x >= x1) return ON_NOTHING;
993
994 /* Outside any interesting column? */ 963 /* Outside any interesting column? */
995 if (x < left_x || x > right_x) 964 if (x < left_x || x > right_x)
996 return ON_SCROLL_BAR; 965 return ON_SCROLL_BAR;
@@ -1083,6 +1052,7 @@ window_relative_x_coord (struct window *w, enum window_part part, int x)
1083DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p, 1052DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p,
1084 Scoordinates_in_window_p, 2, 2, 0, 1053 Scoordinates_in_window_p, 2, 2, 0,
1085 doc: /* Return non-nil if COORDINATES are in WINDOW. 1054 doc: /* Return non-nil if COORDINATES are in WINDOW.
1055WINDOW must be a live window.
1086COORDINATES is a cons of the form (X . Y), X and Y being distances 1056COORDINATES is a cons of the form (X . Y), X and Y being distances
1087measured in characters from the upper-left corner of the frame. 1057measured in characters from the upper-left corner of the frame.
1088\(0 . 0) denotes the character in the upper left corner of the 1058\(0 . 0) denotes the character in the upper left corner of the
@@ -1104,7 +1074,7 @@ If they are in the windows's left or right marginal areas, `left-margin'\n\
1104 int x, y; 1074 int x, y;
1105 Lisp_Object lx, ly; 1075 Lisp_Object lx, ly;
1106 1076
1107 CHECK_WINDOW (window); 1077 CHECK_LIVE_WINDOW (window);
1108 w = XWINDOW (window); 1078 w = XWINDOW (window);
1109 f = XFRAME (w->frame); 1079 f = XFRAME (w->frame);
1110 CHECK_CONS (coordinates); 1080 CHECK_CONS (coordinates);
@@ -1317,7 +1287,7 @@ WINDOW must be a live window and defaults to the selected one.
1317This is updated by redisplay, when it runs to completion. 1287This is updated by redisplay, when it runs to completion.
1318Simply changing the buffer text or setting `window-start' 1288Simply changing the buffer text or setting `window-start'
1319does not update this value. 1289does not update this value.
1320Return nil if there is no recorded value. \(This can happen if the 1290Return nil if there is no recorded value. (This can happen if the
1321last redisplay of WINDOW was preempted, and did not finish.) 1291last redisplay of WINDOW was preempted, and did not finish.)
1322If UPDATE is non-nil, compute the up-to-date position 1292If UPDATE is non-nil, compute the up-to-date position
1323if it isn't already recorded. */) 1293if it isn't already recorded. */)
@@ -1350,6 +1320,7 @@ if it isn't already recorded. */)
1350 struct text_pos startp; 1320 struct text_pos startp;
1351 struct it it; 1321 struct it it;
1352 struct buffer *old_buffer = NULL; 1322 struct buffer *old_buffer = NULL;
1323 void *itdata = NULL;
1353 1324
1354 /* Cannot use Fvertical_motion because that function doesn't 1325 /* Cannot use Fvertical_motion because that function doesn't
1355 cope with variable-height lines. */ 1326 cope with variable-height lines. */
@@ -1371,11 +1342,13 @@ if it isn't already recorded. */)
1371 else 1342 else
1372 SET_TEXT_POS_FROM_MARKER (startp, w->start); 1343 SET_TEXT_POS_FROM_MARKER (startp, w->start);
1373 1344
1345 itdata = bidi_shelve_cache ();
1374 start_display (&it, w, startp); 1346 start_display (&it, w, startp);
1375 move_it_vertically (&it, window_box_height (w)); 1347 move_it_vertically (&it, window_box_height (w));
1376 if (it.current_y < it.last_visible_y) 1348 if (it.current_y < it.last_visible_y)
1377 move_it_past_eol (&it); 1349 move_it_past_eol (&it);
1378 value = make_number (IT_CHARPOS (it)); 1350 value = make_number (IT_CHARPOS (it));
1351 bidi_unshelve_cache (itdata, 0);
1379 1352
1380 if (old_buffer) 1353 if (old_buffer)
1381 set_buffer_internal (old_buffer); 1354 set_buffer_internal (old_buffer);
@@ -1410,7 +1383,7 @@ Return POS. */)
1410 1383
1411DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0, 1384DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0,
1412 doc: /* Make display in WINDOW start at position POS in WINDOW's buffer. 1385 doc: /* Make display in WINDOW start at position POS in WINDOW's buffer.
1413WINDOW defaults to the selected window. Return POS. 1386If WINDOW is nil, the selected window is used. Return POS.
1414Optional third arg NOFORCE non-nil inhibits next redisplay from 1387Optional third arg NOFORCE non-nil inhibits next redisplay from
1415overriding motion of point in order to display at this exact start. */) 1388overriding motion of point in order to display at this exact start. */)
1416 (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce) 1389 (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce)
@@ -1661,8 +1634,9 @@ DEFUN ("window-prev-buffers", Fwindow_prev_buffers, Swindow_prev_buffers,
1661 doc: /* Return buffers previously shown in WINDOW. 1634 doc: /* Return buffers previously shown in WINDOW.
1662WINDOW must be a live window and defaults to the selected one. 1635WINDOW must be a live window and defaults to the selected one.
1663 1636
1664The return value is either nil or a list of <buffer, window-start, 1637The return value is a list of elements (BUFFER WINDOW-START POS),
1665window-point> triples where buffer was previously shown in WINDOW. */) 1638where BUFFER is a buffer, WINDOW-START is the start position of the
1639window for that buffer, and POS is a window-specific point value. */)
1666 (Lisp_Object window) 1640 (Lisp_Object window)
1667{ 1641{
1668 return decode_window (window)->prev_buffers; 1642 return decode_window (window)->prev_buffers;
@@ -1671,14 +1645,14 @@ window-point> triples where buffer was previously shown in WINDOW. */)
1671DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers, 1645DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers,
1672 Sset_window_prev_buffers, 2, 2, 0, 1646 Sset_window_prev_buffers, 2, 2, 0,
1673 doc: /* Set WINDOW's previous buffers to PREV-BUFFERS. 1647 doc: /* Set WINDOW's previous buffers to PREV-BUFFERS.
1674WINDOW must be a live window and defaults to the selected one. Return 1648WINDOW must be a live window and defaults to the selected one.
1675PREV-BUFFERS.
1676 1649
1677PREV-BUFFERS should be either nil or a list of <buffer, window-start, 1650PREV-BUFFERS should be a list of elements (BUFFER WINDOW-START POS),
1678window-point> triples where buffer was previously shown in WINDOW. */) 1651where BUFFER is a buffer, WINDOW-START is the start position of the
1652window for that buffer, and POS is a window-specific point value. */)
1679 (Lisp_Object window, Lisp_Object prev_buffers) 1653 (Lisp_Object window, Lisp_Object prev_buffers)
1680{ 1654{
1681 return decode_any_window (window)->prev_buffers = prev_buffers; 1655 return decode_window (window)->prev_buffers = prev_buffers;
1682} 1656}
1683 1657
1684DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers, 1658DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers,
@@ -1693,21 +1667,18 @@ WINDOW must be a live window and defaults to the selected one. */)
1693DEFUN ("set-window-next-buffers", Fset_window_next_buffers, 1667DEFUN ("set-window-next-buffers", Fset_window_next_buffers,
1694 Sset_window_next_buffers, 2, 2, 0, 1668 Sset_window_next_buffers, 2, 2, 0,
1695 doc: /* Set WINDOW's next buffers to NEXT-BUFFERS. 1669 doc: /* Set WINDOW's next buffers to NEXT-BUFFERS.
1696WINDOW must be a live window and defaults to the selected one. Return 1670WINDOW must be a live window and defaults to the selected one.
1697NEXT-BUFFERS. 1671NEXT-BUFFERS should be a list of buffers. */)
1698
1699NEXT-BUFFERS should be either nil or a list of buffers that have been
1700recently re-shown in WINDOW. */)
1701 (Lisp_Object window, Lisp_Object next_buffers) 1672 (Lisp_Object window, Lisp_Object next_buffers)
1702{ 1673{
1703 return decode_any_window (window)->next_buffers = next_buffers; 1674 return decode_window (window)->next_buffers = next_buffers;
1704} 1675}
1705 1676
1706DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters, 1677DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters,
1707 0, 1, 0, 1678 0, 1, 0,
1708 doc: /* Return the parameters of WINDOW and their values. 1679 doc: /* Return the parameters of WINDOW and their values.
1709WINDOW defaults to the selected window. The return value is a list of 1680WINDOW defaults to the selected window. The return value is a list of
1710elements of the form (PARAMETER . VALUE). */) 1681elements of the form (PARAMETER . VALUE). */)
1711 (Lisp_Object window) 1682 (Lisp_Object window)
1712{ 1683{
1713 return Fcopy_alist (decode_any_window (window)->window_parameters); 1684 return Fcopy_alist (decode_any_window (window)->window_parameters);
@@ -1906,7 +1877,7 @@ recombine_windows (Lisp_Object window)
1906 1877
1907 w = XWINDOW (window); 1878 w = XWINDOW (window);
1908 parent = w->parent; 1879 parent = w->parent;
1909 if (!NILP (parent) && NILP (w->nest)) 1880 if (!NILP (parent) && NILP (w->combination_limit))
1910 { 1881 {
1911 p = XWINDOW (parent); 1882 p = XWINDOW (parent);
1912 if (((!NILP (p->vchild) && !NILP (w->vchild)) 1883 if (((!NILP (p->vchild) && !NILP (w->vchild))
@@ -2211,8 +2182,8 @@ next_window (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames, in
2211 2182
2212 2183
2213DEFUN ("next-window", Fnext_window, Snext_window, 0, 3, 0, 2184DEFUN ("next-window", Fnext_window, Snext_window, 0, 3, 0,
2214 doc: /* Return window following WINDOW in cyclic ordering of windows. 2185 doc: /* Return live window after WINDOW in the cyclic ordering of windows.
2215WINDOW must be a live window and defaults to the selected one. The 2186WINDOW must be a live window and defaults to the selected one. The
2216optional arguments MINIBUF and ALL-FRAMES specify the set of windows to 2187optional arguments MINIBUF and ALL-FRAMES specify the set of windows to
2217consider. 2188consider.
2218 2189
@@ -2250,7 +2221,7 @@ windows, eventually ending up back at the window you started with.
2250 2221
2251 2222
2252DEFUN ("previous-window", Fprevious_window, Sprevious_window, 0, 3, 0, 2223DEFUN ("previous-window", Fprevious_window, Sprevious_window, 0, 3, 0,
2253 doc: /* Return window preceding WINDOW in cyclic ordering of windows. 2224 doc: /* Return live window before WINDOW in the cyclic ordering of windows.
2254WINDOW must be a live window and defaults to the selected one. The 2225WINDOW must be a live window and defaults to the selected one. The
2255optional arguments MINIBUF and ALL-FRAMES specify the set of windows to 2226optional arguments MINIBUF and ALL-FRAMES specify the set of windows to
2256consider. 2227consider.
@@ -2321,7 +2292,7 @@ window_list_1 (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames)
2321DEFUN ("window-list", Fwindow_list, Swindow_list, 0, 3, 0, 2292DEFUN ("window-list", Fwindow_list, Swindow_list, 0, 3, 0,
2322 doc: /* Return a list of windows on FRAME, starting with WINDOW. 2293 doc: /* Return a list of windows on FRAME, starting with WINDOW.
2323FRAME nil or omitted means use the selected frame. 2294FRAME nil or omitted means use the selected frame.
2324WINDOW nil or omitted means use the selected window. 2295WINDOW nil or omitted means use the window selected within FRAME.
2325MINIBUF t means include the minibuffer window, even if it isn't active. 2296MINIBUF t means include the minibuffer window, even if it isn't active.
2326MINIBUF nil or omitted means include the minibuffer window only 2297MINIBUF nil or omitted means include the minibuffer window only
2327if it's active. 2298if it's active.
@@ -2371,7 +2342,7 @@ Anything else means consider all windows on WINDOW's frame and no
2371others. 2342others.
2372 2343
2373If WINDOW is not on the list of windows returned, some other window will 2344If WINDOW is not on the list of windows returned, some other window will
2374be listed first but no error is signalled. */) 2345be listed first but no error is signaled. */)
2375 (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames) 2346 (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames)
2376{ 2347{
2377 return window_list_1 (window, minibuf, all_frames); 2348 return window_list_1 (window, minibuf, all_frames);
@@ -2578,9 +2549,9 @@ DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal,
2578Only the frame WINDOW is on is affected. WINDOW may be any window and 2549Only the frame WINDOW is on is affected. WINDOW may be any window and
2579defaults to the selected one. 2550defaults to the selected one.
2580 2551
2581Optional argument ROOT, if non-nil, must specify an internal window 2552Optional argument ROOT, if non-nil, must specify an internal window such
2582containing WINDOW as a subwindow. If this is the case, replace ROOT by 2553that WINDOW is in its window subtree. If this is the case, replace ROOT
2583WINDOW and leave alone any windows not contained in ROOT. 2554by WINDOW and leave alone any windows not part of ROOT's subtree.
2584 2555
2585When WINDOW is live try to reduce display jumps by keeping the text 2556When WINDOW is live try to reduce display jumps by keeping the text
2586previously visible in WINDOW in the same place on the frame. Doing this 2557previously visible in WINDOW in the same place on the frame. Doing this
@@ -2644,10 +2615,10 @@ window-start value is reasonable when this function is called. */)
2644 } 2615 }
2645 else 2616 else
2646 { 2617 {
2647 /* See if the frame's selected window is a subwindow of WINDOW, by 2618 /* See if the frame's selected window is a part of the window
2648 finding all the selected window's parents and comparing each 2619 subtree rooted at WINDOW, by finding all the selected window's
2649 one with WINDOW. If it isn't we need a new selected window for 2620 parents and comparing each one with WINDOW. If it isn't we
2650 this frame. */ 2621 need a new selected window for this frame. */
2651 swindow = FRAME_SELECTED_WINDOW (f); 2622 swindow = FRAME_SELECTED_WINDOW (f);
2652 while (1) 2623 while (1)
2653 { 2624 {
@@ -2683,7 +2654,7 @@ window-start value is reasonable when this function is called. */)
2683 2654
2684 if (NILP (w->buffer)) 2655 if (NILP (w->buffer))
2685 { 2656 {
2686 /* Resize subwindows vertically. */ 2657 /* Resize child windows vertically. */
2687 XSETINT (delta, XINT (r->total_lines) - XINT (w->total_lines)); 2658 XSETINT (delta, XINT (r->total_lines) - XINT (w->total_lines));
2688 w->top_line = r->top_line; 2659 w->top_line = r->top_line;
2689 resize_root_window (window, delta, Qnil, Qnil); 2660 resize_root_window (window, delta, Qnil, Qnil);
@@ -2698,7 +2669,7 @@ window-start value is reasonable when this function is called. */)
2698 resize_failed = 1; 2669 resize_failed = 1;
2699 } 2670 }
2700 2671
2701 /* Resize subwindows horizontally. */ 2672 /* Resize child windows horizontally. */
2702 if (!resize_failed) 2673 if (!resize_failed)
2703 { 2674 {
2704 w->left_col = r->left_col; 2675 w->left_col = r->left_col;
@@ -2747,23 +2718,20 @@ window-start value is reasonable when this function is called. */)
2747 XWINDOW (w->parent)->hchild = sibling; 2718 XWINDOW (w->parent)->hchild = sibling;
2748 } 2719 }
2749 2720
2750 /* Delete ROOT and all subwindows of ROOT. */ 2721 /* Delete ROOT and all child windows of ROOT. */
2751 if (!NILP (r->vchild)) 2722 if (!NILP (r->vchild))
2752 { 2723 {
2753 delete_all_subwindows (r->vchild); 2724 delete_all_child_windows (r->vchild);
2754 r->vchild = Qnil; 2725 r->vchild = Qnil;
2755 } 2726 }
2756 else if (!NILP (r->hchild)) 2727 else if (!NILP (r->hchild))
2757 { 2728 {
2758 delete_all_subwindows (r->hchild); 2729 delete_all_child_windows (r->hchild);
2759 r->hchild = Qnil; 2730 r->hchild = Qnil;
2760 } 2731 }
2761 2732
2762 replace_window (root, window, 1); 2733 replace_window (root, window, 1);
2763 2734
2764 /* Reset WINDOW's splits status. */
2765 w->splits = Qnil;
2766
2767 /* This must become SWINDOW anyway ....... */ 2735 /* This must become SWINDOW anyway ....... */
2768 if (!NILP (w->buffer) && !resize_failed) 2736 if (!NILP (w->buffer) && !resize_failed)
2769 { 2737 {
@@ -2926,7 +2894,7 @@ run_window_configuration_change_hook (struct frame *f)
2926 = Fdefault_value (Qwindow_configuration_change_hook); 2894 = Fdefault_value (Qwindow_configuration_change_hook);
2927 XSETFRAME (frame, f); 2895 XSETFRAME (frame, f);
2928 2896
2929 if (NILP (Vrun_hooks)) 2897 if (NILP (Vrun_hooks) || !NILP (inhibit_lisp_code))
2930 return; 2898 return;
2931 2899
2932 /* Use the right buffer. Matters when running the local hooks. */ 2900 /* Use the right buffer. Matters when running the local hooks. */
@@ -3120,7 +3088,7 @@ This function runs `window-scroll-functions' before running
3120 error ("Window is dedicated to `%s'", SDATA (BVAR (XBUFFER (tem), name))); 3088 error ("Window is dedicated to `%s'", SDATA (BVAR (XBUFFER (tem), name)));
3121 else 3089 else
3122 /* WINDOW is weakly dedicated to its buffer, reset 3090 /* WINDOW is weakly dedicated to its buffer, reset
3123 dedicatedness. */ 3091 dedication. */
3124 w->dedicated = Qnil; 3092 w->dedicated = Qnil;
3125 3093
3126 call1 (Qrecord_window_buffer, window); 3094 call1 (Qrecord_window_buffer, window);
@@ -3204,10 +3172,7 @@ temp_output_buffer_show (register Lisp_Object buf)
3204 call1 (Vtemp_buffer_show_function, buf); 3172 call1 (Vtemp_buffer_show_function, buf);
3205 else 3173 else
3206 { 3174 {
3207 window = display_buffer (buf, Vtemp_buffer_show_specifiers, Qnil); 3175 window = display_buffer (buf, Qnil, Qnil);
3208 /* Reset Vtemp_buffer_show_specifiers immediately so it won't
3209 affect subsequent calls. */
3210 Vtemp_buffer_show_specifiers = Qnil;
3211 3176
3212 if (!EQ (XWINDOW (window)->frame, selected_frame)) 3177 if (!EQ (XWINDOW (window)->frame, selected_frame))
3213 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); 3178 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window)));
@@ -3243,7 +3208,7 @@ temp_output_buffer_show (register Lisp_Object buf)
3243DEFUN ("internal-temp-output-buffer-show", 3208DEFUN ("internal-temp-output-buffer-show",
3244 Ftemp_output_buffer_show, Stemp_output_buffer_show, 3209 Ftemp_output_buffer_show, Stemp_output_buffer_show,
3245 1, 1, 0, 3210 1, 1, 0,
3246 doc: /* Internal function for `with-output-to-temp-buffer''. */) 3211 doc: /* Internal function for `with-output-to-temp-buffer'. */)
3247 (Lisp_Object buf) 3212 (Lisp_Object buf)
3248{ 3213{
3249 temp_output_buffer_show (buf); 3214 temp_output_buffer_show (buf);
@@ -3281,8 +3246,7 @@ make_parent_window (Lisp_Object window, int horflag)
3281 p->start = Qnil; 3246 p->start = Qnil;
3282 p->pointm = Qnil; 3247 p->pointm = Qnil;
3283 p->buffer = Qnil; 3248 p->buffer = Qnil;
3284 p->splits = Qnil; 3249 p->combination_limit = Qnil;
3285 p->nest = Qnil;
3286 p->window_parameters = Qnil; 3250 p->window_parameters = Qnil;
3287} 3251}
3288 3252
@@ -3329,7 +3293,7 @@ make_window (void)
3329 w->start_at_line_beg = w->display_table = w->dedicated = Qnil; 3293 w->start_at_line_beg = w->display_table = w->dedicated = Qnil;
3330 w->base_line_number = w->base_line_pos = w->region_showing = Qnil; 3294 w->base_line_number = w->base_line_pos = w->region_showing = Qnil;
3331 w->column_number_displayed = w->redisplay_end_trigger = Qnil; 3295 w->column_number_displayed = w->redisplay_end_trigger = Qnil;
3332 w->splits = w->nest = w->window_parameters = Qnil; 3296 w->combination_limit = w->window_parameters = Qnil;
3333 w->prev_buffers = w->next_buffers = Qnil; 3297 w->prev_buffers = w->next_buffers = Qnil;
3334 /* Initialize non-Lisp data. */ 3298 /* Initialize non-Lisp data. */
3335 w->desired_matrix = w->current_matrix = 0; 3299 w->desired_matrix = w->current_matrix = 0;
@@ -3339,6 +3303,7 @@ make_window (void)
3339 memset (&w->phys_cursor, 0, sizeof (w->phys_cursor)); 3303 memset (&w->phys_cursor, 0, sizeof (w->phys_cursor));
3340 w->phys_cursor_type = -1; 3304 w->phys_cursor_type = -1;
3341 w->phys_cursor_width = -1; 3305 w->phys_cursor_width = -1;
3306 w->phys_cursor_on_p = 0;
3342 w->last_cursor_off_p = w->cursor_off_p = 0; 3307 w->last_cursor_off_p = w->cursor_off_p = 0;
3343 w->must_be_updated_p = 0; 3308 w->must_be_updated_p = 0;
3344 w->pseudo_window_p = 0; 3309 w->pseudo_window_p = 0;
@@ -3358,7 +3323,7 @@ Return SIZE.
3358Optional argument ADD non-nil means add SIZE to the new total size of 3323Optional argument ADD non-nil means add SIZE to the new total size of
3359WINDOW and return the sum. 3324WINDOW and return the sum.
3360 3325
3361Note: This function does not operate on any subwindows of WINDOW. */) 3326Note: This function does not operate on any child windows of WINDOW. */)
3362 (Lisp_Object window, Lisp_Object size, Lisp_Object add) 3327 (Lisp_Object window, Lisp_Object size, Lisp_Object add)
3363{ 3328{
3364 struct window *w = decode_any_window (window); 3329 struct window *w = decode_any_window (window);
@@ -3376,7 +3341,7 @@ DEFUN ("set-window-new-normal", Fset_window_new_normal, Sset_window_new_normal,
3376 doc: /* Set new normal size of WINDOW to SIZE. 3341 doc: /* Set new normal size of WINDOW to SIZE.
3377Return SIZE. 3342Return SIZE.
3378 3343
3379Note: This function does not operate on any subwindows of WINDOW. */) 3344Note: This function does not operate on any child windows of WINDOW. */)
3380 (Lisp_Object window, Lisp_Object size) 3345 (Lisp_Object window, Lisp_Object size)
3381{ 3346{
3382 struct window *w = decode_any_window (window); 3347 struct window *w = decode_any_window (window);
@@ -3387,7 +3352,7 @@ Note: This function does not operate on any subwindows of WINDOW. */)
3387 3352
3388/* Return 1 if setting w->total_lines (w->total_cols if HORFLAG is 3353/* Return 1 if setting w->total_lines (w->total_cols if HORFLAG is
3389 non-zero) to w->new_total would result in correct heights (widths) 3354 non-zero) to w->new_total would result in correct heights (widths)
3390 for window W and recursively all subwindows of W. 3355 for window W and recursively all child windows of W.
3391 3356
3392 Note: This function does not check any of `window-fixed-size-p', 3357 Note: This function does not check any of `window-fixed-size-p',
3393 `window-min-height' or `window-min-width'. It does check that window 3358 `window-min-height' or `window-min-width'. It does check that window
@@ -3402,7 +3367,7 @@ window_resize_check (struct window *w, int horflag)
3402 { 3367 {
3403 c = XWINDOW (w->vchild); 3368 c = XWINDOW (w->vchild);
3404 if (horflag) 3369 if (horflag)
3405 /* All subwindows of W must have the same width as W. */ 3370 /* All child windows of W must have the same width as W. */
3406 { 3371 {
3407 while (c) 3372 while (c)
3408 { 3373 {
@@ -3414,8 +3379,8 @@ window_resize_check (struct window *w, int horflag)
3414 return 1; 3379 return 1;
3415 } 3380 }
3416 else 3381 else
3417 /* The sum of the heights of the subwindows of W must equal W's 3382 /* The sum of the heights of the child windows of W must equal
3418 height. */ 3383 W's height. */
3419 { 3384 {
3420 int sum_of_sizes = 0; 3385 int sum_of_sizes = 0;
3421 while (c) 3386 while (c)
@@ -3433,7 +3398,7 @@ window_resize_check (struct window *w, int horflag)
3433 { 3398 {
3434 c = XWINDOW (w->hchild); 3399 c = XWINDOW (w->hchild);
3435 if (horflag) 3400 if (horflag)
3436 /* The sum of the widths of the subwindows of W must equal W's 3401 /* The sum of the widths of the child windows of W must equal W's
3437 width. */ 3402 width. */
3438 { 3403 {
3439 int sum_of_sizes = 0; 3404 int sum_of_sizes = 0;
@@ -3447,7 +3412,7 @@ window_resize_check (struct window *w, int horflag)
3447 return (sum_of_sizes == XINT (w->new_total)); 3412 return (sum_of_sizes == XINT (w->new_total));
3448 } 3413 }
3449 else 3414 else
3450 /* All subwindows of W must have the same height as W. */ 3415 /* All child windows of W must have the same height as W. */
3451 { 3416 {
3452 while (c) 3417 while (c)
3453 { 3418 {
@@ -3467,9 +3432,9 @@ window_resize_check (struct window *w, int horflag)
3467} 3432}
3468 3433
3469/* Set w->total_lines (w->total_cols if HORIZONTAL is non-zero) to 3434/* Set w->total_lines (w->total_cols if HORIZONTAL is non-zero) to
3470 w->new_total for window W and recursively all subwindows of W. Also 3435 w->new_total for window W and recursively all child windows of W.
3471 calculate and assign the new vertical (horizontal) start positions of 3436 Also calculate and assign the new vertical (horizontal) start
3472 each of these windows. 3437 positions of each of these windows.
3473 3438
3474 This function does not perform any error checks. Make sure you have 3439 This function does not perform any error checks. Make sure you have
3475 run window_resize_check on W before applying this function. */ 3440 run window_resize_check on W before applying this function. */
@@ -3543,8 +3508,8 @@ Optional argument HORIZONTAL omitted or nil means apply requested height
3543values. HORIZONTAL non-nil means apply requested width values. 3508values. HORIZONTAL non-nil means apply requested width values.
3544 3509
3545This function checks whether the requested values sum up to a valid 3510This function checks whether the requested values sum up to a valid
3546window layout, recursively assigns the new sizes of all subwindows and 3511window layout, recursively assigns the new sizes of all child windows
3547calculates and assigns the new start positions of these windows. 3512and calculates and assigns the new start positions of these windows.
3548 3513
3549Note: This function does not check any of `window-fixed-size-p', 3514Note: This function does not check any of `window-fixed-size-p',
3550`window-min-height' or `window-min-width'. All these checks have to 3515`window-min-height' or `window-min-width'. All these checks have to
@@ -3701,7 +3666,7 @@ set correctly. See the code of `split-window' for how this is done. */)
3701 int horflag 3666 int horflag
3702 /* HORFLAG is 1 when we split side-by-side, 0 otherwise. */ 3667 /* HORFLAG is 1 when we split side-by-side, 0 otherwise. */
3703 = EQ (side, Qt) || EQ (side, Qleft) || EQ (side, Qright); 3668 = EQ (side, Qt) || EQ (side, Qleft) || EQ (side, Qright);
3704 int do_nest = 0; 3669 int combination_limit = 0;
3705 3670
3706 CHECK_WINDOW (old); 3671 CHECK_WINDOW (old);
3707 o = XWINDOW (old); 3672 o = XWINDOW (old);
@@ -3710,11 +3675,11 @@ set correctly. See the code of `split-window' for how this is done. */)
3710 3675
3711 CHECK_NUMBER (total_size); 3676 CHECK_NUMBER (total_size);
3712 3677
3713 /* Set do_nest to 1 if we have to make a new parent window. We do 3678 /* Set combination_limit to 1 if we have to make a new parent window.
3714 that if either `window-nest' is non-nil, or OLD has no parent, or 3679 We do that if either `window-combination-limit' is t, or OLD has no
3715 OLD is ortho-combined. */ 3680 parent, or OLD is ortho-combined. */
3716 do_nest = 3681 combination_limit =
3717 !NILP (Vwindow_nest) 3682 !NILP (Vwindow_combination_limit)
3718 || NILP (o->parent) 3683 || NILP (o->parent)
3719 || NILP (horflag 3684 || NILP (horflag
3720 ? (XWINDOW (o->parent)->hchild) 3685 ? (XWINDOW (o->parent)->hchild)
@@ -3734,8 +3699,8 @@ set correctly. See the code of `split-window' for how this is done. */)
3734 error ("Attempt to split minibuffer window"); 3699 error ("Attempt to split minibuffer window");
3735 else if (XINT (total_size) < (horflag ? 2 : 1)) 3700 else if (XINT (total_size) < (horflag ? 2 : 1))
3736 error ("Size of new window too small (after split)"); 3701 error ("Size of new window too small (after split)");
3737 else if (!do_nest && !NILP (Vwindow_splits)) 3702 else if (!combination_limit && !NILP (Vwindow_combination_resize))
3738 /* `window-splits' non-nil means try to resize OLD's siblings 3703 /* `window-combination-resize' non-nil means try to resize OLD's siblings
3739 proportionally. */ 3704 proportionally. */
3740 { 3705 {
3741 p = XWINDOW (o->parent); 3706 p = XWINDOW (o->parent);
@@ -3759,7 +3724,7 @@ set correctly. See the code of `split-window' for how this is done. */)
3759 } 3724 }
3760 3725
3761 /* This is our point of no return. */ 3726 /* This is our point of no return. */
3762 if (do_nest) 3727 if (combination_limit)
3763 { 3728 {
3764 /* Save the old value of o->normal_cols/lines. It gets corrupted 3729 /* Save the old value of o->normal_cols/lines. It gets corrupted
3765 by make_parent_window and we need it below for assigning it to 3730 by make_parent_window and we need it below for assigning it to
@@ -3768,12 +3733,9 @@ set correctly. See the code of `split-window' for how this is done. */)
3768 3733
3769 make_parent_window (old, horflag); 3734 make_parent_window (old, horflag);
3770 p = XWINDOW (o->parent); 3735 p = XWINDOW (o->parent);
3771 /* Store value of `window-nest' in new parent's nest slot. */ 3736 /* Store value of `window-combination-limit' in new parent's
3772 p->nest = Vwindow_nest; 3737 combination_limit slot. */
3773 /* Have PARENT inherit splits slot value from OLD. */ 3738 p->combination_limit = Vwindow_combination_limit;
3774 p->splits = o->splits;
3775 /* Store value of `window-splits' in OLD's splits slot. */
3776 o->splits = Vwindow_splits;
3777 /* These get applied below. */ 3739 /* These get applied below. */
3778 p->new_total = horflag ? o->total_cols : o->total_lines; 3740 p->new_total = horflag ? o->total_cols : o->total_lines;
3779 p->new_normal = new_normal; 3741 p->new_normal = new_normal;
@@ -3824,9 +3786,6 @@ set correctly. See the code of `split-window' for how this is done. */)
3824 n->scroll_bar_width = r->scroll_bar_width; 3786 n->scroll_bar_width = r->scroll_bar_width;
3825 n->vertical_scroll_bar_type = r->vertical_scroll_bar_type; 3787 n->vertical_scroll_bar_type = r->vertical_scroll_bar_type;
3826 3788
3827 /* Store `window-splits' in NEW's splits slot. */
3828 n->splits = Vwindow_splits;
3829
3830 /* Directly assign orthogonal coordinates and sizes. */ 3789 /* Directly assign orthogonal coordinates and sizes. */
3831 if (horflag) 3790 if (horflag)
3832 { 3791 {
@@ -3864,8 +3823,8 @@ set correctly. See the code of `split-window' for how this is done. */)
3864 3823
3865DEFUN ("delete-window-internal", Fdelete_window_internal, Sdelete_window_internal, 1, 1, 0, 3824DEFUN ("delete-window-internal", Fdelete_window_internal, Sdelete_window_internal, 1, 1, 0,
3866 doc: /* Remove WINDOW from its frame. 3825 doc: /* Remove WINDOW from its frame.
3867WINDOW defaults to the selected window. Return nil. Signal an error 3826WINDOW defaults to the selected window. Return nil.
3868when WINDOW is the only window on its frame. */) 3827Signal an error when WINDOW is the only window on its frame. */)
3869 (register Lisp_Object window) 3828 (register Lisp_Object window)
3870{ 3829{
3871 register Lisp_Object parent, sibling, frame, root; 3830 register Lisp_Object parent, sibling, frame, root;
@@ -3927,10 +3886,18 @@ when WINDOW is the only window on its frame. */)
3927 && EQ (r->new_total, (horflag ? r->total_cols : r->total_lines))) 3886 && EQ (r->new_total, (horflag ? r->total_cols : r->total_lines)))
3928 /* We can delete WINDOW now. */ 3887 /* We can delete WINDOW now. */
3929 { 3888 {
3889 Mouse_HLInfo *hlinfo;
3890
3930 /* Block input. */ 3891 /* Block input. */
3931 BLOCK_INPUT; 3892 BLOCK_INPUT;
3932 window_resize_apply (p, horflag); 3893 window_resize_apply (p, horflag);
3933 3894
3895 /* If this window is referred to by the dpyinfo's mouse
3896 highlight, invalidate that slot to be safe (Bug#9904). */
3897 hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
3898 if (EQ (hlinfo->mouse_face_window, window))
3899 hlinfo->mouse_face_window = Qnil;
3900
3934 windows_or_buffers_changed++; 3901 windows_or_buffers_changed++;
3935 Vwindow_list = Qnil; 3902 Vwindow_list = Qnil;
3936 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 3903 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
@@ -3940,12 +3907,12 @@ when WINDOW is the only window on its frame. */)
3940 3907
3941 if (!NILP (w->vchild)) 3908 if (!NILP (w->vchild))
3942 { 3909 {
3943 delete_all_subwindows (w->vchild); 3910 delete_all_child_windows (w->vchild);
3944 w->vchild = Qnil; 3911 w->vchild = Qnil;
3945 } 3912 }
3946 else if (!NILP (w->hchild)) 3913 else if (!NILP (w->hchild))
3947 { 3914 {
3948 delete_all_subwindows (w->hchild); 3915 delete_all_child_windows (w->hchild);
3949 w->hchild = Qnil; 3916 w->hchild = Qnil;
3950 } 3917 }
3951 else if (!NILP (w->buffer)) 3918 else if (!NILP (w->buffer))
@@ -3963,10 +3930,9 @@ when WINDOW is the only window on its frame. */)
3963 /* Put SIBLING into PARENT's place. */ 3930 /* Put SIBLING into PARENT's place. */
3964 replace_window (parent, sibling, 0); 3931 replace_window (parent, sibling, 0);
3965 /* Have SIBLING inherit the following three slot values from 3932 /* Have SIBLING inherit the following three slot values from
3966 PARENT (the nest slot is not inherited). */ 3933 PARENT (the combination_limit slot is not inherited). */
3967 s->normal_cols = p->normal_cols; 3934 s->normal_cols = p->normal_cols;
3968 s->normal_lines = p->normal_lines; 3935 s->normal_lines = p->normal_lines;
3969 s->splits = p->splits;
3970 /* Mark PARENT as deleted. */ 3936 /* Mark PARENT as deleted. */
3971 p->vchild = p->hchild = Qnil; 3937 p->vchild = p->hchild = Qnil;
3972 /* Try to merge SIBLING into its new parent. */ 3938 /* Try to merge SIBLING into its new parent. */
@@ -4237,6 +4203,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4237 /* True if we fiddled the window vscroll field without really scrolling. */ 4203 /* True if we fiddled the window vscroll field without really scrolling. */
4238 int vscrolled = 0; 4204 int vscrolled = 0;
4239 int x, y, rtop, rbot, rowh, vpos; 4205 int x, y, rtop, rbot, rowh, vpos;
4206 void *itdata = NULL;
4240 4207
4241 SET_TEXT_POS_FROM_MARKER (start, w->start); 4208 SET_TEXT_POS_FROM_MARKER (start, w->start);
4242 4209
@@ -4247,6 +4214,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4247 4214
4248 if (!pos_visible_p (w, PT, &x, &y, &rtop, &rbot, &rowh, &vpos)) 4215 if (!pos_visible_p (w, PT, &x, &y, &rtop, &rbot, &rowh, &vpos))
4249 { 4216 {
4217 itdata = bidi_shelve_cache ();
4250 /* Move backward half the height of the window. Performance note: 4218 /* Move backward half the height of the window. Performance note:
4251 vmotion used here is about 10% faster, but would give wrong 4219 vmotion used here is about 10% faster, but would give wrong
4252 results for variable height lines. */ 4220 results for variable height lines. */
@@ -4267,6 +4235,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4267 } 4235 }
4268 4236
4269 start = it.current.pos; 4237 start = it.current.pos;
4238 bidi_unshelve_cache (itdata, 0);
4270 } 4239 }
4271 else if (auto_window_vscroll_p) 4240 else if (auto_window_vscroll_p)
4272 { 4241 {
@@ -4329,6 +4298,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4329 Fset_window_vscroll (window, make_number (0), Qt); 4298 Fset_window_vscroll (window, make_number (0), Qt);
4330 } 4299 }
4331 4300
4301 itdata = bidi_shelve_cache ();
4332 /* If scroll_preserve_screen_position is non-nil, we try to set 4302 /* If scroll_preserve_screen_position is non-nil, we try to set
4333 point in the same window line as it is now, so get that line. */ 4303 point in the same window line as it is now, so get that line. */
4334 if (!NILP (Vscroll_preserve_screen_position)) 4304 if (!NILP (Vscroll_preserve_screen_position))
@@ -4407,12 +4377,16 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4407 - it.current_y + it.max_ascent + it.max_descent); 4377 - it.current_y + it.max_ascent + it.max_descent);
4408 adjust_glyphs (it.f); 4378 adjust_glyphs (it.f);
4409 } 4379 }
4410 else if (noerror)
4411 return;
4412 else if (n < 0) /* could happen with empty buffers */
4413 xsignal0 (Qbeginning_of_buffer);
4414 else 4380 else
4415 xsignal0 (Qend_of_buffer); 4381 {
4382 bidi_unshelve_cache (itdata, 0);
4383 if (noerror)
4384 return;
4385 else if (n < 0) /* could happen with empty buffers */
4386 xsignal0 (Qbeginning_of_buffer);
4387 else
4388 xsignal0 (Qend_of_buffer);
4389 }
4416 } 4390 }
4417 else 4391 else
4418 { 4392 {
@@ -4420,10 +4394,14 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4420 /* The first line was only partially visible, make it fully 4394 /* The first line was only partially visible, make it fully
4421 visible. */ 4395 visible. */
4422 w->vscroll = 0; 4396 w->vscroll = 0;
4423 else if (noerror)
4424 return;
4425 else 4397 else
4426 xsignal0 (Qbeginning_of_buffer); 4398 {
4399 bidi_unshelve_cache (itdata, 0);
4400 if (noerror)
4401 return;
4402 else
4403 xsignal0 (Qbeginning_of_buffer);
4404 }
4427 } 4405 }
4428 4406
4429 /* If control gets here, then we vscrolled. */ 4407 /* If control gets here, then we vscrolled. */
@@ -4567,6 +4545,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4567 SET_PT_BOTH (charpos, bytepos); 4545 SET_PT_BOTH (charpos, bytepos);
4568 } 4546 }
4569 } 4547 }
4548 bidi_unshelve_cache (itdata, 0);
4570} 4549}
4571 4550
4572 4551
@@ -4645,14 +4624,9 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror)
4645 4624
4646 if (pos < ZV) 4625 if (pos < ZV)
4647 { 4626 {
4648 int this_scroll_margin = scroll_margin;
4649
4650 /* Don't use a scroll margin that is negative or too large. */ 4627 /* Don't use a scroll margin that is negative or too large. */
4651 if (this_scroll_margin < 0) 4628 int this_scroll_margin =
4652 this_scroll_margin = 0; 4629 max (0, min (scroll_margin, XINT (w->total_lines) / 4));
4653
4654 if (XINT (w->total_lines) < 4 * scroll_margin)
4655 this_scroll_margin = XINT (w->total_lines) / 4;
4656 4630
4657 set_marker_restricted_both (w->start, w->buffer, pos, pos_byte); 4631 set_marker_restricted_both (w->start, w->buffer, pos, pos_byte);
4658 w->start_at_line_beg = bolp; 4632 w->start_at_line_beg = bolp;
@@ -4969,6 +4943,7 @@ displayed_window_lines (struct window *w)
4969 int height = window_box_height (w); 4943 int height = window_box_height (w);
4970 struct buffer *old_buffer; 4944 struct buffer *old_buffer;
4971 int bottom_y; 4945 int bottom_y;
4946 void *itdata = NULL;
4972 4947
4973 if (XBUFFER (w->buffer) != current_buffer) 4948 if (XBUFFER (w->buffer) != current_buffer)
4974 { 4949 {
@@ -4988,9 +4963,11 @@ displayed_window_lines (struct window *w)
4988 else 4963 else
4989 SET_TEXT_POS_FROM_MARKER (start, w->start); 4964 SET_TEXT_POS_FROM_MARKER (start, w->start);
4990 4965
4966 itdata = bidi_shelve_cache ();
4991 start_display (&it, w, start); 4967 start_display (&it, w, start);
4992 move_it_vertically (&it, height); 4968 move_it_vertically (&it, height);
4993 bottom_y = line_bottom_y (&it); 4969 bottom_y = line_bottom_y (&it);
4970 bidi_unshelve_cache (itdata, 0);
4994 4971
4995 /* rms: On a non-window display, 4972 /* rms: On a non-window display,
4996 the value of it.vpos at the bottom of the screen 4973 the value of it.vpos at the bottom of the screen
@@ -5026,7 +5003,7 @@ the selected window; if the variable `recenter-redisplay' is non-nil,
5026also erase the entire frame and redraw it (when `auto-resize-tool-bars' 5003also erase the entire frame and redraw it (when `auto-resize-tool-bars'
5027is set to `grow-only', this resets the tool-bar's height to the minimum 5004is set to `grow-only', this resets the tool-bar's height to the minimum
5028height needed); if `recenter-redisplay' has the special value `tty', 5005height needed); if `recenter-redisplay' has the special value `tty',
5029then only tty frame are redrawn. 5006then only tty frames are redrawn.
5030 5007
5031Just C-u as prefix means put point in the center of the window 5008Just C-u as prefix means put point in the center of the window
5032and redisplay normally--don't erase and redraw the frame. */) 5009and redisplay normally--don't erase and redraw the frame. */)
@@ -5037,7 +5014,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5037 struct buffer *obuf = current_buffer; 5014 struct buffer *obuf = current_buffer;
5038 int center_p = 0; 5015 int center_p = 0;
5039 EMACS_INT charpos, bytepos; 5016 EMACS_INT charpos, bytepos;
5040 int iarg IF_LINT (= 0); 5017 EMACS_INT iarg IF_LINT (= 0);
5041 int this_scroll_margin; 5018 int this_scroll_margin;
5042 5019
5043 /* If redisplay is suppressed due to an error, try again. */ 5020 /* If redisplay is suppressed due to an error, try again. */
@@ -5049,7 +5026,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5049 && (!EQ (Vrecenter_redisplay, Qtty) 5026 && (!EQ (Vrecenter_redisplay, Qtty)
5050 || !NILP (Ftty_type (selected_frame)))) 5027 || !NILP (Ftty_type (selected_frame))))
5051 { 5028 {
5052 int i; 5029 ptrdiff_t i;
5053 5030
5054 /* Invalidate pixel data calculated for all compositions. */ 5031 /* Invalidate pixel data calculated for all compositions. */
5055 for (i = 0; i < n_compositions; i++) 5032 for (i = 0; i < n_compositions; i++)
@@ -5076,9 +5053,8 @@ and redisplay normally--don't erase and redraw the frame. */)
5076 5053
5077 /* Do this after making BUF current 5054 /* Do this after making BUF current
5078 in case scroll_margin is buffer-local. */ 5055 in case scroll_margin is buffer-local. */
5079 this_scroll_margin = max (0, scroll_margin); 5056 this_scroll_margin =
5080 this_scroll_margin = min (this_scroll_margin, 5057 max (0, min (scroll_margin, XFASTINT (w->total_lines) / 4));
5081 XFASTINT (w->total_lines) / 4);
5082 5058
5083 /* Handle centering on a graphical frame specially. Such frames can 5059 /* Handle centering on a graphical frame specially. Such frames can
5084 have variable-height lines and centering point on the basis of 5060 have variable-height lines and centering point on the basis of
@@ -5089,20 +5065,23 @@ and redisplay normally--don't erase and redraw the frame. */)
5089 { 5065 {
5090 struct it it; 5066 struct it it;
5091 struct text_pos pt; 5067 struct text_pos pt;
5068 void *itdata = bidi_shelve_cache ();
5092 5069
5093 SET_TEXT_POS (pt, PT, PT_BYTE); 5070 SET_TEXT_POS (pt, PT, PT_BYTE);
5094 start_display (&it, w, pt); 5071 start_display (&it, w, pt);
5095 move_it_vertically_backward (&it, window_box_height (w) / 2); 5072 move_it_vertically_backward (&it, window_box_height (w) / 2);
5096 charpos = IT_CHARPOS (it); 5073 charpos = IT_CHARPOS (it);
5097 bytepos = IT_BYTEPOS (it); 5074 bytepos = IT_BYTEPOS (it);
5075 bidi_unshelve_cache (itdata, 0);
5098 } 5076 }
5099 else if (iarg < 0) 5077 else if (iarg < 0)
5100 { 5078 {
5101 struct it it; 5079 struct it it;
5102 struct text_pos pt; 5080 struct text_pos pt;
5103 int nlines = -iarg; 5081 int nlines = min (INT_MAX, -iarg);
5104 int extra_line_spacing; 5082 int extra_line_spacing;
5105 int h = window_box_height (w); 5083 int h = window_box_height (w);
5084 void *itdata = bidi_shelve_cache ();
5106 5085
5107 iarg = - max (-iarg, this_scroll_margin); 5086 iarg = - max (-iarg, this_scroll_margin);
5108 5087
@@ -5140,7 +5119,10 @@ and redisplay normally--don't erase and redraw the frame. */)
5140 h -= nlines * (FRAME_LINE_HEIGHT (it.f) + extra_line_spacing); 5119 h -= nlines * (FRAME_LINE_HEIGHT (it.f) + extra_line_spacing);
5141 } 5120 }
5142 if (h <= 0) 5121 if (h <= 0)
5143 return Qnil; 5122 {
5123 bidi_unshelve_cache (itdata, 0);
5124 return Qnil;
5125 }
5144 5126
5145 /* Now find the new top line (starting position) of the window. */ 5127 /* Now find the new top line (starting position) of the window. */
5146 start_display (&it, w, pt); 5128 start_display (&it, w, pt);
@@ -5160,6 +5142,8 @@ and redisplay normally--don't erase and redraw the frame. */)
5160 5142
5161 charpos = IT_CHARPOS (it); 5143 charpos = IT_CHARPOS (it);
5162 bytepos = IT_BYTEPOS (it); 5144 bytepos = IT_BYTEPOS (it);
5145
5146 bidi_unshelve_cache (itdata, 0);
5163 } 5147 }
5164 else 5148 else
5165 { 5149 {
@@ -5209,10 +5193,10 @@ and redisplay normally--don't erase and redraw the frame. */)
5209DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, 5193DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height,
5210 0, 1, 0, 5194 0, 1, 0,
5211 doc: /* Return the height in lines of the text display area of WINDOW. 5195 doc: /* Return the height in lines of the text display area of WINDOW.
5212WINDOW defaults to the selected window. 5196If WINDOW is omitted or nil, it defaults to the selected window.
5213 5197
5214The return value does not include the mode line, any header line, nor 5198The returned height does not include the mode line, any header line,
5215any partial-height lines in the text display area. */) 5199nor any partial-height lines at the bottom of the text area. */)
5216 (Lisp_Object window) 5200 (Lisp_Object window)
5217{ 5201{
5218 struct window *w = decode_window (window); 5202 struct window *w = decode_window (window);
@@ -5226,8 +5210,8 @@ any partial-height lines in the text display area. */)
5226DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line, 5210DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line,
5227 1, 1, "P", 5211 1, 1, "P",
5228 doc: /* Position point relative to window. 5212 doc: /* Position point relative to window.
5229With no argument, position point at center of window. 5213ARG nil means position point at center of window.
5230An argument specifies vertical position within the window; 5214Else, ARG specifies vertical position within the window;
5231zero means top of window, negative means relative to bottom of window. */) 5215zero means top of window, negative means relative to bottom of window. */)
5232 (Lisp_Object arg) 5216 (Lisp_Object arg)
5233{ 5217{
@@ -5260,15 +5244,14 @@ zero means top of window, negative means relative to bottom of window. */)
5260 lines = displayed_window_lines (w); 5244 lines = displayed_window_lines (w);
5261 5245
5262#if 0 5246#if 0
5263 this_scroll_margin = max (0, scroll_margin); 5247 this_scroll_margin = max (0, min (scroll_margin, lines / 4));
5264 this_scroll_margin = min (this_scroll_margin, lines / 4);
5265#endif 5248#endif
5266 5249
5267 if (NILP (arg)) 5250 if (NILP (arg))
5268 XSETFASTINT (arg, lines / 2); 5251 XSETFASTINT (arg, lines / 2);
5269 else 5252 else
5270 { 5253 {
5271 int iarg = XINT (Fprefix_numeric_value (arg)); 5254 EMACS_INT iarg = XINT (Fprefix_numeric_value (arg));
5272 5255
5273 if (iarg < 0) 5256 if (iarg < 0)
5274 iarg = iarg + lines; 5257 iarg = iarg + lines;
@@ -5336,7 +5319,7 @@ struct saved_window
5336 Lisp_Object left_margin_cols, right_margin_cols; 5319 Lisp_Object left_margin_cols, right_margin_cols;
5337 Lisp_Object left_fringe_width, right_fringe_width, fringes_outside_margins; 5320 Lisp_Object left_fringe_width, right_fringe_width, fringes_outside_margins;
5338 Lisp_Object scroll_bar_width, vertical_scroll_bar_type, dedicated; 5321 Lisp_Object scroll_bar_width, vertical_scroll_bar_type, dedicated;
5339 Lisp_Object splits, nest, window_parameters; 5322 Lisp_Object combination_limit, window_parameters;
5340}; 5323};
5341 5324
5342#define SAVED_WINDOW_N(swv,n) \ 5325#define SAVED_WINDOW_N(swv,n) \
@@ -5435,12 +5418,14 @@ the return value is nil. Otherwise the value is t. */)
5435 { 5418 {
5436 Lisp_Object window; 5419 Lisp_Object window;
5437 Lisp_Object dead_windows = Qnil; 5420 Lisp_Object dead_windows = Qnil;
5421 register Lisp_Object tem, par, pers;
5438 register struct window *w; 5422 register struct window *w;
5439 register struct saved_window *p; 5423 register struct saved_window *p;
5440 struct window *root_window; 5424 struct window *root_window;
5441 struct window **leaf_windows; 5425 struct window **leaf_windows;
5442 int n_leaf_windows; 5426 int n_leaf_windows;
5443 int k, i, n; 5427 ptrdiff_t k;
5428 int i, n;
5444 5429
5445 /* If the frame has been resized since this window configuration was 5430 /* If the frame has been resized since this window configuration was
5446 made, we change the frame to the size specified in the 5431 made, we change the frame to the size specified in the
@@ -5506,7 +5491,7 @@ the return value is nil. Otherwise the value is t. */)
5506 Save their current buffers in their height fields, since we may 5491 Save their current buffers in their height fields, since we may
5507 need it later, if a buffer saved in the configuration is now 5492 need it later, if a buffer saved in the configuration is now
5508 dead. */ 5493 dead. */
5509 delete_all_subwindows (FRAME_ROOT_WINDOW (f)); 5494 delete_all_child_windows (FRAME_ROOT_WINDOW (f));
5510 5495
5511 for (k = 0; k < saved_windows->header.size; k++) 5496 for (k = 0; k < saved_windows->header.size; k++)
5512 { 5497 {
@@ -5566,9 +5551,29 @@ the return value is nil. Otherwise the value is t. */)
5566 w->scroll_bar_width = p->scroll_bar_width; 5551 w->scroll_bar_width = p->scroll_bar_width;
5567 w->vertical_scroll_bar_type = p->vertical_scroll_bar_type; 5552 w->vertical_scroll_bar_type = p->vertical_scroll_bar_type;
5568 w->dedicated = p->dedicated; 5553 w->dedicated = p->dedicated;
5569 w->splits = p->splits; 5554 w->combination_limit = p->combination_limit;
5570 w->nest = p->nest; 5555 /* Restore any window parameters that have been saved.
5571 w->window_parameters = p->window_parameters; 5556 Parameters that have not been saved are left alone. */
5557 for (tem = p->window_parameters; CONSP (tem); tem = XCDR (tem))
5558 {
5559 pers = XCAR (tem);
5560 if (CONSP (pers))
5561 {
5562 if (NILP (XCDR (pers)))
5563 {
5564 par = Fassq (XCAR (pers), w->window_parameters);
5565 if (CONSP (par) && !NILP (XCDR (par)))
5566 /* Reset a parameter to nil if and only if it
5567 has a non-nil association. Don't make new
5568 associations. */
5569 Fsetcdr (par, Qnil);
5570 }
5571 else
5572 /* Always restore a non-nil value. */
5573 Fset_window_parameter (window, XCAR (pers), XCDR (pers));
5574 }
5575 }
5576
5572 XSETFASTINT (w->last_modified, 0); 5577 XSETFASTINT (w->last_modified, 0);
5573 XSETFASTINT (w->last_overlay_modified, 0); 5578 XSETFASTINT (w->last_overlay_modified, 0);
5574 5579
@@ -5720,10 +5725,10 @@ the return value is nil. Otherwise the value is t. */)
5720} 5725}
5721 5726
5722 5727
5723/* Delete all subwindows reachable via the next, vchild, and hchild 5728/* Recursively delete all child windows reachable via the next, vchild,
5724 slots of WINDOW. */ 5729 and hchild slots of WINDOW. */
5725void 5730void
5726delete_all_subwindows (Lisp_Object window) 5731delete_all_child_windows (Lisp_Object window)
5727{ 5732{
5728 register struct window *w; 5733 register struct window *w;
5729 5734
@@ -5731,18 +5736,18 @@ delete_all_subwindows (Lisp_Object window)
5731 5736
5732 if (!NILP (w->next)) 5737 if (!NILP (w->next))
5733 /* Delete WINDOW's siblings (we traverse postorderly). */ 5738 /* Delete WINDOW's siblings (we traverse postorderly). */
5734 delete_all_subwindows (w->next); 5739 delete_all_child_windows (w->next);
5735 5740
5736 w->total_lines = w->buffer; /* See Fset_window_configuration for excuse. */ 5741 w->total_lines = w->buffer; /* See Fset_window_configuration for excuse. */
5737 5742
5738 if (!NILP (w->vchild)) 5743 if (!NILP (w->vchild))
5739 { 5744 {
5740 delete_all_subwindows (w->vchild); 5745 delete_all_child_windows (w->vchild);
5741 w->vchild = Qnil; 5746 w->vchild = Qnil;
5742 } 5747 }
5743 else if (!NILP (w->hchild)) 5748 else if (!NILP (w->hchild))
5744 { 5749 {
5745 delete_all_subwindows (w->hchild); 5750 delete_all_child_windows (w->hchild);
5746 w->hchild = Qnil; 5751 w->hchild = Qnil;
5747 } 5752 }
5748 else if (!NILP (w->buffer)) 5753 else if (!NILP (w->buffer))
@@ -5792,20 +5797,37 @@ get_leaf_windows (struct window *w, struct window **flat, int i)
5792 5797
5793 5798
5794/* Return a pointer to the glyph W's physical cursor is on. Value is 5799/* Return a pointer to the glyph W's physical cursor is on. Value is
5795 null if W's current matrix is invalid, so that no meaningfull glyph 5800 null if W's current matrix is invalid, so that no meaningful glyph
5796 can be returned. */ 5801 can be returned. */
5797struct glyph * 5802struct glyph *
5798get_phys_cursor_glyph (struct window *w) 5803get_phys_cursor_glyph (struct window *w)
5799{ 5804{
5800 struct glyph_row *row; 5805 struct glyph_row *row;
5801 struct glyph *glyph; 5806 struct glyph *glyph;
5807 int hpos = w->phys_cursor.hpos;
5808
5809 if (!(w->phys_cursor.vpos >= 0
5810 && w->phys_cursor.vpos < w->current_matrix->nrows))
5811 return NULL;
5812
5813 row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos);
5814 if (!row->enabled_p)
5815 return NULL;
5802 5816
5803 if (w->phys_cursor.vpos >= 0 5817 if (XINT (w->hscroll))
5804 && w->phys_cursor.vpos < w->current_matrix->nrows 5818 {
5805 && (row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos), 5819 /* When the window is hscrolled, cursor hpos can legitimately be
5806 row->enabled_p) 5820 out of bounds, but we draw the cursor at the corresponding
5807 && row->used[TEXT_AREA] > w->phys_cursor.hpos) 5821 window margin in that case. */
5808 glyph = row->glyphs[TEXT_AREA] + w->phys_cursor.hpos; 5822 if (!row->reversed_p && hpos < 0)
5823 hpos = 0;
5824 if (row->reversed_p && hpos >= row->used[TEXT_AREA])
5825 hpos = row->used[TEXT_AREA] - 1;
5826 }
5827
5828 if (row->used[TEXT_AREA] > hpos
5829 && 0 <= hpos)
5830 glyph = row->glyphs[TEXT_AREA] + hpos;
5809 else 5831 else
5810 glyph = NULL; 5832 glyph = NULL;
5811 5833
@@ -5818,7 +5840,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
5818{ 5840{
5819 register struct saved_window *p; 5841 register struct saved_window *p;
5820 register struct window *w; 5842 register struct window *w;
5821 register Lisp_Object tem; 5843 register Lisp_Object tem, pers, par;
5822 5844
5823 for (;!NILP (window); window = w->next) 5845 for (;!NILP (window); window = w->next)
5824 { 5846 {
@@ -5845,14 +5867,60 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
5845 p->scroll_bar_width = w->scroll_bar_width; 5867 p->scroll_bar_width = w->scroll_bar_width;
5846 p->vertical_scroll_bar_type = w->vertical_scroll_bar_type; 5868 p->vertical_scroll_bar_type = w->vertical_scroll_bar_type;
5847 p->dedicated = w->dedicated; 5869 p->dedicated = w->dedicated;
5848 p->splits = w->splits; 5870 p->combination_limit = w->combination_limit;
5849 p->nest = w->nest; 5871 p->window_parameters = Qnil;
5850 p->window_parameters = w->window_parameters; 5872
5873 if (!NILP (Vwindow_persistent_parameters))
5874 {
5875 /* Run cycle detection on Vwindow_persistent_parameters. */
5876 Lisp_Object tortoise, hare;
5877
5878 hare = tortoise = Vwindow_persistent_parameters;
5879 while (CONSP (hare))
5880 {
5881 hare = XCDR (hare);
5882 if (!CONSP (hare))
5883 break;
5884
5885 hare = XCDR (hare);
5886 tortoise = XCDR (tortoise);
5887
5888 if (EQ (hare, tortoise))
5889 /* Reset Vwindow_persistent_parameters to Qnil. */
5890 {
5891 Vwindow_persistent_parameters = Qnil;
5892 break;
5893 }
5894 }
5895
5896 for (tem = Vwindow_persistent_parameters; CONSP (tem);
5897 tem = XCDR (tem))
5898 {
5899 pers = XCAR (tem);
5900 /* Save values for persistent window parameters. */
5901 if (CONSP (pers) && !NILP (XCDR (pers)))
5902 {
5903 par = Fassq (XCAR (pers), w->window_parameters);
5904 if (NILP (par))
5905 /* If the window has no value for the parameter,
5906 make one. */
5907 p->window_parameters = Fcons (Fcons (XCAR (pers), Qnil),
5908 p->window_parameters);
5909 else
5910 /* If the window has a value for the parameter,
5911 save it. */
5912 p->window_parameters = Fcons (Fcons (XCAR (par),
5913 XCDR (par)),
5914 p->window_parameters);
5915 }
5916 }
5917 }
5918
5851 if (!NILP (w->buffer)) 5919 if (!NILP (w->buffer))
5852 { 5920 {
5853 /* Save w's value of point in the window configuration. 5921 /* Save w's value of point in the window configuration. If w
5854 If w is the selected window, then get the value of point 5922 is the selected window, then get the value of point from
5855 from the buffer; pointm is garbage in the selected window. */ 5923 the buffer; pointm is garbage in the selected window. */
5856 if (EQ (window, selected_window)) 5924 if (EQ (window, selected_window))
5857 { 5925 {
5858 p->pointm = Fmake_marker (); 5926 p->pointm = Fmake_marker ();
@@ -5905,7 +5973,9 @@ and for each displayed buffer, where display starts, and the positions of
5905point and mark. An exception is made for point in the current buffer: 5973point and mark. An exception is made for point in the current buffer:
5906its value is -not- saved. 5974its value is -not- saved.
5907This also records the currently selected frame, and FRAME's focus 5975This also records the currently selected frame, and FRAME's focus
5908redirection (see `redirect-frame-focus'). */) 5976redirection (see `redirect-frame-focus'). The variable
5977`window-persistent-parameters' specifies which window parameters are
5978saved by this function. */)
5909 (Lisp_Object frame) 5979 (Lisp_Object frame)
5910{ 5980{
5911 register Lisp_Object tem; 5981 register Lisp_Object tem;
@@ -5996,7 +6066,7 @@ means no margin. */)
5996DEFUN ("window-margins", Fwindow_margins, Swindow_margins, 6066DEFUN ("window-margins", Fwindow_margins, Swindow_margins,
5997 0, 1, 0, 6067 0, 1, 0,
5998 doc: /* Get width of marginal areas of window WINDOW. 6068 doc: /* Get width of marginal areas of window WINDOW.
5999If WINDOW is omitted or nil, use the currently selected window. 6069If WINDOW is omitted or nil, it defaults to the selected window.
6000Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH). 6070Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH).
6001If a marginal area does not exist, its width will be returned 6071If a marginal area does not exist, its width will be returned
6002as nil. */) 6072as nil. */)
@@ -6060,7 +6130,7 @@ display marginal areas and the text area. */)
6060DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes, 6130DEFUN ("window-fringes", Fwindow_fringes, Swindow_fringes,
6061 0, 1, 0, 6131 0, 1, 0,
6062 doc: /* Get width of fringes of window WINDOW. 6132 doc: /* Get width of fringes of window WINDOW.
6063If WINDOW is omitted or nil, use the currently selected window. 6133If WINDOW is omitted or nil, it defaults to the selected window.
6064Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) 6134Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */)
6065 (Lisp_Object window) 6135 (Lisp_Object window)
6066{ 6136{
@@ -6129,7 +6199,7 @@ Fourth parameter HORIZONTAL-TYPE is currently unused. */)
6129DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars, 6199DEFUN ("window-scroll-bars", Fwindow_scroll_bars, Swindow_scroll_bars,
6130 0, 1, 0, 6200 0, 1, 0,
6131 doc: /* Get width and type of scroll bars of window WINDOW. 6201 doc: /* Get width and type of scroll bars of window WINDOW.
6132If WINDOW is omitted or nil, use the currently selected window. 6202If WINDOW is omitted or nil, it defaults to the selected window.
6133Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE). 6203Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE).
6134If WIDTH is nil or TYPE is t, the window is using the frame's corresponding 6204If WIDTH is nil or TYPE is t, the window is using the frame's corresponding
6135value. */) 6205value. */)
@@ -6152,7 +6222,7 @@ value. */)
6152 6222
6153DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 2, 0, 6223DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 2, 0,
6154 doc: /* Return the amount by which WINDOW is scrolled vertically. 6224 doc: /* Return the amount by which WINDOW is scrolled vertically.
6155Use the selected window if WINDOW is nil or omitted. 6225If WINDOW is omitted or nil, it defaults to the selected window.
6156Normally, value is a multiple of the canonical character height of WINDOW; 6226Normally, value is a multiple of the canonical character height of WINDOW;
6157optional second arg PIXELS-P means value is measured in pixels. */) 6227optional second arg PIXELS-P means value is measured in pixels. */)
6158 (Lisp_Object window, Lisp_Object pixels_p) 6228 (Lisp_Object window, Lisp_Object pixels_p)
@@ -6308,15 +6378,16 @@ freeze_window_starts (struct frame *f, int freeze_p)
6308 ignore_positions non-zero means ignore non-matching scroll positions 6378 ignore_positions non-zero means ignore non-matching scroll positions
6309 and the like. 6379 and the like.
6310 6380
6311 This ignores a couple of things like the dedicatedness status of 6381 This ignores a couple of things like the dedication status of
6312 window, splits, nest and the like. This might have to be fixed. */ 6382 window, combination_limit and the like. This might have to be
6383 fixed. */
6313 6384
6314int 6385int
6315compare_window_configurations (Lisp_Object configuration1, Lisp_Object configuration2, int ignore_positions) 6386compare_window_configurations (Lisp_Object configuration1, Lisp_Object configuration2, int ignore_positions)
6316{ 6387{
6317 register struct save_window_data *d1, *d2; 6388 register struct save_window_data *d1, *d2;
6318 struct Lisp_Vector *sws1, *sws2; 6389 struct Lisp_Vector *sws1, *sws2;
6319 int i; 6390 ptrdiff_t i;
6320 6391
6321 CHECK_WINDOW_CONFIGURATION (configuration1); 6392 CHECK_WINDOW_CONFIGURATION (configuration1);
6322 CHECK_WINDOW_CONFIGURATION (configuration2); 6393 CHECK_WINDOW_CONFIGURATION (configuration2);
@@ -6441,6 +6512,7 @@ syms_of_window (void)
6441 DEFSYM (Qabove, "above"); 6512 DEFSYM (Qabove, "above");
6442 DEFSYM (Qbelow, "below"); 6513 DEFSYM (Qbelow, "below");
6443 DEFSYM (Qauto_buffer_name, "auto-buffer-name"); 6514 DEFSYM (Qauto_buffer_name, "auto-buffer-name");
6515 DEFSYM (Qclone_of, "clone-of");
6444 6516
6445 staticpro (&Vwindow_list); 6517 staticpro (&Vwindow_list);
6446 6518
@@ -6460,16 +6532,6 @@ If this function is used, then it must do the entire job of showing
6460the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */); 6532the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */);
6461 Vtemp_buffer_show_function = Qnil; 6533 Vtemp_buffer_show_function = Qnil;
6462 6534
6463 DEFVAR_LISP ("temp-buffer-show-specifiers", Vtemp_buffer_show_specifiers,
6464 doc: /* Buffer display specifiers used by `with-output-to-temp-buffer'.
6465These specifiers are passed by `with-output-to-temp-buffer' as second
6466argument to `display-buffer'. Applications should only let-bind this
6467around a call to `with-output-to-temp-buffer'.
6468
6469For a description of buffer display specifiers see the variable
6470`display-buffer-alist'. */);
6471 Vtemp_buffer_show_specifiers = Qnil;
6472
6473 DEFVAR_LISP ("minibuffer-scroll-window", Vminibuf_scroll_window, 6535 DEFVAR_LISP ("minibuffer-scroll-window", Vminibuf_scroll_window,
6474 doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */); 6536 doc: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */);
6475 Vminibuf_scroll_window = Qnil; 6537 Vminibuf_scroll_window = Qnil;
@@ -6518,46 +6580,72 @@ with the relevant frame selected. */);
6518 Vwindow_configuration_change_hook = Qnil; 6580 Vwindow_configuration_change_hook = Qnil;
6519 6581
6520 DEFVAR_LISP ("recenter-redisplay", Vrecenter_redisplay, 6582 DEFVAR_LISP ("recenter-redisplay", Vrecenter_redisplay,
6521 doc: /* If non-nil, then the `recenter' command with a nil argument 6583 doc: /* Non-nil means `recenter' redraws entire frame.
6522will redraw the entire frame; the special value `tty' causes the 6584If this option is non-nil, then the `recenter' command with a nil
6523frame to be redrawn only if it is a tty frame. */); 6585argument will redraw the entire frame; the special value `tty' causes
6586the frame to be redrawn only if it is a tty frame. */);
6524 Vrecenter_redisplay = Qtty; 6587 Vrecenter_redisplay = Qtty;
6525 6588
6526 DEFVAR_LISP ("window-splits", Vwindow_splits, 6589 DEFVAR_LISP ("window-combination-resize", Vwindow_combination_resize,
6527 doc: /* Non-nil means splitting windows is handled specially. 6590 doc: /* If t, resize window combinations proportionally.
6528If this variable is nil, splitting a window gets the entire screen space 6591If this variable is nil, splitting a window gets the entire screen space
6529for displaying the new window from the window to split. If this 6592for displaying the new window from the window to split. Deleting and
6530variable is non-nil, splitting a window may resize all windows in the 6593resizing a window preferably resizes one adjacent window only.
6531same combination. This also allows to split a window that is otherwise 6594
6532too small or of fixed size. 6595If this variable is t, splitting a window tries to get the space
6533 6596proportionally from all windows in the same combination. This also
6534The value of this variable is also assigned to the split status of the 6597allows to split a window that is otherwise too small or of fixed size.
6535new window and, provided the old and new window form a new combination, 6598Resizing and deleting a window proportionally resize all windows in the
6536to the window that was split as well. The split status of a window can 6599same combination.
6537be retrieved with the function `window-splits' and altered by the 6600
6538function `set-window-splits'. 6601Other values are reserved for future use.
6539 6602
6540If the value of the variable `window-nest' is non-nil, the space for the 6603This variable takes no effect if `window-combination-limit' is non-nil. */);
6541new window is exclusively taken from the window that shall be split, but 6604 Vwindow_combination_resize = Qnil;
6542the split status of the window that is split as well as that of the new 6605
6543window are still set to the value of this variable. */); 6606 DEFVAR_LISP ("window-combination-limit", Vwindow_combination_limit,
6544 Vwindow_splits = Qnil; 6607 doc: /* If t, splitting a window makes a new parent window.
6545
6546 DEFVAR_LISP ("window-nest", Vwindow_nest,
6547 doc: /* Non-nil means splitting a window makes a new parent window.
6548If this variable is nil, splitting a window will create a new parent 6608If this variable is nil, splitting a window will create a new parent
6549window only if the window has no parent window or the window shall 6609window only if the window has no parent window or the window shall
6550become a combination orthogonal to the one it it is part of. 6610become a combination orthogonal to the one it is part of.
6611
6612If this variable is t, splitting a window always creates a new parent
6613window. If all splits behave this way, each frame's window tree is a
6614binary tree and every window but the frame's root window has exactly one
6615sibling.
6616
6617Other values are reserved for future use.
6618
6619The value of this variable is also assigned to the combination limit of
6620the new parent window. The combination limit of a window can be
6621retrieved via the function `window-combination-limit' and altered by the
6622function `set-window-combination-limit'. */);
6623 Vwindow_combination_limit = Qnil;
6624
6625 DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters,
6626 doc: /* Alist of persistent window parameters.
6627This alist specifies which window parameters shall get saved by
6628`current-window-configuration' and `window-state-get' and subsequently
6629restored to their previous values by `set-window-configuration' and
6630`window-state-put'.
6631
6632The car of each entry of this alist is the symbol specifying the
6633parameter. The cdr is one of the following:
6634
6635nil means the parameter is neither saved by `window-state-get' nor by
6636`current-window-configuration'.
6637
6638t means the parameter is saved by `current-window-configuration' and,
6639provided its WRITABLE argument is nil, by `window-state-get'.
6551 6640
6552If this variable is non-nil, splitting a window always creates a new 6641The symbol `writable' means the parameter is saved unconditionally by
6553parent window. If all splits behave this way, each frame's window tree 6642both `current-window-configuration' and `window-state-get'. Do not use
6554is a binary tree and every window but the frame's root window has 6643this value for parameters without read syntax (like windows or frames).
6555exactly one sibling.
6556 6644
6557The value of this variable is also assigned to the nest status of the 6645Parameters not saved by `current-window-configuration' or
6558new parent window. The nest status of a window can be retrieved via the 6646`window-state-get' are left alone by `set-window-configuration'
6559function `window-nest' and altered by the function `set-window-nest'. */); 6647respectively are not installed by `window-state-put'. */);
6560 Vwindow_nest = Qnil; 6648 Vwindow_persistent_parameters = list1 (Fcons (Qclone_of, Qt));
6561 6649
6562 defsubr (&Sselected_window); 6650 defsubr (&Sselected_window);
6563 defsubr (&Sminibuffer_window); 6651 defsubr (&Sminibuffer_window);
@@ -6577,21 +6665,21 @@ function `window-nest' and altered by the function `set-window-nest'. */);
6577 defsubr (&Swindow_left_child); 6665 defsubr (&Swindow_left_child);
6578 defsubr (&Swindow_next_sibling); 6666 defsubr (&Swindow_next_sibling);
6579 defsubr (&Swindow_prev_sibling); 6667 defsubr (&Swindow_prev_sibling);
6580 defsubr (&Swindow_splits); 6668 defsubr (&Swindow_combination_limit);
6581 defsubr (&Sset_window_splits); 6669 defsubr (&Sset_window_combination_limit);
6582 defsubr (&Swindow_nest);
6583 defsubr (&Sset_window_nest);
6584 defsubr (&Swindow_use_time); 6670 defsubr (&Swindow_use_time);
6585 defsubr (&Swindow_top_line); 6671 defsubr (&Swindow_top_line);
6586 defsubr (&Swindow_left_column); 6672 defsubr (&Swindow_left_column);
6587 defsubr (&Swindow_total_size); 6673 defsubr (&Swindow_total_height);
6674 defsubr (&Swindow_total_width);
6588 defsubr (&Swindow_normal_size); 6675 defsubr (&Swindow_normal_size);
6589 defsubr (&Swindow_new_total); 6676 defsubr (&Swindow_new_total);
6590 defsubr (&Swindow_new_normal); 6677 defsubr (&Swindow_new_normal);
6591 defsubr (&Sset_window_new_total); 6678 defsubr (&Sset_window_new_total);
6592 defsubr (&Sset_window_new_normal); 6679 defsubr (&Sset_window_new_normal);
6593 defsubr (&Swindow_resize_apply); 6680 defsubr (&Swindow_resize_apply);
6594 defsubr (&Swindow_body_size); 6681 defsubr (&Swindow_body_height);
6682 defsubr (&Swindow_body_width);
6595 defsubr (&Swindow_hscroll); 6683 defsubr (&Swindow_hscroll);
6596 defsubr (&Sset_window_hscroll); 6684 defsubr (&Sset_window_hscroll);
6597 defsubr (&Swindow_redisplay_end_trigger); 6685 defsubr (&Swindow_redisplay_end_trigger);