]> code.delx.au - gnu-emacs/blobdiff - src/window.c
lisp.h: Fix a problem with aliasing and vector headers.
[gnu-emacs] / src / window.c
index 9a0955955fa0e12392ea2c39014cf9de9bf9bb22..92c7c57e213859b280456346cc1ea4626428dddc 100644 (file)
@@ -50,10 +50,11 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "nsterm.h"
 #endif
 
-Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
-Lisp_Object Qdisplay_buffer;
-Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
-Lisp_Object Qwindow_size_fixed;
+Lisp_Object Qwindowp, Qwindow_live_p;
+static Lisp_Object Qwindow_configuration_p;
+static Lisp_Object Qdisplay_buffer;
+static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
+static Lisp_Object Qwindow_size_fixed;
 
 static int displayed_window_lines (struct window *);
 static struct window *decode_window (Lisp_Object);
@@ -116,7 +117,7 @@ Lisp_Object minibuf_selected_window;
 
 /* Hook run at end of temp_output_buffer_show.  */
 
-Lisp_Object Qtemp_buffer_show_hook;
+static Lisp_Object Qtemp_buffer_show_hook;
 
 /* Incremented for each window created.  */
 
@@ -131,7 +132,7 @@ static int window_initialized;
 static Lisp_Object Qwindow_configuration_change_hook;
 /* Incremented by 1 whenever a window is deleted.  */
 
-int window_deletion_count;
+static int window_deletion_count;
 
 /* Used by the function window_scroll_pixel_based */
 
@@ -235,7 +236,8 @@ used by that frame.  */)
   return FRAME_MINIBUF_WINDOW (XFRAME (frame));
 }
 
-DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, Swindow_minibuffer_p, 0, 1, 0,
+DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p,
+       Swindow_minibuffer_p, 0, 1, 0,
        doc: /* Return non-nil if WINDOW is a minibuffer window.
 WINDOW defaults to the selected window.  */)
   (Lisp_Object window)
@@ -2209,13 +2211,13 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
          case DELETE_BUFFER_WINDOWS:
            if (EQ (w->buffer, obj))
              {
-               struct frame *f = XFRAME (WINDOW_FRAME (w));
+               struct frame *fr = XFRAME (WINDOW_FRAME (w));
 
                /* If this window is dedicated, and in a frame of its own,
                   kill the frame.  */
-               if (EQ (window, FRAME_ROOT_WINDOW (f))
+               if (EQ (window, FRAME_ROOT_WINDOW (fr))
                    && !NILP (w->dedicated)
-                   && other_visible_frames (f))
+                   && other_visible_frames (fr))
                  {
                    /* Skip the other windows on this frame.
                       There might be one, the minibuffer!  */
@@ -2267,16 +2269,16 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
            if (EQ (w->buffer, obj))
              {
                Lisp_Object buffer;
-               struct frame *f = XFRAME (w->frame);
+               struct frame *fr = XFRAME (w->frame);
 
                /* Find another buffer to show in this window.  */
                buffer = Fother_buffer (obj, Qnil, w->frame);
 
                /* If this window is dedicated, and in a frame of its own,
                   kill the frame.  */
-               if (EQ (window, FRAME_ROOT_WINDOW (f))
+               if (EQ (window, FRAME_ROOT_WINDOW (fr))
                    && !NILP (w->dedicated)
-                   && other_visible_frames (f))
+                   && other_visible_frames (fr))
                  {
                    /* Skip the other windows on this frame.
                       There might be one, the minibuffer!  */
@@ -2290,11 +2292,11 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
                  }
                else if (!NILP (w->dedicated) && !NILP (w->parent))
                  {
-                   Lisp_Object window;
-                   XSETWINDOW (window, w);
+                   Lisp_Object window_to_delete;
+                   XSETWINDOW (window_to_delete, w);
                    /* If this window is dedicated and not the only window
                       in its frame, then kill it.  */
-                   Fdelete_window (window);
+                   Fdelete_window (window_to_delete);
                  }
                else
                  {
@@ -2336,6 +2338,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
 
 /* Used for debugging.  Abort if any window has a dead buffer.  */
 
+extern void check_all_windows (void) EXTERNALLY_VISIBLE;
 void
 check_all_windows (void)
 {
@@ -2978,14 +2981,10 @@ shrink_windows (int total, int size, int nchildren, int shrinkable,
   while (total_shrink > total_removed)
     {
       int nonzero_sizes = 0;
-      int nonzero_idx = -1;
 
       for (i = 0; i < nchildren; ++i)
         if (new_sizes[i] > 0)
-          {
-            ++nonzero_sizes;
-            nonzero_idx = i;
-          }
+         ++nonzero_sizes;
 
       for (i = 0; i < nchildren; ++i)
         if (new_sizes[i] > min_sizes[i])
@@ -3124,7 +3123,7 @@ size_window (Lisp_Object window, int size, int width_p, int nodelete_p, int firs
     }
   else if (!NILP (*forward))
     {
-      int fixed_size, each, extra, n;
+      int fixed_size, each IF_LINT (= 0), extra IF_LINT (= 0), n;
       int resize_fixed_p, nfixed;
       int last_pos, first_pos, nchildren, total;
       int *new_sizes = NULL;
@@ -3170,11 +3169,11 @@ size_window (Lisp_Object window, int size, int width_p, int nodelete_p, int firs
       last_pos = first_pos;
       for (n = 0, child = *forward; !NILP (child); child = c->next, ++n)
        {
-         int new_size, old_size;
+         int new_child_size, old_child_size;
 
          c = XWINDOW (child);
-         old_size = WINDOW_TOTAL_SIZE (c, width_p);
-         new_size = old_size;
+         old_child_size = WINDOW_TOTAL_SIZE (c, width_p);
+         new_child_size = old_child_size;
 
          /* The top or left edge position of this child equals the
             bottom or right edge of its predecessor.  */
@@ -3186,18 +3185,20 @@ size_window (Lisp_Object window, int size, int width_p, int nodelete_p, int firs
          /* If this child can be resized, do it.  */
          if (resize_fixed_p || !window_fixed_size_p (c, width_p, 0))
            {
-             new_size = new_sizes ? new_sizes[n] : old_size + each + extra;
+             new_child_size =
+               new_sizes ? new_sizes[n] : old_child_size + each + extra;
              extra = 0;
            }
 
          /* Set new size.  Note that size_window also propagates
             edge positions to children, so it's not a no-op if we
             didn't change the child's size.  */
-         size_window (child, new_size, width_p, 1, first_only, last_only);
+         size_window (child, new_child_size, width_p, 1,
+                      first_only, last_only);
 
          /* Remember the bottom/right edge position of this child; it
             will be used to set the top/left edge of the next child.  */
-          last_pos += new_size;
+          last_pos += new_child_size;
        }
 
       xfree (new_sizes);
@@ -3277,8 +3278,12 @@ change_window_heights (Lisp_Object window, int n)
 \f
 int window_select_count;
 
-EXFUN (Fset_window_fringes, 4);
-EXFUN (Fset_window_scroll_bars, 4);
+static Lisp_Object Fset_window_margins (Lisp_Object, Lisp_Object, Lisp_Object);
+static Lisp_Object Fset_window_fringes (Lisp_Object, Lisp_Object, Lisp_Object,
+                                       Lisp_Object);
+static Lisp_Object Fset_window_scroll_bars (Lisp_Object, Lisp_Object,
+                                           Lisp_Object, Lisp_Object);
+static Lisp_Object Fset_window_vscroll (Lisp_Object, Lisp_Object, Lisp_Object);
 
 static void
 run_funs (Lisp_Object funs)
@@ -3325,12 +3330,12 @@ run_window_configuration_change_hook (struct frame *f)
        if (!NILP (Flocal_variable_p (Qwindow_configuration_change_hook,
                                      buffer)))
          {
-           int count = SPECPDL_INDEX ();
+           int count1 = 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 (count, Qnil);
+           unbind_to (count1, Qnil);
          }
       }
   }
@@ -3602,7 +3607,7 @@ select_frame_norecord (Lisp_Object frame)
     ? Fselect_frame (frame, Qt) : selected_frame;
 }
 \f
-Lisp_Object
+static Lisp_Object
 display_buffer (Lisp_Object buffer, Lisp_Object not_this_window_p, Lisp_Object override_frame)
 {
   return call3 (Qdisplay_buffer, buffer, not_this_window_p, override_frame);
@@ -3651,6 +3656,7 @@ displaying that buffer.  */)
   return Qnil;
 }
 
+
 void
 temp_output_buffer_show (register Lisp_Object buf)
 {
@@ -3665,9 +3671,6 @@ temp_output_buffer_show (register Lisp_Object 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 (!NILP (Vtemp_buffer_show_function))
@@ -3687,27 +3690,23 @@ temp_output_buffer_show (register Lisp_Object buf)
 
       /* Run temp-buffer-show-hook, with the chosen window selected
         and its buffer current.  */
-
-      if (!NILP (Vrun_hooks)
-         && !NILP (Fboundp (Qtemp_buffer_show_hook))
-         && !NILP (Fsymbol_value (Qtemp_buffer_show_hook)))
-       {
-         int count = SPECPDL_INDEX ();
-         Lisp_Object prev_window, prev_buffer;
-         prev_window = selected_window;
-         XSETBUFFER (prev_buffer, old);
-
-         /* Select the window that was chosen, for running the hook.
-            Note: Both Fselect_window and select_window_norecord may
-            set-buffer to the buffer displayed in the window,
-            so we need to save the current buffer.  --stef  */
-         record_unwind_protect (Fset_buffer, prev_buffer);
-         record_unwind_protect (select_window_norecord, prev_window);
-         Fselect_window (window, Qt);
-         Fset_buffer (w->buffer);
-         call1 (Vrun_hooks, Qtemp_buffer_show_hook);
-         unbind_to (count, Qnil);
-       }
+      {
+        int count = SPECPDL_INDEX ();
+        Lisp_Object prev_window, prev_buffer;
+        prev_window = selected_window;
+        XSETBUFFER (prev_buffer, old);
+
+        /* Select the window that was chosen, for running the hook.
+           Note: Both Fselect_window and select_window_norecord may
+           set-buffer to the buffer displayed in the window,
+           so we need to save the current buffer.  --stef  */
+        record_unwind_protect (Fset_buffer, prev_buffer);
+        record_unwind_protect (select_window_norecord, prev_window);
+        Fselect_window (window, Qt);
+        Fset_buffer (w->buffer);
+        Frun_hooks (1, &Qtemp_buffer_show_hook);
+        unbind_to (count, Qnil);
+      }
     }
 }
 
@@ -3809,7 +3808,7 @@ See Info node `(elisp)Splitting Windows' for more details and examples.  */)
        error ("Window height %d too small (after splitting)", size_int);
       if (size_int + window_safe_height > XFASTINT (o->total_lines))
        error ("Window height %d too small (after splitting)",
-              XFASTINT (o->total_lines) - size_int);
+              (int) (XFASTINT (o->total_lines) - size_int));
       if (NILP (o->parent)
          || NILP (XWINDOW (o->parent)->vchild))
        {
@@ -3826,7 +3825,7 @@ See Info node `(elisp)Splitting Windows' for more details and examples.  */)
        error ("Window width %d too small (after splitting)", size_int);
       if (size_int + window_safe_width > XFASTINT (o->total_cols))
        error ("Window width %d too small (after splitting)",
-              XFASTINT (o->total_cols) - size_int);
+              (int) (XFASTINT (o->total_cols) - size_int));
       if (NILP (o->parent)
          || NILP (XWINDOW (o->parent)->hchild))
        {
@@ -4128,7 +4127,7 @@ enlarge_window (Lisp_Object window, int delta, int horiz_flag)
        {
          /* If trying to grow this window to or beyond size of the parent,
             just delete all the sibling windows.  */
-         Lisp_Object start, tem, next;
+         Lisp_Object start, tem;
 
          start = XWINDOW (parent)->vchild;
          if (NILP (start))
@@ -4138,9 +4137,9 @@ enlarge_window (Lisp_Object window, int delta, int horiz_flag)
          tem = XWINDOW (window)->next;
          while (! NILP (tem))
            {
-             next = XWINDOW (tem)->next;
+             Lisp_Object next1 = XWINDOW (tem)->next;
              delete_window (tem);
-             tem = next;
+             tem = next1;
            }
 
          /* Delete any siblings that come after WINDOW.
@@ -4149,9 +4148,9 @@ enlarge_window (Lisp_Object window, int delta, int horiz_flag)
          tem = start;
          while (! EQ (tem, window))
            {
-             next = XWINDOW (tem)->next;
+             Lisp_Object next1 = XWINDOW (tem)->next;
              delete_window (tem);
-             tem = next;
+             tem = next1;
            }
        }
       else
@@ -4873,7 +4872,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
             looking at an image that is taller that the window height.  */
          while (start_pos == IT_CHARPOS (it)
                 && start_pos > BEGV)
-           move_it_by_lines (&it, -1, 1);
+           move_it_by_lines (&it, -1);
        }
       else if (dy > 0)
        {
@@ -4883,11 +4882,11 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
             looking at an image that is taller that the window height.  */
          while (start_pos == IT_CHARPOS (it)
                 && start_pos < ZV)
-           move_it_by_lines (&it, 1, 1);
+           move_it_by_lines (&it, 1);
        }
     }
   else
-    move_it_by_lines (&it, n, 1);
+    move_it_by_lines (&it, n);
 
   /* 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
@@ -4998,7 +4997,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
          while (it.current_y < this_scroll_margin)
            {
              int prev = it.current_y;
-             move_it_by_lines (&it, 1, 1);
+             move_it_by_lines (&it, 1);
              if (prev == it.current_y)
                break;
            }
@@ -5032,7 +5031,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
        partial_p = it.current_y + it.ascent + it.descent > it.last_visible_y;
       else
        {
-         move_it_by_lines (&it, 1, 1);
+         move_it_by_lines (&it, 1);
          partial_p = it.current_y > it.last_visible_y;
        }
 
@@ -5059,7 +5058,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
            /* The last line was only partially visible, so back up two
               lines to make sure we're on a fully visible line.  */
            {
-             move_it_by_lines (&it, -2, 0);
+             move_it_by_lines (&it, -2);
              SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
            }
          else
@@ -5529,7 +5528,7 @@ and redisplay normally--don't erase and redraw the frame.  */)
   struct buffer *obuf = current_buffer;
   int center_p = 0;
   EMACS_INT charpos, bytepos;
-  int iarg;
+  int iarg IF_LINT (= 0);
   int this_scroll_margin;
 
   /* If redisplay is suppressed due to an error, try again.  */
@@ -5602,14 +5601,14 @@ and redisplay normally--don't erase and redraw the frame.  */)
          start_display (&it, w, pt);
 
          /* Be sure we have the exact height of the full line containing PT.  */
-         move_it_by_lines (&it, 0, 1);
+         move_it_by_lines (&it, 0);
 
          /* The amount of pixels we have to move back is the window
             height minus what's displayed in the line containing PT,
             and the lines below.  */
          it.current_y = 0;
          it.vpos = 0;
-         move_it_by_lines (&it, nlines, 1);
+         move_it_by_lines (&it, nlines);
 
          if (it.vpos == nlines)
            h -= it.current_y;
@@ -5648,7 +5647,7 @@ and redisplay normally--don't erase and redraw the frame.  */)
          */
          h += extra_line_spacing;
          while (-it.current_y > h)
-           move_it_by_lines (&it, 1, 1);
+           move_it_by_lines (&it, 1);
 
          charpos = IT_CHARPOS (it);
          bytepos = IT_BYTEPOS (it);
@@ -5795,8 +5794,7 @@ zero means top of window, negative means relative to bottom of window.  */)
 
 struct save_window_data
   {
-    EMACS_UINT size;
-    struct Lisp_Vector *next_from_Lisp_Vector_struct;
+    struct vector_header header;
     Lisp_Object selected_frame;
     Lisp_Object current_window;
     Lisp_Object current_buffer;
@@ -5818,10 +5816,7 @@ struct save_window_data
 /* This is saved as a Lisp_Vector  */
 struct saved_window
 {
-  /* these first two must agree with struct Lisp_Vector in lisp.h */
-  EMACS_UINT size;
-  struct Lisp_Vector *next_from_Lisp_Vector_struct;
-
+  struct vector_header header;
   Lisp_Object window;
   Lisp_Object buffer, start, pointm, mark;
   Lisp_Object left_col, top_line, total_cols, total_lines;
@@ -6002,7 +5997,7 @@ the return value is nil.  Otherwise the value is t.  */)
         dead.  */
       delete_all_subwindows (XWINDOW (FRAME_ROOT_WINDOW (f)));
 
-      for (k = 0; k < saved_windows->size; k++)
+      for (k = 0; k < saved_windows->header.size; k++)
        {
          p = SAVED_WINDOW_N (saved_windows, k);
          w = XWINDOW (p->window);
@@ -6615,8 +6610,8 @@ Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS).  */)
                            Scroll bars
  ***********************************************************************/
 
-DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, Sset_window_scroll_bars,
-       2, 4, 0,
+DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars,
+       Sset_window_scroll_bars, 2, 4, 0,
        doc: /* Set width and type of scroll bars of window WINDOW.
 If window is nil, set scroll bars of the currently selected window.
 Second parameter WIDTH specifies the pixel width for the scroll bar;
@@ -6885,10 +6880,10 @@ compare_window_configurations (Lisp_Object c1, Lisp_Object c2, int ignore_positi
     return 0;
 
   /* Verify that the two confis have the same number of windows.  */
-  if (sw1->size != sw2->size)
+  if (sw1->header.size != sw2->header.size)
     return 0;
 
-  for (i = 0; i < sw1->size; i++)
+  for (i = 0; i < sw1->header.size; i++)
     {
       struct saved_window *p1, *p2;
       int w1_is_current, w2_is_current;
@@ -7211,4 +7206,3 @@ keys_of_window (void)
   initial_define_key (meta_map, Ctl ('V'), "scroll-other-window");
   initial_define_key (meta_map, 'v', "scroll-down-command");
 }
-