Using saved parent location: http://bzr.savannah.gnu.org/r/emacs/trunk/ Now on revision 104543. ------------------------------------------------------------ revno: 104543 committer: martin rudalics branch nick: trunk timestamp: Thu 2011-06-09 08:35:02 +0200 message: Final preparations for new window resize code. * window.c (replace_window): Rename second argument REPLACEMENT to NEW. New third argument SETFLAG. Rewrite. (delete_window, make_dummy_parent): Call replace_window with third argument 1. (window_list_1): Move down in code. (run_window_configuration_change_hook): Move set_buffer part before select_frame_norecord part in order to unwind correctly. Rename count1 to count. (recombine_windows, delete_deletable_window, resize_root_window) (Fdelete_other_windows_internal) (Frun_window_configuration_change_hook, make_parent_window) (resize_window_check, resize_window_apply, Fresize_window_apply) (resize_frame_windows, Fsplit_window_internal) (Fdelete_window_internal, Fresize_mini_window_internal): New functions. (syms_of_window): New variables Vwindow_splits and Vwindow_nest. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-08 13:00:51 +0000 +++ src/ChangeLog 2011-06-09 06:35:02 +0000 @@ -1,3 +1,22 @@ +2011-06-09 Martin Rudalics + + * window.c (replace_window): Rename second argument REPLACEMENT to + NEW. New third argument SETFLAG. Rewrite. + (delete_window, make_dummy_parent): Call replace_window with + third argument 1. + (window_list_1): Move down in code. + (run_window_configuration_change_hook): Move set_buffer part + before select_frame_norecord part in order to unwind correctly. + Rename count1 to count. + (recombine_windows, delete_deletable_window, resize_root_window) + (Fdelete_other_windows_internal) + (Frun_window_configuration_change_hook, make_parent_window) + (resize_window_check, resize_window_apply, Fresize_window_apply) + (resize_frame_windows, Fsplit_window_internal) + (Fdelete_window_internal, Fresize_mini_window_internal): New + functions. + (syms_of_window): New variables Vwindow_splits and Vwindow_nest. + 2011-06-08 Martin Rudalics * window.h (window): Add some new members to window structure - === modified file 'src/window.c' --- src/window.c 2011-06-08 13:00:51 +0000 +++ src/window.c 2011-06-09 06:35:02 +0000 @@ -90,6 +90,7 @@ int (* fn) (struct window *, void *), void *); static Lisp_Object window_list_1 (Lisp_Object, Lisp_Object, Lisp_Object); +static void resize_window_apply (struct window *, int); static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); /* This is the window in which the terminal's cursor should @@ -1853,60 +1854,146 @@ BVAR (b, last_selected_window) = Qnil; } -/* Put replacement into the window structure in place of old. */ +/* Put NEW into the window structure in place of OLD. SETFLAG zero + means change window structure only. Otherwise store geometry and + other settings as well. */ static void -replace_window (Lisp_Object old, Lisp_Object replacement) +replace_window (Lisp_Object old, Lisp_Object new, int setflag) { register Lisp_Object tem; - register struct window *o = XWINDOW (old), *p = XWINDOW (replacement); - - /* If OLD is its frame's root_window, then replacement is the new - root_window for that frame. */ - + register struct window *o = XWINDOW (old), *n = XWINDOW (new); + + /* If OLD is its frame's root window, then NEW is the new + root window for that frame. */ if (EQ (old, FRAME_ROOT_WINDOW (XFRAME (o->frame)))) - FRAME_ROOT_WINDOW (XFRAME (o->frame)) = replacement; - - p->left_col = o->left_col; - p->top_line = o->top_line; - p->total_cols = o->total_cols; - p->total_lines = o->total_lines; - p->desired_matrix = p->current_matrix = 0; - p->vscroll = 0; - memset (&p->cursor, 0, sizeof (p->cursor)); - memset (&p->last_cursor, 0, sizeof (p->last_cursor)); - memset (&p->phys_cursor, 0, sizeof (p->phys_cursor)); - p->phys_cursor_type = -1; - p->phys_cursor_width = -1; - p->must_be_updated_p = 0; - p->pseudo_window_p = 0; - XSETFASTINT (p->window_end_vpos, 0); - XSETFASTINT (p->window_end_pos, 0); - p->window_end_valid = Qnil; - p->frozen_window_start_p = 0; - p->orig_top_line = p->orig_total_lines = Qnil; - - p->next = tem = o->next; - if (!NILP (tem)) - XWINDOW (tem)->prev = replacement; - - p->prev = tem = o->prev; - if (!NILP (tem)) - XWINDOW (tem)->next = replacement; - - p->parent = tem = o->parent; + FRAME_ROOT_WINDOW (XFRAME (o->frame)) = new; + + if (setflag) + { + n->left_col = o->left_col; + n->top_line = o->top_line; + n->total_cols = o->total_cols; + n->total_lines = o->total_lines; + n->normal_cols = o->normal_cols; + o->normal_cols = make_float (1.0); + n->normal_lines = o->normal_lines; + o->normal_lines = make_float (1.0); + n->desired_matrix = n->current_matrix = 0; + n->vscroll = 0; + memset (&n->cursor, 0, sizeof (n->cursor)); + memset (&n->last_cursor, 0, sizeof (n->last_cursor)); + memset (&n->phys_cursor, 0, sizeof (n->phys_cursor)); + n->phys_cursor_type = -1; + n->phys_cursor_width = -1; + n->must_be_updated_p = 0; + n->pseudo_window_p = 0; + XSETFASTINT (n->window_end_vpos, 0); + XSETFASTINT (n->window_end_pos, 0); + n->window_end_valid = Qnil; + n->frozen_window_start_p = 0; + n->orig_top_line = n->orig_total_lines = Qnil; + } + + n->next = tem = o->next; + if (!NILP (tem)) + XWINDOW (tem)->prev = new; + + n->prev = tem = o->prev; + if (!NILP (tem)) + XWINDOW (tem)->next = new; + + n->parent = tem = o->parent; if (!NILP (tem)) { if (EQ (XWINDOW (tem)->vchild, old)) - XWINDOW (tem)->vchild = replacement; + XWINDOW (tem)->vchild = new; if (EQ (XWINDOW (tem)->hchild, old)) - XWINDOW (tem)->hchild = replacement; - } - -/*** Here, if replacement is a vertical combination -and so is its new parent, we should make replacement's -children be children of that parent instead. ***/ -} - + XWINDOW (tem)->hchild = new; + } +} + +/* If window WINDOW and its parent window are iso-combined, merge + WINDOW's children into those of its parent window and mark WINDOW as + deleted. */ + +static void +recombine_windows (Lisp_Object window) +{ + struct window *w, *p, *c; + Lisp_Object parent, child; + int horflag; + + w = XWINDOW (window); + parent = w->parent; + if (!NILP (parent) && NILP (w->nest)) + { + p = XWINDOW (parent); + if (((!NILP (p->vchild) && !NILP (w->vchild)) + || (!NILP (p->hchild) && !NILP (w->hchild)))) + /* WINDOW and PARENT are both either a vertical or a horizontal + combination. */ + { + horflag = NILP (w->vchild); + child = horflag ? w->hchild : w->vchild; + c = XWINDOW (child); + + /* Splice WINDOW's children into its parent's children and + assign new normal sizes. */ + if (NILP (w->prev)) + if (horflag) + p->hchild = child; + else + p->vchild = child; + else + { + c->prev = w->prev; + XWINDOW (w->prev)->next = child; + } + + while (c) + { + c->parent = parent; + + if (horflag) + c->normal_cols + = make_float (XFLOATINT (c->total_cols) + / XFLOATINT (p->total_cols)); + else + c->normal_lines + = make_float (XFLOATINT (c->total_lines) + / XFLOATINT (p->total_lines)); + + if (NILP (c->next)) + { + if (!NILP (w->next)) + { + c->next = w->next; + XWINDOW (c->next)->prev = child; + } + + c = 0; + } + else + { + child = c->next; + c = XWINDOW (child); + } + } + + /* WINDOW can be deleted now. */ + w->vchild = w->hchild = Qnil; + } + } +} + +/* If WINDOW can be deleted, delete it. */ +Lisp_Object +delete_deletable_window (Lisp_Object window) +{ + if (!NILP (call1 (Qwindow_deletable_p, window))) + call1 (Qdelete_window, window); +} + DEFUN ("delete-window", Fdelete_window, Sdelete_window, 0, 1, "", doc: /* Remove WINDOW from its frame. WINDOW defaults to the selected window. Return nil. @@ -2067,7 +2154,7 @@ if (NILP (tem)) tem = par->vchild; if (NILP (XWINDOW (tem)->next)) { - replace_window (parent, tem); + replace_window (parent, tem, 1); par = XWINDOW (tem); } @@ -2427,43 +2514,6 @@ } -DEFUN ("window-list-1", Fwindow_list_1, Swindow_list_1, 0, 3, 0, - doc: /* Return a list of all live windows. -WINDOW specifies the first window to list and defaults to the selected -window. - -Optional argument MINIBUF nil or omitted means consider the minibuffer -window only if the minibuffer is active. MINIBUF t means consider the -minibuffer window even if the minibuffer is not active. Any other value -means do not consider the minibuffer window even if the minibuffer is -active. - -Optional argument ALL-FRAMES nil or omitted means consider all windows -on WINDOW's frame, plus the minibuffer window if specified by the -MINIBUF argument. If the minibuffer counts, consider all windows on all -frames that share that minibuffer too. The following non-nil values of -ALL-FRAMES have special meanings: - -- t means consider all windows on all existing frames. - -- `visible' means consider all windows on all visible frames. - -- 0 (the number zero) means consider all windows on all visible and - iconified 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 WINDOW is not on the list of windows returned, some other window will -be listed first but no error is signalled. */) - (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames) -{ - return window_list_1 (window, minibuf, all_frames); -} - - DEFUN ("other-window", Fother_window, Sother_window, 1, 2, "p", doc: /* Select another window in cyclic ordering of windows. COUNT specifies the number of windows to skip, starting with the @@ -2547,6 +2597,41 @@ } +DEFUN ("window-list-1", Fwindow_list_1, Swindow_list_1, 0, 3, 0, + doc: /* Return a list of all live windows. +WINDOW specifies the first window to list and defaults to the selected +window. + +Optional argument MINIBUF nil or omitted means consider the minibuffer +window only if the minibuffer is active. MINIBUF t means consider the +minibuffer window even if the minibuffer is not active. Any other value +means do not consider the minibuffer window even if the minibuffer is +active. + +Optional argument ALL-FRAMES nil or omitted means consider all windows +on WINDOW's frame, plus the minibuffer window if specified by the +MINIBUF argument. If the minibuffer counts, consider all windows on all +frames that share that minibuffer too. The following non-nil values of +ALL-FRAMES have special meanings: + +- t means consider all windows on all existing frames. + +- `visible' means consider all windows on all visible frames. + +- 0 (the number zero) means consider all windows on all visible and + iconified 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 WINDOW is not on the list of windows returned, some other window will +be listed first but no error is signalled. */) + (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames) +{ + return window_list_1 (window, minibuf, all_frames); +} /* Look at all windows, performing an operation specified by TYPE with argument OBJ. @@ -2801,6 +2886,248 @@ return Qnil; } +Lisp_Object +resize_root_window (Lisp_Object window, Lisp_Object delta, Lisp_Object horizontal, Lisp_Object ignore) +{ + return call4 (Qresize_root_window, window, delta, horizontal, ignore); +} + + +DEFUN ("delete-other-windows-internal", Fdelete_other_windows_internal, + Sdelete_other_windows_internal, 0, 2, "", + doc: /* Make WINDOW fill its frame. +Only the frame WINDOW is on is affected. WINDOW may be any window and +defaults to the selected one. + +Optional argument ROOT, if non-nil, must specify an internal window +containing WINDOW as a subwindow. If this is the case, replace ROOT by +WINDOW and leave alone any windows not contained in ROOT. + +When WINDOW is live try to reduce display jumps by keeping the text +previously visible in WINDOW in the same place on the frame. Doing this +depends on the value of (window-start WINDOW), so if calling this +function in a program gives strange scrolling, make sure the +window-start value is reasonable when this function is called. */) + (Lisp_Object window, Lisp_Object root) +{ + struct window *w, *r, *s; + struct frame *f; + Lisp_Object sibling, pwindow, swindow, delta; + EMACS_INT startpos; + int top, new_top, resize_failed; + + w = decode_any_window (window); + XSETWINDOW (window, w); + f = XFRAME (w->frame); + + if (NILP (root)) + /* ROOT is the frame's root window. */ + { + root = FRAME_ROOT_WINDOW (f); + r = XWINDOW (root); + } + else + /* ROOT must be an ancestor of WINDOW. */ + { + r = decode_any_window (root); + pwindow = XWINDOW (window)->parent; + while (!NILP (pwindow)) + if (EQ (pwindow, root)) + break; + else + pwindow = XWINDOW (pwindow)->parent; + if (!EQ (pwindow, root)) + error ("Specified root is not an ancestor of specified window"); + } + + if (EQ (window, root)) + /* A noop. */ + return Qnil; + /* I don't understand the "top > 0" part below. If we deal with a + standalone minibuffer it would have been caught by the preceding + test. */ + else if (MINI_WINDOW_P (w)) /* && top > 0) */ + error ("Can't expand minibuffer to full frame"); + + if (!NILP (w->buffer)) + { + startpos = marker_position (w->start); + top = WINDOW_TOP_EDGE_LINE (w) + - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); + /* Make sure WINDOW is the frame's selected window. */ + if (!EQ (window, FRAME_SELECTED_WINDOW (f))) + { + if (EQ (selected_frame, w->frame)) + Fselect_window (window, Qnil); + else + FRAME_SELECTED_WINDOW (f) = window; + } + } + else + { + /* See if the frame's selected window is a subwindow of WINDOW, by + finding all the selected window's parents and comparing each + one with WINDOW. If it isn't we need a new selected window for + this frame. */ + swindow = FRAME_SELECTED_WINDOW (f); + while (1) + { + pwindow = swindow; + while (!NILP (pwindow) && !EQ (window, pwindow)) + pwindow = XWINDOW (pwindow)->parent; + + if (EQ (window, pwindow)) + /* If WINDOW is an ancestor of SWINDOW, then SWINDOW is ok + as the new selected window. */ + break; + else + /* Else try the previous window of SWINDOW. */ + swindow = Fprevious_window (swindow, Qlambda, Qnil); + } + + if (!EQ (swindow, FRAME_SELECTED_WINDOW (f))) + { + if (EQ (selected_frame, w->frame)) + Fselect_window (swindow, Qnil); + else + FRAME_SELECTED_WINDOW (f) = swindow; + } + } + + BLOCK_INPUT; + free_window_matrices (r); + + windows_or_buffers_changed++; + Vwindow_list = Qnil; + FRAME_WINDOW_SIZES_CHANGED (f) = 1; + + if (NILP (w->buffer)) + { + resize_failed = 0; + /* Resize subwindows vertically. */ + XSETINT (delta, XINT (r->total_lines) - XINT (w->total_lines)); + w->top_line = r->top_line; + resize_root_window (window, delta, Qnil, Qnil); + if (resize_window_check (w, 0)) + resize_window_apply (w, 0); + else + { + resize_root_window (window, delta, Qnil, Qt); + if (resize_window_check (w, 0)) + resize_window_apply (w, 0); + else + resize_failed = 1; + } + + /* Resize subwindows horizontally. */ + if (!resize_failed) + { + w->left_col = r->left_col; + XSETINT (delta, XINT (r->total_cols) - XINT (w->total_cols)); + w->left_col = r->left_col; + resize_root_window (window, delta, Qt, Qnil); + if (resize_window_check (w, 1)) + resize_window_apply (w, 1); + else + { + resize_root_window (window, delta, Qt, Qt); + if (resize_window_check (w, 1)) + resize_window_apply (w, 1); + else + resize_failed = 1; + } + } + + if (resize_failed) + /* Play safe, if we still can ... */ + { + window = swindow; + w = XWINDOW (window); + } + } + + /* Cleanly unlink WINDOW from window-tree. */ + if (!NILP (w->prev)) + /* Get SIBLING above (on the left of) WINDOW. */ + { + sibling = w->prev; + s = XWINDOW (sibling); + s->next = w->next; + if (!NILP (s->next)) + XWINDOW (s->next)->prev = sibling; + } + else + /* Get SIBLING below (on the right of) WINDOW. */ + { + sibling = w->next; + s = XWINDOW (sibling); + s->prev = Qnil; + if (!NILP (XWINDOW (w->parent)->vchild)) + XWINDOW (w->parent)->vchild = sibling; + else + XWINDOW (w->parent)->hchild = sibling; + } + + /* Delete ROOT and all subwindows of ROOT. */ + if (!NILP (r->vchild)) + { + delete_all_subwindows (r->vchild); + r->vchild = Qnil; + } + else if (!NILP (r->hchild)) + { + delete_all_subwindows (r->hchild); + r->hchild = Qnil; + } + + replace_window (root, window, 1); + + /* Reset WINDOW's splits status. */ + w->splits = Qnil; + + /* This must become SWINDOW anyway ....... */ + if (!NILP (w->buffer) && !resize_failed) + { + /* Try to minimize scrolling, by setting the window start to the + point will cause the text at the old window start to be at the + same place on the frame. But don't try to do this if the + window start is outside the visible portion (as might happen + when the display is not current, due to typeahead). */ + new_top = WINDOW_TOP_EDGE_LINE (w) - FRAME_TOP_MARGIN (XFRAME (WINDOW_FRAME (w))); + if (new_top != top + && startpos >= BUF_BEGV (XBUFFER (w->buffer)) + && startpos <= BUF_ZV (XBUFFER (w->buffer))) + { + struct position pos; + struct buffer *obuf = current_buffer; + + Fset_buffer (w->buffer); + /* This computation used to temporarily move point, but that + can have unwanted side effects due to text properties. */ + pos = *vmotion (startpos, -top, w); + + set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); + w->window_end_valid = Qnil; + w->start_at_line_beg = ((pos.bytepos == BEGV_BYTE + || FETCH_BYTE (pos.bytepos - 1) == '\n') ? Qt + : Qnil); + /* We need to do this, so that the window-scroll-functions + get called. */ + w->optional_new_start = Qt; + + set_buffer_internal (obuf); + } + } + + adjust_glyphs (f); + UNBLOCK_INPUT; + + run_window_configuration_change_hook (f); + + return Qnil; +} + + DEFUN ("delete-other-windows", Fdelete_other_windows, Sdelete_other_windows, 0, 1, "", doc: /* Make WINDOW (or the selected window) fill its frame. @@ -3676,12 +4003,6 @@ if (NILP (Vrun_hooks)) return; - if (SELECTED_FRAME () != f) - { - record_unwind_protect (select_frame_norecord, Fselected_frame ()); - Fselect_frame (frame, Qt); - } - /* Use the right buffer. Matters when running the local hooks. */ if (current_buffer != XBUFFER (Fwindow_buffer (Qnil))) { @@ -3689,6 +4010,12 @@ Fset_buffer (Fwindow_buffer (Qnil)); } + if (SELECTED_FRAME () != f) + { + record_unwind_protect (select_frame_norecord, Fselected_frame ()); + select_frame_norecord (frame); + } + /* Look for buffer-local values. */ { Lisp_Object windows = Fwindow_list (frame, Qlambda, Qnil); @@ -3699,12 +4026,12 @@ if (!NILP (Flocal_variable_p (Qwindow_configuration_change_hook, buffer))) { - int count1 = SPECPDL_INDEX (); + int count = SPECPDL_INDEX (); record_unwind_protect (select_window_norecord, Fselected_window ()); select_window_norecord (window); run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook, buffer)); - unbind_to (count1, Qnil); + unbind_to (count, Qnil); } } } @@ -3713,6 +4040,16 @@ unbind_to (count, Qnil); } +DEFUN ("run-window-configuration-change-hook", Frun_window_configuration_change_hook, + Srun_window_configuration_change_hook, 1, 1, 0, + doc: /* Run `window-configuration-change-hook' for FRAME. */) + (Lisp_Object frame) +{ + CHECK_LIVE_FRAME (frame); + run_window_configuration_change_hook (XFRAME (frame)); + return Qnil; +} + /* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero means it's allowed to run hooks. See make_frame for a case where it's not allowed. KEEP_MARGINS_P non-zero means that the current @@ -4019,7 +4356,7 @@ XSETFASTINT (p->clone_number, sequence_number); /* Put new into window structure in place of window */ - replace_window (window, new); + replace_window (window, new, 1); o->next = Qnil; o->prev = Qnil; @@ -4037,6 +4374,43 @@ } +/* Make new window, have it replace WINDOW in window-tree, and make + WINDOW its only vertical child (HORFLAG 1 means make WINDOW its only + horizontal child). */ +static void +make_parent_window (Lisp_Object window, int horflag) +{ + Lisp_Object parent; + register struct window *o, *p; + int i; + + o = XWINDOW (window); + p = allocate_window (); + for (i = 0; i < VECSIZE (struct window); ++i) + ((struct Lisp_Vector *) p)->contents[i] + = ((struct Lisp_Vector *) o)->contents[i]; + XSETWINDOW (parent, p); + + ++sequence_number; + XSETFASTINT (p->sequence_number, sequence_number); + XSETFASTINT (p->clone_number, sequence_number); + + replace_window (window, parent, 1); + + o->next = Qnil; + o->prev = Qnil; + o->parent = parent; + + p->hchild = horflag ? window : Qnil; + p->vchild = horflag ? Qnil : window; + p->start = Qnil; + p->pointm = Qnil; + p->buffer = Qnil; + p->splits = Qnil; + p->nest = Qnil; + p->window_parameters = Qnil; +} + /* Make new window from scratch. */ Lisp_Object make_window (void) @@ -4138,6 +4512,654 @@ return w->new_normal; } +/* Return 1 if setting w->total_lines (w->total_cols if HORFLAG is + non-zero) to w->new_total would result in correct heights (widths) + for window W and recursively all subwindows of W. + + Note: This function does not check any of `window-fixed-size-p', + `window-min-height' or `window-min-width'. It does check that window + sizes do not drop below one line (two columns). */ +int +resize_window_check (struct window *w, int horflag) +{ + struct window *c; + + if (!NILP (w->vchild)) + /* W is a vertical combination. */ + { + c = XWINDOW (w->vchild); + if (horflag) + /* All subwindows of W must have the same width as W. */ + { + while (c) + { + if ((XINT (c->new_total) != XINT (w->new_total)) + || !resize_window_check (c, horflag)) + return 0; + c = NILP (c->next) ? 0 : XWINDOW (c->next); + } + return 1; + } + else + /* The sum of the heights of the subwindows of W must equal W's + height. */ + { + int sum_of_sizes = 0; + while (c) + { + if (!resize_window_check (c, horflag)) + return 0; + sum_of_sizes = sum_of_sizes + XINT (c->new_total); + c = NILP (c->next) ? 0 : XWINDOW (c->next); + } + return (sum_of_sizes == XINT (w->new_total)); + } + } + else if (!NILP (w->hchild)) + /* W is a horizontal combination. */ + { + c = XWINDOW (w->hchild); + if (horflag) + /* The sum of the widths of the subwindows of W must equal W's + width. */ + { + int sum_of_sizes = 0; + while (c) + { + if (!resize_window_check (c, horflag)) + return 0; + sum_of_sizes = sum_of_sizes + XINT (c->new_total); + c = NILP (c->next) ? 0 : XWINDOW (c->next); + } + return (sum_of_sizes == XINT (w->new_total)); + } + else + /* All subwindows of W must have the same height as W. */ + { + while (c) + { + if ((XINT (c->new_total) != XINT (w->new_total)) + || !resize_window_check (c, horflag)) + return 0; + c = NILP (c->next) ? 0 : XWINDOW (c->next); + } + return 1; + } + } + else + /* A leaf window. Make sure it's not too small. The following + hardcodes the values of `window-safe-min-width' (2) and + `window-safe-min-height' (1) which are defined in window.el. */ + return XINT (w->new_total) >= (horflag ? 2 : 1); +} + +/* Set w->total_lines (w->total_cols if HORIZONTAL is non-zero) to + w->new_total for window W and recursively all subwindows of W. Also + calculate and assign the new vertical (horizontal) start positions of + each of these windows. + + This function does not perform any error checks. Make sure you have + run resize_window_check on W before applying this function. */ +void +resize_window_apply (struct window *w, int horflag) +{ + struct window *c, *p; + int pos; + + /* Note: Assigning new_normal requires that the new total size of the + parent window has been set *before*. */ + if (horflag) + { + w->total_cols = w->new_total; + if (NUMBERP (w->new_normal)) + w->normal_cols = w->new_normal; + + pos = XINT (w->left_col); + } + else + { + w->total_lines = w->new_total; + if (NUMBERP (w->new_normal)) + w->normal_lines = w->new_normal; + + pos = XINT (w->top_line); + } + + if (!NILP (w->vchild)) + /* W is a vertical combination. */ + { + c = XWINDOW (w->vchild); + while (c) + { + if (horflag) + XSETFASTINT (c->left_col, pos); + else + XSETFASTINT (c->top_line, pos); + resize_window_apply (c, horflag); + if (!horflag) + pos = pos + XINT (c->total_lines); + c = NILP (c->next) ? 0 : XWINDOW (c->next); + } + } + else if (!NILP (w->hchild)) + /* W is a horizontal combination. */ + { + c = XWINDOW (w->hchild); + while (c) + { + if (horflag) + XSETFASTINT (c->left_col, pos); + else + XSETFASTINT (c->top_line, pos); + resize_window_apply (c, horflag); + if (horflag) + pos = pos + XINT (c->total_cols); + c = NILP (c->next) ? 0 : XWINDOW (c->next); + } + } + + /* Clear out some redisplay caches. */ + XSETFASTINT (w->last_modified, 0); + XSETFASTINT (w->last_overlay_modified, 0); +} + + +DEFUN ("resize-window-apply", Fresize_window_apply, Sresize_window_apply, 1, 2, 0, + doc: /* Apply requested size values for window-tree of FRAME. +Optional argument HORIZONTAL omitted or nil means apply requested height +values. HORIZONTAL non-nil means apply requested width values. + +This function checks whether the requested values sum up to a valid +window layout, recursively assigns the new sizes of all subwindows and +calculates and assigns the new start positions of these windows. + +Note: This function does not check any of `window-fixed-size-p', +`window-min-height' or `window-min-width'. All these checks have to +be applied on the Elisp level. */) + (Lisp_Object frame, Lisp_Object horizontal) +{ + struct frame *f; + struct window *r; + int horflag = !NILP (horizontal); + + if (NILP (frame)) + frame = selected_frame; + CHECK_LIVE_FRAME (frame); + + f = XFRAME (frame); + r = XWINDOW (FRAME_ROOT_WINDOW (f)); + + if (!resize_window_check (r, horflag) + || ! EQ (r->new_total, (horflag ? r->total_cols : r->total_lines))) + return Qnil; + + BLOCK_INPUT; + resize_window_apply (r, horflag); + + windows_or_buffers_changed++; + FRAME_WINDOW_SIZES_CHANGED (f) = 1; + + adjust_glyphs (f); + UNBLOCK_INPUT; + + run_window_configuration_change_hook (f); + + return Qt; +} + + +/* Resize frame F's windows when number of lines of F is set to SIZE. + HORFLAG 1 means resize windows when number of columns of F is set to + SIZE. + + This function can delete all windows but the selected one in order to + satisfy the request. The result will be meaningful if and only if + F's windows have meaningful sizes when you call this. */ +void +resize_frame_windows (struct frame *f, int size, int horflag) +{ + Lisp_Object root = f->root_window; + struct window *r = XWINDOW (root); + Lisp_Object mini = f->minibuffer_window; + struct window *m; + /* new_size is the new size of the frame's root window. */ + int new_size = (horflag + ? size + : (size + - FRAME_TOP_MARGIN (f) + - ((FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f)) + ? 1 : 0))); + + XSETFASTINT (r->top_line, FRAME_TOP_MARGIN (f)); + if (NILP (r->vchild) && NILP (r->hchild)) + /* For a leaf root window just set the size. */ + if (horflag) + XSETFASTINT (r->total_cols, new_size); + else + XSETFASTINT (r->total_lines, new_size); + else + { + /* old_size is the old size of the frame's root window. */ + int old_size = XFASTINT (horflag ? r->total_cols : r->total_lines); + Lisp_Object delta; + + XSETINT (delta, new_size - old_size); + /* Try a "normal" resize first. */ + resize_root_window (root, delta, horflag ? Qt : Qnil, Qnil); + if (resize_window_check (r, horflag) && new_size == XINT (r->new_total)) + resize_window_apply (r, horflag); + else + { + /* Try with "reasonable" minimum sizes next. */ + resize_root_window (root, delta, horflag ? Qt : Qnil, Qt); + if (resize_window_check (r, horflag) + && new_size == XINT (r->new_total)) + resize_window_apply (r, horflag); + else + { + /* Finally, try with "safe" minimum sizes. */ + resize_root_window (root, delta, horflag ? Qt : Qnil, Qsafe); + if (resize_window_check (r, horflag) + && new_size == XINT (r->new_total)) + resize_window_apply (r, horflag); + else + { + /* We lost. Delete all windows but the frame's + selected one. */ + root = f->selected_window; + Fdelete_other_windows_internal (root, Qnil); + if (horflag) + XSETFASTINT (XWINDOW (root)->total_cols, new_size); + else + XSETFASTINT (XWINDOW (root)->total_lines, new_size); + } + } + } + } + + if (FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f)) + { + m = XWINDOW (mini); + if (horflag) + XSETFASTINT (m->total_cols, size); + else + { + /* Are we sure we always want 1 line here? */ + XSETFASTINT (m->total_lines, 1); + XSETFASTINT (m->top_line, XINT (r->top_line) + XINT (r->total_lines)); + } + } +} + + +DEFUN ("split-window-internal", Fsplit_window_internal, Ssplit_window_internal, 4, 4, 0, + doc: /* Split window OLD. +Second argument TOTAL-SIZE specifies the number of lines or columns of the +new window. In any case TOTAL-SIZE must be a positive integer + +Third argument SIDE nil (or `below') specifies that the new window shall +be located below WINDOW. SIDE `above' means the new window shall be +located above WINDOW. In both cases TOTAL-SIZE specifies the number of +lines of the new window including space reserved for the mode and/or +header line. + +SIDE t (or `right') specifies that the new window shall be located on +the right side of WINDOW. SIDE `left' means the new window shall be +located on the left of WINDOW. In both cases TOTAL-SIZE specifies the +number of columns of the new window including space reserved for fringes +and the scrollbar or a divider column. + +Fourth argument NORMAL-SIZE specifies the normal size of the new window +according to the SIDE argument. + +The new total and normal sizes of all involved windows must have been +set correctly. See the code of `split-window' for how this is done. */) + (Lisp_Object old, Lisp_Object total_size, Lisp_Object side, Lisp_Object normal_size) +{ + /* OLD (*o) is the window we have to split. (*p) is either OLD's + parent window or an internal window we have to install as OLD's new + parent. REFERENCE (*r) must denote a live window, or is set to OLD + provided OLD is a leaf window, or to the frame's selected window. + NEW (*n) is the new window created with some parameters taken from + REFERENCE (*r). */ + register Lisp_Object new, frame, reference; + register struct window *o, *p, *n, *r; + struct frame *f; + int horflag + /* HORFLAG is 1 when we split side-by-side, 0 otherwise. */ + = EQ (side, Qt) || EQ (side, Qleft) || EQ (side, Qright); + int do_nest = 0; + + CHECK_WINDOW (old); + o = XWINDOW (old); + frame = WINDOW_FRAME (o); + f = XFRAME (frame); + + CHECK_NUMBER (total_size); + + /* Set do_nest to 1 if we have to make a new parent window. We do + that if either `window-nest' is non-nil, or OLD has no parent, or + OLD is ortho-combined. */ + do_nest = + !NILP (Vwindow_nest) + || NILP (o->parent) + || NILP (horflag + ? (XWINDOW (o->parent)->hchild) + : (XWINDOW (o->parent)->vchild)); + + /* We need a live reference window to initialize some parameters. */ + if (WINDOW_LIVE_P (old)) + /* OLD is live, use it as reference window. */ + reference = old; + else + /* Use the frame's selected window as reference window. */ + reference = FRAME_SELECTED_WINDOW (f); + r = XWINDOW (reference); + + /* The following bugs are caught by `split-window'. */ + if (MINI_WINDOW_P (o)) + error ("Attempt to split minibuffer window"); + else if (XINT (total_size) < (horflag ? 2 : 1)) + error ("Size of new window too small (after split)"); + else if (!do_nest && !NILP (Vwindow_splits)) + /* `window-splits' non-nil means try to resize OLD's siblings + proportionally. */ + { + p = XWINDOW (o->parent); + /* Temporarily pretend we split the parent window. */ + XSETINT (p->new_total, + XINT (horflag ? p->total_cols : p->total_lines) + - XINT (total_size)); + if (!resize_window_check (p, horflag)) + error ("Window sizes don't fit"); + else + /* Undo the temporary pretension. */ + p->new_total = horflag ? p->total_cols : p->total_lines; + } + else + { + if (!resize_window_check (o, horflag)) + error ("Resizing old window failed"); + else if (XINT (total_size) + XINT (o->new_total) + != XINT (horflag ? o->total_cols : o->total_lines)) + error ("Sum of sizes of old and new window don't fit"); + } + + /* This is our point of no return. */ + if (do_nest) + { + /* Save the old value of o->normal_cols/lines. It gets corrupted + by make_parent_window and we need it below for assigning it to + p->new_normal. */ + Lisp_Object new_normal = horflag ? o->normal_cols : o->normal_lines; + + make_parent_window (old, horflag); + p = XWINDOW (o->parent); + /* Store value of `window-nest' in new parent's nest slot. */ + p->nest = Vwindow_nest; + /* Have PARENT inherit splits slot value from OLD. */ + p->splits = o->splits; + /* Store value of `window-splits' in OLD's splits slot. */ + o->splits = Vwindow_splits; + /* These get applied below. */ + p->new_total = horflag ? o->total_cols : o->total_lines; + p->new_normal = new_normal; + } + else + p = XWINDOW (o->parent); + + windows_or_buffers_changed++; + FRAME_WINDOW_SIZES_CHANGED (f) = 1; + new = make_window (); + n = XWINDOW (new); + n->frame = frame; + n->parent = o->parent; + n->vchild = n->hchild = Qnil; + + if (EQ (side, Qabove) || EQ (side, Qleft)) + { + n->prev = o->prev; + if (NILP (n->prev)) + if (horflag) + p->hchild = new; + else + p->vchild = new; + else + XWINDOW (n->prev)->next = new; + n->next = old; + o->prev = new; + } + else + { + n->next = o->next; + if (!NILP (n->next)) + XWINDOW (n->next)->prev = new; + n->prev = old; + o->next = new; + } + + n->buffer = Qt; + n->window_end_valid = Qnil; + memset (&n->last_cursor, 0, sizeof n->last_cursor); + + /* Get special geometry settings from reference window. */ + n->left_margin_cols = r->left_margin_cols; + n->right_margin_cols = r->right_margin_cols; + n->left_fringe_width = r->left_fringe_width; + n->right_fringe_width = r->right_fringe_width; + n->fringes_outside_margins = r->fringes_outside_margins; + n->scroll_bar_width = r->scroll_bar_width; + n->vertical_scroll_bar_type = r->vertical_scroll_bar_type; + + /* Store `window-splits' in NEW's splits slot. */ + n->splits = Vwindow_splits; + + /* Directly assign orthogonal coordinates and sizes. */ + if (horflag) + { + n->top_line = o->top_line; + n->total_lines = o->total_lines; + } + else + { + n->left_col = o->left_col; + n->total_cols = o->total_cols; + } + + /* Iso-coordinates and sizes are assigned by resize_window_apply, + get them ready here. */ + n->new_total = total_size; + n->new_normal = normal_size; + + BLOCK_INPUT; + resize_window_apply (p, horflag); + adjust_glyphs (f); + /* Set buffer of NEW to buffer of reference window. Don't run + any hooks. */ + set_window_buffer (new, r->buffer, 0, 1); + UNBLOCK_INPUT; + + /* Maybe we should run the scroll functions in Elisp (which already + runs the configuration change hook). */ + if (! NILP (Vwindow_scroll_functions)) + run_hook_with_args_2 (Qwindow_scroll_functions, new, + Fmarker_position (n->start)); + /* Return NEW. */ + return new; +} + + +DEFUN ("delete-window-internal", Fdelete_window_internal, Sdelete_window_internal, 1, 1, 0, + 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. */) + (register Lisp_Object window) +{ + register Lisp_Object parent, sibling, frame, root; + struct window *w, *p, *s, *r; + struct frame *f; + int horflag; + int before_sibling = 0; + + w = decode_any_window (window); + XSETWINDOW (window, w); + if (NILP (w->buffer) && NILP (w->hchild) && NILP (w->vchild)) + /* It's a no-op to delete an already deleted window. */ + return Qnil; + + parent = w->parent; + if (NILP (parent)) + /* Never delete a minibuffer or frame root window. */ + error ("Attempt to delete minibuffer or sole ordinary window"); + else if (NILP (w->prev) && NILP (w->next)) + /* Rather bow out here, this case should be handled on the Elisp + level. */ + error ("Attempt to delete sole window of parent"); + + p = XWINDOW (parent); + horflag = NILP (p->vchild); + + frame = WINDOW_FRAME (w); + f = XFRAME (frame); + + root = FRAME_ROOT_WINDOW (f); + r = XWINDOW (root); + + /* Unlink WINDOW from window tree. */ + if (NILP (w->prev)) + /* Get SIBLING below (on the right of) WINDOW. */ + { + /* before_sibling 1 means WINDOW is the first child of its + parent and thus before the sibling. */ + before_sibling = 1; + sibling = w->next; + s = XWINDOW (sibling); + s->prev = Qnil; + if (horflag) + p->hchild = sibling; + else + p->vchild = sibling; + } + else + /* Get SIBLING above (on the left of) WINDOW. */ + { + sibling = w->prev; + s = XWINDOW (sibling); + s->next = w->next; + if (!NILP (s->next)) + XWINDOW (s->next)->prev = sibling; + } + + if (resize_window_check (r, horflag) + && EQ (r->new_total, (horflag ? r->total_cols : r->total_lines))) + /* We can delete WINDOW now. */ + { + /* Block input. */ + BLOCK_INPUT; + resize_window_apply (p, horflag); + + windows_or_buffers_changed++; + Vwindow_list = Qnil; + FRAME_WINDOW_SIZES_CHANGED (f) = 1; + + w->next = Qnil; /* Don't delete w->next too. */ + free_window_matrices (w); + + if (!NILP (w->vchild)) + { + delete_all_subwindows (w->vchild); + w->vchild = Qnil; + } + else if (!NILP (w->hchild)) + { + delete_all_subwindows (w->hchild); + w->hchild = Qnil; + } + else if (!NILP (w->buffer)) + { + unshow_buffer (w); + unchain_marker (XMARKER (w->pointm)); + unchain_marker (XMARKER (w->start)); + w->buffer = Qnil; + } + + if (NILP (s->prev) && NILP (s->next)) + /* A matrjoshka where SIBLING has become the only child of + PARENT. */ + { + /* Put SIBLING into PARENT's place. */ + replace_window (parent, sibling, 0); + /* Have SIBLING inherit the following three slot values from + PARENT (the nest slot is not inherited). */ + s->normal_cols = p->normal_cols; + s->normal_lines = p->normal_lines; + s->splits = p->splits; + /* Mark PARENT as deleted. */ + p->vchild = p->hchild = Qnil; + /* Try to merge SIBLING into its new parent. */ + recombine_windows (sibling); + } + + adjust_glyphs (f); + + if (!WINDOW_LIVE_P (FRAME_SELECTED_WINDOW (f))) + /* We deleted the frame's selected window. */ + { + /* Use the frame's first window as fallback ... */ + Lisp_Object new_selected_window = Fframe_first_window (frame); + /* ... but preferably use its most recently used window. */ + Lisp_Object mru_window; + + /* `get-mru-window' might fail for some reason so play it safe + - promote the first window _without recording it_ first. */ + if (EQ (FRAME_SELECTED_WINDOW (f), selected_window)) + Fselect_window (new_selected_window, Qt); + else + FRAME_SELECTED_WINDOW (f) = new_selected_window; + + UNBLOCK_INPUT; + + /* Now look whether `get-mru-window' gets us something. */ + mru_window = call1 (Qget_mru_window, frame); + if (WINDOW_LIVE_P (mru_window) + && EQ (XWINDOW (mru_window)->frame, frame)) + new_selected_window = mru_window; + + /* If all ended up well, we now promote the mru window. */ + if (EQ (FRAME_SELECTED_WINDOW (f), selected_window)) + Fselect_window (new_selected_window, Qnil); + else + FRAME_SELECTED_WINDOW (f) = new_selected_window; + } + else + UNBLOCK_INPUT; + + /* Must be run by the caller: + run_window_configuration_change_hook (f); */ + } + else + /* We failed: Relink WINDOW into window tree. */ + { + if (before_sibling) + { + s->prev = window; + if (horflag) + p->hchild = window; + else + p->vchild = window; + } + else + { + s->next = window; + if (!NILP (w->next)) + XWINDOW (w->next)->prev = window; + } + error ("Deletion failed"); + } + + return Qnil; +} + DEFUN ("split-window", Fsplit_window, Ssplit_window, 0, 3, "", doc: /* Split WINDOW, putting SIZE lines in the first of the pair. WINDOW defaults to selected one and SIZE to half its size. @@ -4279,6 +5301,46 @@ Fset_window_buffer (new, o->buffer, Qt); return new; } + +DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini_window_internal, 1, 1, 0, + doc: /* Resize minibuffer window WINDOW. */) + (Lisp_Object window) +{ + struct window *w = XWINDOW (window); + struct window *r; + struct frame *f; + int height; + + CHECK_WINDOW (window); + f = XFRAME (w->frame); + + if (!EQ (FRAME_MINIBUF_WINDOW (XFRAME (w->frame)), window)) + error ("Not a valid minibuffer window"); + else if (FRAME_MINIBUF_ONLY_P (f)) + error ("Cannot resize a minibuffer-only frame"); + + r = XWINDOW (FRAME_ROOT_WINDOW (f)); + height = XINT (r->total_lines) + XINT (w->total_lines); + if (resize_window_check (r, 0) + && XINT (w->new_total) > 0 + && height == XINT (r->new_total) + XINT (w->new_total)) + { + BLOCK_INPUT; + resize_window_apply (r, 0); + + w->total_lines = w->new_total; + XSETFASTINT (w->top_line, XINT (r->top_line) + XINT (r->total_lines)); + + windows_or_buffers_changed++; + FRAME_WINDOW_SIZES_CHANGED (f) = 1; + adjust_glyphs (f); + UNBLOCK_INPUT; + + run_window_configuration_change_hook (f); + return Qt; + } + else error ("Failed to resize minibuffer window"); +} DEFUN ("enlarge-window", Fenlarge_window, Senlarge_window, 1, 2, "p", doc: /* Make selected window SIZE lines taller. @@ -7527,6 +8589,41 @@ frame to be redrawn only if it is a tty frame. */); Vrecenter_redisplay = Qtty; + DEFVAR_LISP ("window-splits", Vwindow_splits, + doc: /* Non-nil means splitting windows is handled specially. +If this variable is nil, splitting a window gets the entire screen space +for displaying the new window from the window to split. If this +variable is non-nil, splitting a window may resize all windows in the +same combination. This also allows to split a window that is otherwise +too small or of fixed size. + +The value of this variable is also assigned to the split status of the +new window and, provided the old and new window form a new combination, +to the window that was split as well. The split status of a window can +be retrieved with the function `window-splits' and altered by the +function `set-window-splits'. + +If the value of the variable `window-nest' is non-nil, the space for the +new window is exclusively taken from the window that shall be split, but +the split status of the window that is split as well as that of the new +window are still set to the value of this variable. */); + Vwindow_splits = Qnil; + + DEFVAR_LISP ("window-nest", Vwindow_nest, + doc: /* Non-nil means splitting a window makes a new parent window. +If this variable is nil, splitting a window will create a new parent +window only if the window has no parent window or the window shall +become a combination orthogonal to the one it it is part of. + +If this variable is non-nil, splitting a window always creates a new +parent window. If all splits behave this way, each frame's window tree +is a binary tree and every window but the frame's root window has +exactly one sibling. + +The value of this variable is also assigned to the nest status of the +new parent window. The nest status of a window can be retrieved via the +function `window-nest' and altered by the function `set-window-nest'. */); + Vwindow_nest = Qnil; defsubr (&Sselected_window); defsubr (&Sminibuffer_window); @@ -7560,6 +8657,7 @@ defsubr (&Swindow_new_normal); defsubr (&Sset_window_new_total); defsubr (&Sset_window_new_normal); + defsubr (&Sresize_window_apply); defsubr (&Swindow_body_size); defsubr (&Swindow_hscroll); defsubr (&Sset_window_hscroll); @@ -7590,12 +8688,17 @@ defsubr (&Sdelete_windows_on); defsubr (&Sreplace_buffer_in_windows); defsubr (&Sdelete_window); + defsubr (&Sdelete_other_windows_internal); + defsubr (&Sdelete_window_internal); + defsubr (&Sresize_mini_window_internal); defsubr (&Sset_window_buffer); defsubr (&Sset_window_clone_number); + defsubr (&Srun_window_configuration_change_hook); defsubr (&Sselect_window); defsubr (&Sforce_window_update); defsubr (&Stemp_output_buffer_show); defsubr (&Ssplit_window); + defsubr (&Ssplit_window_internal); defsubr (&Senlarge_window); defsubr (&Sshrink_window); defsubr (&Sadjust_window_trailing_edge); ------------------------------------------------------------ revno: 104542 committer: Glenn Morris branch nick: trunk timestamp: Wed 2011-06-08 23:07:11 -0700 message: ange-ftp fixes for dired switches not being just a single short option. * lisp/net/ange-ftp.el (ange-ftp-switches-ok): New function. (ange-ftp-get-files): Use it. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-09 05:33:26 +0000 +++ lisp/ChangeLog 2011-06-09 06:07:11 +0000 @@ -1,3 +1,8 @@ +2011-06-09 Glenn Morris + + * net/ange-ftp.el (ange-ftp-switches-ok): New function. + (ange-ftp-get-files): Use it. + 2011-06-09 Alexander Klimov (tiny change) * mail/sendmail.el (mail-recover-1, mail-recover): === modified file 'lisp/net/ange-ftp.el' --- lisp/net/ange-ftp.el 2011-05-23 17:57:17 +0000 +++ lisp/net/ange-ftp.el 2011-06-09 06:07:11 +0000 @@ -2806,6 +2806,19 @@ (and files (puthash (file-name-as-directory directory) files ange-ftp-files-hashtable))) +(defun ange-ftp-switches-ok (switches) + "Return SWITCHES (a string) if suitable for our use." + (and (stringp switches) + ;; We allow the A switch, which lists all files except "." and + ;; "..". This is OK because we manually insert these entries + ;; in the hash table. + (string-match + "--\\(almost-\\)?all\\>\\|\\(\\`\\| \\)-[[:alpha:]]*[aA]" switches) + (string-match "\\(\\`\\| \\)-[[:alpha:]]*l" switches) + (not (string-match + "--recursive\\>\\|\\(\\`\\| \\)-[[:alpha:]]*R" switches)) + switches)) + (defun ange-ftp-get-files (directory &optional no-error) "Given a DIRECTORY, return a hashtable of file entries. This will give an error or return nil, depending on the value of @@ -2817,30 +2830,12 @@ ;; This is an efficiency hack. We try to ;; anticipate what sort of listing dired ;; might want, and cache just such a listing. - (if (and (boundp 'dired-actual-switches) - (stringp dired-actual-switches) - ;; We allow the A switch, which lists - ;; all files except "." and "..". - ;; This is OK because we manually - ;; insert these entries - ;; in the hash table. - (string-match - "[aA]" dired-actual-switches) - (string-match - "l" dired-actual-switches) - (not (string-match - "R" dired-actual-switches))) - dired-actual-switches - (if (and (boundp 'dired-listing-switches) - (stringp dired-listing-switches) - (string-match - "[aA]" dired-listing-switches) - (string-match - "l" dired-listing-switches) - (not (string-match - "R" dired-listing-switches))) - dired-listing-switches - "-al")) + (or (and (boundp 'dired-actual-switches) + (ange-ftp-switches-ok dired-actual-switches)) + (and (boundp 'dired-listing-switches) + (ange-ftp-switches-ok + dired-listing-switches)) + "-al") t no-error) (gethash directory ange-ftp-files-hashtable))))) ------------------------------------------------------------ revno: 104541 author: Alexander Klimov committer: Glenn Morris branch nick: trunk timestamp: Wed 2011-06-08 22:33:26 -0700 message: Small fixes for dired-listing-switches usage. Ref: http://lists.gnu.org/archive/html/emacs-devel/2011-05/msg01000.html * lisp/mail/sendmail.el (mail-recover-1, mail-recover): * lisp/files.el (recover-file, recover-session): Handle dired-listing-switches not being just a single short option. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-09 05:08:11 +0000 +++ lisp/ChangeLog 2011-06-09 05:33:26 +0000 @@ -1,3 +1,9 @@ +2011-06-09 Alexander Klimov (tiny change) + + * mail/sendmail.el (mail-recover-1, mail-recover): + * files.el (recover-file, recover-session): + Handle dired-listing-switches not being just a single short option. + 2011-06-09 Glenn Morris * calendar/appt.el (appt-display-message, appt-disp-window): === modified file 'lisp/files.el' --- lisp/files.el 2011-05-28 19:26:25 +0000 +++ lisp/files.el 2011-06-09 05:33:26 +0000 @@ -5256,7 +5256,7 @@ (save-excursion (let ((switches dired-listing-switches)) (if (file-symlink-p file) - (setq switches (concat switches "L"))) + (setq switches (concat switches " -L"))) (set-buffer standard-output) ;; Use insert-directory-safely, not insert-directory, ;; because these files might not exist. In particular, @@ -5299,7 +5299,7 @@ (error "No previous sessions to recover"))) (let ((ls-lisp-support-shell-wildcards t)) (dired (concat auto-save-list-file-prefix "*") - (concat dired-listing-switches "t"))) + (concat dired-listing-switches " -t"))) (save-excursion (goto-char (point-min)) (or (looking-at " Move to the session you want to recover,") === modified file 'lisp/mail/sendmail.el' --- lisp/mail/sendmail.el 2011-06-01 19:32:04 +0000 +++ lisp/mail/sendmail.el 2011-06-09 05:33:26 +0000 @@ -1801,7 +1801,7 @@ ;; unbound on exit from the let. (require 'dired) (let ((dired-trivial-filenames t)) - (dired-other-window wildcard (concat dired-listing-switches "t"))) + (dired-other-window wildcard (concat dired-listing-switches " -t"))) (rename-buffer "*Auto-saved Drafts*" t) (save-excursion (goto-char (point-min)) @@ -1881,7 +1881,7 @@ ;; `ls' is not a standard program (it will use ;; ls-lisp instead). (dired-noselect file-name - (concat dired-listing-switches "t")))) + (concat dired-listing-switches " -t")))) (save-selected-window (select-window (display-buffer dispbuf t)) (goto-char (point-min)) ------------------------------------------------------------ revno: 104540 committer: Glenn Morris branch nick: trunk timestamp: Wed 2011-06-08 22:08:11 -0700 message: Allow some appt.el display functions to handle lists. * lisp/calendar/appt.el (appt-display-message, appt-disp-window): Handle lists of appointments. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-08 09:13:43 +0000 +++ lisp/ChangeLog 2011-06-09 05:08:11 +0000 @@ -1,3 +1,8 @@ +2011-06-09 Glenn Morris + + * calendar/appt.el (appt-display-message, appt-disp-window): + Handle lists of appointments. + 2011-06-08 Martin Rudalics * window.el (one-window-p): Move down in code. Rewrite === modified file 'lisp/calendar/appt.el' --- lisp/calendar/appt.el 2011-06-08 06:57:38 +0000 +++ lisp/calendar/appt.el 2011-06-09 05:08:11 +0000 @@ -214,20 +214,42 @@ (defun appt-display-message (string mins) "Display a reminder about an appointment. The string STRING describes the appointment, due in integer MINS minutes. -The format of the visible reminder is controlled by `appt-display-format'. -The variable `appt-audible' controls the audible reminder." +The arguments may also be lists, where each element relates to a +separate appointment. The variable `appt-display-format' controls +the format of the visible reminder. If `appt-audible' is non-nil, +also calls `beep' for an audible reminder." (if appt-audible (beep 1)) + ;; Backwards compatibility: avoid passing lists to a-d-w-f if not necessary. + (and (listp mins) + (= (length mins) 1) + (setq mins (car mins) + string (car string))) (cond ((eq appt-display-format 'window) - (funcall appt-disp-window-function - (number-to-string mins) - ;; TODO - use calendar-month-abbrev-array rather than %b? - (format-time-string "%a %b %e " (current-time)) - string) + ;; TODO use calendar-month-abbrev-array rather than %b? + (let ((time (format-time-string "%a %b %e " (current-time))) + err) + (condition-case err + (funcall appt-disp-window-function + (if (listp mins) + (mapcar 'number-to-string mins) + (number-to-string mins)) + time string) + (wrong-type-argument + (if (not (listp mins)) + (signal (car err) (cdr err)) + (message "Argtype error in `appt-disp-window-function' - \ +update it for multiple appts?") + ;; Fallback to just displaying the first appt, as we used to. + (funcall appt-disp-window-function + (number-to-string (car mins)) time + (car string)))))) (run-at-time (format "%d sec" appt-display-duration) nil appt-delete-window-function)) ((eq appt-display-format 'echo) - (message "%s" string)))) + (message "%s" (if (listp string) + (mapconcat 'identity string "\n") + string))))) (defun appt-check (&optional force) @@ -373,8 +395,10 @@ (defun appt-disp-window (min-to-app new-time appt-msg) "Display appointment due in MIN-TO-APP (a string) minutes. -NEW-TIME is a string giving the date. Displays the appointment -message APPT-MSG in a separate buffer." +NEW-TIME is a string giving the current date. +Displays the appointment message APPT-MSG in a separate buffer. +The arguments may also be lists, where each element relates to a +separate appointment." (let ((this-window (selected-window)) (appt-disp-buf (get-buffer-create appt-buffer-name))) ;; Make sure we're not in the minibuffer before splitting the window. @@ -395,17 +419,40 @@ (when (>= (window-height) (* 2 window-min-height)) (select-window (split-window)))) (switch-to-buffer appt-disp-buf)) - ;; FIXME Link to diary entry? - (calendar-set-mode-line - (format " Appointment %s. %s " - (if (string-equal "0" min-to-app) "now" - (format "in %s minute%s" min-to-app - (if (string-equal "1" min-to-app) "" "s"))) - new-time)) - (setq buffer-read-only nil - buffer-undo-list t) - (erase-buffer) - (insert appt-msg) + (or (listp min-to-app) + (setq min-to-app (list min-to-app) + appt-msg (list appt-msg))) + ;; I don't really see the point of the new-time argument. + ;; It repeatedly reminds you of the date? + ;; It would make more sense if it was eg the time of the appointment. + ;; Let's allow it to be a list or not independent of the other elements. + (or (listp new-time) + (setq new-time (list new-time))) + ;; All this silliness is just to make the formatting slightly nicer. + (let* ((multiple (> (length min-to-app) 1)) + (sametime (or (not multiple) + (not (delete (car min-to-app) min-to-app)))) + (imin (if sametime (car min-to-app)))) + ;; FIXME Link to diary entry? + (calendar-set-mode-line + (format " Appointment%s %s. %s " + (if multiple "s" "") + (if (equal imin "0") + "now" + (format "in %s minute%s" + (or imin (mapconcat 'identity min-to-app ",")) + (if (equal imin "1") + "" "s"))) + (mapconcat 'identity new-time ", "))) + (setq buffer-read-only nil + buffer-undo-list t) + (erase-buffer) + ;; If we have appointments at different times, prepend the times. + (if sametime + (insert (mapconcat 'identity appt-msg "\n")) + (dotimes (i (length appt-msg)) + (insert (format "%s%sm: %s" (if (> i 0) "\n" "") + (nth i min-to-app) (nth i appt-msg)))))) (shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf t)) (set-buffer-modified-p nil) (setq buffer-read-only t) ------------------------------------------------------------ revno: 104539 committer: Paul Eggert branch nick: trunk timestamp: Wed 2011-06-08 09:26:45 -0700 message: * lib/gnulib.mk, m4/gnulib-common.m4: Merge from gnulib. diff: === modified file 'ChangeLog' --- ChangeLog 2011-06-08 06:51:26 +0000 +++ ChangeLog 2011-06-08 16:26:45 +0000 @@ -1,3 +1,7 @@ +2011-06-08 Paul Eggert + + * lib/gnulib.mk, m4/gnulib-common.m4: Merge from gnulib. + 2011-06-07 Paul Eggert * configure.in: Add --with-wide-int. === modified file 'lib/gnulib.mk' --- lib/gnulib.mk 2011-05-29 21:52:18 +0000 +++ lib/gnulib.mk 2011-06-08 16:26:45 +0000 @@ -414,58 +414,58 @@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ - -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \ - -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \ - -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \ - -e 's|@''GNULIB_FGETC''@|$(GNULIB_FGETC)|g' \ - -e 's|@''GNULIB_FGETS''@|$(GNULIB_FGETS)|g' \ - -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \ - -e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \ - -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \ - -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \ - -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \ - -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \ - -e 's|@''GNULIB_FREAD''@|$(GNULIB_FREAD)|g' \ - -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \ - -e 's|@''GNULIB_FSCANF''@|$(GNULIB_FSCANF)|g' \ - -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \ - -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \ - -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \ - -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \ - -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \ - -e 's|@''GNULIB_GETC''@|$(GNULIB_GETC)|g' \ - -e 's|@''GNULIB_GETCHAR''@|$(GNULIB_GETCHAR)|g' \ - -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \ - -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \ - -e 's|@''GNULIB_GETS''@|$(GNULIB_GETS)|g' \ - -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \ - -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \ - -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \ - -e 's|@''GNULIB_POPEN''@|$(GNULIB_POPEN)|g' \ - -e 's|@''GNULIB_PRINTF''@|$(GNULIB_PRINTF)|g' \ - -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \ - -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \ - -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \ - -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \ - -e 's|@''GNULIB_REMOVE''@|$(GNULIB_REMOVE)|g' \ - -e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \ - -e 's|@''GNULIB_RENAMEAT''@|$(GNULIB_RENAMEAT)|g' \ - -e 's|@''GNULIB_SCANF''@|$(GNULIB_SCANF)|g' \ - -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \ - -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \ - -e 's|@''GNULIB_STDIO_H_NONBLOCKING''@|$(GNULIB_STDIO_H_NONBLOCKING)|g' \ - -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \ - -e 's|@''GNULIB_TMPFILE''@|$(GNULIB_TMPFILE)|g' \ - -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \ - -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \ - -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \ - -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \ - -e 's|@''GNULIB_VFSCANF''@|$(GNULIB_VFSCANF)|g' \ - -e 's|@''GNULIB_VSCANF''@|$(GNULIB_VSCANF)|g' \ - -e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \ - -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \ - -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \ - -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \ + -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \ + -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \ + -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \ + -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \ + -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \ + -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \ + -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \ + -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \ + -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \ + -e 's/@''GNULIB_FPUTC''@/$(GNULIB_FPUTC)/g' \ + -e 's/@''GNULIB_FPUTS''@/$(GNULIB_FPUTS)/g' \ + -e 's/@''GNULIB_FREAD''@/$(GNULIB_FREAD)/g' \ + -e 's/@''GNULIB_FREOPEN''@/$(GNULIB_FREOPEN)/g' \ + -e 's/@''GNULIB_FSCANF''@/$(GNULIB_FSCANF)/g' \ + -e 's/@''GNULIB_FSEEK''@/$(GNULIB_FSEEK)/g' \ + -e 's/@''GNULIB_FSEEKO''@/$(GNULIB_FSEEKO)/g' \ + -e 's/@''GNULIB_FTELL''@/$(GNULIB_FTELL)/g' \ + -e 's/@''GNULIB_FTELLO''@/$(GNULIB_FTELLO)/g' \ + -e 's/@''GNULIB_FWRITE''@/$(GNULIB_FWRITE)/g' \ + -e 's/@''GNULIB_GETC''@/$(GNULIB_GETC)/g' \ + -e 's/@''GNULIB_GETCHAR''@/$(GNULIB_GETCHAR)/g' \ + -e 's/@''GNULIB_GETDELIM''@/$(GNULIB_GETDELIM)/g' \ + -e 's/@''GNULIB_GETLINE''@/$(GNULIB_GETLINE)/g' \ + -e 's/@''GNULIB_GETS''@/$(GNULIB_GETS)/g' \ + -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \ + -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \ + -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \ + -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \ + -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \ + -e 's/@''GNULIB_PRINTF_POSIX''@/$(GNULIB_PRINTF_POSIX)/g' \ + -e 's/@''GNULIB_PUTC''@/$(GNULIB_PUTC)/g' \ + -e 's/@''GNULIB_PUTCHAR''@/$(GNULIB_PUTCHAR)/g' \ + -e 's/@''GNULIB_PUTS''@/$(GNULIB_PUTS)/g' \ + -e 's/@''GNULIB_REMOVE''@/$(GNULIB_REMOVE)/g' \ + -e 's/@''GNULIB_RENAME''@/$(GNULIB_RENAME)/g' \ + -e 's/@''GNULIB_RENAMEAT''@/$(GNULIB_RENAMEAT)/g' \ + -e 's/@''GNULIB_SCANF''@/$(GNULIB_SCANF)/g' \ + -e 's/@''GNULIB_SNPRINTF''@/$(GNULIB_SNPRINTF)/g' \ + -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GNULIB_SPRINTF_POSIX)/g' \ + -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GNULIB_STDIO_H_NONBLOCKING)/g' \ + -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GNULIB_STDIO_H_SIGPIPE)/g' \ + -e 's/@''GNULIB_TMPFILE''@/$(GNULIB_TMPFILE)/g' \ + -e 's/@''GNULIB_VASPRINTF''@/$(GNULIB_VASPRINTF)/g' \ + -e 's/@''GNULIB_VDPRINTF''@/$(GNULIB_VDPRINTF)/g' \ + -e 's/@''GNULIB_VFPRINTF''@/$(GNULIB_VFPRINTF)/g' \ + -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GNULIB_VFPRINTF_POSIX)/g' \ + -e 's/@''GNULIB_VFSCANF''@/$(GNULIB_VFSCANF)/g' \ + -e 's/@''GNULIB_VSCANF''@/$(GNULIB_VSCANF)/g' \ + -e 's/@''GNULIB_VPRINTF''@/$(GNULIB_VPRINTF)/g' \ + -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GNULIB_VPRINTF_POSIX)/g' \ + -e 's/@''GNULIB_VSNPRINTF''@/$(GNULIB_VSNPRINTF)/g' \ + -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GNULIB_VSPRINTF_POSIX)/g' \ < $(srcdir)/stdio.in.h | \ sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \ @@ -538,34 +538,34 @@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ - -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \ - -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \ - -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ - -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \ - -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \ - -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \ - -e 's|@''GNULIB_GRANTPT''@|$(GNULIB_GRANTPT)|g' \ - -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \ - -e 's|@''GNULIB_MBTOWC''@|$(GNULIB_MBTOWC)|g' \ - -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \ - -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \ - -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \ - -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \ - -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \ - -e 's|@''GNULIB_PTSNAME''@|$(GNULIB_PTSNAME)|g' \ - -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \ - -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \ - -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \ - -e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \ - -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \ - -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \ - -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \ - -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \ - -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \ - -e 's|@''GNULIB_SYSTEM_POSIX''@|$(GNULIB_SYSTEM_POSIX)|g' \ - -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \ - -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ - -e 's|@''GNULIB_WCTOMB''@|$(GNULIB_WCTOMB)|g' \ + -e 's/@''GNULIB__EXIT''@/$(GNULIB__EXIT)/g' \ + -e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \ + -e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \ + -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \ + -e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \ + -e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \ + -e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \ + -e 's/@''GNULIB_MALLOC_POSIX''@/$(GNULIB_MALLOC_POSIX)/g' \ + -e 's/@''GNULIB_MBTOWC''@/$(GNULIB_MBTOWC)/g' \ + -e 's/@''GNULIB_MKDTEMP''@/$(GNULIB_MKDTEMP)/g' \ + -e 's/@''GNULIB_MKOSTEMP''@/$(GNULIB_MKOSTEMP)/g' \ + -e 's/@''GNULIB_MKOSTEMPS''@/$(GNULIB_MKOSTEMPS)/g' \ + -e 's/@''GNULIB_MKSTEMP''@/$(GNULIB_MKSTEMP)/g' \ + -e 's/@''GNULIB_MKSTEMPS''@/$(GNULIB_MKSTEMPS)/g' \ + -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \ + -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \ + -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \ + -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \ + -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \ + -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \ + -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \ + -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \ + -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \ + -e 's/@''GNULIB_STRTOULL''@/$(GNULIB_STRTOULL)/g' \ + -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GNULIB_SYSTEM_POSIX)/g' \ + -e 's/@''GNULIB_UNLOCKPT''@/$(GNULIB_UNLOCKPT)/g' \ + -e 's/@''GNULIB_UNSETENV''@/$(GNULIB_UNSETENV)/g' \ + -e 's/@''GNULIB_WCTOMB''@/$(GNULIB_WCTOMB)/g' \ < $(srcdir)/stdlib.in.h | \ sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ @@ -667,18 +667,18 @@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ - -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \ - -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \ - -e 's|@''GNULIB_FUTIMENS''@|$(GNULIB_FUTIMENS)|g' \ - -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \ - -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \ - -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \ - -e 's|@''GNULIB_MKFIFO''@|$(GNULIB_MKFIFO)|g' \ - -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \ - -e 's|@''GNULIB_MKNOD''@|$(GNULIB_MKNOD)|g' \ - -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \ - -e 's|@''GNULIB_STAT''@|$(GNULIB_STAT)|g' \ - -e 's|@''GNULIB_UTIMENSAT''@|$(GNULIB_UTIMENSAT)|g' \ + -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \ + -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \ + -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \ + -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \ + -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \ + -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \ + -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \ + -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \ + -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \ + -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \ + -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \ + -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \ -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \ @@ -726,11 +726,11 @@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ - -e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \ - -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \ - -e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \ - -e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \ - -e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \ + -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ + -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ + -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \ + -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ + -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ @@ -778,50 +778,50 @@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ - -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ - -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ - -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \ - -e 's|@''GNULIB_DUP3''@|$(GNULIB_DUP3)|g' \ - -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \ - -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \ - -e 's|@''GNULIB_FACCESSAT''@|$(GNULIB_FACCESSAT)|g' \ - -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \ - -e 's|@''GNULIB_FCHOWNAT''@|$(GNULIB_FCHOWNAT)|g' \ - -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \ - -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ - -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ - -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \ - -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \ - -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \ - -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \ - -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \ - -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ - -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \ - -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \ - -e 's|@''GNULIB_GROUP_MEMBER''@|$(GNULIB_GROUP_MEMBER)|g' \ - -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ - -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \ - -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \ - -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ - -e 's|@''GNULIB_PIPE''@|$(GNULIB_PIPE)|g' \ - -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ - -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \ - -e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|g' \ - -e 's|@''GNULIB_READ''@|$(GNULIB_READ)|g' \ - -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ - -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ - -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \ - -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ - -e 's|@''GNULIB_SYMLINK''@|$(GNULIB_SYMLINK)|g' \ - -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \ - -e 's|@''GNULIB_TTYNAME_R''@|$(GNULIB_TTYNAME_R)|g' \ - -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \ - -e 's|@''GNULIB_UNISTD_H_NONBLOCKING''@|$(GNULIB_UNISTD_H_NONBLOCKING)|g' \ - -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \ - -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \ - -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \ - -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \ - -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \ + -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \ + -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ + -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \ + -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \ + -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \ + -e 's/@''GNULIB_EUIDACCESS''@/$(GNULIB_EUIDACCESS)/g' \ + -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \ + -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \ + -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \ + -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \ + -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \ + -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \ + -e 's/@''GNULIB_GETDOMAINNAME''@/$(GNULIB_GETDOMAINNAME)/g' \ + -e 's/@''GNULIB_GETDTABLESIZE''@/$(GNULIB_GETDTABLESIZE)/g' \ + -e 's/@''GNULIB_GETGROUPS''@/$(GNULIB_GETGROUPS)/g' \ + -e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \ + -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \ + -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \ + -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \ + -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \ + -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \ + -e 's/@''GNULIB_LCHOWN''@/$(GNULIB_LCHOWN)/g' \ + -e 's/@''GNULIB_LINK''@/$(GNULIB_LINK)/g' \ + -e 's/@''GNULIB_LINKAT''@/$(GNULIB_LINKAT)/g' \ + -e 's/@''GNULIB_LSEEK''@/$(GNULIB_LSEEK)/g' \ + -e 's/@''GNULIB_PIPE''@/$(GNULIB_PIPE)/g' \ + -e 's/@''GNULIB_PIPE2''@/$(GNULIB_PIPE2)/g' \ + -e 's/@''GNULIB_PREAD''@/$(GNULIB_PREAD)/g' \ + -e 's/@''GNULIB_PWRITE''@/$(GNULIB_PWRITE)/g' \ + -e 's/@''GNULIB_READ''@/$(GNULIB_READ)/g' \ + -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \ + -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \ + -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \ + -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \ + -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \ + -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \ + -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \ + -e 's/@''GNULIB_UNISTD_H_GETOPT''@/$(GNULIB_UNISTD_H_GETOPT)/g' \ + -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \ + -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' \ + -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \ + -e 's/@''GNULIB_UNLINKAT''@/$(GNULIB_UNLINKAT)/g' \ + -e 's/@''GNULIB_USLEEP''@/$(GNULIB_USLEEP)/g' \ + -e 's/@''GNULIB_WRITE''@/$(GNULIB_WRITE)/g' \ < $(srcdir)/unistd.in.h | \ sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ === modified file 'm4/gnulib-common.m4' --- m4/gnulib-common.m4 2011-06-06 19:53:44 +0000 +++ m4/gnulib-common.m4 2011-06-08 16:26:45 +0000 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 25 +# gnulib-common.m4 serial 26 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -61,16 +61,49 @@ # expands to a C preprocessor expression that evaluates to 1 or 0, depending # whether a gnulib module that has been requested shall be considered present # or not. -AC_DEFUN([gl_MODULE_INDICATOR_CONDITION], [1]) +m4_define([gl_MODULE_INDICATOR_CONDITION], [1]) # gl_MODULE_INDICATOR_SET_VARIABLE([modulename]) # sets the shell variable that indicates the presence of the given module to # a C preprocessor expression that will evaluate to 1. AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], [ - GNULIB_[]m4_translit([[$1]], - [abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=gl_MODULE_INDICATOR_CONDITION + gl_MODULE_INDICATOR_SET_VARIABLE_AUX( + [GNULIB_[]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], + [gl_MODULE_INDICATOR_CONDITION]) +]) + +# gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable]) +# modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION. +# The shell variable's value is a C preprocessor expression that evaluates +# to 0 or 1. +AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX], +[ + m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1], + [ + dnl Simplify the expression VALUE || 1 to 1. + $1=1 + ], + [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1], + [gl_MODULE_INDICATOR_CONDITION])]) +]) + +# gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition]) +# modifies the shell variable to include the given condition. The shell +# variable's value is a C preprocessor expression that evaluates to 0 or 1. +AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR], +[ + dnl Simplify the expression 1 || CONDITION to 1. + if test "$[]$1" != 1; then + dnl Simplify the expression 0 || CONDITION to CONDITION. + if test "$[]$1" = 0; then + $1=$2 + else + $1="($[]$1 || $2)" + fi + fi ]) # gl_MODULE_INDICATOR([modulename]) ------------------------------------------------------------ revno: 104538 committer: martin rudalics branch nick: trunk timestamp: Wed 2011-06-08 15:00:51 +0200 message: New symbols in window.c. * window.c: (WINDOW_TOTAL_SIZE, MIN_SAFE_WINDOW_WIDTH) (MIN_SAFE_WINDOW_HEIGHT): Really remove them from window.c. (syms_of_window): New Lisp objects Qrecord_window_buffer, Qwindow_deletable_p, Qdelete_window, Qreplace_buffer_in_windows, Qget_mru_window, Qresize_root_window, Qresize_root_window_vertically, Qsafe, Qabove, Qbelow, Qauto_buffer_name; staticpro them. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-08 08:35:20 +0000 +++ src/ChangeLog 2011-06-08 13:00:51 +0000 @@ -4,7 +4,7 @@ normal_lines, normal_cols, new_total, new_normal, clone_number, splits, nest, prev_buffers, next_buffers. (WINDOW_TOTAL_SIZE): Move here from window.c. - (MIN_SAFE_WINDOW_WIDTH, MIN_SAFE_WINDOW_HEIGHT): Define. + (MIN_SAFE_WINDOW_WIDTH, MIN_SAFE_WINDOW_HEIGHT): Define here. * window.c (Fwindow_height, Fwindow_width, Fwindow_full_width_p): Remove. @@ -28,7 +28,13 @@ (Fset_window_configuration, saved_window) (Fcurrent_window_configuration, save_window_save): Handle new members of window structure. - (WINDOW_TOTAL_SIZE): Move to window.h. + (WINDOW_TOTAL_SIZE, MIN_SAFE_WINDOW_WIDTH) + (MIN_SAFE_WINDOW_HEIGHT): Move to window.h. + (syms_of_window): New Lisp objects Qrecord_window_buffer, + Qwindow_deletable_p, Qdelete_window, Qreplace_buffer_in_windows, + Qget_mru_window, Qresize_root_window, + Qresize_root_window_vertically, Qsafe, Qabove, Qbelow, + Qauto_buffer_name; staticpro them. 2011-06-07 Martin Rudalics === modified file 'src/window.c' --- src/window.c 2011-06-08 08:35:20 +0000 +++ src/window.c 2011-06-08 13:00:51 +0000 @@ -51,9 +51,14 @@ #endif Lisp_Object Qwindowp, Qwindow_live_p; -static Lisp_Object Qwindow_configuration_p; -static Lisp_Object Qdisplay_buffer; +static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer; +static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; +static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; +static Lisp_Object Qresize_root_window, Qresize_root_window_vertically; static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; +static Lisp_Object Qsafe, Qabove, Qbelow; +static Lisp_Object Qauto_buffer_name; + static Lisp_Object Qwindow_size_fixed; static int displayed_window_lines (struct window *); @@ -2941,18 +2946,6 @@ /* Set the height of WINDOW and all its inferiors. */ -/* The smallest acceptable dimensions for a window. Anything smaller - might crash Emacs. */ - -#define MIN_SAFE_WINDOW_WIDTH (2) -#define MIN_SAFE_WINDOW_HEIGHT (1) - -/* For wp non-zero the total number of columns of window w. Otherwise - the total number of lines of w. */ - -#define WINDOW_TOTAL_SIZE(w, wp) \ - (wp ? WINDOW_TOTAL_COLS (w) : WINDOW_TOTAL_LINES (w)) - /* If *ROWS or *COLS are too small a size for FRAME, set them to the minimum allowable size. */ @@ -7406,12 +7399,45 @@ Qwindow_live_p = intern_c_string ("window-live-p"); staticpro (&Qwindow_live_p); + Qwindow_deletable_p = intern_c_string ("window-deletable-p"); + staticpro (&Qwindow_deletable_p); + + Qdelete_window = intern_c_string ("delete-window"); + staticpro (&Qdelete_window); + + Qresize_root_window = intern_c_string ("resize-root-window"); + staticpro (&Qresize_root_window); + + Qresize_root_window_vertically = intern_c_string ("resize-root-window-vertically"); + staticpro (&Qresize_root_window_vertically); + + Qsafe = intern_c_string ("safe"); + staticpro (&Qsafe); + Qdisplay_buffer = intern_c_string ("display-buffer"); staticpro (&Qdisplay_buffer); + Qreplace_buffer_in_windows = intern_c_string ("replace-buffer-in-windows"); + staticpro (&Qreplace_buffer_in_windows); + + Qrecord_window_buffer = intern_c_string ("record-window-buffer"); + staticpro (&Qrecord_window_buffer); + + Qget_mru_window = intern_c_string ("get-mru-window"); + staticpro (&Qget_mru_window); + Qtemp_buffer_show_hook = intern_c_string ("temp-buffer-show-hook"); staticpro (&Qtemp_buffer_show_hook); + Qabove = intern_c_string ("above"); + staticpro (&Qabove); + + Qbelow = intern_c_string ("below"); + staticpro (&Qbelow); + + Qauto_buffer_name = intern_c_string ("auto-buffer-name"); + staticpro (&Qauto_buffer_name); + staticpro (&Vwindow_list); minibuf_selected_window = Qnil; ------------------------------------------------------------ revno: 104537 committer: martin rudalics branch nick: trunk timestamp: Wed 2011-06-08 11:13:43 +0200 message: A few new functions and rewrites in window.el. * window.el (one-window-p): Move down in code. Rewrite doc-string. (window-current-scroll-bars): Rewrite doc-string. Normalize live window argument. (walk-windows, get-window-with-predicate, count-windows): Rewrite doc-string. Use window-list-1. (window-in-direction-2, window-in-direction, get-mru-window): New functions. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-08 07:17:26 +0000 +++ lisp/ChangeLog 2011-06-08 09:13:43 +0000 @@ -1,3 +1,14 @@ +2011-06-08 Martin Rudalics + + * window.el (one-window-p): Move down in code. Rewrite + doc-string. + (window-current-scroll-bars): Rewrite doc-string. Normalize + live window argument. + (walk-windows, get-window-with-predicate, count-windows): + Rewrite doc-string. Use window-list-1. + (window-in-direction-2, window-in-direction, get-mru-window): + New functions. + 2011-06-08 Reuben Thomas * progmodes/flymake.el (flymake-compilation-prevents-syntax-check): === modified file 'lisp/window.el' --- lisp/window.el 2011-06-08 05:40:45 +0000 +++ lisp/window.el 2011-06-08 09:13:43 +0000 @@ -957,28 +957,9 @@ ;; Eventually we should make `window-height' obsolete. (defalias 'window-width 'window-body-width) -(defun one-window-p (&optional nomini all-frames) - "Return non-nil if the selected window is the only window. -Optional arg NOMINI non-nil means don't count the minibuffer -even if it is active. Otherwise, the minibuffer is counted -when it is active. - -The optional arg ALL-FRAMES t means count windows on all frames. -If it is `visible', count windows on all visible frames on the -current terminal. ALL-FRAMES nil or omitted means count only the -selected frame, plus the minibuffer it uses (which may be on -another frame). ALL-FRAMES 0 means count all windows in all -visible or iconified frames on the current terminal. If -ALL-FRAMES is anything else, count only the selected frame." - (let ((base-window (selected-window))) - (if (and nomini (eq base-window (minibuffer-window))) - (setq base-window (next-window base-window))) - (eq base-window - (next-window base-window (if nomini 'arg) all-frames)))) - (defun window-current-scroll-bars (&optional window) "Return the current scroll bar settings for WINDOW. -WINDOW defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. The return value is a cons cell (VERTICAL . HORIZONTAL) where VERTICAL specifies the current location of the vertical scroll @@ -989,11 +970,11 @@ Unlike `window-scroll-bars', this function reports the scroll bar type actually used, once frame defaults and `scroll-bar-mode' are taken into account." + (setq window (normalize-live-window window)) (let ((vert (nth 2 (window-scroll-bars window))) (hor nil)) (when (or (eq vert t) (eq hor t)) - (let ((fcsb (frame-current-scroll-bars - (window-frame (or window (selected-window)))))) + (let ((fcsb (frame-current-scroll-bars (window-frame window)))) (if (eq vert t) (setq vert (car fcsb))) (if (eq hor t) @@ -1001,10 +982,10 @@ (cons vert hor))) (defun walk-windows (proc &optional minibuf all-frames) - "Cycle through all windows, calling PROC for each one. + "Cycle through all live windows, calling PROC for each one. PROC must specify a function with a window as its sole argument. The optional arguments MINIBUF and ALL-FRAMES specify the set of -windows to include in the walk, see also `next-window'. +windows to include in the walk. MINIBUF t means include the minibuffer window even if the minibuffer is not active. MINIBUF nil or omitted means include @@ -1012,29 +993,24 @@ other value means do not include the minibuffer window even if the minibuffer is active. -Several frames may share a single minibuffer; if the minibuffer -is active, all windows on all frames that share that minibuffer -are included too. Therefore, if you are using a separate -minibuffer frame and the minibuffer is active and MINIBUF says it -counts, `walk-windows' includes the windows in the frame from -which you entered the minibuffer, as well as the minibuffer -window. - -ALL-FRAMES nil or omitted means cycle through all windows on the - selected frame, plus the minibuffer window if specified by the - MINIBUF argument, see above. If the minibuffer counts, cycle - through all windows on all frames that share that minibuffer - too. -ALL-FRAMES t means cycle through all windows on all existing - frames. -ALL-FRAMES `visible' means cycle through all windows on all - visible frames on the current terminal. -ALL-FRAMES 0 means cycle through all windows on all visible and - iconified frames on the current terminal. -ALL-FRAMES a frame means cycle through all windows on that frame - only. -Anything else means cycle through all windows on the selected - frame and no others. +ALL-FRAMES nil or omitted means consider all windows on the +selected frame, plus the minibuffer window if specified by the +MINIBUF argument. If the minibuffer counts, consider all windows +on all frames that share that minibuffer too. The following +non-nil values of ALL-FRAMES have special meanings: + +- t means consider all windows on all existing frames. + +- `visible' means consider all windows on all visible frames on + the current terminal. + +- 0 (the number zero) means consider all windows on all visible + and iconified frames on the current terminal. + +- A frame means consider all windows on that frame only. + +Anything else means consider all windows on the selected frame +and no others. This function changes neither the order of recently selected windows nor the buffer list." @@ -1048,33 +1024,146 @@ (save-selected-window (when (framep all-frames) (select-window (frame-first-window all-frames) 'norecord)) - (let* (walk-windows-already-seen - (walk-windows-current (selected-window))) - (while (progn - (setq walk-windows-current - (next-window walk-windows-current minibuf all-frames)) - (not (memq walk-windows-current walk-windows-already-seen))) - (setq walk-windows-already-seen - (cons walk-windows-current walk-windows-already-seen)) - (funcall proc walk-windows-current))))) + (dolist (walk-windows-window (window-list-1 nil minibuf all-frames)) + (funcall proc walk-windows-window)))) + +(defun window-in-direction-2 (window posn &optional horizontal) + "Support function for `window-in-direction'." + (if horizontal + (let ((top (window-top-line window))) + (if (> top posn) + (- top posn) + (- posn top (window-total-height window)))) + (let ((left (window-left-column window))) + (if (> left posn) + (- left posn) + (- posn left (window-total-width window)))))) + +(defun window-in-direction (direction &optional window ignore) + "Return window in DIRECTION as seen from WINDOW. +DIRECTION must be one of `above', `below', `left' or `right'. +WINDOW must be a live window and defaults to the selected one. +IGNORE, when non-nil means a window can be returned even if its +`no-other-window' parameter is non-nil." + (setq window (normalize-live-window window)) + (unless (memq direction '(above below left right)) + (error "Wrong direction %s" direction)) + (let* ((frame (window-frame window)) + (hor (memq direction '(left right))) + (first (if hor + (window-left-column window) + (window-top-line window))) + (last (+ first (if hor + (window-total-width window) + (window-total-height window)))) + (posn-cons (nth 6 (posn-at-point (window-point window) window))) + ;; The column / row value of `posn-at-point' can be nil for the + ;; mini-window, guard against that. + (posn (if hor + (+ (or (cdr posn-cons) 1) (window-top-line window)) + (+ (or (car posn-cons) 1) (window-left-column window)))) + (best-edge + (cond + ((eq direction 'below) (frame-height frame)) + ((eq direction 'right) (frame-width frame)) + (t -1))) + (best-edge-2 best-edge) + (best-diff-2 (if hor (frame-height frame) (frame-width frame))) + best best-2 best-diff-2-new) + (walk-window-tree + (lambda (w) + (let* ((w-top (window-top-line w)) + (w-left (window-left-column w))) + (cond + ((or (eq window w) + ;; Ignore ourselves. + (and (window-parameter w 'no-other-window) + ;; Ignore W unless IGNORE is non-nil. + (not ignore)))) + (hor + (cond + ((and (<= w-top posn) + (< posn (+ w-top (window-total-height w)))) + ;; W is to the left or right of WINDOW and covers POSN. + (when (or (and (eq direction 'left) + (<= w-left first) (> w-left best-edge)) + (and (eq direction 'right) + (>= w-left last) (< w-left best-edge))) + (setq best-edge w-left) + (setq best w))) + ((and (or (and (eq direction 'left) + (<= (+ w-left (window-total-width w)) first)) + (and (eq direction 'right) (<= last w-left))) + ;; W is to the left or right of WINDOW but does not + ;; cover POSN. + (setq best-diff-2-new + (window-in-direction-2 w posn hor)) + (or (< best-diff-2-new best-diff-2) + (and (= best-diff-2-new best-diff-2) + (if (eq direction 'left) + (> w-left best-edge-2) + (< w-left best-edge-2))))) + (setq best-edge-2 w-left) + (setq best-diff-2 best-diff-2-new) + (setq best-2 w)))) + (t + (cond + ((and (<= w-left posn) + (< posn (+ w-left (window-total-width w)))) + ;; W is above or below WINDOW and covers POSN. + (when (or (and (eq direction 'above) + (<= w-top first) (> w-top best-edge)) + (and (eq direction 'below) + (>= w-top first) (< w-top best-edge))) + (setq best-edge w-top) + (setq best w))) + ((and (or (and (eq direction 'above) + (<= (+ w-top (window-total-height w)) first)) + (and (eq direction 'below) (<= last w-top))) + ;; W is above or below WINDOW but does not cover POSN. + (setq best-diff-2-new + (window-in-direction-2 w posn hor)) + (or (< best-diff-2-new best-diff-2) + (and (= best-diff-2-new best-diff-2) + (if (eq direction 'above) + (> w-top best-edge-2) + (< w-top best-edge-2))))) + (setq best-edge-2 w-top) + (setq best-diff-2 best-diff-2-new) + (setq best-2 w))))))) + (window-frame window)) + (or best best-2))) (defun get-window-with-predicate (predicate &optional minibuf all-frames default) - "Return a window satisfying PREDICATE. -More precisely, cycle through all windows using `walk-windows', -calling the function PREDICATE on each one of them with the -window as its sole argument. Return the first window for which -PREDICATE returns non-nil. If no window satisfies PREDICATE, -return DEFAULT. - -The optional arguments MINIBUF and ALL-FRAMES specify the set of -windows to include. See `walk-windows' for the meaning of these -arguments." + "Return a live window satisfying PREDICATE. +More precisely, cycle through all windows calling the function +PREDICATE on each one of them with the window as its sole +argument. Return the first window for which PREDICATE returns +non-nil. If no window satisfies PREDICATE, return DEFAULT. + +ALL-FRAMES nil or omitted means consider all windows on the selected +frame, plus the minibuffer window if specified by the MINIBUF +argument. If the minibuffer counts, consider all windows on all +frames that share that minibuffer too. The following non-nil +values of ALL-FRAMES have special meanings: + +- t means consider all windows on all existing frames. + +- `visible' means consider all windows on all visible frames on + the current terminal. + +- 0 (the number zero) means consider all windows on all visible + and iconified frames on the current terminal. + +- A frame means consider all windows on that frame only. + +Anything else means consider all windows on the selected frame +and no others." (catch 'found - (walk-windows #'(lambda (window) - (when (funcall predicate window) - (throw 'found window))) - minibuf all-frames) + (dolist (window (window-list-1 nil minibuf all-frames)) + (when (funcall predicate window) + (throw 'found window))) default)) (defalias 'some-window 'get-window-with-predicate) @@ -1115,6 +1204,33 @@ (setq best-window window))))) (or best-window second-best-window))) +(defun get-mru-window (&optional all-frames) + "Return the most recently used window on frames specified by ALL-FRAMES. +Do not return a minibuffer window. + +The following non-nil values of the optional argument ALL-FRAMES +have special meanings: + +- t means consider all windows on all existing frames. + +- `visible' means consider all windows on all visible frames on + the current terminal. + +- 0 (the number zero) means consider all windows on all visible + and iconified frames on the current terminal. + +- A frame means consider all windows on that frame only. + +Any other value of ALL-FRAMES means consider all windows on the +selected frame and no others." + (let (best-window best-time time) + (dolist (window (window-list-1 nil nil all-frames)) + (setq time (window-use-time window)) + (when (or (not best-time) (> time best-time)) + (setq best-time time) + (setq best-window window))) + best-window)) + (defun get-largest-window (&optional all-frames dedicated) "Return the largest window on frames specified by ALL-FRAMES. A minibuffer window is never a candidate. A dedicated window is @@ -1189,16 +1305,47 @@ (defun minibuffer-window-active-p (window) "Return t if WINDOW is the currently active minibuffer window." (eq window (active-minibuffer-window))) - + (defun count-windows (&optional minibuf) - "Return the number of visible windows. + "Return the number of live windows on the selected frame. The optional argument MINIBUF specifies whether the minibuffer window shall be counted. See `walk-windows' for the precise meaning of this argument." - (let ((count 0)) - (walk-windows (lambda (_w) (setq count (+ count 1))) - minibuf) - count)) + (length (window-list-1 nil minibuf))) + +;; This should probably return non-nil when the selected window is part +;; of an atomic window whose root is the frame's root window. +(defun one-window-p (&optional nomini all-frames) + "Return non-nil if the selected window is the only window. +Optional arg NOMINI non-nil means don't count the minibuffer +even if it is active. Otherwise, the minibuffer is counted +when it is active. + +Optional argument ALL-FRAMES specifies the set of frames to +consider, see also `next-window'. ALL-FRAMES nil or omitted +means consider windows on the selected frame only, plus the +minibuffer window if specified by the NOMINI argument. If the +minibuffer counts, consider all windows on all frames that share +that minibuffer too. The remaining non-nil values of ALL-FRAMES +with a special meaning are: + +- t means consider all windows on all existing frames. + +- `visible' means consider all windows on all visible frames on + the current terminal. + +- 0 (the number zero) means consider all windows on all visible + and iconified frames on the current terminal. + +- A frame means consider all windows on that frame only. + +Anything else means consider all windows on the selected frame +and no others." + (let ((base-window (selected-window))) + (if (and nomini (eq base-window (minibuffer-window))) + (setq base-window (next-window base-window))) + (eq base-window + (next-window base-window (if nomini 'arg) all-frames)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; `balance-windows' subroutines using `window-tree' ------------------------------------------------------------ revno: 104536 committer: martin rudalics branch nick: trunk timestamp: Wed 2011-06-08 10:35:20 +0200 message: Add some new members to window structure in window.h. * window.h (window): Add some new members to window structure - normal_lines, normal_cols, new_total, new_normal, clone_number, splits, nest, prev_buffers, next_buffers. (WINDOW_TOTAL_SIZE): Move here from window.c. (MIN_SAFE_WINDOW_WIDTH, MIN_SAFE_WINDOW_HEIGHT): Define. * window.c (WINDOW_TOTAL_SIZE): Move to window.h. (make_dummy_parent): Set new members of windows structure. (make_window): Move down in code. Handle new members of window structure. (Fwindow_clone_number, Fwindow_splits, Fset_window_splits) (Fwindow_nest, Fset_window_nest, Fwindow_new_total) (Fwindow_normal_size, Fwindow_new_normal, Fwindow_prev_buffers) (Fset_window_prev_buffers, Fwindow_next_buffers) (Fset_window_next_buffers, Fset_window_clone_number): New functions. (Fwindow_hscroll, Fwindow_at, Fwindow_point, Fwindow_start) (Fwindow_end, Fwindow_line_height, Fset_window_dedicated_p): Doc-string fixes. (Fwindow_parameters, Fwindow_parameter, Fset_window_parameter): Argument WINDOW can be now internal window too. (Fwindow_use_time): Move up in code. (Fget_buffer_window): Rename argument FRAME to ALL-FRAMES. Rewrite doc-string. (Fset_window_configuration, saved_window) (Fcurrent_window_configuration, save_window_save): Handle new members of window structure. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-06-08 05:40:45 +0000 +++ src/ChangeLog 2011-06-08 08:35:20 +0000 @@ -1,7 +1,34 @@ 2011-06-08 Martin Rudalics + * window.h (window): Add some new members to window structure - + normal_lines, normal_cols, new_total, new_normal, clone_number, + splits, nest, prev_buffers, next_buffers. + (WINDOW_TOTAL_SIZE): Move here from window.c. + (MIN_SAFE_WINDOW_WIDTH, MIN_SAFE_WINDOW_HEIGHT): Define. + * window.c (Fwindow_height, Fwindow_width, Fwindow_full_width_p): Remove. + (make_dummy_parent): Set new members of windows structure. + (make_window): Move down in code. Handle new members of window + structure. + (Fwindow_clone_number, Fwindow_splits, Fset_window_splits) + (Fwindow_nest, Fset_window_nest, Fwindow_new_total) + (Fwindow_normal_size, Fwindow_new_normal, Fwindow_prev_buffers) + (Fset_window_prev_buffers, Fwindow_next_buffers) + (Fset_window_next_buffers, Fset_window_clone_number): New + functions. + (Fwindow_hscroll, Fwindow_at, Fwindow_point, Fwindow_start) + (Fwindow_end, Fwindow_line_height, Fset_window_dedicated_p): + Doc-string fixes. + (Fwindow_parameters, Fwindow_parameter, Fset_window_parameter): + Argument WINDOW can be now internal window too. + (Fwindow_use_time): Move up in code. + (Fget_buffer_window): Rename argument FRAME to ALL-FRAMES. + Rewrite doc-string. + (Fset_window_configuration, saved_window) + (Fcurrent_window_configuration, save_window_save): Handle new + members of window structure. + (WINDOW_TOTAL_SIZE): Move to window.h. 2011-06-07 Martin Rudalics === modified file 'src/window.c' --- src/window.c 2011-06-08 05:40:45 +0000 +++ src/window.c 2011-06-08 08:35:20 +0000 @@ -410,6 +410,14 @@ return select_window (window, norecord, 0); } +DEFUN ("window-clone-number", Fwindow_clone_number, Swindow_clone_number, 0, 1, 0, + doc: /* Return WINDOW's clone number. +WINDOW can be any window and defaults to the selected one. */) + (Lisp_Object window) +{ + return decode_any_window (window)->clone_number; +} + DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, doc: /* Return the buffer that WINDOW is displaying. WINDOW can be any window and defaults to the selected one. @@ -463,233 +471,80 @@ { return decode_any_window (window)->prev; } - -Lisp_Object -make_window (void) -{ - Lisp_Object val; - register struct window *p; - - p = allocate_window (); - ++sequence_number; - XSETFASTINT (p->sequence_number, sequence_number); - XSETFASTINT (p->left_col, 0); - XSETFASTINT (p->top_line, 0); - XSETFASTINT (p->total_lines, 0); - XSETFASTINT (p->total_cols, 0); - XSETFASTINT (p->hscroll, 0); - XSETFASTINT (p->min_hscroll, 0); - p->orig_top_line = p->orig_total_lines = Qnil; - p->start = Fmake_marker (); - p->pointm = Fmake_marker (); - XSETFASTINT (p->use_time, 0); - p->frame = Qnil; - p->display_table = Qnil; - p->dedicated = Qnil; - p->window_parameters = Qnil; - p->pseudo_window_p = 0; - memset (&p->cursor, 0, sizeof (p->cursor)); - memset (&p->last_cursor, 0, sizeof (p->last_cursor)); - memset (&p->phys_cursor, 0, sizeof (p->phys_cursor)); - p->desired_matrix = p->current_matrix = 0; - p->nrows_scale_factor = p->ncols_scale_factor = 1; - p->phys_cursor_type = -1; - p->phys_cursor_width = -1; - p->must_be_updated_p = 0; - XSETFASTINT (p->window_end_vpos, 0); - XSETFASTINT (p->window_end_pos, 0); - p->window_end_valid = Qnil; - p->vscroll = 0; - XSETWINDOW (val, p); - XSETFASTINT (p->last_point, 0); - p->frozen_window_start_p = 0; - p->last_cursor_off_p = p->cursor_off_p = 0; - p->left_margin_cols = Qnil; - p->right_margin_cols = Qnil; - p->left_fringe_width = Qnil; - p->right_fringe_width = Qnil; - p->fringes_outside_margins = Qnil; - p->scroll_bar_width = Qnil; - p->vertical_scroll_bar_type = Qt; - p->resize_proportionally = Qnil; - - Vwindow_list = Qnil; - return val; -} - -DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, - Spos_visible_in_window_p, 0, 3, 0, - doc: /* Return non-nil if position POS is currently on the frame in WINDOW. -Return nil if that position is scrolled vertically out of view. -If a character is only partially visible, nil is returned, unless the -optional argument PARTIALLY is non-nil. -If POS is only out of view because of horizontal scrolling, return non-nil. -If POS is t, it specifies the position of the last visible glyph in WINDOW. -POS defaults to point in WINDOW; WINDOW defaults to the selected window. - -If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, -return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), -where X and Y are the pixel coordinates relative to the top left corner -of the window. The remaining elements are omitted if the character after -POS is fully visible; otherwise, RTOP and RBOT are the number of pixels -off-window at the top and bottom of the row, ROWH is the height of the -display row, and VPOS is the row number (0-based) containing POS. */) - (Lisp_Object pos, Lisp_Object window, Lisp_Object partially) -{ - register struct window *w; - register EMACS_INT posint; - register struct buffer *buf; - struct text_pos top; - Lisp_Object in_window = Qnil; - int rtop, rbot, rowh, vpos, fully_p = 1; - int x, y; - - w = decode_window (window); - buf = XBUFFER (w->buffer); - SET_TEXT_POS_FROM_MARKER (top, w->start); - - if (EQ (pos, Qt)) - posint = -1; - else if (!NILP (pos)) - { - CHECK_NUMBER_COERCE_MARKER (pos); - posint = XINT (pos); - } - else if (w == XWINDOW (selected_window)) - posint = PT; - else - posint = XMARKER (w->pointm)->charpos; - - /* If position is above window start or outside buffer boundaries, - or if window start is out of range, position is not visible. */ - if ((EQ (pos, Qt) - || (posint >= CHARPOS (top) && posint <= BUF_ZV (buf))) - && CHARPOS (top) >= BUF_BEGV (buf) - && CHARPOS (top) <= BUF_ZV (buf) - && pos_visible_p (w, posint, &x, &y, &rtop, &rbot, &rowh, &vpos) - && (fully_p = !rtop && !rbot, (!NILP (partially) || fully_p))) - in_window = Qt; - - if (!NILP (in_window) && !NILP (partially)) - { - Lisp_Object part = Qnil; - if (!fully_p) - part = list4 (make_number (rtop), make_number (rbot), - make_number (rowh), make_number (vpos)); - in_window = Fcons (make_number (x), - Fcons (make_number (y), part)); - } - - return in_window; -} - -DEFUN ("window-line-height", Fwindow_line_height, - Swindow_line_height, 0, 2, 0, - doc: /* Return height in pixels of text line LINE in window WINDOW. -If WINDOW is nil or omitted, use selected window. - -Return height of current line if LINE is omitted or nil. Return height of -header or mode line if LINE is `header-line' and `mode-line'. -Otherwise, LINE is a text line number starting from 0. A negative number -counts from the end of the window. - -Value is a list (HEIGHT VPOS YPOS OFFBOT), where HEIGHT is the height -in pixels of the visible part of the line, VPOS and YPOS are the -vertical position in lines and pixels of the line, relative to the top -of the first text line, and OFFBOT is the number of off-window pixels at -the bottom of the text line. If there are off-window pixels at the top -of the (first) text line, YPOS is negative. - -Return nil if window display is not up-to-date. In that case, use -`pos-visible-in-window-p' to obtain the information. */) - (Lisp_Object line, Lisp_Object window) -{ - register struct window *w; - register struct buffer *b; - struct glyph_row *row, *end_row; - int max_y, crop, i, n; - - w = decode_window (window); - - if (noninteractive - || w->pseudo_window_p) - return Qnil; - - CHECK_BUFFER (w->buffer); - b = XBUFFER (w->buffer); - - /* Fail if current matrix is not up-to-date. */ - if (NILP (w->window_end_valid) - || current_buffer->clip_changed - || current_buffer->prevent_redisplay_optimizations_p - || XFASTINT (w->last_modified) < BUF_MODIFF (b) - || XFASTINT (w->last_overlay_modified) < BUF_OVERLAY_MODIFF (b)) - return Qnil; - - if (NILP (line)) - { - i = w->cursor.vpos; - if (i < 0 || i >= w->current_matrix->nrows - || (row = MATRIX_ROW (w->current_matrix, i), !row->enabled_p)) - return Qnil; - max_y = window_text_bottom_y (w); - goto found_row; - } - - if (EQ (line, Qheader_line)) - { - if (!WINDOW_WANTS_HEADER_LINE_P (w)) - return Qnil; - row = MATRIX_HEADER_LINE_ROW (w->current_matrix); - if (!row->enabled_p) - return Qnil; - return list4 (make_number (row->height), - make_number (0), make_number (0), - make_number (0)); - } - - if (EQ (line, Qmode_line)) - { - row = MATRIX_MODE_LINE_ROW (w->current_matrix); - if (!row->enabled_p) - return Qnil; - return list4 (make_number (row->height), - make_number (0), /* not accurate */ - make_number (WINDOW_HEADER_LINE_HEIGHT (w) - + window_text_bottom_y (w)), - make_number (0)); - } - - CHECK_NUMBER (line); - n = XINT (line); - - row = MATRIX_FIRST_TEXT_ROW (w->current_matrix); - end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w); - max_y = window_text_bottom_y (w); - i = 0; - - while ((n < 0 || i < n) - && row <= end_row && row->enabled_p - && row->y + row->height < max_y) - row++, i++; - - if (row > end_row || !row->enabled_p) - return Qnil; - - if (++n < 0) - { - if (-n > i) - return Qnil; - row += n; - i += n; - } - - found_row: - crop = max (0, (row->y + row->height) - max_y); - return list4 (make_number (row->height + min (0, row->y) - crop), - make_number (i), - make_number (row->y), - make_number (crop)); + +DEFUN ("window-splits", Fwindow_splits, Swindow_splits, 0, 1, 0, + doc: /* Return splits status for WINDOW. +WINDOW can be any window and defaults to the selected one. + +If the value returned by this function is nil and WINDOW is resized, the +corresponding space is preferably taken from (or given to) WINDOW's +right sibling. When WINDOW is deleted, its space is given to its left +sibling. + +If the value returned by this function is non-nil, resizing and deleting +WINDOW may resize all windows in the same combination. */) + (Lisp_Object window) +{ + return decode_any_window (window)->splits; +} + +DEFUN ("set-window-splits", Fset_window_splits, Sset_window_splits, 2, 2, 0, + doc: /* Set splits status of WINDOW to STATUS. +WINDOW can be any window and defaults to the selected one. Return +STATUS. + +If STATUS is nil and WINDOW is later resized, the corresponding space is +preferably taken from (or given to) WINDOW's right sibling. When WINDOW +is deleted, its space is given to its left sibling. + +If STATUS is non-nil, resizing and deleting WINDOW may resize all +windows in the same combination. */) + (Lisp_Object window, Lisp_Object status) +{ + register struct window *w = decode_any_window (window); + + w->splits = status; + + return w->splits; +} + +DEFUN ("window-nest", Fwindow_nest, Swindow_nest, 0, 1, 0, + doc: /* Return nest status of WINDOW. +WINDOW can be any window and defaults to the selected one. + +If the return value is nil, subwindows of WINDOW can be recombined with +WINDOW's siblings. A return value of non-nil means that subwindows of +WINDOW are never \(re-)combined with WINDOW's siblings. */) + (Lisp_Object window) +{ + return decode_any_window (window)->nest; +} + +DEFUN ("set-window-nest", Fset_window_nest, Sset_window_nest, 2, 2, 0, + doc: /* Set nest status of WINDOW to STATUS. +WINDOW can be any window and defaults to the selected one. Return +STATUS. + +If STATUS is nil, subwindows of WINDOW can be recombined with WINDOW's +siblings. STATUS non-nil means that subwindows of WINDOW are never +\(re-)combined with WINDOW's siblings. */) + (Lisp_Object window, Lisp_Object status) +{ + register struct window *w = decode_any_window (window); + + w->nest = status; + + return w->nest; +} + +DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0, + doc: /* Return WINDOW's use time. +WINDOW defaults to the selected window. The window with the highest use +time is the most recently selected one. The window with the lowest use +time is the least recently selected one. */) + (Lisp_Object window) +{ + return decode_window (window)->use_time; } DEFUN ("window-total-size", Fwindow_total_size, Swindow_total_size, 0, 2, 0, @@ -714,6 +569,34 @@ return decode_any_window (window)->total_cols; } +DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0, + doc: /* Return new total size of WINDOW. +WINDOW defaults to the selected window. */) + (Lisp_Object window) +{ + return decode_any_window (window)->new_total; +} + +DEFUN ("window-normal-size", Fwindow_normal_size, Swindow_normal_size, 0, 2, 0, + doc: /* Return normal height of WINDOW. +WINDOW can be any window and defaults to the selected one. Optional +argument HORIZONTAL non-nil means return normal width of WINDOW. */) + (Lisp_Object window, Lisp_Object horizontal) +{ + if (NILP (horizontal)) + return decode_any_window (window)->normal_lines; + else + return decode_any_window (window)->normal_cols; +} + +DEFUN ("window-new-normal", Fwindow_new_normal, Swindow_new_normal, 0, 1, 0, + doc: /* Return new normal size of WINDOW. +WINDOW can be any window and defaults to the selected one. */) + (Lisp_Object window) +{ + return decode_any_window (window)->new_normal; +} + DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0, doc: /* Return left column of WINDOW. WINDOW can be any window and defaults to the selected one. */) @@ -802,7 +685,7 @@ DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, doc: /* Return the number of columns by which WINDOW is scrolled from left margin. -WINDOW defaults to the selected window. */) +WINDOW must be a live window and defaults to the selected one. */) (Lisp_Object window) { return decode_window (window)->hscroll; @@ -1372,7 +1255,7 @@ DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0, doc: /* Return window containing coordinates X and Y on FRAME. -If omitted, FRAME defaults to the currently selected frame. +FRAME must be a live frame and defaults to the selected one. The top left corner of the frame is considered to be row 0, column 0. */) (Lisp_Object x, Lisp_Object y, Lisp_Object frame) @@ -1398,7 +1281,7 @@ DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0, doc: /* Return current value of point in WINDOW. -WINDOW defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. For a nonselected window, this is the value point would have if that window were selected. @@ -1420,7 +1303,7 @@ DEFUN ("window-start", Fwindow_start, Swindow_start, 0, 1, 0, doc: /* Return position at which display currently starts in WINDOW. -WINDOW defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. This is updated by redisplay or by calling `set-window-start'. */) (Lisp_Object window) { @@ -1440,7 +1323,7 @@ DEFUN ("window-end", Fwindow_end, Swindow_end, 0, 2, 0, doc: /* Return position at which display currently ends in WINDOW. -WINDOW defaults to the selected window. +WINDOW must be a live window and defaults to the selected one. This is updated by redisplay, when it runs to completion. Simply changing the buffer text or setting `window-start' does not update this value. @@ -1559,6 +1442,179 @@ return pos; } +DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, + Spos_visible_in_window_p, 0, 3, 0, + doc: /* Return non-nil if position POS is currently on the frame in WINDOW. +Return nil if that position is scrolled vertically out of view. +If a character is only partially visible, nil is returned, unless the +optional argument PARTIALLY is non-nil. +If POS is only out of view because of horizontal scrolling, return non-nil. +If POS is t, it specifies the position of the last visible glyph in WINDOW. +POS defaults to point in WINDOW; WINDOW defaults to the selected window. + +If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, +return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), +where X and Y are the pixel coordinates relative to the top left corner +of the window. The remaining elements are omitted if the character after +POS is fully visible; otherwise, RTOP and RBOT are the number of pixels +off-window at the top and bottom of the row, ROWH is the height of the +display row, and VPOS is the row number (0-based) containing POS. */) + (Lisp_Object pos, Lisp_Object window, Lisp_Object partially) +{ + register struct window *w; + register EMACS_INT posint; + register struct buffer *buf; + struct text_pos top; + Lisp_Object in_window = Qnil; + int rtop, rbot, rowh, vpos, fully_p = 1; + int x, y; + + w = decode_window (window); + buf = XBUFFER (w->buffer); + SET_TEXT_POS_FROM_MARKER (top, w->start); + + if (EQ (pos, Qt)) + posint = -1; + else if (!NILP (pos)) + { + CHECK_NUMBER_COERCE_MARKER (pos); + posint = XINT (pos); + } + else if (w == XWINDOW (selected_window)) + posint = PT; + else + posint = XMARKER (w->pointm)->charpos; + + /* If position is above window start or outside buffer boundaries, + or if window start is out of range, position is not visible. */ + if ((EQ (pos, Qt) + || (posint >= CHARPOS (top) && posint <= BUF_ZV (buf))) + && CHARPOS (top) >= BUF_BEGV (buf) + && CHARPOS (top) <= BUF_ZV (buf) + && pos_visible_p (w, posint, &x, &y, &rtop, &rbot, &rowh, &vpos) + && (fully_p = !rtop && !rbot, (!NILP (partially) || fully_p))) + in_window = Qt; + + if (!NILP (in_window) && !NILP (partially)) + { + Lisp_Object part = Qnil; + if (!fully_p) + part = list4 (make_number (rtop), make_number (rbot), + make_number (rowh), make_number (vpos)); + in_window = Fcons (make_number (x), + Fcons (make_number (y), part)); + } + + return in_window; +} + +DEFUN ("window-line-height", Fwindow_line_height, + Swindow_line_height, 0, 2, 0, + doc: /* Return height in pixels of text line LINE in window WINDOW. +WINDOW defaults to the selected window. + +Return height of current line if LINE is omitted or nil. Return height of +header or mode line if LINE is `header-line' or `mode-line'. +Otherwise, LINE is a text line number starting from 0. A negative number +counts from the end of the window. + +Value is a list (HEIGHT VPOS YPOS OFFBOT), where HEIGHT is the height +in pixels of the visible part of the line, VPOS and YPOS are the +vertical position in lines and pixels of the line, relative to the top +of the first text line, and OFFBOT is the number of off-window pixels at +the bottom of the text line. If there are off-window pixels at the top +of the (first) text line, YPOS is negative. + +Return nil if window display is not up-to-date. In that case, use +`pos-visible-in-window-p' to obtain the information. */) + (Lisp_Object line, Lisp_Object window) +{ + register struct window *w; + register struct buffer *b; + struct glyph_row *row, *end_row; + int max_y, crop, i, n; + + w = decode_window (window); + + if (noninteractive || w->pseudo_window_p) + return Qnil; + + CHECK_BUFFER (w->buffer); + b = XBUFFER (w->buffer); + + /* Fail if current matrix is not up-to-date. */ + if (NILP (w->window_end_valid) + || current_buffer->clip_changed + || current_buffer->prevent_redisplay_optimizations_p + || XFASTINT (w->last_modified) < BUF_MODIFF (b) + || XFASTINT (w->last_overlay_modified) < BUF_OVERLAY_MODIFF (b)) + return Qnil; + + if (NILP (line)) + { + i = w->cursor.vpos; + if (i < 0 || i >= w->current_matrix->nrows + || (row = MATRIX_ROW (w->current_matrix, i), !row->enabled_p)) + return Qnil; + max_y = window_text_bottom_y (w); + goto found_row; + } + + if (EQ (line, Qheader_line)) + { + if (!WINDOW_WANTS_HEADER_LINE_P (w)) + return Qnil; + row = MATRIX_HEADER_LINE_ROW (w->current_matrix); + if (!row->enabled_p) + return Qnil; + return list4 (make_number (row->height), + make_number (0), make_number (0), + make_number (0)); + } + + if (EQ (line, Qmode_line)) + { + row = MATRIX_MODE_LINE_ROW (w->current_matrix); + if (!row->enabled_p) + return Qnil; + return list4 (make_number (row->height), + make_number (0), /* not accurate */ + make_number (WINDOW_HEADER_LINE_HEIGHT (w) + + window_text_bottom_y (w)), + make_number (0)); + } + + CHECK_NUMBER (line); + n = XINT (line); + + row = MATRIX_FIRST_TEXT_ROW (w->current_matrix); + end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w); + max_y = window_text_bottom_y (w); + i = 0; + + while ((n < 0 || i < n) + && row <= end_row && row->enabled_p + && row->y + row->height < max_y) + row++, i++; + + if (row > end_row || !row->enabled_p) + return Qnil; + + if (++n < 0) + { + if (-n > i) + return Qnil; + row += n; + i += n; + } + + found_row: + crop = max (0, (row->y + row->height) - max_y); + return list4 (make_number (row->height + min (0, row->y) - crop), + make_number (i), + make_number (row->y), + make_number (crop)); +} DEFUN ("window-dedicated-p", Fwindow_dedicated_p, Swindow_dedicated_p, 0, 1, 0, @@ -1586,22 +1642,22 @@ DEFUN ("set-window-dedicated-p", Fset_window_dedicated_p, Sset_window_dedicated_p, 2, 2, 0, doc: /* Mark WINDOW as dedicated according to FLAG. -WINDOW defaults to the selected window. FLAG non-nil means mark WINDOW -as dedicated to its buffer. FLAG nil means mark WINDOW as non-dedicated. -Return FLAG. +WINDOW must be a live window and defaults to the selected one. FLAG +non-nil means mark WINDOW as dedicated to its buffer. FLAG nil means +mark WINDOW as non-dedicated. Return FLAG. When a window is dedicated to its buffer, `display-buffer' will refrain from displaying another buffer in it. `get-lru-window' and `get-largest-window' treat dedicated windows specially. -`delete-windows-on', `replace-buffer-in-windows', `quit-window' and -`kill-buffer' can delete a dedicated window and the containing -frame. +`delete-windows-on', `replace-buffer-in-windows', `quit-window', +`quit-restore-window' and `kill-buffer' can delete a dedicated window +and the containing frame. As a special case, if FLAG is t, mark WINDOW as "strongly" dedicated to its buffer. Functions like `set-window-buffer' may change the buffer displayed by a window, unless that window is strongly dedicated to its buffer. If and when `set-window-buffer' displays another buffer in a -window, it also makes sure that the window is not marked as dedicated. */) +window, it also makes sure that the window is no more dedicated. */) (Lisp_Object window, Lisp_Object flag) { register struct window *w = decode_window (window); @@ -1610,6 +1666,52 @@ return w->dedicated; } +DEFUN ("window-prev-buffers", Fwindow_prev_buffers, Swindow_prev_buffers, + 0, 1, 0, + doc: /* Return buffers previously shown in WINDOW. +WINDOW must be a live window and defaults to the selected one. + +The return value is either nil or a list of triples where buffer was previously shown in WINDOW. */) + (Lisp_Object window) +{ + return decode_window (window)->prev_buffers; +} + +DEFUN ("set-window-prev-buffers", Fset_window_prev_buffers, + Sset_window_prev_buffers, 2, 2, 0, + doc: /* Set WINDOW's previous buffers to PREV-BUFFERS. +WINDOW must be a live window and defaults to the selected one. Return +PREV-BUFFERS. + +PREV-BUFFERS should be either nil or a list of triples where buffer was previously shown in WINDOW. */) + (Lisp_Object window, Lisp_Object prev_buffers) +{ + return decode_any_window (window)->prev_buffers = prev_buffers; +} + +DEFUN ("window-next-buffers", Fwindow_next_buffers, Swindow_next_buffers, + 0, 1, 0, + doc: /* Return list of buffers recently re-shown in WINDOW. +WINDOW must be a live window and defaults to the selected one. */) + (Lisp_Object window) +{ + return decode_window (window)->next_buffers; +} + +DEFUN ("set-window-next-buffers", Fset_window_next_buffers, + Sset_window_next_buffers, 2, 2, 0, + doc: /* Set WINDOW's next buffers to NEXT-BUFFERS. +WINDOW must be a live window and defaults to the selected one. Return +NEXT-BUFFERS. + +NEXT-BUFFERS should be either nil or a list of buffers that have been +recently re-shown in WINDOW. */) + (Lisp_Object window, Lisp_Object next_buffers) +{ + return decode_any_window (window)->next_buffers = next_buffers; +} DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters, 0, 1, 0, @@ -1618,7 +1720,7 @@ elements of the form (PARAMETER . VALUE). */) (Lisp_Object window) { - return Fcopy_alist (decode_window (window)->window_parameters); + return Fcopy_alist (decode_any_window (window)->window_parameters); } DEFUN ("window-parameter", Fwindow_parameter, Swindow_parameter, @@ -1629,7 +1731,7 @@ { Lisp_Object result; - result = Fassq (parameter, decode_window (window)->window_parameters); + result = Fassq (parameter, decode_any_window (window)->window_parameters); return CDR_SAFE (result); } @@ -1639,7 +1741,7 @@ WINDOW defaults to the selected window. Return VALUE. */) (Lisp_Object window, Lisp_Object parameter, Lisp_Object value) { - register struct window *w = decode_window (window); + register struct window *w = decode_any_window (window); Lisp_Object old_alist_elt; old_alist_elt = Fassq (parameter, w->window_parameters); @@ -1650,7 +1752,6 @@ return value; } - DEFUN ("window-display-table", Fwindow_display_table, Swindow_display_table, 0, 1, 0, doc: /* Return the display-table that WINDOW is using. @@ -2033,7 +2134,7 @@ /* Add window W to *USER_DATA. USER_DATA is actually a Lisp_Object pointer. This is a callback function for foreach_window, used in - function window_list. */ + the window_list function. */ static int add_window_to_list (struct window *w, void *user_data) @@ -2662,26 +2763,25 @@ window_loop (CHECK_ALL_WINDOWS, Qnil, 1, Qt); } -DEFUN ("window-use-time", Fwindow_use_time, Swindow_use_time, 0, 1, 0, - doc: /* Return WINDOW's use time. -WINDOW defaults to the selected window. The window with the highest use -time is the most recently selected one. The window with the lowest use -time is the least recently selected one. */) - (Lisp_Object window) -{ - return decode_window (window)->use_time; -} - DEFUN ("get-buffer-window", Fget_buffer_window, Sget_buffer_window, 0, 2, 0, doc: /* Return a window currently displaying BUFFER-OR-NAME, or nil if none. -BUFFER-OR-NAME may be a buffer or a buffer name and defaults to the -current buffer. -If optional argument FRAME is `visible', search all visible frames. -If optional argument 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. */) - (Lisp_Object buffer_or_name, Lisp_Object frame) +BUFFER-OR-NAME may be a buffer or a buffer name and defaults to +the current buffer. + +The optional argument ALL-FRAMES specifies the frames to consider: + +- t means consider all windows on all existing frames. + +- `visible' means consider all windows on all visible frames. + +- 0 (the number zero) means consider all windows on all visible + and iconified frames. + +- A frame means consider all windows on that frame only. + +Any other value of ALL-FRAMES means consider all windows on the +selected frame and no others. */) + (Lisp_Object buffer_or_name, Lisp_Object all_frames) { Lisp_Object buffer; @@ -2691,7 +2791,7 @@ buffer = Fget_buffer (buffer_or_name); if (BUFFERP (buffer)) - return window_loop (GET_BUFFER_WINDOW, buffer, 1, frame); + return window_loop (GET_BUFFER_WINDOW, buffer, 1, all_frames); else return Qnil; } @@ -3723,6 +3823,17 @@ unbind_to (count, Qnil); } +DEFUN ("set-window-clone-number", Fset_window_clone_number, Sset_window_clone_number, 2, 2, 0, + doc: /* Set WINDOW's clone number to CLONE-NUMBER. +WINDOW can be any window and defaults to the selected one. */) + (Lisp_Object window, Lisp_Object clone_number) +{ + register struct window *w = decode_any_window (window); + + CHECK_NUMBER (clone_number); + w->clone_number = clone_number; + return w->clone_number; +} DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0, doc: /* Make WINDOW display BUFFER-OR-NAME as its contents. @@ -3912,6 +4023,7 @@ ++sequence_number; XSETFASTINT (p->sequence_number, sequence_number); + XSETFASTINT (p->clone_number, sequence_number); /* Put new into window structure in place of window */ replace_window (window, new); @@ -3925,6 +4037,112 @@ p->start = Qnil; p->pointm = Qnil; p->buffer = Qnil; + + p->splits = Qnil; + p->nest = Qnil; + p->window_parameters = Qnil; + +} + +/* Make new window from scratch. */ +Lisp_Object +make_window (void) +{ + Lisp_Object window; + register struct window *w; + + w = allocate_window (); + /* Initialize all Lisp data. */ + w->frame = w->mini_p = Qnil; + w->next = w->prev = w->hchild = w->vchild = w->parent = Qnil; + XSETFASTINT (w->left_col, 0); + XSETFASTINT (w->top_line, 0); + XSETFASTINT (w->total_lines, 0); + XSETFASTINT (w->total_cols, 0); + w->normal_lines = make_float (1.0); + w->normal_cols = make_float (1.0); + XSETFASTINT (w->new_total, 0); + XSETFASTINT (w->new_normal, 0); + w->buffer = Qnil; + w->start = Fmake_marker (); + w->pointm = Fmake_marker (); + w->force_start = w->optional_new_start = Qnil; + XSETFASTINT (w->hscroll, 0); + XSETFASTINT (w->min_hscroll, 0); + XSETFASTINT (w->use_time, 0); + ++sequence_number; + XSETFASTINT (w->sequence_number, sequence_number); + XSETFASTINT (w->clone_number, sequence_number); + w->temslot = w->last_modified = w->last_overlay_modified = Qnil; + XSETFASTINT (w->last_point, 0); + w->last_had_star = w->vertical_scroll_bar = Qnil; + w->left_margin_cols = w->right_margin_cols = Qnil; + w->left_fringe_width = w->right_fringe_width = Qnil; + w->fringes_outside_margins = Qnil; + w->scroll_bar_width = Qnil; + w->vertical_scroll_bar_type = Qt; + w->last_mark_x = w->last_mark_y = Qnil; + XSETFASTINT (w->window_end_pos, 0); + XSETFASTINT (w->window_end_vpos, 0); + w->window_end_valid = w->update_mode_line = Qnil; + w->start_at_line_beg = w->display_table = w->dedicated = Qnil; + w->base_line_number = w->base_line_pos = w->region_showing = Qnil; + w->column_number_displayed = w->redisplay_end_trigger = Qnil; + w->splits = w->nest = w->window_parameters = Qnil; + w->prev_buffers = w->next_buffers = Qnil; + /* Initialize non-Lisp data. */ + w->desired_matrix = w->current_matrix = 0; + w->nrows_scale_factor = w->ncols_scale_factor = 1; + memset (&w->cursor, 0, sizeof (w->cursor)); + memset (&w->last_cursor, 0, sizeof (w->last_cursor)); + memset (&w->phys_cursor, 0, sizeof (w->phys_cursor)); + w->phys_cursor_type = -1; + w->phys_cursor_width = -1; + w->last_cursor_off_p = w->cursor_off_p = 0; + w->must_be_updated_p = 0; + w->pseudo_window_p = 0; + w->frozen_window_start_p = 0; + w->vscroll = 0; + w->resize_proportionally = Qnil; + /* Reset window_list. */ + Vwindow_list = Qnil; + /* Return window. */ + XSETWINDOW (window, w); + return window; +} + +DEFUN ("set-window-new-total", Fset_window_new_total, Sset_window_new_total, 2, 3, 0, + doc: /* Set new total size of WINDOW to SIZE. +Return SIZE. + +Optional argument ADD non-nil means add SIZE to the new total size of +WINDOW and return the sum. + +Note: This function does not operate on any subwindows of WINDOW. */) + (Lisp_Object window, Lisp_Object size, Lisp_Object add) +{ + struct window *w = decode_any_window (window); + + CHECK_NUMBER (size); + if (NILP (add)) + XSETINT (w->new_total, XINT (size)); + else + XSETINT (w->new_total, XINT (w->new_total) + XINT (size)); + + return w->new_total; +} + +DEFUN ("set-window-new-normal", Fset_window_new_normal, Sset_window_new_normal, 1, 2, 0, + doc: /* Set new normal size of WINDOW to SIZE. +Return SIZE. + +Note: This function does not operate on any subwindows of WINDOW. */) + (Lisp_Object window, Lisp_Object size) +{ + struct window *w = decode_any_window (window); + + w->new_normal = size; + return w->new_normal; } DEFUN ("split-window", Fsplit_window, Ssplit_window, 0, 3, "", @@ -5970,9 +6188,11 @@ struct saved_window { struct vectorlike_header header; - Lisp_Object window; + + Lisp_Object window, clone_number; Lisp_Object buffer, start, pointm, mark; Lisp_Object left_col, top_line, total_cols, total_lines; + Lisp_Object normal_cols, normal_lines; Lisp_Object hscroll, min_hscroll; Lisp_Object parent, prev; Lisp_Object start_at_line_beg; @@ -5982,6 +6202,7 @@ Lisp_Object left_fringe_width, right_fringe_width, fringes_outside_margins; Lisp_Object scroll_bar_width, vertical_scroll_bar_type; Lisp_Object dedicated, resize_proportionally; + Lisp_Object splits, nest, window_parameters; }; #define SAVED_WINDOW_N(swv,n) \ @@ -6186,6 +6407,7 @@ } } + w->clone_number = p->clone_number; /* If we squirreled away the buffer in the window's height, restore it now. */ if (BUFFERP (w->total_lines)) @@ -6194,6 +6416,8 @@ w->top_line = p->top_line; w->total_cols = p->total_cols; w->total_lines = p->total_lines; + w->normal_cols = p->normal_cols; + w->normal_lines = p->normal_lines; w->hscroll = p->hscroll; w->min_hscroll = p->min_hscroll; w->display_table = p->display_table; @@ -6207,6 +6431,9 @@ w->scroll_bar_width = p->scroll_bar_width; w->vertical_scroll_bar_type = p->vertical_scroll_bar_type; w->dedicated = p->dedicated; + w->splits = p->splits; + w->nest = p->nest; + w->window_parameters = p->window_parameters; w->resize_proportionally = p->resize_proportionally; XSETFASTINT (w->last_modified, 0); XSETFASTINT (w->last_overlay_modified, 0); @@ -6445,11 +6672,14 @@ XSETFASTINT (w->temslot, i); i++; p->window = window; + p->clone_number = w->clone_number; p->buffer = w->buffer; p->left_col = w->left_col; p->top_line = w->top_line; p->total_cols = w->total_cols; p->total_lines = w->total_lines; + p->normal_cols = w->normal_cols; + p->normal_lines = w->normal_lines; p->hscroll = w->hscroll; p->min_hscroll = w->min_hscroll; p->display_table = w->display_table; @@ -6463,7 +6693,10 @@ p->scroll_bar_width = w->scroll_bar_width; p->vertical_scroll_bar_type = w->vertical_scroll_bar_type; p->dedicated = w->dedicated; + p->splits = w->splits; + p->nest = w->nest; p->resize_proportionally = w->resize_proportionally; + p->window_parameters = w->window_parameters; if (!NILP (w->buffer)) { /* Save w's value of point in the window configuration. @@ -7281,16 +7514,26 @@ defsubr (&Sset_frame_selected_window); defsubr (&Spos_visible_in_window_p); defsubr (&Swindow_line_height); + defsubr (&Swindow_clone_number); defsubr (&Swindow_buffer); defsubr (&Swindow_parent); defsubr (&Swindow_vchild); defsubr (&Swindow_hchild); defsubr (&Swindow_next); defsubr (&Swindow_prev); + defsubr (&Swindow_splits); + defsubr (&Sset_window_splits); + defsubr (&Swindow_nest); + defsubr (&Sset_window_nest); defsubr (&Swindow_use_time); defsubr (&Swindow_top_line); defsubr (&Swindow_left_column); defsubr (&Swindow_total_size); + defsubr (&Swindow_normal_size); + defsubr (&Swindow_new_total); + defsubr (&Swindow_new_normal); + defsubr (&Sset_window_new_total); + defsubr (&Sset_window_new_normal); defsubr (&Swindow_body_size); defsubr (&Swindow_hscroll); defsubr (&Sset_window_hscroll); @@ -7322,6 +7565,7 @@ defsubr (&Sreplace_buffer_in_windows); defsubr (&Sdelete_window); defsubr (&Sset_window_buffer); + defsubr (&Sset_window_clone_number); defsubr (&Sselect_window); defsubr (&Sforce_window_update); defsubr (&Stemp_output_buffer_show); @@ -7355,6 +7599,10 @@ defsubr (&Scompare_window_configurations); defsubr (&Swindow_list); defsubr (&Swindow_list_1); + defsubr (&Swindow_prev_buffers); + defsubr (&Sset_window_prev_buffers); + defsubr (&Swindow_next_buffers); + defsubr (&Sset_window_next_buffers); defsubr (&Swindow_parameters); defsubr (&Swindow_parameter); defsubr (&Sset_window_parameter); === modified file 'src/window.h' --- src/window.h 2011-06-07 12:51:07 +0000 +++ src/window.h 2011-06-08 08:35:20 +0000 @@ -93,38 +93,57 @@ /* The frame this window is on. */ Lisp_Object frame; + /* t if this window is a minibuffer window. */ Lisp_Object mini_p; - /* Following child (to right or down) at same level of tree */ - Lisp_Object next; - /* Preceding child (to left or up) at same level of tree */ - Lisp_Object prev; - /* First child of this window. */ - /* vchild is used if this is a vertical combination, - hchild if this is a horizontal combination. */ + + /* Following (to right or down) and preceding (to left or up) child + at same level of tree. */ + Lisp_Object next, prev; + + /* First child of this window: vchild is used if this is a vertical + combination, hchild if this is a horizontal combination. Of the + fields vchild, hchild and buffer, one and only one is non-nil + unless the window is dead. */ Lisp_Object hchild, vchild; - /* The window this one is a child of. */ + + /* The window this one is a child of. */ Lisp_Object parent; - /* The upper left corner coordinates of this window, - as integers relative to upper left corner of frame = 0, 0 */ + + /* The upper left corner coordinates of this window, as integers + relative to upper left corner of frame = 0, 0. */ Lisp_Object left_col; Lisp_Object top_line; - /* The size of the window */ + + /* The size of the window. */ Lisp_Object total_lines; Lisp_Object total_cols; - /* The buffer displayed in this window */ - /* Of the fields vchild, hchild and buffer, only one is non-nil. */ + + /* The normal size of the window. */ + Lisp_Object normal_lines; + Lisp_Object normal_cols; + + /* New sizes of the window. */ + Lisp_Object new_total; + Lisp_Object new_normal; + + /* The buffer displayed in this window. Of the fields vchild, + hchild and buffer, one and only one is non-nil unless the window + is dead. */ Lisp_Object buffer; + /* A marker pointing to where in the text to start displaying. BIDI Note: This is the _logical-order_ start, i.e. the smallest buffer position visible in the window, not necessarily the character displayed in the top left corner of the window. */ Lisp_Object start; + /* A marker pointing to where in the text point is in this window, used only when the window is not selected. This exists so that when multiple windows show one buffer each one can have its own value of point. */ Lisp_Object pointm; + /* Non-nil means next redisplay must use the value of start set up for it in advance. Set by scrolling commands. */ Lisp_Object force_start; @@ -133,26 +152,38 @@ This is used in Fdelete_other_windows to force a call to Vwindow_scroll_functions; also by Frecenter with argument. */ Lisp_Object optional_new_start; + /* Number of columns display within the window is scrolled to the left. */ Lisp_Object hscroll; /* Minimum hscroll for automatic hscrolling. This is the value the user has set, by set-window-hscroll for example. */ Lisp_Object min_hscroll; - /* Number saying how recently window was selected */ + + /* Number saying how recently window was selected. */ Lisp_Object use_time; - /* Unique number of window assigned when it was created */ + + /* Unique number of window assigned when it was created. */ Lisp_Object sequence_number; - /* No permanent meaning; used by save-window-excursion's bookkeeping */ + + /* Sequence number of window this window was cloned from. Identic + to sequence number if window was not cloned. */ + Lisp_Object clone_number; + + /* No permanent meaning; used by save-window-excursion's + bookkeeping. */ Lisp_Object temslot; - /* text.modified of displayed buffer as of last time display completed */ + + /* text.modified of displayed buffer as of last time display + completed. */ Lisp_Object last_modified; /* BUF_OVERLAY_MODIFIED of displayed buffer as of last complete update. */ Lisp_Object last_overlay_modified; - /* Value of point at that time */ + /* Value of point at that time. */ Lisp_Object last_point; /* Non-nil if the buffer was "modified" when the window was last updated. */ Lisp_Object last_had_star; + /* This window's vertical scroll bar. This field is only for use by the window-system-dependent code which implements the scroll bars; it can store anything it likes here. If this @@ -167,14 +198,14 @@ /* Width of left and right fringes. A value of nil or t means use frame values. */ Lisp_Object left_fringe_width, right_fringe_width; - - /* Non-nil means fringes are drawn outside display margins; - othersize draw them between margin areas and text. */ + /* Non-nil means fringes are drawn outside display margins; + othersize draw them between margin areas and text. */ Lisp_Object fringes_outside_margins; /* Pixel width of scroll bars. A value of nil or t means use frame values. */ Lisp_Object scroll_bar_width; + /* Type of vertical scroll bar. A value of nil means no scroll bar. A value of t means use frame value. */ Lisp_Object vertical_scroll_bar_type; @@ -183,6 +214,7 @@ /* May be nil if mark does not exist or was not on frame */ Lisp_Object last_mark_x; Lisp_Object last_mark_y; + /* Z - the buffer position of the last glyph in the current matrix of W. Only valid if WINDOW_END_VALID is not nil. */ Lisp_Object window_end_pos; @@ -194,30 +226,38 @@ since in that case the frame image that window_end_pos did not get onto the frame. */ Lisp_Object window_end_valid; + /* Non-nil means must regenerate mode line of this window */ Lisp_Object update_mode_line; + /* Non-nil means current value of `start' was the beginning of a line when it was chosen. */ Lisp_Object start_at_line_beg; + /* Display-table to use for displaying chars in this window. Nil means use the buffer's own display-table. */ Lisp_Object display_table; + /* Non-nil means window is marked as dedicated. */ Lisp_Object dedicated; - /* Line number and position of a line somewhere above the - top of the screen. */ - /* If this field is nil, it means we don't have a base line. */ + + /* Line number and position of a line somewhere above the top of the + screen. If this field is nil, it means we don't have a base + line. */ Lisp_Object base_line_number; /* If this field is nil, it means we don't have a base line. If it is a buffer, it means don't display the line number as long as the window shows that buffer. */ Lisp_Object base_line_pos; + /* If we have highlighted the region (or any part of it), this is the mark position that we used, as an integer. */ Lisp_Object region_showing; + /* The column number currently displayed in this window's mode line, or nil if column numbers are not being displayed. */ Lisp_Object column_number_displayed; + /* If redisplay in this window goes beyond this buffer position, must run the redisplay-end-trigger-hook. */ Lisp_Object redisplay_end_trigger; @@ -228,6 +268,21 @@ /* Original window height and top before mini-window was enlarged. */ Lisp_Object orig_total_lines, orig_top_line; + /* Non-nil means deleting or resizing this window distributes + space among all windows in the same combination. */ + Lisp_Object splits; + + /* Non-nil means this window's child windows are never + (re-)combined. */ + Lisp_Object nest; + + /* Alist of triples listing + buffers previously shown in this window. */ + Lisp_Object prev_buffers; + + /* List of buffers re-shown in this window. */ + Lisp_Object next_buffers; + /* An alist with parameteres. */ Lisp_Object window_parameters; @@ -361,6 +416,17 @@ #define WINDOW_TOTAL_HEIGHT(W) \ (WINDOW_TOTAL_LINES (W) * WINDOW_FRAME_LINE_HEIGHT (W)) +/* For HORFLAG non-zero the total number of columns of window W. Otherwise + the total number of lines of W. */ + +#define WINDOW_TOTAL_SIZE(w, horflag) \ + (horflag ? WINDOW_TOTAL_COLS (w) : WINDOW_TOTAL_LINES (w)) + +/* The smallest acceptable dimensions for a window. Anything smaller + might crash Emacs. */ + +#define MIN_SAFE_WINDOW_WIDTH (2) +#define MIN_SAFE_WINDOW_HEIGHT (1) /* Return the canonical frame column at which window W starts. This includes a left-hand scroll bar, if any. */ @@ -859,6 +925,7 @@ EXFUN (Fpos_visible_in_window_p, 3); extern void mark_window_cursors_off (struct window *); extern int window_internal_height (struct window *); +extern int window_body_cols (struct window *w); EXFUN (Frecenter, 1); extern void temp_output_buffer_show (Lisp_Object); extern void replace_buffer_in_all_windows (Lisp_Object); @@ -867,6 +934,4 @@ extern void syms_of_window (void); extern void keys_of_window (void); -extern int window_body_cols (struct window *w); - #endif /* not WINDOW_H_INCLUDED */ ------------------------------------------------------------ revno: 104535 committer: Glenn Morris branch nick: trunk timestamp: Wed 2011-06-08 00:17:26 -0700 message: Merge from emacs-23; up to r100595. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-08 06:57:38 +0000 +++ lisp/ChangeLog 2011-06-08 07:17:26 +0000 @@ -1,3 +1,17 @@ +2011-06-08 Reuben Thomas + + * progmodes/flymake.el (flymake-compilation-prevents-syntax-check): + Doc fix (Bug#8713). + +2011-06-08 Chong Yidong + + * repeat.el (repeat-on-final-keystroke): Fix type (Bug#8696). + +2011-06-08 Juanma Barranquero + + * loadhist.el (unload-feature-special-hooks): + Add `comint-output-filter-functions'. + 2011-06-08 Ivan Kanis * calendar/appt.el (appt-check): Move some initializations into the let. === modified file 'lisp/loadhist.el' --- lisp/loadhist.el 2011-01-25 04:08:28 +0000 +++ lisp/loadhist.el 2011-06-08 07:17:26 +0000 @@ -117,16 +117,16 @@ '(after-change-functions after-insert-file-functions after-make-frame-functions auto-fill-function before-change-functions blink-paren-function buffer-access-fontify-functions - choose-completion-string-functions command-line-functions - comment-indent-function compilation-finish-functions delete-frame-functions - disabled-command-function find-file-not-found-functions - font-lock-beginning-of-syntax-function font-lock-fontify-buffer-function - font-lock-fontify-region-function font-lock-mark-block-function - font-lock-syntactic-face-function font-lock-unfontify-buffer-function - font-lock-unfontify-region-function kill-buffer-query-functions - kill-emacs-query-functions lisp-indent-function mouse-position-function - redisplay-end-trigger-functions suspend-tty-functions - temp-buffer-show-function window-scroll-functions + choose-completion-string-functions comint-output-filter-functions + command-line-functions comment-indent-function compilation-finish-functions + delete-frame-functions disabled-command-function + find-file-not-found-functions font-lock-beginning-of-syntax-function + font-lock-fontify-buffer-function font-lock-fontify-region-function + font-lock-mark-block-function font-lock-syntactic-face-function + font-lock-unfontify-buffer-function font-lock-unfontify-region-function + kill-buffer-query-functions kill-emacs-query-functions lisp-indent-function + mouse-position-function redisplaylay-end-trigger-functions + suspend-tty-functions temp-buffer-show-function window-scroll-functions window-size-change-functions write-contents-functions write-file-functions write-region-annotate-functions) "A list of special hooks from Info node `(elisp)Standard Hooks'. === modified file 'lisp/progmodes/flymake.el' --- lisp/progmodes/flymake.el 2011-04-22 18:44:26 +0000 +++ lisp/progmodes/flymake.el 2011-06-08 07:17:26 +0000 @@ -1118,7 +1118,7 @@ (flymake-log 1 "Failed to delete dir %s, error ignored" dir-name)))) (defcustom flymake-compilation-prevents-syntax-check t - "If non-nil, syntax check won't be started in case compilation is running." + "If non-nil, don't start syntax check if compilation is running." :group 'flymake :type 'boolean) === modified file 'lisp/repeat.el' --- lisp/repeat.el 2011-01-25 04:08:28 +0000 +++ lisp/repeat.el 2011-06-08 07:17:26 +0000 @@ -123,7 +123,9 @@ only occurs if the final character by which `repeat' was invoked is a member of that sequence. If this variable is nil, no re-execution occurs." :group 'convenience - :type 'boolean) + :type '(choice (const :tag "Repeat for all keys" t) + (const :tag "Don't repeat" nil) + (sexp :tag "Repeat for specific keys"))) ;;;;; ****************** HACKS TO THE REST OF EMACS ******************* ;;;;; ------------------------------------------------------------ revno: 104534 author: Ivan Kanis committer: Glenn Morris branch nick: trunk timestamp: Tue 2011-06-07 23:57:38 -0700 message: * lisp/calendar/appt.el (appt-check): Move some initializations into the let. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-06-08 05:40:45 +0000 +++ lisp/ChangeLog 2011-06-08 06:57:38 +0000 @@ -1,3 +1,7 @@ +2011-06-08 Ivan Kanis + + * calendar/appt.el (appt-check): Move some initializations into the let. + 2011-06-08 Martin Rudalics * window.el (window-height): Defalias to window-total-height. === modified file 'lisp/calendar/appt.el' --- lisp/calendar/appt.el 2011-05-17 04:05:39 +0000 +++ lisp/calendar/appt.el 2011-06-08 06:57:38 +0000 @@ -285,11 +285,11 @@ (let* ((min-to-app -1) (prev-appt-mode-string appt-mode-string) (prev-appt-display-count appt-display-count) - now now-mins appt-mins appt-warn-time) + ;; Convert current time to minutes after midnight (12.01am = 1). + (now (decode-time)) + (now-mins (+ (* 60 (nth 2 now)) (nth 1 now))) + appt-mins appt-warn-time) (save-excursion ; FIXME ? - ;; Convert current time to minutes after midnight (12.01am = 1). - (setq now (decode-time) - now-mins (+ (* 60 (nth 2 now)) (nth 1 now))) ;; At first check in any day, update appointments to today's list. (if (or force ; eg initialize, diary save (null appt-prev-comp-time) ; first check