1 /* Window creation, deletion and examination for GNU Emacs.
2 Does not include redisplay.
3 Copyright (C) 1985,86,87,93,94,95,96,97,1998,2000, 2001, 2002, 2003
4 Free Software Foundation, Inc.
6 This file is part of GNU Emacs.
8 GNU Emacs is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs; see the file COPYING. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
34 #include "dispextern.h"
35 #include "blockinput.h"
36 #include "intervals.h"
40 #endif /* HAVE_X_WINDOWS */
52 Lisp_Object Qwindowp
, Qwindow_live_p
, Qwindow_configuration_p
;
53 Lisp_Object Qwindow_size_fixed
;
54 extern Lisp_Object Qleft_margin
, Qright_margin
;
56 static int displayed_window_lines
P_ ((struct window
*));
57 static struct window
*decode_window
P_ ((Lisp_Object
));
58 static int count_windows
P_ ((struct window
*));
59 static int get_leaf_windows
P_ ((struct window
*, struct window
**, int));
60 static void window_scroll
P_ ((Lisp_Object
, int, int, int));
61 static void window_scroll_pixel_based
P_ ((Lisp_Object
, int, int, int));
62 static void window_scroll_line_based
P_ ((Lisp_Object
, int, int, int));
63 static int window_min_size_1
P_ ((struct window
*, int));
64 static int window_min_size
P_ ((struct window
*, int, int, int *));
65 static void size_window
P_ ((Lisp_Object
, int, int, int));
66 static int freeze_window_start
P_ ((struct window
*, void *));
67 static int window_fixed_size_p
P_ ((struct window
*, int, int));
68 static void enlarge_window
P_ ((Lisp_Object
, int, int, int));
69 static Lisp_Object window_list
P_ ((void));
70 static int add_window_to_list
P_ ((struct window
*, void *));
71 static int candidate_window_p
P_ ((Lisp_Object
, Lisp_Object
, Lisp_Object
,
73 static Lisp_Object next_window
P_ ((Lisp_Object
, Lisp_Object
,
75 static void decode_next_window_args
P_ ((Lisp_Object
*, Lisp_Object
*,
77 static int foreach_window_1
P_ ((struct window
*,
78 int (* fn
) (struct window
*, void *),
80 static Lisp_Object window_list_1
P_ ((Lisp_Object
, Lisp_Object
, Lisp_Object
));
82 /* The value of `window-size-fixed'. */
84 int window_size_fixed
;
86 /* This is the window in which the terminal's cursor should
87 be left when nothing is being done with it. This must
88 always be a leaf window, and its buffer is selected by
89 the top level editing loop at the end of each command.
91 This value is always the same as
92 FRAME_SELECTED_WINDOW (selected_frame). */
94 Lisp_Object selected_window
;
96 /* A list of all windows for use by next_window and Fwindow_list.
97 Functions creating or deleting windows should invalidate this cache
98 by setting it to nil. */
100 Lisp_Object Vwindow_list
;
102 /* The mini-buffer window of the selected frame.
103 Note that you cannot test for mini-bufferness of an arbitrary window
104 by comparing against this; but you can test for mini-bufferness of
105 the selected window. */
107 Lisp_Object minibuf_window
;
109 /* Non-nil means it is the window whose mode line should be
110 shown as the selected window when the minibuffer is selected. */
112 Lisp_Object minibuf_selected_window
;
114 /* Non-nil means it is the window for C-M-v to scroll
115 when the mini-buffer is selected. */
117 Lisp_Object Vminibuf_scroll_window
;
119 /* Non-nil means this is the buffer whose window C-M-v should scroll. */
121 Lisp_Object Vother_window_scroll_buffer
;
123 /* Non-nil means it's function to call to display temp buffers. */
125 Lisp_Object Vtemp_buffer_show_function
;
127 /* Non-zero means to use mode-line-inactive face in all windows but the
128 selected-window and the minibuffer-scroll-window when the
129 minibuffer is active. */
130 int mode_line_in_non_selected_windows
;
132 /* If a window gets smaller than either of these, it is removed. */
134 EMACS_INT window_min_height
;
135 EMACS_INT window_min_width
;
137 /* Nonzero implies Fdisplay_buffer should create windows. */
141 /* Nonzero implies make new frames for Fdisplay_buffer. */
145 /* Nonzero means reuse existing frames for displaying buffers. */
147 int display_buffer_reuse_frames
;
149 /* Non-nil means use this function instead of default */
151 Lisp_Object Vpop_up_frame_function
;
153 /* Function to call to handle Fdisplay_buffer. */
155 Lisp_Object Vdisplay_buffer_function
;
157 /* Non-nil means that Fdisplay_buffer should even the heights of windows. */
159 Lisp_Object Veven_window_heights
;
161 /* List of buffer *names* for buffers that should have their own frames. */
163 Lisp_Object Vspecial_display_buffer_names
;
165 /* List of regexps for buffer names that should have their own frames. */
167 Lisp_Object Vspecial_display_regexps
;
169 /* Function to pop up a special frame. */
171 Lisp_Object Vspecial_display_function
;
173 /* List of buffer *names* for buffers to appear in selected window. */
175 Lisp_Object Vsame_window_buffer_names
;
177 /* List of regexps for buffer names to appear in selected window. */
179 Lisp_Object Vsame_window_regexps
;
181 /* Hook run at end of temp_output_buffer_show. */
183 Lisp_Object Qtemp_buffer_show_hook
;
185 /* Fdisplay_buffer always splits the largest window
186 if that window is more than this high. */
188 EMACS_INT split_height_threshold
;
190 /* Number of lines of continuity in scrolling by screenfuls. */
192 EMACS_INT next_screen_context_lines
;
194 /* Incremented for each window created. */
196 static int sequence_number
;
198 /* Nonzero after init_window_once has finished. */
200 static int window_initialized
;
202 /* Hook to run when window config changes. */
204 Lisp_Object Qwindow_configuration_change_hook
;
205 Lisp_Object Vwindow_configuration_change_hook
;
207 /* Nonzero means scroll commands try to put point
208 at the same screen height as previously. */
210 Lisp_Object Vscroll_preserve_screen_position
;
212 #if 0 /* This isn't used anywhere. */
213 /* Nonzero means we can split a frame even if it is "unsplittable". */
214 static int inhibit_frame_unsplittable
;
217 extern EMACS_INT scroll_margin
;
219 extern Lisp_Object Qwindow_scroll_functions
, Vwindow_scroll_functions
;
221 DEFUN ("windowp", Fwindowp
, Swindowp
, 1, 1, 0,
222 doc
: /* Returns t if OBJECT is a window. */)
226 return WINDOWP (object
) ? Qt
: Qnil
;
229 DEFUN ("window-live-p", Fwindow_live_p
, Swindow_live_p
, 1, 1, 0,
230 doc
: /* Returns t if OBJECT is a window which is currently visible. */)
234 return WINDOW_LIVE_P (object
) ? Qt
: Qnil
;
241 register struct window
*p
;
243 p
= allocate_window ();
244 XSETFASTINT (p
->sequence_number
, ++sequence_number
);
245 XSETFASTINT (p
->left_col
, 0);
246 XSETFASTINT (p
->top_line
, 0);
247 XSETFASTINT (p
->total_lines
, 0);
248 XSETFASTINT (p
->total_cols
, 0);
249 XSETFASTINT (p
->hscroll
, 0);
250 XSETFASTINT (p
->min_hscroll
, 0);
251 p
->orig_top_line
= p
->orig_total_lines
= Qnil
;
252 p
->start
= Fmake_marker ();
253 p
->pointm
= Fmake_marker ();
254 XSETFASTINT (p
->use_time
, 0);
256 p
->display_table
= Qnil
;
258 p
->pseudo_window_p
= 0;
259 bzero (&p
->cursor
, sizeof (p
->cursor
));
260 bzero (&p
->last_cursor
, sizeof (p
->last_cursor
));
261 bzero (&p
->phys_cursor
, sizeof (p
->phys_cursor
));
262 p
->desired_matrix
= p
->current_matrix
= 0;
263 p
->phys_cursor_type
= -1;
264 p
->phys_cursor_width
= -1;
265 p
->must_be_updated_p
= 0;
266 XSETFASTINT (p
->window_end_vpos
, 0);
267 XSETFASTINT (p
->window_end_pos
, 0);
268 p
->window_end_valid
= Qnil
;
271 XSETFASTINT (p
->last_point
, 0);
272 p
->frozen_window_start_p
= 0;
273 p
->height_fixed_p
= 0;
274 p
->last_cursor_off_p
= p
->cursor_off_p
= 0;
275 p
->left_margin_cols
= Qnil
;
276 p
->right_margin_cols
= Qnil
;
277 p
->left_fringe_width
= Qnil
;
278 p
->right_fringe_width
= Qnil
;
279 p
->fringes_outside_margins
= Qnil
;
280 p
->scroll_bar_width
= Qnil
;
281 p
->vertical_scroll_bar_type
= Qt
;
282 p
->overlay_arrow_bitmap
= 0;
288 DEFUN ("selected-window", Fselected_window
, Sselected_window
, 0, 0, 0,
289 doc
: /* Return the window that the cursor now appears in and commands apply to. */)
292 return selected_window
;
295 DEFUN ("minibuffer-window", Fminibuffer_window
, Sminibuffer_window
, 0, 1, 0,
296 doc
: /* Return the window used now for minibuffers.
297 If the optional argument FRAME is specified, return the minibuffer window
298 used by that frame. */)
303 frame
= selected_frame
;
304 CHECK_LIVE_FRAME (frame
);
305 return FRAME_MINIBUF_WINDOW (XFRAME (frame
));
308 DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p
, Swindow_minibuffer_p
, 0, 1, 0,
309 doc
: /* Returns non-nil if WINDOW is a minibuffer window.
310 WINDOW defaults to the selected window. */)
314 struct window
*w
= decode_window (window
);
315 return MINI_WINDOW_P (w
) ? Qt
: Qnil
;
319 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p
,
320 Spos_visible_in_window_p
, 0, 3, 0,
321 doc
: /* Return t if position POS is currently on the frame in WINDOW.
322 Return nil if that position is scrolled vertically out of view.
323 If a character is only partially visible, nil is returned, unless the
324 optional argument PARTIALLY is non-nil.
325 POS defaults to point in WINDOW; WINDOW defaults to the selected window.
327 If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil,
328 return value is a list (X Y PARTIAL) where X and Y are the pixel relative
330 (pos
, window
, partially
)
331 Lisp_Object pos
, window
, partially
;
333 register struct window
*w
;
335 register struct buffer
*buf
;
337 Lisp_Object in_window
= Qnil
;
341 w
= decode_window (window
);
342 buf
= XBUFFER (w
->buffer
);
343 SET_TEXT_POS_FROM_MARKER (top
, w
->start
);
347 CHECK_NUMBER_COERCE_MARKER (pos
);
350 else if (w
== XWINDOW (selected_window
))
353 posint
= XMARKER (w
->pointm
)->charpos
;
355 /* If position is above window start or outside buffer boundaries,
356 or if window start is out of range, position is not visible. */
357 if (posint
>= CHARPOS (top
)
358 && posint
<= BUF_ZV (buf
)
359 && CHARPOS (top
) >= BUF_BEGV (buf
)
360 && CHARPOS (top
) <= BUF_ZV (buf
)
361 && pos_visible_p (w
, posint
, &fully_p
, &x
, &y
, NILP (partially
))
362 && (!NILP (partially
) || fully_p
))
365 if (!NILP (in_window
) && !NILP (partially
))
366 in_window
= Fcons (make_number (x
),
367 Fcons (make_number (y
),
368 Fcons (fully_p
? Qt
: Qnil
, Qnil
)));
373 static struct window
*
374 decode_window (window
)
375 register Lisp_Object window
;
378 return XWINDOW (selected_window
);
380 CHECK_LIVE_WINDOW (window
);
381 return XWINDOW (window
);
384 static struct window
*
385 decode_any_window (window
)
386 register Lisp_Object window
;
389 return XWINDOW (selected_window
);
391 CHECK_WINDOW (window
);
392 return XWINDOW (window
);
395 DEFUN ("window-buffer", Fwindow_buffer
, Swindow_buffer
, 0, 1, 0,
396 doc
: /* Return the buffer that WINDOW is displaying. */)
400 return decode_window (window
)->buffer
;
403 DEFUN ("window-height", Fwindow_height
, Swindow_height
, 0, 1, 0,
404 doc
: /* Return the number of lines in WINDOW (including its mode line). */)
408 return decode_any_window (window
)->total_lines
;
411 DEFUN ("window-width", Fwindow_width
, Swindow_width
, 0, 1, 0,
412 doc
: /* Return the number of display columns in WINDOW.
413 This is the width that is usable columns available for text in WINDOW.
414 If you want to find out how many columns WINDOW takes up,
415 use (let ((edges (window-edges))) (- (nth 2 edges) (nth 0 edges))). */)
419 return make_number (window_box_text_cols (decode_any_window (window
)));
422 DEFUN ("window-hscroll", Fwindow_hscroll
, Swindow_hscroll
, 0, 1, 0,
423 doc
: /* Return the number of columns by which WINDOW is scrolled from left margin. */)
427 return decode_window (window
)->hscroll
;
430 DEFUN ("set-window-hscroll", Fset_window_hscroll
, Sset_window_hscroll
, 2, 2, 0,
431 doc
: /* Set number of columns WINDOW is scrolled from left margin to NCOL.
432 NCOL should be zero or positive.
434 Note that if `automatic-hscrolling' is non-nil, you cannot scroll the
435 window so that the location of point becomes invisible. */)
437 Lisp_Object window
, ncol
;
439 struct window
*w
= decode_window (window
);
443 hscroll
= max (0, XINT (ncol
));
445 /* Prevent redisplay shortcuts when changing the hscroll. */
446 if (XINT (w
->hscroll
) != hscroll
)
447 XBUFFER (w
->buffer
)->prevent_redisplay_optimizations_p
= 1;
449 w
->hscroll
= make_number (hscroll
);
453 DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger
,
454 Swindow_redisplay_end_trigger
, 0, 1, 0,
455 doc
: /* Return WINDOW's redisplay end trigger value.
456 See `set-window-redisplay-end-trigger' for more information. */)
460 return decode_window (window
)->redisplay_end_trigger
;
463 DEFUN ("set-window-redisplay-end-trigger", Fset_window_redisplay_end_trigger
,
464 Sset_window_redisplay_end_trigger
, 2, 2, 0,
465 doc
: /* Set WINDOW's redisplay end trigger value to VALUE.
466 VALUE should be a buffer position (typically a marker) or nil.
467 If it is a buffer position, then if redisplay in WINDOW reaches a position
468 beyond VALUE, the functions in `redisplay-end-trigger-functions' are called
469 with two arguments: WINDOW, and the end trigger value.
470 Afterwards the end-trigger value is reset to nil. */)
472 register Lisp_Object window
, value
;
474 register struct window
*w
;
476 w
= decode_window (window
);
477 w
->redisplay_end_trigger
= value
;
481 DEFUN ("window-edges", Fwindow_edges
, Swindow_edges
, 0, 1, 0,
482 doc
: /* Return a list of the edge coordinates of WINDOW.
483 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame.
484 RIGHT is one more than the rightmost column occupied by WINDOW,
485 and BOTTOM is one more than the bottommost row occupied by WINDOW.
486 The edges include the space used by the window's scroll bar,
487 display margins, fringes, header line, and mode line, if it has them.
488 To get the edges of the actual text area, use `window-inside-edges'. */)
492 register struct window
*w
= decode_any_window (window
);
494 return Fcons (make_number (WINDOW_LEFT_EDGE_COL (w
)),
495 Fcons (make_number (WINDOW_TOP_EDGE_LINE (w
)),
496 Fcons (make_number (WINDOW_RIGHT_EDGE_COL (w
)),
497 Fcons (make_number (WINDOW_BOTTOM_EDGE_LINE (w
)),
501 DEFUN ("window-pixel-edges", Fwindow_pixel_edges
, Swindow_pixel_edges
, 0, 1, 0,
502 doc
: /* Return a list of the edge pixel coordinates of WINDOW.
503 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame.
504 RIGHT is one more than the rightmost x position occupied by WINDOW,
505 and BOTTOM is one more than the bottommost y position occupied by WINDOW.
506 The pixel edges include the space used by the window's scroll bar,
507 display margins, fringes, header line, and mode line, if it has them.
508 To get the edges of the actual text area, use `window-inside-pixel-edges'. */)
512 register struct window
*w
= decode_any_window (window
);
514 return Fcons (make_number (WINDOW_LEFT_EDGE_X (w
)),
515 Fcons (make_number (WINDOW_TOP_EDGE_Y (w
)),
516 Fcons (make_number (WINDOW_RIGHT_EDGE_X (w
)),
517 Fcons (make_number (WINDOW_BOTTOM_EDGE_Y (w
)),
521 DEFUN ("window-inside-edges", Fwindow_inside_edges
, Swindow_inside_edges
, 0, 1, 0,
522 doc
: /* Return a list of the edge coordinates of WINDOW.
523 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame.
524 RIGHT is one more than the rightmost column used by text in WINDOW,
525 and BOTTOM is one more than the bottommost row used by text in WINDOW.
526 The inside edges do not include the space used by the window's scroll bar,
527 display margins, fringes, header line, and/or mode line. */)
531 register struct window
*w
= decode_any_window (window
);
533 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_COL (w
)
534 + WINDOW_LEFT_MARGIN_COLS (w
)
535 + WINDOW_LEFT_FRINGE_COLS (w
)),
536 make_number (WINDOW_TOP_EDGE_LINE (w
)
537 + WINDOW_HEADER_LINE_LINES (w
)),
538 make_number (WINDOW_RIGHT_EDGE_COL (w
)
539 - WINDOW_RIGHT_MARGIN_COLS (w
)
540 - WINDOW_RIGHT_FRINGE_COLS (w
)),
541 make_number (WINDOW_BOTTOM_EDGE_LINE (w
)
542 - WINDOW_MODE_LINE_LINES (w
)));
545 DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges
, Swindow_inside_pixel_edges
, 0, 1, 0,
546 doc
: /* Return a list of the edge coordinates of WINDOW.
547 \(LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at top left corner of frame.
548 RIGHT is one more than the rightmost x position used by text in WINDOW,
549 and BOTTOM is one more than the bottommost y position used by text in WINDOW.
550 The inside edges do not include the space used by the window's scroll bar,
551 display margins, fringes, header line, and/or mode line. */)
555 register struct window
*w
= decode_any_window (window
);
557 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w
)
558 + WINDOW_LEFT_MARGIN_WIDTH (w
)
559 + WINDOW_LEFT_FRINGE_WIDTH (w
)),
560 make_number (WINDOW_TOP_EDGE_Y (w
)
561 + WINDOW_HEADER_LINE_HEIGHT (w
)),
562 make_number (WINDOW_RIGHT_EDGE_X (w
)
563 - WINDOW_RIGHT_MARGIN_WIDTH (w
)
564 - WINDOW_RIGHT_FRINGE_WIDTH (w
)),
565 make_number (WINDOW_BOTTOM_EDGE_Y (w
)
566 - WINDOW_MODE_LINE_HEIGHT (w
)));
569 /* Test if the character at column *X, row *Y is within window W.
570 If it is not, return ON_NOTHING;
571 if it is in the window's text area,
572 set *x and *y to its location relative to the upper left corner
575 if it is on the window's modeline, return ON_MODE_LINE;
576 if it is on the border between the window and its right sibling,
577 return ON_VERTICAL_BORDER.
578 if it is on the window's top line, return ON_HEADER_LINE;
579 if it is in left or right fringe of the window,
580 return ON_LEFT_FRINGE or ON_RIGHT_FRINGE, and convert *X and *Y
581 to window-relative coordinates;
582 if it is in the marginal area to the left/right of the window,
583 return ON_LEFT_MARGIN or ON_RIGHT_MARGIN, and convert *X and *Y
584 to window-relative coordinates.
586 X and Y are frame relative pixel coordinates. */
588 static enum window_part
589 coordinates_in_window (w
, x
, y
)
590 register struct window
*w
;
593 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
594 int left_x
, right_x
, top_y
, bottom_y
;
595 enum window_part part
;
596 int ux
= FRAME_COLUMN_WIDTH (f
);
597 int x0
= WINDOW_LEFT_EDGE_X (w
);
598 int x1
= WINDOW_RIGHT_EDGE_X (w
);
599 /* The width of the area where the vertical line can be dragged.
600 (Between mode lines for instance. */
601 int grabbable_width
= ux
;
602 int lmargin_width
, rmargin_width
, text_left
, text_right
;
604 if (*x
< x0
|| *x
>= x1
)
607 /* In what's below, we subtract 1 when computing right_x because we
608 want the rightmost pixel, which is given by left_pixel+width-1. */
609 if (w
->pseudo_window_p
)
612 right_x
= WINDOW_TOTAL_WIDTH (w
) - 1;
613 top_y
= WINDOW_TOP_EDGE_Y (w
);
614 bottom_y
= WINDOW_BOTTOM_EDGE_Y (w
);
618 left_x
= WINDOW_BOX_LEFT_EDGE_X (w
);
619 right_x
= WINDOW_BOX_RIGHT_EDGE_X (w
) - 1;
620 top_y
= WINDOW_TOP_EDGE_Y (w
);
621 bottom_y
= WINDOW_BOTTOM_EDGE_Y (w
);
624 /* Outside any interesting row? */
625 if (*y
< top_y
|| *y
>= bottom_y
)
628 /* On the mode line or header line? If it's near the start of
629 the mode or header line of window that's has a horizontal
630 sibling, say it's on the vertical line. That's to be able
631 to resize windows horizontally in case we're using toolkit
634 if (WINDOW_WANTS_MODELINE_P (w
)
635 && *y
>= bottom_y
- CURRENT_MODE_LINE_HEIGHT (w
))
639 header_vertical_border_check
:
640 /* We're somewhere on the mode line. We consider the place
641 between mode lines of horizontally adjacent mode lines
642 as the vertical border. If scroll bars on the left,
643 return the right window. */
644 if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w
)
645 || WINDOW_RIGHTMOST_P (w
))
647 if (!WINDOW_LEFTMOST_P (w
) && abs (*x
- x0
) < grabbable_width
)
648 return ON_VERTICAL_BORDER
;
652 if (abs (*x
- x1
) < grabbable_width
)
653 return ON_VERTICAL_BORDER
;
656 /* Convert X and Y to window relative coordinates.
657 Mode line starts at left edge of window. */
663 if (WINDOW_WANTS_HEADER_LINE_P (w
)
664 && *y
< top_y
+ CURRENT_HEADER_LINE_HEIGHT (w
))
666 part
= ON_HEADER_LINE
;
667 goto header_vertical_border_check
;
670 /* Outside any interesting column? */
671 if (*x
< left_x
|| *x
> right_x
)
674 lmargin_width
= window_box_width (w
, LEFT_MARGIN_AREA
);
675 rmargin_width
= window_box_width (w
, RIGHT_MARGIN_AREA
);
677 text_left
= window_box_left (w
, TEXT_AREA
);
678 text_right
= text_left
+ window_box_width (w
, TEXT_AREA
);
680 if (FRAME_WINDOW_P (f
))
682 if (!w
->pseudo_window_p
683 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w
)
684 && !WINDOW_RIGHTMOST_P (w
)
685 && (abs (*x
- right_x
) < grabbable_width
))
686 return ON_VERTICAL_BORDER
;
690 /* Need to say "*x > right_x" rather than >=, since on character
691 terminals, the vertical line's x coordinate is right_x. */
692 if (!w
->pseudo_window_p
693 && !WINDOW_RIGHTMOST_P (w
)
694 && *x
> right_x
- ux
)
696 /* On the border on the right side of the window? Assume that
697 this area begins at RIGHT_X minus a canonical char width. */
698 return ON_VERTICAL_BORDER
;
704 if (lmargin_width
> 0
705 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w
)
706 ? (*x
>= left_x
+ WINDOW_LEFT_FRINGE_WIDTH (w
))
707 : (*x
< left_x
+ lmargin_width
)))
710 if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w
))
711 *x
-= WINDOW_LEFT_FRINGE_WIDTH (w
);
713 return ON_LEFT_MARGIN
;
716 /* Convert X and Y to window-relative pixel coordinates. */
719 return ON_LEFT_FRINGE
;
722 if (*x
>= text_right
)
724 if (rmargin_width
> 0
725 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w
)
726 ? (*x
< right_x
- WINDOW_RIGHT_FRINGE_WIDTH (w
))
727 : (*x
>= right_x
- rmargin_width
)))
730 if (!WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w
))
731 *x
-= WINDOW_RIGHT_FRINGE_WIDTH (w
);
733 return ON_RIGHT_MARGIN
;
736 /* Convert X and Y to window-relative pixel coordinates. */
737 *x
-= left_x
+ WINDOW_LEFT_FRINGE_WIDTH (w
);
739 return ON_RIGHT_FRINGE
;
742 /* Everything special ruled out - must be on text area */
743 *x
-= left_x
+ WINDOW_LEFT_FRINGE_WIDTH (w
);
749 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p
,
750 Scoordinates_in_window_p
, 2, 2, 0,
751 doc
: /* Return non-nil if COORDINATES are in WINDOW.
752 COORDINATES is a cons of the form (X . Y), X and Y being distances
753 measured in characters from the upper-left corner of the frame.
754 \(0 . 0) denotes the character in the upper left corner of the
756 If COORDINATES are in the text portion of WINDOW,
757 the coordinates relative to the window are returned.
758 If they are in the mode line of WINDOW, `mode-line' is returned.
759 If they are in the top mode line of WINDOW, `header-line' is returned.
760 If they are in the left fringe of WINDOW, `left-fringe' is returned.
761 If they are in the right fringe of WINDOW, `right-fringe' is returned.
762 If they are on the border between WINDOW and its right sibling,
763 `vertical-line' is returned.
764 If they are in the windows's left or right marginal areas, `left-margin'\n\
765 or `right-margin' is returned. */)
766 (coordinates
, window
)
767 register Lisp_Object coordinates
, window
;
774 CHECK_WINDOW (window
);
775 w
= XWINDOW (window
);
776 f
= XFRAME (w
->frame
);
777 CHECK_CONS (coordinates
);
778 lx
= Fcar (coordinates
);
779 ly
= Fcdr (coordinates
);
780 CHECK_NUMBER_OR_FLOAT (lx
);
781 CHECK_NUMBER_OR_FLOAT (ly
);
782 x
= FRAME_PIXEL_X_FROM_CANON_X (f
, lx
);
783 y
= FRAME_PIXEL_Y_FROM_CANON_Y (f
, ly
);
785 switch (coordinates_in_window (w
, &x
, &y
))
791 /* X and Y are now window relative pixel coordinates. Convert
792 them to canonical char units before returning them. */
793 return Fcons (FRAME_CANON_X_FROM_PIXEL_X (f
, x
),
794 FRAME_CANON_Y_FROM_PIXEL_Y (f
, y
));
799 case ON_VERTICAL_BORDER
:
800 return Qvertical_line
;
808 case ON_RIGHT_FRINGE
:
809 return Qright_fringe
;
814 case ON_RIGHT_MARGIN
:
815 return Qright_margin
;
823 /* Callback for foreach_window, used in window_from_coordinates.
824 Check if window W contains coordinates specified by USER_DATA which
825 is actually a pointer to a struct check_window_data CW.
827 Check if window W contains coordinates *CW->x and *CW->y. If it
828 does, return W in *CW->window, as Lisp_Object, and return in
829 *CW->part the part of the window under coordinates *X,*Y. Return
830 zero from this function to stop iterating over windows. */
832 struct check_window_data
836 enum window_part
*part
;
840 check_window_containing (w
, user_data
)
844 struct check_window_data
*cw
= (struct check_window_data
*) user_data
;
845 enum window_part found
;
848 found
= coordinates_in_window (w
, cw
->x
, cw
->y
);
849 if (found
!= ON_NOTHING
)
852 XSETWINDOW (*cw
->window
, w
);
860 /* Find the window containing frame-relative pixel position X/Y and
861 return it as a Lisp_Object.
863 If X, Y is on one of the window's special `window_part' elements,
864 set *PART to the id of that element, and return X and Y converted
865 to window relative coordinates in WX and WY.
867 If there is no window under X, Y return nil and leave *PART
868 unmodified. TOOL_BAR_P non-zero means detect tool-bar windows.
870 This function was previously implemented with a loop cycling over
871 windows with Fnext_window, and starting with the frame's selected
872 window. It turned out that this doesn't work with an
873 implementation of next_window using Vwindow_list, because
874 FRAME_SELECTED_WINDOW (F) is not always contained in the window
875 tree of F when this function is called asynchronously from
876 note_mouse_highlight. The original loop didn't terminate in this
880 window_from_coordinates (f
, x
, y
, part
, wx
, wy
, tool_bar_p
)
883 enum window_part
*part
;
888 struct check_window_data cw
;
889 enum window_part dummy
;
895 cw
.window
= &window
, cw
.x
= &x
, cw
.y
= &y
; cw
.part
= part
;
896 foreach_window (f
, check_window_containing
, &cw
);
898 /* If not found above, see if it's in the tool bar window, if a tool
902 && WINDOWP (f
->tool_bar_window
)
903 && WINDOW_TOTAL_LINES (XWINDOW (f
->tool_bar_window
)) > 0
904 && (coordinates_in_window (XWINDOW (f
->tool_bar_window
), &x
, &y
)
908 window
= f
->tool_bar_window
;
917 DEFUN ("window-at", Fwindow_at
, Swindow_at
, 2, 3, 0,
918 doc
: /* Return window containing coordinates X and Y on FRAME.
919 If omitted, FRAME defaults to the currently selected frame.
920 The top left corner of the frame is considered to be row 0,
923 Lisp_Object x
, y
, frame
;
928 frame
= selected_frame
;
929 CHECK_LIVE_FRAME (frame
);
932 /* Check that arguments are integers or floats. */
933 CHECK_NUMBER_OR_FLOAT (x
);
934 CHECK_NUMBER_OR_FLOAT (y
);
936 return window_from_coordinates (f
,
937 FRAME_PIXEL_X_FROM_CANON_X (f
, x
),
938 FRAME_PIXEL_Y_FROM_CANON_Y (f
, y
),
942 DEFUN ("window-point", Fwindow_point
, Swindow_point
, 0, 1, 0,
943 doc
: /* Return current value of point in WINDOW.
944 For a nonselected window, this is the value point would have
945 if that window were selected.
947 Note that, when WINDOW is the selected window and its buffer
948 is also currently selected, the value returned is the same as (point).
949 It would be more strictly correct to return the `top-level' value
950 of point, outside of any save-excursion forms.
951 But that is hard to define. */)
955 register struct window
*w
= decode_window (window
);
957 if (w
== XWINDOW (selected_window
)
958 && current_buffer
== XBUFFER (w
->buffer
))
960 return Fmarker_position (w
->pointm
);
963 DEFUN ("window-start", Fwindow_start
, Swindow_start
, 0, 1, 0,
964 doc
: /* Return position at which display currently starts in WINDOW.
965 This is updated by redisplay or by calling `set-window-start'. */)
969 return Fmarker_position (decode_window (window
)->start
);
972 /* This is text temporarily removed from the doc string below.
974 This function returns nil if the position is not currently known.
975 That happens when redisplay is preempted and doesn't finish.
976 If in that case you want to compute where the end of the window would
977 have been if redisplay had finished, do this:
979 (goto-char (window-start window))
980 (vertical-motion (1- (window-height window)) window)
983 DEFUN ("window-end", Fwindow_end
, Swindow_end
, 0, 2, 0,
984 doc
: /* Return position at which display currently ends in WINDOW.
985 This is updated by redisplay, when it runs to completion.
986 Simply changing the buffer text or setting `window-start'
987 does not update this value.
988 If UPDATE is non-nil, compute the up-to-date position
989 if it isn't already recorded. */)
991 Lisp_Object window
, update
;
994 struct window
*w
= decode_window (window
);
1000 #if 0 /* This change broke some things. We should make it later. */
1001 /* If we don't know the end position, return nil.
1002 The user can compute it with vertical-motion if he wants to.
1003 It would be nicer to do it automatically,
1004 but that's so slow that it would probably bother people. */
1005 if (NILP (w
->window_end_valid
))
1010 && ! (! NILP (w
->window_end_valid
)
1011 && XFASTINT (w
->last_modified
) >= MODIFF
))
1013 struct text_pos startp
;
1015 struct buffer
*old_buffer
= NULL
, *b
= XBUFFER (buf
);
1017 /* In case W->start is out of the range, use something
1018 reasonable. This situation occurred when loading a file with
1019 `-l' containing a call to `rmail' with subsequent other
1020 commands. At the end, W->start happened to be BEG, while
1021 rmail had already narrowed the buffer. */
1022 if (XMARKER (w
->start
)->charpos
< BEGV
)
1023 SET_TEXT_POS (startp
, BEGV
, BEGV_BYTE
);
1024 else if (XMARKER (w
->start
)->charpos
> ZV
)
1025 SET_TEXT_POS (startp
, ZV
, ZV_BYTE
);
1027 SET_TEXT_POS_FROM_MARKER (startp
, w
->start
);
1029 /* Cannot use Fvertical_motion because that function doesn't
1030 cope with variable-height lines. */
1031 if (b
!= current_buffer
)
1033 old_buffer
= current_buffer
;
1034 set_buffer_internal (b
);
1037 start_display (&it
, w
, startp
);
1038 move_it_vertically (&it
, window_box_height (w
));
1039 if (it
.current_y
< it
.last_visible_y
)
1040 move_it_past_eol (&it
);
1041 value
= make_number (IT_CHARPOS (it
));
1044 set_buffer_internal (old_buffer
);
1047 XSETINT (value
, BUF_Z (XBUFFER (buf
)) - XFASTINT (w
->window_end_pos
));
1052 DEFUN ("set-window-point", Fset_window_point
, Sset_window_point
, 2, 2, 0,
1053 doc
: /* Make point value in WINDOW be at position POS in WINDOW's buffer. */)
1055 Lisp_Object window
, pos
;
1057 register struct window
*w
= decode_window (window
);
1059 CHECK_NUMBER_COERCE_MARKER (pos
);
1060 if (w
== XWINDOW (selected_window
)
1061 && XBUFFER (w
->buffer
) == current_buffer
)
1064 set_marker_restricted (w
->pointm
, pos
, w
->buffer
);
1066 /* We have to make sure that redisplay updates the window to show
1067 the new value of point. */
1068 if (!EQ (window
, selected_window
))
1069 ++windows_or_buffers_changed
;
1074 DEFUN ("set-window-start", Fset_window_start
, Sset_window_start
, 2, 3, 0,
1075 doc
: /* Make display in WINDOW start at position POS in WINDOW's buffer.
1076 Optional third arg NOFORCE non-nil inhibits next redisplay
1077 from overriding motion of point in order to display at this exact start. */)
1078 (window
, pos
, noforce
)
1079 Lisp_Object window
, pos
, noforce
;
1081 register struct window
*w
= decode_window (window
);
1083 CHECK_NUMBER_COERCE_MARKER (pos
);
1084 set_marker_restricted (w
->start
, pos
, w
->buffer
);
1085 /* this is not right, but much easier than doing what is right. */
1086 w
->start_at_line_beg
= Qnil
;
1088 w
->force_start
= Qt
;
1089 w
->update_mode_line
= Qt
;
1090 XSETFASTINT (w
->last_modified
, 0);
1091 XSETFASTINT (w
->last_overlay_modified
, 0);
1092 if (!EQ (window
, selected_window
))
1093 windows_or_buffers_changed
++;
1098 DEFUN ("window-dedicated-p", Fwindow_dedicated_p
, Swindow_dedicated_p
,
1100 doc
: /* Return WINDOW's dedicated object, usually t or nil.
1101 See also `set-window-dedicated-p'. */)
1105 return decode_window (window
)->dedicated
;
1108 DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p
,
1109 Sset_window_dedicated_p
, 2, 2, 0,
1110 doc
: /* Control whether WINDOW is dedicated to the buffer it displays.
1111 If it is dedicated, Emacs will not automatically change
1112 which buffer appears in it.
1113 The second argument is the new value for the dedication flag;
1114 non-nil means yes. */)
1116 Lisp_Object window
, arg
;
1118 register struct window
*w
= decode_window (window
);
1122 return w
->dedicated
;
1125 DEFUN ("window-display-table", Fwindow_display_table
, Swindow_display_table
,
1127 doc
: /* Return the display-table that WINDOW is using. */)
1131 return decode_window (window
)->display_table
;
1134 /* Get the display table for use on window W. This is either W's
1135 display table or W's buffer's display table. Ignore the specified
1136 tables if they are not valid; if no valid table is specified,
1139 struct Lisp_Char_Table
*
1140 window_display_table (w
)
1143 struct Lisp_Char_Table
*dp
= NULL
;
1145 if (DISP_TABLE_P (w
->display_table
))
1146 dp
= XCHAR_TABLE (w
->display_table
);
1147 else if (BUFFERP (w
->buffer
))
1149 struct buffer
*b
= XBUFFER (w
->buffer
);
1151 if (DISP_TABLE_P (b
->display_table
))
1152 dp
= XCHAR_TABLE (b
->display_table
);
1153 else if (DISP_TABLE_P (Vstandard_display_table
))
1154 dp
= XCHAR_TABLE (Vstandard_display_table
);
1160 DEFUN ("set-window-display-table", Fset_window_display_table
, Sset_window_display_table
, 2, 2, 0,
1161 doc
: /* Set WINDOW's display-table to TABLE. */)
1163 register Lisp_Object window
, table
;
1165 register struct window
*w
;
1167 w
= decode_window (window
);
1168 w
->display_table
= table
;
1172 /* Record info on buffer window w is displaying
1173 when it is about to cease to display that buffer. */
1176 register struct window
*w
;
1183 if (b
!= XMARKER (w
->pointm
)->buffer
)
1187 if (w
== XWINDOW (selected_window
)
1188 || ! EQ (buf
, XWINDOW (selected_window
)->buffer
))
1189 /* Do this except when the selected window's buffer
1190 is being removed from some other window. */
1192 /* last_window_start records the start position that this buffer
1193 had in the last window to be disconnected from it.
1194 Now that this statement is unconditional,
1195 it is possible for the buffer to be displayed in the
1196 selected window, while last_window_start reflects another
1197 window which was recently showing the same buffer.
1198 Some people might say that might be a good thing. Let's see. */
1199 b
->last_window_start
= marker_position (w
->start
);
1201 /* Point in the selected window's buffer
1202 is actually stored in that buffer, and the window's pointm isn't used.
1203 So don't clobber point in that buffer. */
1204 if (! EQ (buf
, XWINDOW (selected_window
)->buffer
)
1205 /* This line helps to fix Horsley's testbug.el bug. */
1206 && !(WINDOWP (b
->last_selected_window
)
1207 && w
!= XWINDOW (b
->last_selected_window
)
1208 && EQ (buf
, XWINDOW (b
->last_selected_window
)->buffer
)))
1209 temp_set_point_both (b
,
1210 clip_to_bounds (BUF_BEGV (b
),
1211 XMARKER (w
->pointm
)->charpos
,
1213 clip_to_bounds (BUF_BEGV_BYTE (b
),
1214 marker_byte_position (w
->pointm
),
1217 if (WINDOWP (b
->last_selected_window
)
1218 && w
== XWINDOW (b
->last_selected_window
))
1219 b
->last_selected_window
= Qnil
;
1222 /* Put replacement into the window structure in place of old. */
1224 replace_window (old
, replacement
)
1225 Lisp_Object old
, replacement
;
1227 register Lisp_Object tem
;
1228 register struct window
*o
= XWINDOW (old
), *p
= XWINDOW (replacement
);
1230 /* If OLD is its frame's root_window, then replacement is the new
1231 root_window for that frame. */
1233 if (EQ (old
, FRAME_ROOT_WINDOW (XFRAME (o
->frame
))))
1234 FRAME_ROOT_WINDOW (XFRAME (o
->frame
)) = replacement
;
1236 p
->left_col
= o
->left_col
;
1237 p
->top_line
= o
->top_line
;
1238 p
->total_cols
= o
->total_cols
;
1239 p
->total_lines
= o
->total_lines
;
1240 p
->desired_matrix
= p
->current_matrix
= 0;
1242 bzero (&p
->cursor
, sizeof (p
->cursor
));
1243 bzero (&p
->last_cursor
, sizeof (p
->last_cursor
));
1244 bzero (&p
->phys_cursor
, sizeof (p
->phys_cursor
));
1245 p
->phys_cursor_type
= -1;
1246 p
->phys_cursor_width
= -1;
1247 p
->must_be_updated_p
= 0;
1248 p
->pseudo_window_p
= 0;
1249 XSETFASTINT (p
->window_end_vpos
, 0);
1250 XSETFASTINT (p
->window_end_pos
, 0);
1251 p
->window_end_valid
= Qnil
;
1252 p
->frozen_window_start_p
= 0;
1253 p
->orig_top_line
= p
->orig_total_lines
= Qnil
;
1255 p
->next
= tem
= o
->next
;
1257 XWINDOW (tem
)->prev
= replacement
;
1259 p
->prev
= tem
= o
->prev
;
1261 XWINDOW (tem
)->next
= replacement
;
1263 p
->parent
= tem
= o
->parent
;
1266 if (EQ (XWINDOW (tem
)->vchild
, old
))
1267 XWINDOW (tem
)->vchild
= replacement
;
1268 if (EQ (XWINDOW (tem
)->hchild
, old
))
1269 XWINDOW (tem
)->hchild
= replacement
;
1272 /*** Here, if replacement is a vertical combination
1273 and so is its new parent, we should make replacement's
1274 children be children of that parent instead. ***/
1277 DEFUN ("delete-window", Fdelete_window
, Sdelete_window
, 0, 1, "",
1278 doc
: /* Remove WINDOW from the display. Default is selected window. */)
1280 register Lisp_Object window
;
1282 delete_window (window
);
1284 if (! NILP (Vwindow_configuration_change_hook
)
1285 && ! NILP (Vrun_hooks
))
1286 call1 (Vrun_hooks
, Qwindow_configuration_change_hook
);
1292 delete_window (window
)
1293 register Lisp_Object window
;
1295 register Lisp_Object tem
, parent
, sib
;
1296 register struct window
*p
;
1297 register struct window
*par
;
1300 /* Because this function is called by other C code on non-leaf
1301 windows, the CHECK_LIVE_WINDOW macro would choke inappropriately,
1302 so we can't decode_window here. */
1304 window
= selected_window
;
1306 CHECK_WINDOW (window
);
1307 p
= XWINDOW (window
);
1309 /* It's okay to delete an already-deleted window. */
1310 if (NILP (p
->buffer
)
1312 && NILP (p
->vchild
))
1317 error ("Attempt to delete minibuffer or sole ordinary window");
1318 par
= XWINDOW (parent
);
1320 windows_or_buffers_changed
++;
1321 Vwindow_list
= Qnil
;
1322 f
= XFRAME (WINDOW_FRAME (p
));
1323 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
1325 /* Are we trying to delete any frame's selected window? */
1327 Lisp_Object swindow
, pwindow
;
1329 /* See if the frame's selected window is either WINDOW
1330 or any subwindow of it, by finding all that window's parents
1331 and comparing each one with WINDOW. */
1332 swindow
= FRAME_SELECTED_WINDOW (f
);
1337 while (!NILP (pwindow
))
1339 if (EQ (window
, pwindow
))
1341 pwindow
= XWINDOW (pwindow
)->parent
;
1344 /* If the window being deleted is not a parent of SWINDOW,
1345 then SWINDOW is ok as the new selected window. */
1346 if (!EQ (window
, pwindow
))
1348 /* Otherwise, try another window for SWINDOW. */
1349 swindow
= Fnext_window (swindow
, Qlambda
, Qnil
);;
1351 /* If we get back to the frame's selected window,
1352 it means there was no acceptable alternative,
1353 so we cannot delete. */
1354 if (EQ (swindow
, FRAME_SELECTED_WINDOW (f
)))
1355 error ("Cannot delete window");
1358 /* If we need to change SWINDOW, do it. */
1359 if (! EQ (swindow
, FRAME_SELECTED_WINDOW (f
)))
1361 /* If we're about to delete the selected window on the
1362 selected frame, then we should use Fselect_window to select
1363 the new window. On the other hand, if we're about to
1364 delete the selected window on any other frame, we shouldn't do
1365 anything but set the frame's selected_window slot. */
1366 if (EQ (FRAME_SELECTED_WINDOW (f
), selected_window
))
1367 Fselect_window (swindow
, Qnil
);
1369 FRAME_SELECTED_WINDOW (f
) = swindow
;
1374 /* tem is null for dummy parent windows
1375 (which have inferiors but not any contents themselves) */
1379 unchain_marker (XMARKER (p
->pointm
));
1380 unchain_marker (XMARKER (p
->start
));
1383 /* Free window glyph matrices. It is sure that they are allocated
1384 again when ADJUST_GLYPHS is called. Block input so that expose
1385 events and other events that access glyph matrices are not
1386 processed while we are changing them. */
1388 free_window_matrices (XWINDOW (FRAME_ROOT_WINDOW (f
)));
1392 XWINDOW (tem
)->prev
= p
->prev
;
1396 XWINDOW (tem
)->next
= p
->next
;
1398 if (EQ (window
, par
->hchild
))
1399 par
->hchild
= p
->next
;
1400 if (EQ (window
, par
->vchild
))
1401 par
->vchild
= p
->next
;
1403 /* Find one of our siblings to give our space to. */
1407 /* If p gives its space to its next sibling, that sibling needs
1408 to have its top/left side pulled back to where p's is.
1409 set_window_{height,width} will re-position the sibling's
1412 XWINDOW (sib
)->top_line
= p
->top_line
;
1413 XWINDOW (sib
)->left_col
= p
->left_col
;
1416 /* Stretch that sibling. */
1417 if (!NILP (par
->vchild
))
1418 set_window_height (sib
,
1419 XFASTINT (XWINDOW (sib
)->total_lines
) + XFASTINT (p
->total_lines
),
1421 if (!NILP (par
->hchild
))
1422 set_window_width (sib
,
1423 XFASTINT (XWINDOW (sib
)->total_cols
) + XFASTINT (p
->total_cols
),
1426 /* If parent now has only one child,
1427 put the child into the parent's place. */
1431 if (NILP (XWINDOW (tem
)->next
))
1432 replace_window (parent
, tem
);
1434 /* Since we may be deleting combination windows, we must make sure that
1435 not only p but all its children have been marked as deleted. */
1436 if (! NILP (p
->hchild
))
1437 delete_all_subwindows (XWINDOW (p
->hchild
));
1438 else if (! NILP (p
->vchild
))
1439 delete_all_subwindows (XWINDOW (p
->vchild
));
1441 /* Mark this window as deleted. */
1442 p
->buffer
= p
->hchild
= p
->vchild
= Qnil
;
1444 /* Adjust glyph matrices. */
1451 /***********************************************************************
1453 ***********************************************************************/
1455 /* Add window W to *USER_DATA. USER_DATA is actually a Lisp_Object
1456 pointer. This is a callback function for foreach_window, used in
1457 function window_list. */
1460 add_window_to_list (w
, user_data
)
1464 Lisp_Object
*list
= (Lisp_Object
*) user_data
;
1466 XSETWINDOW (window
, w
);
1467 *list
= Fcons (window
, *list
);
1472 /* Return a list of all windows, for use by next_window. If
1473 Vwindow_list is a list, return that list. Otherwise, build a new
1474 list, cache it in Vwindow_list, and return that. */
1479 if (!CONSP (Vwindow_list
))
1483 Vwindow_list
= Qnil
;
1484 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
1486 Lisp_Object args
[2];
1488 /* We are visiting windows in canonical order, and add
1489 new windows at the front of args[1], which means we
1490 have to reverse this list at the end. */
1492 foreach_window (XFRAME (XCAR (tail
)), add_window_to_list
, &args
[1]);
1493 args
[0] = Vwindow_list
;
1494 args
[1] = Fnreverse (args
[1]);
1495 Vwindow_list
= Fnconc (2, args
);
1499 return Vwindow_list
;
1503 /* Value is non-zero if WINDOW satisfies the constraints given by
1504 OWINDOW, MINIBUF and ALL_FRAMES.
1506 MINIBUF t means WINDOW may be minibuffer windows.
1507 `lambda' means WINDOW may not be a minibuffer window.
1508 a window means a specific minibuffer window
1510 ALL_FRAMES t means search all frames,
1511 nil means search just current frame,
1512 `visible' means search just visible frames,
1513 0 means search visible and iconified frames,
1514 a window means search the frame that window belongs to,
1515 a frame means consider windows on that frame, only. */
1518 candidate_window_p (window
, owindow
, minibuf
, all_frames
)
1519 Lisp_Object window
, owindow
, minibuf
, all_frames
;
1521 struct window
*w
= XWINDOW (window
);
1522 struct frame
*f
= XFRAME (w
->frame
);
1523 int candidate_p
= 1;
1525 if (!BUFFERP (w
->buffer
))
1527 else if (MINI_WINDOW_P (w
)
1528 && (EQ (minibuf
, Qlambda
)
1529 || (WINDOWP (minibuf
) && !EQ (minibuf
, window
))))
1531 /* If MINIBUF is `lambda' don't consider any mini-windows.
1532 If it is a window, consider only that one. */
1535 else if (EQ (all_frames
, Qt
))
1537 else if (NILP (all_frames
))
1539 xassert (WINDOWP (owindow
));
1540 candidate_p
= EQ (w
->frame
, XWINDOW (owindow
)->frame
);
1542 else if (EQ (all_frames
, Qvisible
))
1544 FRAME_SAMPLE_VISIBILITY (f
);
1545 candidate_p
= FRAME_VISIBLE_P (f
);
1547 else if (INTEGERP (all_frames
) && XINT (all_frames
) == 0)
1549 FRAME_SAMPLE_VISIBILITY (f
);
1550 candidate_p
= FRAME_VISIBLE_P (f
) || FRAME_ICONIFIED_P (f
);
1552 else if (WINDOWP (all_frames
))
1553 candidate_p
= (EQ (FRAME_MINIBUF_WINDOW (f
), all_frames
)
1554 || EQ (XWINDOW (all_frames
)->frame
, w
->frame
)
1555 || EQ (XWINDOW (all_frames
)->frame
, FRAME_FOCUS_FRAME (f
)));
1556 else if (FRAMEP (all_frames
))
1557 candidate_p
= EQ (all_frames
, w
->frame
);
1563 /* Decode arguments as allowed by Fnext_window, Fprevious_window, and
1564 Fwindow_list. See there for the meaning of WINDOW, MINIBUF, and
1568 decode_next_window_args (window
, minibuf
, all_frames
)
1569 Lisp_Object
*window
, *minibuf
, *all_frames
;
1572 *window
= selected_window
;
1574 CHECK_LIVE_WINDOW (*window
);
1576 /* MINIBUF nil may or may not include minibuffers. Decide if it
1578 if (NILP (*minibuf
))
1579 *minibuf
= minibuf_level
? minibuf_window
: Qlambda
;
1580 else if (!EQ (*minibuf
, Qt
))
1583 /* Now *MINIBUF can be t => count all minibuffer windows, `lambda'
1584 => count none of them, or a specific minibuffer window (the
1585 active one) to count. */
1587 /* ALL_FRAMES nil doesn't specify which frames to include. */
1588 if (NILP (*all_frames
))
1589 *all_frames
= (!EQ (*minibuf
, Qlambda
)
1590 ? FRAME_MINIBUF_WINDOW (XFRAME (XWINDOW (*window
)->frame
))
1592 else if (EQ (*all_frames
, Qvisible
))
1594 else if (XFASTINT (*all_frames
) == 0)
1596 else if (FRAMEP (*all_frames
))
1598 else if (!EQ (*all_frames
, Qt
))
1601 /* Now *ALL_FRAMES is t meaning search all frames, nil meaning
1602 search just current frame, `visible' meaning search just visible
1603 frames, 0 meaning search visible and iconified frames, or a
1604 window, meaning search the frame that window belongs to, or a
1605 frame, meaning consider windows on that frame, only. */
1609 /* Return the next or previous window of WINDOW in canonical ordering
1610 of windows. NEXT_P non-zero means return the next window. See the
1611 documentation string of next-window for the meaning of MINIBUF and
1615 next_window (window
, minibuf
, all_frames
, next_p
)
1616 Lisp_Object window
, minibuf
, all_frames
;
1619 decode_next_window_args (&window
, &minibuf
, &all_frames
);
1621 /* If ALL_FRAMES is a frame, and WINDOW isn't on that frame, just
1622 return the first window on the frame. */
1623 if (FRAMEP (all_frames
)
1624 && !EQ (all_frames
, XWINDOW (window
)->frame
))
1625 return Fframe_first_window (all_frames
);
1631 /* Find WINDOW in the list of all windows. */
1632 list
= Fmemq (window
, window_list ());
1634 /* Scan forward from WINDOW to the end of the window list. */
1636 for (list
= XCDR (list
); CONSP (list
); list
= XCDR (list
))
1637 if (candidate_window_p (XCAR (list
), window
, minibuf
, all_frames
))
1640 /* Scan from the start of the window list up to WINDOW. */
1642 for (list
= Vwindow_list
;
1643 CONSP (list
) && !EQ (XCAR (list
), window
);
1645 if (candidate_window_p (XCAR (list
), window
, minibuf
, all_frames
))
1649 window
= XCAR (list
);
1653 Lisp_Object candidate
, list
;
1655 /* Scan through the list of windows for candidates. If there are
1656 candidate windows in front of WINDOW, the last one of these
1657 is the one we want. If there are candidates following WINDOW
1658 in the list, again the last one of these is the one we want. */
1660 for (list
= window_list (); CONSP (list
); list
= XCDR (list
))
1662 if (EQ (XCAR (list
), window
))
1664 if (WINDOWP (candidate
))
1667 else if (candidate_window_p (XCAR (list
), window
, minibuf
,
1669 candidate
= XCAR (list
);
1672 if (WINDOWP (candidate
))
1680 DEFUN ("next-window", Fnext_window
, Snext_window
, 0, 3, 0,
1681 doc
: /* Return next window after WINDOW in canonical ordering of windows.
1682 If omitted, WINDOW defaults to the selected window.
1684 Optional second arg MINIBUF t means count the minibuffer window even
1685 if not active. MINIBUF nil or omitted means count the minibuffer iff
1686 it is active. MINIBUF neither t nor nil means not to count the
1687 minibuffer even if it is active.
1689 Several frames may share a single minibuffer; if the minibuffer
1690 counts, all windows on all frames that share that minibuffer count
1691 too. Therefore, `next-window' can be used to iterate through the
1692 set of windows even when the minibuffer is on another frame. If the
1693 minibuffer does not count, only windows from WINDOW's frame count.
1695 Optional third arg ALL-FRAMES t means include windows on all frames.
1696 ALL-FRAMES nil or omitted means cycle within the frames as specified
1697 above. ALL-FRAMES = `visible' means include windows on all visible frames.
1698 ALL-FRAMES = 0 means include windows on all visible and iconified frames.
1699 If ALL-FRAMES is a frame, restrict search to windows on that frame.
1700 Anything else means restrict to WINDOW's frame.
1702 If you use consistent values for MINIBUF and ALL-FRAMES, you can use
1703 `next-window' to iterate through the entire cycle of acceptable
1704 windows, eventually ending up back at the window you started with.
1705 `previous-window' traverses the same cycle, in the reverse order. */)
1706 (window
, minibuf
, all_frames
)
1707 Lisp_Object window
, minibuf
, all_frames
;
1709 return next_window (window
, minibuf
, all_frames
, 1);
1713 DEFUN ("previous-window", Fprevious_window
, Sprevious_window
, 0, 3, 0,
1714 doc
: /* Return the window preceding WINDOW in canonical ordering of windows.
1715 If omitted, WINDOW defaults to the selected window.
1717 Optional second arg MINIBUF t means count the minibuffer window even
1718 if not active. MINIBUF nil or omitted means count the minibuffer iff
1719 it is active. MINIBUF neither t nor nil means not to count the
1720 minibuffer even if it is active.
1722 Several frames may share a single minibuffer; if the minibuffer
1723 counts, all windows on all frames that share that minibuffer count
1724 too. Therefore, `previous-window' can be used to iterate through
1725 the set of windows even when the minibuffer is on another frame. If
1726 the minibuffer does not count, only windows from WINDOW's frame count
1728 Optional third arg ALL-FRAMES t means include windows on all frames.
1729 ALL-FRAMES nil or omitted means cycle within the frames as specified
1730 above. ALL-FRAMES = `visible' means include windows on all visible frames.
1731 ALL-FRAMES = 0 means include windows on all visible and iconified frames.
1732 If ALL-FRAMES is a frame, restrict search to windows on that frame.
1733 Anything else means restrict to WINDOW's frame.
1735 If you use consistent values for MINIBUF and ALL-FRAMES, you can use
1736 `previous-window' to iterate through the entire cycle of acceptable
1737 windows, eventually ending up back at the window you started with.
1738 `next-window' traverses the same cycle, in the reverse order. */)
1739 (window
, minibuf
, all_frames
)
1740 Lisp_Object window
, minibuf
, all_frames
;
1742 return next_window (window
, minibuf
, all_frames
, 0);
1746 DEFUN ("other-window", Fother_window
, Sother_window
, 1, 2, "p",
1747 doc
: /* Select the ARG'th different window on this frame.
1748 All windows on current frame are arranged in a cyclic order.
1749 This command selects the window ARG steps away in that order.
1750 A negative ARG moves in the opposite order. If the optional second
1751 argument ALL_FRAMES is non-nil, cycle through all frames. */)
1753 Lisp_Object arg
, all_frames
;
1759 window
= selected_window
;
1761 for (i
= XINT (arg
); i
> 0; --i
)
1762 window
= Fnext_window (window
, Qnil
, all_frames
);
1764 window
= Fprevious_window (window
, Qnil
, all_frames
);
1766 Fselect_window (window
, Qnil
);
1771 DEFUN ("window-list", Fwindow_list
, Swindow_list
, 0, 3, 0,
1772 doc
: /* Return a list of windows on FRAME, starting with WINDOW.
1773 FRAME nil or omitted means use the selected frame.
1774 WINDOW nil or omitted means use the selected window.
1775 MINIBUF t means include the minibuffer window, even if it isn't active.
1776 MINIBUF nil or omitted means include the minibuffer window only
1778 MINIBUF neither nil nor t means never include the minibuffer window. */)
1779 (frame
, minibuf
, window
)
1780 Lisp_Object frame
, minibuf
, window
;
1783 window
= selected_window
;
1785 frame
= selected_frame
;
1787 if (!EQ (frame
, XWINDOW (window
)->frame
))
1788 error ("Window is on a different frame");
1790 return window_list_1 (window
, minibuf
, frame
);
1794 /* Return a list of windows in canonical ordering. Arguments are like
1795 for `next-window'. */
1798 window_list_1 (window
, minibuf
, all_frames
)
1799 Lisp_Object window
, minibuf
, all_frames
;
1801 Lisp_Object tail
, list
;
1803 decode_next_window_args (&window
, &minibuf
, &all_frames
);
1806 for (tail
= window_list (); CONSP (tail
); tail
= XCDR (tail
))
1807 if (candidate_window_p (XCAR (tail
), window
, minibuf
, all_frames
))
1808 list
= Fcons (XCAR (tail
), list
);
1810 return Fnreverse (list
);
1815 /* Look at all windows, performing an operation specified by TYPE
1817 If FRAMES is Qt, look at all frames;
1818 Qnil, look at just the selected frame;
1819 Qvisible, look at visible frames;
1820 a frame, just look at windows on that frame.
1821 If MINI is non-zero, perform the operation on minibuffer windows too. */
1826 GET_BUFFER_WINDOW
, /* Arg is buffer */
1827 GET_LRU_WINDOW
, /* Arg is t for full-width windows only */
1828 DELETE_OTHER_WINDOWS
, /* Arg is window not to delete */
1829 DELETE_BUFFER_WINDOWS
, /* Arg is buffer */
1831 UNSHOW_BUFFER
, /* Arg is buffer */
1832 REDISPLAY_BUFFER_WINDOWS
, /* Arg is buffer */
1837 window_loop (type
, obj
, mini
, frames
)
1838 enum window_loop type
;
1839 Lisp_Object obj
, frames
;
1842 Lisp_Object window
, windows
, best_window
, frame_arg
;
1844 struct gcpro gcpro1
;
1846 /* If we're only looping through windows on a particular frame,
1847 frame points to that frame. If we're looping through windows
1848 on all frames, frame is 0. */
1849 if (FRAMEP (frames
))
1850 f
= XFRAME (frames
);
1851 else if (NILP (frames
))
1852 f
= SELECTED_FRAME ();
1857 frame_arg
= Qlambda
;
1858 else if (XFASTINT (frames
) == 0)
1860 else if (EQ (frames
, Qvisible
))
1865 /* frame_arg is Qlambda to stick to one frame,
1866 Qvisible to consider all visible frames,
1869 /* Pick a window to start with. */
1873 window
= FRAME_SELECTED_WINDOW (f
);
1875 window
= FRAME_SELECTED_WINDOW (SELECTED_FRAME ());
1877 windows
= window_list_1 (window
, mini
? Qt
: Qnil
, frame_arg
);
1881 for (; CONSP (windows
); windows
= CDR (windows
))
1885 window
= XCAR (windows
);
1886 w
= XWINDOW (window
);
1888 /* Note that we do not pay attention here to whether the frame
1889 is visible, since Fwindow_list skips non-visible frames if
1890 that is desired, under the control of frame_arg. */
1891 if (!MINI_WINDOW_P (w
)
1892 /* For UNSHOW_BUFFER, we must always consider all windows. */
1893 || type
== UNSHOW_BUFFER
1894 || (mini
&& minibuf_level
> 0))
1897 case GET_BUFFER_WINDOW
:
1898 if (EQ (w
->buffer
, obj
)
1899 /* Don't find any minibuffer window
1900 except the one that is currently in use. */
1901 && (MINI_WINDOW_P (w
)
1902 ? EQ (window
, minibuf_window
)
1905 if (NILP (best_window
))
1906 best_window
= window
;
1907 else if (EQ (window
, selected_window
))
1908 /* For compatibility with 20.x, prefer to return
1910 best_window
= window
;
1914 case GET_LRU_WINDOW
:
1915 /* t as arg means consider only full-width windows */
1916 if (!NILP (obj
) && !WINDOW_FULL_WIDTH_P (w
))
1918 /* Ignore dedicated windows and minibuffers. */
1919 if (MINI_WINDOW_P (w
) || EQ (w
->dedicated
, Qt
))
1921 if (NILP (best_window
)
1922 || (XFASTINT (XWINDOW (best_window
)->use_time
)
1923 > XFASTINT (w
->use_time
)))
1924 best_window
= window
;
1927 case DELETE_OTHER_WINDOWS
:
1928 if (!EQ (window
, obj
))
1929 Fdelete_window (window
);
1932 case DELETE_BUFFER_WINDOWS
:
1933 if (EQ (w
->buffer
, obj
))
1935 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
1937 /* If this window is dedicated, and in a frame of its own,
1939 if (EQ (window
, FRAME_ROOT_WINDOW (f
))
1940 && !NILP (w
->dedicated
)
1941 && other_visible_frames (f
))
1943 /* Skip the other windows on this frame.
1944 There might be one, the minibuffer! */
1945 while (CONSP (XCDR (windows
))
1946 && EQ (XWINDOW (XCAR (windows
))->frame
,
1947 XWINDOW (XCAR (XCDR (windows
)))->frame
))
1948 windows
= XCDR (windows
);
1950 /* Now we can safely delete the frame. */
1951 Fdelete_frame (w
->frame
, Qnil
);
1953 else if (NILP (w
->parent
))
1955 /* If we're deleting the buffer displayed in the
1956 only window on the frame, find a new buffer to
1959 buffer
= Fother_buffer (obj
, Qnil
, w
->frame
);
1960 Fset_window_buffer (window
, buffer
, Qnil
);
1961 if (EQ (window
, selected_window
))
1962 Fset_buffer (w
->buffer
);
1965 Fdelete_window (window
);
1969 case GET_LARGEST_WINDOW
:
1971 /* Ignore dedicated windows and minibuffers. */
1972 if (MINI_WINDOW_P (w
) || EQ (w
->dedicated
, Qt
))
1975 if (NILP (best_window
))
1976 best_window
= window
;
1979 struct window
*b
= XWINDOW (best_window
);
1980 if (XFASTINT (w
->total_lines
) * XFASTINT (w
->total_cols
)
1981 > XFASTINT (b
->total_lines
) * XFASTINT (b
->total_cols
))
1982 best_window
= window
;
1988 if (EQ (w
->buffer
, obj
))
1991 struct frame
*f
= XFRAME (w
->frame
);
1993 /* Find another buffer to show in this window. */
1994 buffer
= Fother_buffer (obj
, Qnil
, w
->frame
);
1996 /* If this window is dedicated, and in a frame of its own,
1998 if (EQ (window
, FRAME_ROOT_WINDOW (f
))
1999 && !NILP (w
->dedicated
)
2000 && other_visible_frames (f
))
2002 /* Skip the other windows on this frame.
2003 There might be one, the minibuffer! */
2004 while (CONSP (XCDR (windows
))
2005 && EQ (XWINDOW (XCAR (windows
))->frame
,
2006 XWINDOW (XCAR (XCDR (windows
)))->frame
))
2007 windows
= XCDR (windows
);
2009 /* Now we can safely delete the frame. */
2010 Fdelete_frame (w
->frame
, Qnil
);
2012 else if (!NILP (w
->dedicated
) && !NILP (w
->parent
))
2015 XSETWINDOW (window
, w
);
2016 /* If this window is dedicated and not the only window
2017 in its frame, then kill it. */
2018 Fdelete_window (window
);
2022 /* Otherwise show a different buffer in the window. */
2023 w
->dedicated
= Qnil
;
2024 Fset_window_buffer (window
, buffer
, Qnil
);
2025 if (EQ (window
, selected_window
))
2026 Fset_buffer (w
->buffer
);
2031 case REDISPLAY_BUFFER_WINDOWS
:
2032 if (EQ (w
->buffer
, obj
))
2034 mark_window_display_accurate (window
, 0);
2035 w
->update_mode_line
= Qt
;
2036 XBUFFER (obj
)->prevent_redisplay_optimizations_p
= 1;
2037 ++update_mode_lines
;
2038 best_window
= window
;
2042 /* Check for a window that has a killed buffer. */
2043 case CHECK_ALL_WINDOWS
:
2044 if (! NILP (w
->buffer
)
2045 && NILP (XBUFFER (w
->buffer
)->name
))
2049 case WINDOW_LOOP_UNUSED
:
2058 /* Used for debugging. Abort if any window has a dead buffer. */
2061 check_all_windows ()
2063 window_loop (CHECK_ALL_WINDOWS
, Qnil
, 1, Qt
);
2066 DEFUN ("get-lru-window", Fget_lru_window
, Sget_lru_window
, 0, 1, 0,
2067 doc
: /* Return the window least recently selected or used for display.
2068 Return a full-width window if possible.
2069 If optional argument FRAME is `visible', search all visible frames.
2070 If FRAME is 0, search all visible and iconified frames.
2071 If FRAME is t, search all frames.
2072 If FRAME is nil, search only the selected frame.
2073 If FRAME is a frame, search only that frame. */)
2077 register Lisp_Object w
;
2078 /* First try for a window that is full-width */
2079 w
= window_loop (GET_LRU_WINDOW
, Qt
, 0, frame
);
2080 if (!NILP (w
) && !EQ (w
, selected_window
))
2082 /* If none of them, try the rest */
2083 return window_loop (GET_LRU_WINDOW
, Qnil
, 0, frame
);
2086 DEFUN ("get-largest-window", Fget_largest_window
, Sget_largest_window
, 0, 1, 0,
2087 doc
: /* Return the largest window in area.
2088 If optional argument FRAME is `visible', search all visible frames.
2089 If FRAME is 0, search all visible and iconified frames.
2090 If FRAME is t, search all frames.
2091 If FRAME is nil, search only the selected frame.
2092 If FRAME is a frame, search only that frame. */)
2096 return window_loop (GET_LARGEST_WINDOW
, Qnil
, 0,
2100 DEFUN ("get-buffer-window", Fget_buffer_window
, Sget_buffer_window
, 1, 2, 0,
2101 doc
: /* Return a window currently displaying BUFFER, or nil if none.
2102 If optional argument FRAME is `visible', search all visible frames.
2103 If optional argument FRAME is 0, search all visible and iconified frames.
2104 If FRAME is t, search all frames.
2105 If FRAME is nil, search only the selected frame.
2106 If FRAME is a frame, search only that frame. */)
2108 Lisp_Object buffer
, frame
;
2110 buffer
= Fget_buffer (buffer
);
2111 if (BUFFERP (buffer
))
2112 return window_loop (GET_BUFFER_WINDOW
, buffer
, 1, frame
);
2117 DEFUN ("delete-other-windows", Fdelete_other_windows
, Sdelete_other_windows
,
2119 doc
: /* Make WINDOW (or the selected window) fill its frame.
2120 Only the frame WINDOW is on is affected.
2121 This function tries to reduce display jumps
2122 by keeping the text previously visible in WINDOW
2123 in the same place on the frame. Doing this depends on
2124 the value of (window-start WINDOW), so if calling this function
2125 in a program gives strange scrolling, make sure the window-start
2126 value is reasonable when this function is called. */)
2135 window
= selected_window
;
2137 CHECK_LIVE_WINDOW (window
);
2138 w
= XWINDOW (window
);
2140 startpos
= marker_position (w
->start
);
2141 top
= WINDOW_TOP_EDGE_LINE (w
) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w
)));
2143 if (MINI_WINDOW_P (w
) && top
> 0)
2144 error ("Can't expand minibuffer to full frame");
2146 window_loop (DELETE_OTHER_WINDOWS
, window
, 0, WINDOW_FRAME (w
));
2148 /* Try to minimize scrolling, by setting the window start to the point
2149 will cause the text at the old window start to be at the same place
2150 on the frame. But don't try to do this if the window start is
2151 outside the visible portion (as might happen when the display is
2152 not current, due to typeahead). */
2153 new_top
= WINDOW_TOP_EDGE_LINE (w
) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w
)));
2155 && startpos
>= BUF_BEGV (XBUFFER (w
->buffer
))
2156 && startpos
<= BUF_ZV (XBUFFER (w
->buffer
)))
2158 struct position pos
;
2159 struct buffer
*obuf
= current_buffer
;
2161 Fset_buffer (w
->buffer
);
2162 /* This computation used to temporarily move point, but that can
2163 have unwanted side effects due to text properties. */
2164 pos
= *vmotion (startpos
, -top
, w
);
2166 set_marker_both (w
->start
, w
->buffer
, pos
.bufpos
, pos
.bytepos
);
2167 w
->window_end_valid
= Qnil
;
2168 w
->start_at_line_beg
= ((pos
.bytepos
== BEGV_BYTE
2169 || FETCH_BYTE (pos
.bytepos
- 1) == '\n') ? Qt
2171 /* We need to do this, so that the window-scroll-functions
2173 w
->optional_new_start
= Qt
;
2175 set_buffer_internal (obuf
);
2181 DEFUN ("delete-windows-on", Fdelete_windows_on
, Sdelete_windows_on
,
2182 1, 2, "bDelete windows on (buffer): ",
2183 doc
: /* Delete all windows showing BUFFER.
2184 Optional second argument FRAME controls which frames are affected.
2185 If optional argument FRAME is `visible', search all visible frames.
2186 If FRAME is 0, search all visible and iconified frames.
2187 If FRAME is nil, search all frames.
2188 If FRAME is t, search only the selected frame.
2189 If FRAME is a frame, search only that frame. */)
2191 Lisp_Object buffer
, frame
;
2193 /* FRAME uses t and nil to mean the opposite of what window_loop
2197 else if (EQ (frame
, Qt
))
2202 buffer
= Fget_buffer (buffer
);
2203 CHECK_BUFFER (buffer
);
2204 window_loop (DELETE_BUFFER_WINDOWS
, buffer
, 0, frame
);
2210 DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows
,
2211 Sreplace_buffer_in_windows
,
2212 1, 1, "bReplace buffer in windows: ",
2213 doc
: /* Replace BUFFER with some other buffer in all windows showing it. */)
2219 buffer
= Fget_buffer (buffer
);
2220 CHECK_BUFFER (buffer
);
2221 window_loop (UNSHOW_BUFFER
, buffer
, 0, Qt
);
2226 /* Replace BUFFER with some other buffer in all windows
2227 of all frames, even those on other keyboards. */
2230 replace_buffer_in_all_windows (buffer
)
2234 Lisp_Object tail
, frame
;
2236 /* A single call to window_loop won't do the job
2237 because it only considers frames on the current keyboard.
2238 So loop manually over frames, and handle each one. */
2239 FOR_EACH_FRAME (tail
, frame
)
2240 window_loop (UNSHOW_BUFFER
, buffer
, 1, frame
);
2242 window_loop (UNSHOW_BUFFER
, buffer
, 1, Qt
);
2246 /* Set the height of WINDOW and all its inferiors. */
2248 /* The smallest acceptable dimensions for a window. Anything smaller
2249 might crash Emacs. */
2251 #define MIN_SAFE_WINDOW_WIDTH (2)
2252 #define MIN_SAFE_WINDOW_HEIGHT (1)
2254 /* Make sure that window_min_height and window_min_width are
2255 not too small; if they are, set them to safe minima. */
2258 check_min_window_sizes ()
2260 /* Smaller values might permit a crash. */
2261 if (window_min_width
< MIN_SAFE_WINDOW_WIDTH
)
2262 window_min_width
= MIN_SAFE_WINDOW_WIDTH
;
2263 if (window_min_height
< MIN_SAFE_WINDOW_HEIGHT
)
2264 window_min_height
= MIN_SAFE_WINDOW_HEIGHT
;
2267 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
2268 minimum allowable size. */
2271 check_frame_size (frame
, rows
, cols
)
2275 /* For height, we have to see:
2276 how many windows the frame has at minimum (one or two),
2277 and whether it has a menu bar or other special stuff at the top. */
2279 = ((FRAME_MINIBUF_ONLY_P (frame
) || ! FRAME_HAS_MINIBUF_P (frame
))
2280 ? MIN_SAFE_WINDOW_HEIGHT
2281 : 2 * MIN_SAFE_WINDOW_HEIGHT
);
2283 if (FRAME_TOP_MARGIN (frame
) > 0)
2284 min_height
+= FRAME_TOP_MARGIN (frame
);
2286 if (*rows
< min_height
)
2288 if (*cols
< MIN_SAFE_WINDOW_WIDTH
)
2289 *cols
= MIN_SAFE_WINDOW_WIDTH
;
2293 /* Value is non-zero if window W is fixed-size. WIDTH_P non-zero means
2294 check if W's width can be changed, otherwise check W's height.
2295 CHECK_SIBLINGS_P non-zero means check resizablity of WINDOW's
2296 siblings, too. If none of the siblings is resizable, WINDOW isn't
2300 window_fixed_size_p (w
, width_p
, check_siblings_p
)
2302 int width_p
, check_siblings_p
;
2307 if (!NILP (w
->hchild
))
2309 c
= XWINDOW (w
->hchild
);
2313 /* A horiz. combination is fixed-width if all of if its
2315 while (c
&& window_fixed_size_p (c
, width_p
, 0))
2316 c
= WINDOWP (c
->next
) ? XWINDOW (c
->next
) : NULL
;
2317 fixed_p
= c
== NULL
;
2321 /* A horiz. combination is fixed-height if one of if its
2323 while (c
&& !window_fixed_size_p (c
, width_p
, 0))
2324 c
= WINDOWP (c
->next
) ? XWINDOW (c
->next
) : NULL
;
2325 fixed_p
= c
!= NULL
;
2328 else if (!NILP (w
->vchild
))
2330 c
= XWINDOW (w
->vchild
);
2334 /* A vert. combination is fixed-width if one of if its
2336 while (c
&& !window_fixed_size_p (c
, width_p
, 0))
2337 c
= WINDOWP (c
->next
) ? XWINDOW (c
->next
) : NULL
;
2338 fixed_p
= c
!= NULL
;
2342 /* A vert. combination is fixed-height if all of if its
2344 while (c
&& window_fixed_size_p (c
, width_p
, 0))
2345 c
= WINDOWP (c
->next
) ? XWINDOW (c
->next
) : NULL
;
2346 fixed_p
= c
== NULL
;
2349 else if (BUFFERP (w
->buffer
))
2351 if (w
->height_fixed_p
&& !width_p
)
2355 struct buffer
*old
= current_buffer
;
2358 current_buffer
= XBUFFER (w
->buffer
);
2359 val
= find_symbol_value (Qwindow_size_fixed
);
2360 current_buffer
= old
;
2363 if (!EQ (val
, Qunbound
))
2365 fixed_p
= !NILP (val
);
2368 && ((EQ (val
, Qheight
) && width_p
)
2369 || (EQ (val
, Qwidth
) && !width_p
)))
2374 /* Can't tell if this one is resizable without looking at
2375 siblings. If all siblings are fixed-size this one is too. */
2376 if (!fixed_p
&& check_siblings_p
&& WINDOWP (w
->parent
))
2380 for (child
= w
->prev
; !NILP (child
); child
= XWINDOW (child
)->prev
)
2381 if (!window_fixed_size_p (XWINDOW (child
), width_p
, 0))
2385 for (child
= w
->next
; !NILP (child
); child
= XWINDOW (child
)->next
)
2386 if (!window_fixed_size_p (XWINDOW (child
), width_p
, 0))
2400 /* Return the minimum size of window W, not taking fixed-width windows
2401 into account. WIDTH_P non-zero means return the minimum width,
2402 otherwise return the minimum height. If W is a combination window,
2403 compute the minimum size from the minimum sizes of W's children. */
2406 window_min_size_1 (w
, width_p
)
2413 if (!NILP (w
->hchild
))
2415 c
= XWINDOW (w
->hchild
);
2420 /* The min width of a horizontal combination is
2421 the sum of the min widths of its children. */
2424 size
+= window_min_size_1 (c
, width_p
);
2425 c
= WINDOWP (c
->next
) ? XWINDOW (c
->next
) : NULL
;
2430 /* The min height a horizontal combination equals
2431 the maximum of all min height of its children. */
2434 int min_size
= window_min_size_1 (c
, width_p
);
2435 size
= max (min_size
, size
);
2436 c
= WINDOWP (c
->next
) ? XWINDOW (c
->next
) : NULL
;
2440 else if (!NILP (w
->vchild
))
2442 c
= XWINDOW (w
->vchild
);
2447 /* The min width of a vertical combination is
2448 the maximum of the min widths of its children. */
2451 int min_size
= window_min_size_1 (c
, width_p
);
2452 size
= max (min_size
, size
);
2453 c
= WINDOWP (c
->next
) ? XWINDOW (c
->next
) : NULL
;
2458 /* The min height of a vertical combination equals
2459 the sum of the min height of its children. */
2462 size
+= window_min_size_1 (c
, width_p
);
2463 c
= WINDOWP (c
->next
) ? XWINDOW (c
->next
) : NULL
;
2470 size
= window_min_width
;
2473 if (MINI_WINDOW_P (w
)
2474 || (!WINDOW_WANTS_MODELINE_P (w
)
2475 && !WINDOW_WANTS_HEADER_LINE_P (w
)))
2478 size
= window_min_height
;
2486 /* Return the minimum size of window W, taking fixed-size windows into
2487 account. WIDTH_P non-zero means return the minimum width,
2488 otherwise return the minimum height. IGNORE_FIXED_P non-zero means
2489 ignore if W is fixed-size. Set *FIXED to 1 if W is fixed-size
2490 unless FIXED is null. */
2493 window_min_size (w
, width_p
, ignore_fixed_p
, fixed
)
2495 int width_p
, ignore_fixed_p
, *fixed
;
2502 fixed_p
= window_fixed_size_p (w
, width_p
, 1);
2508 size
= width_p
? XFASTINT (w
->total_cols
) : XFASTINT (w
->total_lines
);
2510 size
= window_min_size_1 (w
, width_p
);
2516 /* Adjust the margins of window W if text area is too small.
2517 Return 1 if window width is ok after adjustment; 0 if window
2518 is still too narrow. */
2521 adjust_window_margins (w
)
2524 int box_cols
= (WINDOW_TOTAL_COLS (w
)
2525 - WINDOW_FRINGE_COLS (w
)
2526 - WINDOW_SCROLL_BAR_COLS (w
));
2527 int margin_cols
= (WINDOW_LEFT_MARGIN_COLS (w
)
2528 + WINDOW_RIGHT_MARGIN_COLS (w
));
2530 if (box_cols
- margin_cols
>= MIN_SAFE_WINDOW_WIDTH
)
2533 if (margin_cols
< 0 || box_cols
< MIN_SAFE_WINDOW_WIDTH
)
2536 /* Window's text area is too narrow, but reducing the window
2537 margins will fix that. */
2538 margin_cols
= box_cols
- MIN_SAFE_WINDOW_WIDTH
;
2539 if (WINDOW_RIGHT_MARGIN_COLS (w
) > 0)
2541 if (WINDOW_LEFT_MARGIN_COLS (w
) > 0)
2542 w
->left_margin_cols
= w
->right_margin_cols
2543 = make_number (margin_cols
/2);
2545 w
->right_margin_cols
= make_number (margin_cols
);
2548 w
->left_margin_cols
= make_number (margin_cols
);
2552 /* Calculate new sizes for windows in the list FORWARD when the window size
2553 goes from TOTAL to SIZE. TOTAL must be greater than SIZE.
2554 The number of windows in FORWARD is NCHILDREN, and the number that
2555 can shrink is SHRINKABLE.
2556 The minimum size a window can have is MIN_SIZE.
2557 If we are shrinking fixed windows, RESIZE_FIXED_P is non-zero.
2558 If we are shrinking columns, WIDTH_P is non-zero, otherwise we are
2561 This function returns an allocated array of new sizes that the caller
2562 must free. The size -1 means the window is fixed and RESIZE_FIXED_P
2563 is zero. Array index 0 refers to the first window in FORWARD, 1 to
2564 the second, and so on.
2566 This function tries to keep windows at least at the minimum size
2567 and resize other windows before it resizes any window to zero (i.e.
2568 delete that window).
2570 Windows are resized proportional to their size, so bigger windows
2571 shrink more than smaller windows. */
2573 shrink_windows (total
, size
, nchildren
, shrinkable
,
2574 min_size
, resize_fixed_p
, forward
, width_p
)
2575 int total
, size
, nchildren
, shrinkable
, min_size
;
2576 int resize_fixed_p
, width_p
;
2577 Lisp_Object forward
;
2579 int available_resize
= 0;
2583 int smallest
= total
;
2584 int total_removed
= 0;
2585 int total_shrink
= total
- size
;
2588 new_sizes
= xmalloc (sizeof (*new_sizes
) * nchildren
);
2590 for (i
= 0, child
= forward
; !NILP (child
); child
= c
->next
, ++i
)
2594 c
= XWINDOW (child
);
2595 child_size
= width_p
? XINT (c
->total_cols
) : XINT (c
->total_lines
);
2597 if (! resize_fixed_p
&& window_fixed_size_p (c
, width_p
, 0))
2601 new_sizes
[i
] = child_size
;
2602 if (child_size
> min_size
)
2603 available_resize
+= child_size
- min_size
;
2606 /* We might need to shrink some windows to zero. Find the smallest
2607 windows and set them to 0 until we can fulfil the new size. */
2609 while (shrinkable
> 1 && size
+ available_resize
< total
)
2611 for (i
= 0; i
< nchildren
; ++i
)
2612 if (new_sizes
[i
] > 0 && smallest
> new_sizes
[i
])
2613 smallest
= new_sizes
[i
];
2615 for (i
= 0; i
< nchildren
; ++i
)
2616 if (new_sizes
[i
] == smallest
)
2618 /* Resize this window down to zero. */
2620 if (smallest
> min_size
)
2621 available_resize
-= smallest
- min_size
;
2622 available_resize
+= smallest
;
2624 total_removed
+= smallest
;
2626 /* Out of for, just remove one window at the time and
2627 check again if we have enough space. */
2632 /* Now, calculate the new sizes. Try to shrink each window
2633 proportional to its size. */
2634 for (i
= 0; i
< nchildren
; ++i
)
2636 if (new_sizes
[i
] > min_size
)
2638 int to_shrink
= total_shrink
*new_sizes
[i
]/total
;
2639 if (new_sizes
[i
] - to_shrink
< min_size
)
2640 to_shrink
= new_sizes
[i
] - min_size
;
2641 new_sizes
[i
] -= to_shrink
;
2642 total_removed
+= to_shrink
;
2646 /* Any reminder due to rounding, we just subtract from windows
2647 that are left and still can be shrunk. */
2648 while (total_shrink
> total_removed
)
2650 for (i
= 0; i
< nchildren
; ++i
)
2651 if (new_sizes
[i
] > min_size
)
2656 /* Out of for, just shrink one window at the time and
2657 check again if we have enough space. */
2665 /* Set WINDOW's height or width to SIZE. WIDTH_P non-zero means set
2666 WINDOW's width. Resize WINDOW's children, if any, so that they
2667 keep their proportionate size relative to WINDOW. Propagate
2668 WINDOW's top or left edge position to children. Delete windows
2669 that become too small unless NODELETE_P is non-zero.
2671 If NODELETE_P is 2, that means we do delete windows that are
2672 too small, even if they were too small before! */
2675 size_window (window
, size
, width_p
, nodelete_p
)
2677 int size
, width_p
, nodelete_p
;
2679 struct window
*w
= XWINDOW (window
);
2681 Lisp_Object child
, *forward
, *sideward
;
2682 int old_size
, min_size
, safe_min_size
;
2684 /* We test nodelete_p != 2 and nodelete_p != 1 below, so it
2685 seems like it's too soon to do this here. ++KFS. */
2686 if (nodelete_p
== 2)
2689 check_min_window_sizes ();
2690 size
= max (0, size
);
2692 /* If the window has been "too small" at one point,
2693 don't delete it for being "too small" in the future.
2694 Preserve it as long as that is at all possible. */
2697 old_size
= WINDOW_TOTAL_COLS (w
);
2698 min_size
= window_min_width
;
2699 /* Ensure that there is room for the scroll bar and fringes!
2700 We may reduce display margins though. */
2701 safe_min_size
= (MIN_SAFE_WINDOW_WIDTH
2702 + WINDOW_FRINGE_COLS (w
)
2703 + WINDOW_SCROLL_BAR_COLS (w
));
2707 old_size
= XINT (w
->total_lines
);
2708 min_size
= window_min_height
;
2709 safe_min_size
= MIN_SAFE_WINDOW_HEIGHT
;
2712 if (old_size
< min_size
&& nodelete_p
!= 2)
2713 w
->too_small_ok
= Qt
;
2715 /* Maybe delete WINDOW if it's too small. */
2716 if (nodelete_p
!= 1 && !NILP (w
->parent
))
2718 if (!MINI_WINDOW_P (w
) && !NILP (w
->too_small_ok
))
2719 min_size
= width_p
? MIN_SAFE_WINDOW_WIDTH
: MIN_SAFE_WINDOW_HEIGHT
;
2720 if (min_size
< safe_min_size
)
2721 min_size
= safe_min_size
;
2722 if (size
< min_size
)
2724 delete_window (window
);
2729 /* Set redisplay hints. */
2730 w
->last_modified
= make_number (0);
2731 w
->last_overlay_modified
= make_number (0);
2732 windows_or_buffers_changed
++;
2733 FRAME_WINDOW_SIZES_CHANGED (XFRAME (w
->frame
)) = 1;
2737 sideward
= &w
->vchild
;
2738 forward
= &w
->hchild
;
2739 w
->total_cols
= make_number (size
);
2740 adjust_window_margins (w
);
2744 sideward
= &w
->hchild
;
2745 forward
= &w
->vchild
;
2746 w
->total_lines
= make_number (size
);
2747 w
->orig_total_lines
= Qnil
;
2750 if (!NILP (*sideward
))
2752 for (child
= *sideward
; !NILP (child
); child
= c
->next
)
2754 c
= XWINDOW (child
);
2756 c
->left_col
= w
->left_col
;
2758 c
->top_line
= w
->top_line
;
2759 size_window (child
, size
, width_p
, nodelete_p
);
2762 else if (!NILP (*forward
))
2764 int fixed_size
, each
, extra
, n
;
2765 int resize_fixed_p
, nfixed
;
2766 int last_pos
, first_pos
, nchildren
, total
;
2767 int *new_sizes
= NULL
;
2769 /* Determine the fixed-size portion of the this window, and the
2770 number of child windows. */
2771 fixed_size
= nchildren
= nfixed
= total
= 0;
2772 for (child
= *forward
; !NILP (child
); child
= c
->next
, ++nchildren
)
2776 c
= XWINDOW (child
);
2777 child_size
= width_p
? XINT (c
->total_cols
) : XINT (c
->total_lines
);
2778 total
+= child_size
;
2780 if (window_fixed_size_p (c
, width_p
, 0))
2782 fixed_size
+= child_size
;
2787 /* If the new size is smaller than fixed_size, or if there
2788 aren't any resizable windows, allow resizing fixed-size
2790 resize_fixed_p
= nfixed
== nchildren
|| size
< fixed_size
;
2792 /* Compute how many lines/columns to add/remove to each child. The
2793 value of extra takes care of rounding errors. */
2794 n
= resize_fixed_p
? nchildren
: nchildren
- nfixed
;
2795 if (size
< total
&& n
> 1)
2796 new_sizes
= shrink_windows (total
, size
, nchildren
, n
, min_size
,
2797 resize_fixed_p
, *forward
, width_p
);
2800 each
= (size
- total
) / n
;
2801 extra
= (size
- total
) - n
* each
;
2804 /* Compute new children heights and edge positions. */
2805 first_pos
= width_p
? XINT (w
->left_col
) : XINT (w
->top_line
);
2806 last_pos
= first_pos
;
2807 for (n
= 0, child
= *forward
; !NILP (child
); child
= c
->next
, ++n
)
2809 int new_size
, old_size
;
2811 c
= XWINDOW (child
);
2812 old_size
= width_p
? XFASTINT (c
->total_cols
) : XFASTINT (c
->total_lines
);
2813 new_size
= old_size
;
2815 /* The top or left edge position of this child equals the
2816 bottom or right edge of its predecessor. */
2818 c
->left_col
= make_number (last_pos
);
2820 c
->top_line
= make_number (last_pos
);
2822 /* If this child can be resized, do it. */
2823 if (resize_fixed_p
|| !window_fixed_size_p (c
, width_p
, 0))
2825 new_size
= new_sizes
? new_sizes
[n
] : old_size
+ each
+ extra
;
2829 /* Set new height. Note that size_window also propagates
2830 edge positions to children, so it's not a no-op if we
2831 didn't change the child's size. */
2832 size_window (child
, new_size
, width_p
, 1);
2834 /* Remember the bottom/right edge position of this child; it
2835 will be used to set the top/left edge of the next child. */
2836 last_pos
+= new_size
;
2839 if (new_sizes
) xfree (new_sizes
);
2841 /* We should have covered the parent exactly with child windows. */
2842 xassert (size
== last_pos
- first_pos
);
2844 /* Now delete any children that became too small. */
2846 for (child
= *forward
; !NILP (child
); child
= c
->next
)
2849 c
= XWINDOW (child
);
2850 child_size
= width_p
? XINT (c
->total_cols
) : XINT (c
->total_lines
);
2851 size_window (child
, child_size
, width_p
, 2);
2856 /* Set WINDOW's height to HEIGHT, and recursively change the height of
2857 WINDOW's children. NODELETE non-zero means don't delete windows
2858 that become too small in the process. (The caller should check
2859 later and do so if appropriate.) */
2862 set_window_height (window
, height
, nodelete
)
2867 size_window (window
, height
, 0, nodelete
);
2871 /* Set WINDOW's width to WIDTH, and recursively change the width of
2872 WINDOW's children. NODELETE non-zero means don't delete windows
2873 that become too small in the process. (The caller should check
2874 later and do so if appropriate.) */
2877 set_window_width (window
, width
, nodelete
)
2882 size_window (window
, width
, 1, nodelete
);
2885 /* Change window heights in windows rooted in WINDOW by N lines. */
2888 change_window_heights (window
, n
)
2892 struct window
*w
= XWINDOW (window
);
2894 XSETFASTINT (w
->top_line
, XFASTINT (w
->top_line
) + n
);
2895 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - n
);
2897 if (INTEGERP (w
->orig_top_line
))
2898 XSETFASTINT (w
->orig_top_line
, XFASTINT (w
->orig_top_line
) + n
);
2899 if (INTEGERP (w
->orig_total_lines
))
2900 XSETFASTINT (w
->orig_total_lines
, XFASTINT (w
->orig_total_lines
) - n
);
2902 /* Handle just the top child in a vertical split. */
2903 if (!NILP (w
->vchild
))
2904 change_window_heights (w
->vchild
, n
);
2906 /* Adjust all children in a horizontal split. */
2907 for (window
= w
->hchild
; !NILP (window
); window
= w
->next
)
2909 w
= XWINDOW (window
);
2910 change_window_heights (window
, n
);
2915 int window_select_count
;
2918 Fset_window_buffer_unwind (obuf
)
2925 EXFUN (Fset_window_fringes
, 4);
2926 EXFUN (Fset_window_scroll_bars
, 4);
2928 /* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero
2929 means it's allowed to run hooks. See make_frame for a case where
2930 it's not allowed. KEEP_MARGINS_P non-zero means that the current
2931 margins, fringes, and scroll-bar settings of the window are not
2932 reset from the buffer's local settings. */
2935 set_window_buffer (window
, buffer
, run_hooks_p
, keep_margins_p
)
2936 Lisp_Object window
, buffer
;
2937 int run_hooks_p
, keep_margins_p
;
2939 struct window
*w
= XWINDOW (window
);
2940 struct buffer
*b
= XBUFFER (buffer
);
2941 int count
= SPECPDL_INDEX ();
2945 if (EQ (window
, selected_window
))
2946 b
->last_selected_window
= window
;
2948 /* Update time stamps of buffer display. */
2949 if (INTEGERP (b
->display_count
))
2950 XSETINT (b
->display_count
, XINT (b
->display_count
) + 1);
2951 b
->display_time
= Fcurrent_time ();
2953 XSETFASTINT (w
->window_end_pos
, 0);
2954 XSETFASTINT (w
->window_end_vpos
, 0);
2955 bzero (&w
->last_cursor
, sizeof w
->last_cursor
);
2956 w
->window_end_valid
= Qnil
;
2957 w
->hscroll
= w
->min_hscroll
= make_number (0);
2959 set_marker_both (w
->pointm
, buffer
, BUF_PT (b
), BUF_PT_BYTE (b
));
2960 set_marker_restricted (w
->start
,
2961 make_number (b
->last_window_start
),
2963 w
->start_at_line_beg
= Qnil
;
2964 w
->force_start
= Qnil
;
2965 XSETFASTINT (w
->last_modified
, 0);
2966 XSETFASTINT (w
->last_overlay_modified
, 0);
2967 windows_or_buffers_changed
++;
2969 /* We must select BUFFER for running the window-scroll-functions.
2970 If WINDOW is selected, switch permanently.
2971 Otherwise, switch but go back to the ambient buffer afterward. */
2972 if (EQ (window
, selected_window
))
2973 Fset_buffer (buffer
);
2974 /* We can't check ! NILP (Vwindow_scroll_functions) here
2975 because that might itself be a local variable. */
2976 else if (window_initialized
)
2978 record_unwind_protect (Fset_window_buffer_unwind
, Fcurrent_buffer ());
2979 Fset_buffer (buffer
);
2982 if (!keep_margins_p
)
2984 /* Set left and right marginal area width etc. from buffer. */
2986 /* This may call adjust_window_margins three times, so
2987 temporarily disable window margins. */
2988 Lisp_Object save_left
= w
->left_margin_cols
;
2989 Lisp_Object save_right
= w
->right_margin_cols
;
2991 w
->left_margin_cols
= w
->right_margin_cols
= Qnil
;
2993 Fset_window_fringes (window
,
2994 b
->left_fringe_width
, b
->right_fringe_width
,
2995 b
->fringes_outside_margins
);
2997 Fset_window_scroll_bars (window
,
2998 b
->scroll_bar_width
,
2999 b
->vertical_scroll_bar_type
, Qnil
);
3001 w
->left_margin_cols
= save_left
;
3002 w
->right_margin_cols
= save_right
;
3004 Fset_window_margins (window
,
3005 b
->left_margin_cols
, b
->right_margin_cols
);
3010 if (! NILP (Vwindow_scroll_functions
))
3011 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
3012 Fmarker_position (w
->start
));
3014 if (! NILP (Vwindow_configuration_change_hook
)
3015 && ! NILP (Vrun_hooks
))
3016 call1 (Vrun_hooks
, Qwindow_configuration_change_hook
);
3019 unbind_to (count
, Qnil
);
3023 DEFUN ("set-window-buffer", Fset_window_buffer
, Sset_window_buffer
, 2, 3, 0,
3024 doc
: /* Make WINDOW display BUFFER as its contents.
3025 BUFFER can be a buffer or buffer name.
3026 Optional third arg KEEP_MARGINS non-nil means that WINDOW's current
3027 display margins, fringe widths, and scroll bar settings are maintained;
3028 the default is to reset these from BUFFER's local settings or the frame
3030 (window
, buffer
, keep_margins
)
3031 register Lisp_Object window
, buffer
, keep_margins
;
3033 register Lisp_Object tem
;
3034 register struct window
*w
= decode_window (window
);
3036 XSETWINDOW (window
, w
);
3037 buffer
= Fget_buffer (buffer
);
3038 CHECK_BUFFER (buffer
);
3040 if (NILP (XBUFFER (buffer
)->name
))
3041 error ("Attempt to display deleted buffer");
3045 error ("Window is deleted");
3046 else if (! EQ (tem
, Qt
)) /* w->buffer is t when the window
3047 is first being set up. */
3049 if (!NILP (w
->dedicated
) && !EQ (tem
, buffer
))
3050 error ("Window is dedicated to `%s'",
3051 SDATA (XBUFFER (tem
)->name
));
3056 set_window_buffer (window
, buffer
, 1, !NILP (keep_margins
));
3060 /* Note that selected_window can be nil
3061 when this is called from Fset_window_configuration. */
3063 DEFUN ("select-window", Fselect_window
, Sselect_window
, 1, 2, 0,
3064 doc
: /* Select WINDOW. Most editing will apply to WINDOW's buffer.
3065 If WINDOW is not already selected, also make WINDOW's buffer current.
3066 Also make WINDOW the frame's selected window.
3067 Optional second arg NORECORD non-nil means
3068 do not put this buffer at the front of the list of recently selected ones.
3070 Note that the main editor command loop
3071 selects the buffer of the selected window before each command. */)
3073 register Lisp_Object window
, norecord
;
3075 register struct window
*w
;
3076 register struct window
*ow
;
3079 CHECK_LIVE_WINDOW (window
);
3081 w
= XWINDOW (window
);
3082 w
->frozen_window_start_p
= 0;
3084 XSETFASTINT (w
->use_time
, ++window_select_count
);
3085 if (EQ (window
, selected_window
))
3088 if (!NILP (selected_window
))
3090 ow
= XWINDOW (selected_window
);
3091 if (! NILP (ow
->buffer
))
3092 set_marker_both (ow
->pointm
, ow
->buffer
,
3093 BUF_PT (XBUFFER (ow
->buffer
)),
3094 BUF_PT_BYTE (XBUFFER (ow
->buffer
)));
3097 selected_window
= window
;
3098 sf
= SELECTED_FRAME ();
3099 if (XFRAME (WINDOW_FRAME (w
)) != sf
)
3101 XFRAME (WINDOW_FRAME (w
))->selected_window
= window
;
3102 /* Use this rather than Fhandle_switch_frame
3103 so that FRAME_FOCUS_FRAME is moved appropriately as we
3104 move around in the state where a minibuffer in a separate
3106 Fselect_frame (WINDOW_FRAME (w
), Qnil
);
3109 sf
->selected_window
= window
;
3111 if (NILP (norecord
))
3112 record_buffer (w
->buffer
);
3113 Fset_buffer (w
->buffer
);
3115 XBUFFER (w
->buffer
)->last_selected_window
= window
;
3117 /* Go to the point recorded in the window.
3118 This is important when the buffer is in more
3119 than one window. It also matters when
3120 redisplay_window has altered point after scrolling,
3121 because it makes the change only in the window. */
3123 register int new_point
= marker_position (w
->pointm
);
3124 if (new_point
< BEGV
)
3126 else if (new_point
> ZV
)
3132 windows_or_buffers_changed
++;
3137 select_window_norecord (window
)
3140 return Fselect_window (window
, Qt
);
3143 /* Deiconify the frame containing the window WINDOW,
3144 unless it is the selected frame;
3147 The reason for the exception for the selected frame
3148 is that it seems better not to change the selected frames visibility
3149 merely because of displaying a different buffer in it.
3150 The deiconification is useful when a buffer gets shown in
3151 another frame that you were not using lately. */
3154 display_buffer_1 (window
)
3157 Lisp_Object frame
= XWINDOW (window
)->frame
;
3158 FRAME_PTR f
= XFRAME (frame
);
3160 FRAME_SAMPLE_VISIBILITY (f
);
3162 if (EQ (frame
, selected_frame
))
3163 ; /* Assume the selected frame is already visible enough. */
3164 else if (minibuf_level
> 0
3165 && MINI_WINDOW_P (XWINDOW (selected_window
))
3166 && WINDOW_LIVE_P (minibuf_selected_window
)
3167 && EQ (frame
, WINDOW_FRAME (XWINDOW (minibuf_selected_window
))))
3168 ; /* Assume the frame from which we invoked the minibuffer is visible. */
3171 if (FRAME_ICONIFIED_P (f
))
3172 Fmake_frame_visible (frame
);
3173 else if (FRAME_VISIBLE_P (f
))
3174 Fraise_frame (frame
);
3180 DEFUN ("special-display-p", Fspecial_display_p
, Sspecial_display_p
, 1, 1, 0,
3181 doc
: /* Returns non-nil if a buffer named BUFFER-NAME would be created specially.
3182 The value is actually t if the frame should be called with default frame
3183 parameters, and a list of frame parameters if they were specified.
3184 See `special-display-buffer-names', and `special-display-regexps'. */)
3186 Lisp_Object buffer_name
;
3190 CHECK_STRING (buffer_name
);
3192 tem
= Fmember (buffer_name
, Vspecial_display_buffer_names
);
3196 tem
= Fassoc (buffer_name
, Vspecial_display_buffer_names
);
3200 for (tem
= Vspecial_display_regexps
; CONSP (tem
); tem
= XCDR (tem
))
3202 Lisp_Object car
= XCAR (tem
);
3204 && fast_string_match (car
, buffer_name
) >= 0)
3206 else if (CONSP (car
)
3207 && STRINGP (XCAR (car
))
3208 && fast_string_match (XCAR (car
), buffer_name
) >= 0)
3214 DEFUN ("same-window-p", Fsame_window_p
, Ssame_window_p
, 1, 1, 0,
3215 doc
: /* Returns non-nil if a new buffer named BUFFER-NAME would use the same window.
3216 See `same-window-buffer-names' and `same-window-regexps'. */)
3218 Lisp_Object buffer_name
;
3222 CHECK_STRING (buffer_name
);
3224 tem
= Fmember (buffer_name
, Vsame_window_buffer_names
);
3228 tem
= Fassoc (buffer_name
, Vsame_window_buffer_names
);
3232 for (tem
= Vsame_window_regexps
; CONSP (tem
); tem
= XCDR (tem
))
3234 Lisp_Object car
= XCAR (tem
);
3236 && fast_string_match (car
, buffer_name
) >= 0)
3238 else if (CONSP (car
)
3239 && STRINGP (XCAR (car
))
3240 && fast_string_match (XCAR (car
), buffer_name
) >= 0)
3246 /* Use B so the default is (other-buffer). */
3247 DEFUN ("display-buffer", Fdisplay_buffer
, Sdisplay_buffer
, 1, 3,
3248 "BDisplay buffer: \nP",
3249 doc
: /* Make BUFFER appear in some window but don't select it.
3250 BUFFER can be a buffer or a buffer name.
3251 If BUFFER is shown already in some window, just use that one,
3252 unless the window is the selected window and the optional second
3253 argument NOT-THIS-WINDOW is non-nil (interactively, with prefix arg).
3254 If `pop-up-frames' is non-nil, make a new frame if no window shows BUFFER.
3255 Returns the window displaying BUFFER.
3256 If `display-buffer-reuse-frames' is non-nil, and another frame is currently
3257 displaying BUFFER, then simply raise that frame.
3259 The variables `special-display-buffer-names',
3260 `special-display-regexps', `same-window-buffer-names', and
3261 `same-window-regexps' customize how certain buffer names are handled.
3262 The latter two take effect only if NOT-THIS-WINDOW is t.
3264 If optional argument FRAME is `visible', search all visible frames.
3265 If FRAME is 0, search all visible and iconified frames.
3266 If FRAME is t, search all frames.
3267 If FRAME is a frame, search only that frame.
3268 If FRAME is nil, search only the selected frame
3269 (actually the last nonminibuffer frame),
3270 unless `pop-up-frames' or `display-buffer-reuse-frames' is non-nil,
3271 which means search visible and iconified frames.
3273 If `even-window-heights' is non-nil, window heights will be evened out
3274 if displaying the buffer causes two vertically adjacent windows to be
3276 (buffer
, not_this_window
, frame
)
3277 register Lisp_Object buffer
, not_this_window
, frame
;
3279 register Lisp_Object window
, tem
, swp
;
3283 buffer
= Fget_buffer (buffer
);
3284 CHECK_BUFFER (buffer
);
3286 if (!NILP (Vdisplay_buffer_function
))
3287 return call2 (Vdisplay_buffer_function
, buffer
, not_this_window
);
3289 if (NILP (not_this_window
)
3290 && XBUFFER (XWINDOW (selected_window
)->buffer
) == XBUFFER (buffer
))
3291 return display_buffer_1 (selected_window
);
3293 /* See if the user has specified this buffer should appear
3294 in the selected window. */
3295 if (NILP (not_this_window
))
3297 swp
= Fsame_window_p (XBUFFER (buffer
)->name
);
3298 if (!NILP (swp
) && !no_switch_window (selected_window
))
3300 Fswitch_to_buffer (buffer
, Qnil
);
3301 return display_buffer_1 (selected_window
);
3305 /* If the user wants pop-up-frames or display-buffer-reuse-frames,
3306 look for a window showing BUFFER on any visible or iconified frame.
3307 Otherwise search only the current frame. */
3310 else if (pop_up_frames
3311 || display_buffer_reuse_frames
3312 || last_nonminibuf_frame
== 0)
3313 XSETFASTINT (tem
, 0);
3315 XSETFRAME (tem
, last_nonminibuf_frame
);
3317 window
= Fget_buffer_window (buffer
, tem
);
3319 && (NILP (not_this_window
) || !EQ (window
, selected_window
)))
3320 return display_buffer_1 (window
);
3322 /* Certain buffer names get special handling. */
3323 if (!NILP (Vspecial_display_function
) && NILP (swp
))
3325 tem
= Fspecial_display_p (XBUFFER (buffer
)->name
);
3327 return call1 (Vspecial_display_function
, buffer
);
3329 return call2 (Vspecial_display_function
, buffer
, tem
);
3332 /* If there are no frames open that have more than a minibuffer,
3333 we need to create a new frame. */
3334 if (pop_up_frames
|| last_nonminibuf_frame
== 0)
3336 window
= Fframe_selected_window (call0 (Vpop_up_frame_function
));
3337 Fset_window_buffer (window
, buffer
, Qnil
);
3338 return display_buffer_1 (window
);
3341 f
= SELECTED_FRAME ();
3343 || FRAME_MINIBUF_ONLY_P (f
)
3344 /* If the current frame is a special display frame,
3345 don't try to reuse its windows. */
3346 || !NILP (XWINDOW (FRAME_ROOT_WINDOW (f
))->dedicated
))
3351 if (FRAME_MINIBUF_ONLY_P (f
))
3352 XSETFRAME (frames
, last_nonminibuf_frame
);
3353 /* Don't try to create a window if we would get an error. */
3354 if (split_height_threshold
< window_min_height
<< 1)
3355 split_height_threshold
= window_min_height
<< 1;
3357 /* Note that both Fget_largest_window and Fget_lru_window
3358 ignore minibuffers and dedicated windows.
3359 This means they can return nil. */
3361 /* If the frame we would try to split cannot be split,
3362 try other frames. */
3363 if (FRAME_NO_SPLIT_P (NILP (frames
) ? f
: last_nonminibuf_frame
))
3365 /* Try visible frames first. */
3366 window
= Fget_largest_window (Qvisible
);
3367 /* If that didn't work, try iconified frames. */
3369 window
= Fget_largest_window (make_number (0));
3371 window
= Fget_largest_window (Qt
);
3374 window
= Fget_largest_window (frames
);
3376 /* If we got a tall enough full-width window that can be split,
3379 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window
)->frame
))
3380 && window_height (window
) >= split_height_threshold
3381 && WINDOW_FULL_WIDTH_P (XWINDOW (window
)))
3382 window
= Fsplit_window (window
, Qnil
, Qnil
);
3385 Lisp_Object upper
, lower
, other
;
3387 window
= Fget_lru_window (frames
);
3388 /* If the LRU window is selected, and big enough,
3389 and can be split, split it. */
3391 && ! FRAME_NO_SPLIT_P (XFRAME (XWINDOW (window
)->frame
))
3392 && (EQ (window
, selected_window
)
3393 || EQ (XWINDOW (window
)->parent
, Qnil
))
3394 && window_height (window
) >= window_min_height
<< 1)
3395 window
= Fsplit_window (window
, Qnil
, Qnil
);
3396 /* If Fget_lru_window returned nil, try other approaches. */
3398 /* Try visible frames first. */
3400 window
= Fget_buffer_window (buffer
, Qvisible
);
3402 window
= Fget_largest_window (Qvisible
);
3403 /* If that didn't work, try iconified frames. */
3405 window
= Fget_buffer_window (buffer
, make_number (0));
3407 window
= Fget_largest_window (make_number (0));
3408 /* Try invisible frames. */
3410 window
= Fget_buffer_window (buffer
, Qt
);
3412 window
= Fget_largest_window (Qt
);
3413 /* As a last resort, make a new frame. */
3415 window
= Fframe_selected_window (call0 (Vpop_up_frame_function
));
3416 /* If window appears above or below another,
3417 even out their heights. */
3418 other
= upper
= lower
= Qnil
;
3419 if (!NILP (XWINDOW (window
)->prev
))
3420 other
= upper
= XWINDOW (window
)->prev
, lower
= window
;
3421 if (!NILP (XWINDOW (window
)->next
))
3422 other
= lower
= XWINDOW (window
)->next
, upper
= window
;
3424 && !NILP (Veven_window_heights
)
3425 /* Check that OTHER and WINDOW are vertically arrayed. */
3426 && !EQ (XWINDOW (other
)->top_line
, XWINDOW (window
)->top_line
)
3427 && (XFASTINT (XWINDOW (other
)->total_lines
)
3428 > XFASTINT (XWINDOW (window
)->total_lines
)))
3430 int total
= (XFASTINT (XWINDOW (other
)->total_lines
)
3431 + XFASTINT (XWINDOW (window
)->total_lines
));
3432 enlarge_window (upper
,
3433 total
/ 2 - XFASTINT (XWINDOW (upper
)->total_lines
),
3439 window
= Fget_lru_window (Qnil
);
3441 Fset_window_buffer (window
, buffer
, Qnil
);
3442 return display_buffer_1 (window
);
3446 DEFUN ("force-window-update", Fforce_window_update
, Sforce_window_update
,
3448 doc
: /* Force redisplay of all windows.
3449 If optional arg OBJECT is a window, force redisplay of that window only.
3450 If OBJECT is a buffer or buffer name, force redisplay of all windows
3451 displaying that buffer. */)
3457 windows_or_buffers_changed
++;
3458 update_mode_lines
++;
3462 if (WINDOWP (object
))
3464 struct window
*w
= XWINDOW (object
);
3465 mark_window_display_accurate (object
, 0);
3466 w
->update_mode_line
= Qt
;
3467 if (BUFFERP (w
->buffer
))
3468 XBUFFER (w
->buffer
)->prevent_redisplay_optimizations_p
= 1;
3469 ++update_mode_lines
;
3473 if (STRINGP (object
))
3474 object
= Fget_buffer (object
);
3475 if (BUFFERP (object
) && !NILP (XBUFFER (object
)->name
))
3477 /* Walk all windows looking for buffer, and force update
3478 of each of those windows. */
3480 object
= window_loop (REDISPLAY_BUFFER_WINDOWS
, object
, 0, Qvisible
);
3481 return NILP (object
) ? Qnil
: Qt
;
3484 /* If nothing suitable was found, just return.
3485 We could signal an error, but this feature will typically be used
3486 asynchronously in timers or process sentinels, so we don't. */
3492 temp_output_buffer_show (buf
)
3493 register Lisp_Object buf
;
3495 register struct buffer
*old
= current_buffer
;
3496 register Lisp_Object window
;
3497 register struct window
*w
;
3499 XBUFFER (buf
)->directory
= current_buffer
->directory
;
3502 BUF_SAVE_MODIFF (XBUFFER (buf
)) = MODIFF
;
3506 #if 0 /* rms: there should be no reason for this. */
3507 XBUFFER (buf
)->prevent_redisplay_optimizations_p
= 1;
3509 set_buffer_internal (old
);
3511 if (!EQ (Vtemp_buffer_show_function
, Qnil
))
3512 call1 (Vtemp_buffer_show_function
, buf
);
3515 window
= Fdisplay_buffer (buf
, Qnil
, Qnil
);
3517 if (!EQ (XWINDOW (window
)->frame
, selected_frame
))
3518 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window
)));
3519 Vminibuf_scroll_window
= window
;
3520 w
= XWINDOW (window
);
3521 XSETFASTINT (w
->hscroll
, 0);
3522 XSETFASTINT (w
->min_hscroll
, 0);
3523 set_marker_restricted_both (w
->start
, buf
, BEG
, BEG
);
3524 set_marker_restricted_both (w
->pointm
, buf
, BEG
, BEG
);
3526 /* Run temp-buffer-show-hook, with the chosen window selected
3527 and its buffer current. */
3529 if (!NILP (Vrun_hooks
)
3530 && !NILP (Fboundp (Qtemp_buffer_show_hook
))
3531 && !NILP (Fsymbol_value (Qtemp_buffer_show_hook
)))
3533 int count
= SPECPDL_INDEX ();
3534 Lisp_Object prev_window
, prev_buffer
;
3535 prev_window
= selected_window
;
3536 XSETBUFFER (prev_buffer
, old
);
3538 /* Select the window that was chosen, for running the hook.
3539 Note: Both Fselect_window and select_window_norecord may
3540 set-buffer to the buffer displayed in the window,
3541 so we need to save the current buffer. --stef */
3542 record_unwind_protect (Fset_buffer
, prev_buffer
);
3543 record_unwind_protect (select_window_norecord
, prev_window
);
3544 Fselect_window (window
, Qt
);
3545 Fset_buffer (w
->buffer
);
3546 call1 (Vrun_hooks
, Qtemp_buffer_show_hook
);
3547 unbind_to (count
, Qnil
);
3553 make_dummy_parent (window
)
3557 register struct window
*o
, *p
;
3560 o
= XWINDOW (window
);
3561 p
= allocate_window ();
3562 for (i
= 0; i
< VECSIZE (struct window
); ++i
)
3563 ((struct Lisp_Vector
*) p
)->contents
[i
]
3564 = ((struct Lisp_Vector
*)o
)->contents
[i
];
3565 XSETWINDOW (new, p
);
3567 XSETFASTINT (p
->sequence_number
, ++sequence_number
);
3569 /* Put new into window structure in place of window */
3570 replace_window (window
, new);
3583 DEFUN ("split-window", Fsplit_window
, Ssplit_window
, 0, 3, "",
3584 doc
: /* Split WINDOW, putting SIZE lines in the first of the pair.
3585 WINDOW defaults to selected one and SIZE to half its size.
3586 If optional third arg HORFLAG is non-nil, split side by side
3587 and put SIZE columns in the first of the pair. In that case,
3588 SIZE includes that window's scroll bar, or the divider column to its right. */)
3589 (window
, size
, horflag
)
3590 Lisp_Object window
, size
, horflag
;
3592 register Lisp_Object
new;
3593 register struct window
*o
, *p
;
3595 register int size_int
;
3598 window
= selected_window
;
3600 CHECK_LIVE_WINDOW (window
);
3602 o
= XWINDOW (window
);
3603 fo
= XFRAME (WINDOW_FRAME (o
));
3607 if (!NILP (horflag
))
3608 /* Calculate the size of the left-hand window, by dividing
3609 the usable space in columns by two.
3610 We round up, since the left-hand window may include
3611 a dividing line, while the right-hand may not. */
3612 size_int
= (XFASTINT (o
->total_cols
) + 1) >> 1;
3614 size_int
= XFASTINT (o
->total_lines
) >> 1;
3618 CHECK_NUMBER (size
);
3619 size_int
= XINT (size
);
3622 if (MINI_WINDOW_P (o
))
3623 error ("Attempt to split minibuffer window");
3624 else if (window_fixed_size_p (o
, !NILP (horflag
), 0))
3625 error ("Attempt to split fixed-size window");
3627 check_min_window_sizes ();
3631 if (size_int
< window_min_height
)
3632 error ("Window height %d too small (after splitting)", size_int
);
3633 if (size_int
+ window_min_height
> XFASTINT (o
->total_lines
))
3634 error ("Window height %d too small (after splitting)",
3635 XFASTINT (o
->total_lines
) - size_int
);
3636 if (NILP (o
->parent
)
3637 || NILP (XWINDOW (o
->parent
)->vchild
))
3639 make_dummy_parent (window
);
3641 XWINDOW (new)->vchild
= window
;
3646 if (size_int
< window_min_width
)
3647 error ("Window width %d too small (after splitting)", size_int
);
3649 if (size_int
+ window_min_width
> XFASTINT (o
->total_cols
))
3650 error ("Window width %d too small (after splitting)",
3651 XFASTINT (o
->total_cols
) - size_int
);
3652 if (NILP (o
->parent
)
3653 || NILP (XWINDOW (o
->parent
)->hchild
))
3655 make_dummy_parent (window
);
3657 XWINDOW (new)->hchild
= window
;
3661 /* Now we know that window's parent is a vertical combination
3662 if we are dividing vertically, or a horizontal combination
3663 if we are making side-by-side windows */
3665 windows_or_buffers_changed
++;
3666 FRAME_WINDOW_SIZES_CHANGED (fo
) = 1;
3667 new = make_window ();
3670 p
->frame
= o
->frame
;
3672 if (!NILP (p
->next
))
3673 XWINDOW (p
->next
)->prev
= new;
3676 p
->parent
= o
->parent
;
3678 p
->window_end_valid
= Qnil
;
3679 bzero (&p
->last_cursor
, sizeof p
->last_cursor
);
3681 /* Duplicate special geometry settings. */
3683 p
->left_margin_cols
= o
->left_margin_cols
;
3684 p
->right_margin_cols
= o
->right_margin_cols
;
3685 p
->left_fringe_width
= o
->left_fringe_width
;
3686 p
->right_fringe_width
= o
->right_fringe_width
;
3687 p
->fringes_outside_margins
= o
->fringes_outside_margins
;
3688 p
->scroll_bar_width
= o
->scroll_bar_width
;
3689 p
->vertical_scroll_bar_type
= o
->vertical_scroll_bar_type
;
3691 /* Apportion the available frame space among the two new windows */
3693 if (!NILP (horflag
))
3695 p
->total_lines
= o
->total_lines
;
3696 p
->top_line
= o
->top_line
;
3697 XSETFASTINT (p
->total_cols
, XFASTINT (o
->total_cols
) - size_int
);
3698 XSETFASTINT (o
->total_cols
, size_int
);
3699 XSETFASTINT (p
->left_col
, XFASTINT (o
->left_col
) + size_int
);
3700 adjust_window_margins (p
);
3701 adjust_window_margins (o
);
3705 p
->left_col
= o
->left_col
;
3706 p
->total_cols
= o
->total_cols
;
3707 XSETFASTINT (p
->total_lines
, XFASTINT (o
->total_lines
) - size_int
);
3708 XSETFASTINT (o
->total_lines
, size_int
);
3709 XSETFASTINT (p
->top_line
, XFASTINT (o
->top_line
) + size_int
);
3712 /* Adjust glyph matrices. */
3715 Fset_window_buffer (new, o
->buffer
, Qt
);
3719 DEFUN ("enlarge-window", Fenlarge_window
, Senlarge_window
, 1, 3, "p",
3720 doc
: /* Make current window ARG lines bigger.
3721 From program, optional second arg non-nil means grow sideways ARG columns.
3722 Interactively, if an argument is not given, make the window one line bigger.
3724 Optional third arg PRESERVE-BEFORE, if non-nil, means do not change the size
3725 of the siblings above or to the left of the selected window. Only
3726 siblings to the right or below are changed. */)
3727 (arg
, side
, preserve_before
)
3728 register Lisp_Object arg
, side
, preserve_before
;
3731 enlarge_window (selected_window
, XINT (arg
), !NILP (side
),
3732 !NILP (preserve_before
));
3734 if (! NILP (Vwindow_configuration_change_hook
))
3735 call1 (Vrun_hooks
, Qwindow_configuration_change_hook
);
3740 DEFUN ("shrink-window", Fshrink_window
, Sshrink_window
, 1, 3, "p",
3741 doc
: /* Make current window ARG lines smaller.
3742 From program, optional second arg non-nil means shrink sideways arg columns.
3743 Interactively, if an argument is not given, make the window one line smaller.
3745 Optional third arg PRESERVE-BEFORE, if non-nil, means do not change the size
3746 of the siblings above or to the left of the selected window. Only
3747 siblings to the right or below are changed. */)
3748 (arg
, side
, preserve_before
)
3749 register Lisp_Object arg
, side
, preserve_before
;
3752 enlarge_window (selected_window
, -XINT (arg
), !NILP (side
),
3753 !NILP (preserve_before
));
3755 if (! NILP (Vwindow_configuration_change_hook
))
3756 call1 (Vrun_hooks
, Qwindow_configuration_change_hook
);
3762 window_height (window
)
3765 register struct window
*p
= XWINDOW (window
);
3766 return WINDOW_TOTAL_LINES (p
);
3770 window_width (window
)
3773 register struct window
*p
= XWINDOW (window
);
3774 return WINDOW_TOTAL_COLS (p
);
3779 *(widthflag ? &(XWINDOW (w)->left_col) : &(XWINDOW (w)->top_line))
3781 #define CURSIZE(w) \
3782 *(widthflag ? &(XWINDOW (w)->total_cols) : &(XWINDOW (w)->total_lines))
3785 /* Enlarge WINDOW by DELTA. WIDTHFLAG non-zero means
3786 increase its width. Siblings of the selected window are resized to
3787 fulfill the size request. If they become too small in the process,
3788 they will be deleted.
3790 If PRESERVE_BEFORE is nonzero, that means don't alter
3791 the siblings to the left or above WINDOW. */
3794 enlarge_window (window
, delta
, widthflag
, preserve_before
)
3796 int delta
, widthflag
, preserve_before
;
3798 Lisp_Object parent
, next
, prev
;
3802 int (*sizefun
) P_ ((Lisp_Object
))
3803 = widthflag
? window_width
: window_height
;
3804 void (*setsizefun
) P_ ((Lisp_Object
, int, int))
3805 = (widthflag
? set_window_width
: set_window_height
);
3807 /* Check values of window_min_width and window_min_height for
3809 check_min_window_sizes ();
3811 /* Give up if this window cannot be resized. */
3812 if (window_fixed_size_p (XWINDOW (window
), widthflag
, 1))
3813 error ("Window is not resizable");
3815 /* Find the parent of the selected window. */
3818 p
= XWINDOW (window
);
3824 error ("No other window to side of this one");
3829 ? !NILP (XWINDOW (parent
)->hchild
)
3830 : !NILP (XWINDOW (parent
)->vchild
))
3836 sizep
= &CURSIZE (window
);
3839 register int maxdelta
;
3841 /* Compute the maximum size increment this window can have. */
3843 if (preserve_before
)
3847 maxdelta
= (*sizefun
) (parent
) - XINT (*sizep
);
3848 /* Subtract size of siblings before, since we can't take that. */
3849 maxdelta
-= XINT (CURBEG (window
)) - XINT (CURBEG (parent
));
3852 maxdelta
= (!NILP (p
->next
) ? ((*sizefun
) (p
->next
)
3853 - window_min_size (XWINDOW (p
->next
),
3858 maxdelta
= (!NILP (parent
) ? (*sizefun
) (parent
) - XINT (*sizep
)
3859 /* This is a main window followed by a minibuffer. */
3860 : !NILP (p
->next
) ? ((*sizefun
) (p
->next
)
3861 - window_min_size (XWINDOW (p
->next
),
3863 /* This is a minibuffer following a main window. */
3864 : !NILP (p
->prev
) ? ((*sizefun
) (p
->prev
)
3865 - window_min_size (XWINDOW (p
->prev
),
3867 /* This is a frame with only one window, a minibuffer-only
3868 or a minibufferless frame. */
3871 if (delta
> maxdelta
)
3872 /* This case traps trying to make the minibuffer
3873 the full frame, or make the only window aside from the
3874 minibuffer the full frame. */
3878 if (XINT (*sizep
) + delta
< window_min_size (XWINDOW (window
), widthflag
, 0, 0))
3880 delete_window (window
);
3887 /* Find the total we can get from other siblings without deleting them. */
3889 for (next
= p
->next
; ! NILP (next
); next
= XWINDOW (next
)->next
)
3890 maximum
+= (*sizefun
) (next
) - window_min_size (XWINDOW (next
),
3892 if (! preserve_before
)
3893 for (prev
= p
->prev
; ! NILP (prev
); prev
= XWINDOW (prev
)->prev
)
3894 maximum
+= (*sizefun
) (prev
) - window_min_size (XWINDOW (prev
),
3897 /* If we can get it all from them without deleting them, do so. */
3898 if (delta
<= maximum
)
3900 Lisp_Object first_unaffected
;
3901 Lisp_Object first_affected
;
3906 first_affected
= window
;
3907 /* Look at one sibling at a time,
3908 moving away from this window in both directions alternately,
3909 and take as much as we can get without deleting that sibling. */
3911 && (!NILP (next
) || (!preserve_before
&& !NILP (prev
))))
3915 int this_one
= ((*sizefun
) (next
)
3916 - window_min_size (XWINDOW (next
),
3917 widthflag
, 0, &fixed_p
));
3920 if (this_one
> delta
)
3923 (*setsizefun
) (next
, (*sizefun
) (next
) - this_one
, 0);
3924 (*setsizefun
) (window
, XINT (*sizep
) + this_one
, 0);
3929 next
= XWINDOW (next
)->next
;
3935 if (!preserve_before
&& ! NILP (prev
))
3937 int this_one
= ((*sizefun
) (prev
)
3938 - window_min_size (XWINDOW (prev
),
3939 widthflag
, 0, &fixed_p
));
3942 if (this_one
> delta
)
3945 first_affected
= prev
;
3947 (*setsizefun
) (prev
, (*sizefun
) (prev
) - this_one
, 0);
3948 (*setsizefun
) (window
, XINT (*sizep
) + this_one
, 0);
3953 prev
= XWINDOW (prev
)->prev
;
3957 xassert (delta
== 0);
3959 /* Now recalculate the edge positions of all the windows affected,
3960 based on the new sizes. */
3961 first_unaffected
= next
;
3962 prev
= first_affected
;
3963 for (next
= XWINDOW (prev
)->next
; ! EQ (next
, first_unaffected
);
3964 prev
= next
, next
= XWINDOW (next
)->next
)
3966 XSETINT (CURBEG (next
), XINT (CURBEG (prev
)) + (*sizefun
) (prev
));
3967 /* This does not change size of NEXT,
3968 but it propagates the new top edge to its children */
3969 (*setsizefun
) (next
, (*sizefun
) (next
), 0);
3974 register int delta1
;
3975 register int opht
= (*sizefun
) (parent
);
3977 if (opht
<= XINT (*sizep
) + delta
)
3979 /* If trying to grow this window to or beyond size of the parent,
3980 just delete all the sibling windows. */
3981 Lisp_Object start
, tem
, next
;
3983 start
= XWINDOW (parent
)->vchild
;
3985 start
= XWINDOW (parent
)->hchild
;
3987 /* Delete any siblings that come after WINDOW. */
3988 tem
= XWINDOW (window
)->next
;
3989 while (! NILP (tem
))
3991 next
= XWINDOW (tem
)->next
;
3992 delete_window (tem
);
3996 /* Delete any siblings that come after WINDOW.
3997 Note that if START is not WINDOW, then WINDOW still
3998 Fhas siblings, so WINDOW has not yet replaced its parent. */
4000 while (! EQ (tem
, window
))
4002 next
= XWINDOW (tem
)->next
;
4003 delete_window (tem
);
4009 /* Otherwise, make delta1 just right so that if we add
4010 delta1 lines to this window and to the parent, and then
4011 shrink the parent back to its original size, the new
4012 proportional size of this window will increase by delta.
4014 The function size_window will compute the new height h'
4015 of the window from delta1 as:
4018 x = delta1 - delta1/n * n for the 1st resizable child
4021 where n is the number of children that can be resized.
4022 We can ignore x by choosing a delta1 that is a multiple of
4023 n. We want the height of this window to come out as
4033 The number of children n equals the number of resizable
4034 children of this window + 1 because we know window itself
4035 is resizable (otherwise we would have signalled an error. */
4037 struct window
*w
= XWINDOW (window
);
4041 for (s
= w
->next
; !NILP (s
); s
= XWINDOW (s
)->next
)
4042 if (!window_fixed_size_p (XWINDOW (s
), widthflag
, 0))
4044 for (s
= w
->prev
; !NILP (s
); s
= XWINDOW (s
)->prev
)
4045 if (!window_fixed_size_p (XWINDOW (s
), widthflag
, 0))
4050 /* Add delta1 lines or columns to this window, and to the parent,
4051 keeping things consistent while not affecting siblings. */
4052 XSETINT (CURSIZE (parent
), opht
+ delta1
);
4053 (*setsizefun
) (window
, XINT (*sizep
) + delta1
, 0);
4055 /* Squeeze out delta1 lines or columns from our parent,
4056 shriking this window and siblings proportionately.
4057 This brings parent back to correct size.
4058 Delta1 was calculated so this makes this window the desired size,
4059 taking it all out of the siblings. */
4060 (*setsizefun
) (parent
, opht
, 0);
4065 XSETFASTINT (p
->last_modified
, 0);
4066 XSETFASTINT (p
->last_overlay_modified
, 0);
4068 /* Adjust glyph matrices. */
4069 adjust_glyphs (XFRAME (WINDOW_FRAME (XWINDOW (window
))));
4077 /***********************************************************************
4078 Resizing Mini-Windows
4079 ***********************************************************************/
4081 static void shrink_window_lowest_first
P_ ((struct window
*, int));
4083 enum save_restore_action
4090 static int save_restore_orig_size
P_ ((struct window
*,
4091 enum save_restore_action
));
4093 /* Shrink windows rooted in window W to HEIGHT. Take the space needed
4094 from lowest windows first. */
4097 shrink_window_lowest_first (w
, height
)
4105 xassert (!MINI_WINDOW_P (w
));
4107 /* Set redisplay hints. */
4108 XSETFASTINT (w
->last_modified
, 0);
4109 XSETFASTINT (w
->last_overlay_modified
, 0);
4110 windows_or_buffers_changed
++;
4111 FRAME_WINDOW_SIZES_CHANGED (XFRAME (WINDOW_FRAME (w
))) = 1;
4113 old_height
= XFASTINT (w
->total_lines
);
4114 XSETFASTINT (w
->total_lines
, height
);
4116 if (!NILP (w
->hchild
))
4118 for (child
= w
->hchild
; !NILP (child
); child
= c
->next
)
4120 c
= XWINDOW (child
);
4121 c
->top_line
= w
->top_line
;
4122 shrink_window_lowest_first (c
, height
);
4125 else if (!NILP (w
->vchild
))
4127 Lisp_Object last_child
;
4128 int delta
= old_height
- height
;
4133 /* Find the last child. We are taking space from lowest windows
4134 first, so we iterate over children from the last child
4136 for (child
= w
->vchild
; !NILP (child
); child
= XWINDOW (child
)->next
)
4139 /* Assign new heights. We leave only MIN_SAFE_WINDOW_HEIGHT. */
4140 for (child
= last_child
; delta
&& !NILP (child
); child
= c
->prev
)
4144 c
= XWINDOW (child
);
4145 this_one
= XFASTINT (c
->total_lines
) - MIN_SAFE_WINDOW_HEIGHT
;
4147 if (this_one
> delta
)
4150 shrink_window_lowest_first (c
, XFASTINT (c
->total_lines
) - this_one
);
4154 /* Compute new positions. */
4155 last_top
= XINT (w
->top_line
);
4156 for (child
= w
->vchild
; !NILP (child
); child
= c
->next
)
4158 c
= XWINDOW (child
);
4159 c
->top_line
= make_number (last_top
);
4160 shrink_window_lowest_first (c
, XFASTINT (c
->total_lines
));
4161 last_top
+= XFASTINT (c
->total_lines
);
4167 /* Save, restore, or check positions and sizes in the window tree
4168 rooted at W. ACTION says what to do.
4170 If ACTION is CHECK_ORIG_SIZES, check if orig_top_line and
4171 orig_total_lines members are valid for all windows in the window
4172 tree. Value is non-zero if they are valid.
4174 If ACTION is SAVE_ORIG_SIZES, save members top and height in
4175 orig_top_line and orig_total_lines for all windows in the tree.
4177 If ACTION is RESTORE_ORIG_SIZES, restore top and height from values
4178 stored in orig_top_line and orig_total_lines for all windows. */
4181 save_restore_orig_size (w
, action
)
4183 enum save_restore_action action
;
4189 if (!NILP (w
->hchild
))
4191 if (!save_restore_orig_size (XWINDOW (w
->hchild
), action
))
4194 else if (!NILP (w
->vchild
))
4196 if (!save_restore_orig_size (XWINDOW (w
->vchild
), action
))
4202 case CHECK_ORIG_SIZES
:
4203 if (!INTEGERP (w
->orig_top_line
) || !INTEGERP (w
->orig_total_lines
))
4207 case SAVE_ORIG_SIZES
:
4208 w
->orig_top_line
= w
->top_line
;
4209 w
->orig_total_lines
= w
->total_lines
;
4210 XSETFASTINT (w
->last_modified
, 0);
4211 XSETFASTINT (w
->last_overlay_modified
, 0);
4214 case RESTORE_ORIG_SIZES
:
4215 xassert (INTEGERP (w
->orig_top_line
) && INTEGERP (w
->orig_total_lines
));
4216 w
->top_line
= w
->orig_top_line
;
4217 w
->total_lines
= w
->orig_total_lines
;
4218 w
->orig_total_lines
= w
->orig_top_line
= Qnil
;
4219 XSETFASTINT (w
->last_modified
, 0);
4220 XSETFASTINT (w
->last_overlay_modified
, 0);
4227 w
= NILP (w
->next
) ? NULL
: XWINDOW (w
->next
);
4234 /* Grow mini-window W by DELTA lines, DELTA >= 0, or as much as we can
4235 without deleting other windows. */
4238 grow_mini_window (w
, delta
)
4242 struct frame
*f
= XFRAME (w
->frame
);
4243 struct window
*root
;
4245 xassert (MINI_WINDOW_P (w
));
4246 xassert (delta
>= 0);
4248 /* Check values of window_min_width and window_min_height for
4250 check_min_window_sizes ();
4252 /* Compute how much we can enlarge the mini-window without deleting
4254 root
= XWINDOW (FRAME_ROOT_WINDOW (f
));
4257 int min_height
= window_min_size (root
, 0, 0, 0);
4258 if (XFASTINT (root
->total_lines
) - delta
< min_height
)
4259 /* Note that the root window may already be smaller than
4261 delta
= max (0, XFASTINT (root
->total_lines
) - min_height
);
4266 /* Save original window sizes and positions, if not already done. */
4267 if (!save_restore_orig_size (root
, CHECK_ORIG_SIZES
))
4268 save_restore_orig_size (root
, SAVE_ORIG_SIZES
);
4270 /* Shrink other windows. */
4271 shrink_window_lowest_first (root
, XFASTINT (root
->total_lines
) - delta
);
4273 /* Grow the mini-window. */
4274 w
->top_line
= make_number (XFASTINT (root
->top_line
) + XFASTINT (root
->total_lines
));
4275 w
->total_lines
= make_number (XFASTINT (w
->total_lines
) + delta
);
4276 XSETFASTINT (w
->last_modified
, 0);
4277 XSETFASTINT (w
->last_overlay_modified
, 0);
4284 /* Shrink mini-window W. If there is recorded info about window sizes
4285 before a call to grow_mini_window, restore recorded window sizes.
4286 Otherwise, if the mini-window is higher than 1 line, resize it to 1
4290 shrink_mini_window (w
)
4293 struct frame
*f
= XFRAME (w
->frame
);
4294 struct window
*root
= XWINDOW (FRAME_ROOT_WINDOW (f
));
4296 if (save_restore_orig_size (root
, CHECK_ORIG_SIZES
))
4298 save_restore_orig_size (root
, RESTORE_ORIG_SIZES
);
4300 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
4301 windows_or_buffers_changed
= 1;
4303 else if (XFASTINT (w
->total_lines
) > 1)
4305 /* Distribute the additional lines of the mini-window
4306 among the other windows. */
4308 XSETWINDOW (window
, w
);
4309 enlarge_window (window
, 1 - XFASTINT (w
->total_lines
), 0, 0);
4315 /* Mark window cursors off for all windows in the window tree rooted
4316 at W by setting their phys_cursor_on_p flag to zero. Called from
4317 xterm.c, e.g. when a frame is cleared and thereby all cursors on
4318 the frame are cleared. */
4321 mark_window_cursors_off (w
)
4326 if (!NILP (w
->hchild
))
4327 mark_window_cursors_off (XWINDOW (w
->hchild
));
4328 else if (!NILP (w
->vchild
))
4329 mark_window_cursors_off (XWINDOW (w
->vchild
));
4331 w
->phys_cursor_on_p
= 0;
4333 w
= NILP (w
->next
) ? 0 : XWINDOW (w
->next
);
4338 /* Return number of lines of text (not counting mode lines) in W. */
4341 window_internal_height (w
)
4344 int ht
= XFASTINT (w
->total_lines
);
4346 if (!MINI_WINDOW_P (w
))
4348 if (!NILP (w
->parent
)
4349 || !NILP (w
->vchild
)
4350 || !NILP (w
->hchild
)
4353 || WINDOW_WANTS_MODELINE_P (w
))
4356 if (WINDOW_WANTS_HEADER_LINE_P (w
))
4364 /* Return the number of columns in W.
4365 Don't count columns occupied by scroll bars or the vertical bar
4366 separating W from the sibling to its right. */
4369 window_box_text_cols (w
)
4372 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
4373 int width
= XINT (w
->total_cols
);
4375 if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w
))
4376 /* Scroll bars occupy a few columns. */
4377 width
-= WINDOW_CONFIG_SCROLL_BAR_COLS (w
);
4378 else if (!FRAME_WINDOW_P (f
)
4379 && !WINDOW_RIGHTMOST_P (w
) && !WINDOW_FULL_WIDTH_P (w
))
4380 /* The column of `|' characters separating side-by-side windows
4381 occupies one column only. */
4384 if (FRAME_WINDOW_P (f
))
4385 /* On window-systems, fringes and display margins cannot be
4386 used for normal text. */
4387 width
-= (WINDOW_FRINGE_COLS (w
)
4388 + WINDOW_LEFT_MARGIN_COLS (w
)
4389 + WINDOW_RIGHT_MARGIN_COLS (w
));
4395 /************************************************************************
4397 ***********************************************************************/
4399 /* Scroll contents of window WINDOW up. If WHOLE is non-zero, scroll
4400 N screen-fulls, which is defined as the height of the window minus
4401 next_screen_context_lines. If WHOLE is zero, scroll up N lines
4402 instead. Negative values of N mean scroll down. NOERROR non-zero
4403 means don't signal an error if we try to move over BEGV or ZV,
4407 window_scroll (window
, n
, whole
, noerror
)
4415 /* If we must, use the pixel-based version which is much slower than
4416 the line-based one but can handle varying line heights. */
4417 if (FRAME_WINDOW_P (XFRAME (XWINDOW (window
)->frame
)))
4418 window_scroll_pixel_based (window
, n
, whole
, noerror
);
4420 window_scroll_line_based (window
, n
, whole
, noerror
);
4426 /* Implementation of window_scroll that works based on pixel line
4427 heights. See the comment of window_scroll for parameter
4431 window_scroll_pixel_based (window
, n
, whole
, noerror
)
4438 struct window
*w
= XWINDOW (window
);
4439 struct text_pos start
;
4441 int this_scroll_margin
;
4443 /* True if we fiddled the window vscroll field without really scrolling. */
4446 SET_TEXT_POS_FROM_MARKER (start
, w
->start
);
4448 /* If PT is not visible in WINDOW, move back one half of
4449 the screen. Allow PT to be partially visible, otherwise
4450 something like (scroll-down 1) with PT in the line before
4451 the partially visible one would recenter. */
4452 tem
= Fpos_visible_in_window_p (make_number (PT
), window
, Qt
);
4455 /* Move backward half the height of the window. Performance note:
4456 vmotion used here is about 10% faster, but would give wrong
4457 results for variable height lines. */
4458 init_iterator (&it
, w
, PT
, PT_BYTE
, NULL
, DEFAULT_FACE_ID
);
4459 it
.current_y
= it
.last_visible_y
;
4460 move_it_vertically (&it
, - window_box_height (w
) / 2);
4462 /* The function move_iterator_vertically may move over more than
4463 the specified y-distance. If it->w is small, e.g. a
4464 mini-buffer window, we may end up in front of the window's
4465 display area. This is the case when Start displaying at the
4466 start of the line containing PT in this case. */
4467 if (it
.current_y
<= 0)
4469 init_iterator (&it
, w
, PT
, PT_BYTE
, NULL
, DEFAULT_FACE_ID
);
4470 move_it_vertically (&it
, 0);
4474 start
= it
.current
.pos
;
4477 /* If scroll_preserve_screen_position is non-zero, we try to set
4478 point in the same window line as it is now, so get that line. */
4479 if (!NILP (Vscroll_preserve_screen_position
))
4481 start_display (&it
, w
, start
);
4482 move_it_to (&it
, PT
, -1, -1, -1, MOVE_TO_POS
);
4483 preserve_y
= it
.current_y
;
4488 /* Move iterator it from start the specified distance forward or
4489 backward. The result is the new window start. */
4490 start_display (&it
, w
, start
);
4493 int screen_full
= (window_box_height (w
)
4494 - next_screen_context_lines
* FRAME_LINE_HEIGHT (it
.f
));
4495 int dy
= n
* screen_full
;
4497 /* Note that move_it_vertically always moves the iterator to the
4498 start of a line. So, if the last line doesn't have a newline,
4499 we would end up at the start of the line ending at ZV. */
4501 move_it_vertically_backward (&it
, -dy
);
4503 move_it_to (&it
, ZV
, -1, it
.current_y
+ dy
, -1,
4504 MOVE_TO_POS
| MOVE_TO_Y
);
4507 move_it_by_lines (&it
, n
, 1);
4509 /* We failed if we find ZV is already on the screen (scrolling up,
4510 means there's nothing past the end), or if we can't start any
4511 earlier (scrolling down, means there's nothing past the top). */
4512 if ((n
> 0 && IT_CHARPOS (it
) == ZV
)
4513 || (n
< 0 && IT_CHARPOS (it
) == CHARPOS (start
)))
4515 if (IT_CHARPOS (it
) == ZV
)
4517 if (it
.current_y
< it
.last_visible_y
4518 && (it
.current_y
+ it
.max_ascent
+ it
.max_descent
4519 >= it
.last_visible_y
))
4521 /* The last line was only partially visible, make it fully
4523 w
->vscroll
= (it
.last_visible_y
4524 - it
.current_y
+ it
.max_ascent
+ it
.max_descent
);
4525 adjust_glyphs (it
.f
);
4530 Fsignal (Qend_of_buffer
, Qnil
);
4534 if (w
->vscroll
!= 0)
4535 /* The first line was only partially visible, make it fully
4541 Fsignal (Qbeginning_of_buffer
, Qnil
);
4544 /* If control gets here, then we vscrolled. */
4546 XBUFFER (w
->buffer
)->prevent_redisplay_optimizations_p
= 1;
4548 /* Don't try to change the window start below. */
4554 int pos
= IT_CHARPOS (it
);
4557 /* If in the middle of a multi-glyph character move forward to
4558 the next character. */
4559 if (in_display_vector_p (&it
))
4562 move_it_to (&it
, pos
, -1, -1, -1, MOVE_TO_POS
);
4565 /* Set the window start, and set up the window for redisplay. */
4566 set_marker_restricted (w
->start
, make_number (pos
),
4568 bytepos
= XMARKER (w
->start
)->bytepos
;
4569 w
->start_at_line_beg
= ((pos
== BEGV
|| FETCH_BYTE (bytepos
- 1) == '\n')
4571 w
->update_mode_line
= Qt
;
4572 XSETFASTINT (w
->last_modified
, 0);
4573 XSETFASTINT (w
->last_overlay_modified
, 0);
4574 /* Set force_start so that redisplay_window will run the
4575 window-scroll-functions. */
4576 w
->force_start
= Qt
;
4579 it
.current_y
= it
.vpos
= 0;
4581 /* Preserve the screen position if we must. */
4582 if (preserve_y
>= 0)
4584 move_it_to (&it
, -1, -1, preserve_y
, -1, MOVE_TO_Y
);
4585 SET_PT_BOTH (IT_CHARPOS (it
), IT_BYTEPOS (it
));
4589 /* Move PT out of scroll margins. */
4590 this_scroll_margin
= max (0, scroll_margin
);
4591 this_scroll_margin
= min (this_scroll_margin
, XFASTINT (w
->total_lines
) / 4);
4592 this_scroll_margin
*= FRAME_LINE_HEIGHT (it
.f
);
4596 /* We moved the window start towards ZV, so PT may be now
4597 in the scroll margin at the top. */
4598 move_it_to (&it
, PT
, -1, -1, -1, MOVE_TO_POS
);
4599 while (it
.current_y
< this_scroll_margin
)
4601 int prev
= it
.current_y
;
4602 move_it_by_lines (&it
, 1, 1);
4603 if (prev
== it
.current_y
)
4606 SET_PT_BOTH (IT_CHARPOS (it
), IT_BYTEPOS (it
));
4610 int charpos
, bytepos
;
4612 /* We moved the window start towards BEGV, so PT may be now
4613 in the scroll margin at the bottom. */
4614 move_it_to (&it
, PT
, -1,
4615 it
.last_visible_y
- this_scroll_margin
- 1, -1,
4616 MOVE_TO_POS
| MOVE_TO_Y
);
4618 /* Save our position, in case it's correct. */
4619 charpos
= IT_CHARPOS (it
);
4620 bytepos
= IT_BYTEPOS (it
);
4622 /* See if point is on a partially visible line at the end. */
4623 move_it_by_lines (&it
, 1, 1);
4624 if (it
.current_y
> it
.last_visible_y
)
4625 /* The last line was only partially visible, so back up two
4626 lines to make sure we're on a fully visible line. */
4628 move_it_by_lines (&it
, -2, 0);
4629 SET_PT_BOTH (IT_CHARPOS (it
), IT_BYTEPOS (it
));
4632 /* No, the position we saved is OK, so use it. */
4633 SET_PT_BOTH (charpos
, bytepos
);
4639 /* Implementation of window_scroll that works based on screen lines.
4640 See the comment of window_scroll for parameter descriptions. */
4643 window_scroll_line_based (window
, n
, whole
, noerror
)
4649 register struct window
*w
= XWINDOW (window
);
4650 register int opoint
= PT
, opoint_byte
= PT_BYTE
;
4651 register int pos
, pos_byte
;
4652 register int ht
= window_internal_height (w
);
4653 register Lisp_Object tem
;
4657 struct position posit
;
4660 /* If scrolling screen-fulls, compute the number of lines to
4661 scroll from the window's height. */
4663 n
*= max (1, ht
- next_screen_context_lines
);
4665 startpos
= marker_position (w
->start
);
4667 posit
= *compute_motion (startpos
, 0, 0, 0,
4669 window_box_text_cols (w
), XINT (w
->hscroll
),
4671 original_vpos
= posit
.vpos
;
4673 XSETFASTINT (tem
, PT
);
4674 tem
= Fpos_visible_in_window_p (tem
, window
, Qnil
);
4678 Fvertical_motion (make_number (- (ht
/ 2)), window
);
4683 lose
= n
< 0 && PT
== BEGV
;
4684 Fvertical_motion (make_number (n
), window
);
4688 SET_PT_BOTH (opoint
, opoint_byte
);
4695 Fsignal (Qbeginning_of_buffer
, Qnil
);
4700 int this_scroll_margin
= scroll_margin
;
4702 /* Don't use a scroll margin that is negative or too large. */
4703 if (this_scroll_margin
< 0)
4704 this_scroll_margin
= 0;
4706 if (XINT (w
->total_lines
) < 4 * scroll_margin
)
4707 this_scroll_margin
= XINT (w
->total_lines
) / 4;
4709 set_marker_restricted_both (w
->start
, w
->buffer
, pos
, pos_byte
);
4710 w
->start_at_line_beg
= bolp
;
4711 w
->update_mode_line
= Qt
;
4712 XSETFASTINT (w
->last_modified
, 0);
4713 XSETFASTINT (w
->last_overlay_modified
, 0);
4714 /* Set force_start so that redisplay_window will run
4715 the window-scroll-functions. */
4716 w
->force_start
= Qt
;
4718 if (whole
&& !NILP (Vscroll_preserve_screen_position
))
4720 SET_PT_BOTH (pos
, pos_byte
);
4721 Fvertical_motion (make_number (original_vpos
), window
);
4723 /* If we scrolled forward, put point enough lines down
4724 that it is outside the scroll margin. */
4729 if (this_scroll_margin
> 0)
4731 SET_PT_BOTH (pos
, pos_byte
);
4732 Fvertical_motion (make_number (this_scroll_margin
), window
);
4738 if (top_margin
<= opoint
)
4739 SET_PT_BOTH (opoint
, opoint_byte
);
4740 else if (!NILP (Vscroll_preserve_screen_position
))
4742 SET_PT_BOTH (pos
, pos_byte
);
4743 Fvertical_motion (make_number (original_vpos
), window
);
4746 SET_PT (top_margin
);
4752 /* If we scrolled backward, put point near the end of the window
4753 but not within the scroll margin. */
4754 SET_PT_BOTH (pos
, pos_byte
);
4755 tem
= Fvertical_motion (make_number (ht
- this_scroll_margin
), window
);
4756 if (XFASTINT (tem
) == ht
- this_scroll_margin
)
4759 bottom_margin
= PT
+ 1;
4761 if (bottom_margin
> opoint
)
4762 SET_PT_BOTH (opoint
, opoint_byte
);
4765 if (!NILP (Vscroll_preserve_screen_position
))
4767 SET_PT_BOTH (pos
, pos_byte
);
4768 Fvertical_motion (make_number (original_vpos
), window
);
4771 Fvertical_motion (make_number (-1), window
);
4780 Fsignal (Qend_of_buffer
, Qnil
);
4785 /* Scroll selected_window up or down. If N is nil, scroll a
4786 screen-full which is defined as the height of the window minus
4787 next_screen_context_lines. If N is the symbol `-', scroll.
4788 DIRECTION may be 1 meaning to scroll down, or -1 meaning to scroll
4789 up. This is the guts of Fscroll_up and Fscroll_down. */
4792 scroll_command (n
, direction
)
4796 int count
= SPECPDL_INDEX ();
4798 xassert (abs (direction
) == 1);
4800 /* If selected window's buffer isn't current, make it current for
4801 the moment. But don't screw up if window_scroll gets an error. */
4802 if (XBUFFER (XWINDOW (selected_window
)->buffer
) != current_buffer
)
4804 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
4805 Fset_buffer (XWINDOW (selected_window
)->buffer
);
4807 /* Make redisplay consider other windows than just selected_window. */
4808 ++windows_or_buffers_changed
;
4812 window_scroll (selected_window
, direction
, 1, 0);
4813 else if (EQ (n
, Qminus
))
4814 window_scroll (selected_window
, -direction
, 1, 0);
4817 n
= Fprefix_numeric_value (n
);
4818 window_scroll (selected_window
, XINT (n
) * direction
, 0, 0);
4821 unbind_to (count
, Qnil
);
4824 DEFUN ("scroll-up", Fscroll_up
, Sscroll_up
, 0, 1, "P",
4825 doc
: /* Scroll text of current window upward ARG lines; or near full screen if no ARG.
4826 A near full screen is `next-screen-context-lines' less than a full screen.
4827 Negative ARG means scroll downward.
4828 If ARG is the atom `-', scroll downward by nearly full screen.
4829 When calling from a program, supply as argument a number, nil, or `-'. */)
4833 scroll_command (arg
, 1);
4837 DEFUN ("scroll-down", Fscroll_down
, Sscroll_down
, 0, 1, "P",
4838 doc
: /* Scroll text of current window down ARG lines; or near full screen if no ARG.
4839 A near full screen is `next-screen-context-lines' less than a full screen.
4840 Negative ARG means scroll upward.
4841 If ARG is the atom `-', scroll upward by nearly full screen.
4842 When calling from a program, supply as argument a number, nil, or `-'. */)
4846 scroll_command (arg
, -1);
4850 DEFUN ("other-window-for-scrolling", Fother_window_for_scrolling
, Sother_window_for_scrolling
, 0, 0, 0,
4851 doc
: /* Return the other window for \"other window scroll\" commands.
4852 If in the minibuffer, `minibuffer-scroll-window' if non-nil
4853 specifies the window.
4854 If `other-window-scroll-buffer' is non-nil, a window
4855 showing that buffer is used. */)
4860 if (MINI_WINDOW_P (XWINDOW (selected_window
))
4861 && !NILP (Vminibuf_scroll_window
))
4862 window
= Vminibuf_scroll_window
;
4863 /* If buffer is specified, scroll that buffer. */
4864 else if (!NILP (Vother_window_scroll_buffer
))
4866 window
= Fget_buffer_window (Vother_window_scroll_buffer
, Qnil
);
4868 window
= Fdisplay_buffer (Vother_window_scroll_buffer
, Qt
, Qnil
);
4872 /* Nothing specified; look for a neighboring window on the same
4874 window
= Fnext_window (selected_window
, Qnil
, Qnil
);
4876 if (EQ (window
, selected_window
))
4877 /* That didn't get us anywhere; look for a window on another
4880 window
= Fnext_window (window
, Qnil
, Qt
);
4881 while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window
))))
4882 && ! EQ (window
, selected_window
));
4885 CHECK_LIVE_WINDOW (window
);
4887 if (EQ (window
, selected_window
))
4888 error ("There is no other window");
4893 DEFUN ("scroll-other-window", Fscroll_other_window
, Sscroll_other_window
, 0, 1, "P",
4894 doc
: /* Scroll next window upward ARG lines; or near full screen if no ARG.
4895 A near full screen is `next-screen-context-lines' less than a full screen.
4896 The next window is the one below the current one; or the one at the top
4897 if the current one is at the bottom. Negative ARG means scroll downward.
4898 If ARG is the atom `-', scroll downward by nearly full screen.
4899 When calling from a program, supply as argument a number, nil, or `-'.
4901 If in the minibuffer, `minibuffer-scroll-window' if non-nil
4902 specifies the window to scroll.
4903 If `other-window-scroll-buffer' is non-nil, scroll the window
4904 showing that buffer, popping the buffer up if necessary. */)
4910 int count
= SPECPDL_INDEX ();
4912 window
= Fother_window_for_scrolling ();
4913 w
= XWINDOW (window
);
4915 /* Don't screw up if window_scroll gets an error. */
4916 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
4917 ++windows_or_buffers_changed
;
4919 Fset_buffer (w
->buffer
);
4920 SET_PT (marker_position (w
->pointm
));
4923 window_scroll (window
, 1, 1, 1);
4924 else if (EQ (arg
, Qminus
))
4925 window_scroll (window
, -1, 1, 1);
4931 window_scroll (window
, XINT (arg
), 0, 1);
4934 set_marker_both (w
->pointm
, Qnil
, PT
, PT_BYTE
);
4935 unbind_to (count
, Qnil
);
4940 DEFUN ("scroll-left", Fscroll_left
, Sscroll_left
, 0, 1, "P",
4941 doc
: /* Scroll selected window display ARG columns left.
4942 Default for ARG is window width minus 2.
4943 Value is the total amount of leftward horizontal scrolling in
4944 effect after the change.
4945 If `automatic-hscrolling' is non-nil, the argument ARG modifies
4946 a lower bound for automatic scrolling, i.e. automatic scrolling
4947 will not scroll a window to a column less than the value returned
4948 by this function. */)
4950 register Lisp_Object arg
;
4954 struct window
*w
= XWINDOW (selected_window
);
4957 XSETFASTINT (arg
, window_box_text_cols (w
) - 2);
4959 arg
= Fprefix_numeric_value (arg
);
4961 hscroll
= XINT (w
->hscroll
) + XINT (arg
);
4962 result
= Fset_window_hscroll (selected_window
, make_number (hscroll
));
4964 if (interactive_p (0))
4965 w
->min_hscroll
= w
->hscroll
;
4970 DEFUN ("scroll-right", Fscroll_right
, Sscroll_right
, 0, 1, "P",
4971 doc
: /* Scroll selected window display ARG columns right.
4972 Default for ARG is window width minus 2.
4973 Value is the total amount of leftward horizontal scrolling in
4974 effect after the change.
4975 If `automatic-hscrolling' is non-nil, the argument ARG modifies
4976 a lower bound for automatic scrolling, i.e. automatic scrolling
4977 will not scroll a window to a column less than the value returned
4978 by this function. */)
4980 register Lisp_Object arg
;
4984 struct window
*w
= XWINDOW (selected_window
);
4987 XSETFASTINT (arg
, window_box_text_cols (w
) - 2);
4989 arg
= Fprefix_numeric_value (arg
);
4991 hscroll
= XINT (w
->hscroll
) - XINT (arg
);
4992 result
= Fset_window_hscroll (selected_window
, make_number (hscroll
));
4994 if (interactive_p (0))
4995 w
->min_hscroll
= w
->hscroll
;
5000 DEFUN ("minibuffer-selected-window", Fminibuffer_selected_window
, Sminibuffer_selected_window
, 0, 0, 0,
5001 doc
: /* Return the window which was selected when entering the minibuffer.
5002 Returns nil, if current window is not a minibuffer window. */)
5005 if (minibuf_level
> 0
5006 && MINI_WINDOW_P (XWINDOW (selected_window
))
5007 && WINDOW_LIVE_P (minibuf_selected_window
))
5008 return minibuf_selected_window
;
5013 /* Value is the number of lines actually displayed in window W,
5014 as opposed to its height. */
5017 displayed_window_lines (w
)
5021 struct text_pos start
;
5022 int height
= window_box_height (w
);
5023 struct buffer
*old_buffer
;
5026 if (XBUFFER (w
->buffer
) != current_buffer
)
5028 old_buffer
= current_buffer
;
5029 set_buffer_internal (XBUFFER (w
->buffer
));
5034 /* In case W->start is out of the accessible range, do something
5035 reasonable. This happens in Info mode when Info-scroll-down
5036 calls (recenter -1) while W->start is 1. */
5037 if (XMARKER (w
->start
)->charpos
< BEGV
)
5038 SET_TEXT_POS (start
, BEGV
, BEGV_BYTE
);
5039 else if (XMARKER (w
->start
)->charpos
> ZV
)
5040 SET_TEXT_POS (start
, ZV
, ZV_BYTE
);
5042 SET_TEXT_POS_FROM_MARKER (start
, w
->start
);
5044 start_display (&it
, w
, start
);
5045 move_it_vertically (&it
, height
);
5046 bottom_y
= line_bottom_y (&it
);
5048 /* rms: On a non-window display,
5049 the value of it.vpos at the bottom of the screen
5050 seems to be 1 larger than window_box_height (w).
5051 This kludge fixes a bug whereby (move-to-window-line -1)
5052 when ZV is on the last screen line
5053 moves to the previous screen line instead of the last one. */
5054 if (! FRAME_WINDOW_P (XFRAME (w
->frame
)))
5057 /* Add in empty lines at the bottom of the window. */
5058 if (bottom_y
< height
)
5060 int uy
= FRAME_LINE_HEIGHT (it
.f
);
5061 it
.vpos
+= (height
- bottom_y
+ uy
- 1) / uy
;
5065 set_buffer_internal (old_buffer
);
5071 DEFUN ("recenter", Frecenter
, Srecenter
, 0, 1, "P",
5072 doc
: /* Center point in window and redisplay frame.
5073 With prefix argument ARG, recenter putting point on screen line ARG
5074 relative to the current window. If ARG is negative, it counts up from the
5075 bottom of the window. (ARG should be less than the height of the window.)
5077 If ARG is omitted or nil, erase the entire frame and then
5078 redraw with point in the center of the current window.
5079 Just C-u as prefix means put point in the center of the window
5080 and redisplay normally--don't erase and redraw the frame. */)
5082 register Lisp_Object arg
;
5084 struct window
*w
= XWINDOW (selected_window
);
5085 struct buffer
*buf
= XBUFFER (w
->buffer
);
5086 struct buffer
*obuf
= current_buffer
;
5088 int charpos
, bytepos
;
5090 /* If redisplay is suppressed due to an error, try again. */
5091 obuf
->display_error_modiff
= 0;
5097 /* Invalidate pixel data calculated for all compositions. */
5098 for (i
= 0; i
< n_compositions
; i
++)
5099 composition_table
[i
]->font
= NULL
;
5101 Fredraw_frame (w
->frame
);
5102 SET_FRAME_GARBAGED (XFRAME (WINDOW_FRAME (w
)));
5105 else if (CONSP (arg
)) /* Just C-u. */
5109 arg
= Fprefix_numeric_value (arg
);
5113 set_buffer_internal (buf
);
5115 /* Handle centering on a graphical frame specially. Such frames can
5116 have variable-height lines and centering point on the basis of
5117 line counts would lead to strange effects. */
5118 if (FRAME_WINDOW_P (XFRAME (w
->frame
)))
5125 SET_TEXT_POS (pt
, PT
, PT_BYTE
);
5126 start_display (&it
, w
, pt
);
5127 move_it_vertically (&it
, - window_box_height (w
) / 2);
5128 charpos
= IT_CHARPOS (it
);
5129 bytepos
= IT_BYTEPOS (it
);
5131 else if (XINT (arg
) < 0)
5135 int y0
, y1
, h
, nlines
;
5137 SET_TEXT_POS (pt
, PT
, PT_BYTE
);
5138 start_display (&it
, w
, pt
);
5141 /* The amount of pixels we have to move back is the window
5142 height minus what's displayed in the line containing PT,
5143 and the lines below. */
5144 nlines
= - XINT (arg
) - 1;
5145 move_it_by_lines (&it
, nlines
, 1);
5147 y1
= line_bottom_y (&it
);
5149 /* If we can't move down NLINES lines because we hit
5150 the end of the buffer, count in some empty lines. */
5151 if (it
.vpos
< nlines
)
5152 y1
+= (nlines
- it
.vpos
) * FRAME_LINE_HEIGHT (it
.f
);
5154 h
= window_box_height (w
) - (y1
- y0
);
5156 start_display (&it
, w
, pt
);
5157 move_it_vertically (&it
, - h
);
5158 charpos
= IT_CHARPOS (it
);
5159 bytepos
= IT_BYTEPOS (it
);
5163 struct position pos
;
5164 pos
= *vmotion (PT
, - XINT (arg
), w
);
5165 charpos
= pos
.bufpos
;
5166 bytepos
= pos
.bytepos
;
5171 struct position pos
;
5172 int ht
= window_internal_height (w
);
5175 arg
= make_number (ht
/ 2);
5176 else if (XINT (arg
) < 0)
5177 arg
= make_number (XINT (arg
) + ht
);
5179 pos
= *vmotion (PT
, - XINT (arg
), w
);
5180 charpos
= pos
.bufpos
;
5181 bytepos
= pos
.bytepos
;
5184 /* Set the new window start. */
5185 set_marker_both (w
->start
, w
->buffer
, charpos
, bytepos
);
5186 w
->window_end_valid
= Qnil
;
5188 w
->optional_new_start
= Qt
;
5190 if (bytepos
== BEGV_BYTE
|| FETCH_BYTE (bytepos
- 1) == '\n')
5191 w
->start_at_line_beg
= Qt
;
5193 w
->start_at_line_beg
= Qnil
;
5195 set_buffer_internal (obuf
);
5200 DEFUN ("window-text-height", Fwindow_text_height
, Swindow_text_height
,
5202 doc
: /* Return the height in lines of the text display area of WINDOW.
5203 This doesn't include the mode-line (or header-line if any) or any
5204 partial-height lines in the text display area. */)
5208 struct window
*w
= decode_window (window
);
5209 int pixel_height
= window_box_height (w
);
5210 int line_height
= pixel_height
/ FRAME_LINE_HEIGHT (XFRAME (w
->frame
));
5211 return make_number (line_height
);
5216 DEFUN ("move-to-window-line", Fmove_to_window_line
, Smove_to_window_line
,
5218 doc
: /* Position point relative to window.
5219 With no argument, position point at center of window.
5220 An argument specifies vertical position within the window;
5221 zero means top of window, negative means relative to bottom of window. */)
5225 struct window
*w
= XWINDOW (selected_window
);
5229 window
= selected_window
;
5230 start
= marker_position (w
->start
);
5231 if (start
< BEGV
|| start
> ZV
)
5233 int height
= window_internal_height (w
);
5234 Fvertical_motion (make_number (- (height
/ 2)), window
);
5235 set_marker_both (w
->start
, w
->buffer
, PT
, PT_BYTE
);
5236 w
->start_at_line_beg
= Fbolp ();
5237 w
->force_start
= Qt
;
5240 Fgoto_char (w
->start
);
5242 lines
= displayed_window_lines (w
);
5244 XSETFASTINT (arg
, lines
/ 2);
5247 arg
= Fprefix_numeric_value (arg
);
5249 XSETINT (arg
, XINT (arg
) + lines
);
5252 /* Skip past a partially visible first line. */
5254 XSETINT (arg
, XINT (arg
) + 1);
5256 return Fvertical_motion (arg
, window
);
5261 /***********************************************************************
5262 Window Configuration
5263 ***********************************************************************/
5265 struct save_window_data
5267 EMACS_INT size_from_Lisp_Vector_struct
;
5268 struct Lisp_Vector
*next_from_Lisp_Vector_struct
;
5269 Lisp_Object frame_cols
, frame_lines
, frame_menu_bar_lines
;
5270 Lisp_Object frame_tool_bar_lines
;
5271 Lisp_Object selected_frame
;
5272 Lisp_Object current_window
;
5273 Lisp_Object current_buffer
;
5274 Lisp_Object minibuf_scroll_window
;
5275 Lisp_Object minibuf_selected_window
;
5276 Lisp_Object root_window
;
5277 Lisp_Object focus_frame
;
5278 /* Record the values of window-min-width and window-min-height
5279 so that window sizes remain consistent with them. */
5280 Lisp_Object min_width
, min_height
;
5281 /* A vector, each of whose elements is a struct saved_window
5283 Lisp_Object saved_windows
;
5286 /* This is saved as a Lisp_Vector */
5289 /* these first two must agree with struct Lisp_Vector in lisp.h */
5290 EMACS_INT size_from_Lisp_Vector_struct
;
5291 struct Lisp_Vector
*next_from_Lisp_Vector_struct
;
5294 Lisp_Object buffer
, start
, pointm
, mark
;
5295 Lisp_Object left_col
, top_line
, total_cols
, total_lines
;
5296 Lisp_Object hscroll
, min_hscroll
;
5297 Lisp_Object parent
, prev
;
5298 Lisp_Object start_at_line_beg
;
5299 Lisp_Object display_table
;
5300 Lisp_Object orig_top_line
, orig_total_lines
;
5301 Lisp_Object left_margin_cols
, right_margin_cols
;
5302 Lisp_Object left_fringe_width
, right_fringe_width
, fringes_outside_margins
;
5303 Lisp_Object scroll_bar_width
, vertical_scroll_bar_type
;
5306 #define SAVED_WINDOW_VECTOR_SIZE 24 /* Arg to Fmake_vector */
5308 #define SAVED_WINDOW_N(swv,n) \
5309 ((struct saved_window *) (XVECTOR ((swv)->contents[(n)])))
5311 DEFUN ("window-configuration-p", Fwindow_configuration_p
, Swindow_configuration_p
, 1, 1, 0,
5312 doc
: /* Return t if OBJECT is a window-configuration object. */)
5316 if (WINDOW_CONFIGURATIONP (object
))
5321 DEFUN ("window-configuration-frame", Fwindow_configuration_frame
, Swindow_configuration_frame
, 1, 1, 0,
5322 doc
: /* Return the frame that CONFIG, a window-configuration object, is about. */)
5326 register struct save_window_data
*data
;
5327 struct Lisp_Vector
*saved_windows
;
5329 if (! WINDOW_CONFIGURATIONP (config
))
5330 wrong_type_argument (Qwindow_configuration_p
, config
);
5332 data
= (struct save_window_data
*) XVECTOR (config
);
5333 saved_windows
= XVECTOR (data
->saved_windows
);
5334 return XWINDOW (SAVED_WINDOW_N (saved_windows
, 0)->window
)->frame
;
5337 DEFUN ("set-window-configuration", Fset_window_configuration
,
5338 Sset_window_configuration
, 1, 1, 0,
5339 doc
: /* Set the configuration of windows and buffers as specified by CONFIGURATION.
5340 CONFIGURATION must be a value previously returned
5341 by `current-window-configuration' (which see).
5342 If CONFIGURATION was made from a frame that is now deleted,
5343 only frame-independent values can be restored. In this case,
5344 the return value is nil. Otherwise the value is t. */)
5346 Lisp_Object configuration
;
5348 register struct save_window_data
*data
;
5349 struct Lisp_Vector
*saved_windows
;
5350 Lisp_Object new_current_buffer
;
5355 while (!WINDOW_CONFIGURATIONP (configuration
))
5356 wrong_type_argument (Qwindow_configuration_p
, configuration
);
5358 data
= (struct save_window_data
*) XVECTOR (configuration
);
5359 saved_windows
= XVECTOR (data
->saved_windows
);
5361 new_current_buffer
= data
->current_buffer
;
5362 if (NILP (XBUFFER (new_current_buffer
)->name
))
5363 new_current_buffer
= Qnil
;
5366 if (XBUFFER (new_current_buffer
) == current_buffer
)
5369 old_point
= BUF_PT (XBUFFER (new_current_buffer
));
5372 frame
= XWINDOW (SAVED_WINDOW_N (saved_windows
, 0)->window
)->frame
;
5375 /* If f is a dead frame, don't bother rebuilding its window tree.
5376 However, there is other stuff we should still try to do below. */
5377 if (FRAME_LIVE_P (f
))
5379 register struct window
*w
;
5380 register struct saved_window
*p
;
5381 struct window
*root_window
;
5382 struct window
**leaf_windows
;
5386 /* If the frame has been resized since this window configuration was
5387 made, we change the frame to the size specified in the
5388 configuration, restore the configuration, and then resize it
5389 back. We keep track of the prevailing height in these variables. */
5390 int previous_frame_lines
= FRAME_LINES (f
);
5391 int previous_frame_cols
= FRAME_COLS (f
);
5392 int previous_frame_menu_bar_lines
= FRAME_MENU_BAR_LINES (f
);
5393 int previous_frame_tool_bar_lines
= FRAME_TOOL_BAR_LINES (f
);
5395 /* The mouse highlighting code could get screwed up
5396 if it runs during this. */
5399 if (XFASTINT (data
->frame_lines
) != previous_frame_lines
5400 || XFASTINT (data
->frame_cols
) != previous_frame_cols
)
5401 change_frame_size (f
, XFASTINT (data
->frame_lines
),
5402 XFASTINT (data
->frame_cols
), 0, 0, 0);
5403 #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
5404 if (XFASTINT (data
->frame_menu_bar_lines
)
5405 != previous_frame_menu_bar_lines
)
5406 x_set_menu_bar_lines (f
, data
->frame_menu_bar_lines
, make_number (0));
5407 #ifdef HAVE_WINDOW_SYSTEM
5408 if (XFASTINT (data
->frame_tool_bar_lines
)
5409 != previous_frame_tool_bar_lines
)
5410 x_set_tool_bar_lines (f
, data
->frame_tool_bar_lines
, make_number (0));
5414 /* "Swap out" point from the selected window
5415 into its buffer. We do this now, before
5416 restoring the window contents, and prevent it from
5417 being done later on when we select a new window. */
5418 if (! NILP (XWINDOW (selected_window
)->buffer
))
5420 w
= XWINDOW (selected_window
);
5421 set_marker_both (w
->pointm
,
5423 BUF_PT (XBUFFER (w
->buffer
)),
5424 BUF_PT_BYTE (XBUFFER (w
->buffer
)));
5427 windows_or_buffers_changed
++;
5428 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
5430 /* Problem: Freeing all matrices and later allocating them again
5431 is a serious redisplay flickering problem. What we would
5432 really like to do is to free only those matrices not reused
5434 root_window
= XWINDOW (FRAME_ROOT_WINDOW (f
));
5436 = (struct window
**) alloca (count_windows (root_window
)
5437 * sizeof (struct window
*));
5438 n_leaf_windows
= get_leaf_windows (root_window
, leaf_windows
, 0);
5440 /* Temporarily avoid any problems with windows that are smaller
5441 than they are supposed to be. */
5442 window_min_height
= 1;
5443 window_min_width
= 1;
5446 Mark all windows now on frame as "deleted".
5447 Restoring the new configuration "undeletes" any that are in it.
5449 Save their current buffers in their height fields, since we may
5450 need it later, if a buffer saved in the configuration is now
5452 delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f
)));
5454 for (k
= 0; k
< saved_windows
->size
; k
++)
5456 p
= SAVED_WINDOW_N (saved_windows
, k
);
5457 w
= XWINDOW (p
->window
);
5460 if (!NILP (p
->parent
))
5461 w
->parent
= SAVED_WINDOW_N (saved_windows
,
5462 XFASTINT (p
->parent
))->window
;
5466 if (!NILP (p
->prev
))
5468 w
->prev
= SAVED_WINDOW_N (saved_windows
,
5469 XFASTINT (p
->prev
))->window
;
5470 XWINDOW (w
->prev
)->next
= p
->window
;
5475 if (!NILP (w
->parent
))
5477 if (EQ (p
->total_cols
, XWINDOW (w
->parent
)->total_cols
))
5479 XWINDOW (w
->parent
)->vchild
= p
->window
;
5480 XWINDOW (w
->parent
)->hchild
= Qnil
;
5484 XWINDOW (w
->parent
)->hchild
= p
->window
;
5485 XWINDOW (w
->parent
)->vchild
= Qnil
;
5490 /* If we squirreled away the buffer in the window's height,
5492 if (BUFFERP (w
->total_lines
))
5493 w
->buffer
= w
->total_lines
;
5494 w
->left_col
= p
->left_col
;
5495 w
->top_line
= p
->top_line
;
5496 w
->total_cols
= p
->total_cols
;
5497 w
->total_lines
= p
->total_lines
;
5498 w
->hscroll
= p
->hscroll
;
5499 w
->min_hscroll
= p
->min_hscroll
;
5500 w
->display_table
= p
->display_table
;
5501 w
->orig_top_line
= p
->orig_top_line
;
5502 w
->orig_total_lines
= p
->orig_total_lines
;
5503 w
->left_margin_cols
= p
->left_margin_cols
;
5504 w
->right_margin_cols
= p
->right_margin_cols
;
5505 w
->left_fringe_width
= p
->left_fringe_width
;
5506 w
->right_fringe_width
= p
->right_fringe_width
;
5507 w
->fringes_outside_margins
= p
->fringes_outside_margins
;
5508 w
->scroll_bar_width
= p
->scroll_bar_width
;
5509 w
->vertical_scroll_bar_type
= p
->vertical_scroll_bar_type
;
5510 XSETFASTINT (w
->last_modified
, 0);
5511 XSETFASTINT (w
->last_overlay_modified
, 0);
5513 /* Reinstall the saved buffer and pointers into it. */
5514 if (NILP (p
->buffer
))
5515 w
->buffer
= p
->buffer
;
5518 if (!NILP (XBUFFER (p
->buffer
)->name
))
5519 /* If saved buffer is alive, install it. */
5521 w
->buffer
= p
->buffer
;
5522 w
->start_at_line_beg
= p
->start_at_line_beg
;
5523 set_marker_restricted (w
->start
, p
->start
, w
->buffer
);
5524 set_marker_restricted (w
->pointm
, p
->pointm
, w
->buffer
);
5525 Fset_marker (XBUFFER (w
->buffer
)->mark
,
5526 p
->mark
, w
->buffer
);
5528 /* As documented in Fcurrent_window_configuration, don't
5529 restore the location of point in the buffer which was
5530 current when the window configuration was recorded. */
5531 if (!EQ (p
->buffer
, new_current_buffer
)
5532 && XBUFFER (p
->buffer
) == current_buffer
)
5533 Fgoto_char (w
->pointm
);
5535 else if (NILP (w
->buffer
) || NILP (XBUFFER (w
->buffer
)->name
))
5536 /* Else unless window has a live buffer, get one. */
5538 w
->buffer
= Fcdr (Fcar (Vbuffer_alist
));
5539 /* This will set the markers to beginning of visible
5541 set_marker_restricted (w
->start
, make_number (0), w
->buffer
);
5542 set_marker_restricted (w
->pointm
, make_number (0),w
->buffer
);
5543 w
->start_at_line_beg
= Qt
;
5546 /* Keeping window's old buffer; make sure the markers
5549 /* Set window markers at start of visible range. */
5550 if (XMARKER (w
->start
)->buffer
== 0)
5551 set_marker_restricted (w
->start
, make_number (0),
5553 if (XMARKER (w
->pointm
)->buffer
== 0)
5554 set_marker_restricted_both (w
->pointm
, w
->buffer
,
5555 BUF_PT (XBUFFER (w
->buffer
)),
5556 BUF_PT_BYTE (XBUFFER (w
->buffer
)));
5557 w
->start_at_line_beg
= Qt
;
5562 FRAME_ROOT_WINDOW (f
) = data
->root_window
;
5563 /* Prevent "swapping out point" in the old selected window
5564 using the buffer that has been restored into it.
5565 Use the point value from the beginning of this function
5566 since unshow_buffer (called from delete_all_subwindows)
5567 could have altered it. */
5568 selected_window
= Qnil
;
5569 if (EQ (XWINDOW (data
->current_window
)->buffer
, new_current_buffer
))
5570 set_marker_restricted (XWINDOW (data
->current_window
)->pointm
,
5571 make_number (old_point
),
5572 XWINDOW (data
->current_window
)->buffer
);
5574 Fselect_window (data
->current_window
, Qnil
);
5575 XBUFFER (XWINDOW (selected_window
)->buffer
)->last_selected_window
5578 if (NILP (data
->focus_frame
)
5579 || (FRAMEP (data
->focus_frame
)
5580 && FRAME_LIVE_P (XFRAME (data
->focus_frame
))))
5581 Fredirect_frame_focus (frame
, data
->focus_frame
);
5583 #if 0 /* I don't understand why this is needed, and it causes problems
5584 when the frame's old selected window has been deleted. */
5585 if (f
!= selected_frame
&& FRAME_WINDOW_P (f
))
5586 do_switch_frame (WINDOW_FRAME (XWINDOW (data
->root_window
)),
5590 /* Set the screen height to the value it had before this function. */
5591 if (previous_frame_lines
!= FRAME_LINES (f
)
5592 || previous_frame_cols
!= FRAME_COLS (f
))
5593 change_frame_size (f
, previous_frame_lines
, previous_frame_cols
,
5595 #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
5596 if (previous_frame_menu_bar_lines
!= FRAME_MENU_BAR_LINES (f
))
5597 x_set_menu_bar_lines (f
, make_number (previous_frame_menu_bar_lines
),
5599 #ifdef HAVE_WINDOW_SYSTEM
5600 if (previous_frame_tool_bar_lines
!= FRAME_TOOL_BAR_LINES (f
))
5601 x_set_tool_bar_lines (f
, make_number (previous_frame_tool_bar_lines
),
5606 /* Now, free glyph matrices in windows that were not reused. */
5607 for (i
= n
= 0; i
< n_leaf_windows
; ++i
)
5609 if (NILP (leaf_windows
[i
]->buffer
))
5611 /* Assert it's not reused as a combination. */
5612 xassert (NILP (leaf_windows
[i
]->hchild
)
5613 && NILP (leaf_windows
[i
]->vchild
));
5614 free_window_matrices (leaf_windows
[i
]);
5616 else if (EQ (leaf_windows
[i
]->buffer
, new_current_buffer
))
5624 /* Fselect_window will have made f the selected frame, so we
5625 reselect the proper frame here. Fhandle_switch_frame will change the
5626 selected window too, but that doesn't make the call to
5627 Fselect_window above totally superfluous; it still sets f's
5629 if (FRAME_LIVE_P (XFRAME (data
->selected_frame
)))
5630 do_switch_frame (data
->selected_frame
, 0, 0);
5632 if (! NILP (Vwindow_configuration_change_hook
)
5633 && ! NILP (Vrun_hooks
))
5634 call1 (Vrun_hooks
, Qwindow_configuration_change_hook
);
5637 if (!NILP (new_current_buffer
))
5638 Fset_buffer (new_current_buffer
);
5640 /* Restore the minimum heights recorded in the configuration. */
5641 window_min_height
= XINT (data
->min_height
);
5642 window_min_width
= XINT (data
->min_width
);
5644 Vminibuf_scroll_window
= data
->minibuf_scroll_window
;
5645 minibuf_selected_window
= data
->minibuf_selected_window
;
5647 return (FRAME_LIVE_P (f
) ? Qt
: Qnil
);
5650 /* Mark all windows now on frame as deleted
5651 by setting their buffers to nil. */
5654 delete_all_subwindows (w
)
5655 register struct window
*w
;
5657 if (!NILP (w
->next
))
5658 delete_all_subwindows (XWINDOW (w
->next
));
5659 if (!NILP (w
->vchild
))
5660 delete_all_subwindows (XWINDOW (w
->vchild
));
5661 if (!NILP (w
->hchild
))
5662 delete_all_subwindows (XWINDOW (w
->hchild
));
5664 w
->total_lines
= w
->buffer
; /* See Fset_window_configuration for excuse. */
5666 if (!NILP (w
->buffer
))
5669 /* We set all three of these fields to nil, to make sure that we can
5670 distinguish this dead window from any live window. Live leaf
5671 windows will have buffer set, and combination windows will have
5672 vchild or hchild set. */
5677 Vwindow_list
= Qnil
;
5681 count_windows (window
)
5682 register struct window
*window
;
5684 register int count
= 1;
5685 if (!NILP (window
->next
))
5686 count
+= count_windows (XWINDOW (window
->next
));
5687 if (!NILP (window
->vchild
))
5688 count
+= count_windows (XWINDOW (window
->vchild
));
5689 if (!NILP (window
->hchild
))
5690 count
+= count_windows (XWINDOW (window
->hchild
));
5695 /* Fill vector FLAT with leaf windows under W, starting at index I.
5696 Value is last index + 1. */
5699 get_leaf_windows (w
, flat
, i
)
5701 struct window
**flat
;
5706 if (!NILP (w
->hchild
))
5707 i
= get_leaf_windows (XWINDOW (w
->hchild
), flat
, i
);
5708 else if (!NILP (w
->vchild
))
5709 i
= get_leaf_windows (XWINDOW (w
->vchild
), flat
, i
);
5713 w
= NILP (w
->next
) ? 0 : XWINDOW (w
->next
);
5720 /* Return a pointer to the glyph W's physical cursor is on. Value is
5721 null if W's current matrix is invalid, so that no meaningfull glyph
5725 get_phys_cursor_glyph (w
)
5728 struct glyph_row
*row
;
5729 struct glyph
*glyph
;
5731 if (w
->phys_cursor
.vpos
>= 0
5732 && w
->phys_cursor
.vpos
< w
->current_matrix
->nrows
5733 && (row
= MATRIX_ROW (w
->current_matrix
, w
->phys_cursor
.vpos
),
5735 && row
->used
[TEXT_AREA
] > w
->phys_cursor
.hpos
)
5736 glyph
= row
->glyphs
[TEXT_AREA
] + w
->phys_cursor
.hpos
;
5745 save_window_save (window
, vector
, i
)
5747 struct Lisp_Vector
*vector
;
5750 register struct saved_window
*p
;
5751 register struct window
*w
;
5752 register Lisp_Object tem
;
5754 for (;!NILP (window
); window
= w
->next
)
5756 p
= SAVED_WINDOW_N (vector
, i
);
5757 w
= XWINDOW (window
);
5759 XSETFASTINT (w
->temslot
, i
++);
5761 p
->buffer
= w
->buffer
;
5762 p
->left_col
= w
->left_col
;
5763 p
->top_line
= w
->top_line
;
5764 p
->total_cols
= w
->total_cols
;
5765 p
->total_lines
= w
->total_lines
;
5766 p
->hscroll
= w
->hscroll
;
5767 p
->min_hscroll
= w
->min_hscroll
;
5768 p
->display_table
= w
->display_table
;
5769 p
->orig_top_line
= w
->orig_top_line
;
5770 p
->orig_total_lines
= w
->orig_total_lines
;
5771 p
->left_margin_cols
= w
->left_margin_cols
;
5772 p
->right_margin_cols
= w
->right_margin_cols
;
5773 p
->left_fringe_width
= w
->left_fringe_width
;
5774 p
->right_fringe_width
= w
->right_fringe_width
;
5775 p
->fringes_outside_margins
= w
->fringes_outside_margins
;
5776 p
->scroll_bar_width
= w
->scroll_bar_width
;
5777 p
->vertical_scroll_bar_type
= w
->vertical_scroll_bar_type
;
5778 if (!NILP (w
->buffer
))
5780 /* Save w's value of point in the window configuration.
5781 If w is the selected window, then get the value of point
5782 from the buffer; pointm is garbage in the selected window. */
5783 if (EQ (window
, selected_window
))
5785 p
->pointm
= Fmake_marker ();
5786 set_marker_both (p
->pointm
, w
->buffer
,
5787 BUF_PT (XBUFFER (w
->buffer
)),
5788 BUF_PT_BYTE (XBUFFER (w
->buffer
)));
5791 p
->pointm
= Fcopy_marker (w
->pointm
, Qnil
);
5793 p
->start
= Fcopy_marker (w
->start
, Qnil
);
5794 p
->start_at_line_beg
= w
->start_at_line_beg
;
5796 tem
= XBUFFER (w
->buffer
)->mark
;
5797 p
->mark
= Fcopy_marker (tem
, Qnil
);
5804 p
->start_at_line_beg
= Qnil
;
5807 if (NILP (w
->parent
))
5810 p
->parent
= XWINDOW (w
->parent
)->temslot
;
5815 p
->prev
= XWINDOW (w
->prev
)->temslot
;
5817 if (!NILP (w
->vchild
))
5818 i
= save_window_save (w
->vchild
, vector
, i
);
5819 if (!NILP (w
->hchild
))
5820 i
= save_window_save (w
->hchild
, vector
, i
);
5826 DEFUN ("current-window-configuration", Fcurrent_window_configuration
,
5827 Scurrent_window_configuration
, 0, 1, 0,
5828 doc
: /* Return an object representing the current window configuration of FRAME.
5829 If FRAME is nil or omitted, use the selected frame.
5830 This describes the number of windows, their sizes and current buffers,
5831 and for each displayed buffer, where display starts, and the positions of
5832 point and mark. An exception is made for point in the current buffer:
5833 its value is -not- saved.
5834 This also records the currently selected frame, and FRAME's focus
5835 redirection (see `redirect-frame-focus'). */)
5839 register Lisp_Object tem
;
5840 register int n_windows
;
5841 register struct save_window_data
*data
;
5842 register struct Lisp_Vector
*vec
;
5847 frame
= selected_frame
;
5848 CHECK_LIVE_FRAME (frame
);
5851 n_windows
= count_windows (XWINDOW (FRAME_ROOT_WINDOW (f
)));
5852 vec
= allocate_other_vector (VECSIZE (struct save_window_data
));
5853 data
= (struct save_window_data
*)vec
;
5855 XSETFASTINT (data
->frame_cols
, FRAME_COLS (f
));
5856 XSETFASTINT (data
->frame_lines
, FRAME_LINES (f
));
5857 XSETFASTINT (data
->frame_menu_bar_lines
, FRAME_MENU_BAR_LINES (f
));
5858 XSETFASTINT (data
->frame_tool_bar_lines
, FRAME_TOOL_BAR_LINES (f
));
5859 data
->selected_frame
= selected_frame
;
5860 data
->current_window
= FRAME_SELECTED_WINDOW (f
);
5861 XSETBUFFER (data
->current_buffer
, current_buffer
);
5862 data
->minibuf_scroll_window
= minibuf_level
> 0 ? Vminibuf_scroll_window
: Qnil
;
5863 data
->minibuf_selected_window
= minibuf_level
> 0 ? minibuf_selected_window
: Qnil
;
5864 data
->root_window
= FRAME_ROOT_WINDOW (f
);
5865 data
->focus_frame
= FRAME_FOCUS_FRAME (f
);
5866 XSETINT (data
->min_height
, window_min_height
);
5867 XSETINT (data
->min_width
, window_min_width
);
5868 tem
= Fmake_vector (make_number (n_windows
), Qnil
);
5869 data
->saved_windows
= tem
;
5870 for (i
= 0; i
< n_windows
; i
++)
5871 XVECTOR (tem
)->contents
[i
]
5872 = Fmake_vector (make_number (SAVED_WINDOW_VECTOR_SIZE
), Qnil
);
5873 save_window_save (FRAME_ROOT_WINDOW (f
), XVECTOR (tem
), 0);
5874 XSETWINDOW_CONFIGURATION (tem
, data
);
5878 DEFUN ("save-window-excursion", Fsave_window_excursion
, Ssave_window_excursion
,
5880 doc
: /* Execute body, preserving window sizes and contents.
5881 Restore which buffer appears in which window, where display starts,
5882 and the value of point and mark for each window.
5883 Also restore the choice of selected window.
5884 Also restore which buffer is current.
5885 Does not restore the value of point in current buffer.
5886 usage: (save-window-excursion BODY ...) */)
5890 register Lisp_Object val
;
5891 register int count
= SPECPDL_INDEX ();
5893 record_unwind_protect (Fset_window_configuration
,
5894 Fcurrent_window_configuration (Qnil
));
5895 val
= Fprogn (args
);
5896 return unbind_to (count
, val
);
5900 /***********************************************************************
5902 ***********************************************************************/
5904 DEFUN ("set-window-margins", Fset_window_margins
, Sset_window_margins
,
5906 doc
: /* Set width of marginal areas of window WINDOW.
5907 If WINDOW is nil, set margins of the currently selected window.
5908 Second arg LEFT-WIDTH specifies the number of character cells to
5909 reserve for the left marginal area. Optional third arg RIGHT-WIDTH
5910 does the same for the right marginal area. A nil width parameter
5911 means no margin. */)
5912 (window
, left
, right
)
5913 Lisp_Object window
, left
, right
;
5915 struct window
*w
= decode_window (window
);
5917 /* Translate negative or zero widths to nil.
5918 Margins that are too wide have to be checked elsewhere. */
5922 CHECK_NUMBER (left
);
5923 if (XINT (left
) <= 0)
5929 CHECK_NUMBER (right
);
5930 if (XINT (right
) <= 0)
5934 if (!EQ (w
->left_margin_cols
, left
)
5935 || !EQ (w
->right_margin_cols
, right
))
5937 w
->left_margin_cols
= left
;
5938 w
->right_margin_cols
= right
;
5940 adjust_window_margins (w
);
5942 ++windows_or_buffers_changed
;
5943 adjust_glyphs (XFRAME (WINDOW_FRAME (w
)));
5950 DEFUN ("window-margins", Fwindow_margins
, Swindow_margins
,
5952 doc
: /* Get width of marginal areas of window WINDOW.
5953 If WINDOW is omitted or nil, use the currently selected window.
5954 Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH).
5955 If a marginal area does not exist, its width will be returned
5960 struct window
*w
= decode_window (window
);
5961 return Fcons (w
->left_margin_cols
, w
->right_margin_cols
);
5966 /***********************************************************************
5968 ***********************************************************************/
5970 DEFUN ("set-window-fringes", Fset_window_fringes
, Sset_window_fringes
,
5972 doc
: /* Set the fringe widths of window WINDOW.
5973 If WINDOW is nil, set the fringe widths of the currently selected
5975 Second arg LEFT-WIDTH specifies the number of pixels to reserve for
5976 the left fringe. Optional third arg RIGHT-WIDTH specifies the right
5977 fringe width. If a fringe width arg is nil, that means to use the
5978 frame's default fringe width. Default fringe widths can be set with
5979 the command `set-fringe-style'.
5980 If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes
5981 outside of the display margins. By default, fringes are drawn between
5982 display marginal areas and the text area. */)
5983 (window
, left
, right
, outside_margins
)
5984 Lisp_Object window
, left
, right
, outside_margins
;
5986 struct window
*w
= decode_window (window
);
5989 CHECK_NUMBER (left
);
5991 CHECK_NUMBER (right
);
5993 if (!EQ (w
->left_fringe_width
, left
)
5994 || !EQ (w
->right_fringe_width
, right
)
5995 || !EQ (w
->fringes_outside_margins
, outside_margins
))
5997 w
->left_fringe_width
= left
;
5998 w
->right_fringe_width
= right
;
5999 w
->fringes_outside_margins
= outside_margins
;
6001 adjust_window_margins (w
);
6003 clear_glyph_matrix (w
->current_matrix
);
6004 w
->window_end_valid
= Qnil
;
6006 ++windows_or_buffers_changed
;
6007 adjust_glyphs (XFRAME (WINDOW_FRAME (w
)));
6014 DEFUN ("window-fringes", Fwindow_fringes
, Swindow_fringes
,
6016 doc
: /* Get width of fringes of window WINDOW.
6017 If WINDOW is omitted or nil, use the currently selected window.
6018 Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */)
6022 struct window
*w
= decode_window (window
);
6023 return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w
)),
6024 Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w
)),
6025 Fcons ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w
) ?
6026 Qt
: Qnil
), Qnil
)));
6031 /***********************************************************************
6033 ***********************************************************************/
6035 DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars
, Sset_window_scroll_bars
,
6037 doc
: /* Set width and type of scroll bars of window WINDOW.
6038 If window is nil, set scroll bars of the currently selected window.
6039 Second parameter WIDTH specifies the pixel width for the scroll bar;
6040 this is automatically adjusted to a multiple of the frame column width.
6041 Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
6042 bar: left, right, or nil.
6043 If WIDTH is nil, use the frame's scroll-bar width.
6044 If TYPE is t, use the frame's scroll-bar type. */)
6045 (window
, width
, vertical_type
, horizontal_type
)
6046 Lisp_Object window
, width
, vertical_type
, horizontal_type
;
6048 struct window
*w
= decode_window (window
);
6051 CHECK_NUMBER (width
);
6053 if (XINT (width
) == 0)
6054 vertical_type
= Qnil
;
6056 if (!(EQ (vertical_type
, Qnil
)
6057 || EQ (vertical_type
, Qleft
)
6058 || EQ (vertical_type
, Qright
)
6059 || EQ (vertical_type
, Qt
)))
6060 error ("Invalid type of vertical scroll bar");
6062 if (!EQ (w
->scroll_bar_width
, width
)
6063 || !EQ (w
->vertical_scroll_bar_type
, vertical_type
))
6065 w
->scroll_bar_width
= width
;
6066 w
->vertical_scroll_bar_type
= vertical_type
;
6068 adjust_window_margins (w
);
6070 clear_glyph_matrix (w
->current_matrix
);
6071 w
->window_end_valid
= Qnil
;
6073 ++windows_or_buffers_changed
;
6074 adjust_glyphs (XFRAME (WINDOW_FRAME (w
)));
6081 DEFUN ("window-scroll-bars", Fwindow_scroll_bars
, Swindow_scroll_bars
,
6083 doc
: /* Get width and type of scroll bars of window WINDOW.
6084 If WINDOW is omitted or nil, use the currently selected window.
6085 Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE).
6086 If WIDTH is nil or TYPE is t, the window is using the frame's corresponding
6091 struct window
*w
= decode_window (window
);
6092 return Fcons (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w
)
6093 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (w
)
6094 : WINDOW_SCROLL_BAR_AREA_WIDTH (w
))),
6095 Fcons (make_number (WINDOW_SCROLL_BAR_COLS (w
)),
6096 Fcons (w
->vertical_scroll_bar_type
,
6097 Fcons (Qnil
, Qnil
))));
6102 /***********************************************************************
6104 ***********************************************************************/
6106 DEFUN ("window-vscroll", Fwindow_vscroll
, Swindow_vscroll
, 0, 2, 0,
6107 doc
: /* Return the amount by which WINDOW is scrolled vertically.
6108 Use the selected window if WINDOW is nil or omitted.
6109 Normally, value is a multiple of the canonical character height of WINDOW;
6110 optional second arg PIXELS_P means value is measured in pixels. */)
6112 Lisp_Object window
, pixels_p
;
6119 window
= selected_window
;
6121 CHECK_WINDOW (window
);
6122 w
= XWINDOW (window
);
6123 f
= XFRAME (w
->frame
);
6125 if (FRAME_WINDOW_P (f
))
6126 result
= (NILP (pixels_p
)
6127 ? FRAME_CANON_Y_FROM_PIXEL_Y (f
, -w
->vscroll
)
6128 : make_number (-w
->vscroll
));
6130 result
= make_number (0);
6135 DEFUN ("set-window-vscroll", Fset_window_vscroll
, Sset_window_vscroll
,
6137 doc
: /* Set amount by which WINDOW should be scrolled vertically to VSCROLL.
6138 WINDOW nil means use the selected window. Normally, VSCROLL is a
6139 non-negative multiple of the canonical character height of WINDOW;
6140 optional third arg PIXELS_P non-nil means that VSCROLL is in pixels. */)
6141 (window
, vscroll
, pixels_p
)
6142 Lisp_Object window
, vscroll
, pixels_p
;
6148 window
= selected_window
;
6150 CHECK_WINDOW (window
);
6151 CHECK_NUMBER_OR_FLOAT (vscroll
);
6153 w
= XWINDOW (window
);
6154 f
= XFRAME (w
->frame
);
6156 if (FRAME_WINDOW_P (f
))
6158 int old_dy
= w
->vscroll
;
6160 w
->vscroll
= - (NILP (pixels_p
)
6161 ? FRAME_LINE_HEIGHT (f
) * XFLOATINT (vscroll
)
6162 : XFLOATINT (vscroll
));
6163 w
->vscroll
= min (w
->vscroll
, 0);
6165 /* Adjust glyph matrix of the frame if the virtual display
6166 area becomes larger than before. */
6167 if (w
->vscroll
< 0 && w
->vscroll
< old_dy
)
6170 /* Prevent redisplay shortcuts. */
6171 XBUFFER (w
->buffer
)->prevent_redisplay_optimizations_p
= 1;
6174 return Fwindow_vscroll (window
, pixels_p
);
6178 /* Call FN for all leaf windows on frame F. FN is called with the
6179 first argument being a pointer to the leaf window, and with
6180 additional argument USER_DATA. Stops when FN returns 0. */
6183 foreach_window (f
, fn
, user_data
)
6185 int (* fn
) P_ ((struct window
*, void *));
6188 foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f
)), fn
, user_data
);
6192 /* Helper function for foreach_window. Call FN for all leaf windows
6193 reachable from W. FN is called with the first argument being a
6194 pointer to the leaf window, and with additional argument USER_DATA.
6195 Stop when FN returns 0. Value is 0 if stopped by FN. */
6198 foreach_window_1 (w
, fn
, user_data
)
6200 int (* fn
) P_ ((struct window
*, void *));
6205 for (cont
= 1; w
&& cont
;)
6207 if (!NILP (w
->hchild
))
6208 cont
= foreach_window_1 (XWINDOW (w
->hchild
), fn
, user_data
);
6209 else if (!NILP (w
->vchild
))
6210 cont
= foreach_window_1 (XWINDOW (w
->vchild
), fn
, user_data
);
6212 cont
= fn (w
, user_data
);
6214 w
= NILP (w
->next
) ? 0 : XWINDOW (w
->next
);
6221 /* Freeze or unfreeze the window start of W unless it is a
6222 mini-window or the selected window. FREEZE_P non-null means freeze
6223 the window start. */
6226 freeze_window_start (w
, freeze_p
)
6230 if (w
== XWINDOW (selected_window
)
6231 || MINI_WINDOW_P (w
)
6232 || (MINI_WINDOW_P (XWINDOW (selected_window
))
6233 && ! NILP (Vminibuf_scroll_window
)
6234 && w
== XWINDOW (Vminibuf_scroll_window
)))
6237 w
->frozen_window_start_p
= freeze_p
!= NULL
;
6242 /* Freeze or unfreeze the window starts of all leaf windows on frame
6243 F, except the selected window and a mini-window. FREEZE_P non-zero
6244 means freeze the window start. */
6247 freeze_window_starts (f
, freeze_p
)
6251 foreach_window (f
, freeze_window_start
, (void *) (freeze_p
? f
: 0));
6255 /***********************************************************************
6257 ***********************************************************************/
6259 /* Return 1 if window configurations C1 and C2
6260 describe the same state of affairs. This is used by Fequal. */
6263 compare_window_configurations (c1
, c2
, ignore_positions
)
6265 int ignore_positions
;
6267 register struct save_window_data
*d1
, *d2
;
6268 struct Lisp_Vector
*sw1
, *sw2
;
6271 if (!WINDOW_CONFIGURATIONP (c1
))
6272 wrong_type_argument (Qwindow_configuration_p
, c1
);
6273 if (!WINDOW_CONFIGURATIONP (c2
))
6274 wrong_type_argument (Qwindow_configuration_p
, c2
);
6276 d1
= (struct save_window_data
*) XVECTOR (c1
);
6277 d2
= (struct save_window_data
*) XVECTOR (c2
);
6278 sw1
= XVECTOR (d1
->saved_windows
);
6279 sw2
= XVECTOR (d2
->saved_windows
);
6281 if (! EQ (d1
->frame_cols
, d2
->frame_cols
))
6283 if (! EQ (d1
->frame_lines
, d2
->frame_lines
))
6285 if (! EQ (d1
->frame_menu_bar_lines
, d2
->frame_menu_bar_lines
))
6287 if (! EQ (d1
->selected_frame
, d2
->selected_frame
))
6289 /* Don't compare the current_window field directly.
6290 Instead see w1_is_current and w2_is_current, below. */
6291 if (! EQ (d1
->current_buffer
, d2
->current_buffer
))
6293 if (! ignore_positions
)
6295 if (! EQ (d1
->minibuf_scroll_window
, d2
->minibuf_scroll_window
))
6297 if (! EQ (d1
->minibuf_selected_window
, d2
->minibuf_selected_window
))
6300 /* Don't compare the root_window field.
6301 We don't require the two configurations
6302 to use the same window object,
6303 and the two root windows must be equivalent
6304 if everything else compares equal. */
6305 if (! EQ (d1
->focus_frame
, d2
->focus_frame
))
6307 if (! EQ (d1
->min_width
, d2
->min_width
))
6309 if (! EQ (d1
->min_height
, d2
->min_height
))
6312 /* Verify that the two confis have the same number of windows. */
6313 if (sw1
->size
!= sw2
->size
)
6316 for (i
= 0; i
< sw1
->size
; i
++)
6318 struct saved_window
*p1
, *p2
;
6319 int w1_is_current
, w2_is_current
;
6321 p1
= SAVED_WINDOW_N (sw1
, i
);
6322 p2
= SAVED_WINDOW_N (sw2
, i
);
6324 /* Verify that the current windows in the two
6325 configurations correspond to each other. */
6326 w1_is_current
= EQ (d1
->current_window
, p1
->window
);
6327 w2_is_current
= EQ (d2
->current_window
, p2
->window
);
6329 if (w1_is_current
!= w2_is_current
)
6332 /* Verify that the corresponding windows do match. */
6333 if (! EQ (p1
->buffer
, p2
->buffer
))
6335 if (! EQ (p1
->left_col
, p2
->left_col
))
6337 if (! EQ (p1
->top_line
, p2
->top_line
))
6339 if (! EQ (p1
->total_cols
, p2
->total_cols
))
6341 if (! EQ (p1
->total_lines
, p2
->total_lines
))
6343 if (! EQ (p1
->display_table
, p2
->display_table
))
6345 if (! EQ (p1
->parent
, p2
->parent
))
6347 if (! EQ (p1
->prev
, p2
->prev
))
6349 if (! ignore_positions
)
6351 if (! EQ (p1
->hscroll
, p2
->hscroll
))
6353 if (!EQ (p1
->min_hscroll
, p2
->min_hscroll
))
6355 if (! EQ (p1
->start_at_line_beg
, p2
->start_at_line_beg
))
6357 if (NILP (Fequal (p1
->start
, p2
->start
)))
6359 if (NILP (Fequal (p1
->pointm
, p2
->pointm
)))
6361 if (NILP (Fequal (p1
->mark
, p2
->mark
)))
6364 if (! EQ (p1
->left_margin_cols
, p2
->left_margin_cols
))
6366 if (! EQ (p1
->right_margin_cols
, p2
->right_margin_cols
))
6368 if (! EQ (p1
->left_fringe_width
, p2
->left_fringe_width
))
6370 if (! EQ (p1
->right_fringe_width
, p2
->right_fringe_width
))
6372 if (! EQ (p1
->fringes_outside_margins
, p2
->fringes_outside_margins
))
6374 if (! EQ (p1
->scroll_bar_width
, p2
->scroll_bar_width
))
6376 if (! EQ (p1
->vertical_scroll_bar_type
, p2
->vertical_scroll_bar_type
))
6383 DEFUN ("compare-window-configurations", Fcompare_window_configurations
,
6384 Scompare_window_configurations
, 2, 2, 0,
6385 doc
: /* Compare two window configurations as regards the structure of windows.
6386 This function ignores details such as the values of point and mark
6387 and scrolling positions. */)
6391 if (compare_window_configurations (x
, y
, 1))
6399 struct frame
*f
= make_terminal_frame ();
6400 XSETFRAME (selected_frame
, f
);
6401 Vterminal_frame
= selected_frame
;
6402 minibuf_window
= f
->minibuffer_window
;
6403 selected_window
= f
->selected_window
;
6404 last_nonminibuf_frame
= f
;
6406 window_initialized
= 1;
6412 Vwindow_list
= Qnil
;
6418 Qwindow_size_fixed
= intern ("window-size-fixed");
6419 staticpro (&Qwindow_size_fixed
);
6421 staticpro (&Qwindow_configuration_change_hook
);
6422 Qwindow_configuration_change_hook
6423 = intern ("window-configuration-change-hook");
6425 Qwindowp
= intern ("windowp");
6426 staticpro (&Qwindowp
);
6428 Qwindow_configuration_p
= intern ("window-configuration-p");
6429 staticpro (&Qwindow_configuration_p
);
6431 Qwindow_live_p
= intern ("window-live-p");
6432 staticpro (&Qwindow_live_p
);
6434 Qtemp_buffer_show_hook
= intern ("temp-buffer-show-hook");
6435 staticpro (&Qtemp_buffer_show_hook
);
6437 staticpro (&Vwindow_list
);
6439 minibuf_selected_window
= Qnil
;
6440 staticpro (&minibuf_selected_window
);
6442 DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function
,
6443 doc
: /* Non-nil means call as function to display a help buffer.
6444 The function is called with one argument, the buffer to be displayed.
6445 Used by `with-output-to-temp-buffer'.
6446 If this function is used, then it must do the entire job of showing
6447 the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */);
6448 Vtemp_buffer_show_function
= Qnil
;
6450 DEFVAR_LISP ("display-buffer-function", &Vdisplay_buffer_function
,
6451 doc
: /* If non-nil, function to call to handle `display-buffer'.
6452 It will receive two args, the buffer and a flag which if non-nil means
6453 that the currently selected window is not acceptable.
6454 Commands such as `switch-to-buffer-other-window' and `find-file-other-window'
6455 work using this function. */);
6456 Vdisplay_buffer_function
= Qnil
;
6458 DEFVAR_LISP ("even-window-heights", &Veven_window_heights
,
6459 doc
: /* *If non-nil, `display-buffer' should even the window heights.
6460 If nil, `display-buffer' will leave the window configuration alone. */);
6461 Veven_window_heights
= Qt
;
6463 DEFVAR_LISP ("minibuffer-scroll-window", &Vminibuf_scroll_window
,
6464 doc
: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */);
6465 Vminibuf_scroll_window
= Qnil
;
6467 DEFVAR_BOOL ("mode-line-in-non-selected-windows", &mode_line_in_non_selected_windows
,
6468 doc
: /* Non-nil means to use `mode-line-inactive' face in non-selected windows.
6469 If the minibuffer is active, the `minibuffer-scroll-window' mode line
6470 is displayed in the `mode-line' face. */);
6471 mode_line_in_non_selected_windows
= 1;
6473 DEFVAR_LISP ("other-window-scroll-buffer", &Vother_window_scroll_buffer
,
6474 doc
: /* If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window. */);
6475 Vother_window_scroll_buffer
= Qnil
;
6477 DEFVAR_BOOL ("pop-up-frames", &pop_up_frames
,
6478 doc
: /* *Non-nil means `display-buffer' should make a separate frame. */);
6481 DEFVAR_BOOL ("display-buffer-reuse-frames", &display_buffer_reuse_frames
,
6482 doc
: /* *Non-nil means `display-buffer' should reuse frames.
6483 If the buffer in question is already displayed in a frame, raise that frame. */);
6484 display_buffer_reuse_frames
= 0;
6486 DEFVAR_LISP ("pop-up-frame-function", &Vpop_up_frame_function
,
6487 doc
: /* Function to call to handle automatic new frame creation.
6488 It is called with no arguments and should return a newly created frame.
6490 A typical value might be `(lambda () (new-frame pop-up-frame-alist))'
6491 where `pop-up-frame-alist' would hold the default frame parameters. */);
6492 Vpop_up_frame_function
= Qnil
;
6494 DEFVAR_LISP ("special-display-buffer-names", &Vspecial_display_buffer_names
,
6495 doc
: /* *List of buffer names that should have their own special frames.
6496 Displaying a buffer whose name is in this list makes a special frame for it
6497 using `special-display-function'. See also `special-display-regexps'.
6499 An element of the list can be a list instead of just a string.
6500 There are two ways to use a list as an element:
6501 (BUFFER FRAME-PARAMETERS...) (BUFFER FUNCTION OTHER-ARGS...)
6502 In the first case, FRAME-PARAMETERS are used to create the frame.
6503 In the latter case, FUNCTION is called with BUFFER as the first argument,
6504 followed by OTHER-ARGS--it can display BUFFER in any way it likes.
6505 All this is done by the function found in `special-display-function'.
6507 If the specified frame parameters include (same-buffer . t), the
6508 buffer is displayed in the currently selected window. Otherwise, if
6509 they include (same-frame . t), the buffer is displayed in a new window
6510 in the currently selected frame.
6512 If this variable appears \"not to work\", because you add a name to it
6513 but that buffer still appears in the selected window, look at the
6514 values of `same-window-buffer-names' and `same-window-regexps'.
6515 Those variables take precedence over this one. */);
6516 Vspecial_display_buffer_names
= Qnil
;
6518 DEFVAR_LISP ("special-display-regexps", &Vspecial_display_regexps
,
6519 doc
: /* *List of regexps saying which buffers should have their own special frames.
6520 If a buffer name matches one of these regexps, it gets its own frame.
6521 Displaying a buffer whose name is in this list makes a special frame for it
6522 using `special-display-function'.
6524 An element of the list can be a list instead of just a string.
6525 There are two ways to use a list as an element:
6526 (REGEXP FRAME-PARAMETERS...) (REGEXP FUNCTION OTHER-ARGS...)
6527 In the first case, FRAME-PARAMETERS are used to create the frame.
6528 In the latter case, FUNCTION is called with the buffer as first argument,
6529 followed by OTHER-ARGS--it can display the buffer in any way it likes.
6530 All this is done by the function found in `special-display-function'.
6532 If the specified frame parameters include (same-buffer . t), the
6533 buffer is displayed in the currently selected window. Otherwise, if
6534 they include (same-frame . t), the buffer is displayed in a new window
6535 in the currently selected frame.
6537 If this variable appears \"not to work\", because you add a regexp to it
6538 but the matching buffers still appear in the selected window, look at the
6539 values of `same-window-buffer-names' and `same-window-regexps'.
6540 Those variables take precedence over this one. */);
6541 Vspecial_display_regexps
= Qnil
;
6543 DEFVAR_LISP ("special-display-function", &Vspecial_display_function
,
6544 doc
: /* Function to call to make a new frame for a special buffer.
6545 It is called with two arguments, the buffer and optional buffer specific
6546 data, and should return a window displaying that buffer.
6547 The default value normally makes a separate frame for the buffer,
6548 using `special-display-frame-alist' to specify the frame parameters.
6549 But if the buffer specific data includes (same-buffer . t) then the
6550 buffer is displayed in the current selected window.
6551 Otherwise if it includes (same-frame . t) then the buffer is displayed in
6552 a new window in the currently selected frame.
6554 A buffer is special if it is listed in `special-display-buffer-names'
6555 or matches a regexp in `special-display-regexps'. */);
6556 Vspecial_display_function
= Qnil
;
6558 DEFVAR_LISP ("same-window-buffer-names", &Vsame_window_buffer_names
,
6559 doc
: /* *List of buffer names that should appear in the selected window.
6560 Displaying one of these buffers using `display-buffer' or `pop-to-buffer'
6561 switches to it in the selected window, rather than making it appear
6562 in some other window.
6564 An element of the list can be a cons cell instead of just a string.
6565 Then the car must be a string, which specifies the buffer name.
6566 This is for compatibility with `special-display-buffer-names';
6567 the cdr of the cons cell is ignored.
6569 See also `same-window-regexps'. */);
6570 Vsame_window_buffer_names
= Qnil
;
6572 DEFVAR_LISP ("same-window-regexps", &Vsame_window_regexps
,
6573 doc
: /* *List of regexps saying which buffers should appear in the selected window.
6574 If a buffer name matches one of these regexps, then displaying it
6575 using `display-buffer' or `pop-to-buffer' switches to it
6576 in the selected window, rather than making it appear in some other window.
6578 An element of the list can be a cons cell instead of just a string.
6579 Then the car must be a string, which specifies the buffer name.
6580 This is for compatibility with `special-display-buffer-names';
6581 the cdr of the cons cell is ignored.
6583 See also `same-window-buffer-names'. */);
6584 Vsame_window_regexps
= Qnil
;
6586 DEFVAR_BOOL ("pop-up-windows", &pop_up_windows
,
6587 doc
: /* *Non-nil means display-buffer should make new windows. */);
6590 DEFVAR_INT ("next-screen-context-lines", &next_screen_context_lines
,
6591 doc
: /* *Number of lines of continuity when scrolling by screenfuls. */);
6592 next_screen_context_lines
= 2;
6594 DEFVAR_INT ("split-height-threshold", &split_height_threshold
,
6595 doc
: /* *display-buffer would prefer to split the largest window if this large.
6596 If there is only one window, it is split regardless of this value. */);
6597 split_height_threshold
= 500;
6599 DEFVAR_INT ("window-min-height", &window_min_height
,
6600 doc
: /* *Delete any window less than this tall (including its mode line). */);
6601 window_min_height
= 4;
6603 DEFVAR_INT ("window-min-width", &window_min_width
,
6604 doc
: /* *Delete any window less than this wide. */);
6605 window_min_width
= 10;
6607 DEFVAR_LISP ("scroll-preserve-screen-position",
6608 &Vscroll_preserve_screen_position
,
6609 doc
: /* *Non-nil means scroll commands move point to keep its screen line unchanged. */);
6610 Vscroll_preserve_screen_position
= Qnil
;
6612 DEFVAR_LISP ("window-configuration-change-hook",
6613 &Vwindow_configuration_change_hook
,
6614 doc
: /* Functions to call when window configuration changes.
6615 The selected frame is the one whose configuration has changed. */);
6616 Vwindow_configuration_change_hook
= Qnil
;
6618 DEFVAR_BOOL ("window-size-fixed", &window_size_fixed
,
6619 doc
: /* Non-nil in a buffer means windows displaying the buffer are fixed-size.
6620 Emacs won't change the size of any window displaying that buffer,
6621 unless you explicitly change the size, or Emacs has no other choice.
6622 This variable automatically becomes buffer-local when set. */);
6623 Fmake_variable_buffer_local (Qwindow_size_fixed
);
6624 window_size_fixed
= 0;
6626 defsubr (&Sselected_window
);
6627 defsubr (&Sminibuffer_window
);
6628 defsubr (&Swindow_minibuffer_p
);
6629 defsubr (&Swindowp
);
6630 defsubr (&Swindow_live_p
);
6631 defsubr (&Spos_visible_in_window_p
);
6632 defsubr (&Swindow_buffer
);
6633 defsubr (&Swindow_height
);
6634 defsubr (&Swindow_width
);
6635 defsubr (&Swindow_hscroll
);
6636 defsubr (&Sset_window_hscroll
);
6637 defsubr (&Swindow_redisplay_end_trigger
);
6638 defsubr (&Sset_window_redisplay_end_trigger
);
6639 defsubr (&Swindow_edges
);
6640 defsubr (&Swindow_pixel_edges
);
6641 defsubr (&Swindow_inside_edges
);
6642 defsubr (&Swindow_inside_pixel_edges
);
6643 defsubr (&Scoordinates_in_window_p
);
6644 defsubr (&Swindow_at
);
6645 defsubr (&Swindow_point
);
6646 defsubr (&Swindow_start
);
6647 defsubr (&Swindow_end
);
6648 defsubr (&Sset_window_point
);
6649 defsubr (&Sset_window_start
);
6650 defsubr (&Swindow_dedicated_p
);
6651 defsubr (&Sset_window_dedicated_p
);
6652 defsubr (&Swindow_display_table
);
6653 defsubr (&Sset_window_display_table
);
6654 defsubr (&Snext_window
);
6655 defsubr (&Sprevious_window
);
6656 defsubr (&Sother_window
);
6657 defsubr (&Sget_lru_window
);
6658 defsubr (&Sget_largest_window
);
6659 defsubr (&Sget_buffer_window
);
6660 defsubr (&Sdelete_other_windows
);
6661 defsubr (&Sdelete_windows_on
);
6662 defsubr (&Sreplace_buffer_in_windows
);
6663 defsubr (&Sdelete_window
);
6664 defsubr (&Sset_window_buffer
);
6665 defsubr (&Sselect_window
);
6666 defsubr (&Sspecial_display_p
);
6667 defsubr (&Ssame_window_p
);
6668 defsubr (&Sdisplay_buffer
);
6669 defsubr (&Sforce_window_update
);
6670 defsubr (&Ssplit_window
);
6671 defsubr (&Senlarge_window
);
6672 defsubr (&Sshrink_window
);
6673 defsubr (&Sscroll_up
);
6674 defsubr (&Sscroll_down
);
6675 defsubr (&Sscroll_left
);
6676 defsubr (&Sscroll_right
);
6677 defsubr (&Sother_window_for_scrolling
);
6678 defsubr (&Sscroll_other_window
);
6679 defsubr (&Sminibuffer_selected_window
);
6680 defsubr (&Srecenter
);
6681 defsubr (&Swindow_text_height
);
6682 defsubr (&Smove_to_window_line
);
6683 defsubr (&Swindow_configuration_p
);
6684 defsubr (&Swindow_configuration_frame
);
6685 defsubr (&Sset_window_configuration
);
6686 defsubr (&Scurrent_window_configuration
);
6687 defsubr (&Ssave_window_excursion
);
6688 defsubr (&Sset_window_margins
);
6689 defsubr (&Swindow_margins
);
6690 defsubr (&Sset_window_fringes
);
6691 defsubr (&Swindow_fringes
);
6692 defsubr (&Sset_window_scroll_bars
);
6693 defsubr (&Swindow_scroll_bars
);
6694 defsubr (&Swindow_vscroll
);
6695 defsubr (&Sset_window_vscroll
);
6696 defsubr (&Scompare_window_configurations
);
6697 defsubr (&Swindow_list
);
6703 initial_define_key (control_x_map
, '1', "delete-other-windows");
6704 initial_define_key (control_x_map
, '2', "split-window");
6705 initial_define_key (control_x_map
, '0', "delete-window");
6706 initial_define_key (control_x_map
, 'o', "other-window");
6707 initial_define_key (control_x_map
, '^', "enlarge-window");
6708 initial_define_key (control_x_map
, '<', "scroll-left");
6709 initial_define_key (control_x_map
, '>', "scroll-right");
6711 initial_define_key (global_map
, Ctl ('V'), "scroll-up");
6712 initial_define_key (meta_map
, Ctl ('V'), "scroll-other-window");
6713 initial_define_key (meta_map
, 'v', "scroll-down");
6715 initial_define_key (global_map
, Ctl('L'), "recenter");
6716 initial_define_key (meta_map
, 'r', "move-to-window-line");
6719 /* arch-tag: 90a9c576-0590-48f1-a5f1-6c96a0452d9f
6720 (do not change this comment) */