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 #define min(a, b) ((a) < (b) ? (a) : (b))
116 extern Lisp_Object Qwindow_scroll_functions
, Vwindow_scroll_functions
;
118 DEFUN ("windowp", Fwindowp
, Swindowp
, 1, 1, 0,
119 "Returns t if OBJECT is a window.")
123 return WINDOWP (object
) ? Qt
: Qnil
;
126 DEFUN ("window-live-p", Fwindow_live_p
, Swindow_live_p
, 1, 1, 0,
127 "Returns t if OBJECT is a window which is currently visible.")
131 return (WINDOWP (object
) && ! NILP (XWINDOW (object
)->buffer
) ? Qt
: Qnil
);
138 register struct window
*p
;
139 register struct Lisp_Vector
*vec
;
142 vec
= allocate_vectorlike ((EMACS_INT
) VECSIZE (struct window
));
143 for (i
= 0; i
< VECSIZE (struct window
); i
++)
144 vec
->contents
[i
] = Qnil
;
145 vec
->size
= VECSIZE (struct window
);
146 p
= (struct window
*)vec
;
147 XSETFASTINT (p
->sequence_number
, ++sequence_number
);
148 XSETFASTINT (p
->left
, 0);
149 XSETFASTINT (p
->top
, 0);
150 XSETFASTINT (p
->height
, 0);
151 XSETFASTINT (p
->width
, 0);
152 XSETFASTINT (p
->hscroll
, 0);
153 XSETFASTINT (p
->last_point_x
, 0);
154 XSETFASTINT (p
->last_point_y
, 0);
155 p
->start
= Fmake_marker ();
156 p
->pointm
= Fmake_marker ();
157 XSETFASTINT (p
->use_time
, 0);
159 p
->display_table
= Qnil
;
165 DEFUN ("selected-window", Fselected_window
, Sselected_window
, 0, 0, 0,
166 "Return the window that the cursor now appears in and commands apply to.")
169 return selected_window
;
172 DEFUN ("minibuffer-window", Fminibuffer_window
, Sminibuffer_window
, 0, 1, 0,
173 "Return the window used now for minibuffers.\n\
174 If the optional argument FRAME is specified, return the minibuffer window\n\
175 used by that frame.")
181 XSETFRAME (frame
, selected_frame
);
183 CHECK_LIVE_FRAME (frame
, 0);
186 return FRAME_MINIBUF_WINDOW (XFRAME (frame
));
189 DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p
, Swindow_minibuffer_p
, 0, 1, 0,
190 "Returns non-nil if WINDOW is a minibuffer window.")
194 struct window
*w
= decode_window (window
);
195 return (MINI_WINDOW_P (w
) ? Qt
: Qnil
);
198 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p
,
199 Spos_visible_in_window_p
, 0, 2, 0,
200 "Return t if position POS is currently on the frame in WINDOW.\n\
201 Returns nil if that position is scrolled vertically out of view.\n\
202 POS defaults to point; WINDOW, to the selected window.")
204 Lisp_Object pos
, window
;
206 register struct window
*w
;
210 register struct buffer
*buf
;
211 struct position posval
;
218 CHECK_NUMBER_COERCE_MARKER (pos
, 0);
222 w
= decode_window (window
);
223 top
= marker_position (w
->start
);
224 hscroll
= XINT (w
->hscroll
);
229 height
= XFASTINT (w
->height
) - ! MINI_WINDOW_P (w
);
231 buf
= XBUFFER (w
->buffer
);
232 if (XFASTINT (w
->last_modified
) >= BUF_MODIFF (buf
))
234 /* If frame is up to date,
235 use the info recorded about how much text fit on it. */
236 if (posint
< BUF_Z (buf
) - XFASTINT (w
->window_end_pos
)
237 || (XFASTINT (w
->window_end_vpos
) < height
))
243 if (posint
> BUF_ZV (buf
))
246 /* w->start can be out of range. If it is, do something reasonable. */
247 if (top
< BUF_BEGV (buf
) || top
> BUF_ZV (buf
))
250 /* If that info is not correct, calculate afresh */
251 posval
= *compute_motion (top
, 0, (hscroll
? 1 - hscroll
: 0), 0,
253 window_internal_width (w
) - 1,
256 return posval
.vpos
< height
? Qt
: Qnil
;
260 static struct window
*
261 decode_window (window
)
262 register Lisp_Object window
;
265 return XWINDOW (selected_window
);
267 CHECK_LIVE_WINDOW (window
, 0);
268 return XWINDOW (window
);
271 DEFUN ("window-buffer", Fwindow_buffer
, Swindow_buffer
, 0, 1, 0,
272 "Return the buffer that WINDOW is displaying.")
276 return decode_window (window
)->buffer
;
279 DEFUN ("window-height", Fwindow_height
, Swindow_height
, 0, 1, 0,
280 "Return the number of lines in WINDOW (including its mode line).")
284 return decode_window (window
)->height
;
287 DEFUN ("window-width", Fwindow_width
, Swindow_width
, 0, 1, 0,
288 "Return the number of display columns in WINDOW.\n\
289 This is the width that is usable columns available for text in WINDOW.\n\
290 If you want to find out how many columns WINDOW takes up,\n\
291 use (let ((edges (window-edges))) (- (nth 2 edges) (nth 0 edges))).")
295 return make_number (window_internal_width (decode_window (window
)));
298 DEFUN ("window-hscroll", Fwindow_hscroll
, Swindow_hscroll
, 0, 1, 0,
299 "Return the number of columns by which WINDOW is scrolled from left margin.")
303 return decode_window (window
)->hscroll
;
306 DEFUN ("set-window-hscroll", Fset_window_hscroll
, Sset_window_hscroll
, 2, 2, 0,
307 "Set number of columns WINDOW is scrolled from left margin to NCOL.\n\
308 NCOL should be zero or positive.")
310 register Lisp_Object window
, ncol
;
312 register struct window
*w
;
314 CHECK_NUMBER (ncol
, 1);
315 if (XINT (ncol
) < 0) XSETFASTINT (ncol
, 0);
316 w
= decode_window (window
);
317 if (XINT (w
->hscroll
) != XINT (ncol
))
318 XBUFFER (w
->buffer
)->clip_changed
= 1; /* Prevent redisplay shortcuts */
323 DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger
,
324 Swindow_redisplay_end_trigger
, 0, 1, 0,
325 "Return WINDOW's redisplay end trigger value.\n\
326 See `set-window-redisplay-end-trigger' for more information.")
330 return decode_window (window
)->redisplay_end_trigger
;
333 DEFUN ("set-window-redisplay-end-trigger", Fset_window_redisplay_end_trigger
,
334 Sset_window_redisplay_end_trigger
, 2, 2, 0,
335 "Set WINDOW's redisplay end trigger value to VALUE.\n\
336 VALUE should be a buffer position (typically a marker) or nil.\n\
337 If it is a buffer position, then if redisplay in WINDOW reaches a position\n\
338 beyond VALUE, the functions in `redisplay-end-trigger-functions' are called\n\
339 with two arguments: WINDOW, and the end trigger value.\n\
340 Afterwards the end-trigger value is reset to nil.")
342 register Lisp_Object window
, value
;
344 register struct window
*w
;
346 w
= decode_window (window
);
347 w
->redisplay_end_trigger
= value
;
351 DEFUN ("window-edges", Fwindow_edges
, Swindow_edges
, 0, 1, 0,
352 "Return a list of the edge coordinates of WINDOW.\n\
353 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame.\n\
354 RIGHT is one more than the rightmost column used by WINDOW,\n\
355 and BOTTOM is one more than the bottommost row used by WINDOW\n\
360 register struct window
*w
= decode_window (window
);
362 return Fcons (w
->left
, Fcons (w
->top
,
363 Fcons (make_number (XFASTINT (w
->left
) + XFASTINT (w
->width
)),
364 Fcons (make_number (XFASTINT (w
->top
)
365 + XFASTINT (w
->height
)),
369 /* Test if the character at column *x, row *y is within window *w.
370 If it is not, return 0;
371 if it is in the window's text area,
372 set *x and *y to its location relative to the upper left corner
375 if it is on the window's modeline, return 2;
376 if it is on the border between the window and its right sibling,
379 coordinates_in_window (w
, x
, y
)
380 register struct window
*w
;
383 register int left
= XINT (w
->left
);
384 register int width
= XINT (w
->width
);
385 register int window_height
= XINT (w
->height
);
386 register int top
= XFASTINT (w
->top
);
388 if ( *x
< left
|| *x
>= left
+ width
389 || *y
< top
|| *y
>= top
+ window_height
)
392 /* Is the character is the mode line? */
393 if (*y
== top
+ window_height
- 1
394 && ! MINI_WINDOW_P (w
))
397 /* Is the character in the right border? */
398 if (*x
== left
+ width
- 1
399 && left
+ width
!= FRAME_WIDTH (XFRAME (w
->frame
)))
407 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p
,
408 Scoordinates_in_window_p
, 2, 2, 0,
409 "Return non-nil if COORDINATES are in WINDOW.\n\
410 COORDINATES is a cons of the form (X . Y), X and Y being distances\n\
411 measured in characters from the upper-left corner of the frame.\n\
412 (0 . 0) denotes the character in the upper left corner of the\n\
414 If COORDINATES are in the text portion of WINDOW,\n\
415 the coordinates relative to the window are returned.\n\
416 If they are in the mode line of WINDOW, `mode-line' is returned.\n\
417 If they are on the border between WINDOW and its right sibling,\n\
418 `vertical-line' is returned.")
419 (coordinates
, window
)
420 register Lisp_Object coordinates
, window
;
424 CHECK_LIVE_WINDOW (window
, 0);
425 CHECK_CONS (coordinates
, 1);
426 x
= XINT (Fcar (coordinates
));
427 y
= XINT (Fcdr (coordinates
));
429 switch (coordinates_in_window (XWINDOW (window
), &x
, &y
))
431 case 0: /* NOT in window at all. */
434 case 1: /* In text part of window. */
437 case 2: /* In mode line of window. */
440 case 3: /* On right border of window. */
441 return Qvertical_line
;
448 /* Find the window containing column x, row y, and return it as a
449 Lisp_Object. If x, y is on the window's modeline, set *part
450 to 1; if it is on the separating line between the window and its
451 right sibling, set it to 2; otherwise set it to 0. If there is no
452 window under x, y return nil and leave *part unmodified. */
454 window_from_coordinates (frame
, x
, y
, part
)
459 register Lisp_Object tem
, first
;
461 tem
= first
= FRAME_SELECTED_WINDOW (frame
);
465 int found
= coordinates_in_window (XWINDOW (tem
), &x
, &y
);
473 tem
= Fnext_window (tem
, Qt
, Qlambda
);
475 while (! EQ (tem
, first
));
480 DEFUN ("window-at", Fwindow_at
, Swindow_at
, 2, 3, 0,
481 "Return window containing coordinates X and Y on FRAME.\n\
482 If omitted, FRAME defaults to the currently selected frame.\n\
483 The top left corner of the frame is considered to be row 0,\n\
486 Lisp_Object x
, y
, frame
;
492 XSETFRAME (frame
, selected_frame
);
494 CHECK_LIVE_FRAME (frame
, 2);
499 return window_from_coordinates (XFRAME (frame
),
504 DEFUN ("window-point", Fwindow_point
, Swindow_point
, 0, 1, 0,
505 "Return current value of point in WINDOW.\n\
506 For a nonselected window, this is the value point would have\n\
507 if that window were selected.\n\
509 Note that, when WINDOW is the selected window and its buffer\n\
510 is also currently selected, the value returned is the same as (point).\n\
511 It would be more strictly correct to return the `top-level' value\n\
512 of point, outside of any save-excursion forms.\n\
513 But that is hard to define.")
517 register struct window
*w
= decode_window (window
);
519 if (w
== XWINDOW (selected_window
)
520 && current_buffer
== XBUFFER (w
->buffer
))
522 return Fmarker_position (w
->pointm
);
525 DEFUN ("window-start", Fwindow_start
, Swindow_start
, 0, 1, 0,
526 "Return position at which display currently starts in WINDOW.\n\
527 This is updated by redisplay or by calling `set-window-start'.")
531 return Fmarker_position (decode_window (window
)->start
);
534 /* This is text temporarily removed from the doc string below.
536 This function returns nil if the position is not currently known.\n\
537 That happens when redisplay is preempted and doesn't finish.\n\
538 If in that case you want to compute where the end of the window would\n\
539 have been if redisplay had finished, do this:\n\
541 (goto-char (window-start window))\n\
542 (vertical-motion (1- (window-height window)) window)\n\
545 DEFUN ("window-end", Fwindow_end
, Swindow_end
, 0, 1, 0,
546 "Return position at which display currently ends in WINDOW.\n\
547 This is updated by redisplay, when it runs to completion.\n\
548 Simply changing the buffer text or setting `window-start'\n\
549 does not update this value.")
554 struct window
*w
= decode_window (window
);
558 CHECK_BUFFER (buf
, 0);
560 #if 0 /* This change broke some things. We should make it later. */
561 /* If we don't know the end position, return nil.
562 The user can compute it with vertical-motion if he wants to.
563 It would be nicer to do it automatically,
564 but that's so slow that it would probably bother people. */
565 if (NILP (w
->window_end_valid
))
570 BUF_Z (XBUFFER (buf
)) - XFASTINT (w
->window_end_pos
));
575 DEFUN ("set-window-point", Fset_window_point
, Sset_window_point
, 2, 2, 0,
576 "Make point value in WINDOW be at position POS in WINDOW's buffer.")
578 Lisp_Object window
, pos
;
580 register struct window
*w
= decode_window (window
);
582 CHECK_NUMBER_COERCE_MARKER (pos
, 1);
583 if (w
== XWINDOW (selected_window
))
586 set_marker_restricted (w
->pointm
, pos
, w
->buffer
);
591 DEFUN ("set-window-start", Fset_window_start
, Sset_window_start
, 2, 3, 0,
592 "Make display in WINDOW start at position POS in WINDOW's buffer.\n\
593 Optional third arg NOFORCE non-nil inhibits next redisplay\n\
594 from overriding motion of point in order to display at this exact start.")
595 (window
, pos
, noforce
)
596 Lisp_Object window
, pos
, noforce
;
598 register struct window
*w
= decode_window (window
);
600 CHECK_NUMBER_COERCE_MARKER (pos
, 1);
601 set_marker_restricted (w
->start
, pos
, w
->buffer
);
602 /* this is not right, but much easier than doing what is right. */
603 w
->start_at_line_beg
= Qnil
;
606 w
->update_mode_line
= Qt
;
607 XSETFASTINT (w
->last_modified
, 0);
608 if (!EQ (window
, selected_window
))
609 windows_or_buffers_changed
++;
613 DEFUN ("window-dedicated-p", Fwindow_dedicated_p
, Swindow_dedicated_p
,
615 "Return WINDOW's dedicated object, usually t or nil.\n\
616 See also `set-window-dedicated-p'.")
620 return decode_window (window
)->dedicated
;
623 DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p
,
624 Sset_window_dedicated_p
, 2, 2, 0,
625 "Control whether WINDOW is dedicated to the buffer it displays.\n\
626 If it is dedicated, Emacs will not automatically change\n\
627 which buffer appears in it.\n\
628 The second argument is the new value for the dedication flag;\n\
631 Lisp_Object window
, arg
;
633 register struct window
*w
= decode_window (window
);
643 DEFUN ("window-display-table", Fwindow_display_table
, Swindow_display_table
,
645 "Return the display-table that WINDOW is using.")
649 return decode_window (window
)->display_table
;
652 /* Get the display table for use currently on window W.
653 This is either W's display table or W's buffer's display table.
654 Ignore the specified tables if they are not valid;
655 if no valid table is specified, return 0. */
657 struct Lisp_Char_Table
*
658 window_display_table (w
)
662 tem
= w
->display_table
;
663 if (DISP_TABLE_P (tem
))
664 return XCHAR_TABLE (tem
);
665 tem
= XBUFFER (w
->buffer
)->display_table
;
666 if (DISP_TABLE_P (tem
))
667 return XCHAR_TABLE (tem
);
668 tem
= Vstandard_display_table
;
669 if (DISP_TABLE_P (tem
))
670 return XCHAR_TABLE (tem
);
674 DEFUN ("set-window-display-table", Fset_window_display_table
, Sset_window_display_table
, 2, 2, 0,
675 "Set WINDOW's display-table to TABLE.")
677 register Lisp_Object window
, table
;
679 register struct window
*w
;
680 register Lisp_Object z
; /* Return value. */
682 w
= decode_window (window
);
683 w
->display_table
= table
;
687 /* Record info on buffer window w is displaying
688 when it is about to cease to display that buffer. */
691 register struct window
*w
;
696 if (XBUFFER (buf
) != XMARKER (w
->pointm
)->buffer
)
700 if (w
== XWINDOW (selected_window
)
701 || ! EQ (buf
, XWINDOW (selected_window
)->buffer
))
702 /* Do this except when the selected window's buffer
703 is being removed from some other window. */
705 /* last_window_start records the start position that this buffer
706 had in the last window to be disconnected from it.
707 Now that this statement is unconditional,
708 it is possible for the buffer to be displayed in the
709 selected window, while last_window_start reflects another
710 window which was recently showing the same buffer.
711 Some people might say that might be a good thing. Let's see. */
712 XBUFFER (buf
)->last_window_start
= marker_position (w
->start
);
714 /* Point in the selected window's buffer
715 is actually stored in that buffer, and the window's pointm isn't used.
716 So don't clobber point in that buffer. */
717 if (! EQ (buf
, XWINDOW (selected_window
)->buffer
))
718 BUF_PT (XBUFFER (buf
))
719 = clip_to_bounds (BUF_BEGV (XBUFFER (buf
)),
720 marker_position (w
->pointm
),
721 BUF_ZV (XBUFFER (buf
)));
724 /* Put replacement into the window structure in place of old. */
726 replace_window (old
, replacement
)
727 Lisp_Object old
, replacement
;
729 register Lisp_Object tem
;
730 register struct window
*o
= XWINDOW (old
), *p
= XWINDOW (replacement
);
732 /* If OLD is its frame's root_window, then replacement is the new
733 root_window for that frame. */
735 if (EQ (old
, FRAME_ROOT_WINDOW (XFRAME (o
->frame
))))
736 FRAME_ROOT_WINDOW (XFRAME (o
->frame
)) = replacement
;
741 p
->height
= o
->height
;
743 p
->next
= tem
= o
->next
;
745 XWINDOW (tem
)->prev
= replacement
;
747 p
->prev
= tem
= o
->prev
;
749 XWINDOW (tem
)->next
= replacement
;
751 p
->parent
= tem
= o
->parent
;
754 if (EQ (XWINDOW (tem
)->vchild
, old
))
755 XWINDOW (tem
)->vchild
= replacement
;
756 if (EQ (XWINDOW (tem
)->hchild
, old
))
757 XWINDOW (tem
)->hchild
= replacement
;
760 /*** Here, if replacement is a vertical combination
761 and so is its new parent, we should make replacement's
762 children be children of that parent instead. ***/
765 DEFUN ("delete-window", Fdelete_window
, Sdelete_window
, 0, 1, "",
766 "Remove WINDOW from the display. Default is selected window.")
768 register Lisp_Object window
;
770 register Lisp_Object tem
, parent
, sib
;
771 register struct window
*p
;
772 register struct window
*par
;
774 /* Because this function is called by other C code on non-leaf
775 windows, the CHECK_LIVE_WINDOW macro would choke inappropriately,
776 so we can't decode_window here. */
778 window
= selected_window
;
780 CHECK_WINDOW (window
, 0);
781 p
= XWINDOW (window
);
783 /* It's okay to delete an already-deleted window. */
791 error ("Attempt to delete minibuffer or sole ordinary window");
792 par
= XWINDOW (parent
);
794 windows_or_buffers_changed
++;
795 FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (p
))) = 1;
797 /* Are we trying to delete any frame's selected window? */
799 Lisp_Object frame
, pwindow
;
801 /* See if the frame's selected window is either WINDOW
802 or any subwindow of it, by finding all that window's parents
803 and comparing each one with WINDOW. */
804 frame
= WINDOW_FRAME (XWINDOW (window
));
805 pwindow
= FRAME_SELECTED_WINDOW (XFRAME (frame
));
807 while (!NILP (pwindow
))
809 if (EQ (window
, pwindow
))
811 pwindow
= XWINDOW (pwindow
)->parent
;
814 if (EQ (window
, pwindow
))
816 Lisp_Object alternative
;
817 alternative
= Fnext_window (window
, Qlambda
, Qnil
);
819 /* If we're about to delete the selected window on the
820 selected frame, then we should use Fselect_window to select
821 the new window. On the other hand, if we're about to
822 delete the selected window on any other frame, we shouldn't do
823 anything but set the frame's selected_window slot. */
824 if (EQ (window
, selected_window
))
825 Fselect_window (alternative
);
827 FRAME_SELECTED_WINDOW (XFRAME (frame
)) = alternative
;
832 /* tem is null for dummy parent windows
833 (which have inferiors but not any contents themselves) */
837 unchain_marker (p
->pointm
);
838 unchain_marker (p
->start
);
843 XWINDOW (tem
)->prev
= p
->prev
;
847 XWINDOW (tem
)->next
= p
->next
;
849 if (EQ (window
, par
->hchild
))
850 par
->hchild
= p
->next
;
851 if (EQ (window
, par
->vchild
))
852 par
->vchild
= p
->next
;
854 /* Find one of our siblings to give our space to. */
858 /* If p gives its space to its next sibling, that sibling needs
859 to have its top/left side pulled back to where p's is.
860 set_window_{height,width} will re-position the sibling's
863 XWINDOW (sib
)->top
= p
->top
;
864 XWINDOW (sib
)->left
= p
->left
;
867 /* Stretch that sibling. */
868 if (!NILP (par
->vchild
))
869 set_window_height (sib
,
870 XFASTINT (XWINDOW (sib
)->height
) + XFASTINT (p
->height
),
872 if (!NILP (par
->hchild
))
873 set_window_width (sib
,
874 XFASTINT (XWINDOW (sib
)->width
) + XFASTINT (p
->width
),
877 /* If parent now has only one child,
878 put the child into the parent's place. */
882 if (NILP (XWINDOW (tem
)->next
))
883 replace_window (parent
, tem
);
885 /* Since we may be deleting combination windows, we must make sure that
886 not only p but all its children have been marked as deleted. */
887 if (! NILP (p
->hchild
))
888 delete_all_subwindows (XWINDOW (p
->hchild
));
889 else if (! NILP (p
->vchild
))
890 delete_all_subwindows (XWINDOW (p
->vchild
));
892 /* Mark this window as deleted. */
893 p
->buffer
= p
->hchild
= p
->vchild
= Qnil
;
899 extern Lisp_Object
next_frame (), prev_frame ();
901 /* This comment supplies the doc string for `next-window',
902 for make-docfile to see. We cannot put this in the real DEFUN
903 due to limits in the Unix cpp.
905 DEFUN ("next-window", Ffoo, Sfoo, 0, 3, 0,
906 "Return next window after WINDOW in canonical ordering of windows.\n\
907 If omitted, WINDOW defaults to the selected window.\n\
909 Optional second arg MINIBUF t means count the minibuffer window even\n\
910 if not active. MINIBUF nil or omitted means count the minibuffer iff\n\
911 it is active. MINIBUF neither t nor nil means not to count the\n\
912 minibuffer even if it is active.\n\
914 Several frames may share a single minibuffer; if the minibuffer\n\
915 counts, all windows on all frames that share that minibuffer count\n\
916 too. Therefore, `next-window' can be used to iterate through the\n\
917 set of windows even when the minibuffer is on another frame. If the\n\
918 minibuffer does not count, only windows from WINDOW's frame count.\n\
920 Optional third arg ALL-FRAMES t means include windows on all frames.\n\
921 ALL-FRAMES nil or omitted means cycle within the frames as specified\n\
922 above. ALL-FRAMES = `visible' means include windows on all visible frames.\n\
923 ALL-FRAMES = 0 means include windows on all visible and iconified frames.\n\
924 If ALL-FRAMES is a frame, restrict search to windows on that frame.\n\
925 Anything else means restrict to WINDOW's frame.\n\
927 If you use consistent values for MINIBUF and ALL-FRAMES, you can use\n\
928 `next-window' to iterate through the entire cycle of acceptable\n\
929 windows, eventually ending up back at the window you started with.\n\
930 `previous-window' traverses the same cycle, in the reverse order.")
931 (window, minibuf, all_frames) */
933 DEFUN ("next-window", Fnext_window
, Snext_window
, 0, 3, 0,
935 (window
, minibuf
, all_frames
)
936 register Lisp_Object window
, minibuf
, all_frames
;
938 register Lisp_Object tem
;
939 Lisp_Object start_window
;
942 window
= selected_window
;
944 CHECK_LIVE_WINDOW (window
, 0);
946 start_window
= window
;
948 /* minibuf == nil may or may not include minibuffers.
949 Decide if it does. */
951 minibuf
= (minibuf_level
? minibuf_window
: Qlambda
);
952 else if (! EQ (minibuf
, Qt
))
954 /* Now minibuf can be t => count all minibuffer windows,
955 lambda => count none of them,
956 or a specific minibuffer window (the active one) to count. */
959 /* all_frames == nil doesn't specify which frames to include. */
960 if (NILP (all_frames
))
961 all_frames
= (! EQ (minibuf
, Qlambda
)
962 ? (FRAME_MINIBUF_WINDOW
965 (XWINDOW (window
)))))
967 else if (EQ (all_frames
, Qvisible
))
969 else if (XFASTINT (all_frames
) == 0)
971 else if (FRAMEP (all_frames
) && ! EQ (all_frames
, Fwindow_frame (window
)))
972 /* If all_frames is a frame and window arg isn't on that frame, just
973 return the first window on the frame. */
974 return Fframe_first_window (all_frames
);
975 else if (! EQ (all_frames
, Qt
))
977 /* Now all_frames is t meaning search all frames,
978 nil meaning search just current frame,
979 visible meaning search just visible frames,
980 0 meaning search visible and iconified frames,
981 or a window, meaning search the frame that window belongs to. */
984 /* Do this loop at least once, to get the next window, and perhaps
985 again, if we hit the minibuffer and that is not acceptable. */
988 /* Find a window that actually has a next one. This loop
989 climbs up the tree. */
990 while (tem
= XWINDOW (window
)->next
, NILP (tem
))
991 if (tem
= XWINDOW (window
)->parent
, !NILP (tem
))
995 /* We've reached the end of this frame.
996 Which other frames are acceptable? */
997 tem
= WINDOW_FRAME (XWINDOW (window
));
999 if (! NILP (all_frames
))
1004 tem
= next_frame (tem
, all_frames
);
1005 /* In the case where the minibuffer is active,
1006 and we include its frame as well as the selected one,
1007 next_frame may get stuck in that frame.
1008 If that happens, go back to the selected frame
1009 so we can complete the cycle. */
1011 XSETFRAME (tem
, selected_frame
);
1014 tem
= FRAME_ROOT_WINDOW (XFRAME (tem
));
1021 /* If we're in a combination window, find its first child and
1022 recurse on that. Otherwise, we've found the window we want. */
1025 if (!NILP (XWINDOW (window
)->hchild
))
1026 window
= XWINDOW (window
)->hchild
;
1027 else if (!NILP (XWINDOW (window
)->vchild
))
1028 window
= XWINDOW (window
)->vchild
;
1032 /* Which windows are acceptable?
1033 Exit the loop and accept this window if
1034 this isn't a minibuffer window,
1035 or we're accepting all minibuffer windows,
1036 or this is the active minibuffer and we are accepting that one, or
1037 we've come all the way around and we're back at the original window. */
1038 while (MINI_WINDOW_P (XWINDOW (window
))
1039 && ! EQ (minibuf
, Qt
)
1040 && ! EQ (minibuf
, window
)
1041 && ! EQ (window
, start_window
));
1046 /* This comment supplies the doc string for `previous-window',
1047 for make-docfile to see. We cannot put this in the real DEFUN
1048 due to limits in the Unix cpp.
1050 DEFUN ("previous-window", Ffoo, Sfoo, 0, 3, 0,
1051 "Return the window preceding WINDOW in canonical ordering of windows.\n\
1052 If omitted, WINDOW defaults to the selected window.\n\
1054 Optional second arg MINIBUF t means count the minibuffer window even\n\
1055 if not active. MINIBUF nil or omitted means count the minibuffer iff\n\
1056 it is active. MINIBUF neither t nor nil means not to count the\n\
1057 minibuffer even if it is active.\n\
1059 Several frames may share a single minibuffer; if the minibuffer\n\
1060 counts, all windows on all frames that share that minibuffer count\n\
1061 too. Therefore, `previous-window' can be used to iterate through\n\
1062 the set of windows even when the minibuffer is on another frame. If\n\
1063 the minibuffer does not count, only windows from WINDOW's frame count\n\
1065 Optional third arg ALL-FRAMES t means include windows on all frames.\n\
1066 ALL-FRAMES nil or omitted means cycle within the frames as specified\n\
1067 above. ALL-FRAMES = `visible' means include windows on all visible frames.\n\
1068 ALL-FRAMES = 0 means include windows on all visible and iconified frames.\n\
1069 If ALL-FRAMES is a frame, restrict search to windows on that frame.\n\
1070 Anything else means restrict to WINDOW's frame.\n\
1072 If you use consistent values for MINIBUF and ALL-FRAMES, you can use\n\
1073 `previous-window' to iterate through the entire cycle of acceptable\n\
1074 windows, eventually ending up back at the window you started with.\n\
1075 `next-window' traverses the same cycle, in the reverse order.")
1076 (window, minibuf, all_frames) */
1079 DEFUN ("previous-window", Fprevious_window
, Sprevious_window
, 0, 3, 0,
1081 (window
, minibuf
, all_frames
)
1082 register Lisp_Object window
, minibuf
, all_frames
;
1084 register Lisp_Object tem
;
1085 Lisp_Object start_window
;
1088 window
= selected_window
;
1090 CHECK_LIVE_WINDOW (window
, 0);
1092 start_window
= window
;
1094 /* minibuf == nil may or may not include minibuffers.
1095 Decide if it does. */
1097 minibuf
= (minibuf_level
? minibuf_window
: Qlambda
);
1098 else if (! EQ (minibuf
, Qt
))
1100 /* Now minibuf can be t => count all minibuffer windows,
1101 lambda => count none of them,
1102 or a specific minibuffer window (the active one) to count. */
1105 /* all_frames == nil doesn't specify which frames to include.
1106 Decide which frames it includes. */
1107 if (NILP (all_frames
))
1108 all_frames
= (! EQ (minibuf
, Qlambda
)
1109 ? (FRAME_MINIBUF_WINDOW
1112 (XWINDOW (window
)))))
1114 else if (EQ (all_frames
, Qvisible
))
1116 else if (XFASTINT (all_frames
) == 0)
1118 else if (FRAMEP (all_frames
) && ! EQ (all_frames
, Fwindow_frame (window
)))
1119 /* If all_frames is a frame and window arg isn't on that frame, just
1120 return the first window on the frame. */
1121 return Fframe_first_window (all_frames
);
1122 else if (! EQ (all_frames
, Qt
))
1124 /* Now all_frames is t meaning search all frames,
1125 nil meaning search just current frame,
1126 visible meaning search just visible frames,
1127 0 meaning search visible and iconified frames,
1128 or a window, meaning search the frame that window belongs to. */
1131 /* Do this loop at least once, to get the previous window, and perhaps
1132 again, if we hit the minibuffer and that is not acceptable. */
1135 /* Find a window that actually has a previous one. This loop
1136 climbs up the tree. */
1137 while (tem
= XWINDOW (window
)->prev
, NILP (tem
))
1138 if (tem
= XWINDOW (window
)->parent
, !NILP (tem
))
1142 /* We have found the top window on the frame.
1143 Which frames are acceptable? */
1144 tem
= WINDOW_FRAME (XWINDOW (window
));
1146 if (! NILP (all_frames
))
1147 /* It's actually important that we use prev_frame here,
1148 rather than next_frame. All the windows acceptable
1149 according to the given parameters should form a ring;
1150 Fnext_window and Fprevious_window should go back and
1151 forth around the ring. If we use next_frame here,
1152 then Fnext_window and Fprevious_window take different
1153 paths through the set of acceptable windows.
1154 window_loop assumes that these `ring' requirement are
1160 tem
= prev_frame (tem
, all_frames
);
1161 /* In the case where the minibuffer is active,
1162 and we include its frame as well as the selected one,
1163 next_frame may get stuck in that frame.
1164 If that happens, go back to the selected frame
1165 so we can complete the cycle. */
1167 XSETFRAME (tem
, selected_frame
);
1170 /* If this frame has a minibuffer, find that window first,
1171 because it is conceptually the last window in that frame. */
1172 if (FRAME_HAS_MINIBUF_P (XFRAME (tem
)))
1173 tem
= FRAME_MINIBUF_WINDOW (XFRAME (tem
));
1175 tem
= FRAME_ROOT_WINDOW (XFRAME (tem
));
1181 /* If we're in a combination window, find its last child and
1182 recurse on that. Otherwise, we've found the window we want. */
1185 if (!NILP (XWINDOW (window
)->hchild
))
1186 window
= XWINDOW (window
)->hchild
;
1187 else if (!NILP (XWINDOW (window
)->vchild
))
1188 window
= XWINDOW (window
)->vchild
;
1190 while (tem
= XWINDOW (window
)->next
, !NILP (tem
))
1194 /* Which windows are acceptable?
1195 Exit the loop and accept this window if
1196 this isn't a minibuffer window,
1197 or we're accepting all minibuffer windows,
1198 or this is the active minibuffer and we are accepting that one, or
1199 we've come all the way around and we're back at the original window. */
1200 while (MINI_WINDOW_P (XWINDOW (window
))
1201 && ! EQ (minibuf
, Qt
)
1202 && ! EQ (minibuf
, window
)
1203 && ! EQ (window
, start_window
));
1208 DEFUN ("other-window", Fother_window
, Sother_window
, 1, 2, "p",
1209 "Select the ARG'th different window on this frame.\n\
1210 All windows on current frame are arranged in a cyclic order.\n\
1211 This command selects the window ARG steps away in that order.\n\
1212 A negative ARG moves in the opposite order. If the optional second\n\
1213 argument ALL_FRAMES is non-nil, cycle through all frames.")
1215 register Lisp_Object arg
, all_frames
;
1218 register Lisp_Object w
;
1220 CHECK_NUMBER (arg
, 0);
1221 w
= selected_window
;
1226 w
= Fnext_window (w
, Qnil
, all_frames
);
1231 w
= Fprevious_window (w
, Qnil
, all_frames
);
1238 /* Look at all windows, performing an operation specified by TYPE
1240 If FRAMES is Qt, look at all frames;
1241 Qnil, look at just the selected frame;
1242 Qvisible, look at visible frames;
1243 a frame, just look at windows on that frame.
1244 If MINI is non-zero, perform the operation on minibuffer windows too.
1250 GET_BUFFER_WINDOW
, /* Arg is buffer */
1251 GET_LRU_WINDOW
, /* Arg is t for full-width windows only */
1252 DELETE_OTHER_WINDOWS
, /* Arg is window not to delete */
1253 DELETE_BUFFER_WINDOWS
, /* Arg is buffer */
1255 UNSHOW_BUFFER
/* Arg is buffer */
1259 window_loop (type
, obj
, mini
, frames
)
1260 enum window_loop type
;
1261 register Lisp_Object obj
, frames
;
1264 register Lisp_Object w
;
1265 register Lisp_Object best_window
;
1266 register Lisp_Object next_window
;
1267 register Lisp_Object last_window
;
1269 Lisp_Object frame_arg
;
1273 /* If we're only looping through windows on a particular frame,
1274 frame points to that frame. If we're looping through windows
1275 on all frames, frame is 0. */
1276 if (FRAMEP (frames
))
1277 frame
= XFRAME (frames
);
1278 else if (NILP (frames
))
1279 frame
= selected_frame
;
1283 frame_arg
= Qlambda
;
1284 else if (XFASTINT (frames
) == 0)
1286 else if (EQ (frames
, Qvisible
))
1292 /* frame_arg is Qlambda to stick to one frame,
1293 Qvisible to consider all visible frames,
1296 /* Pick a window to start with. */
1300 w
= FRAME_SELECTED_WINDOW (frame
);
1302 w
= FRAME_SELECTED_WINDOW (selected_frame
);
1304 /* Figure out the last window we're going to mess with. Since
1305 Fnext_window, given the same options, is guaranteed to go in a
1306 ring, we can just use Fprevious_window to find the last one.
1308 We can't just wait until we hit the first window again, because
1309 it might be deleted. */
1311 last_window
= Fprevious_window (w
, mini
? Qt
: Qnil
, frame_arg
);
1316 FRAME_PTR w_frame
= XFRAME (WINDOW_FRAME (XWINDOW (w
)));
1318 /* Pick the next window now, since some operations will delete
1319 the current window. */
1320 next_window
= Fnext_window (w
, mini
? Qt
: Qnil
, frame_arg
);
1322 /* Note that we do not pay attention here to whether
1323 the frame is visible, since Fnext_window skips non-visible frames
1324 if that is desired, under the control of frame_arg. */
1325 if (! MINI_WINDOW_P (XWINDOW (w
))
1326 || (mini
&& minibuf_level
> 0))
1329 case GET_BUFFER_WINDOW
:
1330 if (XBUFFER (XWINDOW (w
)->buffer
) == XBUFFER (obj
))
1334 case GET_LRU_WINDOW
:
1335 /* t as arg means consider only full-width windows */
1336 if (!NILP (obj
) && XFASTINT (XWINDOW (w
)->width
)
1337 != FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (w
)))))
1339 /* Ignore dedicated windows and minibuffers. */
1340 if (MINI_WINDOW_P (XWINDOW (w
))
1341 || !NILP (XWINDOW (w
)->dedicated
))
1343 if (NILP (best_window
)
1344 || (XFASTINT (XWINDOW (best_window
)->use_time
)
1345 > XFASTINT (XWINDOW (w
)->use_time
)))
1349 case DELETE_OTHER_WINDOWS
:
1350 if (XWINDOW (w
) != XWINDOW (obj
))
1354 case DELETE_BUFFER_WINDOWS
:
1355 if (EQ (XWINDOW (w
)->buffer
, obj
))
1358 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (w
)));
1360 /* If this window is dedicated, and in a frame of its own,
1362 if (EQ (w
, FRAME_ROOT_WINDOW (f
))
1363 && !NILP (XWINDOW (w
)->dedicated
)
1364 && other_visible_frames (f
))
1366 /* Skip the other windows on this frame.
1367 There might be one, the minibuffer! */
1368 if (! EQ (w
, last_window
))
1369 while (f
== XFRAME (WINDOW_FRAME (XWINDOW (next_window
))))
1371 /* As we go, check for the end of the loop.
1372 We mustn't start going around a second time. */
1373 if (EQ (next_window
, last_window
))
1378 next_window
= Fnext_window (next_window
,
1382 /* Now we can safely delete the frame. */
1383 Fdelete_frame (WINDOW_FRAME (XWINDOW (w
)), Qnil
);
1387 /* If we're deleting the buffer displayed in the only window
1388 on the frame, find a new buffer to display there. */
1389 if (NILP (XWINDOW (w
)->parent
))
1391 Lisp_Object new_buffer
;
1392 new_buffer
= Fother_buffer (obj
, Qnil
);
1393 if (NILP (new_buffer
))
1395 = Fget_buffer_create (build_string ("*scratch*"));
1396 Fset_window_buffer (w
, new_buffer
);
1397 if (EQ (w
, selected_window
))
1398 Fset_buffer (XWINDOW (w
)->buffer
);
1405 case GET_LARGEST_WINDOW
:
1406 /* Ignore dedicated windows and minibuffers. */
1407 if (MINI_WINDOW_P (XWINDOW (w
))
1408 || !NILP (XWINDOW (w
)->dedicated
))
1411 struct window
*best_window_ptr
= XWINDOW (best_window
);
1412 struct window
*w_ptr
= XWINDOW (w
);
1413 if (NILP (best_window
)
1414 || (XFASTINT (w_ptr
->height
) * XFASTINT (w_ptr
->width
)
1415 > (XFASTINT (best_window_ptr
->height
)
1416 * XFASTINT (best_window_ptr
->width
))))
1422 if (EQ (XWINDOW (w
)->buffer
, obj
))
1424 /* Find another buffer to show in this window. */
1425 Lisp_Object another_buffer
;
1426 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (w
)));
1427 another_buffer
= Fother_buffer (obj
, Qnil
);
1428 if (NILP (another_buffer
))
1430 = Fget_buffer_create (build_string ("*scratch*"));
1432 /* If this window is dedicated, and in a frame of its own,
1434 if (EQ (w
, FRAME_ROOT_WINDOW (f
))
1435 && !NILP (XWINDOW (w
)->dedicated
)
1436 && other_visible_frames (f
))
1438 /* Skip the other windows on this frame.
1439 There might be one, the minibuffer! */
1440 if (! EQ (w
, last_window
))
1441 while (f
== XFRAME (WINDOW_FRAME (XWINDOW (next_window
))))
1443 /* As we go, check for the end of the loop.
1444 We mustn't start going around a second time. */
1445 if (EQ (next_window
, last_window
))
1450 next_window
= Fnext_window (next_window
,
1454 /* Now we can safely delete the frame. */
1455 Fdelete_frame (WINDOW_FRAME (XWINDOW (w
)), Qnil
);
1460 /* Otherwise show a different buffer in the window. */
1461 XWINDOW (w
)->dedicated
= Qnil
;
1462 Fset_window_buffer (w
, another_buffer
);
1463 if (EQ (w
, selected_window
))
1464 Fset_buffer (XWINDOW (w
)->buffer
);
1470 if (EQ (w
, last_window
))
1479 DEFUN ("get-lru-window", Fget_lru_window
, Sget_lru_window
, 0, 1, 0,
1480 "Return the window least recently selected or used for display.\n\
1481 If optional argument FRAME is `visible', search all visible frames.\n\
1482 If FRAME is 0, search all visible and iconified frames.\n\
1483 If FRAME is t, search all frames.\n\
1484 If FRAME is nil, search only the selected frame.\n\
1485 If FRAME is a frame, search only that frame.")
1489 register Lisp_Object w
;
1490 /* First try for a window that is full-width */
1491 w
= window_loop (GET_LRU_WINDOW
, Qt
, 0, frame
);
1492 if (!NILP (w
) && !EQ (w
, selected_window
))
1494 /* If none of them, try the rest */
1495 return window_loop (GET_LRU_WINDOW
, Qnil
, 0, frame
);
1498 DEFUN ("get-largest-window", Fget_largest_window
, Sget_largest_window
, 0, 1, 0,
1499 "Return the largest window in area.\n\
1500 If optional argument FRAME is `visible', search all visible frames.\n\
1501 If FRAME is 0, search all visible and iconified frames.\n\
1502 If FRAME is t, search all frames.\n\
1503 If FRAME is nil, search only the selected frame.\n\
1504 If FRAME is a frame, search only that frame.")
1508 return window_loop (GET_LARGEST_WINDOW
, Qnil
, 0,
1512 DEFUN ("get-buffer-window", Fget_buffer_window
, Sget_buffer_window
, 1, 2, 0,
1513 "Return a window currently displaying BUFFER, or nil if none.\n\
1514 If optional argument FRAME is `visible', search all visible frames.\n\
1515 If optional argument FRAME is 0, search all visible and iconified frames.\n\
1516 If FRAME is t, search all frames.\n\
1517 If FRAME is nil, search only the selected frame.\n\
1518 If FRAME is a frame, search only that frame.")
1520 Lisp_Object buffer
, frame
;
1522 buffer
= Fget_buffer (buffer
);
1523 if (BUFFERP (buffer
))
1524 return window_loop (GET_BUFFER_WINDOW
, buffer
, 1, frame
);
1529 DEFUN ("delete-other-windows", Fdelete_other_windows
, Sdelete_other_windows
,
1531 "Make WINDOW (or the selected window) fill its frame.\n\
1532 Only the frame WINDOW is on is affected.\n\
1533 This function tries to reduce display jumps\n\
1534 by keeping the text previously visible in WINDOW\n\
1535 in the same place on the frame. Doing this depends on\n\
1536 the value of (window-start WINDOW), so if calling this function\n\
1537 in a program gives strange scrolling, make sure the window-start\n\
1538 value is reasonable when this function is called.")
1547 window
= selected_window
;
1549 CHECK_LIVE_WINDOW (window
, 0);
1551 w
= XWINDOW (window
);
1553 startpos
= marker_position (w
->start
);
1554 top
= XFASTINT (w
->top
) - FRAME_MENU_BAR_LINES (XFRAME (WINDOW_FRAME (w
)));
1556 if (MINI_WINDOW_P (w
) && top
> 0)
1557 error ("Can't expand minibuffer to full frame");
1559 window_loop (DELETE_OTHER_WINDOWS
, window
, 0, WINDOW_FRAME (w
));
1561 /* Try to minimize scrolling, by setting the window start to the point
1562 will cause the text at the old window start to be at the same place
1563 on the frame. But don't try to do this if the window start is
1564 outside the visible portion (as might happen when the display is
1565 not current, due to typeahead). */
1566 if (startpos
>= BUF_BEGV (XBUFFER (w
->buffer
))
1567 && startpos
<= BUF_ZV (XBUFFER (w
->buffer
)))
1569 struct position pos
;
1570 struct buffer
*obuf
= current_buffer
;
1572 Fset_buffer (w
->buffer
);
1573 /* This computation used to temporarily move point, but that can
1574 have unwanted side effects due to text properties. */
1575 pos
= *vmotion (startpos
, -top
, w
);
1576 Fset_marker (w
->start
, make_number (pos
.bufpos
), w
->buffer
);
1577 w
->start_at_line_beg
= ((pos
.bufpos
== BEGV
1578 || FETCH_CHAR (pos
.bufpos
- 1) == '\n') ? Qt
1580 /* We need to do this, so that the window-scroll-functions
1582 w
->force_start
= Qt
;
1584 set_buffer_internal (obuf
);
1589 DEFUN ("delete-windows-on", Fdelete_windows_on
, Sdelete_windows_on
,
1590 1, 2, "bDelete windows on (buffer): ",
1591 "Delete all windows showing BUFFER.\n\
1592 Optional second argument FRAME controls which frames are affected.\n\
1593 If nil or omitted, delete all windows showing BUFFER in any frame.\n\
1594 If t, delete only windows showing BUFFER in the selected frame.\n\
1595 If `visible', delete all windows showing BUFFER in any visible frame.\n\
1596 If a frame, delete only windows showing BUFFER in that frame.")
1598 Lisp_Object buffer
, frame
;
1601 /* FRAME uses t and nil to mean the opposite of what window_loop
1603 if (! FRAMEP (frame
))
1604 frame
= NILP (frame
) ? Qt
: Qnil
;
1611 buffer
= Fget_buffer (buffer
);
1612 CHECK_BUFFER (buffer
, 0);
1613 window_loop (DELETE_BUFFER_WINDOWS
, buffer
, 0, frame
);
1618 DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows
,
1619 Sreplace_buffer_in_windows
,
1620 1, 1, "bReplace buffer in windows: ",
1621 "Replace BUFFER with some other buffer in all windows showing it.")
1627 buffer
= Fget_buffer (buffer
);
1628 CHECK_BUFFER (buffer
, 0);
1629 window_loop (UNSHOW_BUFFER
, buffer
, 0, Qt
);
1634 /* Replace BUFFER with some other buffer in all windows
1635 of all frames, even those on other keyboards. */
1638 replace_buffer_in_all_windows (buffer
)
1642 Lisp_Object tail
, frame
;
1644 /* A single call to window_loop won't do the job
1645 because it only considers frames on the current keyboard.
1646 So loop manually over frames, and handle each one. */
1647 FOR_EACH_FRAME (tail
, frame
)
1648 window_loop (UNSHOW_BUFFER
, buffer
, 0, frame
);
1650 window_loop (UNSHOW_BUFFER
, buffer
, 0, Qt
);
1654 /* Set the height of WINDOW and all its inferiors. */
1656 /* The smallest acceptable dimensions for a window. Anything smaller
1657 might crash Emacs. */
1658 #define MIN_SAFE_WINDOW_WIDTH (2)
1659 #define MIN_SAFE_WINDOW_HEIGHT (2)
1661 /* Make sure that window_min_height and window_min_width are
1662 not too small; if they are, set them to safe minima. */
1665 check_min_window_sizes ()
1667 /* Smaller values might permit a crash. */
1668 if (window_min_width
< MIN_SAFE_WINDOW_WIDTH
)
1669 window_min_width
= MIN_SAFE_WINDOW_WIDTH
;
1670 if (window_min_height
< MIN_SAFE_WINDOW_HEIGHT
)
1671 window_min_height
= MIN_SAFE_WINDOW_HEIGHT
;
1674 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
1675 minimum allowable size. */
1677 check_frame_size (frame
, rows
, cols
)
1681 /* For height, we have to see:
1682 whether the frame has a minibuffer,
1683 whether it wants a mode line, and
1684 whether it has a menu bar. */
1686 (FRAME_MINIBUF_ONLY_P (frame
) ? MIN_SAFE_WINDOW_HEIGHT
- 1
1687 : (! FRAME_HAS_MINIBUF_P (frame
)) ? MIN_SAFE_WINDOW_HEIGHT
1688 : 2 * MIN_SAFE_WINDOW_HEIGHT
- 1);
1689 if (FRAME_MENU_BAR_LINES (frame
) > 0)
1690 min_height
+= FRAME_MENU_BAR_LINES (frame
);
1692 if (*rows
< min_height
)
1694 if (*cols
< MIN_SAFE_WINDOW_WIDTH
)
1695 *cols
= MIN_SAFE_WINDOW_WIDTH
;
1698 /* Normally the window is deleted if it gets too small.
1699 nodelete nonzero means do not do this.
1700 (The caller should check later and do so if appropriate) */
1702 set_window_height (window
, height
, nodelete
)
1707 register struct window
*w
= XWINDOW (window
);
1708 register struct window
*c
;
1709 int oheight
= XFASTINT (w
->height
);
1710 int top
, pos
, lastbot
, opos
, lastobot
;
1713 check_min_window_sizes ();
1716 && ! NILP (w
->parent
)
1717 && height
< window_min_height
)
1719 Fdelete_window (window
);
1723 XSETFASTINT (w
->last_modified
, 0);
1724 windows_or_buffers_changed
++;
1725 FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (w
))) = 1;
1727 XSETFASTINT (w
->height
, height
);
1728 if (!NILP (w
->hchild
))
1730 for (child
= w
->hchild
; !NILP (child
); child
= XWINDOW (child
)->next
)
1732 XWINDOW (child
)->top
= w
->top
;
1733 set_window_height (child
, height
, nodelete
);
1736 else if (!NILP (w
->vchild
))
1738 lastbot
= top
= XFASTINT (w
->top
);
1740 for (child
= w
->vchild
; !NILP (child
); child
= c
->next
)
1742 c
= XWINDOW (child
);
1744 opos
= lastobot
+ XFASTINT (c
->height
);
1746 XSETFASTINT (c
->top
, lastbot
);
1748 pos
= (((opos
* height
) << 1) + oheight
) / (oheight
<< 1);
1750 /* Avoid confusion: inhibit deletion of child if becomes too small */
1751 set_window_height (child
, pos
+ top
- lastbot
, 1);
1753 /* Now advance child to next window,
1754 and set lastbot if child was not just deleted. */
1755 lastbot
= pos
+ top
;
1758 /* Now delete any children that became too small. */
1760 for (child
= w
->vchild
; !NILP (child
); child
= XWINDOW (child
)->next
)
1762 set_window_height (child
, XINT (XWINDOW (child
)->height
), 0);
1767 /* Recursively set width of WINDOW and its inferiors. */
1769 set_window_width (window
, width
, nodelete
)
1774 register struct window
*w
= XWINDOW (window
);
1775 register struct window
*c
;
1776 int owidth
= XFASTINT (w
->width
);
1777 int left
, pos
, lastright
, opos
, lastoright
;
1780 if (!nodelete
&& width
< window_min_width
&& !NILP (w
->parent
))
1782 Fdelete_window (window
);
1786 XSETFASTINT (w
->last_modified
, 0);
1787 windows_or_buffers_changed
++;
1788 FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (w
))) = 1;
1790 XSETFASTINT (w
->width
, width
);
1791 if (!NILP (w
->vchild
))
1793 for (child
= w
->vchild
; !NILP (child
); child
= XWINDOW (child
)->next
)
1795 XWINDOW (child
)->left
= w
->left
;
1796 set_window_width (child
, width
, nodelete
);
1799 else if (!NILP (w
->hchild
))
1801 lastright
= left
= XFASTINT (w
->left
);
1803 for (child
= w
->hchild
; !NILP (child
); child
= c
->next
)
1805 c
= XWINDOW (child
);
1807 opos
= lastoright
+ XFASTINT (c
->width
);
1809 XSETFASTINT (c
->left
, lastright
);
1811 pos
= (((opos
* width
) << 1) + owidth
) / (owidth
<< 1);
1813 /* Inhibit deletion for becoming too small */
1814 set_window_width (child
, pos
+ left
- lastright
, 1);
1816 /* Now advance child to next window,
1817 and set lastright if child was not just deleted. */
1818 lastright
= pos
+ left
, lastoright
= opos
;
1820 /* Delete children that became too small */
1822 for (child
= w
->hchild
; !NILP (child
); child
= XWINDOW (child
)->next
)
1824 set_window_width (child
, XINT (XWINDOW (child
)->width
), 0);
1829 int window_select_count
;
1832 Fset_window_buffer_unwind (obuf
)
1839 DEFUN ("set-window-buffer", Fset_window_buffer
, Sset_window_buffer
, 2, 2, 0,
1840 "Make WINDOW display BUFFER as its contents.\n\
1841 BUFFER can be a buffer or buffer name.")
1843 register Lisp_Object window
, buffer
;
1845 register Lisp_Object tem
;
1846 register struct window
*w
= decode_window (window
);
1847 int count
= specpdl_ptr
- specpdl
;
1849 buffer
= Fget_buffer (buffer
);
1850 CHECK_BUFFER (buffer
, 1);
1852 if (NILP (XBUFFER (buffer
)->name
))
1853 error ("Attempt to display deleted buffer");
1857 error ("Window is deleted");
1858 else if (! EQ (tem
, Qt
)) /* w->buffer is t when the window
1859 is first being set up. */
1861 if (!NILP (w
->dedicated
) && !EQ (tem
, buffer
))
1862 error ("Window is dedicated to `%s'",
1863 XSTRING (XBUFFER (tem
)->name
)->data
);
1869 XSETFASTINT (w
->window_end_pos
, 0);
1870 w
->window_end_valid
= Qnil
;
1871 XSETFASTINT (w
->hscroll
, 0);
1872 Fset_marker (w
->pointm
,
1873 make_number (BUF_PT (XBUFFER (buffer
))),
1875 set_marker_restricted (w
->start
,
1876 make_number (XBUFFER (buffer
)->last_window_start
),
1878 w
->start_at_line_beg
= Qnil
;
1879 w
->force_start
= Qnil
;
1880 XSETFASTINT (w
->last_modified
, 0);
1881 windows_or_buffers_changed
++;
1883 /* We must select BUFFER for running the window-scroll-functions.
1884 If WINDOW is selected, switch permanently.
1885 Otherwise, switch but go back to the ambient buffer afterward. */
1886 if (EQ (window
, selected_window
))
1887 Fset_buffer (buffer
);
1888 /* We can't check ! NILP (Vwindow_scroll_functions) here
1889 because that might itself be a local variable. */
1890 else if (window_initialized
)
1892 record_unwind_protect (Fset_window_buffer_unwind
, Fcurrent_buffer ());
1893 Fset_buffer (buffer
);
1896 if (! NILP (Vwindow_scroll_functions
))
1897 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
1898 Fmarker_position (w
->start
));
1900 unbind_to (count
, Qnil
);
1905 DEFUN ("select-window", Fselect_window
, Sselect_window
, 1, 1, 0,
1906 "Select WINDOW. Most editing will apply to WINDOW's buffer.\n\
1907 The main editor command loop selects the buffer of the selected window\n\
1908 before each command.")
1910 register Lisp_Object window
;
1912 register struct window
*w
;
1913 register struct window
*ow
= XWINDOW (selected_window
);
1915 CHECK_LIVE_WINDOW (window
, 0);
1917 w
= XWINDOW (window
);
1919 if (NILP (w
->buffer
))
1920 error ("Trying to select deleted window or non-leaf window");
1922 XSETFASTINT (w
->use_time
, ++window_select_count
);
1923 if (EQ (window
, selected_window
))
1926 Fset_marker (ow
->pointm
, make_number (BUF_PT (XBUFFER (ow
->buffer
))),
1929 selected_window
= window
;
1931 if (XFRAME (WINDOW_FRAME (w
)) != selected_frame
)
1933 XFRAME (WINDOW_FRAME (w
))->selected_window
= window
;
1934 /* Use this rather than Fhandle_switch_frame
1935 so that FRAME_FOCUS_FRAME is moved appropriately as we
1936 move around in the state where a minibuffer in a separate
1938 Fselect_frame (WINDOW_FRAME (w
), Qnil
);
1941 selected_frame
->selected_window
= window
;
1944 record_buffer (w
->buffer
);
1945 Fset_buffer (w
->buffer
);
1947 /* Go to the point recorded in the window.
1948 This is important when the buffer is in more
1949 than one window. It also matters when
1950 redisplay_window has altered point after scrolling,
1951 because it makes the change only in the window. */
1953 register int new_point
= marker_position (w
->pointm
);
1954 if (new_point
< BEGV
)
1956 else if (new_point
> ZV
)
1962 windows_or_buffers_changed
++;
1966 /* Deiconify the frame containing the window WINDOW,
1967 unless it is the selected frame;
1970 The reason for the exception for the selected frame
1971 is that it seems better not to change the selected frames visibility
1972 merely because of displaying a different buffer in it.
1973 The deiconification is useful when a buffer gets shown in
1974 another frame that you were not using lately. */
1977 display_buffer_1 (window
)
1981 FRAME_PTR f
= XFRAME (WINDOW_FRAME (XWINDOW (window
)));
1982 FRAME_SAMPLE_VISIBILITY (f
);
1983 if (f
!= selected_frame
)
1985 if (FRAME_ICONIFIED_P (f
))
1986 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window
)));
1987 else if (FRAME_VISIBLE_P (f
))
1988 Fraise_frame (WINDOW_FRAME (XWINDOW (window
)));
1994 DEFUN ("display-buffer", Fdisplay_buffer
, Sdisplay_buffer
, 1, 2,
1995 "bDisplay buffer: \nP",
1996 "Make BUFFER appear in some window but don't select it.\n\
1997 BUFFER can be a buffer or a buffer name.\n\
1998 If BUFFER is shown already in some window, just use that one,\n\
1999 unless the window is the selected window and the optional second\n\
2000 argument NOT-THIS-WINDOW is non-nil (interactively, with prefix arg).\n\
2001 If `pop-up-frames' is non-nil, make a new frame if no window shows BUFFER.\n\
2002 Returns the window displaying BUFFER.\n\
2004 The variables `special-display-buffer-names', `special-display-regexps',\n\
2005 `same-window-buffer-names', and `same-window-regexps' customize how certain\n\
2006 buffer names are handled.")
2007 (buffer
, not_this_window
)
2008 register Lisp_Object buffer
, not_this_window
;
2010 register Lisp_Object window
, tem
;
2012 buffer
= Fget_buffer (buffer
);
2013 CHECK_BUFFER (buffer
, 0);
2015 if (!NILP (Vdisplay_buffer_function
))
2016 return call2 (Vdisplay_buffer_function
, buffer
, not_this_window
);
2018 if (NILP (not_this_window
)
2019 && XBUFFER (XWINDOW (selected_window
)->buffer
) == XBUFFER (buffer
))
2020 return display_buffer_1 (selected_window
);
2022 /* See if the user has specified this buffer should appear
2023 in the selected window. */
2024 if (NILP (not_this_window
))
2026 tem
= Fmember (XBUFFER (buffer
)->name
, Vsame_window_buffer_names
);
2029 Fswitch_to_buffer (buffer
, Qnil
);
2030 return display_buffer_1 (selected_window
);
2033 tem
= Fassoc (XBUFFER (buffer
)->name
, Vsame_window_buffer_names
);
2036 Fswitch_to_buffer (buffer
, Qnil
);
2037 return display_buffer_1 (selected_window
);
2040 for (tem
= Vsame_window_regexps
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
2042 Lisp_Object car
= XCONS (tem
)->car
;
2044 && fast_string_match (car
, XBUFFER (buffer
)->name
) >= 0)
2046 Fswitch_to_buffer (buffer
, Qnil
);
2047 return display_buffer_1 (selected_window
);
2049 else if (CONSP (car
)
2050 && STRINGP (XCONS (car
)->car
)
2051 && fast_string_match (XCONS (car
)->car
,
2052 XBUFFER (buffer
)->name
) >= 0)
2054 Fswitch_to_buffer (buffer
, Qnil
);
2055 return display_buffer_1 (selected_window
);
2061 /* If pop_up_frames,
2062 look for a window showing BUFFER on any visible or iconified frame.
2063 Otherwise search only the current frame. */
2064 if (pop_up_frames
|| last_nonminibuf_frame
== 0)
2065 XSETFASTINT (tem
, 0);
2068 XSETFRAME (tem
, last_nonminibuf_frame
);
2069 window
= Fget_buffer_window (buffer
, tem
);
2071 && (NILP (not_this_window
) || !EQ (window
, selected_window
)))
2073 return display_buffer_1 (window
);
2076 /* Certain buffer names get special handling. */
2077 if (! NILP (Vspecial_display_function
))
2079 tem
= Fmember (XBUFFER (buffer
)->name
, Vspecial_display_buffer_names
);
2081 return call1 (Vspecial_display_function
, buffer
);
2083 tem
= Fassoc (XBUFFER (buffer
)->name
, Vspecial_display_buffer_names
);
2085 return call2 (Vspecial_display_function
, buffer
, XCONS (tem
)->cdr
);
2087 for (tem
= Vspecial_display_regexps
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
2089 Lisp_Object car
= XCONS (tem
)->car
;
2091 && fast_string_match (car
, XBUFFER (buffer
)->name
) >= 0)
2092 return call1 (Vspecial_display_function
, buffer
);
2093 else if (CONSP (car
)
2094 && STRINGP (XCONS (car
)->car
)
2095 && fast_string_match (XCONS (car
)->car
,
2096 XBUFFER (buffer
)->name
) >= 0)
2097 return call2 (Vspecial_display_function
,
2104 /* If there are no frames open that have more than a minibuffer,
2105 we need to create a new frame. */
2106 if (pop_up_frames
|| last_nonminibuf_frame
== 0)
2108 window
= Fframe_selected_window (call0 (Vpop_up_frame_function
));
2109 Fset_window_buffer (window
, buffer
);
2110 return display_buffer_1 (window
);
2112 #endif /* MULTI_FRAME */
2116 || FRAME_MINIBUF_ONLY_P (selected_frame
)
2117 /* If the current frame is a special display frame,
2118 don't try to reuse its windows. */
2119 || !NILP (XWINDOW (FRAME_ROOT_WINDOW (selected_frame
))->dedicated
)
2127 if (FRAME_MINIBUF_ONLY_P (selected_frame
))
2128 XSETFRAME (frames
, last_nonminibuf_frame
);
2130 /* Don't try to create a window if would get an error */
2131 if (split_height_threshold
< window_min_height
<< 1)
2132 split_height_threshold
= window_min_height
<< 1;
2134 /* Note that both Fget_largest_window and Fget_lru_window
2135 ignore minibuffers and dedicated windows.
2136 This means they can return nil. */
2139 /* If the frame we would try to split cannot be split,
2140 try other frames. */
2141 if (FRAME_NO_SPLIT_P (NILP (frames
) ? selected_frame
2142 : last_nonminibuf_frame
))
2144 /* Try visible frames first. */
2145 window
= Fget_largest_window (Qvisible
);
2146 /* If that didn't work, try iconified frames. */
2148 window
= Fget_largest_window (make_number (0));
2150 window
= Fget_largest_window (Qt
);
2154 window
= Fget_largest_window (frames
);
2156 /* If we got a tall enough full-width window that can be split,
2159 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window
)->frame
))
2160 && window_height (window
) >= split_height_threshold
2161 && (XFASTINT (XWINDOW (window
)->width
)
2162 == FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (window
))))))
2163 window
= Fsplit_window (window
, Qnil
, Qnil
);
2166 Lisp_Object upper
, lower
, other
;
2168 window
= Fget_lru_window (frames
);
2169 /* If the LRU window is selected, and big enough,
2170 and can be split, split it. */
2172 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window
)->frame
))
2173 && (EQ (window
, selected_window
)
2174 || EQ (XWINDOW (window
)->parent
, Qnil
))
2175 && window_height (window
) >= window_min_height
<< 1)
2176 window
= Fsplit_window (window
, Qnil
, Qnil
);
2178 /* If Fget_lru_window returned nil, try other approaches. */
2179 /* Try visible frames first. */
2181 window
= Fget_largest_window (Qvisible
);
2182 /* If that didn't work, try iconified frames. */
2184 window
= Fget_largest_window (make_number (0));
2185 /* Try invisible frames. */
2187 window
= Fget_largest_window (Qt
);
2188 /* As a last resort, make a new frame. */
2190 window
= Fframe_selected_window (call0 (Vpop_up_frame_function
));
2192 /* As a last resort, use a non minibuffer window. */
2194 window
= Fframe_first_window (Fselected_frame ());
2196 /* If window appears above or below another,
2197 even out their heights. */
2198 other
= upper
= lower
= Qnil
;
2199 if (!NILP (XWINDOW (window
)->prev
))
2200 other
= upper
= XWINDOW (window
)->prev
, lower
= window
;
2201 if (!NILP (XWINDOW (window
)->next
))
2202 other
= lower
= XWINDOW (window
)->next
, upper
= window
;
2204 /* Check that OTHER and WINDOW are vertically arrayed. */
2205 && XWINDOW (other
)->top
!= XWINDOW (window
)->top
2206 && XWINDOW (other
)->height
> XWINDOW (window
)->height
)
2208 int total
= XWINDOW (other
)->height
+ XWINDOW (window
)->height
;
2209 Lisp_Object old_selected_window
;
2210 old_selected_window
= selected_window
;
2212 selected_window
= upper
;
2213 change_window_height (total
/ 2 - XWINDOW (upper
)->height
, 0);
2214 selected_window
= old_selected_window
;
2219 window
= Fget_lru_window (Qnil
);
2221 Fset_window_buffer (window
, buffer
);
2222 return display_buffer_1 (window
);
2226 temp_output_buffer_show (buf
)
2227 register Lisp_Object buf
;
2229 register struct buffer
*old
= current_buffer
;
2230 register Lisp_Object window
;
2231 register struct window
*w
;
2234 BUF_SAVE_MODIFF (XBUFFER (buf
)) = MODIFF
;
2238 XBUFFER (buf
)->clip_changed
= 1;
2239 set_buffer_internal (old
);
2241 if (!EQ (Vtemp_buffer_show_function
, Qnil
))
2242 call1 (Vtemp_buffer_show_function
, buf
);
2245 window
= Fdisplay_buffer (buf
, Qnil
);
2248 if (XFRAME (XWINDOW (window
)->frame
) != selected_frame
)
2249 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window
)));
2250 #endif /* MULTI_FRAME */
2251 Vminibuf_scroll_window
= window
;
2252 w
= XWINDOW (window
);
2253 XSETFASTINT (w
->hscroll
, 0);
2254 set_marker_restricted (w
->start
, make_number (1), buf
);
2255 set_marker_restricted (w
->pointm
, make_number (1), buf
);
2257 /* Run temp-buffer-show-hook, with the chosen window selected. */
2258 if (!NILP (Vrun_hooks
))
2261 tem
= Fboundp (Qtemp_buffer_show_hook
);
2264 tem
= Fsymbol_value (Qtemp_buffer_show_hook
);
2267 int count
= specpdl_ptr
- specpdl
;
2269 /* Select the window that was chosen, for running the hook. */
2270 record_unwind_protect (Fset_window_configuration
,
2271 Fcurrent_window_configuration (Qnil
));
2273 Fselect_window (window
);
2274 call1 (Vrun_hooks
, Qtemp_buffer_show_hook
);
2275 unbind_to (count
, Qnil
);
2283 make_dummy_parent (window
)
2287 register struct window
*o
, *p
;
2288 register struct Lisp_Vector
*vec
;
2291 o
= XWINDOW (window
);
2292 vec
= allocate_vectorlike ((EMACS_INT
)VECSIZE (struct window
));
2293 for (i
= 0; i
< VECSIZE (struct window
); ++i
)
2294 vec
->contents
[i
] = ((struct Lisp_Vector
*)o
)->contents
[i
];
2295 vec
->size
= VECSIZE (struct window
);
2296 p
= (struct window
*)vec
;
2297 XSETWINDOW (new, p
);
2299 XSETFASTINT (p
->sequence_number
, ++sequence_number
);
2301 /* Put new into window structure in place of window */
2302 replace_window (window
, new);
2315 DEFUN ("split-window", Fsplit_window
, Ssplit_window
, 0, 3, "",
2316 "Split WINDOW, putting SIZE lines in the first of the pair.\n\
2317 WINDOW defaults to selected one and SIZE to half its size.\n\
2318 If optional third arg HORFLAG is non-nil, split side by side\n\
2319 and put SIZE columns in the first of the pair.")
2320 (window
, size
, horflag
)
2321 Lisp_Object window
, size
, horflag
;
2323 register Lisp_Object
new;
2324 register struct window
*o
, *p
;
2326 register int size_int
;
2328 int separator_width
= 1;
2331 window
= selected_window
;
2333 CHECK_LIVE_WINDOW (window
, 0);
2335 o
= XWINDOW (window
);
2336 fo
= XFRAME (WINDOW_FRAME (o
));
2337 if (FRAME_HAS_VERTICAL_SCROLL_BARS (fo
))
2338 separator_width
= FRAME_SCROLL_BAR_COLS (fo
);
2339 internal_width
= window_internal_width (o
);
2343 if (!NILP (horflag
))
2344 /* Calculate the size of the left-hand window, by dividing
2345 the usable space in columns by two. */
2346 size_int
= (internal_width
- separator_width
) >> 1;
2348 size_int
= XFASTINT (o
->height
) >> 1;
2352 CHECK_NUMBER (size
, 1);
2353 size_int
= XINT (size
);
2356 if (MINI_WINDOW_P (o
))
2357 error ("Attempt to split minibuffer window");
2358 else if (FRAME_NO_SPLIT_P (fo
))
2359 error ("Attempt to split unsplittable frame");
2361 check_min_window_sizes ();
2365 if (size_int
< window_min_height
)
2366 error ("Window height %d too small (after splitting)", size_int
);
2367 if (size_int
+ window_min_height
> XFASTINT (o
->height
))
2368 error ("Window height %d too small (after splitting)",
2369 XFASTINT (o
->height
) - size_int
);
2370 if (NILP (o
->parent
)
2371 || NILP (XWINDOW (o
->parent
)->vchild
))
2373 make_dummy_parent (window
);
2375 XWINDOW (new)->vchild
= window
;
2380 if (size_int
< window_min_width
)
2381 error ("Window width %d too small (after splitting)", size_int
);
2382 if (internal_width
- size_int
- separator_width
< window_min_width
)
2383 error ("Window width %d too small (after splitting)",
2384 internal_width
- size_int
- separator_width
);
2385 if (NILP (o
->parent
)
2386 || NILP (XWINDOW (o
->parent
)->hchild
))
2388 make_dummy_parent (window
);
2390 XWINDOW (new)->hchild
= window
;
2394 /* Now we know that window's parent is a vertical combination
2395 if we are dividing vertically, or a horizontal combination
2396 if we are making side-by-side windows */
2398 windows_or_buffers_changed
++;
2399 FRAME_WINDOW_SIZES_CHANGED (fo
) = 1;
2400 new = make_window ();
2403 p
->frame
= o
->frame
;
2405 if (!NILP (p
->next
))
2406 XWINDOW (p
->next
)->prev
= new;
2409 p
->parent
= o
->parent
;
2412 Fset_window_buffer (new, o
->buffer
);
2414 /* Apportion the available frame space among the two new windows */
2416 if (!NILP (horflag
))
2418 p
->height
= o
->height
;
2420 size_int
+= separator_width
;
2421 XSETFASTINT (p
->width
, internal_width
- size_int
);
2422 XSETFASTINT (o
->width
, size_int
);
2423 XSETFASTINT (p
->left
, XFASTINT (o
->left
) + size_int
);
2428 p
->width
= o
->width
;
2429 XSETFASTINT (p
->height
, XFASTINT (o
->height
) - size_int
);
2430 XSETFASTINT (o
->height
, size_int
);
2431 XSETFASTINT (p
->top
, XFASTINT (o
->top
) + size_int
);
2437 DEFUN ("enlarge-window", Fenlarge_window
, Senlarge_window
, 1, 2, "p",
2438 "Make current window ARG lines bigger.\n\
2439 From program, optional second arg non-nil means grow sideways ARG columns.")
2441 register Lisp_Object arg
, side
;
2443 CHECK_NUMBER (arg
, 0);
2444 change_window_height (XINT (arg
), !NILP (side
));
2448 DEFUN ("shrink-window", Fshrink_window
, Sshrink_window
, 1, 2, "p",
2449 "Make current window ARG lines smaller.\n\
2450 From program, optional second arg non-nil means shrink sideways arg columns.")
2452 register Lisp_Object arg
, side
;
2454 CHECK_NUMBER (arg
, 0);
2455 change_window_height (-XINT (arg
), !NILP (side
));
2460 window_height (window
)
2463 register struct window
*p
= XWINDOW (window
);
2464 return XFASTINT (p
->height
);
2468 window_width (window
)
2471 register struct window
*p
= XWINDOW (window
);
2472 return XFASTINT (p
->width
);
2475 #define MINSIZE(w) \
2477 ? window_min_width \
2478 : (MINI_WINDOW_P (XWINDOW (w)) ? 1 : window_min_height))
2481 *(widthflag ? (int *) &(XWINDOW (w)->left) : (int *) &(XWINDOW (w)->top))
2483 #define CURSIZE(w) \
2484 *(widthflag ? (int *) &(XWINDOW (w)->width) : (int *) &(XWINDOW (w)->height))
2486 /* Unlike set_window_height, this function
2487 also changes the heights of the siblings so as to
2488 keep everything consistent. */
2490 change_window_height (delta
, widthflag
)
2494 register Lisp_Object parent
;
2496 register struct window
*p
;
2498 int (*sizefun
) () = widthflag
? window_width
: window_height
;
2499 register int (*setsizefun
) () = (widthflag
2501 : set_window_height
);
2503 check_min_window_sizes ();
2505 window
= selected_window
;
2508 p
= XWINDOW (window
);
2513 error ("No other window to side of this one");
2516 if (widthflag
? !NILP (XWINDOW (parent
)->hchild
)
2517 : !NILP (XWINDOW (parent
)->vchild
))
2522 sizep
= &CURSIZE (window
);
2525 register int maxdelta
;
2527 maxdelta
= (!NILP (parent
) ? (*sizefun
) (parent
) - *sizep
2528 : !NILP (p
->next
) ? (*sizefun
) (p
->next
) - MINSIZE (p
->next
)
2529 : !NILP (p
->prev
) ? (*sizefun
) (p
->prev
) - MINSIZE (p
->prev
)
2530 /* This is a frame with only one window, a minibuffer-only
2531 or a minibufferless frame. */
2534 if (delta
> maxdelta
)
2535 /* This case traps trying to make the minibuffer
2536 the full frame, or make the only window aside from the
2537 minibuffer the full frame. */
2541 if (*sizep
+ delta
< MINSIZE (window
))
2543 Fdelete_window (window
);
2551 && (*sizefun
) (p
->next
) - delta
>= MINSIZE (p
->next
))
2553 (*setsizefun
) (p
->next
, (*sizefun
) (p
->next
) - delta
, 0);
2554 (*setsizefun
) (window
, *sizep
+ delta
, 0);
2555 CURBEG (p
->next
) += delta
;
2556 /* This does not change size of p->next,
2557 but it propagates the new top edge to its children */
2558 (*setsizefun
) (p
->next
, (*sizefun
) (p
->next
), 0);
2560 else if (!NILP (p
->prev
)
2561 && (*sizefun
) (p
->prev
) - delta
>= MINSIZE (p
->prev
))
2563 (*setsizefun
) (p
->prev
, (*sizefun
) (p
->prev
) - delta
, 0);
2564 CURBEG (window
) -= delta
;
2565 (*setsizefun
) (window
, *sizep
+ delta
, 0);
2569 register int delta1
;
2570 register int opht
= (*sizefun
) (parent
);
2572 /* If trying to grow this window to or beyond size of the parent,
2573 make delta1 so big that, on shrinking back down,
2574 all the siblings end up with less than one line and are deleted. */
2575 if (opht
<= *sizep
+ delta
)
2576 delta1
= opht
* opht
* 2;
2577 /* Otherwise, make delta1 just right so that if we add delta1
2578 lines to this window and to the parent, and then shrink
2579 the parent back to its original size, the new proportional
2580 size of this window will increase by delta. */
2582 delta1
= (delta
* opht
* 100) / ((opht
- *sizep
- delta
) * 100);
2584 /* Add delta1 lines or columns to this window, and to the parent,
2585 keeping things consistent while not affecting siblings. */
2586 CURSIZE (parent
) = opht
+ delta1
;
2587 (*setsizefun
) (window
, *sizep
+ delta1
, 0);
2589 /* Squeeze out delta1 lines or columns from our parent,
2590 shriking this window and siblings proportionately.
2591 This brings parent back to correct size.
2592 Delta1 was calculated so this makes this window the desired size,
2593 taking it all out of the siblings. */
2594 (*setsizefun
) (parent
, opht
, 0);
2597 XSETFASTINT (p
->last_modified
, 0);
2604 /* Return number of lines of text (not counting mode line) in W. */
2607 window_internal_height (w
)
2610 int ht
= XFASTINT (w
->height
);
2612 if (MINI_WINDOW_P (w
))
2615 if (!NILP (w
->parent
) || !NILP (w
->vchild
) || !NILP (w
->hchild
)
2616 || !NILP (w
->next
) || !NILP (w
->prev
)
2617 || FRAME_WANTS_MODELINE_P (XFRAME (WINDOW_FRAME (w
))))
2624 /* Return the number of columns in W.
2625 Don't count columns occupied by scroll bars or the vertical bar
2626 separating W from the sibling to its right. */
2628 window_internal_width (w
)
2631 FRAME_PTR f
= XFRAME (WINDOW_FRAME (w
));
2632 int left
= XINT (w
->left
);
2633 int width
= XINT (w
->width
);
2635 /* If this window is flush against the right edge of the frame, its
2636 internal width is its full width. */
2637 if (left
+ width
>= FRAME_WIDTH (f
))
2640 /* If we are not flush right, then our rightmost columns are
2641 occupied by some sort of separator. */
2643 /* Scroll bars occupy a few columns. */
2644 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f
))
2645 return width
- FRAME_SCROLL_BAR_COLS (f
);
2647 /* The column of `|' characters separating side-by-side windows
2648 occupies one column only. */
2653 /* Scroll contents of window WINDOW up N lines. */
2656 window_scroll (window
, n
, noerror
)
2661 register struct window
*w
= XWINDOW (window
);
2662 register int opoint
= PT
;
2664 register int ht
= window_internal_height (w
);
2665 register Lisp_Object tem
;
2667 Lisp_Object bolp
, nmoved
;
2669 /* Always set force_start so that redisplay_window will run
2670 the window-scroll-functions. */
2671 w
->force_start
= Qt
;
2673 XSETFASTINT (tem
, PT
);
2674 tem
= Fpos_visible_in_window_p (tem
, window
);
2678 Fvertical_motion (make_number (- (ht
/ 2)), window
);
2679 XSETFASTINT (tem
, PT
);
2680 Fset_marker (w
->start
, tem
, w
->buffer
);
2683 SET_PT (marker_position (w
->start
));
2684 lose
= n
< 0 && PT
== BEGV
;
2685 Fvertical_motion (make_number (n
), window
);
2695 Fsignal (Qbeginning_of_buffer
, Qnil
);
2700 set_marker_restricted (w
->start
, make_number (pos
), w
->buffer
);
2701 w
->start_at_line_beg
= bolp
;
2702 w
->update_mode_line
= Qt
;
2703 XSETFASTINT (w
->last_modified
, 0);
2709 tem
= Fvertical_motion (make_number (ht
), window
);
2710 if (PT
> opoint
|| XFASTINT (tem
) < ht
)
2713 Fvertical_motion (make_number (-1), window
);
2721 Fsignal (Qend_of_buffer
, Qnil
);
2725 /* This is the guts of Fscroll_up and Fscroll_down. */
2728 scroll_command (n
, direction
)
2729 register Lisp_Object n
;
2732 register int defalt
;
2733 int count
= specpdl_ptr
- specpdl
;
2735 /* If selected window's buffer isn't current, make it current for the moment.
2736 But don't screw up if window_scroll gets an error. */
2737 if (XBUFFER (XWINDOW (selected_window
)->buffer
) != current_buffer
)
2739 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
2740 Fset_buffer (XWINDOW (selected_window
)->buffer
);
2743 defalt
= (window_internal_height (XWINDOW (selected_window
))
2744 - next_screen_context_lines
);
2745 defalt
= direction
* (defalt
< 1 ? 1 : defalt
);
2748 window_scroll (selected_window
, defalt
, 0);
2749 else if (EQ (n
, Qminus
))
2750 window_scroll (selected_window
, - defalt
, 0);
2753 n
= Fprefix_numeric_value (n
);
2754 window_scroll (selected_window
, XINT (n
) * direction
, 0);
2757 unbind_to (count
, Qnil
);
2760 DEFUN ("scroll-up", Fscroll_up
, Sscroll_up
, 0, 1, "P",
2761 "Scroll text of current window upward ARG lines; or near full screen if no ARG.\n\
2762 A near full screen is `next-screen-context-lines' less than a full screen.\n\
2763 Negative ARG means scroll downward.\n\
2764 When calling from a program, supply a number as argument or nil.")
2768 scroll_command (arg
, 1);
2772 DEFUN ("scroll-down", Fscroll_down
, Sscroll_down
, 0, 1, "P",
2773 "Scroll text of current window downward ARG lines; or near full screen if no ARG.\n\
2774 A near full screen is `next-screen-context-lines' less than a full screen.\n\
2775 Negative ARG means scroll upward.\n\
2776 When calling from a program, supply a number as argument or nil.")
2780 scroll_command (arg
, -1);
2784 DEFUN ("other-window-for-scrolling", Fother_window_for_scrolling
, Sother_window_for_scrolling
, 0, 0, 0,
2785 "Return the other window for \"other window scroll\" commands.\n\
2786 If in the minibuffer, `minibuffer-scroll-window' if non-nil\n\
2787 specifies the window.\n\
2788 If `other-window-scroll-buffer' is non-nil, a window\n\
2789 showing that buffer is used.")
2794 if (MINI_WINDOW_P (XWINDOW (selected_window
))
2795 && !NILP (Vminibuf_scroll_window
))
2796 window
= Vminibuf_scroll_window
;
2797 /* If buffer is specified, scroll that buffer. */
2798 else if (!NILP (Vother_window_scroll_buffer
))
2800 window
= Fget_buffer_window (Vother_window_scroll_buffer
, Qnil
);
2802 window
= Fdisplay_buffer (Vother_window_scroll_buffer
, Qt
);
2806 /* Nothing specified; look for a neighboring window on the same
2808 window
= Fnext_window (selected_window
, Qnil
, Qnil
);
2810 if (EQ (window
, selected_window
))
2811 /* That didn't get us anywhere; look for a window on another
2814 window
= Fnext_window (window
, Qnil
, Qt
);
2815 while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window
))))
2816 && ! EQ (window
, selected_window
));
2819 CHECK_LIVE_WINDOW (window
, 0);
2821 if (EQ (window
, selected_window
))
2822 error ("There is no other window");
2827 DEFUN ("scroll-other-window", Fscroll_other_window
, Sscroll_other_window
, 0, 1, "P",
2828 "Scroll next window upward ARG lines; or near full screen if no ARG.\n\
2829 The next window is the one below the current one; or the one at the top\n\
2830 if the current one is at the bottom. Negative ARG means scroll downward.\n\
2831 When calling from a program, supply a number as argument or nil.\n\
2833 If in the minibuffer, `minibuffer-scroll-window' if non-nil\n\
2834 specifies the window to scroll.\n\
2835 If `other-window-scroll-buffer' is non-nil, scroll the window\n\
2836 showing that buffer, popping the buffer up if necessary.")
2838 register Lisp_Object arg
;
2840 register Lisp_Object window
;
2841 register int defalt
;
2842 register struct window
*w
;
2843 register int count
= specpdl_ptr
- specpdl
;
2845 window
= Fother_window_for_scrolling ();
2847 w
= XWINDOW (window
);
2848 defalt
= window_internal_height (w
) - next_screen_context_lines
;
2849 if (defalt
< 1) defalt
= 1;
2851 /* Don't screw up if window_scroll gets an error. */
2852 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
2854 Fset_buffer (w
->buffer
);
2855 SET_PT (marker_position (w
->pointm
));
2858 window_scroll (window
, defalt
, 1);
2859 else if (EQ (arg
, Qminus
))
2860 window_scroll (window
, -defalt
, 1);
2865 CHECK_NUMBER (arg
, 0);
2866 window_scroll (window
, XINT (arg
), 1);
2869 Fset_marker (w
->pointm
, make_number (PT
), Qnil
);
2870 unbind_to (count
, Qnil
);
2875 DEFUN ("scroll-left", Fscroll_left
, Sscroll_left
, 0, 1, "P",
2876 "Scroll selected window display ARG columns left.\n\
2877 Default for ARG is window width minus 2.")
2879 register Lisp_Object arg
;
2883 XSETFASTINT (arg
, window_internal_width (XWINDOW (selected_window
)) - 2);
2885 arg
= Fprefix_numeric_value (arg
);
2888 Fset_window_hscroll (selected_window
,
2889 make_number (XINT (XWINDOW (selected_window
)->hscroll
)
2893 DEFUN ("scroll-right", Fscroll_right
, Sscroll_right
, 0, 1, "P",
2894 "Scroll selected window display ARG columns right.\n\
2895 Default for ARG is window width minus 2.")
2897 register Lisp_Object arg
;
2900 XSETFASTINT (arg
, window_internal_width (XWINDOW (selected_window
)) - 2);
2902 arg
= Fprefix_numeric_value (arg
);
2905 Fset_window_hscroll (selected_window
,
2906 make_number (XINT (XWINDOW (selected_window
)->hscroll
)
2910 DEFUN ("recenter", Frecenter
, Srecenter
, 0, 1, "P",
2911 "Center point in window and redisplay frame. With ARG, put point on line ARG.\n\
2912 The desired position of point is always relative to the current window.\n\
2913 Just C-u as prefix means put point in the center of the window.\n\
2914 If ARG is omitted or nil, erases the entire frame and then\n\
2915 redraws with point in the center of the current window.")
2917 register Lisp_Object arg
;
2919 register struct window
*w
= XWINDOW (selected_window
);
2920 register int ht
= window_internal_height (w
);
2921 struct position pos
;
2925 extern int frame_garbaged
;
2927 SET_FRAME_GARBAGED (XFRAME (WINDOW_FRAME (w
)));
2928 XSETFASTINT (arg
, ht
/ 2);
2930 else if (CONSP (arg
)) /* Just C-u. */
2932 XSETFASTINT (arg
, ht
/ 2);
2936 arg
= Fprefix_numeric_value (arg
);
2937 CHECK_NUMBER (arg
, 0);
2941 XSETINT (arg
, XINT (arg
) + ht
);
2943 pos
= *vmotion (point
, - XINT (arg
), w
);
2945 Fset_marker (w
->start
, make_number (pos
.bufpos
), w
->buffer
);
2946 w
->start_at_line_beg
= ((pos
.bufpos
== BEGV
2947 || FETCH_CHAR (pos
.bufpos
- 1) == '\n')
2949 w
->force_start
= Qt
;
2954 DEFUN ("move-to-window-line", Fmove_to_window_line
, Smove_to_window_line
,
2956 "Position point relative to window.\n\
2957 With no argument, position point at center of window.\n\
2958 An argument specifies frame line; zero means top of window,\n\
2959 negative means relative to bottom of window.")
2961 register Lisp_Object arg
;
2963 register struct window
*w
= XWINDOW (selected_window
);
2964 register int height
= window_internal_height (w
);
2969 XSETFASTINT (arg
, height
/ 2);
2972 arg
= Fprefix_numeric_value (arg
);
2974 XSETINT (arg
, XINT (arg
) + height
);
2977 start
= marker_position (w
->start
);
2978 XSETWINDOW (window
, w
);
2979 if (start
< BEGV
|| start
> ZV
)
2981 Fvertical_motion (make_number (- (height
/ 2)), window
);
2982 Fset_marker (w
->start
, make_number (PT
), w
->buffer
);
2983 w
->start_at_line_beg
= Fbolp ();
2984 w
->force_start
= Qt
;
2989 return Fvertical_motion (arg
, window
);
2992 struct save_window_data
2994 int size_from_Lisp_Vector_struct
;
2995 struct Lisp_Vector
*next_from_Lisp_Vector_struct
;
2996 Lisp_Object frame_width
, frame_height
, frame_menu_bar_lines
;
2997 Lisp_Object selected_frame
;
2998 Lisp_Object current_window
;
2999 Lisp_Object current_buffer
;
3000 Lisp_Object minibuf_scroll_window
;
3001 Lisp_Object root_window
;
3002 Lisp_Object focus_frame
;
3003 /* Record the values of window-min-width and window-min-height
3004 so that window sizes remain consistent with them. */
3005 Lisp_Object min_width
, min_height
;
3006 /* A vector, interpreted as a struct saved_window */
3007 Lisp_Object saved_windows
;
3010 /* This is saved as a Lisp_Vector */
3013 /* these first two must agree with struct Lisp_Vector in lisp.h */
3014 int size_from_Lisp_Vector_struct
;
3015 struct Lisp_Vector
*next_from_Lisp_Vector_struct
;
3018 Lisp_Object buffer
, start
, pointm
, mark
;
3019 Lisp_Object left
, top
, width
, height
, hscroll
;
3020 Lisp_Object parent
, prev
;
3021 Lisp_Object start_at_line_beg
;
3022 Lisp_Object display_table
;
3024 #define SAVED_WINDOW_VECTOR_SIZE 14 /* Arg to Fmake_vector */
3026 #define SAVED_WINDOW_N(swv,n) \
3027 ((struct saved_window *) (XVECTOR ((swv)->contents[(n)])))
3029 DEFUN ("window-configuration-p", Fwindow_configuration_p
, Swindow_configuration_p
, 1, 1, 0,
3030 "T if OBJECT is a window-configuration object.")
3034 if (WINDOW_CONFIGURATIONP (object
))
3040 DEFUN ("set-window-configuration", Fset_window_configuration
,
3041 Sset_window_configuration
, 1, 1, 0,
3042 "Set the configuration of windows and buffers as specified by CONFIGURATION.\n\
3043 CONFIGURATION must be a value previously returned\n\
3044 by `current-window-configuration' (which see).")
3046 Lisp_Object configuration
;
3048 register struct save_window_data
*data
;
3049 struct Lisp_Vector
*saved_windows
;
3050 Lisp_Object new_current_buffer
;
3054 while (!WINDOW_CONFIGURATIONP (configuration
))
3056 configuration
= wrong_type_argument (intern ("window-configuration-p"),
3060 data
= (struct save_window_data
*) XVECTOR (configuration
);
3061 saved_windows
= XVECTOR (data
->saved_windows
);
3063 new_current_buffer
= data
->current_buffer
;
3064 if (NILP (XBUFFER (new_current_buffer
)->name
))
3065 new_current_buffer
= Qnil
;
3067 frame
= XWINDOW (SAVED_WINDOW_N (saved_windows
, 0)->window
)->frame
;
3070 /* If f is a dead frame, don't bother rebuilding its window tree.
3071 However, there is other stuff we should still try to do below. */
3072 if (FRAME_LIVE_P (f
))
3074 register struct window
*w
;
3075 register struct saved_window
*p
;
3078 /* If the frame has been resized since this window configuration was
3079 made, we change the frame to the size specified in the
3080 configuration, restore the configuration, and then resize it
3081 back. We keep track of the prevailing height in these variables. */
3082 int previous_frame_height
= FRAME_HEIGHT (f
);
3083 int previous_frame_width
= FRAME_WIDTH (f
);
3084 int previous_frame_menu_bar_lines
= FRAME_MENU_BAR_LINES (f
);
3086 if (XFASTINT (data
->frame_height
) != previous_frame_height
3087 || XFASTINT (data
->frame_width
) != previous_frame_width
)
3088 change_frame_size (f
, data
->frame_height
, data
->frame_width
, 0, 0);
3089 #if defined (HAVE_WINDOW_SYSTEM) || (defined (MSDOS) && defined (MULTI_FRAME))
3090 if (XFASTINT (data
->frame_menu_bar_lines
)
3091 != previous_frame_menu_bar_lines
)
3092 x_set_menu_bar_lines (f
, data
->frame_menu_bar_lines
, 0);
3095 windows_or_buffers_changed
++;
3096 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
3098 /* Temporarily avoid any problems with windows that are smaller
3099 than they are supposed to be. */
3100 window_min_height
= 1;
3101 window_min_width
= 1;
3104 Mark all windows now on frame as "deleted".
3105 Restoring the new configuration "undeletes" any that are in it.
3107 Save their current buffers in their height fields, since we may
3108 need it later, if a buffer saved in the configuration is now
3110 delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f
)));
3112 for (k
= 0; k
< saved_windows
->size
; k
++)
3114 p
= SAVED_WINDOW_N (saved_windows
, k
);
3115 w
= XWINDOW (p
->window
);
3118 if (!NILP (p
->parent
))
3119 w
->parent
= SAVED_WINDOW_N (saved_windows
,
3120 XFASTINT (p
->parent
))->window
;
3124 if (!NILP (p
->prev
))
3126 w
->prev
= SAVED_WINDOW_N (saved_windows
,
3127 XFASTINT (p
->prev
))->window
;
3128 XWINDOW (w
->prev
)->next
= p
->window
;
3133 if (!NILP (w
->parent
))
3135 if (EQ (p
->width
, XWINDOW (w
->parent
)->width
))
3137 XWINDOW (w
->parent
)->vchild
= p
->window
;
3138 XWINDOW (w
->parent
)->hchild
= Qnil
;
3142 XWINDOW (w
->parent
)->hchild
= p
->window
;
3143 XWINDOW (w
->parent
)->vchild
= Qnil
;
3148 /* If we squirreled away the buffer in the window's height,
3150 if (BUFFERP (w
->height
))
3151 w
->buffer
= w
->height
;
3154 w
->width
= p
->width
;
3155 w
->height
= p
->height
;
3156 w
->hscroll
= p
->hscroll
;
3157 w
->display_table
= p
->display_table
;
3158 XSETFASTINT (w
->last_modified
, 0);
3160 /* Reinstall the saved buffer and pointers into it. */
3161 if (NILP (p
->buffer
))
3162 w
->buffer
= p
->buffer
;
3165 if (!NILP (XBUFFER (p
->buffer
)->name
))
3166 /* If saved buffer is alive, install it. */
3168 w
->buffer
= p
->buffer
;
3169 w
->start_at_line_beg
= p
->start_at_line_beg
;
3170 set_marker_restricted (w
->start
,
3171 Fmarker_position (p
->start
),
3173 set_marker_restricted (w
->pointm
,
3174 Fmarker_position (p
->pointm
),
3176 Fset_marker (XBUFFER (w
->buffer
)->mark
,
3177 Fmarker_position (p
->mark
), w
->buffer
);
3179 /* As documented in Fcurrent_window_configuration, don't
3180 save the location of point in the buffer which was current
3181 when the window configuration was recorded. */
3182 if (!EQ (p
->buffer
, new_current_buffer
)
3183 && XBUFFER (p
->buffer
) == current_buffer
)
3184 Fgoto_char (w
->pointm
);
3186 else if (NILP (w
->buffer
) || NILP (XBUFFER (w
->buffer
)->name
))
3187 /* Else unless window has a live buffer, get one. */
3189 w
->buffer
= Fcdr (Fcar (Vbuffer_alist
));
3190 /* This will set the markers to beginning of visible
3192 set_marker_restricted (w
->start
, make_number (0), w
->buffer
);
3193 set_marker_restricted (w
->pointm
, make_number (0),w
->buffer
);
3194 w
->start_at_line_beg
= Qt
;
3197 /* Keeping window's old buffer; make sure the markers
3200 /* Set window markers at start of visible range. */
3201 if (XMARKER (w
->start
)->buffer
== 0)
3202 set_marker_restricted (w
->start
, make_number (0),
3204 if (XMARKER (w
->pointm
)->buffer
== 0)
3205 set_marker_restricted (w
->pointm
,
3207 (BUF_PT (XBUFFER (w
->buffer
)))),
3209 w
->start_at_line_beg
= Qt
;
3214 FRAME_ROOT_WINDOW (f
) = data
->root_window
;
3215 Fselect_window (data
->current_window
);
3218 if (NILP (data
->focus_frame
)
3219 || (FRAMEP (data
->focus_frame
)
3220 && FRAME_LIVE_P (XFRAME (data
->focus_frame
))))
3221 Fredirect_frame_focus (frame
, data
->focus_frame
);
3224 #if 0 /* I don't understand why this is needed, and it causes problems
3225 when the frame's old selected window has been deleted. */
3227 if (f
!= selected_frame
&& FRAME_WINDOW_P (f
))
3228 do_switch_frame (WINDOW_FRAME (XWINDOW (data
->root_window
)),
3233 /* Set the screen height to the value it had before this function. */
3234 if (previous_frame_height
!= FRAME_HEIGHT (f
)
3235 || previous_frame_width
!= FRAME_WIDTH (f
))
3236 change_frame_size (f
, previous_frame_height
, previous_frame_width
,
3238 #if defined (HAVE_WINDOW_SYSTEM) || (defined (MSDOS) && defined (MULTI_FRAME))
3239 if (previous_frame_menu_bar_lines
!= FRAME_MENU_BAR_LINES (f
))
3240 x_set_menu_bar_lines (f
, previous_frame_menu_bar_lines
, 0);
3244 /* Restore the minimum heights recorded in the configuration. */
3245 window_min_height
= XINT (data
->min_height
);
3246 window_min_width
= XINT (data
->min_width
);
3249 /* Fselect_window will have made f the selected frame, so we
3250 reselect the proper frame here. Fhandle_switch_frame will change the
3251 selected window too, but that doesn't make the call to
3252 Fselect_window above totally superfluous; it still sets f's
3254 if (FRAME_LIVE_P (XFRAME (data
->selected_frame
)))
3255 do_switch_frame (data
->selected_frame
, Qnil
, 0);
3258 if (!NILP (new_current_buffer
))
3259 Fset_buffer (new_current_buffer
);
3261 Vminibuf_scroll_window
= data
->minibuf_scroll_window
;
3265 /* Mark all windows now on frame as deleted
3266 by setting their buffers to nil. */
3269 delete_all_subwindows (w
)
3270 register struct window
*w
;
3272 if (!NILP (w
->next
))
3273 delete_all_subwindows (XWINDOW (w
->next
));
3274 if (!NILP (w
->vchild
))
3275 delete_all_subwindows (XWINDOW (w
->vchild
));
3276 if (!NILP (w
->hchild
))
3277 delete_all_subwindows (XWINDOW (w
->hchild
));
3279 w
->height
= w
->buffer
; /* See Fset_window_configuration for excuse. */
3281 /* We set all three of these fields to nil, to make sure that we can
3282 distinguish this dead window from any live window. Live leaf
3283 windows will have buffer set, and combination windows will have
3284 vchild or hchild set. */
3291 count_windows (window
)
3292 register struct window
*window
;
3294 register int count
= 1;
3295 if (!NILP (window
->next
))
3296 count
+= count_windows (XWINDOW (window
->next
));
3297 if (!NILP (window
->vchild
))
3298 count
+= count_windows (XWINDOW (window
->vchild
));
3299 if (!NILP (window
->hchild
))
3300 count
+= count_windows (XWINDOW (window
->hchild
));
3305 save_window_save (window
, vector
, i
)
3307 struct Lisp_Vector
*vector
;
3310 register struct saved_window
*p
;
3311 register struct window
*w
;
3312 register Lisp_Object tem
;
3314 for (;!NILP (window
); window
= w
->next
)
3316 p
= SAVED_WINDOW_N (vector
, i
);
3317 w
= XWINDOW (window
);
3319 XSETFASTINT (w
->temslot
, i
++);
3321 p
->buffer
= w
->buffer
;
3324 p
->width
= w
->width
;
3325 p
->height
= w
->height
;
3326 p
->hscroll
= w
->hscroll
;
3327 p
->display_table
= w
->display_table
;
3328 if (!NILP (w
->buffer
))
3330 /* Save w's value of point in the window configuration.
3331 If w is the selected window, then get the value of point
3332 from the buffer; pointm is garbage in the selected window. */
3333 if (EQ (window
, selected_window
))
3335 p
->pointm
= Fmake_marker ();
3336 Fset_marker (p
->pointm
, BUF_PT (XBUFFER (w
->buffer
)),
3340 p
->pointm
= Fcopy_marker (w
->pointm
, Qnil
);
3342 p
->start
= Fcopy_marker (w
->start
, Qnil
);
3343 p
->start_at_line_beg
= w
->start_at_line_beg
;
3345 tem
= XBUFFER (w
->buffer
)->mark
;
3346 p
->mark
= Fcopy_marker (tem
, Qnil
);
3353 p
->start_at_line_beg
= Qnil
;
3356 if (NILP (w
->parent
))
3359 p
->parent
= XWINDOW (w
->parent
)->temslot
;
3364 p
->prev
= XWINDOW (w
->prev
)->temslot
;
3366 if (!NILP (w
->vchild
))
3367 i
= save_window_save (w
->vchild
, vector
, i
);
3368 if (!NILP (w
->hchild
))
3369 i
= save_window_save (w
->hchild
, vector
, i
);
3375 DEFUN ("current-window-configuration",
3376 Fcurrent_window_configuration
, Scurrent_window_configuration
, 0, 1, 0,
3377 "Return an object representing the current window configuration of FRAME.\n\
3378 If FRAME is nil or omitted, use the selected frame.\n\
3379 This describes the number of windows, their sizes and current buffers,\n\
3380 and for each displayed buffer, where display starts, and the positions of\n\
3381 point and mark. An exception is made for point in the current buffer:\n\
3382 its value is -not- saved.\n\
3383 This also records the currently selected frame, and FRAME's focus\n\
3384 redirection (see `redirect-frame-focus').")
3388 register Lisp_Object tem
;
3389 register int n_windows
;
3390 register struct save_window_data
*data
;
3391 register struct Lisp_Vector
*vec
;
3399 CHECK_LIVE_FRAME (frame
, 0);
3403 n_windows
= count_windows (XWINDOW (FRAME_ROOT_WINDOW (f
)));
3404 vec
= allocate_vectorlike (VECSIZE (struct save_window_data
));
3405 for (i
= 0; i
< VECSIZE (struct save_window_data
); i
++)
3406 vec
->contents
[i
] = Qnil
;
3407 vec
->size
= VECSIZE (struct save_window_data
);
3408 data
= (struct save_window_data
*)vec
;
3410 XSETFASTINT (data
->frame_width
, FRAME_WIDTH (f
));
3411 XSETFASTINT (data
->frame_height
, FRAME_HEIGHT (f
));
3412 XSETFASTINT (data
->frame_menu_bar_lines
, FRAME_MENU_BAR_LINES (f
));
3414 XSETFRAME (data
->selected_frame
, selected_frame
);
3416 data
->current_window
= FRAME_SELECTED_WINDOW (f
);
3417 XSETBUFFER (data
->current_buffer
, current_buffer
);
3418 data
->minibuf_scroll_window
= Vminibuf_scroll_window
;
3419 data
->root_window
= FRAME_ROOT_WINDOW (f
);
3420 data
->focus_frame
= FRAME_FOCUS_FRAME (f
);
3421 XSETINT (data
->min_height
, window_min_height
);
3422 XSETINT (data
->min_width
, window_min_width
);
3423 tem
= Fmake_vector (make_number (n_windows
), Qnil
);
3424 data
->saved_windows
= tem
;
3425 for (i
= 0; i
< n_windows
; i
++)
3426 XVECTOR (tem
)->contents
[i
]
3427 = Fmake_vector (make_number (SAVED_WINDOW_VECTOR_SIZE
), Qnil
);
3428 save_window_save (FRAME_ROOT_WINDOW (f
),
3430 XSETWINDOW_CONFIGURATION (tem
, data
);
3434 DEFUN ("save-window-excursion", Fsave_window_excursion
, Ssave_window_excursion
,
3436 "Execute body, preserving window sizes and contents.\n\
3437 Restore which buffer appears in which window, where display starts,\n\
3438 and the value of point and mark for each window.\n\
3439 Also restore which buffer is current.\n\
3440 But do not preserve point in the current buffer.\n\
3441 Does not restore the value of point in current buffer.")
3445 register Lisp_Object val
;
3446 register int count
= specpdl_ptr
- specpdl
;
3448 record_unwind_protect (Fset_window_configuration
,
3449 Fcurrent_window_configuration (Qnil
));
3450 val
= Fprogn (args
);
3451 return unbind_to (count
, val
);
3457 selected_frame
= make_terminal_frame ();
3458 XSETFRAME (Vterminal_frame
, selected_frame
);
3459 minibuf_window
= selected_frame
->minibuffer_window
;
3460 selected_window
= selected_frame
->selected_window
;
3461 last_nonminibuf_frame
= selected_frame
;
3462 #else /* not MULTI_FRAME */
3463 extern Lisp_Object
get_minibuffer ();
3465 selected_frame
= last_nonminibuf_frame
= &the_only_frame
;
3467 minibuf_window
= make_window ();
3468 FRAME_ROOT_WINDOW (selected_frame
) = make_window ();
3470 XWINDOW (FRAME_ROOT_WINDOW (selected_frame
))->next
= minibuf_window
;
3471 XWINDOW (minibuf_window
)->prev
= FRAME_ROOT_WINDOW (selected_frame
);
3472 XWINDOW (minibuf_window
)->mini_p
= Qt
;
3474 /* These values 9 and 10 are arbitrary,
3475 just so that there is "something there."
3476 Correct values are put in in init_xdisp */
3478 XSETFASTINT (XWINDOW (FRAME_ROOT_WINDOW (selected_frame
))->width
, 10);
3479 XSETFASTINT (XWINDOW (minibuf_window
)->width
, 10);
3481 XSETFASTINT (XWINDOW (FRAME_ROOT_WINDOW (selected_frame
))->height
, 9);
3482 XSETFASTINT (XWINDOW (minibuf_window
)->top
, 9);
3483 XSETFASTINT (XWINDOW (minibuf_window
)->height
, 1);
3485 /* Prevent error in Fset_window_buffer. */
3486 XWINDOW (FRAME_ROOT_WINDOW (selected_frame
))->buffer
= Qt
;
3487 XWINDOW (minibuf_window
)->buffer
= Qt
;
3489 /* Now set them up for real. */
3490 Fset_window_buffer (FRAME_ROOT_WINDOW (selected_frame
),
3491 Fcurrent_buffer ());
3492 Fset_window_buffer (minibuf_window
, get_minibuffer (0));
3494 selected_window
= FRAME_ROOT_WINDOW (selected_frame
);
3495 /* Make sure this window seems more recently used than
3496 a newly-created, never-selected window. Increment
3497 window_select_count so the first selection ever will get
3498 something newer than this. */
3499 XSETFASTINT (XWINDOW (selected_window
)->use_time
, ++window_select_count
);
3500 #endif /* not MULTI_FRAME */
3502 window_initialized
= 1;
3507 Qwindowp
= intern ("windowp");
3508 staticpro (&Qwindowp
);
3510 Qwindow_live_p
= intern ("window-live-p");
3511 staticpro (&Qwindow_live_p
);
3513 Qtemp_buffer_show_hook
= intern ("temp-buffer-show-hook");
3514 staticpro (&Qtemp_buffer_show_hook
);
3517 /* Make sure all windows get marked */
3518 staticpro (&minibuf_window
);
3521 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function
,
3522 "Non-nil means call as function to display a help buffer.\n\
3523 The function is called with one argument, the buffer to be displayed.\n\
3524 Used by `with-output-to-temp-buffer'.\n\
3525 If this function is used, then it must do the entire job of showing\n\
3526 the buffer; `temp-buffer-show-hook' is not run unless this function runs it.");
3527 Vtemp_buffer_show_function
= Qnil
;
3529 DEFVAR_LISP ("display-buffer-function", &Vdisplay_buffer_function
,
3530 "If non-nil, function to call to handle `display-buffer'.\n\
3531 It will receive two args, the buffer and a flag which if non-nil means\n\
3532 that the currently selected window is not acceptable.\n\
3533 Commands such as `switch-to-buffer-other-window' and `find-file-other-window'\n\
3534 work using this function.");
3535 Vdisplay_buffer_function
= Qnil
;
3537 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window
,
3538 "Non-nil means it is the window that C-M-v in minibuffer should scroll.");
3539 Vminibuf_scroll_window
= Qnil
;
3541 DEFVAR_LISP ("other-window-scroll-buffer", &Vother_window_scroll_buffer
,
3542 "If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window.");
3543 Vother_window_scroll_buffer
= Qnil
;
3545 DEFVAR_BOOL ("pop-up-frames", &pop_up_frames
,
3546 "*Non-nil means `display-buffer' should make a separate frame.");
3549 DEFVAR_LISP ("pop-up-frame-function", &Vpop_up_frame_function
,
3550 "Function to call to handle automatic new frame creation.\n\
3551 It is called with no arguments and should return a newly created frame.\n\
3553 A typical value might be `(lambda () (new-frame pop-up-frame-alist))'\n\
3554 where `pop-up-frame-alist' would hold the default frame parameters.");
3555 Vpop_up_frame_function
= Qnil
;
3557 DEFVAR_LISP ("special-display-buffer-names", &Vspecial_display_buffer_names
,
3558 "*List of buffer names that should have their own special frames.\n\
3559 Displaying a buffer whose name is in this list makes a special frame for it\n\
3560 using `special-display-function'.\n\
3562 An element of the list can be a cons cell instead of just a string.\n\
3563 Then the car should be a buffer name, and the cdr specifies frame\n\
3564 parameters for creating the frame for that buffer.\n\
3565 More precisely, the cdr is passed as the second argument to\n\
3566 the function found in `special-display-function', when making that frame.\n\
3567 See also `special-display-regexps'.");
3568 Vspecial_display_buffer_names
= Qnil
;
3570 DEFVAR_LISP ("special-display-regexps", &Vspecial_display_regexps
,
3571 "*List of regexps saying which buffers should have their own special frames.\n\
3572 If a buffer name matches one of these regexps, it gets its own frame.\n\
3573 Displaying a buffer whose name is in this list makes a special frame for it\n\
3574 using `special-display-function'.\n\
3576 An element of the list can be a cons cell instead of just a string.\n\
3577 Then the car should be the regexp, and the cdr specifies frame\n\
3578 parameters for creating the frame for buffers that match.\n\
3579 More precisely, the cdr is passed as the second argument to\n\
3580 the function found in `special-display-function', when making that frame.\n\
3581 See also `special-display-buffer-names'.");
3582 Vspecial_display_regexps
= Qnil
;
3584 DEFVAR_LISP ("special-display-function", &Vspecial_display_function
,
3585 "Function to call to make a new frame for a special buffer.\n\
3586 It is called with two arguments, the buffer and optional buffer specific\n\
3587 data, and should return a window displaying that buffer.\n\
3588 The default value makes a separate frame for the buffer,\n\
3589 using `special-display-frame-alist' to specify the frame parameters.\n\
3591 A buffer is special if its is listed in `special-display-buffer-names'\n\
3592 or matches a regexp in `special-display-regexps'.");
3593 Vspecial_display_function
= Qnil
;
3595 DEFVAR_LISP ("same-window-buffer-names", &Vsame_window_buffer_names
,
3596 "*List of buffer names that should appear in the selected window.\n\
3597 Displaying one of these buffers using `display-buffer' or `pop-to-buffer'\n\
3598 switches to it in the selected window, rather than making it appear\n\
3599 in some other window.\n\
3601 An element of the list can be a cons cell instead of just a string.\n\
3602 Then the car must be a string, which specifies the buffer name.\n\
3603 This is for compatibility with `special-display-buffer-names';\n\
3604 the cdr of the cons cell is ignored.\n\
3606 See also `same-window-regexps'.");
3607 Vsame_window_buffer_names
= Qnil
;
3609 DEFVAR_LISP ("same-window-regexps", &Vsame_window_regexps
,
3610 "*List of regexps saying which buffers should appear in the selected window.\n\
3611 If a buffer name matches one of these regexps, then displaying it\n\
3612 using `display-buffer' or `pop-to-buffer' switches to it\n\
3613 in the selected window, rather than making it appear in some other window.\n\
3615 An element of the list can be a cons cell instead of just a string.\n\
3616 Then the car must be a string, which specifies the buffer name.\n\
3617 This is for compatibility with `special-display-buffer-names';\n\
3618 the cdr of the cons cell is ignored.\n\
3620 See also `same-window-buffer-names'.");
3621 Vsame_window_regexps
= Qnil
;
3623 DEFVAR_BOOL ("pop-up-windows", &pop_up_windows
,
3624 "*Non-nil means display-buffer should make new windows.");
3627 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines
,
3628 "*Number of lines of continuity when scrolling by screenfuls.");
3629 next_screen_context_lines
= 2;
3631 DEFVAR_INT ("split-height-threshold", &split_height_threshold
,
3632 "*display-buffer would prefer to split the largest window if this large.\n\
3633 If there is only one window, it is split regardless of this value.");
3634 split_height_threshold
= 500;
3636 DEFVAR_INT ("window-min-height", &window_min_height
,
3637 "*Delete any window less than this tall (including its mode line).");
3638 window_min_height
= 4;
3640 DEFVAR_INT ("window-min-width", &window_min_width
,
3641 "*Delete any window less than this wide.");
3642 window_min_width
= 10;
3644 defsubr (&Sselected_window
);
3645 defsubr (&Sminibuffer_window
);
3646 defsubr (&Swindow_minibuffer_p
);
3647 defsubr (&Swindowp
);
3648 defsubr (&Swindow_live_p
);
3649 defsubr (&Spos_visible_in_window_p
);
3650 defsubr (&Swindow_buffer
);
3651 defsubr (&Swindow_height
);
3652 defsubr (&Swindow_width
);
3653 defsubr (&Swindow_hscroll
);
3654 defsubr (&Sset_window_hscroll
);
3655 defsubr (&Swindow_redisplay_end_trigger
);
3656 defsubr (&Sset_window_redisplay_end_trigger
);
3657 defsubr (&Swindow_edges
);
3658 defsubr (&Scoordinates_in_window_p
);
3659 defsubr (&Swindow_at
);
3660 defsubr (&Swindow_point
);
3661 defsubr (&Swindow_start
);
3662 defsubr (&Swindow_end
);
3663 defsubr (&Sset_window_point
);
3664 defsubr (&Sset_window_start
);
3665 defsubr (&Swindow_dedicated_p
);
3666 defsubr (&Sset_window_dedicated_p
);
3667 defsubr (&Swindow_display_table
);
3668 defsubr (&Sset_window_display_table
);
3669 defsubr (&Snext_window
);
3670 defsubr (&Sprevious_window
);
3671 defsubr (&Sother_window
);
3672 defsubr (&Sget_lru_window
);
3673 defsubr (&Sget_largest_window
);
3674 defsubr (&Sget_buffer_window
);
3675 defsubr (&Sdelete_other_windows
);
3676 defsubr (&Sdelete_windows_on
);
3677 defsubr (&Sreplace_buffer_in_windows
);
3678 defsubr (&Sdelete_window
);
3679 defsubr (&Sset_window_buffer
);
3680 defsubr (&Sselect_window
);
3681 defsubr (&Sdisplay_buffer
);
3682 defsubr (&Ssplit_window
);
3683 defsubr (&Senlarge_window
);
3684 defsubr (&Sshrink_window
);
3685 defsubr (&Sscroll_up
);
3686 defsubr (&Sscroll_down
);
3687 defsubr (&Sscroll_left
);
3688 defsubr (&Sscroll_right
);
3689 defsubr (&Sother_window_for_scrolling
);
3690 defsubr (&Sscroll_other_window
);
3691 defsubr (&Srecenter
);
3692 defsubr (&Smove_to_window_line
);
3693 defsubr (&Swindow_configuration_p
);
3694 defsubr (&Sset_window_configuration
);
3695 defsubr (&Scurrent_window_configuration
);
3696 defsubr (&Ssave_window_excursion
);
3701 initial_define_key (control_x_map
, '1', "delete-other-windows");
3702 initial_define_key (control_x_map
, '2', "split-window");
3703 initial_define_key (control_x_map
, '0', "delete-window");
3704 initial_define_key (control_x_map
, 'o', "other-window");
3705 initial_define_key (control_x_map
, '^', "enlarge-window");
3706 initial_define_key (control_x_map
, '<', "scroll-left");
3707 initial_define_key (control_x_map
, '>', "scroll-right");
3709 initial_define_key (global_map
, Ctl ('V'), "scroll-up");
3710 initial_define_key (meta_map
, Ctl ('V'), "scroll-other-window");
3711 initial_define_key (meta_map
, 'v', "scroll-down");
3713 initial_define_key (global_map
, Ctl('L'), "recenter");
3714 initial_define_key (meta_map
, 'r', "move-to-window-line");