Mercurial > emacs
diff src/window.c @ 83397:693e794b57bf
Merged from miles@gnu.org--gnu-2005 (patch 149-151, 629-641)
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-629
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-630
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-631
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-632
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-633
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-634
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-635
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-636
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-637
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-638
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-639
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-640
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-641
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-149
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-150
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-151
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-437
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Mon, 07 Nov 2005 14:56:19 +0000 |
parents | 732c5740ca8f d89d56f50d43 |
children | 1955a4462bf9 |
line wrap: on
line diff
--- a/src/window.c Mon Nov 07 14:17:18 2005 +0000 +++ b/src/window.c Mon Nov 07 14:56:19 2005 +0000 @@ -1998,11 +1998,13 @@ break; case GET_LRU_WINDOW: - /* t as arg means consider only full-width windows */ - if (!NILP (obj) && !WINDOW_FULL_WIDTH_P (w)) - break; - /* Ignore dedicated windows and minibuffers. */ - if (MINI_WINDOW_P (w) || EQ (w->dedicated, Qt)) + /* `obj' is an integer encoding a bitvector. + `obj & 1' means consider only full-width windows. + `obj & 2' means consider also dedicated windows. */ + if (((XINT (obj) & 1) && !WINDOW_FULL_WIDTH_P (w)) + || (!(XINT (obj) & 2) && EQ (w->dedicated, Qt)) + /* Minibuffer windows are always ignored. */ + || MINI_WINDOW_P (w)) break; if (NILP (best_window) || (XFASTINT (XWINDOW (best_window)->use_time) @@ -2053,9 +2055,9 @@ break; case GET_LARGEST_WINDOW: - { + { /* nil `obj' means to ignore dedicated windows. */ /* Ignore dedicated windows and minibuffers. */ - if (MINI_WINDOW_P (w) || EQ (w->dedicated, Qt)) + if (MINI_WINDOW_P (w) || (NILP (obj) && EQ (w->dedicated, Qt))) break; if (NILP (best_window)) @@ -2149,43 +2151,47 @@ window_loop (CHECK_ALL_WINDOWS, Qnil, 1, Qt); } -DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 1, 0, +DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 2, 0, doc: /* Return the window least recently selected or used for display. Return a full-width window if possible. A minibuffer window is never a candidate. -A dedicated window is never a candidate, so if all windows are dedicated, -the value is nil. +A dedicated window is never a candidate, unless DEDICATED is non-nil, + so if all windows are dedicated, the value is nil. If optional argument FRAME is `visible', search all visible frames. If FRAME is 0, search all visible and iconified frames. If FRAME is t, search all frames. If FRAME is nil, search only the selected frame. If FRAME is a frame, search only that frame. */) - (frame) - Lisp_Object frame; + (frame, dedicated) + Lisp_Object frame, dedicated; { register Lisp_Object w; /* First try for a window that is full-width */ - w = window_loop (GET_LRU_WINDOW, Qt, 0, frame); + w = window_loop (GET_LRU_WINDOW, + NILP (dedicated) ? make_number (1) : make_number (3), + 0, frame); if (!NILP (w) && !EQ (w, selected_window)) return w; /* If none of them, try the rest */ - return window_loop (GET_LRU_WINDOW, Qnil, 0, frame); + return window_loop (GET_LRU_WINDOW, + NILP (dedicated) ? make_number (0) : make_number (2), + 0, frame); } -DEFUN ("get-largest-window", Fget_largest_window, Sget_largest_window, 0, 1, 0, +DEFUN ("get-largest-window", Fget_largest_window, Sget_largest_window, 0, 2, 0, doc: /* Return the largest window in area. A minibuffer window is never a candidate. -A dedicated window is never a candidate, so if all windows are dedicated, -the value is nil. +A dedicated window is never a candidate unless DEDICATED is non-nil, + so if all windows are dedicated, the value is nil. If optional argument FRAME is `visible', search all visible frames. If FRAME is 0, search all visible and iconified frames. If FRAME is t, search all frames. If FRAME is nil, search only the selected frame. If FRAME is a frame, search only that frame. */) - (frame) - Lisp_Object frame; -{ - return window_loop (GET_LARGEST_WINDOW, Qnil, 0, + (frame, dedicated) + Lisp_Object frame, dedicated; +{ + return window_loop (GET_LARGEST_WINDOW, dedicated, 0, frame); } @@ -3505,15 +3511,17 @@ if (FRAME_NO_SPLIT_P (NILP (frames) ? f : last_nonminibuf_frame)) { /* Try visible frames first. */ - window = Fget_largest_window (Qvisible); + window = Fget_largest_window (Qvisible, Qt); /* If that didn't work, try iconified frames. */ if (NILP (window)) - window = Fget_largest_window (make_number (0)); + window = Fget_largest_window (make_number (0), Qt); +#if 0 /* Don't try windows on other displays. */ if (NILP (window)) - window = Fget_largest_window (Qt); + window = Fget_largest_window (Qt, Qt); +#endif } else - window = Fget_largest_window (frames); + window = Fget_largest_window (frames, Qt); /* If we got a tall enough full-width window that can be split, split it. */ @@ -3526,7 +3534,7 @@ { Lisp_Object upper, lower, other; - window = Fget_lru_window (frames); + window = Fget_lru_window (frames, Qt); /* If the LRU window is selected, and big enough, and can be split, split it. */ if (!NILP (window) @@ -3535,23 +3543,27 @@ || EQ (XWINDOW (window)->parent, Qnil)) && window_height (window) >= window_min_height << 1) window = Fsplit_window (window, Qnil, Qnil); + else + window = Fget_lru_window (frames, Qnil); /* If Fget_lru_window returned nil, try other approaches. */ /* Try visible frames first. */ if (NILP (window)) window = Fget_buffer_window (buffer, Qvisible); if (NILP (window)) - window = Fget_largest_window (Qvisible); + window = Fget_largest_window (Qvisible, Qnil); /* If that didn't work, try iconified frames. */ if (NILP (window)) window = Fget_buffer_window (buffer, make_number (0)); if (NILP (window)) - window = Fget_largest_window (make_number (0)); - /* Try invisible frames. */ + window = Fget_largest_window (make_number (0), Qnil); + +#if 0 /* Don't try frames on other displays. */ if (NILP (window)) window = Fget_buffer_window (buffer, Qt); if (NILP (window)) - window = Fget_largest_window (Qt); + window = Fget_largest_window (Qt, Qnil); +#endif /* As a last resort, make a new frame. */ if (NILP (window)) window = Fframe_selected_window (call0 (Vpop_up_frame_function)); @@ -3578,7 +3590,7 @@ } } else - window = Fget_lru_window (Qnil); + window = Fget_lru_window (Qnil, Qnil); Fset_window_buffer (window, buffer, Qnil); return display_buffer_1 (window); @@ -3868,15 +3880,16 @@ doc: /* Make current window ARG lines bigger. From program, optional second arg non-nil means grow sideways ARG columns. Interactively, if an argument is not given, make the window one line bigger. +If HORIZONTAL is non-nil, enlarge horizontally instead of vertically. Optional third arg PRESERVE-BEFORE, if non-nil, means do not change the size of the siblings above or to the left of the selected window. Only siblings to the right or below are changed. */) - (arg, side, preserve_before) - register Lisp_Object arg, side, preserve_before; + (arg, horizontal, preserve_before) + register Lisp_Object arg, horizontal, preserve_before; { CHECK_NUMBER (arg); - enlarge_window (selected_window, XINT (arg), !NILP (side), + enlarge_window (selected_window, XINT (arg), !NILP (horizontal), !NILP (preserve_before)); if (! NILP (Vwindow_configuration_change_hook)) @@ -3924,40 +3937,43 @@ #define CURBEG(w) \ - *(widthflag ? &(XWINDOW (w)->left_col) : &(XWINDOW (w)->top_line)) + *(horiz_flag ? &(XWINDOW (w)->left_col) : &(XWINDOW (w)->top_line)) #define CURSIZE(w) \ - *(widthflag ? &(XWINDOW (w)->total_cols) : &(XWINDOW (w)->total_lines)) - - -/* Enlarge WINDOW by DELTA. WIDTHFLAG non-zero means - increase its width. Siblings of the selected window are resized to - fulfill the size request. If they become too small in the process, - they will be deleted. + *(horiz_flag ? &(XWINDOW (w)->total_cols) : &(XWINDOW (w)->total_lines)) + + +/* Enlarge WINDOW by DELTA. + HORIZ_FLAG nonzero means enlarge it horizontally; + zero means do it vertically. + + Siblings of the selected window are resized to fulfill the size + request. If they become too small in the process, they will be + deleted. If PRESERVE_BEFORE is nonzero, that means don't alter the siblings to the left or above WINDOW. */ static void -enlarge_window (window, delta, widthflag, preserve_before) +enlarge_window (window, delta, horiz_flag, preserve_before) Lisp_Object window; - int delta, widthflag, preserve_before; + int delta, horiz_flag, preserve_before; { Lisp_Object parent, next, prev; struct window *p; Lisp_Object *sizep; int maximum; int (*sizefun) P_ ((Lisp_Object)) - = widthflag ? window_width : window_height; + = horiz_flag ? window_width : window_height; void (*setsizefun) P_ ((Lisp_Object, int, int)) - = (widthflag ? set_window_width : set_window_height); + = (horiz_flag ? set_window_width : set_window_height); /* Check values of window_min_width and window_min_height for validity. */ check_min_window_sizes (); /* Give up if this window cannot be resized. */ - if (window_fixed_size_p (XWINDOW (window), widthflag, 1)) + if (window_fixed_size_p (XWINDOW (window), horiz_flag, 1)) error ("Window is not resizable"); /* Find the parent of the selected window. */ @@ -3968,12 +3984,12 @@ if (NILP (parent)) { - if (widthflag) + if (horiz_flag) error ("No other window to side of this one"); break; } - if (widthflag + if (horiz_flag ? !NILP (XWINDOW (parent)->hchild) : !NILP (XWINDOW (parent)->vchild)) break; @@ -3999,7 +4015,7 @@ else maxdelta = (!NILP (p->next) ? ((*sizefun) (p->next) - window_min_size (XWINDOW (p->next), - widthflag, 0, 0)) + horiz_flag, 0, 0)) : (delta = 0)); } else @@ -4007,11 +4023,11 @@ /* This is a main window followed by a minibuffer. */ : !NILP (p->next) ? ((*sizefun) (p->next) - window_min_size (XWINDOW (p->next), - widthflag, 0, 0)) + horiz_flag, 0, 0)) /* This is a minibuffer following a main window. */ : !NILP (p->prev) ? ((*sizefun) (p->prev) - window_min_size (XWINDOW (p->prev), - widthflag, 0, 0)) + horiz_flag, 0, 0)) /* This is a frame with only one window, a minibuffer-only or a minibufferless frame. */ : (delta = 0)); @@ -4023,7 +4039,7 @@ delta = maxdelta; } - if (XINT (*sizep) + delta < window_min_size (XWINDOW (window), widthflag, 0, 0)) + if (XINT (*sizep) + delta < window_min_size (XWINDOW (window), horiz_flag, 0, 0)) { delete_window (window); return; @@ -4036,11 +4052,11 @@ maximum = 0; for (next = p->next; ! NILP (next); next = XWINDOW (next)->next) maximum += (*sizefun) (next) - window_min_size (XWINDOW (next), - widthflag, 0, 0); + horiz_flag, 0, 0); if (! preserve_before) for (prev = p->prev; ! NILP (prev); prev = XWINDOW (prev)->prev) maximum += (*sizefun) (prev) - window_min_size (XWINDOW (prev), - widthflag, 0, 0); + horiz_flag, 0, 0); /* If we can get it all from them without deleting them, do so. */ if (delta <= maximum) @@ -4062,7 +4078,7 @@ { int this_one = ((*sizefun) (next) - window_min_size (XWINDOW (next), - widthflag, 0, &fixed_p)); + horiz_flag, 0, &fixed_p)); if (!fixed_p) { if (this_one > delta) @@ -4084,7 +4100,7 @@ { int this_one = ((*sizefun) (prev) - window_min_size (XWINDOW (prev), - widthflag, 0, &fixed_p)); + horiz_flag, 0, &fixed_p)); if (!fixed_p) { if (this_one > delta) @@ -4187,10 +4203,10 @@ int n = 1; for (s = w->next; !NILP (s); s = XWINDOW (s)->next) - if (!window_fixed_size_p (XWINDOW (s), widthflag, 0)) + if (!window_fixed_size_p (XWINDOW (s), horiz_flag, 0)) ++n; for (s = w->prev; !NILP (s); s = XWINDOW (s)->prev) - if (!window_fixed_size_p (XWINDOW (s), widthflag, 0)) + if (!window_fixed_size_p (XWINDOW (s), horiz_flag, 0)) ++n; delta1 = n * delta;