Make Emacs functions such as Fatom 'static' by default.
[bpt/emacs.git] / src / frame.c
index e663538..6e0e9c4 100644 (file)
@@ -1,8 +1,6 @@
 /* Generic frame functions.
 
-   Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
-  2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-  Free Software Foundation, Inc.
+Copyright (C) 1993-1995, 1997, 1999-2011  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -227,7 +225,7 @@ return values.  */)
          : Qnil);
 }
 
-DEFUN ("window-system", Fwindow_system, Swindow_system, 0, 1, 0,
+DEFUE ("window-system", Fwindow_system, Swindow_system, 0, 1, 0,
        doc: /* The name of the window system that FRAME is displaying through.
 The value is a symbol:
  nil for a termcap frame (a character-only terminal),
@@ -430,20 +428,20 @@ make_frame_without_minibuffer (register Lisp_Object mini_window, KBOARD *kb, Lis
   if (NILP (mini_window))
     {
       /* Use default-minibuffer-frame if possible.  */
-      if (!FRAMEP (kb->Vdefault_minibuffer_frame)
-         || ! FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame)))
+      if (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame))
+         || ! FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame))))
        {
           Lisp_Object frame_dummy;
 
           XSETFRAME (frame_dummy, f);
           GCPRO1 (frame_dummy);
          /* If there's no minibuffer frame to use, create one.  */
-         kb->Vdefault_minibuffer_frame =
+         KVAR (kb, Vdefault_minibuffer_frame) =
            call1 (intern ("make-initial-minibuffer-frame"), display);
           UNGCPRO;
        }
 
-      mini_window = XFRAME (kb->Vdefault_minibuffer_frame)->minibuffer_window;
+      mini_window = XFRAME (KVAR (kb, Vdefault_minibuffer_frame))->minibuffer_window;
     }
 
   f->minibuffer_window = mini_window;
@@ -695,7 +693,7 @@ affects all frames on the same terminal device.  */)
       if (!NILP (tty))
         {
           name = (char *) alloca (SBYTES (tty) + 1);
-          strncpy (name, SDATA (tty), SBYTES (tty));
+          strncpy (name, SSDATA (tty), SBYTES (tty));
           name[SBYTES (tty)] = 0;
         }
 
@@ -706,7 +704,7 @@ affects all frames on the same terminal device.  */)
       if (!NILP (tty_type))
         {
           type = (char *) alloca (SBYTES (tty_type) + 1);
-          strncpy (type, SDATA (tty_type), SBYTES (tty_type));
+          strncpy (type, SSDATA (tty_type), SBYTES (tty_type));
           type[SBYTES (tty_type)] = 0;
         }
 
@@ -858,7 +856,7 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor
   return frame;
 }
 
-DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
+DEFUE ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
        doc: /* Select FRAME.
 Subsequent editing commands apply to its selected window.
 Optional argument NORECORD means to neither change the order of
@@ -891,19 +889,19 @@ to that frame.  */)
   (Lisp_Object event)
 {
   /* Preserve prefix arg that the command loop just cleared.  */
-  current_kboard->Vprefix_arg = Vcurrent_prefix_arg;
-  call1 (Vrun_hooks, Qmouse_leave_buffer_hook);
+  KVAR (current_kboard, Vprefix_arg) = Vcurrent_prefix_arg;
+  Frun_hooks (1, &Qmouse_leave_buffer_hook);
   return do_switch_frame (event, 0, 0, Qnil);
 }
 
-DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
+DEFUE ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
        doc: /* Return the frame that is now selected.  */)
   (void)
 {
   return selected_frame;
 }
 \f
-DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
+DEFUE ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
        doc: /* Return the frame object that window WINDOW is on.  */)
   (Lisp_Object window)
 {
@@ -911,7 +909,7 @@ DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
   return XWINDOW (window)->frame;
 }
 
-DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
+DEFUE ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0,
        doc: /* Returns the topmost, leftmost window of FRAME.
 If omitted, FRAME defaults to the currently selected frame.  */)
   (Lisp_Object frame)
@@ -945,7 +943,7 @@ DEFUN ("active-minibuffer-window", Factive_minibuffer_window,
   return minibuf_level ? minibuf_window : Qnil;
 }
 
-DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
+DEFUE ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0,
        doc: /* Returns the root-window of FRAME.
 If omitted, FRAME defaults to the currently selected frame.  */)
   (Lisp_Object frame)
@@ -982,7 +980,7 @@ FRAME defaults to the currently selected frame.  */)
   return window;
 }
 
-DEFUN ("set-frame-selected-window", Fset_frame_selected_window,
+DEFUE ("set-frame-selected-window", Fset_frame_selected_window,
        Sset_frame_selected_window, 2, 3, 0,
        doc: /* Set selected window of FRAME to WINDOW.
 If FRAME is nil, use the selected frame.  If FRAME is the
@@ -1528,7 +1526,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
   /* If we've deleted this keyboard's default_minibuffer_frame, try to
      find another one.  Prefer minibuffer-only frames, but also notice
      frames with other windows.  */
-  if (kb != NULL && EQ (frame, kb->Vdefault_minibuffer_frame))
+  if (kb != NULL && EQ (frame, KVAR (kb, Vdefault_minibuffer_frame)))
     {
       Lisp_Object frames;
 
@@ -1577,11 +1575,11 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
          if (NILP (frame_with_minibuf))
            abort ();
 
-         kb->Vdefault_minibuffer_frame = frame_with_minibuf;
+         KVAR (kb, Vdefault_minibuffer_frame) = frame_with_minibuf;
        }
       else
        /* No frames left on this kboard--say no minibuffer either.  */
-       kb->Vdefault_minibuffer_frame = Qnil;
+       KVAR (kb, Vdefault_minibuffer_frame) = Qnil;
     }
 
   /* Cause frame titles to update--necessary if we now have just one frame.  */
@@ -1778,7 +1776,7 @@ before calling this function on it, like this.
 \f
 static void make_frame_visible_1 (Lisp_Object);
 
-DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
+DEFUE ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible,
        0, 1, "",
        doc: /* Make the frame FRAME visible (assuming it is an X window).
 If omitted, FRAME defaults to the currently selected frame.  */)
@@ -1819,7 +1817,7 @@ make_frame_visible_1 (Lisp_Object window)
       w = XWINDOW (window);
 
       if (!NILP (w->buffer))
-       XBUFFER (w->buffer)->display_time = Fcurrent_time ();
+       BVAR (XBUFFER (w->buffer), display_time) = Fcurrent_time ();
 
       if (!NILP (w->vchild))
        make_frame_visible_1 (w->vchild);
@@ -1878,7 +1876,7 @@ displayed in the terminal.  */)
   return Qnil;
 }
 
-DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame,
+DEFUE ("iconify-frame", Ficonify_frame, Siconify_frame,
        0, 1, "",
        doc: /* Make the frame FRAME into an icon.
 If omitted, FRAME defaults to the currently selected frame.  */)
@@ -1963,7 +1961,7 @@ DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list,
 }
 
 
-DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "",
+DEFUE ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "",
        doc: /* Bring FRAME to the front, so it occludes any frames it overlaps.
 If FRAME is invisible or iconified, make it visible.
 If you don't specify a frame, the selected frame is used.
@@ -2016,7 +2014,7 @@ doesn't support multiple overlapping frames, this function does nothing.  */)
 }
 
 \f
-DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus,
+DEFUE ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus,
        1, 2, 0,
        doc: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.
 In other words, switch-frame events caused by events in FRAME will
@@ -2178,7 +2176,7 @@ set_term_frame_name (struct frame *f, Lisp_Object name)
 
       /* Check for no change needed in this very common case
         before we do any consing.  */
-      if (frame_name_fnn_p (SDATA (f->name),
+      if (frame_name_fnn_p (SSDATA (f->name),
                            SBYTES (f->name)))
        return;
 
@@ -2196,7 +2194,7 @@ set_term_frame_name (struct frame *f, Lisp_Object name)
 
       /* Don't allow the user to set the frame name to F<num>, so it
         doesn't clash with the names we generate for terminal frames.  */
-      if (frame_name_fnn_p (SDATA (name), SBYTES (name)))
+      if (frame_name_fnn_p (SSDATA (name), SBYTES (name)))
        error ("Frame names of the form F<num> are usurped by Emacs");
     }
 
@@ -2210,15 +2208,23 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
   register Lisp_Object old_alist_elt;
 
   /* The buffer-list parameters are stored in a special place and not
-     in the alist.  */
+     in the alist.  All buffers must be live.  */
   if (EQ (prop, Qbuffer_list))
     {
-      f->buffer_list = val;
+      Lisp_Object list = Qnil;
+      for (; CONSP (val); val = XCDR (val))
+       if (!NILP (Fbuffer_live_p (XCAR (val))))
+         list = Fcons (XCAR (val), list);
+      f->buffer_list = Fnreverse (list);
       return;
     }
   if (EQ (prop, Qburied_buffer_list))
     {
-      f->buried_buffer_list = val;
+      Lisp_Object list = Qnil;
+      for (; CONSP (val); val = XCDR (val))
+       if (!NILP (Fbuffer_live_p (XCAR (val))))
+         list = Fcons (XCAR (val), list);
+      f->buried_buffer_list = Fnreverse (list);
       return;
     }
 
@@ -2323,11 +2329,11 @@ If FRAME is omitted, return information on the currently selected frame.  */)
       elt = Fassq (Qforeground_color, alist);
       if (CONSP (elt) && STRINGP (XCDR (elt)))
        {
-         if (strncmp (SDATA (XCDR (elt)),
+         if (strncmp (SSDATA (XCDR (elt)),
                       unspecified_bg,
                       SCHARS (XCDR (elt))) == 0)
            store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg));
-         else if (strncmp (SDATA (XCDR (elt)),
+         else if (strncmp (SSDATA (XCDR (elt)),
                            unspecified_fg,
                            SCHARS (XCDR (elt))) == 0)
            store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg));
@@ -2337,11 +2343,11 @@ If FRAME is omitted, return information on the currently selected frame.  */)
       elt = Fassq (Qbackground_color, alist);
       if (CONSP (elt) && STRINGP (XCDR (elt)))
        {
-         if (strncmp (SDATA (XCDR (elt)),
+         if (strncmp (SSDATA (XCDR (elt)),
                       unspecified_fg,
                       SCHARS (XCDR (elt))) == 0)
            store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg));
-         else if (strncmp (SDATA (XCDR (elt)),
+         else if (strncmp (SSDATA (XCDR (elt)),
                            unspecified_bg,
                            SCHARS (XCDR (elt))) == 0)
            store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg));
@@ -2386,7 +2392,7 @@ If FRAME is omitted, return information on the currently selected frame.  */)
 }
 
 
-DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0,
+DEFUE ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0,
        doc: /* Return FRAME's value for parameter PARAMETER.
 If FRAME is nil, describe the currently selected frame.  */)
   (Lisp_Object frame, Lisp_Object parameter)
@@ -2430,7 +2436,7 @@ If FRAME is nil, describe the currently selected frame.  */)
 
                  if (EQ (parameter, Qbackground_color))
                    {
-                     color_name = SDATA (value);
+                     color_name = SSDATA (value);
                      csz = SCHARS (value);
                      if (strncmp (color_name, unspecified_bg, csz) == 0)
                        value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f));
@@ -2439,7 +2445,7 @@ If FRAME is nil, describe the currently selected frame.  */)
                    }
                  else if (EQ (parameter, Qforeground_color))
                    {
-                     color_name = SDATA (value);
+                     color_name = SSDATA (value);
                      csz = SCHARS (value);
                      if (strncmp (color_name, unspecified_fg, csz) == 0)
                        value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f));
@@ -2464,7 +2470,7 @@ If FRAME is nil, describe the currently selected frame.  */)
 }
 
 
-DEFUN ("modify-frame-parameters", Fmodify_frame_parameters,
+DEFUE ("modify-frame-parameters", Fmodify_frame_parameters,
        Smodify_frame_parameters, 2, 2, 0,
        doc: /* Modify the parameters of frame FRAME according to ALIST.
 If FRAME is nil, it defaults to the selected frame.
@@ -2523,7 +2529,7 @@ use is not recommended.  Explicitly check for a frame-parameter instead.  */)
        }
 
       /* Now process them in reverse of specified order.  */
-      for (i--; i >= 0; i--)
+      while (--i >= 0)
        {
          prop = parms[i];
          val = values[i];
@@ -2896,7 +2902,7 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist)
   /* Record in these vectors all the parms specified.  */
   Lisp_Object *parms;
   Lisp_Object *values;
-  int i, p;
+  size_t i, p;
   int left_no_change = 0, top_no_change = 0;
   int icon_left_no_change = 0, icon_top_no_change = 0;
   int size_changed = 0;
@@ -2969,7 +2975,7 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist)
     }
 
   /* Now process them in reverse of specified order.  */
-  for (i--; i >= 0; i--)
+  while (i-- != 0)
     {
       Lisp_Object prop, val;
 
@@ -3277,12 +3283,12 @@ x_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
   bgcolor = Fassq (Qbackground_color, f->param_alist);
   if (CONSP (bgcolor) && (bgcolor = XCDR (bgcolor), STRINGP (bgcolor)))
     {
-      Lisp_Object index = Fget (Qbackground_color, Qx_frame_parameter);
-      if (NATNUMP (index)
-         && (XFASTINT (index)
+      Lisp_Object parm_index = Fget (Qbackground_color, Qx_frame_parameter);
+      if (NATNUMP (parm_index)
+         && (XFASTINT (parm_index)
              < sizeof (frame_parms)/sizeof (frame_parms[0]))
-         && FRAME_RIF (f)->frame_parm_handlers[XFASTINT (index)])
-         (*FRAME_RIF (f)->frame_parm_handlers[XFASTINT (index)])
+         && FRAME_RIF (f)->frame_parm_handlers[XFASTINT (parm_index)])
+         (*FRAME_RIF (f)->frame_parm_handlers[XFASTINT (parm_index)])
            (f, bgcolor, Qnil);
     }
 
@@ -3309,16 +3315,16 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
       fontset = fs_query_fontset (arg, 0);
       if (fontset < 0)
        {
-         font_object = font_open_by_name (f, SDATA (arg));
+         font_object = font_open_by_name (f, SSDATA (arg));
          if (NILP (font_object))
-           error ("Font `%s' is not defined", SDATA (arg));
+           error ("Font `%s' is not defined", SSDATA (arg));
          arg = AREF (font_object, FONT_NAME_INDEX);
        }
       else if (fontset > 0)
        {
          Lisp_Object ascii_font = fontset_ascii (fontset);
 
-         font_object = font_open_by_name (f, SDATA (ascii_font));
+         font_object = font_open_by_name (f, SSDATA (ascii_font));
          if (NILP (font_object))
            error ("Font `%s' is not defined", SDATA (arg));
          arg = AREF (font_object, FONT_NAME_INDEX);
@@ -3396,7 +3402,7 @@ x_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
       char *p0, *p1;
 
       CHECK_STRING (new_value);
-      p0 = p1 = SDATA (new_value);
+      p0 = p1 = SSDATA (new_value);
       new_value = Qnil;
       while (*p0)
        {
@@ -3707,8 +3713,7 @@ validate_x_resource_name (void)
     return;
 
   /* If name is entirely invalid, or nearly so, use `emacs'.  */
-  if (good_count == 0
-      || (good_count == 1 && bad_count > 0))
+  if (good_count < 2)
     {
       Vx_resource_name = build_string ("emacs");
       return;
@@ -3773,23 +3778,23 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li
 
   /* Start with emacs.FRAMENAME for the name (the specific one)
      and with `Emacs' for the class key (the general one).  */
-  strcpy (name_key, SDATA (Vx_resource_name));
-  strcpy (class_key, SDATA (Vx_resource_class));
+  strcpy (name_key, SSDATA (Vx_resource_name));
+  strcpy (class_key, SSDATA (Vx_resource_class));
 
   strcat (class_key, ".");
-  strcat (class_key, SDATA (class));
+  strcat (class_key, SSDATA (class));
 
   if (!NILP (component))
     {
       strcat (class_key, ".");
-      strcat (class_key, SDATA (subclass));
+      strcat (class_key, SSDATA (subclass));
 
       strcat (name_key, ".");
-      strcat (name_key, SDATA (component));
+      strcat (name_key, SSDATA (component));
     }
 
   strcat (name_key, ".");
-  strcat (name_key, SDATA (attribute));
+  strcat (name_key, SSDATA (attribute));
 
   value = x_get_string_resource (rdb, name_key, class_key);
 
@@ -3906,25 +3911,25 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
          switch (type)
            {
            case RES_TYPE_NUMBER:
-             return make_number (atoi (SDATA (tem)));
+             return make_number (atoi (SSDATA (tem)));
 
            case RES_TYPE_BOOLEAN_NUMBER:
-             if (!strcmp (SDATA (tem), "on")
-                 || !strcmp (SDATA (tem), "true"))
+             if (!strcmp (SSDATA (tem), "on")
+                 || !strcmp (SSDATA (tem), "true"))
                return make_number (1);
-             return make_number (atoi (SDATA (tem)));
+             return make_number (atoi (SSDATA (tem)));
               break;
 
            case RES_TYPE_FLOAT:
-             return make_float (atof (SDATA (tem)));
+             return make_float (atof (SSDATA (tem)));
 
            case RES_TYPE_BOOLEAN:
              tem = Fdowncase (tem);
-             if (!strcmp (SDATA (tem), "on")
+             if (!strcmp (SSDATA (tem), "on")
 #ifdef HAVE_NS
-                  || !strcmp(SDATA(tem), "yes")
+                  || !strcmp (SSDATA (tem), "yes")
 #endif
-                 || !strcmp (SDATA (tem), "true"))
+                 || !strcmp (SSDATA (tem), "true"))
                return Qt;
              else
                return Qnil;
@@ -3938,17 +3943,17 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
              {
                Lisp_Object lower;
                lower = Fdowncase (tem);
-               if (!strcmp (SDATA (lower), "on")
+               if (!strcmp (SSDATA (lower), "on")
 #ifdef HAVE_NS
-                    || !strcmp(SDATA(lower), "yes")
+                    || !strcmp (SSDATA (lower), "yes")
 #endif
-                   || !strcmp (SDATA (lower), "true"))
+                   || !strcmp (SSDATA (lower), "true"))
                  return Qt;
-               else if (!strcmp (SDATA (lower), "off")
+               else if (!strcmp (SSDATA (lower), "off")
 #ifdef HAVE_NS
-                      || !strcmp(SDATA(lower), "no")
+                      || !strcmp (SSDATA (lower), "no")
 #endif
-                     || !strcmp (SDATA (lower), "false"))
+                     || !strcmp (SSDATA (lower), "false"))
                  return Qnil;
                else
                  return Fintern (tem, Qnil);