/* Window creation, deletion and examination for GNU Emacs.
Does not include redisplay.
Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GNU Emacs.
extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions;
\f
DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0,
- doc: /* Returns t if OBJECT is a window. */)
+ doc: /* Return t if OBJECT is a window. */)
(object)
Lisp_Object object;
{
}
DEFUN ("window-live-p", Fwindow_live_p, Swindow_live_p, 1, 1, 0,
- doc: /* Returns t if OBJECT is a window which is currently visible. */)
+ doc: /* Return t if OBJECT is a window which is currently visible. */)
(object)
Lisp_Object object;
{
}
DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, Swindow_minibuffer_p, 0, 1, 0,
- doc: /* Returns non-nil if WINDOW is a minibuffer window.
+ doc: /* Return non-nil if WINDOW is a minibuffer window.
WINDOW defaults to the selected window. */)
(window)
Lisp_Object window;
}
DEFUN ("window-height", Fwindow_height, Swindow_height, 0, 1, 0,
- doc: /* Return the number of lines in WINDOW (including its mode line).
-WINDOW defaults to the selected window. */)
+ doc: /* Return the number of lines in WINDOW.
+WINDOW defaults to the selected window.
+
+The return value includes WINDOW's mode line and header line, if any. */)
(window)
Lisp_Object window;
{
}
else
{
- if (eabs (*x - x1) < grabbable_width)
+ /* Make sure we're not at the rightmost position of a
+ mode-/header-line and there's yet another window on
+ the right. (Bug#1372) */
+ if ((WINDOW_RIGHTMOST_P (w) || *x < x1)
+ && eabs (*x - x1) < grabbable_width)
{
/* Convert X and Y to window relative coordinates.
Vertical border is at the right edge of window. */
doc: /* Return non-nil if COORDINATES are in WINDOW.
COORDINATES is a cons of the form (X . Y), X and Y being distances
measured in characters from the upper-left corner of the frame.
-\(0 . 0) denotes the character in the upper left corner of the
+\(0 . 0) denotes the character in the upper left corner of the
frame.
If COORDINATES are in the text portion of WINDOW,
the coordinates relative to the window are returned.
}
DEFUN ("delete-window", Fdelete_window, Sdelete_window, 0, 1, "",
- doc: /* Remove WINDOW from the display. Default is selected window. */)
+ doc: /* Remove WINDOW from its frame.
+WINDOW defaults to the selected window. Return nil.
+Signal an error when WINDOW is the only window on its frame. */)
(window)
register Lisp_Object window;
{
}
-/* Return the next or previous window of WINDOW in canonical ordering
+/* Return the next or previous window of WINDOW in cyclic ordering
of windows. NEXT_P non-zero means return the next window. See the
documentation string of next-window for the meaning of MINIBUF and
ALL_FRAMES. */
DEFUN ("next-window", Fnext_window, Snext_window, 0, 3, 0,
- doc: /* Return next window after WINDOW in canonical ordering of windows.
-If omitted, WINDOW defaults to the selected window.
+ doc: /* Return window following WINDOW in cyclic ordering of windows.
+WINDOW defaults to the selected window. The optional arguments
+MINIBUF and ALL-FRAMES specify the set of windows to consider.
-Optional second arg MINIBUF t means count the minibuffer window even
-if not active. MINIBUF nil or omitted means count the minibuffer iff
-it is active. MINIBUF neither t nor nil means not to count the
-minibuffer even if it is active.
+MINIBUF t means consider the minibuffer window even if the
+minibuffer is not active. MINIBUF nil or omitted means consider
+the minibuffer window only if the minibuffer is active. Any
+other value means do not consider the minibuffer window even if
+the minibuffer is active.
Several frames may share a single minibuffer; if the minibuffer
-counts, all windows on all frames that share that minibuffer count
-too. Therefore, `next-window' can be used to iterate through the
-set of windows even when the minibuffer is on another frame. If the
-minibuffer does not count, only windows from WINDOW's frame count.
-
-Optional third arg ALL-FRAMES t means include windows on all frames.
-ALL-FRAMES nil or omitted means cycle within the frames as specified
-above. ALL-FRAMES = `visible' means include windows on all visible frames.
-ALL-FRAMES = 0 means include windows on all visible and iconified frames.
-If ALL-FRAMES is a frame, restrict search to windows on that frame.
-Anything else means restrict to WINDOW's frame.
+is active, all windows on all frames that share that minibuffer
+are considered too. Therefore, if you are using a separate
+minibuffer frame and the minibuffer is active and MINIBUF says it
+counts, `next-window' considers the windows in the frame from
+which you entered the minibuffer, as well as the minibuffer
+window.
+
+ALL-FRAMES nil or omitted means consider all windows on WINDOW's
+ frame, plus the minibuffer window if specified by the MINIBUF
+ argument, see above. If the minibuffer counts, consider all
+ windows on all frames that share that minibuffer too.
+ALL-FRAMES t means consider all windows on all existing frames.
+ALL-FRAMES `visible' means consider all windows on all visible
+ frames.
+ALL-FRAMES 0 means consider all windows on all visible and
+ iconified frames.
+ALL-FRAMES a frame means consider all windows on that frame only.
+Anything else means consider all windows on WINDOW's frame and no
+ others.
If you use consistent values for MINIBUF and ALL-FRAMES, you can use
`next-window' to iterate through the entire cycle of acceptable
DEFUN ("previous-window", Fprevious_window, Sprevious_window, 0, 3, 0,
- doc: /* Return the window preceding WINDOW in canonical ordering of windows.
-If omitted, WINDOW defaults to the selected window.
-
-Optional second arg MINIBUF t means count the minibuffer window even
-if not active. MINIBUF nil or omitted means count the minibuffer iff
-it is active. MINIBUF neither t nor nil means not to count the
-minibuffer even if it is active.
-
-Several frames may share a single minibuffer; if the minibuffer
-counts, all windows on all frames that share that minibuffer count
-too. Therefore, `previous-window' can be used to iterate through
-the set of windows even when the minibuffer is on another frame. If
-the minibuffer does not count, only windows from WINDOW's frame count
-
-Optional third arg ALL-FRAMES t means include windows on all frames.
-ALL-FRAMES nil or omitted means cycle within the frames as specified
-above. ALL-FRAMES = `visible' means include windows on all visible frames.
-ALL-FRAMES = 0 means include windows on all visible and iconified frames.
-If ALL-FRAMES is a frame, restrict search to windows on that frame.
-Anything else means restrict to WINDOW's frame.
-
-If you use consistent values for MINIBUF and ALL-FRAMES, you can use
-`previous-window' to iterate through the entire cycle of acceptable
-windows, eventually ending up back at the window you started with.
-`next-window' traverses the same cycle, in the reverse order. */)
+ doc: /* Return window preceding WINDOW in cyclic ordering of windows.
+WINDOW defaults to the selected window. The optional arguments
+MINIBUF and ALL-FRAMES specify the set of windows to consider.
+For the precise meaning of these arguments see `next-window'.
+
+If you use consistent values for MINIBUF and ALL-FRAMES, you can
+use `previous-window' to iterate through the entire cycle of
+acceptable windows, eventually ending up back at the window you
+started with. `next-window' traverses the same cycle, in the
+reverse order. */)
(window, minibuf, all_frames)
Lisp_Object window, minibuf, all_frames;
{
DEFUN ("other-window", Fother_window, Sother_window, 1, 2, "p",
- doc: /* Select the ARG'th different window on this frame.
-All windows on current frame are arranged in a cyclic order.
-This command selects the window ARG steps away in that order.
-A negative ARG moves in the opposite order. The optional second
-argument ALL-FRAMES has the same meaning as in `next-window', which see. */)
- (arg, all_frames)
- Lisp_Object arg, all_frames;
+ doc: /* Select another window in cyclic ordering of windows.
+COUNT specifies the number of windows to skip, starting with the
+selected window, before making the selection. If COUNT is
+positive, skip COUNT windows forwards. If COUNT is negative,
+skip -COUNT windows backwards. COUNT zero means do not skip any
+window, so select the selected window. In an interactive call,
+COUNT is the numeric prefix argument. Return nil.
+
+This function uses `next-window' for finding the window to select.
+The argument ALL-FRAMES has the same meaning as in `next-window',
+but the MINIBUF argument of `next-window' is always effectively
+nil. */)
+ (count, all_frames)
+ Lisp_Object count, all_frames;
{
Lisp_Object window;
int i;
- CHECK_NUMBER (arg);
+ CHECK_NUMBER (count);
window = selected_window;
- for (i = XINT (arg); i > 0; --i)
+ for (i = XINT (count); i > 0; --i)
window = Fnext_window (window, Qnil, all_frames);
for (; i < 0; ++i)
window = Fprevious_window (window, Qnil, all_frames);
}
-/* Return a list of windows in canonical ordering. Arguments are like
+/* Return a list of windows in cyclic ordering. Arguments are like
for `next-window'. */
static Lisp_Object
windows = XCDR (windows);
/* Now we can safely delete the frame. */
- Fdelete_frame (w->frame, Qnil);
+ delete_frame (w->frame, Qnil);
}
else if (NILP (w->parent))
{
display there. */
Lisp_Object buffer;
buffer = Fother_buffer (obj, Qnil, w->frame);
+ /* Reset dedicated state of window. */
+ w->dedicated = Qnil;
Fset_window_buffer (window, buffer, Qnil);
if (EQ (window, selected_window))
Fset_buffer (w->buffer);
windows = XCDR (windows);
/* Now we can safely delete the frame. */
- Fdelete_frame (w->frame, Qnil);
+ delete_frame (w->frame, Qnil);
}
else if (!NILP (w->dedicated) && !NILP (w->parent))
{
}
static Lisp_Object select_window_norecord (Lisp_Object window);
+static Lisp_Object select_frame_norecord (Lisp_Object frame);
void
run_window_configuration_change_hook (struct frame *f)
if (SELECTED_FRAME () != f)
{
- record_unwind_protect (Fselect_frame, Fselected_frame ());
- Fselect_frame (frame);
+ record_unwind_protect (select_frame_norecord, Fselected_frame ());
+ Fselect_frame (frame, Qt);
}
/* Use the right buffer. Matters when running the local hooks. */
bzero (&w->last_cursor, sizeof w->last_cursor);
w->window_end_valid = Qnil;
if (!(keep_margins_p && samebuf))
- { /* If we're not actually changing the buffer, Don't reset hscroll and
+ { /* If we're not actually changing the buffer, don't reset hscroll and
vscroll. This case happens for example when called from
change_frame_size_1, where we use a dummy call to
Fset_window_buffer on the frame's selected window (and no other)
buffer (that is `window-dedicated-p' returns t for WINDOW) and does not
already display BUFFER-OR-NAME.
-This function runs the hook `window-scroll-functions'. */)
+This function runs `window-scroll-functions' before running
+`window-configuration-change-hook'. */)
(window, buffer_or_name, keep_margins)
register Lisp_Object window, buffer_or_name, keep_margins;
{
If WINDOW is not already selected, make WINDOW's buffer current
and make WINDOW the frame's selected window. Return WINDOW.
Optional second arg NORECORD non-nil means do not put this buffer
-at the front of the list of recently selected ones.
+at the front of the list of recently selected ones and do not
+make this window the most recently selected one.
Note that the main editor command loop selects the buffer of the
selected window before each command. */)
so that FRAME_FOCUS_FRAME is moved appropriately as we
move around in the state where a minibuffer in a separate
frame is active. */
- Fselect_frame (WINDOW_FRAME (w));
+ Fselect_frame (WINDOW_FRAME (w), norecord);
/* Fselect_frame called us back so we've done all the work already. */
eassert (EQ (window, selected_window));
return window;
select_window_norecord (window)
Lisp_Object window;
{
- return Fselect_window (window, Qt);
+ return WINDOW_LIVE_P (window)
+ ? Fselect_window (window, Qt) : selected_window;
+}
+
+static Lisp_Object
+select_frame_norecord (frame)
+ Lisp_Object frame;
+{
+ return FRAME_LIVE_P (XFRAME (frame))
+ ? Fselect_frame (frame, Qt) : selected_frame;
}
\f
Lisp_Object
Default for ARG is window width minus 2.
Value is the total amount of leftward horizontal scrolling in
effect after the change.
-If SET_MINIMUM is non-nil, the new scroll amount becomes the
+If SET-MINIMUM is non-nil, the new scroll amount becomes the
lower bound for automatic scrolling, i.e. automatic scrolling
will not scroll a window to a column less than the value returned
by this function. This happens in an interactive call. */)
Default for ARG is window width minus 2.
Value is the total amount of leftward horizontal scrolling in
effect after the change.
-If SET_MINIMUM is non-nil, the new scroll amount becomes the
+If SET-MINIMUM is non-nil, the new scroll amount becomes the
lower bound for automatic scrolling, i.e. automatic scrolling
will not scroll a window to a column less than the value returned
by this function. This happens in an interactive call. */)
0, 1, 0,
doc: /* Return the height in lines of the text display area of WINDOW.
WINDOW defaults to the selected window.
-This doesn't include the mode-line (or header-line if any) or any
-partial-height lines in the text display area. */)
+
+The return value does not include the mode line, any header line, nor
+any partial-height lines in the text display area. */)
(window)
Lisp_Object window;
{
when the frame's old selected window has been deleted. */
if (f != selected_frame && FRAME_WINDOW_P (f))
do_switch_frame (WINDOW_FRAME (XWINDOW (data->root_window)),
- 0, 0);
+ 0, 0, Qnil);
#endif
/* Set the screen height to the value it had before this function. */
Fselect_window above totally superfluous; it still sets f's
selected window. */
if (FRAME_LIVE_P (XFRAME (data->selected_frame)))
- do_switch_frame (data->selected_frame, 0, 0);
+ do_switch_frame (data->selected_frame, 0, 0, Qnil);
run_window_configuration_change_hook (f);
}
int (* fn) P_ ((struct window *, void *));
void *user_data;
{
- /* Fdelete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */
+ /* delete_frame may set FRAME_ROOT_WINDOW (f) to Qnil. */
if (WINDOWP (FRAME_ROOT_WINDOW (f)))
foreach_window_1 (XWINDOW (FRAME_ROOT_WINDOW (f)), fn, user_data);
}