]> code.delx.au - gnu-emacs/blobdiff - src/window.c
*** empty log message ***
[gnu-emacs] / src / window.c
index 7bfa8e3290a36e11e6d0f1a38557b6c2acbd7bd8..83440f440cc52f44e7e43ee0340926ec5926b797 100644 (file)
@@ -1861,7 +1861,7 @@ window_loop (type, obj, mini, frames)
            if (!NILP (obj) && !WINDOW_FULL_WIDTH_P (w))
              break;
            /* Ignore dedicated windows and minibuffers.  */
-           if (MINI_WINDOW_P (w) || !NILP (w->dedicated))
+           if (MINI_WINDOW_P (w) || EQ (w->dedicated, Qt))
              break;
            if (NILP (best_window)
                || (XFASTINT (XWINDOW (best_window)->use_time)
@@ -1914,7 +1914,7 @@ window_loop (type, obj, mini, frames)
          case GET_LARGEST_WINDOW:
            {
              /* Ignore dedicated windows and minibuffers.  */
-             if (MINI_WINDOW_P (w) || !NILP (w->dedicated))
+             if (MINI_WINDOW_P (w) || EQ (w->dedicated, Qt))
                break;
              
              if (NILP (best_window))
@@ -1954,6 +1954,14 @@ window_loop (type, obj, mini, frames)
                    /* Now we can safely delete the frame.  */
                    Fdelete_frame (w->frame, Qnil);
                  }
+               else if (!NILP (w->dedicated) && !NILP (w->parent))
+                 {
+                   Lisp_Object window;
+                   XSETWINDOW (window, w);
+                   /* If this window is dedicated and not the only window
+                      in its frame, then kill it.  */
+                   Fdelete_window (window);
+                 }
                else
                  {
                    /* Otherwise show a different buffer in the window.  */
@@ -2664,7 +2672,7 @@ set_window_buffer (window, buffer, run_hooks_p)
 {
   struct window *w = XWINDOW (window);
   struct buffer *b = XBUFFER (buffer);
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
 
   w->buffer = buffer;
 
@@ -2747,7 +2755,7 @@ BUFFER can be a buffer or buffer name.  */)
     {
       if (!NILP (w->dedicated) && !EQ (tem, buffer))
        error ("Window is dedicated to `%s'",
-              XSTRING (XBUFFER (tem)->name)->data);
+              SDATA (XBUFFER (tem)->name));
 
       unshow_buffer (w);
     }
@@ -2759,6 +2767,8 @@ BUFFER can be a buffer or buffer name.  */)
 DEFUN ("select-window", Fselect_window, Sselect_window, 1, 1, 0,
        doc: /* Select WINDOW.  Most editing will apply to WINDOW's buffer.
 If WINDOW is not already selected, also make WINDOW's buffer current.
+Also make WINDOW the frame's selected window.
+
 Note that the main editor command loop
 selects the buffer of the selected window before each command.  */)
      (window)
@@ -3038,7 +3048,7 @@ displayed.  */)
       frames = Qnil;
       if (FRAME_MINIBUF_ONLY_P (f))
        XSETFRAME (frames, last_nonminibuf_frame);
-      /* Don't try to create a window if would get an error */
+      /* Don't try to create a window if we would get an error.  */
       if (split_height_threshold < window_min_height << 1)
        split_height_threshold = window_min_height << 1;
 
@@ -3145,7 +3155,9 @@ temp_output_buffer_show (buf)
   BEGV = BEG;
   ZV = Z;
   SET_PT (BEG);
+#if 0  /* rms: there should be no reason for this.  */
   XBUFFER (buf)->prevent_redisplay_optimizations_p = 1;
+#endif
   set_buffer_internal (old);
 
   if (!EQ (Vtemp_buffer_show_function, Qnil))
@@ -3164,7 +3176,7 @@ temp_output_buffer_show (buf)
       set_marker_restricted_both (w->pointm, buf, 1, 1);
 
       /* Run temp-buffer-show-hook, with the chosen window selected
-        and it sbuffer current.  */
+        and itbuffer current.  */
       if (!NILP (Vrun_hooks))
        {
          Lisp_Object tem;
@@ -3174,11 +3186,14 @@ temp_output_buffer_show (buf)
              tem = Fsymbol_value (Qtemp_buffer_show_hook);
              if (!NILP (tem))
                {
-                 int count = specpdl_ptr - specpdl;
+                 int count = SPECPDL_INDEX ();
                  Lisp_Object prev_window;
                  prev_window = selected_window;
 
                  /* Select the window that was chosen, for running the hook.  */
+                 /* Both this Fselect_window and the select_window_1
+                    below will (may) incorrectly set-buffer to the buffer
+                    displayed in the window.  --stef  */
                  record_unwind_protect (Fselect_window, prev_window);
                  select_window_1 (window, 0);
                  Fset_buffer (w->buffer);
@@ -3366,15 +3381,20 @@ siblings to the right or below are changed.  */)
   return Qnil;
 }
 
-DEFUN ("shrink-window", Fshrink_window, Sshrink_window, 1, 2, "p",
+DEFUN ("shrink-window", Fshrink_window, Sshrink_window, 1, 3, "p",
        doc: /* Make current window ARG lines smaller.
 From program, optional second arg non-nil means shrink sideways arg columns.
-Interactively, if an argument is not given, make the window one line smaller.  */)
-     (arg, side)
-     register Lisp_Object arg, side;
+Interactively, if an argument is not given, make the window one line smaller.
+
+Optional third arg PRESERVE-BEFORE, if non-nil, means do not change the size
+of the siblings above or to the left of the selected window.  Only
+siblings to the right or below are changed.  */)
+     (arg, side, preserve_before)
+     register Lisp_Object arg, side, preserve_before;
 {
   CHECK_NUMBER (arg);
-  enlarge_window (selected_window, -XINT (arg), !NILP (side), 0);
+  enlarge_window (selected_window, -XINT (arg), !NILP (side),
+                 !NILP (preserve_before));
 
   if (! NILP (Vwindow_configuration_change_hook))
     call1 (Vrun_hooks, Qwindow_configuration_change_hook);
@@ -3654,7 +3674,7 @@ enlarge_window (window, delta, widthflag, preserve_before)
             delta1/n = delta
             delta1 = n * delta.
 
-            The number of children n rquals the number of resizable
+            The number of children n equals the number of resizable
             children of this window + 1 because we know window itself
             is resizable (otherwise we would have signalled an error.  */
 
@@ -4031,12 +4051,16 @@ window_scroll (window, n, whole, noerror)
      int whole;
      int noerror;
 {
+  immediate_quit = 1;
+
   /* If we must, use the pixel-based version which is much slower than
      the line-based one but can handle varying line heights.  */
   if (FRAME_WINDOW_P (XFRAME (XWINDOW (window)->frame)))
     window_scroll_pixel_based (window, n, whole, noerror);
   else
     window_scroll_line_based (window, n, whole, noerror);
+
+  immediate_quit = 0;
 }
 
 
@@ -4123,14 +4147,17 @@ window_scroll_pixel_based (window, n, whole, noerror)
   else
     move_it_by_lines (&it, n, 1);
 
-  /* End if we end up at ZV or BEGV.  */
+  /* We failed if we find ZV is already on the screen (scrolling up,
+     means there's nothing past the end), or if we can't start any
+     earlier (scrolling down, means there's nothing past the top).  */
   if ((n > 0 && IT_CHARPOS (it) == ZV)
       || (n < 0 && IT_CHARPOS (it) == CHARPOS (start)))
     {
       if (IT_CHARPOS (it) == ZV)
        {
-         if (it.current_y + it.max_ascent + it.max_descent
-             > it.last_visible_y)
+         if (it.current_y < it.last_visible_y
+             && (it.current_y + it.max_ascent + it.max_descent
+                 >= it.last_visible_y))
            {
              /* The last line was only partially visible, make it fully
                 visible.  */
@@ -4651,6 +4678,15 @@ displayed_window_lines (w)
   move_it_vertically (&it, height);
   bottom_y = line_bottom_y (&it);
 
+  /* rms: On a non-window display,
+     the value of it.vpos at the bottom of the screen
+     seems to be 1 larger than window_box_height (w).
+     This kludge fixes a bug whereby (move-to-window-line -1)
+     when ZV is on the last screen line
+     moves to the previous screen line instead of the last one.  */
+  if (! FRAME_WINDOW_P (XFRAME (w->frame)))
+    height++;
+
   /* Add in empty lines at the bottom of the window.  */
   if (bottom_y < height)
     {
@@ -4955,7 +4991,12 @@ the return value is nil.  Otherwise the value is t.  */)
   if (NILP (XBUFFER (new_current_buffer)->name))
     new_current_buffer = Qnil;
   else
-    old_point = BUF_PT (XBUFFER (new_current_buffer));
+    {
+      if (XBUFFER (new_current_buffer) == current_buffer)
+       old_point = PT;
+      else
+       old_point = BUF_PT (XBUFFER (new_current_buffer));
+    }
 
   frame = XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame;
   f = XFRAME (frame);
@@ -5462,7 +5503,7 @@ usage: (save-window-excursion BODY ...)  */)
      Lisp_Object args;
 {
   register Lisp_Object val;
-  register int count = specpdl_ptr - specpdl;
+  register int count = SPECPDL_INDEX ();
 
   record_unwind_protect (Fset_window_configuration,
                         Fcurrent_window_configuration (Qnil));
@@ -5947,10 +5988,14 @@ Those variables take precedence over this one.  */);
               doc: /* Function to call to make a new frame for a special buffer.
 It is called with two arguments, the buffer and optional buffer specific
 data, and should return a window displaying that buffer.
-The default value makes a separate frame for the buffer,
-using `special-display-frame-alist' to specify the frame parameters.
-
-A buffer is special if its is listed in `special-display-buffer-names'
+The default value normally makes a separate frame for the buffer,
+  using `special-display-frame-alist' to specify the frame parameters.
+But if the buffer specific data includes (same-buffer . t) then the
+  buffer is displayed in the current selected window.
+Otherwise if it includes (same-frame . t) then the buffer is displayed in
+  a new window in the currently selected frame.
+
+A buffer is special if it is listed in `special-display-buffer-names'
 or matches a regexp in `special-display-regexps'.  */);
   Vspecial_display_function = Qnil;