1 /* Window creation, deletion and examination for GNU Emacs.
2 Does not include redisplay.
3 Copyright (C) 1985, 86, 87, 93, 94, 95, 96 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
33 Lisp_Object Qwindowp
, Qwindow_live_p
;
35 Lisp_Object
Fnext_window (), Fdelete_window (), Fselect_window ();
36 Lisp_Object
Fset_window_buffer (), Fsplit_window (), Frecenter ();
38 void delete_all_subwindows ();
39 static struct window
*decode_window();
41 /* This is the window in which the terminal's cursor should
42 be left when nothing is being done with it. This must
43 always be a leaf window, and its buffer is selected by
44 the top level editing loop at the end of each command.
46 This value is always the same as
47 FRAME_SELECTED_WINDOW (selected_frame). */
49 Lisp_Object selected_window
;
51 /* The minibuffer window of the selected frame.
52 Note that you cannot test for minibufferness of an arbitrary window
53 by comparing against this; but you can test for minibufferness of
54 the selected window. */
55 Lisp_Object minibuf_window
;
57 /* Non-nil means it is the window for C-M-v to scroll
58 when the minibuffer is selected. */
59 Lisp_Object Vminibuf_scroll_window
;
61 /* Non-nil means this is the buffer whose window C-M-v should scroll. */
62 Lisp_Object Vother_window_scroll_buffer
;
64 /* Non-nil means it's function to call to display temp buffers. */
65 Lisp_Object Vtemp_buffer_show_function
;
67 /* If a window gets smaller than either of these, it is removed. */
68 int window_min_height
;
71 /* Nonzero implies Fdisplay_buffer should create windows. */
74 /* Nonzero implies make new frames for Fdisplay_buffer. */
77 /* Non-nil means use this function instead of default */
78 Lisp_Object Vpop_up_frame_function
;
80 /* Function to call to handle Fdisplay_buffer. */
81 Lisp_Object Vdisplay_buffer_function
;
83 /* List of buffer *names* for buffers that should have their own frames. */
84 Lisp_Object Vspecial_display_buffer_names
;
86 /* List of regexps for buffer names that should have their own frames. */
87 Lisp_Object Vspecial_display_regexps
;
89 /* Function to pop up a special frame. */
90 Lisp_Object Vspecial_display_function
;
92 /* List of buffer *names* for buffers to appear in selected window. */
93 Lisp_Object Vsame_window_buffer_names
;
95 /* List of regexps for buffer names to appear in selected window. */
96 Lisp_Object Vsame_window_regexps
;
98 /* Hook run at end of temp_output_buffer_show. */
99 Lisp_Object Qtemp_buffer_show_hook
;
101 /* Fdisplay_buffer always splits the largest window
102 if that window is more than this high. */
103 int split_height_threshold
;
105 /* Number of lines of continuity in scrolling by screenfuls. */
106 int next_screen_context_lines
;
108 /* Incremented for each window created. */
109 static int sequence_number
;
111 /* Nonzero after init_window_once has finished. */
112 static int window_initialized
;
114 /* Nonzero means scroll commands try to put point
115 at the same screen height as previously. */
116 static int scroll_preserve_screen_position
;
118 #define min(a, b) ((a) < (b) ? (a) : (b))
120 extern int scroll_margin
;
122 extern Lisp_Object Qwindow_scroll_functions
, Vwindow_scroll_functions
;
124 DEFUN ("windowp", Fwindowp
, Swindowp
, 1, 1, 0,
125 "Returns t if OBJECT is a window.")
129 return WINDOWP (object
) ? Qt
: Qnil
;
132 DEFUN ("window-live-p", Fwindow_live_p
, Swindow_live_p
, 1, 1, 0,
133 "Returns t if OBJECT is a window which is currently visible.")
137 return (WINDOWP (object
) && ! NILP (XWINDOW (object
)->buffer
) ? Qt
: Qnil
);
144 register struct window
*p
;
145 register struct Lisp_Vector
*vec
;
148 vec
= allocate_vectorlike ((EMACS_INT
) VECSIZE (struct window
));
149 for (i
= 0; i
< VECSIZE (struct window
); i
++)
150 vec
->contents
[i
] = Qnil
;
151 vec
->size
= VECSIZE (struct window
);
152 p
= (struct window
*)vec
;
153 XSETFASTINT (p
->sequence_number
, ++sequence_number
);
154 XSETFASTINT (p
->left
, 0);
155 XSETFASTINT (p
->top
, 0);
156 XSETFASTINT (p
->height
, 0);
157 XSETFASTINT (p
->width
, 0);
158 XSETFASTINT (p
->hscroll
, 0);
159 XSETFASTINT (p
->last_point_x
, 0);
160 XSETFASTINT (p
->last_point_y
, 0);
161 p
->start
= Fmake_marker ();
162 p
->pointm
= Fmake_marker ();
163 XSETFASTINT (p
->use_time
, 0);
165 p
->display_table
= Qnil
;
171 DEFUN ("selected-window", Fselected_window
, Sselected_window
, 0, 0, 0,
172 "Return the window that the cursor now appears in and commands apply to.")
175 return selected_window
;
178 DEFUN ("minibuffer-window", Fminibuffer_window
, Sminibuffer_window
, 0, 1, 0,
179 "Return the window used now for minibuffers.\n\
180 If the optional argument FRAME is specified, return the minibuffer window\n\
181 used by that frame.")
186 XSETFRAME (frame
, selected_frame
);
188 CHECK_LIVE_FRAME (frame
, 0);
190 return FRAME_MINIBUF_WINDOW (XFRAME (frame
));
193 DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p
, Swindow_minibuffer_p
, 0, 1, 0,
194 "Returns non-nil if WINDOW is a minibuffer window.")
198 struct window
*w
= decode_window (window
);
199 return (MINI_WINDOW_P (w
) ? Qt
: Qnil
);
202 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p
,
203 Spos_visible_in_window_p
, 0, 2, 0,
204 "Return t if position POS is currently on the frame in WINDOW.\n\
205 Returns nil if that position is scrolled vertically out of view.\n\
206 POS defaults to point; WINDOW, to the selected window.")
208 Lisp_Object pos
, window
;
210 register struct window
*w
;
214 register struct buffer
*buf
;
215 struct position posval
;
222 CHECK_NUMBER_COERCE_MARKER (pos
, 0);
226 w
= decode_window (window
);
227 top
= marker_position (w
->start
);
228 hscroll
= XINT (w
->hscroll
);
233 height
= XFASTINT (w
->height
) - ! MINI_WINDOW_P (w
);
235 buf
= XBUFFER (w
->buffer
);
236 if (XFASTINT (w
->last_modified
) >= BUF_MODIFF (buf
)
237 && XFASTINT (w
->last_overlay_modified
) >= BUF_OVERLAY_MODIFF (buf
))
239 /* If frame is up to date,
240 use the info recorded about how much text fit on it. */
241 if (posint
< BUF_Z (buf
) - XFASTINT (w
->window_end_pos
)
242 || (XFASTINT (w
->window_end_vpos
) < height
))
248 if (posint
> BUF_ZV (buf
))
251 /* w->start can be out of range. If it is, do something reasonable. */
252 if (top
< BUF_BEGV (buf
) || top
> BUF_ZV (buf
))
255 /* If that info is not correct, calculate afresh */
256 /* BUG FIX for the 7th arg (TOHPOS).
258 '0' is harmless, however, ' - (1 << (BITS_PER_SHORT - 1))' is
259 more appropriate here. In case of HSCROLL > 0, this can avoid
260 needless calculation done until (HPOS == 0).
262 We want to determine if the position POSINT is in HEIGHT or
263 not. We don't have to do calculation until (HPOS == 0). We
264 can stop it when VPOS goes beyond HEIGHT. */
265 posval
= *compute_motion (top
, 0, (hscroll
? 1 - hscroll
: 0), 0,
266 posint
, height
, - (1 << (BITS_PER_SHORT
- 1)),
267 window_internal_width (w
) - 1,
270 return posval
.vpos
< height
? Qt
: Qnil
;
274 static struct window
*
275 decode_window (window
)
276 register Lisp_Object window
;
279 return XWINDOW (selected_window
);
281 CHECK_LIVE_WINDOW (window
, 0);
282 return XWINDOW (window
);
285 DEFUN ("window-buffer", Fwindow_buffer
, Swindow_buffer
, 0, 1, 0,
286 "Return the buffer that WINDOW is displaying.")
290 return decode_window (window
)->buffer
;
293 DEFUN ("window-height", Fwindow_height
, Swindow_height
, 0, 1, 0,
294 "Return the number of lines in WINDOW (including its mode line).")
298 return decode_window (window
)->height
;
301 DEFUN ("window-width", Fwindow_width
, Swindow_width
, 0, 1, 0,
302 "Return the number of display columns in WINDOW.\n\
303 This is the width that is usable columns available for text in WINDOW.\n\
304 If you want to find out how many columns WINDOW takes up,\n\
305 use (let ((edges (window-edges))) (- (nth 2 edges) (nth 0 edges))).")
309 return make_number (window_internal_width (decode_window (window
)));
312 DEFUN ("window-hscroll", Fwindow_hscroll
, Swindow_hscroll
, 0, 1, 0,
313 "Return the number of columns by which WINDOW is scrolled from left margin.")
317 return decode_window (window
)->hscroll
;
320 DEFUN ("set-window-hscroll", Fset_window_hscroll
, Sset_window_hscroll
, 2, 2, 0,
321 "Set number of columns WINDOW is scrolled from left margin to NCOL.\n\
322 NCOL should be zero or positive.")
324 register Lisp_Object window
, ncol
;
326 register struct window
*w
;
328 CHECK_NUMBER (ncol
, 1);
329 if (XINT (ncol
) < 0) XSETFASTINT (ncol
, 0);
330 w
= decode_window (window
);
331 if (XINT (w
->hscroll
) != XINT (ncol
))
332 XBUFFER (w
->buffer
)->clip_changed
= 1; /* Prevent redisplay shortcuts */
337 DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger
,
338 Swindow_redisplay_end_trigger
, 0, 1, 0,
339 "Return WINDOW's redisplay end trigger value.\n\
340 See `set-window-redisplay-end-trigger' for more information.")
344 return decode_window (window
)->redisplay_end_trigger
;
347 DEFUN ("set-window-redisplay-end-trigger", Fset_window_redisplay_end_trigger
,
348 Sset_window_redisplay_end_trigger
, 2, 2, 0,
349 "Set WINDOW's redisplay end trigger value to VALUE.\n\
350 VALUE should be a buffer position (typically a marker) or nil.\n\
351 If it is a buffer position, then if redisplay in WINDOW reaches a position\n\
352 beyond VALUE, the functions in `redisplay-end-trigger-functions' are called\n\
353 with two arguments: WINDOW, and the end trigger value.\n\
354 Afterwards the end-trigger value is reset to nil.")
356 register Lisp_Object window
, value
;
358 register struct window
*w
;
360 w
= decode_window (window
);
361 w
->redisplay_end_trigger
= value
;
365 DEFUN ("window-edges", Fwindow_edges
, Swindow_edges
, 0, 1, 0,
366 "Return a list of the edge coordinates of WINDOW.\n\
367 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame.\n\
368 RIGHT is one more than the rightmost column used by WINDOW,\n\
369 and BOTTOM is one more than the bottommost row used by WINDOW\n\
374 register struct window
*w
= decode_window (window
);
376 return Fcons (w
->left
, Fcons (w
->top
,
377 Fcons (make_number (WINDOW_RIGHT_EDGE (w
)),
378 Fcons (make_number (XFASTINT (w
->top
)
379 + XFASTINT (w
->height
)),
383 /* Test if the character at column *x, row *y is within window *w.
384 If it is not, return 0;
385 if it is in the window's text area,
386 set *x and *y to its location relative to the upper left corner
389 if it is on the window's modeline, return 2;
390 if it is on the border between the window and its right sibling,
393 coordinates_in_window (w
, x
, y
)
394 register struct window
*w
;
397 register int left
= XINT (w
->left
);
398 register int right_edge
= WINDOW_RIGHT_EDGE (w
);
399 register int left_margin
= WINDOW_LEFT_MARGIN (w
);
400 register int right_margin
= WINDOW_RIGHT_MARGIN (w
);
401 register int window_height
= XINT (w
->height
);
402 register int top
= XFASTINT (w
->top
);
404 if ( *x
< left
|| *x
>= right_edge
405 || *y
< top
|| *y
>= top
+ window_height
)
408 if (left_margin
!= left
&& *x
< left_margin
&& *x
>= left
)
411 if (right_margin
!= right_edge
&& *x
>= right_margin
&& *x
< right_edge
)
414 /* Is the character is the mode line? */
415 if (*y
== top
+ window_height
- 1
416 && ! MINI_WINDOW_P (w
))
419 *x
-= WINDOW_LEFT_MARGIN (w
);
424 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p
,
425 Scoordinates_in_window_p
, 2, 2, 0,
426 "Return non-nil if COORDINATES are in WINDOW.\n\
427 COORDINATES is a cons of the form (X . Y), X and Y being distances\n\
428 measured in characters from the upper-left corner of the frame.\n\
429 (0 . 0) denotes the character in the upper left corner of the\n\
431 If COORDINATES are in the text portion of WINDOW,\n\
432 the coordinates relative to the window are returned.\n\
433 If they are in the mode line of WINDOW, `mode-line' is returned.\n\
434 If they are on the border between WINDOW and its right sibling,\n\
435 `vertical-line' is returned.")
436 (coordinates
, window
)
437 register Lisp_Object coordinates
, window
;
441 CHECK_LIVE_WINDOW (window
, 0);
442 CHECK_CONS (coordinates
, 1);
443 x
= XINT (Fcar (coordinates
));
444 y
= XINT (Fcdr (coordinates
));
446 switch (coordinates_in_window (XWINDOW (window
), &x
, &y
))
448 case 0: /* NOT in window at all. */
451 case 1: /* In text part of window. */
454 case 2: /* In mode line of window. */
457 case 3: /* On right border of window. */
458 return Qvertical_line
;
465 /* Find the window containing column x, row y, and return it as a
466 Lisp_Object. If x, y is on the window's modeline, set *part
467 to 1; if it is on the separating line between the window and its
468 right sibling, set it to 2; otherwise set it to 0. If there is no
469 window under x, y return nil and leave *part unmodified. */
471 window_from_coordinates (frame
, x
, y
, part
)
476 register Lisp_Object tem
, first
;
478 tem
= first
= FRAME_SELECTED_WINDOW (frame
);
482 int found
= coordinates_in_window (XWINDOW (tem
), &x
, &y
);
490 tem
= Fnext_window (tem
, Qt
, Qlambda
);
492 while (! EQ (tem
, first
));
497 DEFUN ("window-at", Fwindow_at
, Swindow_at
, 2, 3, 0,
498 "Return window containing coordinates X and Y on FRAME.\n\
499 If omitted, FRAME defaults to the currently selected frame.\n\
500 The top left corner of the frame is considered to be row 0,\n\
503 Lisp_Object x
, y
, frame
;
508 XSETFRAME (frame
, selected_frame
);
510 CHECK_LIVE_FRAME (frame
, 2);
514 return window_from_coordinates (XFRAME (frame
),
519 DEFUN ("window-point", Fwindow_point
, Swindow_point
, 0, 1, 0,
520 "Return current value of point in WINDOW.\n\
521 For a nonselected window, this is the value point would have\n\
522 if that window were selected.\n\
524 Note that, when WINDOW is the selected window and its buffer\n\
525 is also currently selected, the value returned is the same as (point).\n\
526 It would be more strictly correct to return the `top-level' value\n\
527 of point, outside of any save-excursion forms.\n\
528 But that is hard to define.")
532 register struct window
*w
= decode_window (window
);
534 if (w
== XWINDOW (selected_window
)
535 && current_buffer
== XBUFFER (w
->buffer
))
537 return Fmarker_position (w
->pointm
);
540 DEFUN ("window-start", Fwindow_start
, Swindow_start
, 0, 1, 0,
541 "Return position at which display currently starts in WINDOW.\n\
542 This is updated by redisplay or by calling `set-window-start'.")
546 return Fmarker_position (decode_window (window
)->start
);
549 /* This is text temporarily removed from the doc string below.
551 This function returns nil if the position is not currently known.\n\
552 That happens when redisplay is preempted and doesn't finish.\n\
553 If in that case you want to compute where the end of the window would\n\
554 have been if redisplay had finished, do this:\n\
556 (goto-char (window-start window))\n\
557 (vertical-motion (1- (window-height window)) window)\n\
560 DEFUN ("window-end", Fwindow_end
, Swindow_end
, 0, 1, 0,
561 "Return position at which display currently ends in WINDOW.\n\
562 This is updated by redisplay, when it runs to completion.\n\
563 Simply changing the buffer text or setting `window-start'\n\
564 does not update this value.")
569 struct window
*w
= decode_window (window
);
573 CHECK_BUFFER (buf
, 0);
575 #if 0 /* This change broke some things. We should make it later. */
576 /* If we don't know the end position, return nil.
577 The user can compute it with vertical-motion if he wants to.
578 It would be nicer to do it automatically,
579 but that's so slow that it would probably bother people. */
580 if (NILP (w
->window_end_valid
))
585 BUF_Z (XBUFFER (buf
)) - XFASTINT (w
->window_end_pos
));
590 DEFUN ("set-window-point", Fset_window_point
, Sset_window_point
, 2, 2, 0,
591 "Make point value in WINDOW be at position POS in WINDOW's buffer.")
593 Lisp_Object window
, pos
;
595 register struct window
*w
= decode_window (window
);
597 CHECK_NUMBER_COERCE_MARKER (pos
, 1);
598 if (w
== XWINDOW (selected_window
))
601 set_marker_restricted (w
->pointm
, pos
, w
->buffer
);
606 DEFUN ("set-window-start", Fset_window_start
, Sset_window_start
, 2, 3, 0,
607 "Make display in WINDOW start at position POS in WINDOW's buffer.\n\
608 Optional third arg NOFORCE non-nil inhibits next redisplay\n\
609 from overriding motion of point in order to display at this exact start.")
610 (window
, pos
, noforce
)
611 Lisp_Object window
, pos
, noforce
;
613 register struct window
*w
= decode_window (window
);
615 CHECK_NUMBER_COERCE_MARKER (pos
, 1);
616 set_marker_restricted (w
->start
, pos
, w
->buffer
);
617 /* this is not right, but much easier than doing what is right. */
618 w
->start_at_line_beg
= Qnil
;
621 w
->update_mode_line
= Qt
;
622 XSETFASTINT (w
->last_modified
, 0);
623 XSETFASTINT (w
->last_overlay_modified
, 0);
624 if (!EQ (window
, selected_window
))
625 windows_or_buffers_changed
++;
629 DEFUN ("window-dedicated-p", Fwindow_dedicated_p
, Swindow_dedicated_p
,
631 "Return WINDOW's dedicated object, usually t or nil.\n\
632 See also `set-window-dedicated-p'.")
636 return decode_window (window
)->dedicated
;
639 DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p
,
640 Sset_window_dedicated_p
, 2, 2, 0,
641 "Control whether WINDOW is dedicated to the buffer it displays.\n\
642 If it is dedicated, Emacs will not automatically change\n\
643 which buffer appears in it.\n\
644 The second argument is the new value for the dedication flag;\n\
647 Lisp_Object window
, arg
;
649 register struct window
*w
= decode_window (window
);
659 DEFUN ("window-display-table", Fwindow_display_table
, Swindow_display_table
,
661 "Return the display-table that WINDOW is using.")
665 return decode_window (window
)->display_table
;
668 /* Get the display table for use currently on window W.
669 This is either W's display table or W's buffer's display table.
670 Ignore the specified tables if they are not valid;
671 if no valid table is specified, return 0. */
673 struct Lisp_Char_Table
*
674 window_display_table (w
)
678 tem
= w
->display_table
;
679 if (DISP_TABLE_P (tem
))
680 return XCHAR_TABLE (tem
);
681 tem
= XBUFFER (w
->buffer
)->display_table
;
682 if (DISP_TABLE_P (tem
))
683 return XCHAR_TABLE (tem
);
684 tem
= Vstandard_display_table
;
685 if (DISP_TABLE_P (tem
))
686 return XCHAR_TABLE (tem
);
690 DEFUN ("set-window-display-table", Fset_window_display_table
, Sset_window_display_table
, 2, 2, 0,
691 "Set WINDOW's display-table to TABLE.")
693 register Lisp_Object window
, table
;
695 register struct window
*w
;
696 register Lisp_Object z
; /* Return value. */
698 w
= decode_window (window
);
699 w
->display_table
= table
;
703 /* Record info on buffer window w is displaying
704 when it is about to cease to display that buffer. */
707 register struct window
*w
;
712 if (XBUFFER (buf
) != XMARKER (w
->pointm
)->buffer
)
715 if (w
== XWINDOW (XBUFFER (buf
)->last_selected_window
))
716 XBUFFER (buf
)->last_selected_window
= Qnil
;
719 if (w
== XWINDOW (selected_window
)
720 || ! EQ (buf
, XWINDOW (selected_window
)->buffer
))
721 /* Do this except when the selected window's buffer
722 is being removed from some other window. */
724 /* last_window_start records the start position that this buffer
725 had in the last window to be disconnected from it.
726 Now that this statement is unconditional,
727 it is possible for the buffer to be displayed in the
728 selected window, while last_window_start reflects another
729 window which was recently showing the same buffer.
730 Some people might say that might be a good thing. Let's see. */
731 XBUFFER (buf
)->last_window_start
= marker_position (w
->start
);
733 /* Point in the selected window's buffer
734 is actually stored in that buffer, and the window's pointm isn't used.
735 So don't clobber point in that buffer. */
736 if (! EQ (buf
, XWINDOW (selected_window
)->buffer
))
737 BUF_PT (XBUFFER (buf
))
738 = clip_to_bounds (BUF_BEGV (XBUFFER (buf
)),
739 marker_position (w
->pointm
),
740 BUF_ZV (XBUFFER (buf
)));
743 /* Put replacement into the window structure in place of old. */
745 replace_window (old
, replacement
)
746 Lisp_Object old
, replacement
;
748 register Lisp_Object tem
;
749 register struct window
*o
= XWINDOW (old
), *p
= XWINDOW (replacement
);
751 /* If OLD is its frame's root_window, then replacement is the new
752 root_window for that frame. */
754 if (EQ (old
, FRAME_ROOT_WINDOW (XFRAME (o
->frame
))))
755 FRAME_ROOT_WINDOW (XFRAME (o
->frame
)) = replacement
;
760 p
->height
= o
->height
;
762 p
->next
= tem
= o
->next
;
764 XWINDOW (tem
)->prev
= replacement
;
766 p
->prev
= tem
= o
->prev
;
768 XWINDOW (tem
)->next
= replacement
;
770 p
->parent
= tem
= o
->parent
;
773 if (EQ (XWINDOW (tem
)->vchild
, old
))
774 XWINDOW (tem
)->vchild
= replacement
;
775 if (EQ (XWINDOW (tem
)->hchild
, old
))
776 XWINDOW (tem
)->hchild
= replacement
;
779 /*** Here, if replacement is a vertical combination
780 and so is its new parent, we should make replacement's
781 children be children of that parent instead. ***/
784 DEFUN ("delete-window", Fdelete_window
, Sdelete_window
, 0, 1, "",
785 "Remove WINDOW from the display. Default is selected window.")
787 register Lisp_Object window
;
789 register Lisp_Object tem
, parent
, sib
;
790 register struct window
*p
;
791 register struct window
*par
;
793 /* Because this function is called by other C code on non-leaf
794 windows, the CHECK_LIVE_WINDOW macro would choke inappropriately,
795 so we can't decode_window here. */
797 window
= selected_window
;
799 CHECK_WINDOW (window
, 0);
800 p
= XWINDOW (window
);
802 /* It's okay to delete an already-deleted window. */
810 error ("Attempt to delete minibuffer or sole ordinary window");
811 par
= XWINDOW (parent
);
813 windows_or_buffers_changed
++;
814 FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (p
))) = 1;
816 /* Are we trying to delete any frame's selected window? */
818 Lisp_Object frame
, pwindow
;
820 /* See if the frame's selected window is either WINDOW
821 or any subwindow of it, by finding all that window's parents
822 and comparing each one with WINDOW. */
823 frame
= WINDOW_FRAME (XWINDOW (window
));
824 pwindow
= FRAME_SELECTED_WINDOW (XFRAME (frame
));
826 while (!NILP (pwindow
))
828 if (EQ (window
, pwindow
))
830 pwindow
= XWINDOW (pwindow
)->parent
;
833 if (EQ (window
, pwindow
))
835 Lisp_Object alternative
;
836 alternative
= Fnext_window (window
, Qlambda
, Qnil
);
838 /* If we're about to delete the selected window on the
839 selected frame, then we should use Fselect_window to select
840 the new window. On the other hand, if we're about to
841 delete the selected window on any other frame, we shouldn't do
842 anything but set the frame's selected_window slot. */
843 if (EQ (window
, selected_window
))
844 Fselect_window (alternative
);
846 FRAME_SELECTED_WINDOW (XFRAME (frame
)) = alternative
;
851 /* tem is null for dummy parent windows
852 (which have inferiors but not any contents themselves) */
856 unchain_marker (p
->pointm
);
857 unchain_marker (p
->start
);
862 XWINDOW (tem
)->prev
= p
->prev
;
866 XWINDOW (tem
)->next
= p
->next
;
868 if (EQ (window
, par
->hchild
))
869 par
->hchild
= p
->next
;
870 if (EQ (window
, par
->vchild
))
871 par
->vchild
= p
->next
;
873 /* Find one of our siblings to give our space to. */
877 /* If p gives its space to its next sibling, that sibling needs
878 to have its top/left side pulled back to where p's is.
879 set_window_{height,width} will re-position the sibling's
882 XWINDOW (sib
)->top
= p
->top
;
883 XWINDOW (sib
)->left
= p
->left
;
886 /* Stretch that sibling. */
887 if (!NILP (par
->vchild
))
888 set_window_height (sib
,
889 XFASTINT (XWINDOW (sib
)->height
) + XFASTINT (p
->height
),
891 if (!NILP (par
->hchild
))
892 set_window_width (sib
,
893 XFASTINT (XWINDOW (sib
)->width
) + XFASTINT (p
->width
),
896 /* If parent now has only one child,
897 put the child into the parent's place. */
901 if (NILP (XWINDOW (tem
)->next
))
902 replace_window (parent
, tem
);
904 /* Since we may be deleting combination windows, we must make sure that
905 not only p but all its children have been marked as deleted. */
906 if (! NILP (p
->hchild
))
907 delete_all_subwindows (XWINDOW (p
->hchild
));
908 else if (! NILP (p
->vchild
))
909 delete_all_subwindows (XWINDOW (p
->vchild
));
911 /* Mark this window as deleted. */
912 p
->buffer
= p
->hchild
= p
->vchild
= Qnil
;
918 extern Lisp_Object
next_frame (), prev_frame ();
920 /* This comment supplies the doc string for `next-window',
921 for make-docfile to see. We cannot put this in the real DEFUN
922 due to limits in the Unix cpp.
924 DEFUN ("next-window", Ffoo, Sfoo, 0, 3, 0,
925 "Return next window after WINDOW in canonical ordering of windows.\n\
926 If omitted, WINDOW defaults to the selected window.\n\
928 Optional second arg MINIBUF t means count the minibuffer window even\n\
929 if not active. MINIBUF nil or omitted means count the minibuffer iff\n\
930 it is active. MINIBUF neither t nor nil means not to count the\n\
931 minibuffer even if it is active.\n\
933 Several frames may share a single minibuffer; if the minibuffer\n\
934 counts, all windows on all frames that share that minibuffer count\n\
935 too. Therefore, `next-window' can be used to iterate through the\n\
936 set of windows even when the minibuffer is on another frame. If the\n\
937 minibuffer does not count, only windows from WINDOW's frame count.\n\
939 Optional third arg ALL-FRAMES t means include windows on all frames.\n\
940 ALL-FRAMES nil or omitted means cycle within the frames as specified\n\
941 above. ALL-FRAMES = `visible' means include windows on all visible frames.\n\
942 ALL-FRAMES = 0 means include windows on all visible and iconified frames.\n\
943 If ALL-FRAMES is a frame, restrict search to windows on that frame.\n\
944 Anything else means restrict to WINDOW's frame.\n\
946 If you use consistent values for MINIBUF and ALL-FRAMES, you can use\n\
947 `next-window' to iterate through the entire cycle of acceptable\n\
948 windows, eventually ending up back at the window you started with.\n\
949 `previous-window' traverses the same cycle, in the reverse order.")
950 (window, minibuf, all_frames) */
952 DEFUN ("next-window", Fnext_window
, Snext_window
, 0, 3, 0,
954 (window
, minibuf
, all_frames
)
955 register Lisp_Object window
, minibuf
, all_frames
;
957 register Lisp_Object tem
;
958 Lisp_Object start_window
;
961 window
= selected_window
;
963 CHECK_LIVE_WINDOW (window
, 0);
965 start_window
= window
;
967 /* minibuf == nil may or may not include minibuffers.
968 Decide if it does. */
970 minibuf
= (minibuf_level
? minibuf_window
: Qlambda
);
971 else if (! EQ (minibuf
, Qt
))
973 /* Now minibuf can be t => count all minibuffer windows,
974 lambda => count none of them,
975 or a specific minibuffer window (the active one) to count. */
977 /* all_frames == nil doesn't specify which frames to include. */
978 if (NILP (all_frames
))
979 all_frames
= (! EQ (minibuf
, Qlambda
)
980 ? (FRAME_MINIBUF_WINDOW
983 (XWINDOW (window
)))))
985 else if (EQ (all_frames
, Qvisible
))
987 else if (XFASTINT (all_frames
) == 0)
989 else if (FRAMEP (all_frames
) && ! EQ (all_frames
, Fwindow_frame (window
)))
990 /* If all_frames is a frame and window arg isn't on that frame, just
991 return the first window on the frame. */
992 return Fframe_first_window (all_frames
);
993 else if (! EQ (all_frames
, Qt
))
995 /* Now all_frames is t meaning search all frames,
996 nil meaning search just current frame,
997 visible meaning search just visible frames,
998 0 meaning search visible and iconified frames,
999 or a window, meaning search the frame that window belongs to. */
1001 /* Do this loop at least once, to get the next window, and perhaps
1002 again, if we hit the minibuffer and that is not acceptable. */
1005 /* Find a window that actually has a next one. This loop
1006 climbs up the tree. */
1007 while (tem
= XWINDOW (window
)->next
, NILP (tem
))
1008 if (tem
= XWINDOW (window
)->parent
, !NILP (tem
))
1012 /* We've reached the end of this frame.
1013 Which other frames are acceptable? */
1014 tem
= WINDOW_FRAME (XWINDOW (window
));
1015 if (! NILP (all_frames
))
1020 tem
= next_frame (tem
, all_frames
);
1021 /* In the case where the minibuffer is active,
1022 and we include its frame as well as the selected one,
1023 next_frame may get stuck in that frame.
1024 If that happens, go back to the selected frame
1025 so we can complete the cycle. */
1027 XSETFRAME (tem
, selected_frame
);
1029 tem
= FRAME_ROOT_WINDOW (XFRAME (tem
));
1036 /* If we're in a combination window, find its first child and
1037 recurse on that. Otherwise, we've found the window we want. */
1040 if (!NILP (XWINDOW (window
)->hchild
))
1041 window
= XWINDOW (window
)->hchild
;
1042 else if (!NILP (XWINDOW (window
)->vchild
))
1043 window
= XWINDOW (window
)->vchild
;
1047 /* Which windows are acceptable?
1048 Exit the loop and accept this window if
1049 this isn't a minibuffer window,
1050 or we're accepting all minibuffer windows,
1051 or this is the active minibuffer and we are accepting that one, or
1052 we've come all the way around and we're back at the original window. */
1053 while (MINI_WINDOW_P (XWINDOW (window
))
1054 && ! EQ (minibuf
, Qt
)
1055 && ! EQ (minibuf
, window
)
1056 && ! EQ (window
, start_window
));
1061 /* This comment supplies the doc string for `previous-window',
1062 for make-docfile to see. We cannot put this in the real DEFUN
1063 due to limits in the Unix cpp.
1065 DEFUN ("previous-window", Ffoo, Sfoo, 0, 3, 0,
1066 "Return the window preceding WINDOW in canonical ordering of windows.\n\
1067 If omitted, WINDOW defaults to the selected window.\n\
1069 Optional second arg MINIBUF t means count the minibuffer window even\n\
1070 if not active. MINIBUF nil or omitted means count the minibuffer iff\n\
1071 it is active. MINIBUF neither t nor nil means not to count the\n\
1072 minibuffer even if it is active.\n\
1074 Several frames may share a single minibuffer; if the minibuffer\n\
1075 counts, all windows on all frames that share that minibuffer count\n\
1076 too. Therefore, `previous-window' can be used to iterate through\n\
1077 the set of windows even when the minibuffer is on another frame. If\n\
1078 the minibuffer does not count, only windows from WINDOW's frame count\n\
1080 Optional third arg ALL-FRAMES t means include windows on all frames.\n\
1081 ALL-FRAMES nil or omitted means cycle within the frames as specified\n\
1082 above. ALL-FRAMES = `visible' means include windows on all visible frames.\n\
1083 ALL-FRAMES = 0 means include windows on all visible and iconified frames.\n\
1084 If ALL-FRAMES is a frame, restrict search to windows on that frame.\n\
1085 Anything else means restrict to WINDOW's frame.\n\
1087 If you use consistent values for MINIBUF and ALL-FRAMES, you can use\n\
1088 `previous-window' to iterate through the entire cycle of acceptable\n\
1089 windows, eventually ending up back at the window you started with.\n\
1090 `next-window' traverses the same cycle, in the reverse order.")
1091 (window, minibuf, all_frames) */
1094 DEFUN ("previous-window", Fprevious_window
, Sprevious_window
, 0, 3, 0,
1096 (window
, minibuf
, all_frames
)
1097 register Lisp_Object window
, minibuf
, all_frames
;
1099 register Lisp_Object tem
;
1100 Lisp_Object start_window
;
1103 window
= selected_window
;
1105 CHECK_LIVE_WINDOW (window
, 0);
1107 start_window
= window
;
1109 /* minibuf == nil may or may not include minibuffers.
1110 Decide if it does. */
1112 minibuf
= (minibuf_level
? minibuf_window
: Qlambda
);
1113 else if (! EQ (minibuf
, Qt
))
1115 /* Now minibuf can be t => count all minibuffer windows,
1116 lambda => count none of them,
1117 or a specific minibuffer window (the active one) to count. */
1119 /* all_frames == nil doesn't specify which frames to include.
1120 Decide which frames it includes. */
1121 if (NILP (all_frames
))
1122 all_frames
= (! EQ (minibuf
, Qlambda
)
1123 ? (FRAME_MINIBUF_WINDOW
1126 (XWINDOW (window
)))))
1128 else if (EQ (all_frames
, Qvisible
))
1130 else if (XFASTINT (all_frames
) == 0)
1132 else if (FRAMEP (all_frames
) && ! EQ (all_frames
, Fwindow_frame (window
)))
1133 /* If all_frames is a frame and window arg isn't on that frame, just
1134 return the first window on the frame. */
1135 return Fframe_first_window (all_frames
);
1136 else if (! EQ (all_frames
, Qt
))
1138 /* Now all_frames is t meaning search all frames,
1139 nil meaning search just current frame,
1140 visible meaning search just visible frames,
1141 0 meaning search visible and iconified frames,
1142 or a window, meaning search the frame that window belongs to. */
1144 /* Do this loop at least once, to get the previous window, and perhaps
1145 again, if we hit the minibuffer and that is not acceptable. */
1148 /* Find a window that actually has a previous one. This loop
1149 climbs up the tree. */
1150 while (tem
= XWINDOW (window
)->prev
, NILP (tem
))
1151 if (tem
= XWINDOW (window
)->parent
, !NILP (tem
))
1155 /* We have found the top window on the frame.
1156 Which frames are acceptable? */
1157 tem
= WINDOW_FRAME (XWINDOW (window
));
1158 if (! NILP (all_frames
))
1159 /* It's actually important that we use prev_frame here,
1160 rather than next_frame. All the windows acceptable
1161 according to the given parameters should form a ring;
1162 Fnext_window and Fprevious_window should go back and
1163 forth around the ring. If we use next_frame here,
1164 then Fnext_window and Fprevious_window take different
1165 paths through the set of acceptable windows.
1166 window_loop assumes that these `ring' requirement are
1172 tem
= prev_frame (tem
, all_frames
);
1173 /* In the case where the minibuffer is active,
1174 and we include its frame as well as the selected one,
1175 next_frame may get stuck in that frame.
1176 If that happens, go back to the selected frame
1177 so we can complete the cycle. */
1179 XSETFRAME (tem
, selected_frame
);
1181 /* If this frame has a minibuffer, find that window first,
1182 because it is conceptually the last window in that frame. */
1183 if (FRAME_HAS_MINIBUF_P (XFRAME (tem
)))
1184 tem
= FRAME_MINIBUF_WINDOW (XFRAME (tem
));
1186 tem
= FRAME_ROOT_WINDOW (XFRAME (tem
));
1192 /* If we're in a combination window, find its last child and
1193 recurse on that. Otherwise, we've found the window we want. */
1196 if (!NILP (XWINDOW (window
)->hchild
))
1197 window
= XWINDOW (window
)->hchild
;
1198 else if (!NILP (XWINDOW (window
)->vchild
))
1199 window
= XWINDOW (window
)->vchild
;
1201 while (tem
= XWINDOW (window
)->next
, !NILP (tem
))
1205 /* Which windows are acceptable?
1206 Exit the loop and accept this window if
1207 this isn't a minibuffer window,
1208 or we're accepting all minibuffer windows,
1209 or this is the active minibuffer and we are accepting that one, or
1210 we've come all the way around and we're back at the original window. */
1211 while (MINI_WINDOW_P (XWINDOW (window
))
1212 && ! EQ (minibuf
, Qt
)
1213 && ! EQ (minibuf
, window
)
1214 && ! EQ (window
, start_window
));
1219 DEFUN ("other-window", Fother_window
, Sother_window
, 1, 2, "p",
1220 "Select the ARG'th different window on this frame.\n\
1221 All windows on current frame are arranged in a cyclic order.\n\
1222 This command selects the window ARG steps away in that order.\n\
1223 A negative ARG moves in the opposite order. If the optional second\n\
1224 argument ALL_FRAMES is non-nil, cycle through all frames.")
1226 register Lisp_Object arg
, all_frames
;
1229 register Lisp_Object w
;
1231 CHECK_NUMBER (arg
, 0);
1232 w
= selected_window
;
1237 w
= Fnext_window (w
, Qnil
, all_frames
);
1242 w
= Fprevious_window (w
, Qnil
, all_frames
);
1249 /* Look at all windows, performing an operation specified by TYPE
1251 If FRAMES is Qt, look at all frames;
1252 Qnil, look at just the selected frame;
1253 Qvisible, look at visible frames;
1254 a frame, just look at windows on that frame.
1255 If MINI is non-zero, perform the operation on minibuffer windows too.
1261 GET_BUFFER_WINDOW
, /* Arg is buffer */
1262 GET_LRU_WINDOW
, /* Arg is t for full-width windows only */
1263 DELETE_OTHER_WINDOWS
, /* Arg is window not to delete */
1264 DELETE_BUFFER_WINDOWS
, /* Arg is buffer */
1266 UNSHOW_BUFFER
/* Arg is buffer */
1270 window_loop (type
, obj
, mini
, frames
)
1271 enum window_loop type
;
1272 register Lisp_Object obj
, frames
;
1275 register Lisp_Object w
;
1276 register Lisp_Object best_window
;
1277 register Lisp_Object next_window
;
1278 register Lisp_Object last_window
;
1280 Lisp_Object frame_arg
;
1283 /* If we're only looping through windows on a particular frame,
1284 frame points to that frame. If we're looping through windows
1285 on all frames, frame is 0. */
1286 if (FRAMEP (frames
))
1287 frame
= XFRAME (frames
);
1288 else if (NILP (frames
))
1289 frame
= selected_frame
;
1293 frame_arg
= Qlambda
;
1294 else if (XFASTINT (frames
) == 0)
1296 else if (EQ (frames
, Qvisible
))
1299 /* frame_arg is Qlambda to stick to one frame,
1300 Qvisible to consider all visible frames,
1303 /* Pick a window to start with. */
1307 w
= FRAME_SELECTED_WINDOW (frame
);
1309 w
= FRAME_SELECTED_WINDOW (selected_frame
);
1311 /* Figure out the last window we're going to mess with. Since
1312 Fnext_window, given the same options, is guaranteed to go in a
1313 ring, we can just use Fprevious_window to find the last one.
1315 We can't just wait until we hit the first window again, because
1316 it might be deleted. */
1318 last_window
= Fprevious_window (w
, mini
? Qt
: Qnil
, frame_arg
);
1323 FRAME_PTR w_frame
= XFRAME (WINDOW_FRAME (XWINDOW (w
)));
1325 /* Pick the next window now, since some operations will delete
1326 the current window. */
1327 next_window
= Fnext_window (w
, mini
? Qt
: Qnil
, frame_arg
);
1329 /* Note that we do not pay attention here to whether
1330 the frame is visible, since Fnext_window skips non-visible frames
1331 if that is desired, under the control of frame_arg. */
1332 if (! MINI_WINDOW_P (XWINDOW (w
))
1333 || (mini
&& minibuf_level
> 0))
1336 case GET_BUFFER_WINDOW
:
1337 if (XBUFFER (XWINDOW (w
)->buffer
) == XBUFFER (obj
)
1338 /* Don't find any minibuffer window
1339 except the one that is currently in use. */
1340 && (MINI_WINDOW_P (XWINDOW (w
))
1341 ? EQ (w
, minibuf_window
) : 1))
1345 case GET_LRU_WINDOW
:
1346 /* t as arg means consider only full-width windows */
1347 if (!NILP (obj
) && !WINDOW_FULL_WIDTH_P (XWINDOW (w
)))
1349 /* Ignore dedicated windows and minibuffers. */
1350 if (MINI_WINDOW_P (XWINDOW (w
))
1351 || !NILP (XWINDOW (w
)->dedicated
))
1353 if (NILP (best_window
)
1354 || (XFASTINT (XWINDOW (best_window
)->use_time
)
1355 > XFASTINT (XWINDOW (w
)->use_time
)))
1359 case DELETE_OTHER_WINDOWS
:
1360 if (XWINDOW (w
) != XWINDOW (obj
))
1364 case DELETE_BUFFER_WINDOWS
:
1365 if (EQ (XWINDOW (w
)->buffer
, obj
))
1367 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (w
)));
1369 /* If this window is dedicated, and in a frame of its own,
1371 if (EQ (w
, FRAME_ROOT_WINDOW (f
))
1372 && !NILP (XWINDOW (w
)->dedicated
)
1373 && other_visible_frames (f
))
1375 /* Skip the other windows on this frame.
1376 There might be one, the minibuffer! */
1377 if (! EQ (w
, last_window
))
1378 while (f
== XFRAME (WINDOW_FRAME (XWINDOW (next_window
))))
1380 /* As we go, check for the end of the loop.
1381 We mustn't start going around a second time. */
1382 if (EQ (next_window
, last_window
))
1387 next_window
= Fnext_window (next_window
,
1391 /* Now we can safely delete the frame. */
1392 Fdelete_frame (WINDOW_FRAME (XWINDOW (w
)), Qnil
);
1395 /* If we're deleting the buffer displayed in the only window
1396 on the frame, find a new buffer to display there. */
1397 if (NILP (XWINDOW (w
)->parent
))
1399 Lisp_Object new_buffer
;
1400 new_buffer
= Fother_buffer (obj
, Qnil
);
1401 if (NILP (new_buffer
))
1403 = Fget_buffer_create (build_string ("*scratch*"));
1404 Fset_window_buffer (w
, new_buffer
);
1405 if (EQ (w
, selected_window
))
1406 Fset_buffer (XWINDOW (w
)->buffer
);
1413 case GET_LARGEST_WINDOW
:
1414 /* Ignore dedicated windows and minibuffers. */
1415 if (MINI_WINDOW_P (XWINDOW (w
))
1416 || !NILP (XWINDOW (w
)->dedicated
))
1419 struct window
*best_window_ptr
= XWINDOW (best_window
);
1420 struct window
*w_ptr
= XWINDOW (w
);
1421 if (NILP (best_window
)
1422 || (XFASTINT (w_ptr
->height
) * XFASTINT (w_ptr
->width
)
1423 > (XFASTINT (best_window_ptr
->height
)
1424 * XFASTINT (best_window_ptr
->width
))))
1430 if (EQ (XWINDOW (w
)->buffer
, obj
))
1432 /* Find another buffer to show in this window. */
1433 Lisp_Object another_buffer
;
1434 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (w
)));
1435 another_buffer
= Fother_buffer (obj
, Qnil
);
1436 if (NILP (another_buffer
))
1438 = Fget_buffer_create (build_string ("*scratch*"));
1439 /* If this window is dedicated, and in a frame of its own,
1441 if (EQ (w
, FRAME_ROOT_WINDOW (f
))
1442 && !NILP (XWINDOW (w
)->dedicated
)
1443 && other_visible_frames (f
))
1445 /* Skip the other windows on this frame.
1446 There might be one, the minibuffer! */
1447 if (! EQ (w
, last_window
))
1448 while (f
== XFRAME (WINDOW_FRAME (XWINDOW (next_window
))))
1450 /* As we go, check for the end of the loop.
1451 We mustn't start going around a second time. */
1452 if (EQ (next_window
, last_window
))
1457 next_window
= Fnext_window (next_window
,
1461 /* Now we can safely delete the frame. */
1462 Fdelete_frame (WINDOW_FRAME (XWINDOW (w
)), Qnil
);
1466 /* Otherwise show a different buffer in the window. */
1467 XWINDOW (w
)->dedicated
= Qnil
;
1468 Fset_window_buffer (w
, another_buffer
);
1469 if (EQ (w
, selected_window
))
1470 Fset_buffer (XWINDOW (w
)->buffer
);
1476 if (EQ (w
, last_window
))
1485 DEFUN ("get-lru-window", Fget_lru_window
, Sget_lru_window
, 0, 1, 0,
1486 "Return the window least recently selected or used for display.\n\
1487 If optional argument FRAME is `visible', search all visible frames.\n\
1488 If FRAME is 0, search all visible and iconified frames.\n\
1489 If FRAME is t, search all frames.\n\
1490 If FRAME is nil, search only the selected frame.\n\
1491 If FRAME is a frame, search only that frame.")
1495 register Lisp_Object w
;
1496 /* First try for a window that is full-width */
1497 w
= window_loop (GET_LRU_WINDOW
, Qt
, 0, frame
);
1498 if (!NILP (w
) && !EQ (w
, selected_window
))
1500 /* If none of them, try the rest */
1501 return window_loop (GET_LRU_WINDOW
, Qnil
, 0, frame
);
1504 DEFUN ("get-largest-window", Fget_largest_window
, Sget_largest_window
, 0, 1, 0,
1505 "Return the largest window in area.\n\
1506 If optional argument FRAME is `visible', search all visible frames.\n\
1507 If FRAME is 0, search all visible and iconified frames.\n\
1508 If FRAME is t, search all frames.\n\
1509 If FRAME is nil, search only the selected frame.\n\
1510 If FRAME is a frame, search only that frame.")
1514 return window_loop (GET_LARGEST_WINDOW
, Qnil
, 0,
1518 DEFUN ("get-buffer-window", Fget_buffer_window
, Sget_buffer_window
, 1, 2, 0,
1519 "Return a window currently displaying BUFFER, or nil if none.\n\
1520 If optional argument FRAME is `visible', search all visible frames.\n\
1521 If optional argument FRAME is 0, search all visible and iconified frames.\n\
1522 If FRAME is t, search all frames.\n\
1523 If FRAME is nil, search only the selected frame.\n\
1524 If FRAME is a frame, search only that frame.")
1526 Lisp_Object buffer
, frame
;
1528 buffer
= Fget_buffer (buffer
);
1529 if (BUFFERP (buffer
))
1530 return window_loop (GET_BUFFER_WINDOW
, buffer
, 1, frame
);
1535 DEFUN ("delete-other-windows", Fdelete_other_windows
, Sdelete_other_windows
,
1537 "Make WINDOW (or the selected window) fill its frame.\n\
1538 Only the frame WINDOW is on is affected.\n\
1539 This function tries to reduce display jumps\n\
1540 by keeping the text previously visible in WINDOW\n\
1541 in the same place on the frame. Doing this depends on\n\
1542 the value of (window-start WINDOW), so if calling this function\n\
1543 in a program gives strange scrolling, make sure the window-start\n\
1544 value is reasonable when this function is called.")
1553 window
= selected_window
;
1555 CHECK_LIVE_WINDOW (window
, 0);
1557 w
= XWINDOW (window
);
1559 startpos
= marker_position (w
->start
);
1560 top
= XFASTINT (w
->top
) - FRAME_MENU_BAR_LINES (XFRAME (WINDOW_FRAME (w
)));
1562 if (MINI_WINDOW_P (w
) && top
> 0)
1563 error ("Can't expand minibuffer to full frame");
1565 window_loop (DELETE_OTHER_WINDOWS
, window
, 0, WINDOW_FRAME (w
));
1567 /* Try to minimize scrolling, by setting the window start to the point
1568 will cause the text at the old window start to be at the same place
1569 on the frame. But don't try to do this if the window start is
1570 outside the visible portion (as might happen when the display is
1571 not current, due to typeahead). */
1572 if (startpos
>= BUF_BEGV (XBUFFER (w
->buffer
))
1573 && startpos
<= BUF_ZV (XBUFFER (w
->buffer
)))
1575 struct position pos
;
1576 struct buffer
*obuf
= current_buffer
;
1578 Fset_buffer (w
->buffer
);
1579 /* This computation used to temporarily move point, but that can
1580 have unwanted side effects due to text properties. */
1581 pos
= *vmotion (startpos
, -top
, w
);
1583 Fset_marker (w
->start
, make_number (pos
.bufpos
), w
->buffer
);
1584 w
->start_at_line_beg
= ((pos
.bufpos
== BEGV
1585 || FETCH_BYTE (pos
.bufpos
- 1) == '\n') ? Qt
1587 /* We need to do this, so that the window-scroll-functions
1589 w
->optional_new_start
= Qt
;
1591 set_buffer_internal (obuf
);
1596 DEFUN ("delete-windows-on", Fdelete_windows_on
, Sdelete_windows_on
,
1597 1, 2, "bDelete windows on (buffer): ",
1598 "Delete all windows showing BUFFER.\n\
1599 Optional second argument FRAME controls which frames are affected.\n\
1600 If nil or omitted, delete all windows showing BUFFER in any frame.\n\
1601 If t, delete only windows showing BUFFER in the selected frame.\n\
1602 If `visible', delete all windows showing BUFFER in any visible frame.\n\
1603 If a frame, delete only windows showing BUFFER in that frame.")
1605 Lisp_Object buffer
, frame
;
1607 /* FRAME uses t and nil to mean the opposite of what window_loop
1609 if (! FRAMEP (frame
))
1610 frame
= NILP (frame
) ? Qt
: Qnil
;
1614 buffer
= Fget_buffer (buffer
);
1615 CHECK_BUFFER (buffer
, 0);
1616 window_loop (DELETE_BUFFER_WINDOWS
, buffer
, 0, frame
);
1621 DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows
,
1622 Sreplace_buffer_in_windows
,
1623 1, 1, "bReplace buffer in windows: ",
1624 "Replace BUFFER with some other buffer in all windows showing it.")
1630 buffer
= Fget_buffer (buffer
);
1631 CHECK_BUFFER (buffer
, 0);
1632 window_loop (UNSHOW_BUFFER
, buffer
, 0, Qt
);
1637 /* Replace BUFFER with some other buffer in all windows
1638 of all frames, even those on other keyboards. */
1641 replace_buffer_in_all_windows (buffer
)
1645 Lisp_Object tail
, frame
;
1647 /* A single call to window_loop won't do the job
1648 because it only considers frames on the current keyboard.
1649 So loop manually over frames, and handle each one. */
1650 FOR_EACH_FRAME (tail
, frame
)
1651 window_loop (UNSHOW_BUFFER
, buffer
, 0, frame
);
1653 window_loop (UNSHOW_BUFFER
, buffer
, 0, Qt
);
1657 /* Set the height of WINDOW and all its inferiors. */
1659 /* The smallest acceptable dimensions for a window. Anything smaller
1660 might crash Emacs. */
1661 #define MIN_SAFE_WINDOW_WIDTH (2)
1662 #define MIN_SAFE_WINDOW_HEIGHT (2)
1664 /* Make sure that window_min_height and window_min_width are
1665 not too small; if they are, set them to safe minima. */
1668 check_min_window_sizes ()
1670 /* Smaller values might permit a crash. */
1671 if (window_min_width
< MIN_SAFE_WINDOW_WIDTH
)
1672 window_min_width
= MIN_SAFE_WINDOW_WIDTH
;
1673 if (window_min_height
< MIN_SAFE_WINDOW_HEIGHT
)
1674 window_min_height
= MIN_SAFE_WINDOW_HEIGHT
;
1677 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
1678 minimum allowable size. */
1680 check_frame_size (frame
, rows
, cols
)
1684 /* For height, we have to see:
1685 whether the frame has a minibuffer,
1686 whether it wants a mode line, and
1687 whether it has a menu bar. */
1689 (FRAME_MINIBUF_ONLY_P (frame
) ? MIN_SAFE_WINDOW_HEIGHT
- 1
1690 : (! FRAME_HAS_MINIBUF_P (frame
)) ? MIN_SAFE_WINDOW_HEIGHT
1691 : 2 * MIN_SAFE_WINDOW_HEIGHT
- 1);
1692 if (FRAME_MENU_BAR_LINES (frame
) > 0)
1693 min_height
+= FRAME_MENU_BAR_LINES (frame
);
1695 if (*rows
< min_height
)
1697 if (*cols
< MIN_SAFE_WINDOW_WIDTH
)
1698 *cols
= MIN_SAFE_WINDOW_WIDTH
;
1701 /* Normally the window is deleted if it gets too small.
1702 nodelete nonzero means do not do this.
1703 (The caller should check later and do so if appropriate) */
1705 set_window_height (window
, height
, nodelete
)
1710 register struct window
*w
= XWINDOW (window
);
1711 register struct window
*c
;
1712 int oheight
= XFASTINT (w
->height
);
1713 int top
, pos
, lastbot
, opos
, lastobot
;
1716 check_min_window_sizes ();
1719 && ! NILP (w
->parent
)
1720 && height
< window_min_height
)
1722 Fdelete_window (window
);
1726 XSETFASTINT (w
->last_modified
, 0);
1727 XSETFASTINT (w
->last_overlay_modified
, 0);
1728 windows_or_buffers_changed
++;
1729 FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (w
))) = 1;
1731 XSETFASTINT (w
->height
, height
);
1732 if (!NILP (w
->hchild
))
1734 for (child
= w
->hchild
; !NILP (child
); child
= XWINDOW (child
)->next
)
1736 XWINDOW (child
)->top
= w
->top
;
1737 set_window_height (child
, height
, nodelete
);
1740 else if (!NILP (w
->vchild
))
1742 lastbot
= top
= XFASTINT (w
->top
);
1744 for (child
= w
->vchild
; !NILP (child
); child
= c
->next
)
1746 c
= XWINDOW (child
);
1748 opos
= lastobot
+ XFASTINT (c
->height
);
1750 XSETFASTINT (c
->top
, lastbot
);
1752 pos
= (((opos
* height
) << 1) + oheight
) / (oheight
<< 1);
1754 /* Avoid confusion: inhibit deletion of child if becomes too small */
1755 set_window_height (child
, pos
+ top
- lastbot
, 1);
1757 /* Now advance child to next window,
1758 and set lastbot if child was not just deleted. */
1759 lastbot
= pos
+ top
;
1762 /* Now delete any children that became too small. */
1764 for (child
= w
->vchild
; !NILP (child
); child
= XWINDOW (child
)->next
)
1766 set_window_height (child
, XINT (XWINDOW (child
)->height
), 0);
1771 /* Recursively set width of WINDOW and its inferiors. */
1773 set_window_width (window
, width
, nodelete
)
1778 register struct window
*w
= XWINDOW (window
);
1779 register struct window
*c
;
1780 int owidth
= XFASTINT (w
->width
);
1781 int left
, pos
, lastright
, opos
, lastoright
;
1784 if (!nodelete
&& width
< window_min_width
&& !NILP (w
->parent
))
1786 Fdelete_window (window
);
1790 XSETFASTINT (w
->last_modified
, 0);
1791 XSETFASTINT (w
->last_overlay_modified
, 0);
1792 windows_or_buffers_changed
++;
1793 FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (w
))) = 1;
1795 XSETFASTINT (w
->width
, width
);
1796 if (!NILP (w
->vchild
))
1798 for (child
= w
->vchild
; !NILP (child
); child
= XWINDOW (child
)->next
)
1800 XWINDOW (child
)->left
= w
->left
;
1801 set_window_width (child
, width
, nodelete
);
1804 else if (!NILP (w
->hchild
))
1806 lastright
= left
= XFASTINT (w
->left
);
1808 for (child
= w
->hchild
; !NILP (child
); child
= c
->next
)
1810 c
= XWINDOW (child
);
1812 opos
= lastoright
+ XFASTINT (c
->width
);
1814 XSETFASTINT (c
->left
, lastright
);
1816 pos
= (((opos
* width
) << 1) + owidth
) / (owidth
<< 1);
1818 /* Inhibit deletion for becoming too small */
1819 set_window_width (child
, pos
+ left
- lastright
, 1);
1821 /* Now advance child to next window,
1822 and set lastright if child was not just deleted. */
1823 lastright
= pos
+ left
, lastoright
= opos
;
1825 /* Delete children that became too small */
1827 for (child
= w
->hchild
; !NILP (child
); child
= XWINDOW (child
)->next
)
1829 set_window_width (child
, XINT (XWINDOW (child
)->width
), 0);
1834 int window_select_count
;
1837 Fset_window_buffer_unwind (obuf
)
1844 DEFUN ("set-window-buffer", Fset_window_buffer
, Sset_window_buffer
, 2, 2, 0,
1845 "Make WINDOW display BUFFER as its contents.\n\
1846 BUFFER can be a buffer or buffer name.")
1848 register Lisp_Object window
, buffer
;
1850 register Lisp_Object tem
;
1851 register struct window
*w
= decode_window (window
);
1852 int count
= specpdl_ptr
- specpdl
;
1854 buffer
= Fget_buffer (buffer
);
1855 CHECK_BUFFER (buffer
, 1);
1857 if (NILP (XBUFFER (buffer
)->name
))
1858 error ("Attempt to display deleted buffer");
1862 error ("Window is deleted");
1863 else if (! EQ (tem
, Qt
)) /* w->buffer is t when the window
1864 is first being set up. */
1866 if (!NILP (w
->dedicated
) && !EQ (tem
, buffer
))
1867 error ("Window is dedicated to `%s'",
1868 XSTRING (XBUFFER (tem
)->name
)->data
);
1875 if (EQ (window
, selected_window
))
1876 XBUFFER (w
->buffer
)->last_selected_window
= window
;
1878 XSETFASTINT (w
->window_end_pos
, 0);
1879 w
->window_end_valid
= Qnil
;
1880 XSETFASTINT (w
->hscroll
, 0);
1881 Fset_marker (w
->pointm
,
1882 make_number (BUF_PT (XBUFFER (buffer
))),
1884 set_marker_restricted (w
->start
,
1885 make_number (XBUFFER (buffer
)->last_window_start
),
1887 w
->start_at_line_beg
= Qnil
;
1888 w
->force_start
= Qnil
;
1889 XSETFASTINT (w
->last_modified
, 0);
1890 XSETFASTINT (w
->last_overlay_modified
, 0);
1891 windows_or_buffers_changed
++;
1893 /* We must select BUFFER for running the window-scroll-functions.
1894 If WINDOW is selected, switch permanently.
1895 Otherwise, switch but go back to the ambient buffer afterward. */
1896 if (EQ (window
, selected_window
))
1897 Fset_buffer (buffer
);
1898 /* We can't check ! NILP (Vwindow_scroll_functions) here
1899 because that might itself be a local variable. */
1900 else if (window_initialized
)
1902 record_unwind_protect (Fset_window_buffer_unwind
, Fcurrent_buffer ());
1903 Fset_buffer (buffer
);
1906 if (! NILP (Vwindow_scroll_functions
))
1907 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
1908 Fmarker_position (w
->start
));
1910 unbind_to (count
, Qnil
);
1915 DEFUN ("select-window", Fselect_window
, Sselect_window
, 1, 1, 0,
1916 "Select WINDOW. Most editing will apply to WINDOW's buffer.\n\
1917 The main editor command loop selects the buffer of the selected window\n\
1918 before each command.")
1920 register Lisp_Object window
;
1922 register struct window
*w
;
1923 register struct window
*ow
= XWINDOW (selected_window
);
1925 CHECK_LIVE_WINDOW (window
, 0);
1927 w
= XWINDOW (window
);
1929 if (NILP (w
->buffer
))
1930 error ("Trying to select deleted window or non-leaf window");
1932 XSETFASTINT (w
->use_time
, ++window_select_count
);
1933 if (EQ (window
, selected_window
))
1936 Fset_marker (ow
->pointm
, make_number (BUF_PT (XBUFFER (ow
->buffer
))),
1939 selected_window
= window
;
1940 if (XFRAME (WINDOW_FRAME (w
)) != selected_frame
)
1942 XFRAME (WINDOW_FRAME (w
))->selected_window
= window
;
1943 /* Use this rather than Fhandle_switch_frame
1944 so that FRAME_FOCUS_FRAME is moved appropriately as we
1945 move around in the state where a minibuffer in a separate
1947 Fselect_frame (WINDOW_FRAME (w
), Qnil
);
1950 selected_frame
->selected_window
= window
;
1952 record_buffer (w
->buffer
);
1953 Fset_buffer (w
->buffer
);
1955 XBUFFER (w
->buffer
)->last_selected_window
= window
;
1957 /* Go to the point recorded in the window.
1958 This is important when the buffer is in more
1959 than one window. It also matters when
1960 redisplay_window has altered point after scrolling,
1961 because it makes the change only in the window. */
1963 register int new_point
= marker_position (w
->pointm
);
1964 if (new_point
< BEGV
)
1966 else if (new_point
> ZV
)
1972 windows_or_buffers_changed
++;
1976 /* Deiconify the frame containing the window WINDOW,
1977 unless it is the selected frame;
1980 The reason for the exception for the selected frame
1981 is that it seems better not to change the selected frames visibility
1982 merely because of displaying a different buffer in it.
1983 The deiconification is useful when a buffer gets shown in
1984 another frame that you were not using lately. */
1987 display_buffer_1 (window
)
1990 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (window
)));
1991 FRAME_SAMPLE_VISIBILITY (f
);
1992 if (f
!= selected_frame
)
1994 if (FRAME_ICONIFIED_P (f
))
1995 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window
)));
1996 else if (FRAME_VISIBLE_P (f
))
1997 Fraise_frame (WINDOW_FRAME (XWINDOW (window
)));
2002 DEFUN ("special-display-p", Fspecial_display_p
, Sspecial_display_p
, 1, 1, 0,
2003 "Returns non-nil if a buffer named BUFFER-NAME would be created specially.\n\
2004 The value is actually t if the frame should be called with default frame\n\
2005 parameters, and a list of frame parameters if they were specified.\n\
2006 See `special-display-buffer-names', and `special-display-regexps'.")
2008 Lisp_Object buffer_name
;
2012 CHECK_STRING (buffer_name
, 1);
2014 tem
= Fmember (buffer_name
, Vspecial_display_buffer_names
);
2018 tem
= Fassoc (buffer_name
, Vspecial_display_buffer_names
);
2022 for (tem
= Vspecial_display_regexps
; CONSP (tem
); tem
= XCDR (tem
))
2024 Lisp_Object car
= XCAR (tem
);
2026 && fast_string_match (car
, buffer_name
) >= 0)
2028 else if (CONSP (car
)
2029 && STRINGP (XCAR (car
))
2030 && fast_string_match (XCAR (car
), buffer_name
) >= 0)
2036 DEFUN ("same-window-p", Fsame_window_p
, Ssame_window_p
, 1, 1, 0,
2037 "Returns non-nil if a new buffer named BUFFER-NAME would use the same window.\n\
2038 See `same-window-buffer-names' and `same-window-regexps'.")
2040 Lisp_Object buffer_name
;
2044 CHECK_STRING (buffer_name
, 1);
2046 tem
= Fmember (buffer_name
, Vsame_window_buffer_names
);
2050 tem
= Fassoc (buffer_name
, Vsame_window_buffer_names
);
2054 for (tem
= Vsame_window_regexps
; CONSP (tem
); tem
= XCDR (tem
))
2056 Lisp_Object car
= XCAR (tem
);
2058 && fast_string_match (car
, buffer_name
) >= 0)
2060 else if (CONSP (car
)
2061 && STRINGP (XCAR (car
))
2062 && fast_string_match (XCAR (car
), buffer_name
) >= 0)
2068 DEFUN ("display-buffer", Fdisplay_buffer
, Sdisplay_buffer
, 1, 2,
2069 "bDisplay buffer: \nP",
2070 "Make BUFFER appear in some window but don't select it.\n\
2071 BUFFER can be a buffer or a buffer name.\n\
2072 If BUFFER is shown already in some window, just use that one,\n\
2073 unless the window is the selected window and the optional second\n\
2074 argument NOT-THIS-WINDOW is non-nil (interactively, with prefix arg).\n\
2075 If `pop-up-frames' is non-nil, make a new frame if no window shows BUFFER.\n\
2076 Returns the window displaying BUFFER.\n\
2078 The variables `special-display-buffer-names', `special-display-regexps',\n\
2079 `same-window-buffer-names', and `same-window-regexps' customize how certain\n\
2080 buffer names are handled.")
2081 (buffer
, not_this_window
)
2082 register Lisp_Object buffer
, not_this_window
;
2084 register Lisp_Object window
, tem
;
2086 buffer
= Fget_buffer (buffer
);
2087 CHECK_BUFFER (buffer
, 0);
2089 if (!NILP (Vdisplay_buffer_function
))
2090 return call2 (Vdisplay_buffer_function
, buffer
, not_this_window
);
2092 if (NILP (not_this_window
)
2093 && XBUFFER (XWINDOW (selected_window
)->buffer
) == XBUFFER (buffer
))
2094 return display_buffer_1 (selected_window
);
2096 /* See if the user has specified this buffer should appear
2097 in the selected window. */
2098 if (NILP (not_this_window
))
2100 tem
= Fsame_window_p (XBUFFER (buffer
)->name
);
2103 Fswitch_to_buffer (buffer
, Qnil
);
2104 return display_buffer_1 (selected_window
);
2108 /* If pop_up_frames,
2109 look for a window showing BUFFER on any visible or iconified frame.
2110 Otherwise search only the current frame. */
2111 if (pop_up_frames
|| last_nonminibuf_frame
== 0)
2112 XSETFASTINT (tem
, 0);
2114 XSETFRAME (tem
, last_nonminibuf_frame
);
2115 window
= Fget_buffer_window (buffer
, tem
);
2117 && (NILP (not_this_window
) || !EQ (window
, selected_window
)))
2119 return display_buffer_1 (window
);
2122 /* Certain buffer names get special handling. */
2123 if (!NILP (Vspecial_display_function
))
2125 tem
= Fspecial_display_p (XBUFFER (buffer
)->name
);
2127 return call1 (Vspecial_display_function
, buffer
);
2129 return call2 (Vspecial_display_function
, buffer
, tem
);
2132 /* If there are no frames open that have more than a minibuffer,
2133 we need to create a new frame. */
2134 if (pop_up_frames
|| last_nonminibuf_frame
== 0)
2136 window
= Fframe_selected_window (call0 (Vpop_up_frame_function
));
2137 Fset_window_buffer (window
, buffer
);
2138 return display_buffer_1 (window
);
2142 || FRAME_MINIBUF_ONLY_P (selected_frame
)
2143 /* If the current frame is a special display frame,
2144 don't try to reuse its windows. */
2145 || !NILP (XWINDOW (FRAME_ROOT_WINDOW (selected_frame
))->dedicated
)
2151 if (FRAME_MINIBUF_ONLY_P (selected_frame
))
2152 XSETFRAME (frames
, last_nonminibuf_frame
);
2153 /* Don't try to create a window if would get an error */
2154 if (split_height_threshold
< window_min_height
<< 1)
2155 split_height_threshold
= window_min_height
<< 1;
2157 /* Note that both Fget_largest_window and Fget_lru_window
2158 ignore minibuffers and dedicated windows.
2159 This means they can return nil. */
2161 /* If the frame we would try to split cannot be split,
2162 try other frames. */
2163 if (FRAME_NO_SPLIT_P (NILP (frames
) ? selected_frame
2164 : last_nonminibuf_frame
))
2166 /* Try visible frames first. */
2167 window
= Fget_largest_window (Qvisible
);
2168 /* If that didn't work, try iconified frames. */
2170 window
= Fget_largest_window (make_number (0));
2172 window
= Fget_largest_window (Qt
);
2175 window
= Fget_largest_window (frames
);
2177 /* If we got a tall enough full-width window that can be split,
2180 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window
)->frame
))
2181 && window_height (window
) >= split_height_threshold
2182 && WINDOW_FULL_WIDTH_P (XWINDOW (window
)))
2183 window
= Fsplit_window (window
, Qnil
, Qnil
);
2186 Lisp_Object upper
, lower
, other
;
2188 window
= Fget_lru_window (frames
);
2189 /* If the LRU window is selected, and big enough,
2190 and can be split, split it. */
2192 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window
)->frame
))
2193 && (EQ (window
, selected_window
)
2194 || EQ (XWINDOW (window
)->parent
, Qnil
))
2195 && window_height (window
) >= window_min_height
<< 1)
2196 window
= Fsplit_window (window
, Qnil
, Qnil
);
2197 /* If Fget_lru_window returned nil, try other approaches. */
2198 /* Try visible frames first. */
2200 window
= Fget_largest_window (Qvisible
);
2201 /* If that didn't work, try iconified frames. */
2203 window
= Fget_largest_window (make_number (0));
2204 /* Try invisible frames. */
2206 window
= Fget_largest_window (Qt
);
2207 /* As a last resort, make a new frame. */
2209 window
= Fframe_selected_window (call0 (Vpop_up_frame_function
));
2210 /* If window appears above or below another,
2211 even out their heights. */
2212 other
= upper
= lower
= Qnil
;
2213 if (!NILP (XWINDOW (window
)->prev
))
2214 other
= upper
= XWINDOW (window
)->prev
, lower
= window
;
2215 if (!NILP (XWINDOW (window
)->next
))
2216 other
= lower
= XWINDOW (window
)->next
, upper
= window
;
2218 /* Check that OTHER and WINDOW are vertically arrayed. */
2219 && XWINDOW (other
)->top
!= XWINDOW (window
)->top
2220 && XWINDOW (other
)->height
> XWINDOW (window
)->height
)
2222 int total
= XWINDOW (other
)->height
+ XWINDOW (window
)->height
;
2223 Lisp_Object old_selected_window
;
2224 old_selected_window
= selected_window
;
2226 selected_window
= upper
;
2227 change_window_height (total
/ 2 - XWINDOW (upper
)->height
, 0);
2228 selected_window
= old_selected_window
;
2233 window
= Fget_lru_window (Qnil
);
2235 Fset_window_buffer (window
, buffer
);
2236 return display_buffer_1 (window
);
2240 temp_output_buffer_show (buf
)
2241 register Lisp_Object buf
;
2243 register struct buffer
*old
= current_buffer
;
2244 register Lisp_Object window
;
2245 register struct window
*w
;
2248 BUF_SAVE_MODIFF (XBUFFER (buf
)) = MODIFF
;
2252 XBUFFER (buf
)->clip_changed
= 1;
2253 set_buffer_internal (old
);
2255 if (!EQ (Vtemp_buffer_show_function
, Qnil
))
2256 call1 (Vtemp_buffer_show_function
, buf
);
2259 window
= Fdisplay_buffer (buf
, Qnil
);
2261 if (XFRAME (XWINDOW (window
)->frame
) != selected_frame
)
2262 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window
)));
2263 Vminibuf_scroll_window
= window
;
2264 w
= XWINDOW (window
);
2265 XSETFASTINT (w
->hscroll
, 0);
2266 set_marker_restricted (w
->start
, make_number (1), buf
);
2267 set_marker_restricted (w
->pointm
, make_number (1), buf
);
2269 /* Run temp-buffer-show-hook, with the chosen window selected. */
2270 if (!NILP (Vrun_hooks
))
2273 tem
= Fboundp (Qtemp_buffer_show_hook
);
2276 tem
= Fsymbol_value (Qtemp_buffer_show_hook
);
2279 int count
= specpdl_ptr
- specpdl
;
2281 /* Select the window that was chosen, for running the hook. */
2282 record_unwind_protect (Fset_window_configuration
,
2283 Fcurrent_window_configuration (Qnil
));
2285 Fselect_window (window
);
2286 call1 (Vrun_hooks
, Qtemp_buffer_show_hook
);
2287 unbind_to (count
, Qnil
);
2295 make_dummy_parent (window
)
2299 register struct window
*o
, *p
;
2300 register struct Lisp_Vector
*vec
;
2303 o
= XWINDOW (window
);
2304 vec
= allocate_vectorlike ((EMACS_INT
)VECSIZE (struct window
));
2305 for (i
= 0; i
< VECSIZE (struct window
); ++i
)
2306 vec
->contents
[i
] = ((struct Lisp_Vector
*)o
)->contents
[i
];
2307 vec
->size
= VECSIZE (struct window
);
2308 p
= (struct window
*)vec
;
2309 XSETWINDOW (new, p
);
2311 XSETFASTINT (p
->sequence_number
, ++sequence_number
);
2313 /* Put new into window structure in place of window */
2314 replace_window (window
, new);
2327 DEFUN ("split-window", Fsplit_window
, Ssplit_window
, 0, 3, "",
2328 "Split WINDOW, putting SIZE lines in the first of the pair.\n\
2329 WINDOW defaults to selected one and SIZE to half its size.\n\
2330 If optional third arg HORFLAG is non-nil, split side by side\n\
2331 and put SIZE columns in the first of the pair.")
2332 (window
, size
, horflag
)
2333 Lisp_Object window
, size
, horflag
;
2335 register Lisp_Object
new;
2336 register struct window
*o
, *p
;
2338 register int size_int
;
2341 window
= selected_window
;
2343 CHECK_LIVE_WINDOW (window
, 0);
2345 o
= XWINDOW (window
);
2346 fo
= XFRAME (WINDOW_FRAME (o
));
2350 if (!NILP (horflag
))
2351 /* Calculate the size of the left-hand window, by dividing
2352 the usable space in columns by two. */
2353 size_int
= XFASTINT (o
->width
) >> 1;
2355 size_int
= XFASTINT (o
->height
) >> 1;
2359 CHECK_NUMBER (size
, 1);
2360 size_int
= XINT (size
);
2363 if (MINI_WINDOW_P (o
))
2364 error ("Attempt to split minibuffer window");
2365 else if (FRAME_NO_SPLIT_P (fo
))
2366 error ("Attempt to split unsplittable frame");
2368 check_min_window_sizes ();
2372 if (size_int
< window_min_height
)
2373 error ("Window height %d too small (after splitting)", size_int
);
2374 if (size_int
+ window_min_height
> XFASTINT (o
->height
))
2375 error ("Window height %d too small (after splitting)",
2376 XFASTINT (o
->height
) - size_int
);
2377 if (NILP (o
->parent
)
2378 || NILP (XWINDOW (o
->parent
)->vchild
))
2380 make_dummy_parent (window
);
2382 XWINDOW (new)->vchild
= window
;
2387 if (size_int
< window_min_width
)
2388 error ("Window width %d too small (after splitting)", size_int
);
2390 if (size_int
+ window_min_width
> XFASTINT (o
->width
))
2391 error ("Window width %d too small (after splitting)",
2392 XFASTINT (o
->width
) - size_int
);
2393 if (NILP (o
->parent
)
2394 || NILP (XWINDOW (o
->parent
)->hchild
))
2396 make_dummy_parent (window
);
2398 XWINDOW (new)->hchild
= window
;
2402 /* Now we know that window's parent is a vertical combination
2403 if we are dividing vertically, or a horizontal combination
2404 if we are making side-by-side windows */
2406 windows_or_buffers_changed
++;
2407 FRAME_WINDOW_SIZES_CHANGED (fo
) = 1;
2408 new = make_window ();
2411 p
->frame
= o
->frame
;
2413 if (!NILP (p
->next
))
2414 XWINDOW (p
->next
)->prev
= new;
2417 p
->parent
= o
->parent
;
2420 Fset_window_buffer (new, o
->buffer
);
2422 /* Apportion the available frame space among the two new windows */
2424 if (!NILP (horflag
))
2426 p
->height
= o
->height
;
2428 XSETFASTINT (p
->width
, XFASTINT (o
->width
) - size_int
);
2429 XSETFASTINT (o
->width
, size_int
);
2430 XSETFASTINT (p
->left
, XFASTINT (o
->left
) + size_int
);
2435 p
->width
= o
->width
;
2436 XSETFASTINT (p
->height
, XFASTINT (o
->height
) - size_int
);
2437 XSETFASTINT (o
->height
, size_int
);
2438 XSETFASTINT (p
->top
, XFASTINT (o
->top
) + size_int
);
2444 DEFUN ("enlarge-window", Fenlarge_window
, Senlarge_window
, 1, 2, "p",
2445 "Make current window ARG lines bigger.\n\
2446 From program, optional second arg non-nil means grow sideways ARG columns.")
2448 register Lisp_Object arg
, side
;
2450 CHECK_NUMBER (arg
, 0);
2451 change_window_height (XINT (arg
), !NILP (side
));
2455 DEFUN ("shrink-window", Fshrink_window
, Sshrink_window
, 1, 2, "p",
2456 "Make current window ARG lines smaller.\n\
2457 From program, optional second arg non-nil means shrink sideways arg columns.")
2459 register Lisp_Object arg
, side
;
2461 CHECK_NUMBER (arg
, 0);
2462 change_window_height (-XINT (arg
), !NILP (side
));
2467 window_height (window
)
2470 register struct window
*p
= XWINDOW (window
);
2471 return XFASTINT (p
->height
);
2475 window_width (window
)
2478 register struct window
*p
= XWINDOW (window
);
2479 return XFASTINT (p
->width
);
2482 #define MINSIZE(w) \
2484 ? window_min_width \
2485 : (MINI_WINDOW_P (XWINDOW (w)) ? 1 : window_min_height))
2488 *(widthflag ? (int *) &(XWINDOW (w)->left) : (int *) &(XWINDOW (w)->top))
2490 #define CURSIZE(w) \
2491 *(widthflag ? (int *) &(XWINDOW (w)->width) : (int *) &(XWINDOW (w)->height))
2493 /* Unlike set_window_height, this function
2494 also changes the heights of the siblings so as to
2495 keep everything consistent. */
2497 change_window_height (delta
, widthflag
)
2501 register Lisp_Object parent
;
2503 register struct window
*p
;
2505 int (*sizefun
) () = widthflag
? window_width
: window_height
;
2506 register int (*setsizefun
) () = (widthflag
2508 : set_window_height
);
2510 Lisp_Object next
, prev
;
2512 check_min_window_sizes ();
2514 window
= selected_window
;
2517 p
= XWINDOW (window
);
2522 error ("No other window to side of this one");
2525 if (widthflag
? !NILP (XWINDOW (parent
)->hchild
)
2526 : !NILP (XWINDOW (parent
)->vchild
))
2531 sizep
= &CURSIZE (window
);
2534 register int maxdelta
;
2536 maxdelta
= (!NILP (parent
) ? (*sizefun
) (parent
) - *sizep
2537 : !NILP (p
->next
) ? (*sizefun
) (p
->next
) - MINSIZE (p
->next
)
2538 : !NILP (p
->prev
) ? (*sizefun
) (p
->prev
) - MINSIZE (p
->prev
)
2539 /* This is a frame with only one window, a minibuffer-only
2540 or a minibufferless frame. */
2543 if (delta
> maxdelta
)
2544 /* This case traps trying to make the minibuffer
2545 the full frame, or make the only window aside from the
2546 minibuffer the full frame. */
2550 if (*sizep
+ delta
< MINSIZE (window
))
2552 Fdelete_window (window
);
2559 /* Find the total we can get from other siblings. */
2561 for (next
= p
->next
; ! NILP (next
); next
= XWINDOW (next
)->next
)
2562 maximum
+= (*sizefun
) (next
) - MINSIZE (next
);
2563 for (prev
= p
->prev
; ! NILP (prev
); prev
= XWINDOW (prev
)->prev
)
2564 maximum
+= (*sizefun
) (prev
) - MINSIZE (prev
);
2566 /* If we can get it all from them, do so. */
2567 if (delta
< maximum
)
2569 Lisp_Object first_unaffected
;
2570 Lisp_Object first_affected
;
2574 first_affected
= window
;
2575 /* Look at one sibling at a time,
2576 moving away from this window in both directions alternately,
2577 and take as much as we can get without deleting that sibling. */
2584 int this_one
= (*sizefun
) (next
) - MINSIZE (next
);
2585 if (this_one
> delta
)
2588 (*setsizefun
) (next
, (*sizefun
) (next
) - this_one
, 0);
2589 (*setsizefun
) (window
, *sizep
+ this_one
, 0);
2592 next
= XWINDOW (next
)->next
;
2598 int this_one
= (*sizefun
) (prev
) - MINSIZE (prev
);
2599 if (this_one
> delta
)
2602 first_affected
= prev
;
2604 (*setsizefun
) (prev
, (*sizefun
) (prev
) - this_one
, 0);
2605 (*setsizefun
) (window
, *sizep
+ this_one
, 0);
2608 prev
= XWINDOW (prev
)->prev
;
2612 /* Now recalculate the edge positions of all the windows affected,
2613 based on the new sizes. */
2614 first_unaffected
= next
;
2615 prev
= first_affected
;
2616 for (next
= XWINDOW (prev
)->next
; ! EQ (next
, first_unaffected
);
2617 prev
= next
, next
= XWINDOW (next
)->next
)
2619 CURBEG (next
) = CURBEG (prev
) + (*sizefun
) (prev
);
2620 /* This does not change size of NEXT,
2621 but it propagates the new top edge to its children */
2622 (*setsizefun
) (next
, (*sizefun
) (next
), 0);
2627 register int delta1
;
2628 register int opht
= (*sizefun
) (parent
);
2630 /* If trying to grow this window to or beyond size of the parent,
2631 make delta1 so big that, on shrinking back down,
2632 all the siblings end up with less than one line and are deleted. */
2633 if (opht
<= *sizep
+ delta
)
2634 delta1
= opht
* opht
* 2;
2635 /* Otherwise, make delta1 just right so that if we add delta1
2636 lines to this window and to the parent, and then shrink
2637 the parent back to its original size, the new proportional
2638 size of this window will increase by delta. */
2640 delta1
= (delta
* opht
* 100) / ((opht
- *sizep
- delta
) * 100);
2642 /* Add delta1 lines or columns to this window, and to the parent,
2643 keeping things consistent while not affecting siblings. */
2644 CURSIZE (parent
) = opht
+ delta1
;
2645 (*setsizefun
) (window
, *sizep
+ delta1
, 0);
2647 /* Squeeze out delta1 lines or columns from our parent,
2648 shriking this window and siblings proportionately.
2649 This brings parent back to correct size.
2650 Delta1 was calculated so this makes this window the desired size,
2651 taking it all out of the siblings. */
2652 (*setsizefun
) (parent
, opht
, 0);
2655 XSETFASTINT (p
->last_modified
, 0);
2656 XSETFASTINT (p
->last_overlay_modified
, 0);
2663 /* Return number of lines of text (not counting mode line) in W. */
2666 window_internal_height (w
)
2669 int ht
= XFASTINT (w
->height
);
2671 if (MINI_WINDOW_P (w
))
2674 if (!NILP (w
->parent
) || !NILP (w
->vchild
) || !NILP (w
->hchild
)
2675 || !NILP (w
->next
) || !NILP (w
->prev
)
2676 || FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME (w
))))
2683 /* Return the number of columns in W.
2684 Don't count columns occupied by scroll bars or the vertical bar
2685 separating W from the sibling to its right. */
2687 window_internal_width (w
)
2690 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2691 int width
= XINT (w
->width
);
2693 /* Scroll bars occupy a few columns. */
2694 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
2695 return width
- FRAME_SCROLL_BAR_COLS (f
);
2697 /* The column of `|' characters separating side-by-side windows
2698 occupies one column only. */
2699 if (!WINDOW_RIGHTMOST_P (w
) && !WINDOW_FULL_WIDTH_P (w
))
2706 /* Scroll contents of window WINDOW up N lines.
2707 If WHOLE is nonzero, it means scroll N screenfuls instead. */
2710 window_scroll (window
, n
, whole
, noerror
)
2716 register struct window
*w
= XWINDOW (window
);
2717 register int opoint
= PT
;
2719 register int ht
= window_internal_height (w
);
2720 register Lisp_Object tem
;
2722 Lisp_Object bolp
, nmoved
;
2724 struct position posit
;
2727 startpos
= marker_position (w
->start
);
2729 posit
= *compute_motion (startpos
, 0, 0, 0,
2731 window_internal_width (w
), XINT (w
->hscroll
),
2733 original_vpos
= posit
.vpos
;
2735 XSETFASTINT (tem
, PT
);
2736 tem
= Fpos_visible_in_window_p (tem
, window
);
2740 Fvertical_motion (make_number (- (ht
/ 2)), window
);
2745 lose
= n
< 0 && PT
== BEGV
;
2746 Fvertical_motion (make_number (n
), window
);
2756 Fsignal (Qbeginning_of_buffer
, Qnil
);
2761 int this_scroll_margin
= scroll_margin
;
2763 /* Don't use a scroll margin that is negative or too large. */
2764 if (this_scroll_margin
< 0)
2765 this_scroll_margin
= 0;
2767 if (XINT (w
->height
) < 4 * scroll_margin
)
2768 this_scroll_margin
= XINT (w
->height
) / 4;
2770 set_marker_restricted (w
->start
, make_number (pos
), w
->buffer
);
2771 w
->start_at_line_beg
= bolp
;
2772 w
->update_mode_line
= Qt
;
2773 XSETFASTINT (w
->last_modified
, 0);
2774 XSETFASTINT (w
->last_overlay_modified
, 0);
2775 /* Set force_start so that redisplay_window will run
2776 the window-scroll-functions. */
2777 w
->force_start
= Qt
;
2779 if (whole
&& scroll_preserve_screen_position
)
2782 Fvertical_motion (make_number (original_vpos
), window
);
2784 /* If we scrolled forward, put point enough lines down
2785 that it is outside the scroll margin. */
2790 if (this_scroll_margin
> 0)
2793 Fvertical_motion (make_number (this_scroll_margin
), window
);
2799 if (top_margin
<= opoint
)
2801 else if (scroll_preserve_screen_position
)
2804 Fvertical_motion (make_number (original_vpos
), window
);
2813 /* If we scrolled backward, put point near the end of the window
2814 but not within the scroll margin. */
2816 tem
= Fvertical_motion (make_number (ht
- this_scroll_margin
), window
);
2817 if (XFASTINT (tem
) == ht
- this_scroll_margin
)
2820 bottom_margin
= PT
+ 1;
2822 if (bottom_margin
> opoint
)
2826 if (scroll_preserve_screen_position
)
2829 Fvertical_motion (make_number (original_vpos
), window
);
2832 Fvertical_motion (make_number (-1), window
);
2841 Fsignal (Qend_of_buffer
, Qnil
);
2845 /* This is the guts of Fscroll_up and Fscroll_down. */
2848 scroll_command (n
, direction
)
2849 register Lisp_Object n
;
2852 register int defalt
;
2853 int count
= specpdl_ptr
- specpdl
;
2855 /* If selected window's buffer isn't current, make it current for the moment.
2856 But don't screw up if window_scroll gets an error. */
2857 if (XBUFFER (XWINDOW (selected_window
)->buffer
) != current_buffer
)
2859 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
2860 Fset_buffer (XWINDOW (selected_window
)->buffer
);
2863 defalt
= (window_internal_height (XWINDOW (selected_window
))
2864 - next_screen_context_lines
);
2865 defalt
= direction
* (defalt
< 1 ? 1 : defalt
);
2868 window_scroll (selected_window
, defalt
, 1, 0);
2869 else if (EQ (n
, Qminus
))
2870 window_scroll (selected_window
, - defalt
, 1, 0);
2873 n
= Fprefix_numeric_value (n
);
2874 window_scroll (selected_window
, XINT (n
) * direction
, 0, 0);
2877 unbind_to (count
, Qnil
);
2880 DEFUN ("scroll-up", Fscroll_up
, Sscroll_up
, 0, 1, "P",
2881 "Scroll text of current window upward ARG lines; or near full screen if no ARG.\n\
2882 A near full screen is `next-screen-context-lines' less than a full screen.\n\
2883 Negative ARG means scroll downward.\n\
2884 When calling from a program, supply a number as argument or nil.")
2888 scroll_command (arg
, 1);
2892 DEFUN ("scroll-down", Fscroll_down
, Sscroll_down
, 0, 1, "P",
2893 "Scroll text of current window downward ARG lines; or near full screen if no ARG.\n\
2894 A near full screen is `next-screen-context-lines' less than a full screen.\n\
2895 Negative ARG means scroll upward.\n\
2896 When calling from a program, supply a number as argument or nil.")
2900 scroll_command (arg
, -1);
2904 DEFUN ("other-window-for-scrolling", Fother_window_for_scrolling
, Sother_window_for_scrolling
, 0, 0, 0,
2905 "Return the other window for \"other window scroll\" commands.\n\
2906 If in the minibuffer, `minibuffer-scroll-window' if non-nil\n\
2907 specifies the window.\n\
2908 If `other-window-scroll-buffer' is non-nil, a window\n\
2909 showing that buffer is used.")
2914 if (MINI_WINDOW_P (XWINDOW (selected_window
))
2915 && !NILP (Vminibuf_scroll_window
))
2916 window
= Vminibuf_scroll_window
;
2917 /* If buffer is specified, scroll that buffer. */
2918 else if (!NILP (Vother_window_scroll_buffer
))
2920 window
= Fget_buffer_window (Vother_window_scroll_buffer
, Qnil
);
2922 window
= Fdisplay_buffer (Vother_window_scroll_buffer
, Qt
);
2926 /* Nothing specified; look for a neighboring window on the same
2928 window
= Fnext_window (selected_window
, Qnil
, Qnil
);
2930 if (EQ (window
, selected_window
))
2931 /* That didn't get us anywhere; look for a window on another
2934 window
= Fnext_window (window
, Qnil
, Qt
);
2935 while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window
))))
2936 && ! EQ (window
, selected_window
));
2939 CHECK_LIVE_WINDOW (window
, 0);
2941 if (EQ (window
, selected_window
))
2942 error ("There is no other window");
2947 DEFUN ("scroll-other-window", Fscroll_other_window
, Sscroll_other_window
, 0, 1, "P",
2948 "Scroll next window upward ARG lines; or near full screen if no ARG.\n\
2949 The next window is the one below the current one; or the one at the top\n\
2950 if the current one is at the bottom. Negative ARG means scroll downward.\n\
2951 When calling from a program, supply a number as argument or nil.\n\
2953 If in the minibuffer, `minibuffer-scroll-window' if non-nil\n\
2954 specifies the window to scroll.\n\
2955 If `other-window-scroll-buffer' is non-nil, scroll the window\n\
2956 showing that buffer, popping the buffer up if necessary.")
2958 register Lisp_Object arg
;
2960 register Lisp_Object window
;
2961 register int defalt
;
2962 register struct window
*w
;
2963 register int count
= specpdl_ptr
- specpdl
;
2965 window
= Fother_window_for_scrolling ();
2967 w
= XWINDOW (window
);
2968 defalt
= window_internal_height (w
) - next_screen_context_lines
;
2969 if (defalt
< 1) defalt
= 1;
2971 /* Don't screw up if window_scroll gets an error. */
2972 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
2974 Fset_buffer (w
->buffer
);
2975 SET_PT (marker_position (w
->pointm
));
2978 window_scroll (window
, defalt
, 1, 1);
2979 else if (EQ (arg
, Qminus
))
2980 window_scroll (window
, -defalt
, 1, 1);
2985 CHECK_NUMBER (arg
, 0);
2986 window_scroll (window
, XINT (arg
), 0, 1);
2989 Fset_marker (w
->pointm
, make_number (PT
), Qnil
);
2990 unbind_to (count
, Qnil
);
2995 DEFUN ("scroll-left", Fscroll_left
, Sscroll_left
, 0, 1, "P",
2996 "Scroll selected window display ARG columns left.\n\
2997 Default for ARG is window width minus 2.")
2999 register Lisp_Object arg
;
3003 XSETFASTINT (arg
, window_internal_width (XWINDOW (selected_window
)) - 2);
3005 arg
= Fprefix_numeric_value (arg
);
3008 Fset_window_hscroll (selected_window
,
3009 make_number (XINT (XWINDOW (selected_window
)->hscroll
)
3013 DEFUN ("scroll-right", Fscroll_right
, Sscroll_right
, 0, 1, "P",
3014 "Scroll selected window display ARG columns right.\n\
3015 Default for ARG is window width minus 2.")
3017 register Lisp_Object arg
;
3020 XSETFASTINT (arg
, window_internal_width (XWINDOW (selected_window
)) - 2);
3022 arg
= Fprefix_numeric_value (arg
);
3025 Fset_window_hscroll (selected_window
,
3026 make_number (XINT (XWINDOW (selected_window
)->hscroll
)
3030 DEFUN ("recenter", Frecenter
, Srecenter
, 0, 1, "P",
3031 "Center point in window and redisplay frame. With ARG, put point on line ARG.\n\
3032 The desired position of point is always relative to the current window.\n\
3033 Just C-u as prefix means put point in the center of the window.\n\
3034 If ARG is omitted or nil, erases the entire frame and then\n\
3035 redraws with point in the center of the current window.")
3037 register Lisp_Object arg
;
3039 register struct window
*w
= XWINDOW (selected_window
);
3040 register int ht
= window_internal_height (w
);
3041 struct position pos
;
3045 extern int frame_garbaged
;
3047 SET_FRAME_GARBAGED (XFRAME (WINDOW_FRAME (w
)));
3048 XSETFASTINT (arg
, ht
/ 2);
3050 else if (CONSP (arg
)) /* Just C-u. */
3052 XSETFASTINT (arg
, ht
/ 2);
3056 arg
= Fprefix_numeric_value (arg
);
3057 CHECK_NUMBER (arg
, 0);
3061 XSETINT (arg
, XINT (arg
) + ht
);
3063 pos
= *vmotion (PT
, - XINT (arg
), w
);
3065 Fset_marker (w
->start
, make_number (pos
.bufpos
), w
->buffer
);
3066 w
->start_at_line_beg
= ((pos
.bufpos
== BEGV
3067 || FETCH_BYTE (pos
.bufpos
- 1) == '\n')
3069 w
->force_start
= Qt
;
3074 DEFUN ("move-to-window-line", Fmove_to_window_line
, Smove_to_window_line
,
3076 "Position point relative to window.\n\
3077 With no argument, position point at center of window.\n\
3078 An argument specifies frame line; zero means top of window,\n\
3079 negative means relative to bottom of window.")
3081 register Lisp_Object arg
;
3083 register struct window
*w
= XWINDOW (selected_window
);
3084 register int height
= window_internal_height (w
);
3089 XSETFASTINT (arg
, height
/ 2);
3092 arg
= Fprefix_numeric_value (arg
);
3094 XSETINT (arg
, XINT (arg
) + height
);
3097 start
= marker_position (w
->start
);
3098 XSETWINDOW (window
, w
);
3099 if (start
< BEGV
|| start
> ZV
)
3101 Fvertical_motion (make_number (- (height
/ 2)), window
);
3102 Fset_marker (w
->start
, make_number (PT
), w
->buffer
);
3103 w
->start_at_line_beg
= Fbolp ();
3104 w
->force_start
= Qt
;
3109 return Fvertical_motion (arg
, window
);
3112 struct save_window_data
3114 EMACS_INT size_from_Lisp_Vector_struct
;
3115 struct Lisp_Vector
*next_from_Lisp_Vector_struct
;
3116 Lisp_Object frame_width
, frame_height
, frame_menu_bar_lines
;
3117 Lisp_Object selected_frame
;
3118 Lisp_Object current_window
;
3119 Lisp_Object current_buffer
;
3120 Lisp_Object minibuf_scroll_window
;
3121 Lisp_Object root_window
;
3122 Lisp_Object focus_frame
;
3123 /* Record the values of window-min-width and window-min-height
3124 so that window sizes remain consistent with them. */
3125 Lisp_Object min_width
, min_height
;
3126 /* A vector, interpreted as a struct saved_window */
3127 Lisp_Object saved_windows
;
3130 /* This is saved as a Lisp_Vector */
3133 /* these first two must agree with struct Lisp_Vector in lisp.h */
3134 EMACS_INT size_from_Lisp_Vector_struct
;
3135 struct Lisp_Vector
*next_from_Lisp_Vector_struct
;
3138 Lisp_Object buffer
, start
, pointm
, mark
;
3139 Lisp_Object left
, top
, width
, height
, hscroll
;
3140 Lisp_Object parent
, prev
;
3141 Lisp_Object start_at_line_beg
;
3142 Lisp_Object display_table
;
3144 #define SAVED_WINDOW_VECTOR_SIZE 14 /* Arg to Fmake_vector */
3146 #define SAVED_WINDOW_N(swv,n) \
3147 ((struct saved_window *) (XVECTOR ((swv)->contents[(n)])))
3149 DEFUN ("window-configuration-p", Fwindow_configuration_p
, Swindow_configuration_p
, 1, 1, 0,
3150 "T if OBJECT is a window-configuration object.")
3154 if (WINDOW_CONFIGURATIONP (object
))
3160 DEFUN ("set-window-configuration", Fset_window_configuration
,
3161 Sset_window_configuration
, 1, 1, 0,
3162 "Set the configuration of windows and buffers as specified by CONFIGURATION.\n\
3163 CONFIGURATION must be a value previously returned\n\
3164 by `current-window-configuration' (which see).")
3166 Lisp_Object configuration
;
3168 register struct save_window_data
*data
;
3169 struct Lisp_Vector
*saved_windows
;
3170 Lisp_Object new_current_buffer
;
3174 while (!WINDOW_CONFIGURATIONP (configuration
))
3176 configuration
= wrong_type_argument (intern ("window-configuration-p"),
3180 data
= (struct save_window_data
*) XVECTOR (configuration
);
3181 saved_windows
= XVECTOR (data
->saved_windows
);
3183 new_current_buffer
= data
->current_buffer
;
3184 if (NILP (XBUFFER (new_current_buffer
)->name
))
3185 new_current_buffer
= Qnil
;
3187 frame
= XWINDOW (SAVED_WINDOW_N (saved_windows
, 0)->window
)->frame
;
3190 /* If f is a dead frame, don't bother rebuilding its window tree.
3191 However, there is other stuff we should still try to do below. */
3192 if (FRAME_LIVE_P (f
))
3194 register struct window
*w
;
3195 register struct saved_window
*p
;
3198 /* If the frame has been resized since this window configuration was
3199 made, we change the frame to the size specified in the
3200 configuration, restore the configuration, and then resize it
3201 back. We keep track of the prevailing height in these variables. */
3202 int previous_frame_height
= FRAME_HEIGHT (f
);
3203 int previous_frame_width
= FRAME_WIDTH (f
);
3204 int previous_frame_menu_bar_lines
= FRAME_MENU_BAR_LINES (f
);
3206 if (XFASTINT (data
->frame_height
) != previous_frame_height
3207 || XFASTINT (data
->frame_width
) != previous_frame_width
)
3208 change_frame_size (f
, data
->frame_height
, data
->frame_width
, 0, 0);
3209 #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
3210 if (XFASTINT (data
->frame_menu_bar_lines
)
3211 != previous_frame_menu_bar_lines
)
3212 x_set_menu_bar_lines (f
, data
->frame_menu_bar_lines
, 0);
3215 windows_or_buffers_changed
++;
3216 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
3218 /* Temporarily avoid any problems with windows that are smaller
3219 than they are supposed to be. */
3220 window_min_height
= 1;
3221 window_min_width
= 1;
3224 Mark all windows now on frame as "deleted".
3225 Restoring the new configuration "undeletes" any that are in it.
3227 Save their current buffers in their height fields, since we may
3228 need it later, if a buffer saved in the configuration is now
3230 delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f
)));
3232 for (k
= 0; k
< saved_windows
->size
; k
++)
3234 p
= SAVED_WINDOW_N (saved_windows
, k
);
3235 w
= XWINDOW (p
->window
);
3238 if (!NILP (p
->parent
))
3239 w
->parent
= SAVED_WINDOW_N (saved_windows
,
3240 XFASTINT (p
->parent
))->window
;
3244 if (!NILP (p
->prev
))
3246 w
->prev
= SAVED_WINDOW_N (saved_windows
,
3247 XFASTINT (p
->prev
))->window
;
3248 XWINDOW (w
->prev
)->next
= p
->window
;
3253 if (!NILP (w
->parent
))
3255 if (EQ (p
->width
, XWINDOW (w
->parent
)->width
))
3257 XWINDOW (w
->parent
)->vchild
= p
->window
;
3258 XWINDOW (w
->parent
)->hchild
= Qnil
;
3262 XWINDOW (w
->parent
)->hchild
= p
->window
;
3263 XWINDOW (w
->parent
)->vchild
= Qnil
;
3268 /* If we squirreled away the buffer in the window's height,
3270 if (BUFFERP (w
->height
))
3271 w
->buffer
= w
->height
;
3274 w
->width
= p
->width
;
3275 w
->height
= p
->height
;
3276 w
->hscroll
= p
->hscroll
;
3277 w
->display_table
= p
->display_table
;
3278 XSETFASTINT (w
->last_modified
, 0);
3279 XSETFASTINT (w
->last_overlay_modified
, 0);
3281 /* Reinstall the saved buffer and pointers into it. */
3282 if (NILP (p
->buffer
))
3283 w
->buffer
= p
->buffer
;
3286 if (!NILP (XBUFFER (p
->buffer
)->name
))
3287 /* If saved buffer is alive, install it. */
3289 w
->buffer
= p
->buffer
;
3290 w
->start_at_line_beg
= p
->start_at_line_beg
;
3291 set_marker_restricted (w
->start
,
3292 Fmarker_position (p
->start
),
3294 set_marker_restricted (w
->pointm
,
3295 Fmarker_position (p
->pointm
),
3297 Fset_marker (XBUFFER (w
->buffer
)->mark
,
3298 Fmarker_position (p
->mark
), w
->buffer
);
3300 /* As documented in Fcurrent_window_configuration, don't
3301 save the location of point in the buffer which was current
3302 when the window configuration was recorded. */
3303 if (!EQ (p
->buffer
, new_current_buffer
)
3304 && XBUFFER (p
->buffer
) == current_buffer
)
3305 Fgoto_char (w
->pointm
);
3307 else if (NILP (w
->buffer
) || NILP (XBUFFER (w
->buffer
)->name
))
3308 /* Else unless window has a live buffer, get one. */
3310 w
->buffer
= Fcdr (Fcar (Vbuffer_alist
));
3311 /* This will set the markers to beginning of visible
3313 set_marker_restricted (w
->start
, make_number (0), w
->buffer
);
3314 set_marker_restricted (w
->pointm
, make_number (0),w
->buffer
);
3315 w
->start_at_line_beg
= Qt
;
3318 /* Keeping window's old buffer; make sure the markers
3321 /* Set window markers at start of visible range. */
3322 if (XMARKER (w
->start
)->buffer
== 0)
3323 set_marker_restricted (w
->start
, make_number (0),
3325 if (XMARKER (w
->pointm
)->buffer
== 0)
3326 set_marker_restricted (w
->pointm
,
3328 (BUF_PT (XBUFFER (w
->buffer
)))),
3330 w
->start_at_line_beg
= Qt
;
3335 FRAME_ROOT_WINDOW (f
) = data
->root_window
;
3336 Fselect_window (data
->current_window
);
3338 if (NILP (data
->focus_frame
)
3339 || (FRAMEP (data
->focus_frame
)
3340 && FRAME_LIVE_P (XFRAME (data
->focus_frame
))))
3341 Fredirect_frame_focus (frame
, data
->focus_frame
);
3343 #if 0 /* I don't understand why this is needed, and it causes problems
3344 when the frame's old selected window has been deleted. */
3345 if (f
!= selected_frame
&& FRAME_WINDOW_P (f
))
3346 do_switch_frame (WINDOW_FRAME (XWINDOW (data
->root_window
)),
3350 /* Set the screen height to the value it had before this function. */
3351 if (previous_frame_height
!= FRAME_HEIGHT (f
)
3352 || previous_frame_width
!= FRAME_WIDTH (f
))
3353 change_frame_size (f
, previous_frame_height
, previous_frame_width
,
3355 #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
3356 if (previous_frame_menu_bar_lines
!= FRAME_MENU_BAR_LINES (f
))
3357 x_set_menu_bar_lines (f
, previous_frame_menu_bar_lines
, 0);
3361 /* Restore the minimum heights recorded in the configuration. */
3362 window_min_height
= XINT (data
->min_height
);
3363 window_min_width
= XINT (data
->min_width
);
3365 /* Fselect_window will have made f the selected frame, so we
3366 reselect the proper frame here. Fhandle_switch_frame will change the
3367 selected window too, but that doesn't make the call to
3368 Fselect_window above totally superfluous; it still sets f's
3370 if (FRAME_LIVE_P (XFRAME (data
->selected_frame
)))
3371 do_switch_frame (data
->selected_frame
, Qnil
, 0);
3373 if (!NILP (new_current_buffer
))
3374 Fset_buffer (new_current_buffer
);
3376 Vminibuf_scroll_window
= data
->minibuf_scroll_window
;
3380 /* Mark all windows now on frame as deleted
3381 by setting their buffers to nil. */
3384 delete_all_subwindows (w
)
3385 register struct window
*w
;
3387 if (!NILP (w
->next
))
3388 delete_all_subwindows (XWINDOW (w
->next
));
3389 if (!NILP (w
->vchild
))
3390 delete_all_subwindows (XWINDOW (w
->vchild
));
3391 if (!NILP (w
->hchild
))
3392 delete_all_subwindows (XWINDOW (w
->hchild
));
3394 w
->height
= w
->buffer
; /* See Fset_window_configuration for excuse. */
3396 if (!NILP (w
->buffer
))
3399 /* We set all three of these fields to nil, to make sure that we can
3400 distinguish this dead window from any live window. Live leaf
3401 windows will have buffer set, and combination windows will have
3402 vchild or hchild set. */
3409 count_windows (window
)
3410 register struct window
*window
;
3412 register int count
= 1;
3413 if (!NILP (window
->next
))
3414 count
+= count_windows (XWINDOW (window
->next
));
3415 if (!NILP (window
->vchild
))
3416 count
+= count_windows (XWINDOW (window
->vchild
));
3417 if (!NILP (window
->hchild
))
3418 count
+= count_windows (XWINDOW (window
->hchild
));
3423 save_window_save (window
, vector
, i
)
3425 struct Lisp_Vector
*vector
;
3428 register struct saved_window
*p
;
3429 register struct window
*w
;
3430 register Lisp_Object tem
;
3432 for (;!NILP (window
); window
= w
->next
)
3434 p
= SAVED_WINDOW_N (vector
, i
);
3435 w
= XWINDOW (window
);
3437 XSETFASTINT (w
->temslot
, i
++);
3439 p
->buffer
= w
->buffer
;
3442 p
->width
= w
->width
;
3443 p
->height
= w
->height
;
3444 p
->hscroll
= w
->hscroll
;
3445 p
->display_table
= w
->display_table
;
3446 if (!NILP (w
->buffer
))
3448 /* Save w's value of point in the window configuration.
3449 If w is the selected window, then get the value of point
3450 from the buffer; pointm is garbage in the selected window. */
3451 if (EQ (window
, selected_window
))
3453 p
->pointm
= Fmake_marker ();
3454 Fset_marker (p
->pointm
, BUF_PT (XBUFFER (w
->buffer
)),
3458 p
->pointm
= Fcopy_marker (w
->pointm
, Qnil
);
3460 p
->start
= Fcopy_marker (w
->start
, Qnil
);
3461 p
->start_at_line_beg
= w
->start_at_line_beg
;
3463 tem
= XBUFFER (w
->buffer
)->mark
;
3464 p
->mark
= Fcopy_marker (tem
, Qnil
);
3471 p
->start_at_line_beg
= Qnil
;
3474 if (NILP (w
->parent
))
3477 p
->parent
= XWINDOW (w
->parent
)->temslot
;
3482 p
->prev
= XWINDOW (w
->prev
)->temslot
;
3484 if (!NILP (w
->vchild
))
3485 i
= save_window_save (w
->vchild
, vector
, i
);
3486 if (!NILP (w
->hchild
))
3487 i
= save_window_save (w
->hchild
, vector
, i
);
3493 DEFUN ("current-window-configuration", Fcurrent_window_configuration
,
3494 Scurrent_window_configuration
, 0, 1, 0,
3495 "Return an object representing the current window configuration of FRAME.\n\
3496 If FRAME is nil or omitted, use the selected frame.\n\
3497 This describes the number of windows, their sizes and current buffers,\n\
3498 and for each displayed buffer, where display starts, and the positions of\n\
3499 point and mark. An exception is made for point in the current buffer:\n\
3500 its value is -not- saved.\n\
3501 This also records the currently selected frame, and FRAME's focus\n\
3502 redirection (see `redirect-frame-focus').")
3506 register Lisp_Object tem
;
3507 register int n_windows
;
3508 register struct save_window_data
*data
;
3509 register struct Lisp_Vector
*vec
;
3517 CHECK_LIVE_FRAME (frame
, 0);
3521 n_windows
= count_windows (XWINDOW (FRAME_ROOT_WINDOW (f
)));
3522 vec
= allocate_vectorlike (VECSIZE (struct save_window_data
));
3523 for (i
= 0; i
< VECSIZE (struct save_window_data
); i
++)
3524 vec
->contents
[i
] = Qnil
;
3525 vec
->size
= VECSIZE (struct save_window_data
);
3526 data
= (struct save_window_data
*)vec
;
3528 XSETFASTINT (data
->frame_width
, FRAME_WIDTH (f
));
3529 XSETFASTINT (data
->frame_height
, FRAME_HEIGHT (f
));
3530 XSETFASTINT (data
->frame_menu_bar_lines
, FRAME_MENU_BAR_LINES (f
));
3531 XSETFRAME (data
->selected_frame
, selected_frame
);
3532 data
->current_window
= FRAME_SELECTED_WINDOW (f
);
3533 XSETBUFFER (data
->current_buffer
, current_buffer
);
3534 data
->minibuf_scroll_window
= Vminibuf_scroll_window
;
3535 data
->root_window
= FRAME_ROOT_WINDOW (f
);
3536 data
->focus_frame
= FRAME_FOCUS_FRAME (f
);
3537 XSETINT (data
->min_height
, window_min_height
);
3538 XSETINT (data
->min_width
, window_min_width
);
3539 tem
= Fmake_vector (make_number (n_windows
), Qnil
);
3540 data
->saved_windows
= tem
;
3541 for (i
= 0; i
< n_windows
; i
++)
3542 XVECTOR (tem
)->contents
[i
]
3543 = Fmake_vector (make_number (SAVED_WINDOW_VECTOR_SIZE
), Qnil
);
3544 save_window_save (FRAME_ROOT_WINDOW (f
),
3546 XSETWINDOW_CONFIGURATION (tem
, data
);
3550 DEFUN ("save-window-excursion", Fsave_window_excursion
, Ssave_window_excursion
,
3552 "Execute body, preserving window sizes and contents.\n\
3553 Restore which buffer appears in which window, where display starts,\n\
3554 and the value of point and mark for each window.\n\
3555 Also restore which buffer is current.\n\
3556 But do not preserve point in the current buffer.\n\
3557 Does not restore the value of point in current buffer.")
3561 register Lisp_Object val
;
3562 register int count
= specpdl_ptr
- specpdl
;
3564 record_unwind_protect (Fset_window_configuration
,
3565 Fcurrent_window_configuration (Qnil
));
3566 val
= Fprogn (args
);
3567 return unbind_to (count
, val
);
3572 selected_frame
= make_terminal_frame ();
3573 XSETFRAME (Vterminal_frame
, selected_frame
);
3574 minibuf_window
= selected_frame
->minibuffer_window
;
3575 selected_window
= selected_frame
->selected_window
;
3576 last_nonminibuf_frame
= selected_frame
;
3578 window_initialized
= 1;
3583 Qwindowp
= intern ("windowp");
3584 staticpro (&Qwindowp
);
3586 Qwindow_live_p
= intern ("window-live-p");
3587 staticpro (&Qwindow_live_p
);
3589 Qtemp_buffer_show_hook
= intern ("temp-buffer-show-hook");
3590 staticpro (&Qtemp_buffer_show_hook
);
3592 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function
,
3593 "Non-nil means call as function to display a help buffer.\n\
3594 The function is called with one argument, the buffer to be displayed.\n\
3595 Used by `with-output-to-temp-buffer'.\n\
3596 If this function is used, then it must do the entire job of showing\n\
3597 the buffer; `temp-buffer-show-hook' is not run unless this function runs it.");
3598 Vtemp_buffer_show_function
= Qnil
;
3600 DEFVAR_LISP ("display-buffer-function", &Vdisplay_buffer_function
,
3601 "If non-nil, function to call to handle `display-buffer'.\n\
3602 It will receive two args, the buffer and a flag which if non-nil means\n\
3603 that the currently selected window is not acceptable.\n\
3604 Commands such as `switch-to-buffer-other-window' and `find-file-other-window'\n\
3605 work using this function.");
3606 Vdisplay_buffer_function
= Qnil
;
3608 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window
,
3609 "Non-nil means it is the window that C-M-v in minibuffer should scroll.");
3610 Vminibuf_scroll_window
= Qnil
;
3612 DEFVAR_LISP ("other-window-scroll-buffer", &Vother_window_scroll_buffer
,
3613 "If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window.");
3614 Vother_window_scroll_buffer
= Qnil
;
3616 DEFVAR_BOOL ("pop-up-frames", &pop_up_frames
,
3617 "*Non-nil means `display-buffer' should make a separate frame.");
3620 DEFVAR_LISP ("pop-up-frame-function", &Vpop_up_frame_function
,
3621 "Function to call to handle automatic new frame creation.\n\
3622 It is called with no arguments and should return a newly created frame.\n\
3624 A typical value might be `(lambda () (new-frame pop-up-frame-alist))'\n\
3625 where `pop-up-frame-alist' would hold the default frame parameters.");
3626 Vpop_up_frame_function
= Qnil
;
3628 DEFVAR_LISP ("special-display-buffer-names", &Vspecial_display_buffer_names
,
3629 "*List of buffer names that should have their own special frames.\n\
3630 Displaying a buffer whose name is in this list makes a special frame for it\n\
3631 using `special-display-function'. See also `special-display-regexps'.\n\
3633 An element of the list can be a list instead of just a string.\n\
3634 There are two ways to use a list as an element:\n\
3635 (BUFFER FRAME-PARAMETERS...) (BUFFER FUNCTION OTHER-ARGS...)\n\
3636 In the first case, FRAME-PARAMETERS are used to create the frame.\n\
3637 In the latter case, FUNCTION is called with BUFFER as the first argument,\n\
3638 followed by OTHER-ARGS--it can display BUFFER in any way it likes.\n\
3639 All this is done by the function found in `special-display-function'.");
3640 Vspecial_display_buffer_names
= Qnil
;
3642 DEFVAR_LISP ("special-display-regexps", &Vspecial_display_regexps
,
3643 "*List of regexps saying which buffers should have their own special frames.\n\
3644 If a buffer name matches one of these regexps, it gets its own frame.\n\
3645 Displaying a buffer whose name is in this list makes a special frame for it\n\
3646 using `special-display-function'.\n\
3648 An element of the list can be a list instead of just a string.\n\
3649 There are two ways to use a list as an element:\n\
3650 (REGEXP FRAME-PARAMETERS...) (REGEXP FUNCTION OTHER-ARGS...)\n\
3651 In the first case, FRAME-PARAMETERS are used to create the frame.\n\
3652 In the latter case, FUNCTION is called with the buffer as first argument,\n\
3653 followed by OTHER-ARGS--it can display the buffer in any way it likes.\n\
3654 All this is done by the function found in `special-display-function'.");
3655 Vspecial_display_regexps
= Qnil
;
3657 DEFVAR_LISP ("special-display-function", &Vspecial_display_function
,
3658 "Function to call to make a new frame for a special buffer.\n\
3659 It is called with two arguments, the buffer and optional buffer specific\n\
3660 data, and should return a window displaying that buffer.\n\
3661 The default value makes a separate frame for the buffer,\n\
3662 using `special-display-frame-alist' to specify the frame parameters.\n\
3664 A buffer is special if its is listed in `special-display-buffer-names'\n\
3665 or matches a regexp in `special-display-regexps'.");
3666 Vspecial_display_function
= Qnil
;
3668 DEFVAR_LISP ("same-window-buffer-names", &Vsame_window_buffer_names
,
3669 "*List of buffer names that should appear in the selected window.\n\
3670 Displaying one of these buffers using `display-buffer' or `pop-to-buffer'\n\
3671 switches to it in the selected window, rather than making it appear\n\
3672 in some other window.\n\
3674 An element of the list can be a cons cell instead of just a string.\n\
3675 Then the car must be a string, which specifies the buffer name.\n\
3676 This is for compatibility with `special-display-buffer-names';\n\
3677 the cdr of the cons cell is ignored.\n\
3679 See also `same-window-regexps'.");
3680 Vsame_window_buffer_names
= Qnil
;
3682 DEFVAR_LISP ("same-window-regexps", &Vsame_window_regexps
,
3683 "*List of regexps saying which buffers should appear in the selected window.\n\
3684 If a buffer name matches one of these regexps, then displaying it\n\
3685 using `display-buffer' or `pop-to-buffer' switches to it\n\
3686 in the selected window, rather than making it appear in some other window.\n\
3688 An element of the list can be a cons cell instead of just a string.\n\
3689 Then the car must be a string, which specifies the buffer name.\n\
3690 This is for compatibility with `special-display-buffer-names';\n\
3691 the cdr of the cons cell is ignored.\n\
3693 See also `same-window-buffer-names'.");
3694 Vsame_window_regexps
= Qnil
;
3696 DEFVAR_BOOL ("pop-up-windows", &pop_up_windows
,
3697 "*Non-nil means display-buffer should make new windows.");
3700 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines
,
3701 "*Number of lines of continuity when scrolling by screenfuls.");
3702 next_screen_context_lines
= 2;
3704 DEFVAR_INT ("split-height-threshold", &split_height_threshold
,
3705 "*display-buffer would prefer to split the largest window if this large.\n\
3706 If there is only one window, it is split regardless of this value.");
3707 split_height_threshold
= 500;
3709 DEFVAR_INT ("window-min-height", &window_min_height
,
3710 "*Delete any window less than this tall (including its mode line).");
3711 window_min_height
= 4;
3713 DEFVAR_INT ("window-min-width", &window_min_width
,
3714 "*Delete any window less than this wide.");
3715 window_min_width
= 10;
3717 DEFVAR_BOOL ("scroll-preserve-screen-position",
3718 &scroll_preserve_screen_position
,
3719 "*Nonzero means scroll commands move point to keep its screen line unchanged.");
3720 scroll_preserve_screen_position
= 0;
3722 defsubr (&Sselected_window
);
3723 defsubr (&Sminibuffer_window
);
3724 defsubr (&Swindow_minibuffer_p
);
3725 defsubr (&Swindowp
);
3726 defsubr (&Swindow_live_p
);
3727 defsubr (&Spos_visible_in_window_p
);
3728 defsubr (&Swindow_buffer
);
3729 defsubr (&Swindow_height
);
3730 defsubr (&Swindow_width
);
3731 defsubr (&Swindow_hscroll
);
3732 defsubr (&Sset_window_hscroll
);
3733 defsubr (&Swindow_redisplay_end_trigger
);
3734 defsubr (&Sset_window_redisplay_end_trigger
);
3735 defsubr (&Swindow_edges
);
3736 defsubr (&Scoordinates_in_window_p
);
3737 defsubr (&Swindow_at
);
3738 defsubr (&Swindow_point
);
3739 defsubr (&Swindow_start
);
3740 defsubr (&Swindow_end
);
3741 defsubr (&Sset_window_point
);
3742 defsubr (&Sset_window_start
);
3743 defsubr (&Swindow_dedicated_p
);
3744 defsubr (&Sset_window_dedicated_p
);
3745 defsubr (&Swindow_display_table
);
3746 defsubr (&Sset_window_display_table
);
3747 defsubr (&Snext_window
);
3748 defsubr (&Sprevious_window
);
3749 defsubr (&Sother_window
);
3750 defsubr (&Sget_lru_window
);
3751 defsubr (&Sget_largest_window
);
3752 defsubr (&Sget_buffer_window
);
3753 defsubr (&Sdelete_other_windows
);
3754 defsubr (&Sdelete_windows_on
);
3755 defsubr (&Sreplace_buffer_in_windows
);
3756 defsubr (&Sdelete_window
);
3757 defsubr (&Sset_window_buffer
);
3758 defsubr (&Sselect_window
);
3759 defsubr (&Sspecial_display_p
);
3760 defsubr (&Ssame_window_p
);
3761 defsubr (&Sdisplay_buffer
);
3762 defsubr (&Ssplit_window
);
3763 defsubr (&Senlarge_window
);
3764 defsubr (&Sshrink_window
);
3765 defsubr (&Sscroll_up
);
3766 defsubr (&Sscroll_down
);
3767 defsubr (&Sscroll_left
);
3768 defsubr (&Sscroll_right
);
3769 defsubr (&Sother_window_for_scrolling
);
3770 defsubr (&Sscroll_other_window
);
3771 defsubr (&Srecenter
);
3772 defsubr (&Smove_to_window_line
);
3773 defsubr (&Swindow_configuration_p
);
3774 defsubr (&Sset_window_configuration
);
3775 defsubr (&Scurrent_window_configuration
);
3776 defsubr (&Ssave_window_excursion
);
3781 initial_define_key (control_x_map
, '1', "delete-other-windows");
3782 initial_define_key (control_x_map
, '2', "split-window");
3783 initial_define_key (control_x_map
, '0', "delete-window");
3784 initial_define_key (control_x_map
, 'o', "other-window");
3785 initial_define_key (control_x_map
, '^', "enlarge-window");
3786 initial_define_key (control_x_map
, '<', "scroll-left");
3787 initial_define_key (control_x_map
, '>', "scroll-right");
3789 initial_define_key (global_map
, Ctl ('V'), "scroll-up");
3790 initial_define_key (meta_map
, Ctl ('V'), "scroll-other-window");
3791 initial_define_key (meta_map
, 'v', "scroll-down");
3793 initial_define_key (global_map
, Ctl('L'), "recenter");
3794 initial_define_key (meta_map
, 'r', "move-to-window-line");