1 /* Window creation, deletion and examination for GNU Emacs.
2 Does not include redisplay.
3 Copyright (C) 1985-1987, 1993-1998, 2000-2011
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 3 of the License, or
11 (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>. */
35 #include "dispextern.h"
36 #include "blockinput.h"
37 #include "intervals.h"
38 #include "termhooks.h" /* For FRAME_TERMINAL. */
42 #endif /* HAVE_X_WINDOWS */
53 Lisp_Object Qwindowp
, Qwindow_live_p
, Qdelete_window
;
54 static Lisp_Object Qwindow_configuration_p
, Qrecord_window_buffer
;
55 static Lisp_Object Qwindow_deletable_p
, Qdisplay_buffer
;
56 static Lisp_Object Qreplace_buffer_in_windows
, Qget_mru_window
;
57 static Lisp_Object Qresize_root_window
, Qresize_root_window_vertically
;
58 static Lisp_Object Qscroll_up
, Qscroll_down
, Qscroll_command
;
59 static Lisp_Object Qsafe
, Qabove
, Qbelow
;
60 static Lisp_Object Qauto_buffer_name
;
62 static int displayed_window_lines (struct window
*);
63 static struct window
*decode_window (Lisp_Object
);
64 static int count_windows (struct window
*);
65 static int get_leaf_windows (struct window
*, struct window
**, int);
66 static void window_scroll (Lisp_Object
, int, int, int);
67 static void window_scroll_pixel_based (Lisp_Object
, int, int, int);
68 static void window_scroll_line_based (Lisp_Object
, int, int, int);
69 static int freeze_window_start (struct window
*, void *);
70 static Lisp_Object
window_list (void);
71 static int add_window_to_list (struct window
*, void *);
72 static int candidate_window_p (Lisp_Object
, Lisp_Object
, Lisp_Object
,
74 static Lisp_Object
next_window (Lisp_Object
, Lisp_Object
,
76 static void decode_next_window_args (Lisp_Object
*, Lisp_Object
*,
78 static void foreach_window (struct frame
*,
79 int (* fn
) (struct window
*, void *),
81 static int foreach_window_1 (struct window
*,
82 int (* fn
) (struct window
*, void *),
84 static Lisp_Object
window_list_1 (Lisp_Object
, Lisp_Object
, Lisp_Object
);
85 static int resize_window_check (struct window
*, int);
86 static void resize_window_apply (struct window
*, int);
87 static Lisp_Object
select_window (Lisp_Object
, Lisp_Object
, int);
89 /* This is the window in which the terminal's cursor should
90 be left when nothing is being done with it. This must
91 always be a leaf window, and its buffer is selected by
92 the top level editing loop at the end of each command.
94 This value is always the same as
95 FRAME_SELECTED_WINDOW (selected_frame). */
96 Lisp_Object selected_window
;
98 /* A list of all windows for use by next_window and Fwindow_list.
99 Functions creating or deleting windows should invalidate this cache
100 by setting it to nil. */
101 Lisp_Object Vwindow_list
;
103 /* The mini-buffer window of the selected frame.
104 Note that you cannot test for mini-bufferness of an arbitrary window
105 by comparing against this; but you can test for mini-bufferness of
106 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. */
111 Lisp_Object minibuf_selected_window
;
113 /* Hook run at end of temp_output_buffer_show. */
114 static Lisp_Object Qtemp_buffer_show_hook
;
116 /* Incremented for each window created. */
117 static int sequence_number
;
119 /* Nonzero after init_window_once has finished. */
120 static int window_initialized
;
122 /* Hook to run when window config changes. */
123 static Lisp_Object Qwindow_configuration_change_hook
;
125 /* Used by the function window_scroll_pixel_based */
126 static int window_scroll_pixel_based_preserve_x
;
127 static int window_scroll_pixel_based_preserve_y
;
129 /* Same for window_scroll_line_based. */
130 static int window_scroll_preserve_hpos
;
131 static int window_scroll_preserve_vpos
;
133 static struct window
*
134 decode_window (register Lisp_Object window
)
137 return XWINDOW (selected_window
);
139 CHECK_LIVE_WINDOW (window
);
140 return XWINDOW (window
);
143 static struct window
*
144 decode_any_window (register Lisp_Object window
)
147 return XWINDOW (selected_window
);
149 CHECK_WINDOW (window
);
150 return XWINDOW (window
);
153 DEFUN ("windowp", Fwindowp
, Swindowp
, 1, 1, 0,
154 doc
: /* Return t if OBJECT is a window and nil otherwise. */)
157 return WINDOWP (object
) ? Qt
: Qnil
;
160 DEFUN ("window-live-p", Fwindow_live_p
, Swindow_live_p
, 1, 1, 0,
161 doc
: /* Return t if OBJECT is a live window and nil otherwise.
162 A live window is a window that displays a buffer. */)
165 return WINDOW_LIVE_P (object
) ? Qt
: Qnil
;
168 /* Frames and windows. */
169 DEFUN ("window-frame", Fwindow_frame
, Swindow_frame
, 1, 1, 0,
170 doc
: /* Return the frame that window WINDOW is on.
171 WINDOW can be any window and defaults to the selected one. */)
174 return decode_any_window (window
)->frame
;
177 DEFUN ("frame-root-window", Fframe_root_window
, Sframe_root_window
, 0, 1, 0,
178 doc
: /* Return the root window of FRAME_OR_WINDOW.
179 If omitted, FRAME_OR_WINDOW defaults to the currently selected frame.
180 Else if FRAME_OR_WINDOW denotes any window, return the root window of
181 that window's frame. If FRAME_OR_WINDOW denotes a live frame, return
182 the root window of that frame. */)
183 (Lisp_Object frame_or_window
)
187 if (NILP (frame_or_window
))
188 window
= SELECTED_FRAME ()->root_window
;
189 else if (WINDOWP (frame_or_window
))
190 window
= XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window
)))->root_window
;
193 CHECK_LIVE_FRAME (frame_or_window
);
194 window
= XFRAME (frame_or_window
)->root_window
;
200 DEFUN ("minibuffer-window", Fminibuffer_window
, Sminibuffer_window
, 0, 1, 0,
201 doc
: /* Return the window used now for minibuffers.
202 If the optional argument FRAME is specified, return the minibuffer window
203 used by that frame. */)
207 frame
= selected_frame
;
208 CHECK_LIVE_FRAME (frame
);
209 return FRAME_MINIBUF_WINDOW (XFRAME (frame
));
212 DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p
,
213 Swindow_minibuffer_p
, 0, 1, 0,
214 doc
: /* Return non-nil if WINDOW is a minibuffer window.
215 WINDOW can be any window and defaults to the selected one. */)
218 return MINI_WINDOW_P (decode_any_window (window
)) ? Qt
: Qnil
;
221 /* Don't move this to window.el - this must be a safe routine. */
222 DEFUN ("frame-first-window", Fframe_first_window
, Sframe_first_window
, 0, 1, 0,
223 doc
: /* Return the topmost, leftmost live window on FRAME_OR_WINDOW.
224 If omitted, FRAME_OR_WINDOW defaults to the currently selected frame.
225 Else if FRAME_OR_WINDOW denotes any window, return the first window of
226 that window's frame. If FRAME_OR_WINDOW denotes a live frame, return
227 the first window of that frame. */)
228 (Lisp_Object frame_or_window
)
232 if (NILP (frame_or_window
))
233 window
= SELECTED_FRAME ()->root_window
;
234 else if (WINDOWP (frame_or_window
))
235 window
= XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window
)))->root_window
;
238 CHECK_LIVE_FRAME (frame_or_window
);
239 window
= XFRAME (frame_or_window
)->root_window
;
242 while (NILP (XWINDOW (window
)->buffer
))
244 if (! NILP (XWINDOW (window
)->hchild
))
245 window
= XWINDOW (window
)->hchild
;
246 else if (! NILP (XWINDOW (window
)->vchild
))
247 window
= XWINDOW (window
)->vchild
;
255 DEFUN ("frame-selected-window", Fframe_selected_window
,
256 Sframe_selected_window
, 0, 1, 0,
257 doc
: /* Return the selected window of FRAME_OR_WINDOW.
258 If omitted, FRAME_OR_WINDOW defaults to the currently selected frame.
259 Else if FRAME_OR_WINDOW denotes any window, return the selected window
260 of that window's frame. If FRAME_OR_WINDOW denotes a live frame, return
261 the selected window of that frame. */)
262 (Lisp_Object frame_or_window
)
266 if (NILP (frame_or_window
))
267 window
= SELECTED_FRAME ()->selected_window
;
268 else if (WINDOWP (frame_or_window
))
269 window
= XFRAME (WINDOW_FRAME (XWINDOW (frame_or_window
)))->selected_window
;
272 CHECK_LIVE_FRAME (frame_or_window
);
273 window
= XFRAME (frame_or_window
)->selected_window
;
279 DEFUN ("set-frame-selected-window", Fset_frame_selected_window
,
280 Sset_frame_selected_window
, 2, 3, 0,
281 doc
: /* Set selected window of FRAME to WINDOW.
282 FRAME must be a live frame and defaults to the selected one. If FRAME
283 is the selected frame, this makes WINDOW the selected window. Optional
284 argument NORECORD non-nil means to neither change the order of recently
285 selected windows nor the buffer list. WINDOW must denote a live window.
287 (Lisp_Object frame
, Lisp_Object window
, Lisp_Object norecord
)
290 frame
= selected_frame
;
292 CHECK_LIVE_FRAME (frame
);
293 CHECK_LIVE_WINDOW (window
);
295 if (! EQ (frame
, WINDOW_FRAME (XWINDOW (window
))))
296 error ("In `set-frame-selected-window', WINDOW is not on FRAME");
298 if (EQ (frame
, selected_frame
))
299 return Fselect_window (window
, norecord
);
301 return XFRAME (frame
)->selected_window
= window
;
304 DEFUN ("selected-window", Fselected_window
, Sselected_window
, 0, 0, 0,
305 doc
: /* Return the selected window.
306 The selected window is the window in which the standard cursor for
307 selected windows appears and to which many commands apply. */)
310 return selected_window
;
313 /* If select_window is called with inhibit_point_swap non-zero it will
314 not store point of the old selected window's buffer back into that
315 window's pointm slot. This is needed by Fset_window_configuration to
316 avoid that the display routine is called with selected_window set to
317 Qnil causing a subsequent crash. */
319 select_window (Lisp_Object window
, Lisp_Object norecord
, int inhibit_point_swap
)
321 register struct window
*w
;
322 register struct window
*ow
;
325 CHECK_LIVE_WINDOW (window
);
327 w
= XWINDOW (window
);
328 w
->frozen_window_start_p
= 0;
332 ++window_select_count
;
333 XSETFASTINT (w
->use_time
, window_select_count
);
334 record_buffer (w
->buffer
);
337 if (EQ (window
, selected_window
) && !inhibit_point_swap
)
340 sf
= SELECTED_FRAME ();
341 if (XFRAME (WINDOW_FRAME (w
)) != sf
)
343 XFRAME (WINDOW_FRAME (w
))->selected_window
= window
;
344 /* Use this rather than Fhandle_switch_frame
345 so that FRAME_FOCUS_FRAME is moved appropriately as we
346 move around in the state where a minibuffer in a separate
348 Fselect_frame (WINDOW_FRAME (w
), norecord
);
349 /* Fselect_frame called us back so we've done all the work already. */
350 eassert (EQ (window
, selected_window
));
354 sf
->selected_window
= window
;
356 /* Store the current buffer's actual point into the
357 old selected window. It belongs to that window,
358 and when the window is not selected, must be in the window. */
359 if (!inhibit_point_swap
)
361 ow
= XWINDOW (selected_window
);
362 if (! NILP (ow
->buffer
))
363 set_marker_both (ow
->pointm
, ow
->buffer
,
364 BUF_PT (XBUFFER (ow
->buffer
)),
365 BUF_PT_BYTE (XBUFFER (ow
->buffer
)));
368 selected_window
= window
;
370 Fset_buffer (w
->buffer
);
372 BVAR (XBUFFER (w
->buffer
), last_selected_window
) = window
;
374 /* Go to the point recorded in the window.
375 This is important when the buffer is in more
376 than one window. It also matters when
377 redisplay_window has altered point after scrolling,
378 because it makes the change only in the window. */
380 register EMACS_INT new_point
= marker_position (w
->pointm
);
381 if (new_point
< BEGV
)
383 else if (new_point
> ZV
)
389 windows_or_buffers_changed
++;
393 DEFUN ("select-window", Fselect_window
, Sselect_window
, 1, 2, 0,
394 doc
: /* Select WINDOW. Most editing will apply to WINDOW's buffer.
395 Also make WINDOW's buffer current and make WINDOW the frame's selected
396 window. Return WINDOW.
398 Optional second arg NORECORD non-nil means do not put this buffer at the
399 front of the buffer list and do not make this window the most recently
402 Note that the main editor command loop sets the current buffer to the
403 buffer of the selected window before each command. */)
404 (register Lisp_Object window
, Lisp_Object norecord
)
406 return select_window (window
, norecord
, 0);
409 DEFUN ("window-clone-number", Fwindow_clone_number
, Swindow_clone_number
, 0, 1, 0,
410 doc
: /* Return WINDOW's clone number.
411 WINDOW can be any window and defaults to the selected one. */)
414 return decode_any_window (window
)->clone_number
;
417 DEFUN ("window-buffer", Fwindow_buffer
, Swindow_buffer
, 0, 1, 0,
418 doc
: /* Return the buffer that WINDOW is displaying.
419 WINDOW can be any window and defaults to the selected one.
420 If WINDOW is an internal window return nil. */)
423 return decode_any_window (window
)->buffer
;
426 DEFUN ("window-parent", Fwindow_parent
, Swindow_parent
, 0, 1, 0,
427 doc
: /* Return WINDOW's parent window.
428 WINDOW can be any window and defaults to the selected one.
429 Return nil if WINDOW has no parent. */)
432 return decode_any_window (window
)->parent
;
435 DEFUN ("window-vchild", Fwindow_vchild
, Swindow_vchild
, 0, 1, 0,
436 doc
: /* Return WINDOW's first vertical child window.
437 WINDOW can be any window and defaults to the selected one.
438 Return nil if WINDOW has no vertical child. */)
441 return decode_any_window (window
)->vchild
;
444 DEFUN ("window-hchild", Fwindow_hchild
, Swindow_hchild
, 0, 1, 0,
445 doc
: /* Return WINDOW's first horizontal child window.
446 WINDOW can be any window and defaults to the selected one.
447 Return nil if WINDOW has no horizontal child. */)
450 return decode_any_window (window
)->hchild
;
453 DEFUN ("window-next", Fwindow_next
, Swindow_next
, 0, 1, 0,
454 doc
: /* Return WINDOW's right sibling window.
455 WINDOW can be any window and defaults to the selected one.
456 Return nil if WINDOW has no right sibling. */)
459 return decode_any_window (window
)->next
;
462 DEFUN ("window-prev", Fwindow_prev
, Swindow_prev
, 0, 1, 0,
463 doc
: /* Return WINDOW's left sibling window.
464 WINDOW can be any window and defaults to the selected one.
465 Return nil if WINDOW has no left sibling. */)
468 return decode_any_window (window
)->prev
;
471 DEFUN ("window-splits", Fwindow_splits
, Swindow_splits
, 0, 1, 0,
472 doc
: /* Return splits status for WINDOW.
473 WINDOW can be any window and defaults to the selected one.
475 If the value returned by this function is nil and WINDOW is resized, the
476 corresponding space is preferably taken from (or given to) WINDOW's
477 right sibling. When WINDOW is deleted, its space is given to its left
480 If the value returned by this function is non-nil, resizing and deleting
481 WINDOW may resize all windows in the same combination. */)
484 return decode_any_window (window
)->splits
;
487 DEFUN ("set-window-splits", Fset_window_splits
, Sset_window_splits
, 2, 2, 0,
488 doc
: /* Set splits status of WINDOW to STATUS.
489 WINDOW can be any window and defaults to the selected one. Return
492 If STATUS is nil and WINDOW is later resized, the corresponding space is
493 preferably taken from (or given to) WINDOW's right sibling. When WINDOW
494 is deleted, its space is given to its left sibling.
496 If STATUS is non-nil, resizing and deleting WINDOW may resize all
497 windows in the same combination. */)
498 (Lisp_Object window
, Lisp_Object status
)
500 register struct window
*w
= decode_any_window (window
);
507 DEFUN ("window-nest", Fwindow_nest
, Swindow_nest
, 0, 1, 0,
508 doc
: /* Return nest status of WINDOW.
509 WINDOW can be any window and defaults to the selected one.
511 If the return value is nil, subwindows of WINDOW can be recombined with
512 WINDOW's siblings. A return value of non-nil means that subwindows of
513 WINDOW are never \(re-)combined with WINDOW's siblings. */)
516 return decode_any_window (window
)->nest
;
519 DEFUN ("set-window-nest", Fset_window_nest
, Sset_window_nest
, 2, 2, 0,
520 doc
: /* Set nest status of WINDOW to STATUS.
521 WINDOW can be any window and defaults to the selected one. Return
524 If STATUS is nil, subwindows of WINDOW can be recombined with WINDOW's
525 siblings. STATUS non-nil means that subwindows of WINDOW are never
526 \(re-)combined with WINDOW's siblings. */)
527 (Lisp_Object window
, Lisp_Object status
)
529 register struct window
*w
= decode_any_window (window
);
536 DEFUN ("window-use-time", Fwindow_use_time
, Swindow_use_time
, 0, 1, 0,
537 doc
: /* Return WINDOW's use time.
538 WINDOW defaults to the selected window. The window with the highest use
539 time is the most recently selected one. The window with the lowest use
540 time is the least recently selected one. */)
543 return decode_window (window
)->use_time
;
546 DEFUN ("window-total-size", Fwindow_total_size
, Swindow_total_size
, 0, 2, 0,
547 doc
: /* Return the total number of lines of WINDOW.
548 WINDOW can be any window and defaults to the selected one. The return
549 value includes WINDOW's mode line and header line, if any. If WINDOW
550 is internal, the return value is the sum of the total number of lines
551 of WINDOW's child windows if these are vertically combined and the
552 height of WINDOW's first child otherwise.
554 Optional argument HORIZONTAL non-nil means return the total number of
555 columns of WINDOW. In this case the return value includes any vertical
556 dividers or scrollbars of WINDOW. If WINDOW is internal, the return
557 value is the sum of the total number of columns of WINDOW's child
558 windows if they are horizontally combined and the width of WINDOW's
559 first child otherwise. */)
560 (Lisp_Object window
, Lisp_Object horizontal
)
562 if (NILP (horizontal
))
563 return decode_any_window (window
)->total_lines
;
565 return decode_any_window (window
)->total_cols
;
568 DEFUN ("window-new-total", Fwindow_new_total
, Swindow_new_total
, 0, 1, 0,
569 doc
: /* Return new total size of WINDOW.
570 WINDOW defaults to the selected window. */)
573 return decode_any_window (window
)->new_total
;
576 DEFUN ("window-normal-size", Fwindow_normal_size
, Swindow_normal_size
, 0, 2, 0,
577 doc
: /* Return normal height of WINDOW.
578 WINDOW can be any window and defaults to the selected one. Optional
579 argument HORIZONTAL non-nil means return normal width of WINDOW. */)
580 (Lisp_Object window
, Lisp_Object horizontal
)
582 if (NILP (horizontal
))
583 return decode_any_window (window
)->normal_lines
;
585 return decode_any_window (window
)->normal_cols
;
588 DEFUN ("window-new-normal", Fwindow_new_normal
, Swindow_new_normal
, 0, 1, 0,
589 doc
: /* Return new normal size of WINDOW.
590 WINDOW can be any window and defaults to the selected one. */)
593 return decode_any_window (window
)->new_normal
;
596 DEFUN ("window-left-column", Fwindow_left_column
, Swindow_left_column
, 0, 1, 0,
597 doc
: /* Return left column of WINDOW.
598 WINDOW can be any window and defaults to the selected one. */)
601 return decode_any_window (window
)->left_col
;
604 DEFUN ("window-top-line", Fwindow_top_line
, Swindow_top_line
, 0, 1, 0,
605 doc
: /* Return top line of WINDOW.
606 WINDOW can be any window and defaults to the selected one. */)
609 return decode_any_window (window
)->top_line
;
612 /* Return the number of lines of W's body. Don't count any mode or
616 window_body_lines (struct window
*w
)
618 int height
= XFASTINT (w
->total_lines
);
620 if (!MINI_WINDOW_P (w
))
622 if (WINDOW_WANTS_MODELINE_P (w
))
624 if (WINDOW_WANTS_HEADER_LINE_P (w
))
631 /* Return the number of columns of W's body. Don't count columns
632 occupied by the scroll bar or the vertical bar separating W from its
633 right sibling. On window-systems don't count fringes or display
637 window_body_cols (struct window
*w
)
639 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
640 int width
= XINT (w
->total_cols
);
642 if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w
))
643 /* Scroll bars occupy a few columns. */
644 width
-= WINDOW_CONFIG_SCROLL_BAR_COLS (w
);
645 else if (!FRAME_WINDOW_P (f
)
646 && !WINDOW_RIGHTMOST_P (w
) && !WINDOW_FULL_WIDTH_P (w
))
647 /* The column of `|' characters separating side-by-side windows
648 occupies one column only. */
651 if (FRAME_WINDOW_P (f
))
652 /* On window-systems, fringes and display margins cannot be
653 used for normal text. */
654 width
-= (WINDOW_FRINGE_COLS (w
)
655 + WINDOW_LEFT_MARGIN_COLS (w
)
656 + WINDOW_RIGHT_MARGIN_COLS (w
));
661 DEFUN ("window-body-size", Fwindow_body_size
, Swindow_body_size
, 0, 2, 0,
662 doc
: /* Return the number of lines of WINDOW's body.
663 WINDOW must be a live window and defaults to the selected one. The
664 return value does not include WINDOW's mode line and header line, if
667 Optional argument HORIZONTAL non-nil means return the number of columns
668 of WINDOW's body. In this case, the return value does not include any
669 vertical dividers or scroll bars owned by WINDOW. On a window-system
670 the return value does not include the number of columns used for
671 WINDOW's fringes or display margins either. */)
672 (Lisp_Object window
, Lisp_Object horizontal
)
674 struct window
*w
= decode_any_window (window
);
676 if (NILP (horizontal
))
677 return make_number (window_body_lines (w
));
679 return make_number (window_body_cols (w
));
682 DEFUN ("window-hscroll", Fwindow_hscroll
, Swindow_hscroll
, 0, 1, 0,
683 doc
: /* Return the number of columns by which WINDOW is scrolled from left margin.
684 WINDOW must be a live window and defaults to the selected one. */)
687 return decode_window (window
)->hscroll
;
690 DEFUN ("set-window-hscroll", Fset_window_hscroll
, Sset_window_hscroll
, 2, 2, 0,
691 doc
: /* Set number of columns WINDOW is scrolled from left margin to NCOL.
692 Return NCOL. NCOL should be zero or positive.
694 Note that if `automatic-hscrolling' is non-nil, you cannot scroll the
695 window so that the location of point moves off-window. */)
696 (Lisp_Object window
, Lisp_Object ncol
)
698 struct window
*w
= decode_window (window
);
702 hscroll
= max (0, XINT (ncol
));
704 /* Prevent redisplay shortcuts when changing the hscroll. */
705 if (XINT (w
->hscroll
) != hscroll
)
706 XBUFFER (w
->buffer
)->prevent_redisplay_optimizations_p
= 1;
708 w
->hscroll
= make_number (hscroll
);
712 DEFUN ("window-redisplay-end-trigger", Fwindow_redisplay_end_trigger
,
713 Swindow_redisplay_end_trigger
, 0, 1, 0,
714 doc
: /* Return WINDOW's redisplay end trigger value.
715 WINDOW defaults to the selected window.
716 See `set-window-redisplay-end-trigger' for more information. */)
719 return decode_window (window
)->redisplay_end_trigger
;
722 DEFUN ("set-window-redisplay-end-trigger", Fset_window_redisplay_end_trigger
,
723 Sset_window_redisplay_end_trigger
, 2, 2, 0,
724 doc
: /* Set WINDOW's redisplay end trigger value to VALUE.
725 VALUE should be a buffer position (typically a marker) or nil.
726 If it is a buffer position, then if redisplay in WINDOW reaches a position
727 beyond VALUE, the functions in `redisplay-end-trigger-functions' are called
728 with two arguments: WINDOW, and the end trigger value.
729 Afterwards the end-trigger value is reset to nil. */)
730 (register Lisp_Object window
, Lisp_Object value
)
732 register struct window
*w
;
734 w
= decode_window (window
);
735 w
->redisplay_end_trigger
= value
;
739 DEFUN ("window-edges", Fwindow_edges
, Swindow_edges
, 0, 1, 0,
740 doc
: /* Return a list of the edge coordinates of WINDOW.
741 The list has the form (LEFT TOP RIGHT BOTTOM).
742 TOP and BOTTOM count by lines, and LEFT and RIGHT count by columns,
743 all relative to 0, 0 at top left corner of frame.
745 RIGHT is one more than the rightmost column occupied by WINDOW.
746 BOTTOM is one more than the bottommost row occupied by WINDOW.
747 The edges include the space used by WINDOW's scroll bar, display
748 margins, fringes, header line, and/or mode line. For the edges of
749 just the text area, use `window-inside-edges'. */)
752 register struct window
*w
= decode_any_window (window
);
754 return Fcons (make_number (WINDOW_LEFT_EDGE_COL (w
)),
755 Fcons (make_number (WINDOW_TOP_EDGE_LINE (w
)),
756 Fcons (make_number (WINDOW_RIGHT_EDGE_COL (w
)),
757 Fcons (make_number (WINDOW_BOTTOM_EDGE_LINE (w
)),
761 DEFUN ("window-pixel-edges", Fwindow_pixel_edges
, Swindow_pixel_edges
, 0, 1, 0,
762 doc
: /* Return a list of the edge pixel coordinates of WINDOW.
763 The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at
764 the top left corner of the frame.
766 RIGHT is one more than the rightmost x position occupied by WINDOW.
767 BOTTOM is one more than the bottommost y position occupied by WINDOW.
768 The pixel edges include the space used by WINDOW's scroll bar, display
769 margins, fringes, header line, and/or mode line. For the pixel edges
770 of just the text area, use `window-inside-pixel-edges'. */)
773 register struct window
*w
= decode_any_window (window
);
775 return Fcons (make_number (WINDOW_LEFT_EDGE_X (w
)),
776 Fcons (make_number (WINDOW_TOP_EDGE_Y (w
)),
777 Fcons (make_number (WINDOW_RIGHT_EDGE_X (w
)),
778 Fcons (make_number (WINDOW_BOTTOM_EDGE_Y (w
)),
783 calc_absolute_offset(struct window
*w
, int *add_x
, int *add_y
)
785 struct frame
*f
= XFRAME (w
->frame
);
787 #ifdef FRAME_MENUBAR_HEIGHT
788 *add_y
+= FRAME_MENUBAR_HEIGHT (f
);
790 #ifdef FRAME_TOOLBAR_TOP_HEIGHT
791 *add_y
+= FRAME_TOOLBAR_TOP_HEIGHT (f
);
792 #elif FRAME_TOOLBAR_HEIGHT
793 *add_y
+= FRAME_TOOLBAR_HEIGHT (f
);
795 #ifdef FRAME_NS_TITLEBAR_HEIGHT
796 *add_y
+= FRAME_NS_TITLEBAR_HEIGHT (f
);
798 *add_x
= f
->left_pos
;
799 #ifdef FRAME_TOOLBAR_LEFT_WIDTH
800 *add_x
+= FRAME_TOOLBAR_LEFT_WIDTH (f
);
804 DEFUN ("window-absolute-pixel-edges", Fwindow_absolute_pixel_edges
,
805 Swindow_absolute_pixel_edges
, 0, 1, 0,
806 doc
: /* Return a list of the edge pixel coordinates of WINDOW.
807 The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at
808 the top left corner of the display.
810 RIGHT is one more than the rightmost x position occupied by WINDOW.
811 BOTTOM is one more than the bottommost y position occupied by WINDOW.
812 The pixel edges include the space used by WINDOW's scroll bar, display
813 margins, fringes, header line, and/or mode line. For the pixel edges
814 of just the text area, use `window-inside-absolute-pixel-edges'. */)
817 register struct window
*w
= decode_any_window (window
);
819 calc_absolute_offset (w
, &add_x
, &add_y
);
821 return Fcons (make_number (WINDOW_LEFT_EDGE_X (w
) + add_x
),
822 Fcons (make_number (WINDOW_TOP_EDGE_Y (w
) + add_y
),
823 Fcons (make_number (WINDOW_RIGHT_EDGE_X (w
) + add_x
),
824 Fcons (make_number (WINDOW_BOTTOM_EDGE_Y (w
) + add_y
),
828 DEFUN ("window-inside-edges", Fwindow_inside_edges
, Swindow_inside_edges
, 0, 1, 0,
829 doc
: /* Return a list of the edge coordinates of WINDOW.
830 The list has the form (LEFT TOP RIGHT BOTTOM).
831 TOP and BOTTOM count by lines, and LEFT and RIGHT count by columns,
832 all relative to 0, 0 at top left corner of frame.
834 RIGHT is one more than the rightmost column of WINDOW's text area.
835 BOTTOM is one more than the bottommost row of WINDOW's text area.
836 The inside edges do not include the space used by the WINDOW's scroll
837 bar, display margins, fringes, header line, and/or mode line. */)
840 register struct window
*w
= decode_any_window (window
);
842 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_COL (w
)
843 + WINDOW_LEFT_MARGIN_COLS (w
)
844 + WINDOW_LEFT_FRINGE_COLS (w
)),
845 make_number (WINDOW_TOP_EDGE_LINE (w
)
846 + WINDOW_HEADER_LINE_LINES (w
)),
847 make_number (WINDOW_BOX_RIGHT_EDGE_COL (w
)
848 - WINDOW_RIGHT_MARGIN_COLS (w
)
849 - WINDOW_RIGHT_FRINGE_COLS (w
)),
850 make_number (WINDOW_BOTTOM_EDGE_LINE (w
)
851 - WINDOW_MODE_LINE_LINES (w
)));
854 DEFUN ("window-inside-pixel-edges", Fwindow_inside_pixel_edges
, Swindow_inside_pixel_edges
, 0, 1, 0,
855 doc
: /* Return a list of the edge pixel coordinates of WINDOW.
856 The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at
857 the top left corner of the frame.
859 RIGHT is one more than the rightmost x position of WINDOW's text area.
860 BOTTOM is one more than the bottommost y position of WINDOW's text area.
861 The inside edges do not include the space used by WINDOW's scroll bar,
862 display margins, fringes, header line, and/or mode line. */)
865 register struct window
*w
= decode_any_window (window
);
867 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w
)
868 + WINDOW_LEFT_MARGIN_WIDTH (w
)
869 + WINDOW_LEFT_FRINGE_WIDTH (w
)),
870 make_number (WINDOW_TOP_EDGE_Y (w
)
871 + WINDOW_HEADER_LINE_HEIGHT (w
)),
872 make_number (WINDOW_BOX_RIGHT_EDGE_X (w
)
873 - WINDOW_RIGHT_MARGIN_WIDTH (w
)
874 - WINDOW_RIGHT_FRINGE_WIDTH (w
)),
875 make_number (WINDOW_BOTTOM_EDGE_Y (w
)
876 - WINDOW_MODE_LINE_HEIGHT (w
)));
879 DEFUN ("window-inside-absolute-pixel-edges",
880 Fwindow_inside_absolute_pixel_edges
,
881 Swindow_inside_absolute_pixel_edges
, 0, 1, 0,
882 doc
: /* Return a list of the edge pixel coordinates of WINDOW.
883 The list has the form (LEFT TOP RIGHT BOTTOM), all relative to 0, 0 at
884 the top left corner of the display.
886 RIGHT is one more than the rightmost x position of WINDOW's text area.
887 BOTTOM is one more than the bottommost y position of WINDOW's text area.
888 The inside edges do not include the space used by WINDOW's scroll bar,
889 display margins, fringes, header line, and/or mode line. */)
892 register struct window
*w
= decode_any_window (window
);
894 calc_absolute_offset (w
, &add_x
, &add_y
);
896 return list4 (make_number (WINDOW_BOX_LEFT_EDGE_X (w
)
897 + WINDOW_LEFT_MARGIN_WIDTH (w
)
898 + WINDOW_LEFT_FRINGE_WIDTH (w
) + add_x
),
899 make_number (WINDOW_TOP_EDGE_Y (w
)
900 + WINDOW_HEADER_LINE_HEIGHT (w
) + add_y
),
901 make_number (WINDOW_BOX_RIGHT_EDGE_X (w
)
902 - WINDOW_RIGHT_MARGIN_WIDTH (w
)
903 - WINDOW_RIGHT_FRINGE_WIDTH (w
) + add_x
),
904 make_number (WINDOW_BOTTOM_EDGE_Y (w
)
905 - WINDOW_MODE_LINE_HEIGHT (w
) + add_y
));
908 /* Test if the character at column X, row Y is within window W.
909 If it is not, return ON_NOTHING;
910 if it is in the window's text area, return ON_TEXT;
911 if it is on the window's modeline, return ON_MODE_LINE;
912 if it is on the border between the window and its right sibling,
913 return ON_VERTICAL_BORDER.
914 if it is on a scroll bar, return ON_SCROLL_BAR.
915 if it is on the window's top line, return ON_HEADER_LINE;
916 if it is in left or right fringe of the window,
917 return ON_LEFT_FRINGE or ON_RIGHT_FRINGE;
918 if it is in the marginal area to the left/right of the window,
919 return ON_LEFT_MARGIN or ON_RIGHT_MARGIN.
921 X and Y are frame relative pixel coordinates. */
923 static enum window_part
924 coordinates_in_window (register struct window
*w
, int x
, int y
)
926 struct frame
*f
= XFRAME (WINDOW_FRAME (w
));
928 enum window_part part
;
929 int ux
= FRAME_COLUMN_WIDTH (f
);
930 int x0
= WINDOW_LEFT_EDGE_X (w
);
931 int x1
= WINDOW_RIGHT_EDGE_X (w
);
932 /* The width of the area where the vertical line can be dragged.
933 (Between mode lines for instance. */
934 int grabbable_width
= ux
;
935 int lmargin_width
, rmargin_width
, text_left
, text_right
;
936 int top_y
= WINDOW_TOP_EDGE_Y (w
);
937 int bottom_y
= WINDOW_BOTTOM_EDGE_Y (w
);
939 /* Outside any interesting row? */
940 if (y
< top_y
|| y
>= bottom_y
)
943 /* In what's below, we subtract 1 when computing right_x because we
944 want the rightmost pixel, which is given by left_pixel+width-1. */
945 if (w
->pseudo_window_p
)
948 right_x
= WINDOW_TOTAL_WIDTH (w
) - 1;
952 left_x
= WINDOW_BOX_LEFT_EDGE_X (w
);
953 right_x
= WINDOW_BOX_RIGHT_EDGE_X (w
) - 1;
956 /* On the mode line or header line? If it's near the start of
957 the mode or header line of window that's has a horizontal
958 sibling, say it's on the vertical line. That's to be able
959 to resize windows horizontally in case we're using toolkit
962 if (WINDOW_WANTS_MODELINE_P (w
)
963 && y
>= bottom_y
- CURRENT_MODE_LINE_HEIGHT (w
))
967 header_vertical_border_check
:
968 /* We're somewhere on the mode line. We consider the place
969 between mode lines of horizontally adjacent mode lines
970 as the vertical border. If scroll bars on the left,
971 return the right window. */
972 if ((WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w
)
973 || WINDOW_RIGHTMOST_P (w
))
974 && !WINDOW_LEFTMOST_P (w
)
975 && eabs (x
- x0
) < grabbable_width
)
976 return ON_VERTICAL_BORDER
;
978 /* Make sure we're not at the rightmost position of a
979 mode-/header-line and there's yet another window on the
981 else if ((WINDOW_RIGHTMOST_P (w
) || x
< x1
)
982 && eabs (x
- x1
) < grabbable_width
)
983 return ON_VERTICAL_BORDER
;
985 if (x
< x0
|| x
>= x1
)
991 if (WINDOW_WANTS_HEADER_LINE_P (w
)
992 && y
< top_y
+ CURRENT_HEADER_LINE_HEIGHT (w
))
994 part
= ON_HEADER_LINE
;
995 goto header_vertical_border_check
;
998 if (x
< x0
|| x
>= x1
) return ON_NOTHING
;
1000 /* Outside any interesting column? */
1001 if (x
< left_x
|| x
> right_x
)
1002 return ON_SCROLL_BAR
;
1004 lmargin_width
= window_box_width (w
, LEFT_MARGIN_AREA
);
1005 rmargin_width
= window_box_width (w
, RIGHT_MARGIN_AREA
);
1007 text_left
= window_box_left (w
, TEXT_AREA
);
1008 text_right
= text_left
+ window_box_width (w
, TEXT_AREA
);
1010 if (FRAME_WINDOW_P (f
))
1012 if (!w
->pseudo_window_p
1013 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w
)
1014 && !WINDOW_RIGHTMOST_P (w
)
1015 && (eabs (x
- right_x
) < grabbable_width
))
1016 return ON_VERTICAL_BORDER
;
1018 /* Need to say "x > right_x" rather than >=, since on character
1019 terminals, the vertical line's x coordinate is right_x. */
1020 else if (!w
->pseudo_window_p
1021 && !WINDOW_RIGHTMOST_P (w
)
1022 && x
> right_x
- ux
)
1023 return ON_VERTICAL_BORDER
;
1027 if (lmargin_width
> 0
1028 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w
)
1029 ? (x
>= left_x
+ WINDOW_LEFT_FRINGE_WIDTH (w
))
1030 : (x
< left_x
+ lmargin_width
)))
1031 return ON_LEFT_MARGIN
;
1033 return ON_LEFT_FRINGE
;
1036 if (x
>= text_right
)
1038 if (rmargin_width
> 0
1039 && (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w
)
1040 ? (x
< right_x
- WINDOW_RIGHT_FRINGE_WIDTH (w
))
1041 : (x
>= right_x
- rmargin_width
)))
1042 return ON_RIGHT_MARGIN
;
1044 return ON_RIGHT_FRINGE
;
1047 /* Everything special ruled out - must be on text area */
1051 /* Take X is the frame-relative pixel x-coordinate, and return the
1052 x-coordinate relative to part PART of window W. */
1054 window_relative_x_coord (struct window
*w
, enum window_part part
, int x
)
1056 int left_x
= (w
->pseudo_window_p
) ? 0 : WINDOW_BOX_LEFT_EDGE_X (w
);
1061 return x
- window_box_left (w
, TEXT_AREA
);
1063 case ON_LEFT_FRINGE
:
1066 case ON_RIGHT_FRINGE
:
1067 return x
- left_x
- WINDOW_LEFT_FRINGE_WIDTH (w
);
1069 case ON_LEFT_MARGIN
:
1071 - ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w
))
1072 ? WINDOW_LEFT_FRINGE_WIDTH (w
) : 0));
1074 case ON_RIGHT_MARGIN
:
1076 - ((w
->pseudo_window_p
)
1077 ? WINDOW_TOTAL_WIDTH (w
)
1078 : WINDOW_BOX_RIGHT_EDGE_X (w
))
1079 + window_box_width (w
, RIGHT_MARGIN_AREA
)
1080 + ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w
))
1081 ? WINDOW_RIGHT_FRINGE_WIDTH (w
) : 0));
1084 /* ON_SCROLL_BAR, ON_NOTHING, and ON_VERTICAL_BORDER: */
1089 DEFUN ("coordinates-in-window-p", Fcoordinates_in_window_p
,
1090 Scoordinates_in_window_p
, 2, 2, 0,
1091 doc
: /* Return non-nil if COORDINATES are in WINDOW.
1092 COORDINATES is a cons of the form (X . Y), X and Y being distances
1093 measured in characters from the upper-left corner of the frame.
1094 \(0 . 0) denotes the character in the upper left corner of the
1096 If COORDINATES are in the text portion of WINDOW,
1097 the coordinates relative to the window are returned.
1098 If they are in the mode line of WINDOW, `mode-line' is returned.
1099 If they are in the top mode line of WINDOW, `header-line' is returned.
1100 If they are in the left fringe of WINDOW, `left-fringe' is returned.
1101 If they are in the right fringe of WINDOW, `right-fringe' is returned.
1102 If they are on the border between WINDOW and its right sibling,
1103 `vertical-line' is returned.
1104 If they are in the windows's left or right marginal areas, `left-margin'\n\
1105 or `right-margin' is returned. */)
1106 (register Lisp_Object coordinates
, Lisp_Object window
)
1113 CHECK_WINDOW (window
);
1114 w
= XWINDOW (window
);
1115 f
= XFRAME (w
->frame
);
1116 CHECK_CONS (coordinates
);
1117 lx
= Fcar (coordinates
);
1118 ly
= Fcdr (coordinates
);
1119 CHECK_NUMBER_OR_FLOAT (lx
);
1120 CHECK_NUMBER_OR_FLOAT (ly
);
1121 x
= FRAME_PIXEL_X_FROM_CANON_X (f
, lx
) + FRAME_INTERNAL_BORDER_WIDTH (f
);
1122 y
= FRAME_PIXEL_Y_FROM_CANON_Y (f
, ly
) + FRAME_INTERNAL_BORDER_WIDTH (f
);
1124 switch (coordinates_in_window (w
, x
, y
))
1130 /* Convert X and Y to window relative pixel coordinates, and
1131 return the canonical char units. */
1132 x
-= window_box_left (w
, TEXT_AREA
);
1133 y
-= WINDOW_TOP_EDGE_Y (w
);
1134 return Fcons (FRAME_CANON_X_FROM_PIXEL_X (f
, x
),
1135 FRAME_CANON_Y_FROM_PIXEL_Y (f
, y
));
1140 case ON_VERTICAL_BORDER
:
1141 return Qvertical_line
;
1143 case ON_HEADER_LINE
:
1144 return Qheader_line
;
1146 case ON_LEFT_FRINGE
:
1147 return Qleft_fringe
;
1149 case ON_RIGHT_FRINGE
:
1150 return Qright_fringe
;
1152 case ON_LEFT_MARGIN
:
1153 return Qleft_margin
;
1155 case ON_RIGHT_MARGIN
:
1156 return Qright_margin
;
1159 /* Historically we are supposed to return nil in this case. */
1168 /* Callback for foreach_window, used in window_from_coordinates.
1169 Check if window W contains coordinates specified by USER_DATA which
1170 is actually a pointer to a struct check_window_data CW.
1172 Check if window W contains coordinates *CW->x and *CW->y. If it
1173 does, return W in *CW->window, as Lisp_Object, and return in
1174 *CW->part the part of the window under coordinates *X,*Y. Return
1175 zero from this function to stop iterating over windows. */
1177 struct check_window_data
1179 Lisp_Object
*window
;
1181 enum window_part
*part
;
1185 check_window_containing (struct window
*w
, void *user_data
)
1187 struct check_window_data
*cw
= (struct check_window_data
*) user_data
;
1188 enum window_part found
;
1191 found
= coordinates_in_window (w
, cw
->x
, cw
->y
);
1192 if (found
!= ON_NOTHING
)
1195 XSETWINDOW (*cw
->window
, w
);
1203 /* Find the window containing frame-relative pixel position X/Y and
1204 return it as a Lisp_Object.
1206 If X, Y is on one of the window's special `window_part' elements,
1207 set *PART to the id of that element.
1209 If there is no window under X, Y return nil and leave *PART
1210 unmodified. TOOL_BAR_P non-zero means detect tool-bar windows.
1212 This function was previously implemented with a loop cycling over
1213 windows with Fnext_window, and starting with the frame's selected
1214 window. It turned out that this doesn't work with an
1215 implementation of next_window using Vwindow_list, because
1216 FRAME_SELECTED_WINDOW (F) is not always contained in the window
1217 tree of F when this function is called asynchronously from
1218 note_mouse_highlight. The original loop didn't terminate in this
1222 window_from_coordinates (struct frame
*f
, int x
, int y
,
1223 enum window_part
*part
, int tool_bar_p
)
1226 struct check_window_data cw
;
1227 enum window_part dummy
;
1233 cw
.window
= &window
, cw
.x
= x
, cw
.y
= y
; cw
.part
= part
;
1234 foreach_window (f
, check_window_containing
, &cw
);
1236 /* If not found above, see if it's in the tool bar window, if a tool
1240 && WINDOWP (f
->tool_bar_window
)
1241 && WINDOW_TOTAL_LINES (XWINDOW (f
->tool_bar_window
)) > 0
1242 && (coordinates_in_window (XWINDOW (f
->tool_bar_window
), x
, y
)
1246 window
= f
->tool_bar_window
;
1252 DEFUN ("window-at", Fwindow_at
, Swindow_at
, 2, 3, 0,
1253 doc
: /* Return window containing coordinates X and Y on FRAME.
1254 FRAME must be a live frame and defaults to the selected one.
1255 The top left corner of the frame is considered to be row 0,
1257 (Lisp_Object x
, Lisp_Object y
, Lisp_Object frame
)
1262 frame
= selected_frame
;
1263 CHECK_LIVE_FRAME (frame
);
1266 /* Check that arguments are integers or floats. */
1267 CHECK_NUMBER_OR_FLOAT (x
);
1268 CHECK_NUMBER_OR_FLOAT (y
);
1270 return window_from_coordinates (f
,
1271 (FRAME_PIXEL_X_FROM_CANON_X (f
, x
)
1272 + FRAME_INTERNAL_BORDER_WIDTH (f
)),
1273 (FRAME_PIXEL_Y_FROM_CANON_Y (f
, y
)
1274 + FRAME_INTERNAL_BORDER_WIDTH (f
)),
1278 DEFUN ("window-point", Fwindow_point
, Swindow_point
, 0, 1, 0,
1279 doc
: /* Return current value of point in WINDOW.
1280 WINDOW must be a live window and defaults to the selected one.
1282 For a nonselected window, this is the value point would have
1283 if that window were selected.
1285 Note that, when WINDOW is the selected window and its buffer
1286 is also currently selected, the value returned is the same as (point).
1287 It would be more strictly correct to return the `top-level' value
1288 of point, outside of any save-excursion forms.
1289 But that is hard to define. */)
1290 (Lisp_Object window
)
1292 register struct window
*w
= decode_window (window
);
1294 if (w
== XWINDOW (selected_window
)
1295 && current_buffer
== XBUFFER (w
->buffer
))
1297 return Fmarker_position (w
->pointm
);
1300 DEFUN ("window-start", Fwindow_start
, Swindow_start
, 0, 1, 0,
1301 doc
: /* Return position at which display currently starts in WINDOW.
1302 WINDOW must be a live window and defaults to the selected one.
1303 This is updated by redisplay or by calling `set-window-start'. */)
1304 (Lisp_Object window
)
1306 return Fmarker_position (decode_window (window
)->start
);
1309 /* This is text temporarily removed from the doc string below.
1311 This function returns nil if the position is not currently known.
1312 That happens when redisplay is preempted and doesn't finish.
1313 If in that case you want to compute where the end of the window would
1314 have been if redisplay had finished, do this:
1316 (goto-char (window-start window))
1317 (vertical-motion (1- (window-height window)) window)
1320 DEFUN ("window-end", Fwindow_end
, Swindow_end
, 0, 2, 0,
1321 doc
: /* Return position at which display currently ends in WINDOW.
1322 WINDOW must be a live window and defaults to the selected one.
1323 This is updated by redisplay, when it runs to completion.
1324 Simply changing the buffer text or setting `window-start'
1325 does not update this value.
1326 Return nil if there is no recorded value. \(This can happen if the
1327 last redisplay of WINDOW was preempted, and did not finish.)
1328 If UPDATE is non-nil, compute the up-to-date position
1329 if it isn't already recorded. */)
1330 (Lisp_Object window
, Lisp_Object update
)
1333 struct window
*w
= decode_window (window
);
1341 #if 0 /* This change broke some things. We should make it later. */
1342 /* If we don't know the end position, return nil.
1343 The user can compute it with vertical-motion if he wants to.
1344 It would be nicer to do it automatically,
1345 but that's so slow that it would probably bother people. */
1346 if (NILP (w
->window_end_valid
))
1351 && ! (! NILP (w
->window_end_valid
)
1352 && XFASTINT (w
->last_modified
) >= BUF_MODIFF (b
)
1353 && XFASTINT (w
->last_overlay_modified
) >= BUF_OVERLAY_MODIFF (b
))
1356 struct text_pos startp
;
1358 struct buffer
*old_buffer
= NULL
;
1360 /* Cannot use Fvertical_motion because that function doesn't
1361 cope with variable-height lines. */
1362 if (b
!= current_buffer
)
1364 old_buffer
= current_buffer
;
1365 set_buffer_internal (b
);
1368 /* In case W->start is out of the range, use something
1369 reasonable. This situation occurred when loading a file with
1370 `-l' containing a call to `rmail' with subsequent other
1371 commands. At the end, W->start happened to be BEG, while
1372 rmail had already narrowed the buffer. */
1373 if (XMARKER (w
->start
)->charpos
< BEGV
)
1374 SET_TEXT_POS (startp
, BEGV
, BEGV_BYTE
);
1375 else if (XMARKER (w
->start
)->charpos
> ZV
)
1376 SET_TEXT_POS (startp
, ZV
, ZV_BYTE
);
1378 SET_TEXT_POS_FROM_MARKER (startp
, w
->start
);
1380 start_display (&it
, w
, startp
);
1381 move_it_vertically (&it
, window_box_height (w
));
1382 if (it
.current_y
< it
.last_visible_y
)
1383 move_it_past_eol (&it
);
1384 value
= make_number (IT_CHARPOS (it
));
1387 set_buffer_internal (old_buffer
);
1390 XSETINT (value
, BUF_Z (b
) - XFASTINT (w
->window_end_pos
));
1395 DEFUN ("set-window-point", Fset_window_point
, Sset_window_point
, 2, 2, 0,
1396 doc
: /* Make point value in WINDOW be at position POS in WINDOW's buffer.
1398 (Lisp_Object window
, Lisp_Object pos
)
1400 register struct window
*w
= decode_window (window
);
1402 CHECK_NUMBER_COERCE_MARKER (pos
);
1403 if (w
== XWINDOW (selected_window
)
1404 && XBUFFER (w
->buffer
) == current_buffer
)
1407 set_marker_restricted (w
->pointm
, pos
, w
->buffer
);
1409 /* We have to make sure that redisplay updates the window to show
1410 the new value of point. */
1411 if (!EQ (window
, selected_window
))
1412 ++windows_or_buffers_changed
;
1417 DEFUN ("set-window-start", Fset_window_start
, Sset_window_start
, 2, 3, 0,
1418 doc
: /* Make display in WINDOW start at position POS in WINDOW's buffer.
1419 WINDOW defaults to the selected window. Return POS.
1420 Optional third arg NOFORCE non-nil inhibits next redisplay from
1421 overriding motion of point in order to display at this exact start. */)
1422 (Lisp_Object window
, Lisp_Object pos
, Lisp_Object noforce
)
1424 register struct window
*w
= decode_window (window
);
1426 CHECK_NUMBER_COERCE_MARKER (pos
);
1427 set_marker_restricted (w
->start
, pos
, w
->buffer
);
1428 /* this is not right, but much easier than doing what is right. */
1429 w
->start_at_line_beg
= Qnil
;
1431 w
->force_start
= Qt
;
1432 w
->update_mode_line
= Qt
;
1433 XSETFASTINT (w
->last_modified
, 0);
1434 XSETFASTINT (w
->last_overlay_modified
, 0);
1435 if (!EQ (window
, selected_window
))
1436 windows_or_buffers_changed
++;
1441 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p
,
1442 Spos_visible_in_window_p
, 0, 3, 0,
1443 doc
: /* Return non-nil if position POS is currently on the frame in WINDOW.
1444 Return nil if that position is scrolled vertically out of view.
1445 If a character is only partially visible, nil is returned, unless the
1446 optional argument PARTIALLY is non-nil.
1447 If POS is only out of view because of horizontal scrolling, return non-nil.
1448 If POS is t, it specifies the position of the last visible glyph in WINDOW.
1449 POS defaults to point in WINDOW; WINDOW defaults to the selected window.
1451 If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil,
1452 return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]),
1453 where X and Y are the pixel coordinates relative to the top left corner
1454 of the window. The remaining elements are omitted if the character after
1455 POS is fully visible; otherwise, RTOP and RBOT are the number of pixels
1456 off-window at the top and bottom of the row, ROWH is the height of the
1457 display row, and VPOS is the row number (0-based) containing POS. */)
1458 (Lisp_Object pos
, Lisp_Object window
, Lisp_Object partially
)
1460 register struct window
*w
;
1461 register EMACS_INT posint
;
1462 register struct buffer
*buf
;
1463 struct text_pos top
;
1464 Lisp_Object in_window
= Qnil
;
1465 int rtop
, rbot
, rowh
, vpos
, fully_p
= 1;
1468 w
= decode_window (window
);
1469 buf
= XBUFFER (w
->buffer
);
1470 SET_TEXT_POS_FROM_MARKER (top
, w
->start
);
1474 else if (!NILP (pos
))
1476 CHECK_NUMBER_COERCE_MARKER (pos
);
1477 posint
= XINT (pos
);
1479 else if (w
== XWINDOW (selected_window
))
1482 posint
= XMARKER (w
->pointm
)->charpos
;
1484 /* If position is above window start or outside buffer boundaries,
1485 or if window start is out of range, position is not visible. */
1487 || (posint
>= CHARPOS (top
) && posint
<= BUF_ZV (buf
)))
1488 && CHARPOS (top
) >= BUF_BEGV (buf
)
1489 && CHARPOS (top
) <= BUF_ZV (buf
)
1490 && pos_visible_p (w
, posint
, &x
, &y
, &rtop
, &rbot
, &rowh
, &vpos
)
1491 && (fully_p
= !rtop
&& !rbot
, (!NILP (partially
) || fully_p
)))
1494 if (!NILP (in_window
) && !NILP (partially
))
1496 Lisp_Object part
= Qnil
;
1498 part
= list4 (make_number (rtop
), make_number (rbot
),
1499 make_number (rowh
), make_number (vpos
));
1500 in_window
= Fcons (make_number (x
),
1501 Fcons (make_number (y
), part
));
1507 DEFUN ("window-line-height", Fwindow_line_height
,
1508 Swindow_line_height
, 0, 2, 0,
1509 doc
: /* Return height in pixels of text line LINE in window WINDOW.
1510 WINDOW defaults to the selected window.
1512 Return height of current line if LINE is omitted or nil. Return height of
1513 header or mode line if LINE is `header-line' or `mode-line'.
1514 Otherwise, LINE is a text line number starting from 0. A negative number
1515 counts from the end of the window.
1517 Value is a list (HEIGHT VPOS YPOS OFFBOT), where HEIGHT is the height
1518 in pixels of the visible part of the line, VPOS and YPOS are the
1519 vertical position in lines and pixels of the line, relative to the top
1520 of the first text line, and OFFBOT is the number of off-window pixels at
1521 the bottom of the text line. If there are off-window pixels at the top
1522 of the (first) text line, YPOS is negative.
1524 Return nil if window display is not up-to-date. In that case, use
1525 `pos-visible-in-window-p' to obtain the information. */)
1526 (Lisp_Object line
, Lisp_Object window
)
1528 register struct window
*w
;
1529 register struct buffer
*b
;
1530 struct glyph_row
*row
, *end_row
;
1531 int max_y
, crop
, i
, n
;
1533 w
= decode_window (window
);
1535 if (noninteractive
|| w
->pseudo_window_p
)
1538 CHECK_BUFFER (w
->buffer
);
1539 b
= XBUFFER (w
->buffer
);
1541 /* Fail if current matrix is not up-to-date. */
1542 if (NILP (w
->window_end_valid
)
1543 || current_buffer
->clip_changed
1544 || current_buffer
->prevent_redisplay_optimizations_p
1545 || XFASTINT (w
->last_modified
) < BUF_MODIFF (b
)
1546 || XFASTINT (w
->last_overlay_modified
) < BUF_OVERLAY_MODIFF (b
))
1552 if (i
< 0 || i
>= w
->current_matrix
->nrows
1553 || (row
= MATRIX_ROW (w
->current_matrix
, i
), !row
->enabled_p
))
1555 max_y
= window_text_bottom_y (w
);
1559 if (EQ (line
, Qheader_line
))
1561 if (!WINDOW_WANTS_HEADER_LINE_P (w
))
1563 row
= MATRIX_HEADER_LINE_ROW (w
->current_matrix
);
1564 if (!row
->enabled_p
)
1566 return list4 (make_number (row
->height
),
1567 make_number (0), make_number (0),
1571 if (EQ (line
, Qmode_line
))
1573 row
= MATRIX_MODE_LINE_ROW (w
->current_matrix
);
1574 if (!row
->enabled_p
)
1576 return list4 (make_number (row
->height
),
1577 make_number (0), /* not accurate */
1578 make_number (WINDOW_HEADER_LINE_HEIGHT (w
)
1579 + window_text_bottom_y (w
)),
1583 CHECK_NUMBER (line
);
1586 row
= MATRIX_FIRST_TEXT_ROW (w
->current_matrix
);
1587 end_row
= MATRIX_BOTTOM_TEXT_ROW (w
->current_matrix
, w
);
1588 max_y
= window_text_bottom_y (w
);
1591 while ((n
< 0 || i
< n
)
1592 && row
<= end_row
&& row
->enabled_p
1593 && row
->y
+ row
->height
< max_y
)
1596 if (row
> end_row
|| !row
->enabled_p
)
1608 crop
= max (0, (row
->y
+ row
->height
) - max_y
);
1609 return list4 (make_number (row
->height
+ min (0, row
->y
) - crop
),
1611 make_number (row
->y
),
1612 make_number (crop
));
1615 DEFUN ("window-dedicated-p", Fwindow_dedicated_p
, Swindow_dedicated_p
,
1617 doc
: /* Return non-nil when WINDOW is dedicated to its buffer.
1618 More precisely, return the value assigned by the last call of
1619 `set-window-dedicated-p' for WINDOW. Return nil if that function was
1620 never called with WINDOW as its argument, or the value set by that
1621 function was internally reset since its last call. WINDOW defaults to
1622 the selected window.
1624 When a window is dedicated to its buffer, `display-buffer' will refrain
1625 from displaying another buffer in it. `get-lru-window' and
1626 `get-largest-window' treat dedicated windows specially.
1627 `delete-windows-on', `replace-buffer-in-windows', `quit-window' and
1628 `kill-buffer' can delete a dedicated window and the containing frame.
1630 Functions like `set-window-buffer' may change the buffer displayed by a
1631 window, unless that window is "strongly" dedicated to its buffer, that
1632 is the value returned by `window-dedicated-p' is t. */)
1633 (Lisp_Object window
)
1635 return decode_window (window
)->dedicated
;
1638 DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p
,
1639 Sset_window_dedicated_p
, 2, 2, 0,
1640 doc
: /* Mark WINDOW as dedicated according to FLAG.
1641 WINDOW must be a live window and defaults to the selected one. FLAG
1642 non-nil means mark WINDOW as dedicated to its buffer. FLAG nil means
1643 mark WINDOW as non-dedicated. Return FLAG.
1645 When a window is dedicated to its buffer, `display-buffer' will refrain
1646 from displaying another buffer in it. `get-lru-window' and
1647 `get-largest-window' treat dedicated windows specially.
1648 `delete-windows-on', `replace-buffer-in-windows', `quit-window',
1649 `quit-restore-window' and `kill-buffer' can delete a dedicated window
1650 and the containing frame.
1652 As a special case, if FLAG is t, mark WINDOW as "strongly" dedicated to
1653 its buffer. Functions like `set-window-buffer' may change the buffer
1654 displayed by a window, unless that window is strongly dedicated to its
1655 buffer. If and when `set-window-buffer' displays another buffer in a
1656 window, it also makes sure that the window is no more dedicated. */)
1657 (Lisp_Object window
, Lisp_Object flag
)
1659 register struct window
*w
= decode_window (window
);
1661 w
->dedicated
= flag
;
1662 return w
->dedicated
;
1665 DEFUN ("window-prev-buffers", Fwindow_prev_buffers
, Swindow_prev_buffers
,
1667 doc
: /* Return buffers previously shown in WINDOW.
1668 WINDOW must be a live window and defaults to the selected one.
1670 The return value is either nil or a list of <buffer, window-start,
1671 window-point> triples where buffer was previously shown in WINDOW. */)
1672 (Lisp_Object window
)
1674 return decode_window (window
)->prev_buffers
;
1677 DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers
,
1678 Sset_window_prev_buffers
, 2, 2, 0,
1679 doc
: /* Set WINDOW's previous buffers to PREV-BUFFERS.
1680 WINDOW must be a live window and defaults to the selected one. Return
1683 PREV-BUFFERS should be either nil or a list of <buffer, window-start,
1684 window-point> triples where buffer was previously shown in WINDOW. */)
1685 (Lisp_Object window
, Lisp_Object prev_buffers
)
1687 return decode_any_window (window
)->prev_buffers
= prev_buffers
;
1690 DEFUN ("window-next-buffers", Fwindow_next_buffers
, Swindow_next_buffers
,
1692 doc
: /* Return list of buffers recently re-shown in WINDOW.
1693 WINDOW must be a live window and defaults to the selected one. */)
1694 (Lisp_Object window
)
1696 return decode_window (window
)->next_buffers
;
1699 DEFUN ("set-window-next-buffers", Fset_window_next_buffers
,
1700 Sset_window_next_buffers
, 2, 2, 0,
1701 doc
: /* Set WINDOW's next buffers to NEXT-BUFFERS.
1702 WINDOW must be a live window and defaults to the selected one. Return
1705 NEXT-BUFFERS should be either nil or a list of buffers that have been
1706 recently re-shown in WINDOW. */)
1707 (Lisp_Object window
, Lisp_Object next_buffers
)
1709 return decode_any_window (window
)->next_buffers
= next_buffers
;
1712 DEFUN ("window-parameters", Fwindow_parameters
, Swindow_parameters
,
1714 doc
: /* Return the parameters of WINDOW and their values.
1715 WINDOW defaults to the selected window. The return value is a list of
1716 elements of the form (PARAMETER . VALUE). */)
1717 (Lisp_Object window
)
1719 return Fcopy_alist (decode_any_window (window
)->window_parameters
);
1722 DEFUN ("window-parameter", Fwindow_parameter
, Swindow_parameter
,
1724 doc
: /* Return WINDOW's value for PARAMETER.
1725 WINDOW defaults to the selected window. */)
1726 (Lisp_Object window
, Lisp_Object parameter
)
1730 result
= Fassq (parameter
, decode_any_window (window
)->window_parameters
);
1731 return CDR_SAFE (result
);
1734 DEFUN ("set-window-parameter", Fset_window_parameter
,
1735 Sset_window_parameter
, 3, 3, 0,
1736 doc
: /* Set WINDOW's value of PARAMETER to VALUE.
1737 WINDOW defaults to the selected window. Return VALUE. */)
1738 (Lisp_Object window
, Lisp_Object parameter
, Lisp_Object value
)
1740 register struct window
*w
= decode_any_window (window
);
1741 Lisp_Object old_alist_elt
;
1743 old_alist_elt
= Fassq (parameter
, w
->window_parameters
);
1744 if (NILP (old_alist_elt
))
1745 w
->window_parameters
= Fcons (Fcons (parameter
, value
), w
->window_parameters
);
1747 Fsetcdr (old_alist_elt
, value
);
1751 DEFUN ("window-display-table", Fwindow_display_table
, Swindow_display_table
,
1753 doc
: /* Return the display-table that WINDOW is using.
1754 WINDOW defaults to the selected window. */)
1755 (Lisp_Object window
)
1757 return decode_window (window
)->display_table
;
1760 /* Get the display table for use on window W. This is either W's
1761 display table or W's buffer's display table. Ignore the specified
1762 tables if they are not valid; if no valid table is specified,
1765 struct Lisp_Char_Table
*
1766 window_display_table (struct window
*w
)
1768 struct Lisp_Char_Table
*dp
= NULL
;
1770 if (DISP_TABLE_P (w
->display_table
))
1771 dp
= XCHAR_TABLE (w
->display_table
);
1772 else if (BUFFERP (w
->buffer
))
1774 struct buffer
*b
= XBUFFER (w
->buffer
);
1776 if (DISP_TABLE_P (BVAR (b
, display_table
)))
1777 dp
= XCHAR_TABLE (BVAR (b
, display_table
));
1778 else if (DISP_TABLE_P (Vstandard_display_table
))
1779 dp
= XCHAR_TABLE (Vstandard_display_table
);
1785 DEFUN ("set-window-display-table", Fset_window_display_table
, Sset_window_display_table
, 2, 2, 0,
1786 doc
: /* Set WINDOW's display-table to TABLE. */)
1787 (register Lisp_Object window
, Lisp_Object table
)
1789 register struct window
*w
;
1791 w
= decode_window (window
);
1792 w
->display_table
= table
;
1796 /* Record info on buffer window W is displaying
1797 when it is about to cease to display that buffer. */
1799 unshow_buffer (register struct window
*w
)
1806 if (b
!= XMARKER (w
->pointm
)->buffer
)
1810 if (w
== XWINDOW (selected_window
)
1811 || ! EQ (buf
, XWINDOW (selected_window
)->buffer
))
1812 /* Do this except when the selected window's buffer
1813 is being removed from some other window. */
1815 /* last_window_start records the start position that this buffer
1816 had in the last window to be disconnected from it.
1817 Now that this statement is unconditional,
1818 it is possible for the buffer to be displayed in the
1819 selected window, while last_window_start reflects another
1820 window which was recently showing the same buffer.
1821 Some people might say that might be a good thing. Let's see. */
1822 b
->last_window_start
= marker_position (w
->start
);
1824 /* Point in the selected window's buffer
1825 is actually stored in that buffer, and the window's pointm isn't used.
1826 So don't clobber point in that buffer. */
1827 if (! EQ (buf
, XWINDOW (selected_window
)->buffer
)
1828 /* This line helps to fix Horsley's testbug.el bug. */
1829 && !(WINDOWP (BVAR (b
, last_selected_window
))
1830 && w
!= XWINDOW (BVAR (b
, last_selected_window
))
1831 && EQ (buf
, XWINDOW (BVAR (b
, last_selected_window
))->buffer
)))
1832 temp_set_point_both (b
,
1833 clip_to_bounds (BUF_BEGV (b
),
1834 XMARKER (w
->pointm
)->charpos
,
1836 clip_to_bounds (BUF_BEGV_BYTE (b
),
1837 marker_byte_position (w
->pointm
),
1840 if (WINDOWP (BVAR (b
, last_selected_window
))
1841 && w
== XWINDOW (BVAR (b
, last_selected_window
)))
1842 BVAR (b
, last_selected_window
) = Qnil
;
1845 /* Put NEW into the window structure in place of OLD. SETFLAG zero
1846 means change window structure only. Otherwise store geometry and
1847 other settings as well. */
1849 replace_window (Lisp_Object old
, Lisp_Object
new, int setflag
)
1851 register Lisp_Object tem
;
1852 register struct window
*o
= XWINDOW (old
), *n
= XWINDOW (new);
1854 /* If OLD is its frame's root window, then NEW is the new
1855 root window for that frame. */
1856 if (EQ (old
, FRAME_ROOT_WINDOW (XFRAME (o
->frame
))))
1857 FRAME_ROOT_WINDOW (XFRAME (o
->frame
)) = new;
1861 n
->left_col
= o
->left_col
;
1862 n
->top_line
= o
->top_line
;
1863 n
->total_cols
= o
->total_cols
;
1864 n
->total_lines
= o
->total_lines
;
1865 n
->normal_cols
= o
->normal_cols
;
1866 o
->normal_cols
= make_float (1.0);
1867 n
->normal_lines
= o
->normal_lines
;
1868 o
->normal_lines
= make_float (1.0);
1869 n
->desired_matrix
= n
->current_matrix
= 0;
1871 memset (&n
->cursor
, 0, sizeof (n
->cursor
));
1872 memset (&n
->last_cursor
, 0, sizeof (n
->last_cursor
));
1873 memset (&n
->phys_cursor
, 0, sizeof (n
->phys_cursor
));
1874 n
->phys_cursor_type
= -1;
1875 n
->phys_cursor_width
= -1;
1876 n
->must_be_updated_p
= 0;
1877 n
->pseudo_window_p
= 0;
1878 XSETFASTINT (n
->window_end_vpos
, 0);
1879 XSETFASTINT (n
->window_end_pos
, 0);
1880 n
->window_end_valid
= Qnil
;
1881 n
->frozen_window_start_p
= 0;
1884 n
->next
= tem
= o
->next
;
1886 XWINDOW (tem
)->prev
= new;
1888 n
->prev
= tem
= o
->prev
;
1890 XWINDOW (tem
)->next
= new;
1892 n
->parent
= tem
= o
->parent
;
1895 if (EQ (XWINDOW (tem
)->vchild
, old
))
1896 XWINDOW (tem
)->vchild
= new;
1897 if (EQ (XWINDOW (tem
)->hchild
, old
))
1898 XWINDOW (tem
)->hchild
= new;
1902 /* If window WINDOW and its parent window are iso-combined, merge
1903 WINDOW's children into those of its parent window and mark WINDOW as
1907 recombine_windows (Lisp_Object window
)
1909 struct window
*w
, *p
, *c
;
1910 Lisp_Object parent
, child
;
1913 w
= XWINDOW (window
);
1915 if (!NILP (parent
) && NILP (w
->nest
))
1917 p
= XWINDOW (parent
);
1918 if (((!NILP (p
->vchild
) && !NILP (w
->vchild
))
1919 || (!NILP (p
->hchild
) && !NILP (w
->hchild
))))
1920 /* WINDOW and PARENT are both either a vertical or a horizontal
1923 horflag
= NILP (w
->vchild
);
1924 child
= horflag
? w
->hchild
: w
->vchild
;
1925 c
= XWINDOW (child
);
1927 /* Splice WINDOW's children into its parent's children and
1928 assign new normal sizes. */
1937 XWINDOW (w
->prev
)->next
= child
;
1946 = make_float (XFLOATINT (c
->total_cols
)
1947 / XFLOATINT (p
->total_cols
));
1950 = make_float (XFLOATINT (c
->total_lines
)
1951 / XFLOATINT (p
->total_lines
));
1955 if (!NILP (w
->next
))
1958 XWINDOW (c
->next
)->prev
= child
;
1966 c
= XWINDOW (child
);
1970 /* WINDOW can be deleted now. */
1971 w
->vchild
= w
->hchild
= Qnil
;
1976 /***********************************************************************
1978 ***********************************************************************/
1980 /* Add window W to *USER_DATA. USER_DATA is actually a Lisp_Object
1981 pointer. This is a callback function for foreach_window, used in
1982 the window_list function. */
1985 add_window_to_list (struct window
*w
, void *user_data
)
1987 Lisp_Object
*list
= (Lisp_Object
*) user_data
;
1989 XSETWINDOW (window
, w
);
1990 *list
= Fcons (window
, *list
);
1995 /* Return a list of all windows, for use by next_window. If
1996 Vwindow_list is a list, return that list. Otherwise, build a new
1997 list, cache it in Vwindow_list, and return that. */
2002 if (!CONSP (Vwindow_list
))
2006 Vwindow_list
= Qnil
;
2007 for (tail
= Vframe_list
; CONSP (tail
); tail
= XCDR (tail
))
2009 Lisp_Object args
[2];
2011 /* We are visiting windows in canonical order, and add
2012 new windows at the front of args[1], which means we
2013 have to reverse this list at the end. */
2015 foreach_window (XFRAME (XCAR (tail
)), add_window_to_list
, &args
[1]);
2016 args
[0] = Vwindow_list
;
2017 args
[1] = Fnreverse (args
[1]);
2018 Vwindow_list
= Fnconc (2, args
);
2022 return Vwindow_list
;
2026 /* Value is non-zero if WINDOW satisfies the constraints given by
2027 OWINDOW, MINIBUF and ALL_FRAMES.
2029 MINIBUF t means WINDOW may be minibuffer windows.
2030 `lambda' means WINDOW may not be a minibuffer window.
2031 a window means a specific minibuffer window
2033 ALL_FRAMES t means search all frames,
2034 nil means search just current frame,
2035 `visible' means search just visible frames on the
2037 0 means search visible and iconified frames on the
2039 a window means search the frame that window belongs to,
2040 a frame means consider windows on that frame, only. */
2043 candidate_window_p (Lisp_Object window
, Lisp_Object owindow
, Lisp_Object minibuf
, Lisp_Object all_frames
)
2045 struct window
*w
= XWINDOW (window
);
2046 struct frame
*f
= XFRAME (w
->frame
);
2047 int candidate_p
= 1;
2049 if (!BUFFERP (w
->buffer
))
2051 else if (MINI_WINDOW_P (w
)
2052 && (EQ (minibuf
, Qlambda
)
2053 || (WINDOWP (minibuf
) && !EQ (minibuf
, window
))))
2055 /* If MINIBUF is `lambda' don't consider any mini-windows.
2056 If it is a window, consider only that one. */
2059 else if (EQ (all_frames
, Qt
))
2061 else if (NILP (all_frames
))
2063 xassert (WINDOWP (owindow
));
2064 candidate_p
= EQ (w
->frame
, XWINDOW (owindow
)->frame
);
2066 else if (EQ (all_frames
, Qvisible
))
2068 FRAME_SAMPLE_VISIBILITY (f
);
2069 candidate_p
= FRAME_VISIBLE_P (f
)
2070 && (FRAME_TERMINAL (XFRAME (w
->frame
))
2071 == FRAME_TERMINAL (XFRAME (selected_frame
)));
2074 else if (INTEGERP (all_frames
) && XINT (all_frames
) == 0)
2076 FRAME_SAMPLE_VISIBILITY (f
);
2077 candidate_p
= (FRAME_VISIBLE_P (f
) || FRAME_ICONIFIED_P (f
)
2078 #ifdef HAVE_X_WINDOWS
2079 /* Yuck!! If we've just created the frame and the
2080 window-manager requested the user to place it
2081 manually, the window may still not be considered
2082 `visible'. I'd argue it should be at least
2083 something like `iconified', but don't know how to do
2085 || (FRAME_X_P (f
) && f
->output_data
.x
->asked_for_visible
2086 && !f
->output_data
.x
->has_been_visible
)
2089 && (FRAME_TERMINAL (XFRAME (w
->frame
))
2090 == FRAME_TERMINAL (XFRAME (selected_frame
)));
2092 else if (WINDOWP (all_frames
))
2093 candidate_p
= (EQ (FRAME_MINIBUF_WINDOW (f
), all_frames
)
2094 || EQ (XWINDOW (all_frames
)->frame
, w
->frame
)
2095 || EQ (XWINDOW (all_frames
)->frame
, FRAME_FOCUS_FRAME (f
)));
2096 else if (FRAMEP (all_frames
))
2097 candidate_p
= EQ (all_frames
, w
->frame
);
2103 /* Decode arguments as allowed by Fnext_window, Fprevious_window, and
2104 Fwindow_list. See candidate_window_p for the meaning of WINDOW,
2105 MINIBUF, and ALL_FRAMES. */
2108 decode_next_window_args (Lisp_Object
*window
, Lisp_Object
*minibuf
, Lisp_Object
*all_frames
)
2111 *window
= selected_window
;
2113 CHECK_LIVE_WINDOW (*window
);
2115 /* MINIBUF nil may or may not include minibuffers. Decide if it
2117 if (NILP (*minibuf
))
2118 *minibuf
= minibuf_level
? minibuf_window
: Qlambda
;
2119 else if (!EQ (*minibuf
, Qt
))
2122 /* Now *MINIBUF can be t => count all minibuffer windows, `lambda'
2123 => count none of them, or a specific minibuffer window (the
2124 active one) to count. */
2126 /* ALL_FRAMES nil doesn't specify which frames to include. */
2127 if (NILP (*all_frames
))
2128 *all_frames
= (!EQ (*minibuf
, Qlambda
)
2129 ? FRAME_MINIBUF_WINDOW (XFRAME (XWINDOW (*window
)->frame
))
2131 else if (EQ (*all_frames
, Qvisible
))
2133 else if (EQ (*all_frames
, make_number (0)))
2135 else if (FRAMEP (*all_frames
))
2137 else if (!EQ (*all_frames
, Qt
))
2142 /* Return the next or previous window of WINDOW in cyclic ordering
2143 of windows. NEXT_P non-zero means return the next window. See the
2144 documentation string of next-window for the meaning of MINIBUF and
2148 next_window (Lisp_Object window
, Lisp_Object minibuf
, Lisp_Object all_frames
, int next_p
)
2150 decode_next_window_args (&window
, &minibuf
, &all_frames
);
2152 /* If ALL_FRAMES is a frame, and WINDOW isn't on that frame, just
2153 return the first window on the frame. */
2154 if (FRAMEP (all_frames
)
2155 && !EQ (all_frames
, XWINDOW (window
)->frame
))
2156 return Fframe_first_window (all_frames
);
2162 /* Find WINDOW in the list of all windows. */
2163 list
= Fmemq (window
, window_list ());
2165 /* Scan forward from WINDOW to the end of the window list. */
2167 for (list
= XCDR (list
); CONSP (list
); list
= XCDR (list
))
2168 if (candidate_window_p (XCAR (list
), window
, minibuf
, all_frames
))
2171 /* Scan from the start of the window list up to WINDOW. */
2173 for (list
= Vwindow_list
;
2174 CONSP (list
) && !EQ (XCAR (list
), window
);
2176 if (candidate_window_p (XCAR (list
), window
, minibuf
, all_frames
))
2180 window
= XCAR (list
);
2184 Lisp_Object candidate
, list
;
2186 /* Scan through the list of windows for candidates. If there are
2187 candidate windows in front of WINDOW, the last one of these
2188 is the one we want. If there are candidates following WINDOW
2189 in the list, again the last one of these is the one we want. */
2191 for (list
= window_list (); CONSP (list
); list
= XCDR (list
))
2193 if (EQ (XCAR (list
), window
))
2195 if (WINDOWP (candidate
))
2198 else if (candidate_window_p (XCAR (list
), window
, minibuf
,
2200 candidate
= XCAR (list
);
2203 if (WINDOWP (candidate
))
2211 DEFUN ("next-window", Fnext_window
, Snext_window
, 0, 3, 0,
2212 doc
: /* Return window following WINDOW in cyclic ordering of windows.
2213 WINDOW defaults to the selected window. The optional arguments
2214 MINIBUF and ALL-FRAMES specify the set of windows to consider.
2216 MINIBUF t means consider the minibuffer window even if the
2217 minibuffer is not active. MINIBUF nil or omitted means consider
2218 the minibuffer window only if the minibuffer is active. Any
2219 other value means do not consider the minibuffer window even if
2220 the minibuffer is active.
2222 Several frames may share a single minibuffer; if the minibuffer
2223 is active, all windows on all frames that share that minibuffer
2224 are considered too. Therefore, if you are using a separate
2225 minibuffer frame and the minibuffer is active and MINIBUF says it
2226 counts, `next-window' considers the windows in the frame from
2227 which you entered the minibuffer, as well as the minibuffer
2230 ALL-FRAMES nil or omitted means consider all windows on WINDOW's
2231 frame, plus the minibuffer window if specified by the MINIBUF
2232 argument, see above. If the minibuffer counts, consider all
2233 windows on all frames that share that minibuffer too.
2234 ALL-FRAMES t means consider all windows on all existing frames.
2235 ALL-FRAMES `visible' means consider all windows on all visible
2236 frames on the current terminal.
2237 ALL-FRAMES 0 means consider all windows on all visible and
2238 iconified frames on the current terminal.
2239 ALL-FRAMES a frame means consider all windows on that frame only.
2240 Anything else means consider all windows on WINDOW's frame and no
2243 If you use consistent values for MINIBUF and ALL-FRAMES, you can use
2244 `next-window' to iterate through the entire cycle of acceptable
2245 windows, eventually ending up back at the window you started with.
2246 `previous-window' traverses the same cycle, in the reverse order. */)
2247 (Lisp_Object window
, Lisp_Object minibuf
, Lisp_Object all_frames
)
2249 return next_window (window
, minibuf
, all_frames
, 1);
2253 DEFUN ("previous-window", Fprevious_window
, Sprevious_window
, 0, 3, 0,
2254 doc
: /* Return window preceding WINDOW in cyclic ordering of windows.
2255 WINDOW defaults to the selected window. The optional arguments
2256 MINIBUF and ALL-FRAMES specify the set of windows to consider.
2257 For the precise meaning of these arguments see `next-window'.
2259 If you use consistent values for MINIBUF and ALL-FRAMES, you can
2260 use `previous-window' to iterate through the entire cycle of
2261 acceptable windows, eventually ending up back at the window you
2262 started with. `next-window' traverses the same cycle, in the
2264 (Lisp_Object window
, Lisp_Object minibuf
, Lisp_Object all_frames
)
2266 return next_window (window
, minibuf
, all_frames
, 0);
2270 DEFUN ("other-window", Fother_window
, Sother_window
, 1, 2, "p",
2271 doc
: /* Select another window in cyclic ordering of windows.
2272 COUNT specifies the number of windows to skip, starting with the
2273 selected window, before making the selection. If COUNT is
2274 positive, skip COUNT windows forwards. If COUNT is negative,
2275 skip -COUNT windows backwards. COUNT zero means do not skip any
2276 window, so select the selected window. In an interactive call,
2277 COUNT is the numeric prefix argument. Return nil.
2279 This function uses `next-window' for finding the window to select.
2280 The argument ALL-FRAMES has the same meaning as in `next-window',
2281 but the MINIBUF argument of `next-window' is always effectively
2283 (Lisp_Object count
, Lisp_Object all_frames
)
2288 CHECK_NUMBER (count
);
2289 window
= selected_window
;
2291 for (i
= XINT (count
); i
> 0; --i
)
2292 window
= Fnext_window (window
, Qnil
, all_frames
);
2294 window
= Fprevious_window (window
, Qnil
, all_frames
);
2296 Fselect_window (window
, Qnil
);
2301 /* Return a list of windows in cyclic ordering. Arguments are like
2302 for `next-window'. */
2305 window_list_1 (Lisp_Object window
, Lisp_Object minibuf
, Lisp_Object all_frames
)
2307 Lisp_Object tail
, list
, rest
;
2309 decode_next_window_args (&window
, &minibuf
, &all_frames
);
2312 for (tail
= window_list (); CONSP (tail
); tail
= XCDR (tail
))
2313 if (candidate_window_p (XCAR (tail
), window
, minibuf
, all_frames
))
2314 list
= Fcons (XCAR (tail
), list
);
2316 /* Rotate the list to start with WINDOW. */
2317 list
= Fnreverse (list
);
2318 rest
= Fmemq (window
, list
);
2319 if (!NILP (rest
) && !EQ (rest
, list
))
2321 for (tail
= list
; !EQ (XCDR (tail
), rest
); tail
= XCDR (tail
))
2323 XSETCDR (tail
, Qnil
);
2324 list
= nconc2 (rest
, list
);
2330 DEFUN ("window-list", Fwindow_list
, Swindow_list
, 0, 3, 0,
2331 doc
: /* Return a list of windows on FRAME, starting with WINDOW.
2332 FRAME nil or omitted means use the selected frame.
2333 WINDOW nil or omitted means use the selected window.
2334 MINIBUF t means include the minibuffer window, even if it isn't active.
2335 MINIBUF nil or omitted means include the minibuffer window only
2337 MINIBUF neither nil nor t means never include the minibuffer window. */)
2338 (Lisp_Object frame
, Lisp_Object minibuf
, Lisp_Object window
)
2341 window
= FRAMEP (frame
) ? XFRAME (frame
)->selected_window
: selected_window
;
2342 CHECK_WINDOW (window
);
2344 frame
= selected_frame
;
2346 if (!EQ (frame
, XWINDOW (window
)->frame
))
2347 error ("Window is on a different frame");
2349 return window_list_1 (window
, minibuf
, frame
);
2353 DEFUN ("window-list-1", Fwindow_list_1
, Swindow_list_1
, 0, 3, 0,
2354 doc
: /* Return a list of all live windows.
2355 WINDOW specifies the first window to list and defaults to the selected
2358 Optional argument MINIBUF nil or omitted means consider the minibuffer
2359 window only if the minibuffer is active. MINIBUF t means consider the
2360 minibuffer window even if the minibuffer is not active. Any other value
2361 means do not consider the minibuffer window even if the minibuffer is
2364 Optional argument ALL-FRAMES nil or omitted means consider all windows
2365 on WINDOW's frame, plus the minibuffer window if specified by the
2366 MINIBUF argument. If the minibuffer counts, consider all windows on all
2367 frames that share that minibuffer too. The following non-nil values of
2368 ALL-FRAMES have special meanings:
2370 - t means consider all windows on all existing frames.
2372 - `visible' means consider all windows on all visible frames.
2374 - 0 (the number zero) means consider all windows on all visible and
2377 - A frame means consider all windows on that frame only.
2379 Anything else means consider all windows on WINDOW's frame and no
2382 If WINDOW is not on the list of windows returned, some other window will
2383 be listed first but no error is signalled. */)
2384 (Lisp_Object window
, Lisp_Object minibuf
, Lisp_Object all_frames
)
2386 return window_list_1 (window
, minibuf
, all_frames
);
2389 /* Look at all windows, performing an operation specified by TYPE
2391 If FRAMES is Qt, look at all frames;
2392 Qnil, look at just the selected frame;
2393 Qvisible, look at visible frames;
2394 a frame, just look at windows on that frame.
2395 If MINI is non-zero, perform the operation on minibuffer windows too. */
2400 GET_BUFFER_WINDOW
, /* Arg is buffer */
2401 DELETE_BUFFER_WINDOWS
, /* Arg is buffer */
2402 UNSHOW_BUFFER
, /* Arg is buffer */
2403 REDISPLAY_BUFFER_WINDOWS
, /* Arg is buffer */
2408 window_loop (enum window_loop type
, Lisp_Object obj
, int mini
, Lisp_Object frames
)
2410 Lisp_Object window
, windows
, best_window
, frame_arg
;
2412 struct gcpro gcpro1
;
2414 /* If we're only looping through windows on a particular frame,
2415 frame points to that frame. If we're looping through windows
2416 on all frames, frame is 0. */
2417 if (FRAMEP (frames
))
2418 f
= XFRAME (frames
);
2419 else if (NILP (frames
))
2420 f
= SELECTED_FRAME ();
2425 frame_arg
= Qlambda
;
2426 else if (EQ (frames
, make_number (0)))
2428 else if (EQ (frames
, Qvisible
))
2433 /* frame_arg is Qlambda to stick to one frame,
2434 Qvisible to consider all visible frames,
2437 /* Pick a window to start with. */
2441 window
= FRAME_SELECTED_WINDOW (f
);
2443 window
= FRAME_SELECTED_WINDOW (SELECTED_FRAME ());
2445 windows
= window_list_1 (window
, mini
? Qt
: Qnil
, frame_arg
);
2449 for (; CONSP (windows
); windows
= XCDR (windows
))
2453 window
= XCAR (windows
);
2454 w
= XWINDOW (window
);
2456 /* Note that we do not pay attention here to whether the frame
2457 is visible, since Fwindow_list skips non-visible frames if
2458 that is desired, under the control of frame_arg. */
2459 if (!MINI_WINDOW_P (w
)
2460 /* For UNSHOW_BUFFER, we must always consider all windows. */
2461 || type
== UNSHOW_BUFFER
2462 || (mini
&& minibuf_level
> 0))
2465 case GET_BUFFER_WINDOW
:
2466 if (EQ (w
->buffer
, obj
)
2467 /* Don't find any minibuffer window
2468 except the one that is currently in use. */
2469 && (MINI_WINDOW_P (w
)
2470 ? EQ (window
, minibuf_window
)
2473 if (NILP (best_window
))
2474 best_window
= window
;
2475 else if (EQ (window
, selected_window
))
2476 /* Prefer to return selected-window. */
2477 RETURN_UNGCPRO (window
);
2478 else if (EQ (Fwindow_frame (window
), selected_frame
))
2479 /* Prefer windows on the current frame. */
2480 best_window
= window
;
2484 case DELETE_BUFFER_WINDOWS
:
2485 if (EQ (w
->buffer
, obj
))
2487 struct frame
*fr
= XFRAME (WINDOW_FRAME (w
));
2489 /* If this window is dedicated, and in a frame of its own,
2491 if (EQ (window
, FRAME_ROOT_WINDOW (fr
))
2492 && !NILP (w
->dedicated
)
2493 && other_visible_frames (fr
))
2495 /* Skip the other windows on this frame.
2496 There might be one, the minibuffer! */
2497 while (CONSP (XCDR (windows
))
2498 && EQ (XWINDOW (XCAR (windows
))->frame
,
2499 XWINDOW (XCAR (XCDR (windows
)))->frame
))
2500 windows
= XCDR (windows
);
2502 /* Now we can safely delete the frame. */
2503 delete_frame (w
->frame
, Qnil
);
2505 else if (NILP (w
->parent
))
2507 /* If we're deleting the buffer displayed in the
2508 only window on the frame, find a new buffer to
2511 buffer
= Fother_buffer (obj
, Qnil
, w
->frame
);
2512 /* Reset dedicated state of window. */
2513 w
->dedicated
= Qnil
;
2514 Fset_window_buffer (window
, buffer
, Qnil
);
2515 if (EQ (window
, selected_window
))
2516 Fset_buffer (w
->buffer
);
2519 call1 (Qdelete_window
, window
);
2524 if (EQ (w
->buffer
, obj
))
2527 struct frame
*fr
= XFRAME (w
->frame
);
2529 /* Find another buffer to show in this window. */
2530 buffer
= Fother_buffer (obj
, Qnil
, w
->frame
);
2532 /* If this window is dedicated, and in a frame of its own,
2534 if (EQ (window
, FRAME_ROOT_WINDOW (fr
))
2535 && !NILP (w
->dedicated
)
2536 && other_visible_frames (fr
))
2538 /* Skip the other windows on this frame.
2539 There might be one, the minibuffer! */
2540 while (CONSP (XCDR (windows
))
2541 && EQ (XWINDOW (XCAR (windows
))->frame
,
2542 XWINDOW (XCAR (XCDR (windows
)))->frame
))
2543 windows
= XCDR (windows
);
2545 /* Now we can safely delete the frame. */
2546 delete_frame (w
->frame
, Qnil
);
2548 else if (!NILP (w
->dedicated
) && !NILP (w
->parent
))
2550 Lisp_Object window_to_delete
;
2551 XSETWINDOW (window_to_delete
, w
);
2552 /* If this window is dedicated and not the only window
2553 in its frame, then kill it. */
2554 call1 (Qdelete_window
, window_to_delete
);
2558 /* Otherwise show a different buffer in the window. */
2559 w
->dedicated
= Qnil
;
2560 Fset_window_buffer (window
, buffer
, Qnil
);
2561 if (EQ (window
, selected_window
))
2562 Fset_buffer (w
->buffer
);
2567 case REDISPLAY_BUFFER_WINDOWS
:
2568 if (EQ (w
->buffer
, obj
))
2570 mark_window_display_accurate (window
, 0);
2571 w
->update_mode_line
= Qt
;
2572 XBUFFER (obj
)->prevent_redisplay_optimizations_p
= 1;
2573 ++update_mode_lines
;
2574 best_window
= window
;
2578 /* Check for a window that has a killed buffer. */
2579 case CHECK_ALL_WINDOWS
:
2580 if (! NILP (w
->buffer
)
2581 && NILP (BVAR (XBUFFER (w
->buffer
), name
)))
2585 case WINDOW_LOOP_UNUSED
:
2594 /* Used for debugging. Abort if any window has a dead buffer. */
2596 extern void check_all_windows (void) EXTERNALLY_VISIBLE
;
2598 check_all_windows (void)
2600 window_loop (CHECK_ALL_WINDOWS
, Qnil
, 1, Qt
);
2603 DEFUN ("get-buffer-window", Fget_buffer_window
, Sget_buffer_window
, 0, 2, 0,
2604 doc
: /* Return a window currently displaying BUFFER-OR-NAME, or nil if none.
2605 BUFFER-OR-NAME may be a buffer or a buffer name and defaults to
2608 The optional argument ALL-FRAMES specifies the frames to consider:
2610 - t means consider all windows on all existing frames.
2612 - `visible' means consider all windows on all visible frames.
2614 - 0 (the number zero) means consider all windows on all visible
2615 and iconified frames.
2617 - A frame means consider all windows on that frame only.
2619 Any other value of ALL-FRAMES means consider all windows on the
2620 selected frame and no others. */)
2621 (Lisp_Object buffer_or_name
, Lisp_Object all_frames
)
2625 if (NILP (buffer_or_name
))
2626 buffer
= Fcurrent_buffer ();
2628 buffer
= Fget_buffer (buffer_or_name
);
2630 if (BUFFERP (buffer
))
2631 return window_loop (GET_BUFFER_WINDOW
, buffer
, 1, all_frames
);
2637 resize_root_window (Lisp_Object window
, Lisp_Object delta
, Lisp_Object horizontal
, Lisp_Object ignore
)
2639 return call4 (Qresize_root_window
, window
, delta
, horizontal
, ignore
);
2643 DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal
,
2644 Sdelete_other_windows_internal
, 0, 2, "",
2645 doc
: /* Make WINDOW fill its frame.
2646 Only the frame WINDOW is on is affected. WINDOW may be any window and
2647 defaults to the selected one.
2649 Optional argument ROOT, if non-nil, must specify an internal window
2650 containing WINDOW as a subwindow. If this is the case, replace ROOT by
2651 WINDOW and leave alone any windows not contained in ROOT.
2653 When WINDOW is live try to reduce display jumps by keeping the text
2654 previously visible in WINDOW in the same place on the frame. Doing this
2655 depends on the value of (window-start WINDOW), so if calling this
2656 function in a program gives strange scrolling, make sure the
2657 window-start value is reasonable when this function is called. */)
2658 (Lisp_Object window
, Lisp_Object root
)
2660 struct window
*w
, *r
, *s
;
2662 Lisp_Object sibling
, pwindow
, swindow
IF_LINT (= Qnil
), delta
;
2663 EMACS_INT startpos
IF_LINT (= 0);
2664 int top
IF_LINT (= 0), new_top
, resize_failed
;
2666 w
= decode_any_window (window
);
2667 XSETWINDOW (window
, w
);
2668 f
= XFRAME (w
->frame
);
2671 /* ROOT is the frame's root window. */
2673 root
= FRAME_ROOT_WINDOW (f
);
2677 /* ROOT must be an ancestor of WINDOW. */
2679 r
= decode_any_window (root
);
2680 pwindow
= XWINDOW (window
)->parent
;
2681 while (!NILP (pwindow
))
2682 if (EQ (pwindow
, root
))
2685 pwindow
= XWINDOW (pwindow
)->parent
;
2686 if (!EQ (pwindow
, root
))
2687 error ("Specified root is not an ancestor of specified window");
2690 if (EQ (window
, root
))
2693 /* I don't understand the "top > 0" part below. If we deal with a
2694 standalone minibuffer it would have been caught by the preceding
2696 else if (MINI_WINDOW_P (w
)) /* && top > 0) */
2697 error ("Can't expand minibuffer to full frame");
2699 if (!NILP (w
->buffer
))
2701 startpos
= marker_position (w
->start
);
2702 top
= WINDOW_TOP_EDGE_LINE (w
)
2703 - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w
)));
2704 /* Make sure WINDOW is the frame's selected window. */
2705 if (!EQ (window
, FRAME_SELECTED_WINDOW (f
)))
2707 if (EQ (selected_frame
, w
->frame
))
2708 Fselect_window (window
, Qnil
);
2710 FRAME_SELECTED_WINDOW (f
) = window
;
2715 /* See if the frame's selected window is a subwindow of WINDOW, by
2716 finding all the selected window's parents and comparing each
2717 one with WINDOW. If it isn't we need a new selected window for
2719 swindow
= FRAME_SELECTED_WINDOW (f
);
2723 while (!NILP (pwindow
) && !EQ (window
, pwindow
))
2724 pwindow
= XWINDOW (pwindow
)->parent
;
2726 if (EQ (window
, pwindow
))
2727 /* If WINDOW is an ancestor of SWINDOW, then SWINDOW is ok
2728 as the new selected window. */
2731 /* Else try the previous window of SWINDOW. */
2732 swindow
= Fprevious_window (swindow
, Qlambda
, Qnil
);
2735 if (!EQ (swindow
, FRAME_SELECTED_WINDOW (f
)))
2737 if (EQ (selected_frame
, w
->frame
))
2738 Fselect_window (swindow
, Qnil
);
2740 FRAME_SELECTED_WINDOW (f
) = swindow
;
2745 free_window_matrices (r
);
2747 windows_or_buffers_changed
++;
2748 Vwindow_list
= Qnil
;
2749 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
2752 if (NILP (w
->buffer
))
2754 /* Resize subwindows vertically. */
2755 XSETINT (delta
, XINT (r
->total_lines
) - XINT (w
->total_lines
));
2756 w
->top_line
= r
->top_line
;
2757 resize_root_window (window
, delta
, Qnil
, Qnil
);
2758 if (resize_window_check (w
, 0))
2759 resize_window_apply (w
, 0);
2762 resize_root_window (window
, delta
, Qnil
, Qt
);
2763 if (resize_window_check (w
, 0))
2764 resize_window_apply (w
, 0);
2769 /* Resize subwindows horizontally. */
2772 w
->left_col
= r
->left_col
;
2773 XSETINT (delta
, XINT (r
->total_cols
) - XINT (w
->total_cols
));
2774 w
->left_col
= r
->left_col
;
2775 resize_root_window (window
, delta
, Qt
, Qnil
);
2776 if (resize_window_check (w
, 1))
2777 resize_window_apply (w
, 1);
2780 resize_root_window (window
, delta
, Qt
, Qt
);
2781 if (resize_window_check (w
, 1))
2782 resize_window_apply (w
, 1);
2789 /* Play safe, if we still can ... */
2792 w
= XWINDOW (window
);
2796 /* Cleanly unlink WINDOW from window-tree. */
2797 if (!NILP (w
->prev
))
2798 /* Get SIBLING above (on the left of) WINDOW. */
2801 s
= XWINDOW (sibling
);
2803 if (!NILP (s
->next
))
2804 XWINDOW (s
->next
)->prev
= sibling
;
2807 /* Get SIBLING below (on the right of) WINDOW. */
2810 s
= XWINDOW (sibling
);
2812 if (!NILP (XWINDOW (w
->parent
)->vchild
))
2813 XWINDOW (w
->parent
)->vchild
= sibling
;
2815 XWINDOW (w
->parent
)->hchild
= sibling
;
2818 /* Delete ROOT and all subwindows of ROOT. */
2819 if (!NILP (r
->vchild
))
2821 delete_all_subwindows (r
->vchild
);
2824 else if (!NILP (r
->hchild
))
2826 delete_all_subwindows (r
->hchild
);
2830 replace_window (root
, window
, 1);
2832 /* Reset WINDOW's splits status. */
2835 /* This must become SWINDOW anyway ....... */
2836 if (!NILP (w
->buffer
) && !resize_failed
)
2838 /* Try to minimize scrolling, by setting the window start to the
2839 point will cause the text at the old window start to be at the
2840 same place on the frame. But don't try to do this if the
2841 window start is outside the visible portion (as might happen
2842 when the display is not current, due to typeahead). */
2843 new_top
= WINDOW_TOP_EDGE_LINE (w
) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w
)));
2845 && startpos
>= BUF_BEGV (XBUFFER (w
->buffer
))
2846 && startpos
<= BUF_ZV (XBUFFER (w
->buffer
)))
2848 struct position pos
;
2849 struct buffer
*obuf
= current_buffer
;
2851 Fset_buffer (w
->buffer
);
2852 /* This computation used to temporarily move point, but that
2853 can have unwanted side effects due to text properties. */
2854 pos
= *vmotion (startpos
, -top
, w
);
2856 set_marker_both (w
->start
, w
->buffer
, pos
.bufpos
, pos
.bytepos
);
2857 w
->window_end_valid
= Qnil
;
2858 w
->start_at_line_beg
= ((pos
.bytepos
== BEGV_BYTE
2859 || FETCH_BYTE (pos
.bytepos
- 1) == '\n') ? Qt
2861 /* We need to do this, so that the window-scroll-functions
2863 w
->optional_new_start
= Qt
;
2865 set_buffer_internal (obuf
);
2872 run_window_configuration_change_hook (f
);
2878 DEFUN ("delete-windows-on", Fdelete_windows_on
, Sdelete_windows_on
,
2879 0, 2, "bDelete windows on (buffer): ",
2880 doc
: /* Delete all windows showing BUFFER-OR-NAME.
2881 BUFFER-OR-NAME may be a buffer or the name of an existing buffer and
2882 defaults to the current buffer.
2884 Optional second argument FRAME controls which frames are affected.
2885 If optional argument FRAME is `visible', search all visible frames.
2886 If FRAME is 0, search all visible and iconified frames.
2887 If FRAME is nil, search all frames.
2888 If FRAME is t, search only the selected frame.
2889 If FRAME is a frame, search only that frame.
2890 When a window showing BUFFER-OR-NAME is dedicated and the only window of
2891 its frame, that frame is deleted when there are other frames left. */)
2892 (Lisp_Object buffer_or_name
, Lisp_Object frame
)
2896 /* FRAME uses t and nil to mean the opposite of what window_loop
2900 else if (EQ (frame
, Qt
))
2903 if (NILP (buffer_or_name
))
2904 buffer
= Fcurrent_buffer ();
2907 buffer
= Fget_buffer (buffer_or_name
);
2908 CHECK_BUFFER (buffer
);
2911 window_loop (DELETE_BUFFER_WINDOWS
, buffer
, 0, frame
);
2916 DEFUN ("replace-buffer-in-windows", Freplace_buffer_in_windows
,
2917 Sreplace_buffer_in_windows
,
2918 0, 1, "bReplace buffer in windows: ",
2919 doc
: /* Replace BUFFER-OR-NAME with some other buffer in all windows showing it.
2920 BUFFER-OR-NAME may be a buffer or the name of an existing buffer and
2921 defaults to the current buffer.
2923 When a window showing BUFFER-OR-NAME is dedicated that window is
2924 deleted. If that window is the only window on its frame, that frame is
2925 deleted too when there are other frames left. If there are no other
2926 frames left, some other buffer is displayed in that window. */)
2927 (Lisp_Object buffer_or_name
)
2931 if (NILP (buffer_or_name
))
2932 buffer
= Fcurrent_buffer ();
2935 buffer
= Fget_buffer (buffer_or_name
);
2936 CHECK_BUFFER (buffer
);
2939 window_loop (UNSHOW_BUFFER
, buffer
, 0, Qt
);
2944 /* Replace BUFFER with some other buffer in all windows
2945 of all frames, even those on other keyboards. */
2948 replace_buffer_in_all_windows (Lisp_Object buffer
)
2950 Lisp_Object tail
, frame
;
2952 /* A single call to window_loop won't do the job
2953 because it only considers frames on the current keyboard.
2954 So loop manually over frames, and handle each one. */
2955 FOR_EACH_FRAME (tail
, frame
)
2956 window_loop (UNSHOW_BUFFER
, buffer
, 1, frame
);
2959 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
2960 minimum allowable size. */
2963 check_frame_size (FRAME_PTR frame
, int *rows
, int *cols
)
2965 /* For height, we have to see:
2966 how many windows the frame has at minimum (one or two),
2967 and whether it has a menu bar or other special stuff at the top. */
2969 = ((FRAME_MINIBUF_ONLY_P (frame
) || ! FRAME_HAS_MINIBUF_P (frame
))
2970 ? MIN_SAFE_WINDOW_HEIGHT
2971 : 2 * MIN_SAFE_WINDOW_HEIGHT
);
2973 if (FRAME_TOP_MARGIN (frame
) > 0)
2974 min_height
+= FRAME_TOP_MARGIN (frame
);
2976 if (*rows
< min_height
)
2978 if (*cols
< MIN_SAFE_WINDOW_WIDTH
)
2979 *cols
= MIN_SAFE_WINDOW_WIDTH
;
2982 /* Adjust the margins of window W if text area is too small.
2983 Return 1 if window width is ok after adjustment; 0 if window
2984 is still too narrow. */
2987 adjust_window_margins (struct window
*w
)
2989 int box_cols
= (WINDOW_TOTAL_COLS (w
)
2990 - WINDOW_FRINGE_COLS (w
)
2991 - WINDOW_SCROLL_BAR_COLS (w
));
2992 int margin_cols
= (WINDOW_LEFT_MARGIN_COLS (w
)
2993 + WINDOW_RIGHT_MARGIN_COLS (w
));
2995 if (box_cols
- margin_cols
>= MIN_SAFE_WINDOW_WIDTH
)
2998 if (margin_cols
< 0 || box_cols
< MIN_SAFE_WINDOW_WIDTH
)
3001 /* Window's text area is too narrow, but reducing the window
3002 margins will fix that. */
3003 margin_cols
= box_cols
- MIN_SAFE_WINDOW_WIDTH
;
3004 if (WINDOW_RIGHT_MARGIN_COLS (w
) > 0)
3006 if (WINDOW_LEFT_MARGIN_COLS (w
) > 0)
3007 w
->left_margin_cols
= w
->right_margin_cols
3008 = make_number (margin_cols
/2);
3010 w
->right_margin_cols
= make_number (margin_cols
);
3013 w
->left_margin_cols
= make_number (margin_cols
);
3017 int window_select_count
;
3019 static Lisp_Object
Fset_window_margins (Lisp_Object
, Lisp_Object
, Lisp_Object
);
3020 static Lisp_Object
Fset_window_fringes (Lisp_Object
, Lisp_Object
, Lisp_Object
,
3022 static Lisp_Object
Fset_window_scroll_bars (Lisp_Object
, Lisp_Object
,
3023 Lisp_Object
, Lisp_Object
);
3024 static Lisp_Object
Fset_window_vscroll (Lisp_Object
, Lisp_Object
, Lisp_Object
);
3027 run_funs (Lisp_Object funs
)
3029 for (; CONSP (funs
); funs
= XCDR (funs
))
3030 if (!EQ (XCAR (funs
), Qt
))
3031 call0 (XCAR (funs
));
3034 static Lisp_Object
select_window_norecord (Lisp_Object window
);
3035 static Lisp_Object
select_frame_norecord (Lisp_Object frame
);
3038 run_window_configuration_change_hook (struct frame
*f
)
3040 int count
= SPECPDL_INDEX ();
3041 Lisp_Object frame
, global_wcch
3042 = Fdefault_value (Qwindow_configuration_change_hook
);
3043 XSETFRAME (frame
, f
);
3045 if (NILP (Vrun_hooks
))
3048 /* Use the right buffer. Matters when running the local hooks. */
3049 if (current_buffer
!= XBUFFER (Fwindow_buffer (Qnil
)))
3051 record_unwind_protect (Fset_buffer
, Fcurrent_buffer ());
3052 Fset_buffer (Fwindow_buffer (Qnil
));
3055 if (SELECTED_FRAME () != f
)
3057 record_unwind_protect (select_frame_norecord
, Fselected_frame ());
3058 select_frame_norecord (frame
);
3061 /* Look for buffer-local values. */
3063 Lisp_Object windows
= Fwindow_list (frame
, Qlambda
, Qnil
);
3064 for (; CONSP (windows
); windows
= XCDR (windows
))
3066 Lisp_Object window
= XCAR (windows
);
3067 Lisp_Object buffer
= Fwindow_buffer (window
);
3068 if (!NILP (Flocal_variable_p (Qwindow_configuration_change_hook
,
3071 int inner_count
= SPECPDL_INDEX ();
3072 record_unwind_protect (select_window_norecord
, Fselected_window ());
3073 select_window_norecord (window
);
3074 run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook
,
3076 unbind_to (inner_count
, Qnil
);
3081 run_funs (global_wcch
);
3082 unbind_to (count
, Qnil
);
3085 DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook
,
3086 Srun_window_configuration_change_hook
, 1, 1, 0,
3087 doc
: /* Run `window-configuration-change-hook' for FRAME. */)
3090 CHECK_LIVE_FRAME (frame
);
3091 run_window_configuration_change_hook (XFRAME (frame
));
3095 /* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero
3096 means it's allowed to run hooks. See make_frame for a case where
3097 it's not allowed. KEEP_MARGINS_P non-zero means that the current
3098 margins, fringes, and scroll-bar settings of the window are not
3099 reset from the buffer's local settings. */
3102 set_window_buffer (Lisp_Object window
, Lisp_Object buffer
, int run_hooks_p
, int keep_margins_p
)
3104 struct window
*w
= XWINDOW (window
);
3105 struct buffer
*b
= XBUFFER (buffer
);
3106 int count
= SPECPDL_INDEX ();
3107 int samebuf
= EQ (buffer
, w
->buffer
);
3111 if (EQ (window
, selected_window
))
3112 BVAR (b
, last_selected_window
) = window
;
3114 /* Let redisplay errors through. */
3115 b
->display_error_modiff
= 0;
3117 /* Update time stamps of buffer display. */
3118 if (INTEGERP (BVAR (b
, display_count
)))
3119 XSETINT (BVAR (b
, display_count
), XINT (BVAR (b
, display_count
)) + 1);
3120 BVAR (b
, display_time
) = Fcurrent_time ();
3122 XSETFASTINT (w
->window_end_pos
, 0);
3123 XSETFASTINT (w
->window_end_vpos
, 0);
3124 memset (&w
->last_cursor
, 0, sizeof w
->last_cursor
);
3125 w
->window_end_valid
= Qnil
;
3126 if (!(keep_margins_p
&& samebuf
))
3127 { /* If we're not actually changing the buffer, don't reset hscroll and
3128 vscroll. This case happens for example when called from
3129 change_frame_size_1, where we use a dummy call to
3130 Fset_window_buffer on the frame's selected window (and no other)
3131 just in order to run window-configuration-change-hook.
3132 Resetting hscroll and vscroll here is problematic for things like
3133 image-mode and doc-view-mode since it resets the image's position
3134 whenever we resize the frame. */
3135 w
->hscroll
= w
->min_hscroll
= make_number (0);
3137 set_marker_both (w
->pointm
, buffer
, BUF_PT (b
), BUF_PT_BYTE (b
));
3138 set_marker_restricted (w
->start
,
3139 make_number (b
->last_window_start
),
3141 w
->start_at_line_beg
= Qnil
;
3142 w
->force_start
= Qnil
;
3143 XSETFASTINT (w
->last_modified
, 0);
3144 XSETFASTINT (w
->last_overlay_modified
, 0);
3146 /* Maybe we could move this into the `if' but it's not obviously safe and
3147 I doubt it's worth the trouble. */
3148 windows_or_buffers_changed
++;
3150 /* We must select BUFFER for running the window-scroll-functions. */
3151 /* We can't check ! NILP (Vwindow_scroll_functions) here
3152 because that might itself be a local variable. */
3153 if (window_initialized
)
3155 record_unwind_protect (Fset_buffer
, Fcurrent_buffer ());
3156 Fset_buffer (buffer
);
3159 XMARKER (w
->pointm
)->insertion_type
= !NILP (Vwindow_point_insertion_type
);
3161 if (!keep_margins_p
)
3163 /* Set left and right marginal area width etc. from buffer. */
3165 /* This may call adjust_window_margins three times, so
3166 temporarily disable window margins. */
3167 Lisp_Object save_left
= w
->left_margin_cols
;
3168 Lisp_Object save_right
= w
->right_margin_cols
;
3170 w
->left_margin_cols
= w
->right_margin_cols
= Qnil
;
3172 Fset_window_fringes (window
,
3173 BVAR (b
, left_fringe_width
), BVAR (b
, right_fringe_width
),
3174 BVAR (b
, fringes_outside_margins
));
3176 Fset_window_scroll_bars (window
,
3177 BVAR (b
, scroll_bar_width
),
3178 BVAR (b
, vertical_scroll_bar_type
), Qnil
);
3180 w
->left_margin_cols
= save_left
;
3181 w
->right_margin_cols
= save_right
;
3183 Fset_window_margins (window
,
3184 BVAR (b
, left_margin_cols
), BVAR (b
, right_margin_cols
));
3189 if (! NILP (Vwindow_scroll_functions
))
3190 run_hook_with_args_2 (Qwindow_scroll_functions
, window
,
3191 Fmarker_position (w
->start
));
3192 run_window_configuration_change_hook (XFRAME (WINDOW_FRAME (w
)));
3195 unbind_to (count
, Qnil
);
3198 DEFUN ("set-window-clone-number", Fset_window_clone_number
, Sset_window_clone_number
, 2, 2, 0,
3199 doc
: /* Set WINDOW's clone number to CLONE-NUMBER.
3200 WINDOW can be any window and defaults to the selected one. */)
3201 (Lisp_Object window
, Lisp_Object clone_number
)
3203 register struct window
*w
= decode_any_window (window
);
3205 CHECK_NUMBER (clone_number
);
3206 w
->clone_number
= clone_number
;
3207 return w
->clone_number
;
3210 DEFUN ("set-window-buffer", Fset_window_buffer
, Sset_window_buffer
, 2, 3, 0,
3211 doc
: /* Make WINDOW display BUFFER-OR-NAME as its contents.
3212 WINDOW defaults to the selected window. BUFFER-OR-NAME must be a buffer
3213 or the name of an existing buffer. Optional third argument KEEP-MARGINS
3214 non-nil means that WINDOW's current display margins, fringe widths, and
3215 scroll bar settings are preserved; the default is to reset these from
3216 the local settings for BUFFER-OR-NAME or the frame defaults. Return nil.
3218 This function throws an error when WINDOW is strongly dedicated to its
3219 buffer (that is `window-dedicated-p' returns t for WINDOW) and does not
3220 already display BUFFER-OR-NAME.
3222 This function runs `window-scroll-functions' before running
3223 `window-configuration-change-hook'. */)
3224 (register Lisp_Object window
, Lisp_Object buffer_or_name
, Lisp_Object keep_margins
)
3226 register Lisp_Object tem
, buffer
;
3227 register struct window
*w
= decode_window (window
);
3229 XSETWINDOW (window
, w
);
3230 buffer
= Fget_buffer (buffer_or_name
);
3231 CHECK_BUFFER (buffer
);
3232 if (NILP (BVAR (XBUFFER (buffer
), name
)))
3233 error ("Attempt to display deleted buffer");
3237 error ("Window is deleted");
3238 else if (!EQ (tem
, Qt
))
3239 /* w->buffer is t when the window is first being set up. */
3241 if (EQ (tem
, buffer
))
3243 else if (EQ (w
->dedicated
, Qt
))
3244 error ("Window is dedicated to `%s'", SDATA (BVAR (XBUFFER (tem
), name
)));
3246 w
->dedicated
= Qnil
;
3251 set_window_buffer (window
, buffer
, 1, !NILP (keep_margins
));
3256 select_window_norecord (Lisp_Object window
)
3258 return WINDOW_LIVE_P (window
)
3259 ? Fselect_window (window
, Qt
) : selected_window
;
3263 select_frame_norecord (Lisp_Object frame
)
3265 return FRAME_LIVE_P (XFRAME (frame
))
3266 ? Fselect_frame (frame
, Qt
) : selected_frame
;
3270 display_buffer (Lisp_Object buffer
, Lisp_Object not_this_window_p
, Lisp_Object override_frame
)
3272 return call3 (Qdisplay_buffer
, buffer
, not_this_window_p
, override_frame
);
3275 DEFUN ("force-window-update", Fforce_window_update
, Sforce_window_update
,
3277 doc
: /* Force all windows to be updated on next redisplay.
3278 If optional arg OBJECT is a window, force redisplay of that window only.
3279 If OBJECT is a buffer or buffer name, force redisplay of all windows
3280 displaying that buffer. */)
3281 (Lisp_Object object
)
3285 windows_or_buffers_changed
++;
3286 update_mode_lines
++;
3290 if (WINDOWP (object
))
3292 struct window
*w
= XWINDOW (object
);
3293 mark_window_display_accurate (object
, 0);
3294 w
->update_mode_line
= Qt
;
3295 if (BUFFERP (w
->buffer
))
3296 XBUFFER (w
->buffer
)->prevent_redisplay_optimizations_p
= 1;
3297 ++update_mode_lines
;
3301 if (STRINGP (object
))
3302 object
= Fget_buffer (object
);
3303 if (BUFFERP (object
) && !NILP (BVAR (XBUFFER (object
), name
)))
3305 /* Walk all windows looking for buffer, and force update
3306 of each of those windows. */
3308 object
= window_loop (REDISPLAY_BUFFER_WINDOWS
, object
, 0, Qvisible
);
3309 return NILP (object
) ? Qnil
: Qt
;
3312 /* If nothing suitable was found, just return.
3313 We could signal an error, but this feature will typically be used
3314 asynchronously in timers or process sentinels, so we don't. */
3320 temp_output_buffer_show (register Lisp_Object buf
)
3322 register struct buffer
*old
= current_buffer
;
3323 register Lisp_Object window
;
3324 register struct window
*w
;
3326 BVAR (XBUFFER (buf
), directory
) = BVAR (current_buffer
, directory
);
3329 BUF_SAVE_MODIFF (XBUFFER (buf
)) = MODIFF
;
3333 set_buffer_internal (old
);
3335 if (!NILP (Vtemp_buffer_show_function
))
3336 call1 (Vtemp_buffer_show_function
, buf
);
3339 window
= display_buffer (buf
, Qnil
, Qnil
);
3341 if (!EQ (XWINDOW (window
)->frame
, selected_frame
))
3342 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window
)));
3343 Vminibuf_scroll_window
= window
;
3344 w
= XWINDOW (window
);
3345 XSETFASTINT (w
->hscroll
, 0);
3346 XSETFASTINT (w
->min_hscroll
, 0);
3347 set_marker_restricted_both (w
->start
, buf
, BEG
, BEG
);
3348 set_marker_restricted_both (w
->pointm
, buf
, BEG
, BEG
);
3350 /* Run temp-buffer-show-hook, with the chosen window selected
3351 and its buffer current. */
3353 int count
= SPECPDL_INDEX ();
3354 Lisp_Object prev_window
, prev_buffer
;
3355 prev_window
= selected_window
;
3356 XSETBUFFER (prev_buffer
, old
);
3358 /* Select the window that was chosen, for running the hook.
3359 Note: Both Fselect_window and select_window_norecord may
3360 set-buffer to the buffer displayed in the window,
3361 so we need to save the current buffer. --stef */
3362 record_unwind_protect (Fset_buffer
, prev_buffer
);
3363 record_unwind_protect (select_window_norecord
, prev_window
);
3364 Fselect_window (window
, Qt
);
3365 Fset_buffer (w
->buffer
);
3366 Frun_hooks (1, &Qtemp_buffer_show_hook
);
3367 unbind_to (count
, Qnil
);
3372 DEFUN ("internal-temp-output-buffer-show",
3373 Ftemp_output_buffer_show
, Stemp_output_buffer_show
,
3375 doc
: /* Internal function for `with-output-to-temp-buffer''. */)
3378 temp_output_buffer_show (buf
);
3382 /* Make new window, have it replace WINDOW in window-tree, and make
3383 WINDOW its only vertical child (HORFLAG 1 means make WINDOW its only
3384 horizontal child). */
3386 make_parent_window (Lisp_Object window
, int horflag
)
3389 register struct window
*o
, *p
;
3392 o
= XWINDOW (window
);
3393 p
= allocate_window ();
3394 for (i
= 0; i
< VECSIZE (struct window
); ++i
)
3395 ((struct Lisp_Vector
*) p
)->contents
[i
]
3396 = ((struct Lisp_Vector
*) o
)->contents
[i
];
3397 XSETWINDOW (parent
, p
);
3400 XSETFASTINT (p
->sequence_number
, sequence_number
);
3401 XSETFASTINT (p
->clone_number
, sequence_number
);
3403 replace_window (window
, parent
, 1);
3409 p
->hchild
= horflag
? window
: Qnil
;
3410 p
->vchild
= horflag
? Qnil
: window
;
3416 p
->window_parameters
= Qnil
;
3419 /* Make new window from scratch. */
3424 register struct window
*w
;
3426 w
= allocate_window ();
3427 /* Initialize all Lisp data. */
3428 w
->frame
= w
->mini_p
= Qnil
;
3429 w
->next
= w
->prev
= w
->hchild
= w
->vchild
= w
->parent
= Qnil
;
3430 XSETFASTINT (w
->left_col
, 0);
3431 XSETFASTINT (w
->top_line
, 0);
3432 XSETFASTINT (w
->total_lines
, 0);
3433 XSETFASTINT (w
->total_cols
, 0);
3434 w
->normal_lines
= make_float (1.0);
3435 w
->normal_cols
= make_float (1.0);
3436 XSETFASTINT (w
->new_total
, 0);
3437 XSETFASTINT (w
->new_normal
, 0);
3439 w
->start
= Fmake_marker ();
3440 w
->pointm
= Fmake_marker ();
3441 w
->force_start
= w
->optional_new_start
= Qnil
;
3442 XSETFASTINT (w
->hscroll
, 0);
3443 XSETFASTINT (w
->min_hscroll
, 0);
3444 XSETFASTINT (w
->use_time
, 0);
3446 XSETFASTINT (w
->sequence_number
, sequence_number
);
3447 XSETFASTINT (w
->clone_number
, sequence_number
);
3448 w
->temslot
= w
->last_modified
= w
->last_overlay_modified
= Qnil
;
3449 XSETFASTINT (w
->last_point
, 0);
3450 w
->last_had_star
= w
->vertical_scroll_bar
= Qnil
;
3451 w
->left_margin_cols
= w
->right_margin_cols
= Qnil
;
3452 w
->left_fringe_width
= w
->right_fringe_width
= Qnil
;
3453 w
->fringes_outside_margins
= Qnil
;
3454 w
->scroll_bar_width
= Qnil
;
3455 w
->vertical_scroll_bar_type
= Qt
;
3456 w
->last_mark_x
= w
->last_mark_y
= Qnil
;
3457 XSETFASTINT (w
->window_end_pos
, 0);
3458 XSETFASTINT (w
->window_end_vpos
, 0);
3459 w
->window_end_valid
= w
->update_mode_line
= Qnil
;
3460 w
->start_at_line_beg
= w
->display_table
= w
->dedicated
= Qnil
;
3461 w
->base_line_number
= w
->base_line_pos
= w
->region_showing
= Qnil
;
3462 w
->column_number_displayed
= w
->redisplay_end_trigger
= Qnil
;
3463 w
->splits
= w
->nest
= w
->window_parameters
= Qnil
;
3464 w
->prev_buffers
= w
->next_buffers
= Qnil
;
3465 /* Initialize non-Lisp data. */
3466 w
->desired_matrix
= w
->current_matrix
= 0;
3467 w
->nrows_scale_factor
= w
->ncols_scale_factor
= 1;
3468 memset (&w
->cursor
, 0, sizeof (w
->cursor
));
3469 memset (&w
->last_cursor
, 0, sizeof (w
->last_cursor
));
3470 memset (&w
->phys_cursor
, 0, sizeof (w
->phys_cursor
));
3471 w
->phys_cursor_type
= -1;
3472 w
->phys_cursor_width
= -1;
3473 w
->last_cursor_off_p
= w
->cursor_off_p
= 0;
3474 w
->must_be_updated_p
= 0;
3475 w
->pseudo_window_p
= 0;
3476 w
->frozen_window_start_p
= 0;
3478 /* Reset window_list. */
3479 Vwindow_list
= Qnil
;
3480 /* Return window. */
3481 XSETWINDOW (window
, w
);
3485 DEFUN ("set-window-new-total", Fset_window_new_total
, Sset_window_new_total
, 2, 3, 0,
3486 doc
: /* Set new total size of WINDOW to SIZE.
3489 Optional argument ADD non-nil means add SIZE to the new total size of
3490 WINDOW and return the sum.
3492 Note: This function does not operate on any subwindows of WINDOW. */)
3493 (Lisp_Object window
, Lisp_Object size
, Lisp_Object add
)
3495 struct window
*w
= decode_any_window (window
);
3497 CHECK_NUMBER (size
);
3499 XSETINT (w
->new_total
, XINT (size
));
3501 XSETINT (w
->new_total
, XINT (w
->new_total
) + XINT (size
));
3503 return w
->new_total
;
3506 DEFUN ("set-window-new-normal", Fset_window_new_normal
, Sset_window_new_normal
, 1, 2, 0,
3507 doc
: /* Set new normal size of WINDOW to SIZE.
3510 Note: This function does not operate on any subwindows of WINDOW. */)
3511 (Lisp_Object window
, Lisp_Object size
)
3513 struct window
*w
= decode_any_window (window
);
3515 w
->new_normal
= size
;
3516 return w
->new_normal
;
3519 /* Return 1 if setting w->total_lines (w->total_cols if HORFLAG is
3520 non-zero) to w->new_total would result in correct heights (widths)
3521 for window W and recursively all subwindows of W.
3523 Note: This function does not check any of `window-fixed-size-p',
3524 `window-min-height' or `window-min-width'. It does check that window
3525 sizes do not drop below one line (two columns). */
3527 resize_window_check (struct window
*w
, int horflag
)
3531 if (!NILP (w
->vchild
))
3532 /* W is a vertical combination. */
3534 c
= XWINDOW (w
->vchild
);
3536 /* All subwindows of W must have the same width as W. */
3540 if ((XINT (c
->new_total
) != XINT (w
->new_total
))
3541 || !resize_window_check (c
, horflag
))
3543 c
= NILP (c
->next
) ? 0 : XWINDOW (c
->next
);
3548 /* The sum of the heights of the subwindows of W must equal W's
3551 int sum_of_sizes
= 0;
3554 if (!resize_window_check (c
, horflag
))
3556 sum_of_sizes
= sum_of_sizes
+ XINT (c
->new_total
);
3557 c
= NILP (c
->next
) ? 0 : XWINDOW (c
->next
);
3559 return (sum_of_sizes
== XINT (w
->new_total
));
3562 else if (!NILP (w
->hchild
))
3563 /* W is a horizontal combination. */
3565 c
= XWINDOW (w
->hchild
);
3567 /* The sum of the widths of the subwindows of W must equal W's
3570 int sum_of_sizes
= 0;
3573 if (!resize_window_check (c
, horflag
))
3575 sum_of_sizes
= sum_of_sizes
+ XINT (c
->new_total
);
3576 c
= NILP (c
->next
) ? 0 : XWINDOW (c
->next
);
3578 return (sum_of_sizes
== XINT (w
->new_total
));
3581 /* All subwindows of W must have the same height as W. */
3585 if ((XINT (c
->new_total
) != XINT (w
->new_total
))
3586 || !resize_window_check (c
, horflag
))
3588 c
= NILP (c
->next
) ? 0 : XWINDOW (c
->next
);
3594 /* A leaf window. Make sure it's not too small. The following
3595 hardcodes the values of `window-safe-min-width' (2) and
3596 `window-safe-min-height' (1) which are defined in window.el. */
3597 return XINT (w
->new_total
) >= (horflag
? 2 : 1);
3600 /* Set w->total_lines (w->total_cols if HORIZONTAL is non-zero) to
3601 w->new_total for window W and recursively all subwindows of W. Also
3602 calculate and assign the new vertical (horizontal) start positions of
3603 each of these windows.
3605 This function does not perform any error checks. Make sure you have
3606 run resize_window_check on W before applying this function. */
3608 resize_window_apply (struct window
*w
, int horflag
)
3613 /* Note: Assigning new_normal requires that the new total size of the
3614 parent window has been set *before*. */
3617 w
->total_cols
= w
->new_total
;
3618 if (NUMBERP (w
->new_normal
))
3619 w
->normal_cols
= w
->new_normal
;
3621 pos
= XINT (w
->left_col
);
3625 w
->total_lines
= w
->new_total
;
3626 if (NUMBERP (w
->new_normal
))
3627 w
->normal_lines
= w
->new_normal
;
3629 pos
= XINT (w
->top_line
);
3632 if (!NILP (w
->vchild
))
3633 /* W is a vertical combination. */
3635 c
= XWINDOW (w
->vchild
);
3639 XSETFASTINT (c
->left_col
, pos
);
3641 XSETFASTINT (c
->top_line
, pos
);
3642 resize_window_apply (c
, horflag
);
3644 pos
= pos
+ XINT (c
->total_lines
);
3645 c
= NILP (c
->next
) ? 0 : XWINDOW (c
->next
);
3648 else if (!NILP (w
->hchild
))
3649 /* W is a horizontal combination. */
3651 c
= XWINDOW (w
->hchild
);
3655 XSETFASTINT (c
->left_col
, pos
);
3657 XSETFASTINT (c
->top_line
, pos
);
3658 resize_window_apply (c
, horflag
);
3660 pos
= pos
+ XINT (c
->total_cols
);
3661 c
= NILP (c
->next
) ? 0 : XWINDOW (c
->next
);
3665 /* Clear out some redisplay caches. */
3666 XSETFASTINT (w
->last_modified
, 0);
3667 XSETFASTINT (w
->last_overlay_modified
, 0);
3671 DEFUN ("resize-window-apply", Fresize_window_apply
, Sresize_window_apply
, 1, 2, 0,
3672 doc
: /* Apply requested size values for window-tree of FRAME.
3673 Optional argument HORIZONTAL omitted or nil means apply requested height
3674 values. HORIZONTAL non-nil means apply requested width values.
3676 This function checks whether the requested values sum up to a valid
3677 window layout, recursively assigns the new sizes of all subwindows and
3678 calculates and assigns the new start positions of these windows.
3680 Note: This function does not check any of `window-fixed-size-p',
3681 `window-min-height' or `window-min-width'. All these checks have to
3682 be applied on the Elisp level. */)
3683 (Lisp_Object frame
, Lisp_Object horizontal
)
3687 int horflag
= !NILP (horizontal
);
3690 frame
= selected_frame
;
3691 CHECK_LIVE_FRAME (frame
);
3694 r
= XWINDOW (FRAME_ROOT_WINDOW (f
));
3696 if (!resize_window_check (r
, horflag
)
3697 || ! EQ (r
->new_total
, (horflag
? r
->total_cols
: r
->total_lines
)))
3701 resize_window_apply (r
, horflag
);
3703 windows_or_buffers_changed
++;
3704 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
3709 run_window_configuration_change_hook (f
);
3715 /* Resize frame F's windows when number of lines of F is set to SIZE.
3716 HORFLAG 1 means resize windows when number of columns of F is set to
3719 This function can delete all windows but the selected one in order to
3720 satisfy the request. The result will be meaningful if and only if
3721 F's windows have meaningful sizes when you call this. */
3723 resize_frame_windows (struct frame
*f
, int size
, int horflag
)
3725 Lisp_Object root
= f
->root_window
;
3726 struct window
*r
= XWINDOW (root
);
3727 Lisp_Object mini
= f
->minibuffer_window
;
3729 /* new_size is the new size of the frame's root window. */
3730 int new_size
= (horflag
3733 - FRAME_TOP_MARGIN (f
)
3734 - ((FRAME_HAS_MINIBUF_P (f
) && !FRAME_MINIBUF_ONLY_P (f
))
3737 XSETFASTINT (r
->top_line
, FRAME_TOP_MARGIN (f
));
3738 if (NILP (r
->vchild
) && NILP (r
->hchild
))
3739 /* For a leaf root window just set the size. */
3741 XSETFASTINT (r
->total_cols
, new_size
);
3743 XSETFASTINT (r
->total_lines
, new_size
);
3746 /* old_size is the old size of the frame's root window. */
3747 int old_size
= XFASTINT (horflag
? r
->total_cols
: r
->total_lines
);
3750 XSETINT (delta
, new_size
- old_size
);
3751 /* Try a "normal" resize first. */
3752 resize_root_window (root
, delta
, horflag
? Qt
: Qnil
, Qnil
);
3753 if (resize_window_check (r
, horflag
) && new_size
== XINT (r
->new_total
))
3754 resize_window_apply (r
, horflag
);
3757 /* Try with "reasonable" minimum sizes next. */
3758 resize_root_window (root
, delta
, horflag
? Qt
: Qnil
, Qt
);
3759 if (resize_window_check (r
, horflag
)
3760 && new_size
== XINT (r
->new_total
))
3761 resize_window_apply (r
, horflag
);
3764 /* Finally, try with "safe" minimum sizes. */
3765 resize_root_window (root
, delta
, horflag
? Qt
: Qnil
, Qsafe
);
3766 if (resize_window_check (r
, horflag
)
3767 && new_size
== XINT (r
->new_total
))
3768 resize_window_apply (r
, horflag
);
3771 /* We lost. Delete all windows but the frame's
3773 root
= f
->selected_window
;
3774 Fdelete_other_windows_internal (root
, Qnil
);
3776 XSETFASTINT (XWINDOW (root
)->total_cols
, new_size
);
3778 XSETFASTINT (XWINDOW (root
)->total_lines
, new_size
);
3784 if (FRAME_HAS_MINIBUF_P (f
) && !FRAME_MINIBUF_ONLY_P (f
))
3788 XSETFASTINT (m
->total_cols
, size
);
3791 /* Are we sure we always want 1 line here? */
3792 XSETFASTINT (m
->total_lines
, 1);
3793 XSETFASTINT (m
->top_line
, XINT (r
->top_line
) + XINT (r
->total_lines
));
3799 DEFUN ("split-window-internal", Fsplit_window_internal
, Ssplit_window_internal
, 4, 4, 0,
3800 doc
: /* Split window OLD.
3801 Second argument TOTAL-SIZE specifies the number of lines or columns of the
3802 new window. In any case TOTAL-SIZE must be a positive integer
3804 Third argument SIDE nil (or `below') specifies that the new window shall
3805 be located below WINDOW. SIDE `above' means the new window shall be
3806 located above WINDOW. In both cases TOTAL-SIZE specifies the number of
3807 lines of the new window including space reserved for the mode and/or
3810 SIDE t (or `right') specifies that the new window shall be located on
3811 the right side of WINDOW. SIDE `left' means the new window shall be
3812 located on the left of WINDOW. In both cases TOTAL-SIZE specifies the
3813 number of columns of the new window including space reserved for fringes
3814 and the scrollbar or a divider column.
3816 Fourth argument NORMAL-SIZE specifies the normal size of the new window
3817 according to the SIDE argument.
3819 The new total and normal sizes of all involved windows must have been
3820 set correctly. See the code of `split-window' for how this is done. */)
3821 (Lisp_Object old
, Lisp_Object total_size
, Lisp_Object side
, Lisp_Object normal_size
)
3823 /* OLD (*o) is the window we have to split. (*p) is either OLD's
3824 parent window or an internal window we have to install as OLD's new
3825 parent. REFERENCE (*r) must denote a live window, or is set to OLD
3826 provided OLD is a leaf window, or to the frame's selected window.
3827 NEW (*n) is the new window created with some parameters taken from
3829 register Lisp_Object
new, frame
, reference
;
3830 register struct window
*o
, *p
, *n
, *r
;
3833 /* HORFLAG is 1 when we split side-by-side, 0 otherwise. */
3834 = EQ (side
, Qt
) || EQ (side
, Qleft
) || EQ (side
, Qright
);
3839 frame
= WINDOW_FRAME (o
);
3842 CHECK_NUMBER (total_size
);
3844 /* Set do_nest to 1 if we have to make a new parent window. We do
3845 that if either `window-nest' is non-nil, or OLD has no parent, or
3846 OLD is ortho-combined. */
3848 !NILP (Vwindow_nest
)
3851 ? (XWINDOW (o
->parent
)->hchild
)
3852 : (XWINDOW (o
->parent
)->vchild
));
3854 /* We need a live reference window to initialize some parameters. */
3855 if (WINDOW_LIVE_P (old
))
3856 /* OLD is live, use it as reference window. */
3859 /* Use the frame's selected window as reference window. */
3860 reference
= FRAME_SELECTED_WINDOW (f
);
3861 r
= XWINDOW (reference
);
3863 /* The following bugs are caught by `split-window'. */
3864 if (MINI_WINDOW_P (o
))
3865 error ("Attempt to split minibuffer window");
3866 else if (XINT (total_size
) < (horflag
? 2 : 1))
3867 error ("Size of new window too small (after split)");
3868 else if (!do_nest
&& !NILP (Vwindow_splits
))
3869 /* `window-splits' non-nil means try to resize OLD's siblings
3872 p
= XWINDOW (o
->parent
);
3873 /* Temporarily pretend we split the parent window. */
3874 XSETINT (p
->new_total
,
3875 XINT (horflag
? p
->total_cols
: p
->total_lines
)
3876 - XINT (total_size
));
3877 if (!resize_window_check (p
, horflag
))
3878 error ("Window sizes don't fit");
3880 /* Undo the temporary pretension. */
3881 p
->new_total
= horflag
? p
->total_cols
: p
->total_lines
;
3885 if (!resize_window_check (o
, horflag
))
3886 error ("Resizing old window failed");
3887 else if (XINT (total_size
) + XINT (o
->new_total
)
3888 != XINT (horflag
? o
->total_cols
: o
->total_lines
))
3889 error ("Sum of sizes of old and new window don't fit");
3892 /* This is our point of no return. */
3895 /* Save the old value of o->normal_cols/lines. It gets corrupted
3896 by make_parent_window and we need it below for assigning it to
3898 Lisp_Object new_normal
= horflag
? o
->normal_cols
: o
->normal_lines
;
3900 make_parent_window (old
, horflag
);
3901 p
= XWINDOW (o
->parent
);
3902 /* Store value of `window-nest' in new parent's nest slot. */
3903 p
->nest
= Vwindow_nest
;
3904 /* Have PARENT inherit splits slot value from OLD. */
3905 p
->splits
= o
->splits
;
3906 /* Store value of `window-splits' in OLD's splits slot. */
3907 o
->splits
= Vwindow_splits
;
3908 /* These get applied below. */
3909 p
->new_total
= horflag
? o
->total_cols
: o
->total_lines
;
3910 p
->new_normal
= new_normal
;
3913 p
= XWINDOW (o
->parent
);
3915 windows_or_buffers_changed
++;
3916 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
3917 new = make_window ();
3920 n
->parent
= o
->parent
;
3921 n
->vchild
= n
->hchild
= Qnil
;
3923 if (EQ (side
, Qabove
) || EQ (side
, Qleft
))
3932 XWINDOW (n
->prev
)->next
= new;
3939 if (!NILP (n
->next
))
3940 XWINDOW (n
->next
)->prev
= new;
3946 n
->window_end_valid
= Qnil
;
3947 memset (&n
->last_cursor
, 0, sizeof n
->last_cursor
);
3949 /* Get special geometry settings from reference window. */
3950 n
->left_margin_cols
= r
->left_margin_cols
;
3951 n
->right_margin_cols
= r
->right_margin_cols
;
3952 n
->left_fringe_width
= r
->left_fringe_width
;
3953 n
->right_fringe_width
= r
->right_fringe_width
;
3954 n
->fringes_outside_margins
= r
->fringes_outside_margins
;
3955 n
->scroll_bar_width
= r
->scroll_bar_width
;
3956 n
->vertical_scroll_bar_type
= r
->vertical_scroll_bar_type
;
3958 /* Store `window-splits' in NEW's splits slot. */
3959 n
->splits
= Vwindow_splits
;
3961 /* Directly assign orthogonal coordinates and sizes. */
3964 n
->top_line
= o
->top_line
;
3965 n
->total_lines
= o
->total_lines
;
3969 n
->left_col
= o
->left_col
;
3970 n
->total_cols
= o
->total_cols
;
3973 /* Iso-coordinates and sizes are assigned by resize_window_apply,
3974 get them ready here. */
3975 n
->new_total
= total_size
;
3976 n
->new_normal
= normal_size
;
3979 resize_window_apply (p
, horflag
);
3981 /* Set buffer of NEW to buffer of reference window. Don't run
3983 set_window_buffer (new, r
->buffer
, 0, 1);
3986 /* Maybe we should run the scroll functions in Elisp (which already
3987 runs the configuration change hook). */
3988 if (! NILP (Vwindow_scroll_functions
))
3989 run_hook_with_args_2 (Qwindow_scroll_functions
, new,
3990 Fmarker_position (n
->start
));
3996 DEFUN ("delete-window-internal", Fdelete_window_internal
, Sdelete_window_internal
, 1, 1, 0,
3997 doc
: /* Remove WINDOW from its frame.
3998 WINDOW defaults to the selected window. Return nil. Signal an error
3999 when WINDOW is the only window on its frame. */)
4000 (register Lisp_Object window
)
4002 register Lisp_Object parent
, sibling
, frame
, root
;
4003 struct window
*w
, *p
, *s
, *r
;
4006 int before_sibling
= 0;
4008 w
= decode_any_window (window
);
4009 XSETWINDOW (window
, w
);
4010 if (NILP (w
->buffer
) && NILP (w
->hchild
) && NILP (w
->vchild
))
4011 /* It's a no-op to delete an already deleted window. */
4016 /* Never delete a minibuffer or frame root window. */
4017 error ("Attempt to delete minibuffer or sole ordinary window");
4018 else if (NILP (w
->prev
) && NILP (w
->next
))
4019 /* Rather bow out here, this case should be handled on the Elisp
4021 error ("Attempt to delete sole window of parent");
4023 p
= XWINDOW (parent
);
4024 horflag
= NILP (p
->vchild
);
4026 frame
= WINDOW_FRAME (w
);
4029 root
= FRAME_ROOT_WINDOW (f
);
4032 /* Unlink WINDOW from window tree. */
4034 /* Get SIBLING below (on the right of) WINDOW. */
4036 /* before_sibling 1 means WINDOW is the first child of its
4037 parent and thus before the sibling. */
4040 s
= XWINDOW (sibling
);
4043 p
->hchild
= sibling
;
4045 p
->vchild
= sibling
;
4048 /* Get SIBLING above (on the left of) WINDOW. */
4051 s
= XWINDOW (sibling
);
4053 if (!NILP (s
->next
))
4054 XWINDOW (s
->next
)->prev
= sibling
;
4057 if (resize_window_check (r
, horflag
)
4058 && EQ (r
->new_total
, (horflag
? r
->total_cols
: r
->total_lines
)))
4059 /* We can delete WINDOW now. */
4063 resize_window_apply (p
, horflag
);
4065 windows_or_buffers_changed
++;
4066 Vwindow_list
= Qnil
;
4067 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
4069 w
->next
= Qnil
; /* Don't delete w->next too. */
4070 free_window_matrices (w
);
4072 if (!NILP (w
->vchild
))
4074 delete_all_subwindows (w
->vchild
);
4077 else if (!NILP (w
->hchild
))
4079 delete_all_subwindows (w
->hchild
);
4082 else if (!NILP (w
->buffer
))
4085 unchain_marker (XMARKER (w
->pointm
));
4086 unchain_marker (XMARKER (w
->start
));
4090 if (NILP (s
->prev
) && NILP (s
->next
))
4091 /* A matrjoshka where SIBLING has become the only child of
4094 /* Put SIBLING into PARENT's place. */
4095 replace_window (parent
, sibling
, 0);
4096 /* Have SIBLING inherit the following three slot values from
4097 PARENT (the nest slot is not inherited). */
4098 s
->normal_cols
= p
->normal_cols
;
4099 s
->normal_lines
= p
->normal_lines
;
4100 s
->splits
= p
->splits
;
4101 /* Mark PARENT as deleted. */
4102 p
->vchild
= p
->hchild
= Qnil
;
4103 /* Try to merge SIBLING into its new parent. */
4104 recombine_windows (sibling
);
4109 if (!WINDOW_LIVE_P (FRAME_SELECTED_WINDOW (f
)))
4110 /* We deleted the frame's selected window. */
4112 /* Use the frame's first window as fallback ... */
4113 Lisp_Object new_selected_window
= Fframe_first_window (frame
);
4114 /* ... but preferably use its most recently used window. */
4115 Lisp_Object mru_window
;
4117 /* `get-mru-window' might fail for some reason so play it safe
4118 - promote the first window _without recording it_ first. */
4119 if (EQ (FRAME_SELECTED_WINDOW (f
), selected_window
))
4120 Fselect_window (new_selected_window
, Qt
);
4122 FRAME_SELECTED_WINDOW (f
) = new_selected_window
;
4126 /* Now look whether `get-mru-window' gets us something. */
4127 mru_window
= call1 (Qget_mru_window
, frame
);
4128 if (WINDOW_LIVE_P (mru_window
)
4129 && EQ (XWINDOW (mru_window
)->frame
, frame
))
4130 new_selected_window
= mru_window
;
4132 /* If all ended up well, we now promote the mru window. */
4133 if (EQ (FRAME_SELECTED_WINDOW (f
), selected_window
))
4134 Fselect_window (new_selected_window
, Qnil
);
4136 FRAME_SELECTED_WINDOW (f
) = new_selected_window
;
4141 /* Must be run by the caller:
4142 run_window_configuration_change_hook (f); */
4145 /* We failed: Relink WINDOW into window tree. */
4158 if (!NILP (w
->next
))
4159 XWINDOW (w
->next
)->prev
= window
;
4161 error ("Deletion failed");
4167 /***********************************************************************
4168 Resizing Mini-Windows
4169 ***********************************************************************/
4171 /* Grow mini-window W by DELTA lines, DELTA >= 0, or as much as we
4174 grow_mini_window (struct window
*w
, int delta
)
4176 struct frame
*f
= XFRAME (w
->frame
);
4178 Lisp_Object root
, value
;
4180 xassert (MINI_WINDOW_P (w
));
4181 xassert (delta
>= 0);
4183 root
= FRAME_ROOT_WINDOW (f
);
4185 value
= call2 (Qresize_root_window_vertically
, root
, make_number (- delta
));
4186 if (INTEGERP (value
) && resize_window_check (r
, 0))
4189 resize_window_apply (r
, 0);
4191 /* Grow the mini-window. */
4192 XSETFASTINT (w
->top_line
, XFASTINT (r
->top_line
) + XFASTINT (r
->total_lines
));
4193 XSETFASTINT (w
->total_lines
, XFASTINT (w
->total_lines
) - XINT (value
));
4194 XSETFASTINT (w
->last_modified
, 0);
4195 XSETFASTINT (w
->last_overlay_modified
, 0);
4203 /* Shrink mini-window W. */
4205 shrink_mini_window (struct window
*w
)
4207 struct frame
*f
= XFRAME (w
->frame
);
4209 Lisp_Object root
, value
;
4212 xassert (MINI_WINDOW_P (w
));
4214 size
= XINT (w
->total_lines
);
4217 root
= FRAME_ROOT_WINDOW (f
);
4219 value
= call2 (Qresize_root_window_vertically
,
4220 root
, make_number (size
- 1));
4221 if (INTEGERP (value
) && resize_window_check (r
, 0))
4224 resize_window_apply (r
, 0);
4226 /* Shrink the mini-window. */
4227 XSETFASTINT (w
->top_line
, XFASTINT (r
->top_line
) + XFASTINT (r
->total_lines
));
4228 XSETFASTINT (w
->total_lines
, 1);
4230 XSETFASTINT (w
->last_modified
, 0);
4231 XSETFASTINT (w
->last_overlay_modified
, 0);
4236 /* If the above failed for whatever strange reason we must make a
4237 one window frame here. The same routine will be needed when
4238 shrinking the frame (and probably when making the initial
4239 *scratch* window). For the moment leave things as they are. */
4243 DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal
, Sresize_mini_window_internal
, 1, 1, 0,
4244 doc
: /* Resize minibuffer window WINDOW. */)
4245 (Lisp_Object window
)
4247 struct window
*w
= XWINDOW (window
);
4252 CHECK_WINDOW (window
);
4253 f
= XFRAME (w
->frame
);
4255 if (!EQ (FRAME_MINIBUF_WINDOW (XFRAME (w
->frame
)), window
))
4256 error ("Not a valid minibuffer window");
4257 else if (FRAME_MINIBUF_ONLY_P (f
))
4258 error ("Cannot resize a minibuffer-only frame");
4260 r
= XWINDOW (FRAME_ROOT_WINDOW (f
));
4261 height
= XINT (r
->total_lines
) + XINT (w
->total_lines
);
4262 if (resize_window_check (r
, 0)
4263 && XINT (w
->new_total
) > 0
4264 && height
== XINT (r
->new_total
) + XINT (w
->new_total
))
4267 resize_window_apply (r
, 0);
4269 w
->total_lines
= w
->new_total
;
4270 XSETFASTINT (w
->top_line
, XINT (r
->top_line
) + XINT (r
->total_lines
));
4272 windows_or_buffers_changed
++;
4273 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
4277 run_window_configuration_change_hook (f
);
4280 else error ("Failed to resize minibuffer window");
4284 /* Mark window cursors off for all windows in the window tree rooted
4285 at W by setting their phys_cursor_on_p flag to zero. Called from
4286 xterm.c, e.g. when a frame is cleared and thereby all cursors on
4287 the frame are cleared. */
4290 mark_window_cursors_off (struct window
*w
)
4294 if (!NILP (w
->hchild
))
4295 mark_window_cursors_off (XWINDOW (w
->hchild
));
4296 else if (!NILP (w
->vchild
))
4297 mark_window_cursors_off (XWINDOW (w
->vchild
));
4299 w
->phys_cursor_on_p
= 0;
4301 w
= NILP (w
->next
) ? 0 : XWINDOW (w
->next
);
4306 /* Return number of lines of text (not counting mode lines) in W. */
4309 window_internal_height (struct window
*w
)
4311 int ht
= XFASTINT (w
->total_lines
);
4313 if (!MINI_WINDOW_P (w
))
4315 if (!NILP (w
->parent
)
4316 || !NILP (w
->vchild
)
4317 || !NILP (w
->hchild
)
4320 || WINDOW_WANTS_MODELINE_P (w
))
4323 if (WINDOW_WANTS_HEADER_LINE_P (w
))
4330 /************************************************************************
4332 ***********************************************************************/
4334 /* Scroll contents of window WINDOW up. If WHOLE is non-zero, scroll
4335 N screen-fulls, which is defined as the height of the window minus
4336 next_screen_context_lines. If WHOLE is zero, scroll up N lines
4337 instead. Negative values of N mean scroll down. NOERROR non-zero
4338 means don't signal an error if we try to move over BEGV or ZV,
4342 window_scroll (Lisp_Object window
, int n
, int whole
, int noerror
)
4346 /* If we must, use the pixel-based version which is much slower than
4347 the line-based one but can handle varying line heights. */
4348 if (FRAME_WINDOW_P (XFRAME (XWINDOW (window
)->frame
)))
4349 window_scroll_pixel_based (window
, n
, whole
, noerror
);
4351 window_scroll_line_based (window
, n
, whole
, noerror
);
4357 /* Implementation of window_scroll that works based on pixel line
4358 heights. See the comment of window_scroll for parameter
4362 window_scroll_pixel_based (Lisp_Object window
, int n
, int whole
, int noerror
)
4365 struct window
*w
= XWINDOW (window
);
4366 struct text_pos start
;
4367 int this_scroll_margin
;
4368 /* True if we fiddled the window vscroll field without really scrolling. */
4370 int x
, y
, rtop
, rbot
, rowh
, vpos
;
4372 SET_TEXT_POS_FROM_MARKER (start
, w
->start
);
4374 /* If PT is not visible in WINDOW, move back one half of
4375 the screen. Allow PT to be partially visible, otherwise
4376 something like (scroll-down 1) with PT in the line before
4377 the partially visible one would recenter. */
4379 if (!pos_visible_p (w
, PT
, &x
, &y
, &rtop
, &rbot
, &rowh
, &vpos
))
4381 /* Move backward half the height of the window. Performance note:
4382 vmotion used here is about 10% faster, but would give wrong
4383 results for variable height lines. */
4384 init_iterator (&it
, w
, PT
, PT_BYTE
, NULL
, DEFAULT_FACE_ID
);
4385 it
.current_y
= it
.last_visible_y
;
4386 move_it_vertically_backward (&it
, window_box_height (w
) / 2);
4388 /* The function move_iterator_vertically may move over more than
4389 the specified y-distance. If it->w is small, e.g. a
4390 mini-buffer window, we may end up in front of the window's
4391 display area. This is the case when Start displaying at the
4392 start of the line containing PT in this case. */
4393 if (it
.current_y
<= 0)
4395 init_iterator (&it
, w
, PT
, PT_BYTE
, NULL
, DEFAULT_FACE_ID
);
4396 move_it_vertically_backward (&it
, 0);
4400 start
= it
.current
.pos
;
4402 else if (auto_window_vscroll_p
)
4404 if (rtop
|| rbot
) /* partially visible */
4407 int dy
= WINDOW_FRAME_LINE_HEIGHT (w
);
4409 dy
= max ((window_box_height (w
)
4410 - next_screen_context_lines
* dy
),
4416 /* Only vscroll backwards if already vscrolled forwards. */
4417 if (w
->vscroll
< 0 && rtop
> 0)
4419 px
= max (0, -w
->vscroll
- min (rtop
, -dy
));
4420 Fset_window_vscroll (window
, make_number (px
), Qt
);
4426 /* Do vscroll if already vscrolled or only display line. */
4427 if (rbot
> 0 && (w
->vscroll
< 0 || vpos
== 0))
4429 px
= max (0, -w
->vscroll
+ min (rbot
, dy
));
4430 Fset_window_vscroll (window
, make_number (px
), Qt
);
4434 /* Maybe modify window start instead of scrolling. */
4435 if (rbot
> 0 || w
->vscroll
< 0)
4439 Fset_window_vscroll (window
, make_number (0), Qt
);
4440 /* If there are other text lines above the current row,
4441 move window start to current row. Else to next row. */
4443 spos
= XINT (Fline_beginning_position (Qnil
));
4445 spos
= min (XINT (Fline_end_position (Qnil
)) + 1, ZV
);
4446 set_marker_restricted (w
->start
, make_number (spos
),
4448 w
->start_at_line_beg
= Qt
;
4449 w
->update_mode_line
= Qt
;
4450 XSETFASTINT (w
->last_modified
, 0);
4451 XSETFASTINT (w
->last_overlay_modified
, 0);
4452 /* Set force_start so that redisplay_window will run the
4453 window-scroll-functions. */
4454 w
->force_start
= Qt
;
4459 /* Cancel previous vscroll. */
4460 Fset_window_vscroll (window
, make_number (0), Qt
);
4463 /* If scroll_preserve_screen_position is non-nil, we try to set
4464 point in the same window line as it is now, so get that line. */
4465 if (!NILP (Vscroll_preserve_screen_position
))
4467 /* We preserve the goal pixel coordinate across consecutive
4468 calls to scroll-up, scroll-down and other commands that
4469 have the `scroll-command' property. This avoids the
4470 possibility of point becoming "stuck" on a tall line when
4471 scrolling by one line. */
4472 if (window_scroll_pixel_based_preserve_y
< 0
4473 || !SYMBOLP (KVAR (current_kboard
, Vlast_command
))
4474 || NILP (Fget (KVAR (current_kboard
, Vlast_command
), Qscroll_command
)))
4476 start_display (&it
, w
, start
);
4477 move_it_to (&it
, PT
, -1, -1, -1, MOVE_TO_POS
);
4478 window_scroll_pixel_based_preserve_y
= it
.current_y
;
4479 window_scroll_pixel_based_preserve_x
= it
.current_x
;
4483 window_scroll_pixel_based_preserve_y
4484 = window_scroll_pixel_based_preserve_x
= -1;
4486 /* Move iterator it from start the specified distance forward or
4487 backward. The result is the new window start. */
4488 start_display (&it
, w
, start
);
4491 EMACS_INT start_pos
= IT_CHARPOS (it
);
4492 int dy
= WINDOW_FRAME_LINE_HEIGHT (w
);
4493 dy
= max ((window_box_height (w
)
4494 - next_screen_context_lines
* dy
),
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. */
4502 move_it_vertically_backward (&it
, -dy
);
4503 /* Ensure we actually do move, e.g. in case we are currently
4504 looking at an image that is taller that the window height. */
4505 while (start_pos
== IT_CHARPOS (it
)
4506 && start_pos
> BEGV
)
4507 move_it_by_lines (&it
, -1);
4511 move_it_to (&it
, ZV
, -1, it
.current_y
+ dy
, -1,
4512 MOVE_TO_POS
| MOVE_TO_Y
);
4513 /* Ensure we actually do move, e.g. in case we are currently
4514 looking at an image that is taller that the window height. */
4515 while (start_pos
== IT_CHARPOS (it
)
4517 move_it_by_lines (&it
, 1);
4521 move_it_by_lines (&it
, n
);
4523 /* We failed if we find ZV is already on the screen (scrolling up,
4524 means there's nothing past the end), or if we can't start any
4525 earlier (scrolling down, means there's nothing past the top). */
4526 if ((n
> 0 && IT_CHARPOS (it
) == ZV
)
4527 || (n
< 0 && IT_CHARPOS (it
) == CHARPOS (start
)))
4529 if (IT_CHARPOS (it
) == ZV
)
4531 if (it
.current_y
< it
.last_visible_y
4532 && (it
.current_y
+ it
.max_ascent
+ it
.max_descent
4533 > it
.last_visible_y
))
4535 /* The last line was only partially visible, make it fully
4537 w
->vscroll
= (it
.last_visible_y
4538 - it
.current_y
+ it
.max_ascent
+ it
.max_descent
);
4539 adjust_glyphs (it
.f
);
4543 else if (n
< 0) /* could happen with empty buffers */
4544 xsignal0 (Qbeginning_of_buffer
);
4546 xsignal0 (Qend_of_buffer
);
4550 if (w
->vscroll
!= 0)
4551 /* The first line was only partially visible, make it fully
4557 xsignal0 (Qbeginning_of_buffer
);
4560 /* If control gets here, then we vscrolled. */
4562 XBUFFER (w
->buffer
)->prevent_redisplay_optimizations_p
= 1;
4564 /* Don't try to change the window start below. */
4570 EMACS_INT pos
= IT_CHARPOS (it
);
4573 /* If in the middle of a multi-glyph character move forward to
4574 the next character. */
4575 if (in_display_vector_p (&it
))
4578 move_it_to (&it
, pos
, -1, -1, -1, MOVE_TO_POS
);
4581 /* Set the window start, and set up the window for redisplay. */
4582 set_marker_restricted (w
->start
, make_number (pos
),
4584 bytepos
= XMARKER (w
->start
)->bytepos
;
4585 w
->start_at_line_beg
= ((pos
== BEGV
|| FETCH_BYTE (bytepos
- 1) == '\n')
4587 w
->update_mode_line
= Qt
;
4588 XSETFASTINT (w
->last_modified
, 0);
4589 XSETFASTINT (w
->last_overlay_modified
, 0);
4590 /* Set force_start so that redisplay_window will run the
4591 window-scroll-functions. */
4592 w
->force_start
= Qt
;
4595 /* The rest of this function uses current_y in a nonstandard way,
4596 not including the height of the header line if any. */
4597 it
.current_y
= it
.vpos
= 0;
4599 /* Move PT out of scroll margins.
4600 This code wants current_y to be zero at the window start position
4601 even if there is a header line. */
4602 this_scroll_margin
= max (0, scroll_margin
);
4603 this_scroll_margin
= min (this_scroll_margin
, XFASTINT (w
->total_lines
) / 4);
4604 this_scroll_margin
*= FRAME_LINE_HEIGHT (it
.f
);
4608 /* We moved the window start towards ZV, so PT may be now
4609 in the scroll margin at the top. */
4610 move_it_to (&it
, PT
, -1, -1, -1, MOVE_TO_POS
);
4611 if (IT_CHARPOS (it
) == PT
&& it
.current_y
>= this_scroll_margin
4612 && (NILP (Vscroll_preserve_screen_position
)
4613 || EQ (Vscroll_preserve_screen_position
, Qt
)))
4614 /* We found PT at a legitimate height. Leave it alone. */
4616 else if (window_scroll_pixel_based_preserve_y
>= 0)
4618 /* If we have a header line, take account of it.
4619 This is necessary because we set it.current_y to 0, above. */
4620 move_it_to (&it
, -1,
4621 window_scroll_pixel_based_preserve_x
,
4622 window_scroll_pixel_based_preserve_y
4623 - (WINDOW_WANTS_HEADER_LINE_P (w
) ? 1 : 0 ),
4624 -1, MOVE_TO_Y
| MOVE_TO_X
);
4625 SET_PT_BOTH (IT_CHARPOS (it
), IT_BYTEPOS (it
));
4629 while (it
.current_y
< this_scroll_margin
)
4631 int prev
= it
.current_y
;
4632 move_it_by_lines (&it
, 1);
4633 if (prev
== it
.current_y
)
4636 SET_PT_BOTH (IT_CHARPOS (it
), IT_BYTEPOS (it
));
4641 EMACS_INT charpos
, bytepos
;
4644 /* Save our position, for the
4645 window_scroll_pixel_based_preserve_y case. */
4646 charpos
= IT_CHARPOS (it
);
4647 bytepos
= IT_BYTEPOS (it
);
4649 /* We moved the window start towards BEGV, so PT may be now
4650 in the scroll margin at the bottom. */
4651 move_it_to (&it
, PT
, -1,
4652 (it
.last_visible_y
- CURRENT_HEADER_LINE_HEIGHT (w
)
4653 - this_scroll_margin
- 1),
4655 MOVE_TO_POS
| MOVE_TO_Y
);
4657 /* Save our position, in case it's correct. */
4658 charpos
= IT_CHARPOS (it
);
4659 bytepos
= IT_BYTEPOS (it
);
4661 /* See if point is on a partially visible line at the end. */
4662 if (it
.what
== IT_EOB
)
4663 partial_p
= it
.current_y
+ it
.ascent
+ it
.descent
> it
.last_visible_y
;
4666 move_it_by_lines (&it
, 1);
4667 partial_p
= it
.current_y
> it
.last_visible_y
;
4670 if (charpos
== PT
&& !partial_p
4671 && (NILP (Vscroll_preserve_screen_position
)
4672 || EQ (Vscroll_preserve_screen_position
, Qt
)))
4673 /* We found PT before we found the display margin, so PT is ok. */
4675 else if (window_scroll_pixel_based_preserve_y
>= 0)
4677 SET_TEXT_POS_FROM_MARKER (start
, w
->start
);
4678 start_display (&it
, w
, start
);
4679 /* It would be wrong to subtract CURRENT_HEADER_LINE_HEIGHT
4680 here because we called start_display again and did not
4681 alter it.current_y this time. */
4682 move_it_to (&it
, -1, window_scroll_pixel_based_preserve_x
,
4683 window_scroll_pixel_based_preserve_y
, -1,
4684 MOVE_TO_Y
| MOVE_TO_X
);
4685 SET_PT_BOTH (IT_CHARPOS (it
), IT_BYTEPOS (it
));
4690 /* The last line was only partially visible, so back up two
4691 lines to make sure we're on a fully visible line. */
4693 move_it_by_lines (&it
, -2);
4694 SET_PT_BOTH (IT_CHARPOS (it
), IT_BYTEPOS (it
));
4697 /* No, the position we saved is OK, so use it. */
4698 SET_PT_BOTH (charpos
, bytepos
);
4704 /* Implementation of window_scroll that works based on screen lines.
4705 See the comment of window_scroll for parameter descriptions. */
4708 window_scroll_line_based (Lisp_Object window
, int n
, int whole
, int noerror
)
4710 register struct window
*w
= XWINDOW (window
);
4711 /* Fvertical_motion enters redisplay, which can trigger
4712 fontification, which in turn can modify buffer text (e.g., if the
4713 fontification functions replace escape sequences with faces, as
4714 in `grep-mode-font-lock-keywords'). So we use a marker to record
4715 the old point position, to prevent crashes in SET_PT_BOTH. */
4716 Lisp_Object opoint_marker
= Fpoint_marker ();
4717 register EMACS_INT pos
, pos_byte
;
4718 register int ht
= window_internal_height (w
);
4719 register Lisp_Object tem
;
4723 Lisp_Object original_pos
= Qnil
;
4725 /* If scrolling screen-fulls, compute the number of lines to
4726 scroll from the window's height. */
4728 n
*= max (1, ht
- next_screen_context_lines
);
4730 startpos
= marker_position (w
->start
);
4732 if (!NILP (Vscroll_preserve_screen_position
))
4734 if (window_scroll_preserve_vpos
<= 0
4735 || !SYMBOLP (KVAR (current_kboard
, Vlast_command
))
4736 || NILP (Fget (KVAR (current_kboard
, Vlast_command
), Qscroll_command
)))
4738 struct position posit
4739 = *compute_motion (startpos
, 0, 0, 0,
4741 -1, XINT (w
->hscroll
),
4743 window_scroll_preserve_vpos
= posit
.vpos
;
4744 window_scroll_preserve_hpos
= posit
.hpos
+ XINT (w
->hscroll
);
4747 original_pos
= Fcons (make_number (window_scroll_preserve_hpos
),
4748 make_number (window_scroll_preserve_vpos
));
4751 XSETFASTINT (tem
, PT
);
4752 tem
= Fpos_visible_in_window_p (tem
, window
, Qnil
);
4756 Fvertical_motion (make_number (- (ht
/ 2)), window
);
4761 lose
= n
< 0 && PT
== BEGV
;
4762 Fvertical_motion (make_number (n
), window
);
4766 SET_PT_BOTH (marker_position (opoint_marker
),
4767 marker_byte_position (opoint_marker
));
4774 xsignal0 (Qbeginning_of_buffer
);
4779 int this_scroll_margin
= scroll_margin
;
4781 /* Don't use a scroll margin that is negative or too large. */
4782 if (this_scroll_margin
< 0)
4783 this_scroll_margin
= 0;
4785 if (XINT (w
->total_lines
) < 4 * scroll_margin
)
4786 this_scroll_margin
= XINT (w
->total_lines
) / 4;
4788 set_marker_restricted_both (w
->start
, w
->buffer
, pos
, pos_byte
);
4789 w
->start_at_line_beg
= bolp
;
4790 w
->update_mode_line
= Qt
;
4791 XSETFASTINT (w
->last_modified
, 0);
4792 XSETFASTINT (w
->last_overlay_modified
, 0);
4793 /* Set force_start so that redisplay_window will run
4794 the window-scroll-functions. */
4795 w
->force_start
= Qt
;
4797 if (!NILP (Vscroll_preserve_screen_position
)
4798 && (whole
|| !EQ (Vscroll_preserve_screen_position
, Qt
)))
4800 SET_PT_BOTH (pos
, pos_byte
);
4801 Fvertical_motion (original_pos
, window
);
4803 /* If we scrolled forward, put point enough lines down
4804 that it is outside the scroll margin. */
4809 if (this_scroll_margin
> 0)
4811 SET_PT_BOTH (pos
, pos_byte
);
4812 Fvertical_motion (make_number (this_scroll_margin
), window
);
4818 if (top_margin
<= marker_position (opoint_marker
))
4819 SET_PT_BOTH (marker_position (opoint_marker
),
4820 marker_byte_position (opoint_marker
));
4821 else if (!NILP (Vscroll_preserve_screen_position
))
4823 SET_PT_BOTH (pos
, pos_byte
);
4824 Fvertical_motion (original_pos
, window
);
4827 SET_PT (top_margin
);
4833 /* If we scrolled backward, put point near the end of the window
4834 but not within the scroll margin. */
4835 SET_PT_BOTH (pos
, pos_byte
);
4836 tem
= Fvertical_motion (make_number (ht
- this_scroll_margin
), window
);
4837 if (XFASTINT (tem
) == ht
- this_scroll_margin
)
4840 bottom_margin
= PT
+ 1;
4842 if (bottom_margin
> marker_position (opoint_marker
))
4843 SET_PT_BOTH (marker_position (opoint_marker
),
4844 marker_byte_position (opoint_marker
));
4847 if (!NILP (Vscroll_preserve_screen_position
))
4849 SET_PT_BOTH (pos
, pos_byte
);
4850 Fvertical_motion (original_pos
, window
);
4853 Fvertical_motion (make_number (-1), window
);
4862 xsignal0 (Qend_of_buffer
);
4867 /* Scroll selected_window up or down. If N is nil, scroll a
4868 screen-full which is defined as the height of the window minus
4869 next_screen_context_lines. If N is the symbol `-', scroll.
4870 DIRECTION may be 1 meaning to scroll down, or -1 meaning to scroll
4871 up. This is the guts of Fscroll_up and Fscroll_down. */
4874 scroll_command (Lisp_Object n
, int direction
)
4876 int count
= SPECPDL_INDEX ();
4878 xassert (eabs (direction
) == 1);
4880 /* If selected window's buffer isn't current, make it current for
4881 the moment. But don't screw up if window_scroll gets an error. */
4882 if (XBUFFER (XWINDOW (selected_window
)->buffer
) != current_buffer
)
4884 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
4885 Fset_buffer (XWINDOW (selected_window
)->buffer
);
4887 /* Make redisplay consider other windows than just selected_window. */
4888 ++windows_or_buffers_changed
;
4892 window_scroll (selected_window
, direction
, 1, 0);
4893 else if (EQ (n
, Qminus
))
4894 window_scroll (selected_window
, -direction
, 1, 0);
4897 n
= Fprefix_numeric_value (n
);
4898 window_scroll (selected_window
, XINT (n
) * direction
, 0, 0);
4901 unbind_to (count
, Qnil
);
4904 DEFUN ("scroll-up", Fscroll_up
, Sscroll_up
, 0, 1, "^P",
4905 doc
: /* Scroll text of selected window upward ARG lines.
4906 If ARG is omitted or nil, scroll upward by a near full screen.
4907 A near full screen is `next-screen-context-lines' less than a full screen.
4908 Negative ARG means scroll downward.
4909 If ARG is the atom `-', scroll downward by nearly full screen.
4910 When calling from a program, supply as argument a number, nil, or `-'. */)
4913 scroll_command (arg
, 1);
4917 DEFUN ("scroll-down", Fscroll_down
, Sscroll_down
, 0, 1, "^P",
4918 doc
: /* Scroll text of selected window down ARG lines.
4919 If ARG is omitted or nil, scroll down by a near full screen.
4920 A near full screen is `next-screen-context-lines' less than a full screen.
4921 Negative ARG means scroll upward.
4922 If ARG is the atom `-', scroll upward by nearly full screen.
4923 When calling from a program, supply as argument a number, nil, or `-'. */)
4926 scroll_command (arg
, -1);
4930 DEFUN ("other-window-for-scrolling", Fother_window_for_scrolling
, Sother_window_for_scrolling
, 0, 0, 0,
4931 doc
: /* Return the other window for \"other window scroll\" commands.
4932 If `other-window-scroll-buffer' is non-nil, a window
4933 showing that buffer is used.
4934 If in the minibuffer, `minibuffer-scroll-window' if non-nil
4935 specifies the window. This takes precedence over
4936 `other-window-scroll-buffer'. */)
4941 if (MINI_WINDOW_P (XWINDOW (selected_window
))
4942 && !NILP (Vminibuf_scroll_window
))
4943 window
= Vminibuf_scroll_window
;
4944 /* If buffer is specified, scroll that buffer. */
4945 else if (!NILP (Vother_window_scroll_buffer
))
4947 window
= Fget_buffer_window (Vother_window_scroll_buffer
, Qnil
);
4949 window
= display_buffer (Vother_window_scroll_buffer
, Qt
, Qnil
);
4953 /* Nothing specified; look for a neighboring window on the same
4955 window
= Fnext_window (selected_window
, Qnil
, Qnil
);
4957 if (EQ (window
, selected_window
))
4958 /* That didn't get us anywhere; look for a window on another
4961 window
= Fnext_window (window
, Qnil
, Qt
);
4962 while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window
))))
4963 && ! EQ (window
, selected_window
));
4966 CHECK_LIVE_WINDOW (window
);
4968 if (EQ (window
, selected_window
))
4969 error ("There is no other window");
4974 DEFUN ("scroll-other-window", Fscroll_other_window
, Sscroll_other_window
, 0, 1, "P",
4975 doc
: /* Scroll next window upward ARG lines; or near full screen if no ARG.
4976 A near full screen is `next-screen-context-lines' less than a full screen.
4977 The next window is the one below the current one; or the one at the top
4978 if the current one is at the bottom. Negative ARG means scroll downward.
4979 If ARG is the atom `-', scroll downward by nearly full screen.
4980 When calling from a program, supply as argument a number, nil, or `-'.
4982 If `other-window-scroll-buffer' is non-nil, scroll the window
4983 showing that buffer, popping the buffer up if necessary.
4984 If in the minibuffer, `minibuffer-scroll-window' if non-nil
4985 specifies the window to scroll. This takes precedence over
4986 `other-window-scroll-buffer'. */)
4991 int count
= SPECPDL_INDEX ();
4993 window
= Fother_window_for_scrolling ();
4994 w
= XWINDOW (window
);
4996 /* Don't screw up if window_scroll gets an error. */
4997 record_unwind_protect (save_excursion_restore
, save_excursion_save ());
4998 ++windows_or_buffers_changed
;
5000 Fset_buffer (w
->buffer
);
5001 SET_PT (marker_position (w
->pointm
));
5004 window_scroll (window
, 1, 1, 1);
5005 else if (EQ (arg
, Qminus
))
5006 window_scroll (window
, -1, 1, 1);
5012 window_scroll (window
, XINT (arg
), 0, 1);
5015 set_marker_both (w
->pointm
, Qnil
, PT
, PT_BYTE
);
5016 unbind_to (count
, Qnil
);
5021 DEFUN ("scroll-left", Fscroll_left
, Sscroll_left
, 0, 2, "^P\np",
5022 doc
: /* Scroll selected window display ARG columns left.
5023 Default for ARG is window width minus 2.
5024 Value is the total amount of leftward horizontal scrolling in
5025 effect after the change.
5026 If SET-MINIMUM is non-nil, the new scroll amount becomes the
5027 lower bound for automatic scrolling, i.e. automatic scrolling
5028 will not scroll a window to a column less than the value returned
5029 by this function. This happens in an interactive call. */)
5030 (register Lisp_Object arg
, Lisp_Object set_minimum
)
5034 struct window
*w
= XWINDOW (selected_window
);
5037 XSETFASTINT (arg
, window_body_cols (w
) - 2);
5039 arg
= Fprefix_numeric_value (arg
);
5041 hscroll
= XINT (w
->hscroll
) + XINT (arg
);
5042 result
= Fset_window_hscroll (selected_window
, make_number (hscroll
));
5044 if (!NILP (set_minimum
))
5045 w
->min_hscroll
= w
->hscroll
;
5050 DEFUN ("scroll-right", Fscroll_right
, Sscroll_right
, 0, 2, "^P\np",
5051 doc
: /* Scroll selected window display ARG columns right.
5052 Default for ARG is window width minus 2.
5053 Value is the total amount of leftward horizontal scrolling in
5054 effect after the change.
5055 If SET-MINIMUM is non-nil, the new scroll amount becomes the
5056 lower bound for automatic scrolling, i.e. automatic scrolling
5057 will not scroll a window to a column less than the value returned
5058 by this function. This happens in an interactive call. */)
5059 (register Lisp_Object arg
, Lisp_Object set_minimum
)
5063 struct window
*w
= XWINDOW (selected_window
);
5066 XSETFASTINT (arg
, window_body_cols (w
) - 2);
5068 arg
= Fprefix_numeric_value (arg
);
5070 hscroll
= XINT (w
->hscroll
) - XINT (arg
);
5071 result
= Fset_window_hscroll (selected_window
, make_number (hscroll
));
5073 if (!NILP (set_minimum
))
5074 w
->min_hscroll
= w
->hscroll
;
5079 DEFUN ("minibuffer-selected-window", Fminibuffer_selected_window
, Sminibuffer_selected_window
, 0, 0, 0,
5080 doc
: /* Return the window which was selected when entering the minibuffer.
5081 Returns nil, if selected window is not a minibuffer window. */)
5084 if (minibuf_level
> 0
5085 && MINI_WINDOW_P (XWINDOW (selected_window
))
5086 && WINDOW_LIVE_P (minibuf_selected_window
))
5087 return minibuf_selected_window
;
5092 /* Value is the number of lines actually displayed in window W,
5093 as opposed to its height. */
5096 displayed_window_lines (struct window
*w
)
5099 struct text_pos start
;
5100 int height
= window_box_height (w
);
5101 struct buffer
*old_buffer
;
5104 if (XBUFFER (w
->buffer
) != current_buffer
)
5106 old_buffer
= current_buffer
;
5107 set_buffer_internal (XBUFFER (w
->buffer
));
5112 /* In case W->start is out of the accessible range, do something
5113 reasonable. This happens in Info mode when Info-scroll-down
5114 calls (recenter -1) while W->start is 1. */
5115 if (XMARKER (w
->start
)->charpos
< BEGV
)
5116 SET_TEXT_POS (start
, BEGV
, BEGV_BYTE
);
5117 else if (XMARKER (w
->start
)->charpos
> ZV
)
5118 SET_TEXT_POS (start
, ZV
, ZV_BYTE
);
5120 SET_TEXT_POS_FROM_MARKER (start
, w
->start
);
5122 start_display (&it
, w
, start
);
5123 move_it_vertically (&it
, height
);
5124 bottom_y
= line_bottom_y (&it
);
5126 /* rms: On a non-window display,
5127 the value of it.vpos at the bottom of the screen
5128 seems to be 1 larger than window_box_height (w).
5129 This kludge fixes a bug whereby (move-to-window-line -1)
5130 when ZV is on the last screen line
5131 moves to the previous screen line instead of the last one. */
5132 if (! FRAME_WINDOW_P (XFRAME (w
->frame
)))
5135 /* Add in empty lines at the bottom of the window. */
5136 if (bottom_y
< height
)
5138 int uy
= FRAME_LINE_HEIGHT (it
.f
);
5139 it
.vpos
+= (height
- bottom_y
+ uy
- 1) / uy
;
5143 set_buffer_internal (old_buffer
);
5149 DEFUN ("recenter", Frecenter
, Srecenter
, 0, 1, "P",
5150 doc
: /* Center point in selected window and maybe redisplay frame.
5151 With prefix argument ARG, recenter putting point on screen line ARG
5152 relative to the selected window. If ARG is negative, it counts up from the
5153 bottom of the window. (ARG should be less than the height of the window.)
5155 If ARG is omitted or nil, then recenter with point on the middle line of
5156 the selected window; if the variable `recenter-redisplay' is non-nil,
5157 also erase the entire frame and redraw it (when `auto-resize-tool-bars'
5158 is set to `grow-only', this resets the tool-bar's height to the minimum
5159 height needed); if `recenter-redisplay' has the special value `tty',
5160 then only tty frame are redrawn.
5162 Just C-u as prefix means put point in the center of the window
5163 and redisplay normally--don't erase and redraw the frame. */)
5164 (register Lisp_Object arg
)
5166 struct window
*w
= XWINDOW (selected_window
);
5167 struct buffer
*buf
= XBUFFER (w
->buffer
);
5168 struct buffer
*obuf
= current_buffer
;
5170 EMACS_INT charpos
, bytepos
;
5171 int iarg
IF_LINT (= 0);
5172 int this_scroll_margin
;
5174 /* If redisplay is suppressed due to an error, try again. */
5175 obuf
->display_error_modiff
= 0;
5179 if (!NILP (Vrecenter_redisplay
)
5180 && (!EQ (Vrecenter_redisplay
, Qtty
)
5181 || !NILP (Ftty_type (selected_frame
))))
5185 /* Invalidate pixel data calculated for all compositions. */
5186 for (i
= 0; i
< n_compositions
; i
++)
5187 composition_table
[i
]->font
= NULL
;
5189 WINDOW_XFRAME (w
)->minimize_tool_bar_window_p
= 1;
5191 Fredraw_frame (WINDOW_FRAME (w
));
5192 SET_FRAME_GARBAGED (WINDOW_XFRAME (w
));
5197 else if (CONSP (arg
)) /* Just C-u. */
5201 arg
= Fprefix_numeric_value (arg
);
5206 set_buffer_internal (buf
);
5208 /* Do this after making BUF current
5209 in case scroll_margin is buffer-local. */
5210 this_scroll_margin
= max (0, scroll_margin
);
5211 this_scroll_margin
= min (this_scroll_margin
,
5212 XFASTINT (w
->total_lines
) / 4);
5214 /* Handle centering on a graphical frame specially. Such frames can
5215 have variable-height lines and centering point on the basis of
5216 line counts would lead to strange effects. */
5217 if (FRAME_WINDOW_P (XFRAME (w
->frame
)))
5224 SET_TEXT_POS (pt
, PT
, PT_BYTE
);
5225 start_display (&it
, w
, pt
);
5226 move_it_vertically_backward (&it
, window_box_height (w
) / 2);
5227 charpos
= IT_CHARPOS (it
);
5228 bytepos
= IT_BYTEPOS (it
);
5235 int extra_line_spacing
;
5236 int h
= window_box_height (w
);
5238 iarg
= - max (-iarg
, this_scroll_margin
);
5240 SET_TEXT_POS (pt
, PT
, PT_BYTE
);
5241 start_display (&it
, w
, pt
);
5243 /* Be sure we have the exact height of the full line containing PT. */
5244 move_it_by_lines (&it
, 0);
5246 /* The amount of pixels we have to move back is the window
5247 height minus what's displayed in the line containing PT,
5248 and the lines below. */
5251 move_it_by_lines (&it
, nlines
);
5253 if (it
.vpos
== nlines
)
5257 /* Last line has no newline */
5258 h
-= line_bottom_y (&it
);
5262 /* Don't reserve space for extra line spacing of last line. */
5263 extra_line_spacing
= it
.max_extra_line_spacing
;
5265 /* If we can't move down NLINES lines because we hit
5266 the end of the buffer, count in some empty lines. */
5267 if (it
.vpos
< nlines
)
5270 extra_line_spacing
= it
.extra_line_spacing
;
5271 h
-= nlines
* (FRAME_LINE_HEIGHT (it
.f
) + extra_line_spacing
);
5276 /* Now find the new top line (starting position) of the window. */
5277 start_display (&it
, w
, pt
);
5279 move_it_vertically_backward (&it
, h
);
5281 /* If extra line spacing is present, we may move too far
5282 back. This causes the last line to be only partially
5283 visible (which triggers redisplay to recenter that line
5284 in the middle), so move forward.
5285 But ignore extra line spacing on last line, as it is not
5286 considered to be part of the visible height of the line.
5288 h
+= extra_line_spacing
;
5289 while (-it
.current_y
> h
)
5290 move_it_by_lines (&it
, 1);
5292 charpos
= IT_CHARPOS (it
);
5293 bytepos
= IT_BYTEPOS (it
);
5297 struct position pos
;
5299 iarg
= max (iarg
, this_scroll_margin
);
5301 pos
= *vmotion (PT
, -iarg
, w
);
5302 charpos
= pos
.bufpos
;
5303 bytepos
= pos
.bytepos
;
5308 struct position pos
;
5309 int ht
= window_internal_height (w
);
5316 /* Don't let it get into the margin at either top or bottom. */
5317 iarg
= max (iarg
, this_scroll_margin
);
5318 iarg
= min (iarg
, ht
- this_scroll_margin
- 1);
5320 pos
= *vmotion (PT
, - iarg
, w
);
5321 charpos
= pos
.bufpos
;
5322 bytepos
= pos
.bytepos
;
5325 /* Set the new window start. */
5326 set_marker_both (w
->start
, w
->buffer
, charpos
, bytepos
);
5327 w
->window_end_valid
= Qnil
;
5329 w
->optional_new_start
= Qt
;
5331 if (bytepos
== BEGV_BYTE
|| FETCH_BYTE (bytepos
- 1) == '\n')
5332 w
->start_at_line_beg
= Qt
;
5334 w
->start_at_line_beg
= Qnil
;
5336 set_buffer_internal (obuf
);
5341 DEFUN ("window-text-height", Fwindow_text_height
, Swindow_text_height
,
5343 doc
: /* Return the height in lines of the text display area of WINDOW.
5344 WINDOW defaults to the selected window.
5346 The return value does not include the mode line, any header line, nor
5347 any partial-height lines in the text display area. */)
5348 (Lisp_Object window
)
5350 struct window
*w
= decode_window (window
);
5351 int pixel_height
= window_box_height (w
);
5352 int line_height
= pixel_height
/ FRAME_LINE_HEIGHT (XFRAME (w
->frame
));
5353 return make_number (line_height
);
5358 DEFUN ("move-to-window-line", Fmove_to_window_line
, Smove_to_window_line
,
5360 doc
: /* Position point relative to window.
5361 With no argument, position point at center of window.
5362 An argument specifies vertical position within the window;
5363 zero means top of window, negative means relative to bottom of window. */)
5366 struct window
*w
= XWINDOW (selected_window
);
5370 int this_scroll_margin
;
5373 if (!(BUFFERP (w
->buffer
)
5374 && XBUFFER (w
->buffer
) == current_buffer
))
5375 /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer
5376 when passed below to set_marker_both. */
5377 error ("move-to-window-line called from unrelated buffer");
5379 window
= selected_window
;
5380 start
= marker_position (w
->start
);
5381 if (start
< BEGV
|| start
> ZV
)
5383 int height
= window_internal_height (w
);
5384 Fvertical_motion (make_number (- (height
/ 2)), window
);
5385 set_marker_both (w
->start
, w
->buffer
, PT
, PT_BYTE
);
5386 w
->start_at_line_beg
= Fbolp ();
5387 w
->force_start
= Qt
;
5390 Fgoto_char (w
->start
);
5392 lines
= displayed_window_lines (w
);
5395 this_scroll_margin
= max (0, scroll_margin
);
5396 this_scroll_margin
= min (this_scroll_margin
, lines
/ 4);
5400 XSETFASTINT (arg
, lines
/ 2);
5403 int iarg
= XINT (Fprefix_numeric_value (arg
));
5406 iarg
= iarg
+ lines
;
5408 #if 0 /* This code would prevent move-to-window-line from moving point
5409 to a place inside the scroll margins (which would cause the
5410 next redisplay to scroll). I wrote this code, but then concluded
5411 it is probably better not to install it. However, it is here
5412 inside #if 0 so as not to lose it. -- rms. */
5414 /* Don't let it get into the margin at either top or bottom. */
5415 iarg
= max (iarg
, this_scroll_margin
);
5416 iarg
= min (iarg
, lines
- this_scroll_margin
- 1);
5419 arg
= make_number (iarg
);
5422 /* Skip past a partially visible first line. */
5424 XSETINT (arg
, XINT (arg
) + 1);
5426 return Fvertical_motion (arg
, window
);
5431 /***********************************************************************
5432 Window Configuration
5433 ***********************************************************************/
5435 struct save_window_data
5437 struct vectorlike_header header
;
5438 Lisp_Object selected_frame
;
5439 Lisp_Object current_window
;
5440 Lisp_Object current_buffer
;
5441 Lisp_Object minibuf_scroll_window
;
5442 Lisp_Object minibuf_selected_window
;
5443 Lisp_Object root_window
;
5444 Lisp_Object focus_frame
;
5445 /* A vector, each of whose elements is a struct saved_window
5447 Lisp_Object saved_windows
;
5449 /* All fields above are traced by the GC.
5450 From `fame-cols' down, the fields are ignored by the GC. */
5452 int frame_cols
, frame_lines
, frame_menu_bar_lines
;
5453 int frame_tool_bar_lines
;
5456 /* This is saved as a Lisp_Vector */
5459 struct vectorlike_header header
;
5461 Lisp_Object window
, clone_number
;
5462 Lisp_Object buffer
, start
, pointm
, mark
;
5463 Lisp_Object left_col
, top_line
, total_cols
, total_lines
;
5464 Lisp_Object normal_cols
, normal_lines
;
5465 Lisp_Object hscroll
, min_hscroll
;
5466 Lisp_Object parent
, prev
;
5467 Lisp_Object start_at_line_beg
;
5468 Lisp_Object display_table
;
5469 Lisp_Object left_margin_cols
, right_margin_cols
;
5470 Lisp_Object left_fringe_width
, right_fringe_width
, fringes_outside_margins
;
5471 Lisp_Object scroll_bar_width
, vertical_scroll_bar_type
, dedicated
;
5472 Lisp_Object splits
, nest
, window_parameters
;
5475 #define SAVED_WINDOW_N(swv,n) \
5476 ((struct saved_window *) (XVECTOR ((swv)->contents[(n)])))
5478 DEFUN ("window-configuration-p", Fwindow_configuration_p
, Swindow_configuration_p
, 1, 1, 0,
5479 doc
: /* Return t if OBJECT is a window-configuration object. */)
5480 (Lisp_Object object
)
5482 return WINDOW_CONFIGURATIONP (object
) ? Qt
: Qnil
;
5485 DEFUN ("window-configuration-frame", Fwindow_configuration_frame
, Swindow_configuration_frame
, 1, 1, 0,
5486 doc
: /* Return the frame that CONFIG, a window-configuration object, is about. */)
5487 (Lisp_Object config
)
5489 register struct save_window_data
*data
;
5490 struct Lisp_Vector
*saved_windows
;
5492 CHECK_WINDOW_CONFIGURATION (config
);
5494 data
= (struct save_window_data
*) XVECTOR (config
);
5495 saved_windows
= XVECTOR (data
->saved_windows
);
5496 return XWINDOW (SAVED_WINDOW_N (saved_windows
, 0)->window
)->frame
;
5499 DEFUN ("set-window-configuration", Fset_window_configuration
,
5500 Sset_window_configuration
, 1, 1, 0,
5501 doc
: /* Set the configuration of windows and buffers as specified by CONFIGURATION.
5502 CONFIGURATION must be a value previously returned
5503 by `current-window-configuration' (which see).
5504 If CONFIGURATION was made from a frame that is now deleted,
5505 only frame-independent values can be restored. In this case,
5506 the return value is nil. Otherwise the value is t. */)
5507 (Lisp_Object configuration
)
5509 register struct save_window_data
*data
;
5510 struct Lisp_Vector
*saved_windows
;
5511 Lisp_Object new_current_buffer
;
5514 EMACS_INT old_point
= -1;
5516 CHECK_WINDOW_CONFIGURATION (configuration
);
5518 data
= (struct save_window_data
*) XVECTOR (configuration
);
5519 saved_windows
= XVECTOR (data
->saved_windows
);
5521 new_current_buffer
= data
->current_buffer
;
5522 if (NILP (BVAR (XBUFFER (new_current_buffer
), name
)))
5523 new_current_buffer
= Qnil
;
5526 if (XBUFFER (new_current_buffer
) == current_buffer
)
5527 /* The code further down "preserves point" by saving here PT in
5528 old_point and then setting it later back into PT. When the
5529 current-selected-window and the final-selected-window both show
5530 the current buffer, this suffers from the problem that the
5531 current PT is the window-point of the current-selected-window,
5532 while the final PT is the point of the final-selected-window, so
5533 this copy from one PT to the other would end up moving the
5534 window-point of the final-selected-window to the window-point of
5535 the current-selected-window. So we have to be careful which
5536 point of the current-buffer we copy into old_point. */
5537 if (EQ (XWINDOW (data
->current_window
)->buffer
, new_current_buffer
)
5538 && WINDOWP (selected_window
)
5539 && EQ (XWINDOW (selected_window
)->buffer
, new_current_buffer
)
5540 && !EQ (selected_window
, data
->current_window
))
5541 old_point
= XMARKER (XWINDOW (data
->current_window
)->pointm
)->charpos
;
5545 /* BUF_PT (XBUFFER (new_current_buffer)) gives us the position of
5546 point in new_current_buffer as of the last time this buffer was
5547 used. This can be non-deterministic since it can be changed by
5548 things like jit-lock by mere temporary selection of some random
5549 window that happens to show this buffer.
5550 So if possible we want this arbitrary choice of "which point" to
5551 be the one from the to-be-selected-window so as to prevent this
5552 window's cursor from being copied from another window. */
5553 if (EQ (XWINDOW (data
->current_window
)->buffer
, new_current_buffer
)
5554 /* If current_window = selected_window, its point is in BUF_PT. */
5555 && !EQ (selected_window
, data
->current_window
))
5556 old_point
= XMARKER (XWINDOW (data
->current_window
)->pointm
)->charpos
;
5558 old_point
= BUF_PT (XBUFFER (new_current_buffer
));
5561 frame
= XWINDOW (SAVED_WINDOW_N (saved_windows
, 0)->window
)->frame
;
5564 /* If f is a dead frame, don't bother rebuilding its window tree.
5565 However, there is other stuff we should still try to do below. */
5566 if (FRAME_LIVE_P (f
))
5568 register struct window
*w
;
5569 register struct saved_window
*p
;
5570 struct window
*root_window
;
5571 struct window
**leaf_windows
;
5575 /* If the frame has been resized since this window configuration was
5576 made, we change the frame to the size specified in the
5577 configuration, restore the configuration, and then resize it
5578 back. We keep track of the prevailing height in these variables. */
5579 int previous_frame_lines
= FRAME_LINES (f
);
5580 int previous_frame_cols
= FRAME_COLS (f
);
5581 int previous_frame_menu_bar_lines
= FRAME_MENU_BAR_LINES (f
);
5582 int previous_frame_tool_bar_lines
= FRAME_TOOL_BAR_LINES (f
);
5584 /* The mouse highlighting code could get screwed up
5585 if it runs during this. */
5588 if (data
->frame_lines
!= previous_frame_lines
5589 || data
->frame_cols
!= previous_frame_cols
)
5590 change_frame_size (f
, data
->frame_lines
,
5591 data
->frame_cols
, 0, 0, 0);
5592 #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
5593 if (data
->frame_menu_bar_lines
5594 != previous_frame_menu_bar_lines
)
5595 x_set_menu_bar_lines (f
, make_number (data
->frame_menu_bar_lines
),
5597 #ifdef HAVE_WINDOW_SYSTEM
5598 if (data
->frame_tool_bar_lines
5599 != previous_frame_tool_bar_lines
)
5600 x_set_tool_bar_lines (f
, make_number (data
->frame_tool_bar_lines
),
5605 /* "Swap out" point from the selected window's buffer
5606 into the window itself. (Normally the pointm of the selected
5607 window holds garbage.) We do this now, before
5608 restoring the window contents, and prevent it from
5609 being done later on when we select a new window. */
5610 if (! NILP (XWINDOW (selected_window
)->buffer
))
5612 w
= XWINDOW (selected_window
);
5613 set_marker_both (w
->pointm
,
5615 BUF_PT (XBUFFER (w
->buffer
)),
5616 BUF_PT_BYTE (XBUFFER (w
->buffer
)));
5619 windows_or_buffers_changed
++;
5620 FRAME_WINDOW_SIZES_CHANGED (f
) = 1;
5622 /* Problem: Freeing all matrices and later allocating them again
5623 is a serious redisplay flickering problem. What we would
5624 really like to do is to free only those matrices not reused
5626 root_window
= XWINDOW (FRAME_ROOT_WINDOW (f
));
5628 = (struct window
**) alloca (count_windows (root_window
)
5629 * sizeof (struct window
*));
5630 n_leaf_windows
= get_leaf_windows (root_window
, leaf_windows
, 0);
5633 Mark all windows now on frame as "deleted".
5634 Restoring the new configuration "undeletes" any that are in it.
5636 Save their current buffers in their height fields, since we may
5637 need it later, if a buffer saved in the configuration is now
5639 delete_all_subwindows (FRAME_ROOT_WINDOW (f
));
5641 for (k
= 0; k
< saved_windows
->header
.size
; k
++)
5643 p
= SAVED_WINDOW_N (saved_windows
, k
);
5644 w
= XWINDOW (p
->window
);
5647 if (!NILP (p
->parent
))
5648 w
->parent
= SAVED_WINDOW_N (saved_windows
,
5649 XFASTINT (p
->parent
))->window
;
5653 if (!NILP (p
->prev
))
5655 w
->prev
= SAVED_WINDOW_N (saved_windows
,
5656 XFASTINT (p
->prev
))->window
;
5657 XWINDOW (w
->prev
)->next
= p
->window
;
5662 if (!NILP (w
->parent
))
5664 if (EQ (p
->total_cols
, XWINDOW (w
->parent
)->total_cols
))
5666 XWINDOW (w
->parent
)->vchild
= p
->window
;
5667 XWINDOW (w
->parent
)->hchild
= Qnil
;
5671 XWINDOW (w
->parent
)->hchild
= p
->window
;
5672 XWINDOW (w
->parent
)->vchild
= Qnil
;
5677 w
->clone_number
= p
->clone_number
;
5678 /* If we squirreled away the buffer in the window's height,
5680 if (BUFFERP (w
->total_lines
))
5681 w
->buffer
= w
->total_lines
;
5682 w
->left_col
= p
->left_col
;
5683 w
->top_line
= p
->top_line
;
5684 w
->total_cols
= p
->total_cols
;
5685 w
->total_lines
= p
->total_lines
;
5686 w
->normal_cols
= p
->normal_cols
;
5687 w
->normal_lines
= p
->normal_lines
;
5688 w
->hscroll
= p
->hscroll
;
5689 w
->min_hscroll
= p
->min_hscroll
;
5690 w
->display_table
= p
->display_table
;
5691 w
->left_margin_cols
= p
->left_margin_cols
;
5692 w
->right_margin_cols
= p
->right_margin_cols
;
5693 w
->left_fringe_width
= p
->left_fringe_width
;
5694 w
->right_fringe_width
= p
->right_fringe_width
;
5695 w
->fringes_outside_margins
= p
->fringes_outside_margins
;
5696 w
->scroll_bar_width
= p
->scroll_bar_width
;
5697 w
->vertical_scroll_bar_type
= p
->vertical_scroll_bar_type
;
5698 w
->dedicated
= p
->dedicated
;
5699 w
->splits
= p
->splits
;
5701 w
->window_parameters
= p
->window_parameters
;
5702 XSETFASTINT (w
->last_modified
, 0);
5703 XSETFASTINT (w
->last_overlay_modified
, 0);
5705 /* Reinstall the saved buffer and pointers into it. */
5706 if (NILP (p
->buffer
))
5707 w
->buffer
= p
->buffer
;
5710 if (!NILP (BVAR (XBUFFER (p
->buffer
), name
)))
5711 /* If saved buffer is alive, install it. */
5713 w
->buffer
= p
->buffer
;
5714 w
->start_at_line_beg
= p
->start_at_line_beg
;
5715 set_marker_restricted (w
->start
, p
->start
, w
->buffer
);
5716 set_marker_restricted (w
->pointm
, p
->pointm
, w
->buffer
);
5717 Fset_marker (BVAR (XBUFFER (w
->buffer
), mark
),
5718 p
->mark
, w
->buffer
);
5720 /* As documented in Fcurrent_window_configuration, don't
5721 restore the location of point in the buffer which was
5722 current when the window configuration was recorded. */
5723 if (!EQ (p
->buffer
, new_current_buffer
)
5724 && XBUFFER (p
->buffer
) == current_buffer
)
5725 Fgoto_char (w
->pointm
);
5727 else if (NILP (w
->buffer
) || NILP (BVAR (XBUFFER (w
->buffer
), name
)))
5728 /* Else unless window has a live buffer, get one. */
5730 w
->buffer
= Fcdr (Fcar (Vbuffer_alist
));
5731 /* This will set the markers to beginning of visible
5733 set_marker_restricted (w
->start
, make_number (0), w
->buffer
);
5734 set_marker_restricted (w
->pointm
, make_number (0),w
->buffer
);
5735 w
->start_at_line_beg
= Qt
;
5738 /* Keeping window's old buffer; make sure the markers
5741 /* Set window markers at start of visible range. */
5742 if (XMARKER (w
->start
)->buffer
== 0)
5743 set_marker_restricted (w
->start
, make_number (0),
5745 if (XMARKER (w
->pointm
)->buffer
== 0)
5746 set_marker_restricted_both (w
->pointm
, w
->buffer
,
5747 BUF_PT (XBUFFER (w
->buffer
)),
5748 BUF_PT_BYTE (XBUFFER (w
->buffer
)));
5749 w
->start_at_line_beg
= Qt
;
5754 FRAME_ROOT_WINDOW (f
) = data
->root_window
;
5756 /* Arrange *not* to restore point in the buffer that was
5757 current when the window configuration was saved. */
5758 if (EQ (XWINDOW (data
->current_window
)->buffer
, new_current_buffer
))
5759 set_marker_restricted (XWINDOW (data
->current_window
)->pointm
,
5760 make_number (old_point
),
5761 XWINDOW (data
->current_window
)->buffer
);
5763 /* In the following call to `select-window, prevent "swapping
5764 out point" in the old selected window using the buffer that
5765 has been restored into it. We already swapped out that point
5766 from that window's old buffer. */
5767 select_window (data
->current_window
, Qnil
, 1);
5768 BVAR (XBUFFER (XWINDOW (selected_window
)->buffer
), last_selected_window
)
5771 if (NILP (data
->focus_frame
)
5772 || (FRAMEP (data
->focus_frame
)
5773 && FRAME_LIVE_P (XFRAME (data
->focus_frame
))))
5774 Fredirect_frame_focus (frame
, data
->focus_frame
);
5776 /* Set the screen height to the value it had before this function. */
5777 if (previous_frame_lines
!= FRAME_LINES (f
)
5778 || previous_frame_cols
!= FRAME_COLS (f
))
5779 change_frame_size (f
, previous_frame_lines
, previous_frame_cols
,
5781 #if defined (HAVE_WINDOW_SYSTEM) || defined (MSDOS)
5782 if (previous_frame_menu_bar_lines
!= FRAME_MENU_BAR_LINES (f
))
5783 x_set_menu_bar_lines (f
, make_number (previous_frame_menu_bar_lines
),
5785 #ifdef HAVE_WINDOW_SYSTEM
5786 if (previous_frame_tool_bar_lines
!= FRAME_TOOL_BAR_LINES (f
))
5787 x_set_tool_bar_lines (f
, make_number (previous_frame_tool_bar_lines
),
5792 /* Now, free glyph matrices in windows that were not reused. */
5793 for (i
= n
= 0; i
< n_leaf_windows
; ++i
)
5795 if (NILP (leaf_windows
[i
]->buffer
))
5797 /* Assert it's not reused as a combination. */
5798 xassert (NILP (leaf_windows
[i
]->hchild
)
5799 && NILP (leaf_windows
[i
]->vchild
));
5800 free_window_matrices (leaf_windows
[i
]);
5802 else if (EQ (leaf_windows
[i
]->buffer
, new_current_buffer
))
5810 /* Fselect_window will have made f the selected frame, so we
5811 reselect the proper frame here. Fhandle_switch_frame will change the
5812 selected window too, but that doesn't make the call to
5813 Fselect_window above totally superfluous; it still sets f's
5815 if (FRAME_LIVE_P (XFRAME (data
->selected_frame
)))
5816 do_switch_frame (data
->selected_frame
, 0, 0, Qnil
);
5818 run_window_configuration_change_hook (f
);
5821 if (!NILP (new_current_buffer
))
5822 Fset_buffer (new_current_buffer
);
5824 Vminibuf_scroll_window
= data
->minibuf_scroll_window
;
5825 minibuf_selected_window
= data
->minibuf_selected_window
;
5827 return (FRAME_LIVE_P (f
) ? Qt
: Qnil
);
5831 /* Delete all subwindows reachable via the next, vchild, and hchild
5834 delete_all_subwindows (Lisp_Object window
)
5836 register struct window
*w
;
5838 w
= XWINDOW (window
);
5840 if (!NILP (w
->next
))
5841 /* Delete WINDOW's siblings (we traverse postorderly). */
5842 delete_all_subwindows (w
->next
);
5844 w
->total_lines
= w
->buffer
; /* See Fset_window_configuration for excuse. */
5846 if (!NILP (w
->vchild
))
5848 delete_all_subwindows (w
->vchild
);
5851 else if (!NILP (w
->hchild
))
5853 delete_all_subwindows (w
->hchild
);
5856 else if (!NILP (w
->buffer
))
5859 unchain_marker (XMARKER (w
->pointm
));
5860 unchain_marker (XMARKER (w
->start
));
5864 Vwindow_list
= Qnil
;
5868 count_windows (register struct window
*window
)
5870 register int count
= 1;
5871 if (!NILP (window
->next
))
5872 count
+= count_windows (XWINDOW (window
->next
));
5873 if (!NILP (window
->vchild
))
5874 count
+= count_windows (XWINDOW (window
->vchild
));
5875 if (!NILP (window
->hchild
))
5876 count
+= count_windows (XWINDOW (window
->hchild
));
5881 /* Fill vector FLAT with leaf windows under W, starting at index I.
5882 Value is last index + 1. */
5884 get_leaf_windows (struct window
*w
, struct window
**flat
, int i
)
5888 if (!NILP (w
->hchild
))
5889 i
= get_leaf_windows (XWINDOW (w
->hchild
), flat
, i
);
5890 else if (!NILP (w
->vchild
))
5891 i
= get_leaf_windows (XWINDOW (w
->vchild
), flat
, i
);
5895 w
= NILP (w
->next
) ? 0 : XWINDOW (w
->next
);
5902 /* Return a pointer to the glyph W's physical cursor is on. Value is
5903 null if W's current matrix is invalid, so that no meaningfull glyph
5906 get_phys_cursor_glyph (struct window
*w
)
5908 struct glyph_row
*row
;
5909 struct glyph
*glyph
;
5911 if (w
->phys_cursor
.vpos
>= 0
5912 && w
->phys_cursor
.vpos
< w
->current_matrix
->nrows
5913 && (row
= MATRIX_ROW (w
->current_matrix
, w
->phys_cursor
.vpos
),
5915 && row
->used
[TEXT_AREA
] > w
->phys_cursor
.hpos
)
5916 glyph
= row
->glyphs
[TEXT_AREA
] + w
->phys_cursor
.hpos
;
5925 save_window_save (Lisp_Object window
, struct Lisp_Vector
*vector
, int i
)
5927 register struct saved_window
*p
;
5928 register struct window
*w
;
5929 register Lisp_Object tem
;
5931 for (;!NILP (window
); window
= w
->next
)
5933 p
= SAVED_WINDOW_N (vector
, i
);
5934 w
= XWINDOW (window
);
5936 XSETFASTINT (w
->temslot
, i
); i
++;
5938 p
->clone_number
= w
->clone_number
;
5939 p
->buffer
= w
->buffer
;
5940 p
->left_col
= w
->left_col
;
5941 p
->top_line
= w
->top_line
;
5942 p
->total_cols
= w
->total_cols
;
5943 p
->total_lines
= w
->total_lines
;
5944 p
->normal_cols
= w
->normal_cols
;
5945 p
->normal_lines
= w
->normal_lines
;
5946 p
->hscroll
= w
->hscroll
;
5947 p
->min_hscroll
= w
->min_hscroll
;
5948 p
->display_table
= w
->display_table
;
5949 p
->left_margin_cols
= w
->left_margin_cols
;
5950 p
->right_margin_cols
= w
->right_margin_cols
;
5951 p
->left_fringe_width
= w
->left_fringe_width
;
5952 p
->right_fringe_width
= w
->right_fringe_width
;
5953 p
->fringes_outside_margins
= w
->fringes_outside_margins
;
5954 p
->scroll_bar_width
= w
->scroll_bar_width
;
5955 p
->vertical_scroll_bar_type
= w
->vertical_scroll_bar_type
;
5956 p
->dedicated
= w
->dedicated
;
5957 p
->splits
= w
->splits
;
5959 p
->window_parameters
= w
->window_parameters
;
5960 if (!NILP (w
->buffer
))
5962 /* Save w's value of point in the window configuration.
5963 If w is the selected window, then get the value of point
5964 from the buffer; pointm is garbage in the selected window. */
5965 if (EQ (window
, selected_window
))
5967 p
->pointm
= Fmake_marker ();
5968 set_marker_both (p
->pointm
, w
->buffer
,
5969 BUF_PT (XBUFFER (w
->buffer
)),
5970 BUF_PT_BYTE (XBUFFER (w
->buffer
)));
5973 p
->pointm
= Fcopy_marker (w
->pointm
, Qnil
);
5975 p
->start
= Fcopy_marker (w
->start
, Qnil
);
5976 p
->start_at_line_beg
= w
->start_at_line_beg
;
5978 tem
= BVAR (XBUFFER (w
->buffer
), mark
);
5979 p
->mark
= Fcopy_marker (tem
, Qnil
);
5986 p
->start_at_line_beg
= Qnil
;
5989 if (NILP (w
->parent
))
5992 p
->parent
= XWINDOW (w
->parent
)->temslot
;
5997 p
->prev
= XWINDOW (w
->prev
)->temslot
;
5999 if (!NILP (w
->vchild
))
6000 i
= save_window_save (w
->vchild
, vector
, i
);
6001 if (!NILP (w
->hchild
))
6002 i
= save_window_save (w
->hchild
, vector
, i
);
6008 DEFUN ("current-window-configuration", Fcurrent_window_configuration
,
6009 Scurrent_window_configuration
, 0, 1, 0,
6010 doc
: /* Return an object representing the current window configuration of FRAME.
6011 If FRAME is nil or omitted, use the selected frame.
6012 This describes the number of windows, their sizes and current buffers,
6013 and for each displayed buffer, where display starts, and the positions of
6014 point and mark. An exception is made for point in the current buffer:
6015 its value is -not- saved.
6016 This also records the currently selected frame, and FRAME's focus
6017 redirection (see `redirect-frame-focus'). */)
6020 register Lisp_Object tem
;
6021 register int n_windows
;
6022 register struct save_window_data
*data
;
6027 frame
= selected_frame
;
6028 CHECK_LIVE_FRAME (frame
);
6031 n_windows
= count_windows (XWINDOW (FRAME_ROOT_WINDOW (f
)));
6032 data
= ALLOCATE_PSEUDOVECTOR (struct save_window_data
, frame_cols
,
6033 PVEC_WINDOW_CONFIGURATION
);
6035 data
->frame_cols
= FRAME_COLS (f
);
6036 data
->frame_lines
= FRAME_LINES (f
);
6037 data
->frame_menu_bar_lines
= FRAME_MENU_BAR_LINES (f
);
6038 data
->frame_tool_bar_lines
= FRAME_TOOL_BAR_LINES (f
);
6039 data
->selected_frame
= selected_frame
;
6040 data
->current_window
= FRAME_SELECTED_WINDOW (f
);
6041 XSETBUFFER (data
->current_buffer
, current_buffer
);
6042 data
->minibuf_scroll_window
= minibuf_level
> 0 ? Vminibuf_scroll_window
: Qnil
;
6043 data
->minibuf_selected_window
= minibuf_level
> 0 ? minibuf_selected_window
: Qnil
;
6044 data
->root_window
= FRAME_ROOT_WINDOW (f
);
6045 data
->focus_frame
= FRAME_FOCUS_FRAME (f
);
6046 tem
= Fmake_vector (make_number (n_windows
), Qnil
);
6047 data
->saved_windows
= tem
;
6048 for (i
= 0; i
< n_windows
; i
++)
6049 XVECTOR (tem
)->contents
[i
]
6050 = Fmake_vector (make_number (VECSIZE (struct saved_window
)), Qnil
);
6051 save_window_save (FRAME_ROOT_WINDOW (f
), XVECTOR (tem
), 0);
6052 XSETWINDOW_CONFIGURATION (tem
, data
);
6057 /***********************************************************************
6059 ***********************************************************************/
6062 window_tree (struct window
*w
)
6064 Lisp_Object tail
= Qnil
;
6065 Lisp_Object result
= Qnil
;
6072 if (!NILP (w
->hchild
))
6073 wn
= Fcons (Qnil
, Fcons (Fwindow_edges (wn
),
6074 window_tree (XWINDOW (w
->hchild
))));
6075 else if (!NILP (w
->vchild
))
6076 wn
= Fcons (Qt
, Fcons (Fwindow_edges (wn
),
6077 window_tree (XWINDOW (w
->vchild
))));
6081 result
= tail
= Fcons (wn
, Qnil
);
6085 XSETCDR (tail
, Fcons (wn
, Qnil
));
6089 w
= NILP (w
->next
) ? 0 : XWINDOW (w
->next
);
6097 DEFUN ("window-tree", Fwindow_tree
, Swindow_tree
,
6099 doc
: /* Return the window tree for frame FRAME.
6101 The return value is a list of the form (ROOT MINI), where ROOT
6102 represents the window tree of the frame's root window, and MINI
6103 is the frame's minibuffer window.
6105 If the root window is not split, ROOT is the root window itself.
6106 Otherwise, ROOT is a list (DIR EDGES W1 W2 ...) where DIR is nil for a
6107 horizontal split, and t for a vertical split, EDGES gives the combined
6108 size and position of the subwindows in the split, and the rest of the
6109 elements are the subwindows in the split. Each of the subwindows may
6110 again be a window or a list representing a window split, and so on.
6111 EDGES is a list \(LEFT TOP RIGHT BOTTOM) as returned by `window-edges'.
6113 If FRAME is nil or omitted, return information on the currently
6120 frame
= selected_frame
;
6122 CHECK_FRAME (frame
);
6125 if (!FRAME_LIVE_P (f
))
6128 return window_tree (XWINDOW (FRAME_ROOT_WINDOW (f
)));
6132 /***********************************************************************
6134 ***********************************************************************/
6136 DEFUN ("set-window-margins", Fset_window_margins
, Sset_window_margins
,
6138 doc
: /* Set width of marginal areas of window WINDOW.
6139 If WINDOW is nil, set margins of the currently selected window.
6140 Second arg LEFT-WIDTH specifies the number of character cells to
6141 reserve for the left marginal area. Optional third arg RIGHT-WIDTH
6142 does the same for the right marginal area. A nil width parameter
6143 means no margin. */)
6144 (Lisp_Object window
, Lisp_Object left_width
, Lisp_Object right_width
)
6146 struct window
*w
= decode_window (window
);
6148 /* Translate negative or zero widths to nil.
6149 Margins that are too wide have to be checked elsewhere. */
6151 if (!NILP (left_width
))
6153 CHECK_NUMBER (left_width
);
6154 if (XINT (left_width
) <= 0)
6158 if (!NILP (right_width
))
6160 CHECK_NUMBER (right_width
);
6161 if (XINT (right_width
) <= 0)
6165 if (!EQ (w
->left_margin_cols
, left_width
)
6166 || !EQ (w
->right_margin_cols
, right_width
))
6168 w
->left_margin_cols
= left_width
;
6169 w
->right_margin_cols
= right_width
;
6171 adjust_window_margins (w
);
6173 ++windows_or_buffers_changed
;
6174 adjust_glyphs (XFRAME (WINDOW_FRAME (w
)));
6181 DEFUN ("window-margins", Fwindow_margins
, Swindow_margins
,
6183 doc
: /* Get width of marginal areas of window WINDOW.
6184 If WINDOW is omitted or nil, use the currently selected window.
6185 Value is a cons of the form (LEFT-WIDTH . RIGHT-WIDTH).
6186 If a marginal area does not exist, its width will be returned
6188 (Lisp_Object window
)
6190 struct window
*w
= decode_window (window
);
6191 return Fcons (w
->left_margin_cols
, w
->right_margin_cols
);
6196 /***********************************************************************
6198 ***********************************************************************/
6200 DEFUN ("set-window-fringes", Fset_window_fringes
, Sset_window_fringes
,
6202 doc
: /* Set the fringe widths of window WINDOW.
6203 If WINDOW is nil, set the fringe widths of the currently selected
6205 Second arg LEFT-WIDTH specifies the number of pixels to reserve for
6206 the left fringe. Optional third arg RIGHT-WIDTH specifies the right
6207 fringe width. If a fringe width arg is nil, that means to use the
6208 frame's default fringe width. Default fringe widths can be set with
6209 the command `set-fringe-style'.
6210 If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes
6211 outside of the display margins. By default, fringes are drawn between
6212 display marginal areas and the text area. */)
6213 (Lisp_Object window
, Lisp_Object left_width
, Lisp_Object right_width
, Lisp_Object outside_margins
)
6215 struct window
*w
= decode_window (window
);
6217 if (!NILP (left_width
))
6218 CHECK_NATNUM (left_width
);
6219 if (!NILP (right_width
))
6220 CHECK_NATNUM (right_width
);
6222 /* Do nothing on a tty. */
6223 if (FRAME_WINDOW_P (WINDOW_XFRAME (w
))
6224 && (!EQ (w
->left_fringe_width
, left_width
)
6225 || !EQ (w
->right_fringe_width
, right_width
)
6226 || !EQ (w
->fringes_outside_margins
, outside_margins
)))
6228 w
->left_fringe_width
= left_width
;
6229 w
->right_fringe_width
= right_width
;
6230 w
->fringes_outside_margins
= outside_margins
;
6232 adjust_window_margins (w
);
6234 clear_glyph_matrix (w
->current_matrix
);
6235 w
->window_end_valid
= Qnil
;
6237 ++windows_or_buffers_changed
;
6238 adjust_glyphs (XFRAME (WINDOW_FRAME (w
)));
6245 DEFUN ("window-fringes", Fwindow_fringes
, Swindow_fringes
,
6247 doc
: /* Get width of fringes of window WINDOW.
6248 If WINDOW is omitted or nil, use the currently selected window.
6249 Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */)
6250 (Lisp_Object window
)
6252 struct window
*w
= decode_window (window
);
6254 return Fcons (make_number (WINDOW_LEFT_FRINGE_WIDTH (w
)),
6255 Fcons (make_number (WINDOW_RIGHT_FRINGE_WIDTH (w
)),
6256 Fcons ((WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w
)
6257 ? Qt
: Qnil
), Qnil
)));
6262 /***********************************************************************
6264 ***********************************************************************/
6266 DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars
,
6267 Sset_window_scroll_bars
, 2, 4, 0,
6268 doc
: /* Set width and type of scroll bars of window WINDOW.
6269 If window is nil, set scroll bars of the currently selected window.
6270 Second parameter WIDTH specifies the pixel width for the scroll bar;
6271 this is automatically adjusted to a multiple of the frame column width.
6272 Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
6273 bar: left, right, or nil.
6274 If WIDTH is nil, use the frame's scroll-bar width.
6275 If VERTICAL-TYPE is t, use the frame's scroll-bar type.
6276 Fourth parameter HORIZONTAL-TYPE is currently unused. */)
6277 (Lisp_Object window
, Lisp_Object width
, Lisp_Object vertical_type
, Lisp_Object horizontal_type
)
6279 struct window
*w
= decode_window (window
);
6283 CHECK_NATNUM (width
);
6285 if (XINT (width
) == 0)
6286 vertical_type
= Qnil
;
6289 if (!(NILP (vertical_type
)
6290 || EQ (vertical_type
, Qleft
)
6291 || EQ (vertical_type
, Qright
)
6292 || EQ (vertical_type
, Qt
)))
6293 error ("Invalid type of vertical scroll bar");
6295 if (!EQ (w
->scroll_bar_width
, width
)
6296 || !EQ (w
->vertical_scroll_bar_type
, vertical_type
))
6298 w
->scroll_bar_width
= width
;
6299 w
->vertical_scroll_bar_type
= vertical_type
;
6301 adjust_window_margins (w
);
6303 clear_glyph_matrix (w
->current_matrix
);
6304 w
->window_end_valid
= Qnil
;
6306 ++windows_or_buffers_changed
;
6307 adjust_glyphs (XFRAME (WINDOW_FRAME (w
)));
6314 DEFUN ("window-scroll-bars", Fwindow_scroll_bars
, Swindow_scroll_bars
,
6316 doc
: /* Get width and type of scroll bars of window WINDOW.
6317 If WINDOW is omitted or nil, use the currently selected window.
6318 Value is a list of the form (WIDTH COLS VERTICAL-TYPE HORIZONTAL-TYPE).
6319 If WIDTH is nil or TYPE is t, the window is using the frame's corresponding
6321 (Lisp_Object window
)
6323 struct window
*w
= decode_window (window
);
6324 return Fcons (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w
)
6325 ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (w
)
6326 : WINDOW_SCROLL_BAR_AREA_WIDTH (w
))),
6327 Fcons (make_number (WINDOW_SCROLL_BAR_COLS (w
)),
6328 Fcons (w
->vertical_scroll_bar_type
,
6329 Fcons (Qnil
, Qnil
))));
6334 /***********************************************************************
6336 ***********************************************************************/
6338 DEFUN ("window-vscroll", Fwindow_vscroll
, Swindow_vscroll
, 0, 2, 0,
6339 doc
: /* Return the amount by which WINDOW is scrolled vertically.
6340 Use the selected window if WINDOW is nil or omitted.
6341 Normally, value is a multiple of the canonical character height of WINDOW;
6342 optional second arg PIXELS-P means value is measured in pixels. */)
6343 (Lisp_Object window
, Lisp_Object pixels_p
)
6350 window
= selected_window
;
6352 CHECK_WINDOW (window
);
6353 w
= XWINDOW (window
);
6354 f
= XFRAME (w
->frame
);
6356 if (FRAME_WINDOW_P (f
))
6357 result
= (NILP (pixels_p
)
6358 ? FRAME_CANON_Y_FROM_PIXEL_Y (f
, -w
->vscroll
)
6359 : make_number (-w
->vscroll
));
6361 result
= make_number (0);
6366 DEFUN ("set-window-vscroll", Fset_window_vscroll
, Sset_window_vscroll
,
6368 doc
: /* Set amount by which WINDOW should be scrolled vertically to VSCROLL.
6369 WINDOW nil means use the selected window. Normally, VSCROLL is a
6370 non-negative multiple of the canonical character height of WINDOW;
6371 optional third arg PIXELS-P non-nil means that VSCROLL is in pixels.
6372 If PIXELS-P is nil, VSCROLL may have to be rounded so that it
6373 corresponds to an integral number of pixels. The return value is the
6374 result of this rounding.
6375 If PIXELS-P is non-nil, the return value is VSCROLL. */)
6376 (Lisp_Object window
, Lisp_Object vscroll
, Lisp_Object pixels_p
)
6382 window
= selected_window
;
6384 CHECK_WINDOW (window
);
6385 CHECK_NUMBER_OR_FLOAT (vscroll
);
6387 w
= XWINDOW (window
);
6388 f
= XFRAME (w
->frame
);
6390 if (FRAME_WINDOW_P (f
))
6392 int old_dy
= w
->vscroll
;
6394 w
->vscroll
= - (NILP (pixels_p
)
6395 ? FRAME_LINE_HEIGHT (f
) * XFLOATINT (vscroll
)
6396 : XFLOATINT (vscroll
));
6397 w
->vscroll
= min (w
->vscroll
, 0);
6399 if (w
->vscroll
!= old_dy
)
6401 /* Adjust glyph matrix of the frame if the virtual display
6402 area becomes larger than before. */
6403 if (w
->vscroll
< 0 && w
->vscroll
< old_dy
)
6406 /* Prevent redisplay shortcuts. */
6407 XBUFFER (w
->buffer
)->prevent_redisplay_optimizations_p
= 1;
6411 return Fwindow_vscroll (window
, pixels_p
);
6415 /* Call FN for all leaf windows on frame F. FN is called with the
6416 first argument being a pointer to the leaf window, and with
6417 additional argument USER_DATA. Stops when FN returns 0. */
6420 foreach_window (struct frame
*f
, int (*fn
) (struct window
*, void *),
6423 /* delete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */
6424 if (WINDOWP (FRAME_ROOT_WINDOW (f
)))
6425 foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f
)), fn
, user_data
);
6429 /* Helper function for foreach_window. Call FN for all leaf windows
6430 reachable from W. FN is called with the first argument being a
6431 pointer to the leaf window, and with additional argument USER_DATA.
6432 Stop when FN returns 0. Value is 0 if stopped by FN. */
6435 foreach_window_1 (struct window
*w
, int (*fn
) (struct window
*, void *), void *user_data
)
6439 for (cont
= 1; w
&& cont
;)
6441 if (!NILP (w
->hchild
))
6442 cont
= foreach_window_1 (XWINDOW (w
->hchild
), fn
, user_data
);
6443 else if (!NILP (w
->vchild
))
6444 cont
= foreach_window_1 (XWINDOW (w
->vchild
), fn
, user_data
);
6446 cont
= fn (w
, user_data
);
6448 w
= NILP (w
->next
) ? 0 : XWINDOW (w
->next
);
6455 /* Freeze or unfreeze the window start of W unless it is a
6456 mini-window or the selected window. FREEZE_P non-null means freeze
6457 the window start. */
6460 freeze_window_start (struct window
*w
, void *freeze_p
)
6462 if (MINI_WINDOW_P (w
)
6463 || (WINDOWP (selected_window
) /* Can be nil in corner cases. */
6464 && (w
== XWINDOW (selected_window
)
6465 || (MINI_WINDOW_P (XWINDOW (selected_window
))
6466 && ! NILP (Vminibuf_scroll_window
)
6467 && w
== XWINDOW (Vminibuf_scroll_window
)))))
6470 w
->frozen_window_start_p
= freeze_p
!= NULL
;
6475 /* Freeze or unfreeze the window starts of all leaf windows on frame
6476 F, except the selected window and a mini-window. FREEZE_P non-zero
6477 means freeze the window start. */
6480 freeze_window_starts (struct frame
*f
, int freeze_p
)
6482 foreach_window (f
, freeze_window_start
, (void *) (freeze_p
? f
: 0));
6486 /***********************************************************************
6488 ***********************************************************************/
6490 /* Return 1 if window configurations C1 and C2
6491 describe the same state of affairs. This is used by Fequal. */
6494 compare_window_configurations (Lisp_Object c1
, Lisp_Object c2
, int ignore_positions
)
6496 register struct save_window_data
*d1
, *d2
;
6497 struct Lisp_Vector
*sw1
, *sw2
;
6500 CHECK_WINDOW_CONFIGURATION (c1
);
6501 CHECK_WINDOW_CONFIGURATION (c2
);
6503 d1
= (struct save_window_data
*) XVECTOR (c1
);
6504 d2
= (struct save_window_data
*) XVECTOR (c2
);
6505 sw1
= XVECTOR (d1
->saved_windows
);
6506 sw2
= XVECTOR (d2
->saved_windows
);
6508 if (d1
->frame_cols
!= d2
->frame_cols
)
6510 if (d1
->frame_lines
!= d2
->frame_lines
)
6512 if (d1
->frame_menu_bar_lines
!= d2
->frame_menu_bar_lines
)
6514 if (! EQ (d1
->selected_frame
, d2
->selected_frame
))
6516 /* Don't compare the current_window field directly.
6517 Instead see w1_is_current and w2_is_current, below. */
6518 if (! EQ (d1
->current_buffer
, d2
->current_buffer
))
6520 if (! ignore_positions
)
6522 if (! EQ (d1
->minibuf_scroll_window
, d2
->minibuf_scroll_window
))
6524 if (! EQ (d1
->minibuf_selected_window
, d2
->minibuf_selected_window
))
6527 /* Don't compare the root_window field.
6528 We don't require the two configurations
6529 to use the same window object,
6530 and the two root windows must be equivalent
6531 if everything else compares equal. */
6532 if (! EQ (d1
->focus_frame
, d2
->focus_frame
))
6535 /* Verify that the two confis have the same number of windows. */
6536 if (sw1
->header
.size
!= sw2
->header
.size
)
6539 for (i
= 0; i
< sw1
->header
.size
; i
++)
6541 struct saved_window
*p1
, *p2
;
6542 int w1_is_current
, w2_is_current
;
6544 p1
= SAVED_WINDOW_N (sw1
, i
);
6545 p2
= SAVED_WINDOW_N (sw2
, i
);
6547 /* Verify that the current windows in the two
6548 configurations correspond to each other. */
6549 w1_is_current
= EQ (d1
->current_window
, p1
->window
);
6550 w2_is_current
= EQ (d2
->current_window
, p2
->window
);
6552 if (w1_is_current
!= w2_is_current
)
6555 /* Verify that the corresponding windows do match. */
6556 if (! EQ (p1
->buffer
, p2
->buffer
))
6558 if (! EQ (p1
->left_col
, p2
->left_col
))
6560 if (! EQ (p1
->top_line
, p2
->top_line
))
6562 if (! EQ (p1
->total_cols
, p2
->total_cols
))
6564 if (! EQ (p1
->total_lines
, p2
->total_lines
))
6566 if (! EQ (p1
->display_table
, p2
->display_table
))
6568 if (! EQ (p1
->parent
, p2
->parent
))
6570 if (! EQ (p1
->prev
, p2
->prev
))
6572 if (! ignore_positions
)
6574 if (! EQ (p1
->hscroll
, p2
->hscroll
))
6576 if (!EQ (p1
->min_hscroll
, p2
->min_hscroll
))
6578 if (! EQ (p1
->start_at_line_beg
, p2
->start_at_line_beg
))
6580 if (NILP (Fequal (p1
->start
, p2
->start
)))
6582 if (NILP (Fequal (p1
->pointm
, p2
->pointm
)))
6584 if (NILP (Fequal (p1
->mark
, p2
->mark
)))
6587 if (! EQ (p1
->left_margin_cols
, p2
->left_margin_cols
))
6589 if (! EQ (p1
->right_margin_cols
, p2
->right_margin_cols
))
6591 if (! EQ (p1
->left_fringe_width
, p2
->left_fringe_width
))
6593 if (! EQ (p1
->right_fringe_width
, p2
->right_fringe_width
))
6595 if (! EQ (p1
->fringes_outside_margins
, p2
->fringes_outside_margins
))
6597 if (! EQ (p1
->scroll_bar_width
, p2
->scroll_bar_width
))
6599 if (! EQ (p1
->vertical_scroll_bar_type
, p2
->vertical_scroll_bar_type
))
6606 DEFUN ("compare-window-configurations", Fcompare_window_configurations
,
6607 Scompare_window_configurations
, 2, 2, 0,
6608 doc
: /* Compare two window configurations as regards the structure of windows.
6609 This function ignores details such as the values of point and mark
6610 and scrolling positions. */)
6611 (Lisp_Object x
, Lisp_Object y
)
6613 if (compare_window_configurations (x
, y
, 1))
6619 init_window_once (void)
6621 struct frame
*f
= make_initial_frame ();
6622 XSETFRAME (selected_frame
, f
);
6623 Vterminal_frame
= selected_frame
;
6624 minibuf_window
= f
->minibuffer_window
;
6625 selected_window
= f
->selected_window
;
6626 last_nonminibuf_frame
= f
;
6628 window_initialized
= 1;
6634 Vwindow_list
= Qnil
;
6638 syms_of_window (void)
6640 Qscroll_up
= intern_c_string ("scroll-up");
6641 staticpro (&Qscroll_up
);
6643 Qscroll_down
= intern_c_string ("scroll-down");
6644 staticpro (&Qscroll_down
);
6646 Qscroll_command
= intern_c_string ("scroll-command");
6647 staticpro (&Qscroll_command
);
6649 Fput (Qscroll_up
, Qscroll_command
, Qt
);
6650 Fput (Qscroll_down
, Qscroll_command
, Qt
);
6652 staticpro (&Qwindow_configuration_change_hook
);
6653 Qwindow_configuration_change_hook
6654 = intern_c_string ("window-configuration-change-hook");
6656 Qwindowp
= intern_c_string ("windowp");
6657 staticpro (&Qwindowp
);
6659 Qwindow_configuration_p
= intern_c_string ("window-configuration-p");
6660 staticpro (&Qwindow_configuration_p
);
6662 Qwindow_live_p
= intern_c_string ("window-live-p");
6663 staticpro (&Qwindow_live_p
);
6665 Qwindow_deletable_p
= intern_c_string ("window-deletable-p");
6666 staticpro (&Qwindow_deletable_p
);
6668 Qdelete_window
= intern_c_string ("delete-window");
6669 staticpro (&Qdelete_window
);
6671 Qresize_root_window
= intern_c_string ("resize-root-window");
6672 staticpro (&Qresize_root_window
);
6674 Qresize_root_window_vertically
= intern_c_string ("resize-root-window-vertically");
6675 staticpro (&Qresize_root_window_vertically
);
6677 Qsafe
= intern_c_string ("safe");
6680 Qdisplay_buffer
= intern_c_string ("display-buffer");
6681 staticpro (&Qdisplay_buffer
);
6683 Qreplace_buffer_in_windows
= intern_c_string ("replace-buffer-in-windows");
6684 staticpro (&Qreplace_buffer_in_windows
);
6686 Qrecord_window_buffer
= intern_c_string ("record-window-buffer");
6687 staticpro (&Qrecord_window_buffer
);
6689 Qget_mru_window
= intern_c_string ("get-mru-window");
6690 staticpro (&Qget_mru_window
);
6692 Qtemp_buffer_show_hook
= intern_c_string ("temp-buffer-show-hook");
6693 staticpro (&Qtemp_buffer_show_hook
);
6695 Qabove
= intern_c_string ("above");
6696 staticpro (&Qabove
);
6698 Qbelow
= intern_c_string ("below");
6699 staticpro (&Qbelow
);
6701 Qauto_buffer_name
= intern_c_string ("auto-buffer-name");
6702 staticpro (&Qauto_buffer_name
);
6704 staticpro (&Vwindow_list
);
6706 minibuf_selected_window
= Qnil
;
6707 staticpro (&minibuf_selected_window
);
6709 window_scroll_pixel_based_preserve_x
= -1;
6710 window_scroll_pixel_based_preserve_y
= -1;
6711 window_scroll_preserve_hpos
= -1;
6712 window_scroll_preserve_vpos
= -1;
6714 DEFVAR_LISP ("temp-buffer-show-function", Vtemp_buffer_show_function
,
6715 doc
: /* Non-nil means call as function to display a help buffer.
6716 The function is called with one argument, the buffer to be displayed.
6717 Used by `with-output-to-temp-buffer'.
6718 If this function is used, then it must do the entire job of showing
6719 the buffer; `temp-buffer-show-hook' is not run unless this function runs it. */);
6720 Vtemp_buffer_show_function
= Qnil
;
6722 DEFVAR_LISP ("minibuffer-scroll-window", Vminibuf_scroll_window
,
6723 doc
: /* Non-nil means it is the window that C-M-v in minibuffer should scroll. */);
6724 Vminibuf_scroll_window
= Qnil
;
6726 DEFVAR_BOOL ("mode-line-in-non-selected-windows", mode_line_in_non_selected_windows
,
6727 doc
: /* Non-nil means to use `mode-line-inactive' face in non-selected windows.
6728 If the minibuffer is active, the `minibuffer-scroll-window' mode line
6729 is displayed in the `mode-line' face. */);
6730 mode_line_in_non_selected_windows
= 1;
6732 DEFVAR_LISP ("other-window-scroll-buffer", Vother_window_scroll_buffer
,
6733 doc
: /* If non-nil, this is a buffer and \\[scroll-other-window] should scroll its window. */);
6734 Vother_window_scroll_buffer
= Qnil
;
6736 DEFVAR_BOOL ("auto-window-vscroll", auto_window_vscroll_p
,
6737 doc
: /* *Non-nil means to automatically adjust `window-vscroll' to view tall lines. */);
6738 auto_window_vscroll_p
= 1;
6740 DEFVAR_INT ("next-screen-context-lines", next_screen_context_lines
,
6741 doc
: /* *Number of lines of continuity when scrolling by screenfuls. */);
6742 next_screen_context_lines
= 2;
6744 DEFVAR_LISP ("scroll-preserve-screen-position",
6745 Vscroll_preserve_screen_position
,
6746 doc
: /* *Controls if scroll commands move point to keep its screen position unchanged.
6747 A value of nil means point does not keep its screen position except
6748 at the scroll margin or window boundary respectively.
6749 A value of t means point keeps its screen position if the scroll
6750 command moved it vertically out of the window, e.g. when scrolling
6752 Any other value means point always keeps its screen position.
6753 Scroll commands should have the `scroll-command' property
6754 on their symbols to be controlled by this variable. */);
6755 Vscroll_preserve_screen_position
= Qnil
;
6757 DEFVAR_LISP ("window-point-insertion-type", Vwindow_point_insertion_type
,
6758 doc
: /* Type of marker to use for `window-point'. */);
6759 Vwindow_point_insertion_type
= Qnil
;
6761 DEFVAR_LISP ("window-configuration-change-hook",
6762 Vwindow_configuration_change_hook
,
6763 doc
: /* Functions to call when window configuration changes.
6764 The buffer-local part is run once per window, with the relevant window
6765 selected; while the global part is run only once for the modified frame,
6766 with the relevant frame selected. */);
6767 Vwindow_configuration_change_hook
= Qnil
;
6769 DEFVAR_LISP ("recenter-redisplay", Vrecenter_redisplay
,
6770 doc
: /* If non-nil, then the `recenter' command with a nil argument
6771 will redraw the entire frame; the special value `tty' causes the
6772 frame to be redrawn only if it is a tty frame. */);
6773 Vrecenter_redisplay
= Qtty
;
6775 DEFVAR_LISP ("window-splits", Vwindow_splits
,
6776 doc
: /* Non-nil means splitting windows is handled specially.
6777 If this variable is nil, splitting a window gets the entire screen space
6778 for displaying the new window from the window to split. If this
6779 variable is non-nil, splitting a window may resize all windows in the
6780 same combination. This also allows to split a window that is otherwise
6781 too small or of fixed size.
6783 The value of this variable is also assigned to the split status of the
6784 new window and, provided the old and new window form a new combination,
6785 to the window that was split as well. The split status of a window can
6786 be retrieved with the function `window-splits' and altered by the
6787 function `set-window-splits'.
6789 If the value of the variable `window-nest' is non-nil, the space for the
6790 new window is exclusively taken from the window that shall be split, but
6791 the split status of the window that is split as well as that of the new
6792 window are still set to the value of this variable. */);
6793 Vwindow_splits
= Qnil
;
6795 DEFVAR_LISP ("window-nest", Vwindow_nest
,
6796 doc
: /* Non-nil means splitting a window makes a new parent window.
6797 If this variable is nil, splitting a window will create a new parent
6798 window only if the window has no parent window or the window shall
6799 become a combination orthogonal to the one it it is part of.
6801 If this variable is non-nil, splitting a window always creates a new
6802 parent window. If all splits behave this way, each frame's window tree
6803 is a binary tree and every window but the frame's root window has
6804 exactly one sibling.
6806 The value of this variable is also assigned to the nest status of the
6807 new parent window. The nest status of a window can be retrieved via the
6808 function `window-nest' and altered by the function `set-window-nest'. */);
6809 Vwindow_nest
= Qnil
;
6811 defsubr (&Sselected_window
);
6812 defsubr (&Sminibuffer_window
);
6813 defsubr (&Swindow_minibuffer_p
);
6814 defsubr (&Swindowp
);
6815 defsubr (&Swindow_live_p
);
6816 defsubr (&Swindow_frame
);
6817 defsubr (&Sframe_root_window
);
6818 defsubr (&Sframe_first_window
);
6819 defsubr (&Sframe_selected_window
);
6820 defsubr (&Sset_frame_selected_window
);
6821 defsubr (&Spos_visible_in_window_p
);
6822 defsubr (&Swindow_line_height
);
6823 defsubr (&Swindow_clone_number
);
6824 defsubr (&Swindow_buffer
);
6825 defsubr (&Swindow_parent
);
6826 defsubr (&Swindow_vchild
);
6827 defsubr (&Swindow_hchild
);
6828 defsubr (&Swindow_next
);
6829 defsubr (&Swindow_prev
);
6830 defsubr (&Swindow_splits
);
6831 defsubr (&Sset_window_splits
);
6832 defsubr (&Swindow_nest
);
6833 defsubr (&Sset_window_nest
);
6834 defsubr (&Swindow_use_time
);
6835 defsubr (&Swindow_top_line
);
6836 defsubr (&Swindow_left_column
);
6837 defsubr (&Swindow_total_size
);
6838 defsubr (&Swindow_normal_size
);
6839 defsubr (&Swindow_new_total
);
6840 defsubr (&Swindow_new_normal
);
6841 defsubr (&Sset_window_new_total
);
6842 defsubr (&Sset_window_new_normal
);
6843 defsubr (&Sresize_window_apply
);
6844 defsubr (&Swindow_body_size
);
6845 defsubr (&Swindow_hscroll
);
6846 defsubr (&Sset_window_hscroll
);
6847 defsubr (&Swindow_redisplay_end_trigger
);
6848 defsubr (&Sset_window_redisplay_end_trigger
);
6849 defsubr (&Swindow_edges
);
6850 defsubr (&Swindow_pixel_edges
);
6851 defsubr (&Swindow_absolute_pixel_edges
);
6852 defsubr (&Swindow_inside_edges
);
6853 defsubr (&Swindow_inside_pixel_edges
);
6854 defsubr (&Swindow_inside_absolute_pixel_edges
);
6855 defsubr (&Scoordinates_in_window_p
);
6856 defsubr (&Swindow_at
);
6857 defsubr (&Swindow_point
);
6858 defsubr (&Swindow_start
);
6859 defsubr (&Swindow_end
);
6860 defsubr (&Sset_window_point
);
6861 defsubr (&Sset_window_start
);
6862 defsubr (&Swindow_dedicated_p
);
6863 defsubr (&Sset_window_dedicated_p
);
6864 defsubr (&Swindow_display_table
);
6865 defsubr (&Sset_window_display_table
);
6866 defsubr (&Snext_window
);
6867 defsubr (&Sprevious_window
);
6868 defsubr (&Sother_window
);
6869 defsubr (&Sget_buffer_window
);
6870 defsubr (&Sdelete_windows_on
);
6871 defsubr (&Sreplace_buffer_in_windows
);
6872 defsubr (&Sdelete_other_windows_internal
);
6873 defsubr (&Sdelete_window_internal
);
6874 defsubr (&Sresize_mini_window_internal
);
6875 defsubr (&Sset_window_buffer
);
6876 defsubr (&Sset_window_clone_number
);
6877 defsubr (&Srun_window_configuration_change_hook
);
6878 defsubr (&Sselect_window
);
6879 defsubr (&Sforce_window_update
);
6880 defsubr (&Stemp_output_buffer_show
);
6881 defsubr (&Ssplit_window_internal
);
6882 defsubr (&Sscroll_up
);
6883 defsubr (&Sscroll_down
);
6884 defsubr (&Sscroll_left
);
6885 defsubr (&Sscroll_right
);
6886 defsubr (&Sother_window_for_scrolling
);
6887 defsubr (&Sscroll_other_window
);
6888 defsubr (&Sminibuffer_selected_window
);
6889 defsubr (&Srecenter
);
6890 defsubr (&Swindow_text_height
);
6891 defsubr (&Smove_to_window_line
);
6892 defsubr (&Swindow_configuration_p
);
6893 defsubr (&Swindow_configuration_frame
);
6894 defsubr (&Sset_window_configuration
);
6895 defsubr (&Scurrent_window_configuration
);
6896 defsubr (&Swindow_tree
);
6897 defsubr (&Sset_window_margins
);
6898 defsubr (&Swindow_margins
);
6899 defsubr (&Sset_window_fringes
);
6900 defsubr (&Swindow_fringes
);
6901 defsubr (&Sset_window_scroll_bars
);
6902 defsubr (&Swindow_scroll_bars
);
6903 defsubr (&Swindow_vscroll
);
6904 defsubr (&Sset_window_vscroll
);
6905 defsubr (&Scompare_window_configurations
);
6906 defsubr (&Swindow_list
);
6907 defsubr (&Swindow_list_1
);
6908 defsubr (&Swindow_prev_buffers
);
6909 defsubr (&Sset_window_prev_buffers
);
6910 defsubr (&Swindow_next_buffers
);
6911 defsubr (&Sset_window_next_buffers
);
6912 defsubr (&Swindow_parameters
);
6913 defsubr (&Swindow_parameter
);
6914 defsubr (&Sset_window_parameter
);
6918 keys_of_window (void)
6920 initial_define_key (control_x_map
, 'o', "other-window");
6921 initial_define_key (control_x_map
, '<', "scroll-left");
6922 initial_define_key (control_x_map
, '>', "scroll-right");
6924 initial_define_key (global_map
, Ctl ('V'), "scroll-up-command");
6925 initial_define_key (meta_map
, Ctl ('V'), "scroll-other-window");
6926 initial_define_key (meta_map
, 'v', "scroll-down-command");