]> code.delx.au - gnu-emacs/blobdiff - src/frame.c
ecomplete.el (ecomplete-display-matches): Intercept key sequence from terminal as...
[gnu-emacs] / src / frame.c
index 74e222f85fce3e2c02b1b489e7d599d5227dcfab..112f102a1f262960fdc44e578936537966f33866 100644 (file)
@@ -135,11 +135,6 @@ set_menu_bar_lines_1 (Lisp_Object window, int n)
   XSETFASTINT (w->top_line, XFASTINT (w->top_line) + n);
   XSETFASTINT (w->total_lines, XFASTINT (w->total_lines) - n);
 
-  if (INTEGERP (w->orig_top_line))
-    XSETFASTINT (w->orig_top_line, XFASTINT (w->orig_top_line) + n);
-  if (INTEGERP (w->orig_total_lines))
-    XSETFASTINT (w->orig_total_lines, XFASTINT (w->orig_total_lines) - n);
-
   /* Handle just the top child in a vertical split.  */
   if (!NILP (w->vchild))
     set_menu_bar_lines_1 (w->vchild, n);
@@ -165,7 +160,7 @@ set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
   if (FRAME_MINIBUF_ONLY_P (f))
     return;
 
-  if (INTEGERP (value))
+  if (TYPE_RANGED_INTEGERP (int, value))
     nlines = XINT (value);
   else
     nlines = 0;
@@ -375,7 +370,7 @@ make_frame (int mini_p)
     /* If buf is a 'hidden' buffer (i.e. one whose name starts with
        a space), try to find another one.  */
     if (SREF (Fbuffer_name (buf), 0) == ' ')
-      buf = Fother_buffer (buf, Qnil, Qnil);
+      buf = other_buffer_safely (buf);
 
     /* Use set_window_buffer, not Fset_window_buffer, and don't let
        hooks be run by it.  The reason is that the whole frame/window
@@ -502,7 +497,7 @@ make_minibuffer_frame (void)
 \f
 /* Construct a frame that refers to a terminal.  */
 
-static int tty_frame_count;
+static printmax_t tty_frame_count;
 
 struct frame *
 make_initial_frame (void)
@@ -544,10 +539,8 @@ make_initial_frame (void)
   /* The default value of menu-bar-mode is t.  */
   set_menu_bar_lines (f, make_number (1), Qnil);
 
-#ifdef CANNOT_DUMP
   if (!noninteractive)
     init_frame_faces (f);
-#endif
 
   return f;
 }
@@ -558,7 +551,7 @@ make_terminal_frame (struct terminal *terminal)
 {
   register struct frame *f;
   Lisp_Object frame;
-  char name[20];
+  char name[sizeof "F" + INT_STRLEN_BOUND (printmax_t)];
 
   if (!terminal->name)
     error ("Terminal is not live, can't create new frames on it");
@@ -569,7 +562,7 @@ make_terminal_frame (struct terminal *terminal)
   Vframe_list = Fcons (frame, Vframe_list);
 
   tty_frame_count++;
-  sprintf (name, "F%d", tty_frame_count);
+  sprintf (name, "F%"pMd, tty_frame_count);
   f->name = build_string (name);
 
   f->visible = 1;              /* FRAME_SET_VISIBLE wd set frame_garbaged. */
@@ -905,111 +898,6 @@ DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
 {
   return selected_frame;
 }
-\f
-DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0,
-       doc: /* Return the frame object that window WINDOW is on.  */)
-  (Lisp_Object window)
-{
-  CHECK_LIVE_WINDOW (window);
-  return XWINDOW (window)->frame;
-}
-
-DEFUN ("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)
-{
-  Lisp_Object w;
-
-  if (NILP (frame))
-    w = SELECTED_FRAME ()->root_window;
-  else
-    {
-      CHECK_LIVE_FRAME (frame);
-      w = XFRAME (frame)->root_window;
-    }
-  while (NILP (XWINDOW (w)->buffer))
-    {
-      if (! NILP (XWINDOW (w)->hchild))
-       w = XWINDOW (w)->hchild;
-      else if (! NILP (XWINDOW (w)->vchild))
-       w = XWINDOW (w)->vchild;
-      else
-       abort ();
-    }
-  return w;
-}
-
-DEFUN ("active-minibuffer-window", Factive_minibuffer_window,
-       Sactive_minibuffer_window, 0, 0, 0,
-       doc: /* Return the currently active minibuffer window, or nil if none.  */)
-  (void)
-{
-  return minibuf_level ? minibuf_window : Qnil;
-}
-
-DEFUN ("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)
-{
-  Lisp_Object window;
-
-  if (NILP (frame))
-    window = SELECTED_FRAME ()->root_window;
-  else
-    {
-      CHECK_LIVE_FRAME (frame);
-      window = XFRAME (frame)->root_window;
-    }
-
-  return window;
-}
-
-DEFUN ("frame-selected-window", Fframe_selected_window,
-       Sframe_selected_window, 0, 1, 0,
-       doc: /* Return the selected window of FRAME.
-FRAME defaults to the currently selected frame.  */)
-  (Lisp_Object frame)
-{
-  Lisp_Object window;
-
-  if (NILP (frame))
-    window = SELECTED_FRAME ()->selected_window;
-  else
-    {
-      CHECK_LIVE_FRAME (frame);
-      window = XFRAME (frame)->selected_window;
-    }
-
-  return window;
-}
-
-DEFUN ("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
-selected frame, this makes WINDOW the selected window.
-Optional argument NORECORD non-nil means to neither change the
-order of recently selected windows nor the buffer list.
-Return WINDOW.  */)
-  (Lisp_Object frame, Lisp_Object window, Lisp_Object norecord)
-{
-  if (NILP (frame))
-    frame = selected_frame;
-
-  CHECK_LIVE_FRAME (frame);
-  CHECK_LIVE_WINDOW (window);
-
-  if (! EQ (frame, WINDOW_FRAME (XWINDOW (window))))
-    error ("In `set-frame-selected-window', WINDOW is not on FRAME");
-
-  if (EQ (frame, selected_frame))
-    return Fselect_window (window, norecord);
-
-  return XFRAME (frame)->selected_window = window;
-}
-
 \f
 DEFUN ("frame-list", Fframe_list, Sframe_list,
        0, 0, 0,
@@ -1227,7 +1115,7 @@ Otherwise, include all frames.  */)
    0 if all frames aside from F are invisible.
    (Exception: if F is the terminal frame, and we are using X, return 1.)  */
 
-int
+static int
 other_visible_frames (FRAME_PTR f)
 {
   /* We know the selected frame is visible,
@@ -1432,7 +1320,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
 
   /* Mark all the windows that used to be on FRAME as deleted, and then
      remove the reference to them.  */
-  delete_all_subwindows (XWINDOW (f->root_window));
+  delete_all_subwindows (f->root_window);
   f->root_window = Qnil;
 
   Vframe_list = Fdelq (frame, Vframe_list);
@@ -2113,20 +2001,12 @@ frame_buffer_predicate (Lisp_Object frame)
 
 /* Return the buffer-list of the selected frame.  */
 
-Lisp_Object
+static Lisp_Object
 frame_buffer_list (Lisp_Object frame)
 {
   return XFRAME (frame)->buffer_list;
 }
 
-/* Set the buffer-list of the selected frame.  */
-
-void
-set_frame_buffer_list (Lisp_Object frame, Lisp_Object list)
-{
-  XFRAME (frame)->buffer_list = list;
-}
-
 /* Discard BUFFER from the buffer-list and buried-buffer-list of each frame.  */
 
 void
@@ -2183,7 +2063,7 @@ set_term_frame_name (struct frame *f, Lisp_Object name)
   /* If NAME is nil, set the name to F<num>.  */
   if (NILP (name))
     {
-      char namebuf[20];
+      char namebuf[sizeof "F" + INT_STRLEN_BOUND (printmax_t)];
 
       /* Check for no change needed in this very common case
         before we do any consing.  */
@@ -2192,7 +2072,7 @@ set_term_frame_name (struct frame *f, Lisp_Object name)
        return;
 
       tty_frame_count++;
-      sprintf (namebuf, "F%d", tty_frame_count);
+      sprintf (namebuf, "F%"pMd, tty_frame_count);
       name = build_string (namebuf);
     }
   else
@@ -2546,11 +2426,9 @@ use is not recommended.  Explicitly check for a frame-parameter instead.  */)
          val = values[i];
          store_frame_param (f, prop, val);
 
-         /* Changing the background color might change the background
-            mode, so that we have to load new defface specs.
-            Call frame-set-background-mode to do that.  */
-         if (EQ (prop, Qbackground_color))
-           call1 (Qframe_set_background_mode, frame);
+         if (EQ (prop, Qforeground_color)
+             || EQ (prop, Qbackground_color))
+           update_face_from_frame_parameter (f, prop, val);
        }
     }
   return Qnil;
@@ -2916,7 +2794,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;
-  size_t i, p;
+  ptrdiff_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;
@@ -3103,7 +2981,7 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist)
        f->size_hint_flags &= ~ (XNegative | YNegative);
        if (EQ (left, Qminus))
          f->size_hint_flags |= XNegative;
-       else if (INTEGERP (left))
+       else if (TYPE_RANGED_INTEGERP (int, left))
          {
            leftpos = XINT (left);
            if (leftpos < 0)
@@ -3111,21 +2989,21 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist)
          }
        else if (CONSP (left) && EQ (XCAR (left), Qminus)
                 && CONSP (XCDR (left))
-                && INTEGERP (XCAR (XCDR (left))))
+                && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (left)), INT_MAX))
          {
            leftpos = - XINT (XCAR (XCDR (left)));
            f->size_hint_flags |= XNegative;
          }
        else if (CONSP (left) && EQ (XCAR (left), Qplus)
                 && CONSP (XCDR (left))
-                && INTEGERP (XCAR (XCDR (left))))
+                && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (left))))
          {
            leftpos = XINT (XCAR (XCDR (left)));
          }
 
        if (EQ (top, Qminus))
          f->size_hint_flags |= YNegative;
-       else if (INTEGERP (top))
+       else if (TYPE_RANGED_INTEGERP (int, top))
          {
            toppos = XINT (top);
            if (toppos < 0)
@@ -3133,14 +3011,14 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist)
          }
        else if (CONSP (top) && EQ (XCAR (top), Qminus)
                 && CONSP (XCDR (top))
-                && INTEGERP (XCAR (XCDR (top))))
+                && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (top)), INT_MAX))
          {
            toppos = - XINT (XCAR (XCDR (top)));
            f->size_hint_flags |= YNegative;
          }
        else if (CONSP (top) && EQ (XCAR (top), Qplus)
                 && CONSP (XCDR (top))
-                && INTEGERP (XCAR (XCDR (top))))
+                && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (top))))
          {
            toppos = XINT (XCAR (XCDR (top)));
          }
@@ -3176,6 +3054,7 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
 {
   char buf[16];
   Lisp_Object tem;
+  unsigned long w;
 
   /* Represent negative positions (off the top or left screen edge)
      in a way that Fmodify_frame_parameters will understand correctly.  */
@@ -3208,7 +3087,12 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
                      for non-toolkit scroll bar.
                      ruler-mode.el depends on this.  */
                   : Qnil));
-  sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f));
+  /* FRAME_X_WINDOW is not guaranteed to return an integer.  E.g., on
+     MS-Windows it returns a value whose type is HANDLE, which is
+     actually a pointer.  Explicit casting avoids compiler
+     warnings.  */
+  w = (unsigned long) FRAME_X_WINDOW (f);
+  sprintf (buf, "%lu", w);
   store_in_alist (alistptr, Qwindow_id,
                  build_string (buf));
 #ifdef HAVE_X_WINDOWS
@@ -3216,7 +3100,10 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
   /* Tooltip frame may not have this widget.  */
   if (FRAME_X_OUTPUT (f)->widget)
 #endif
-    sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f));
+    {
+      w = (unsigned long) FRAME_OUTER_WINDOW (f);
+      sprintf (buf, "%lu", w);
+    }
   store_in_alist (alistptr, Qouter_window_id,
                  build_string (buf));
 #endif
@@ -3592,7 +3479,7 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
         x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
       do_pending_window_change (0);
     }
-  else if (INTEGERP (arg) && XINT (arg) > 0
+  else if (RANGED_INTEGERP (1, arg, INT_MAX)
           && XFASTINT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
     {
       if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
@@ -3631,7 +3518,7 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   double alpha = 1.0;
   double newval[2];
-  int i, ialpha;
+  int i;
   Lisp_Object item;
 
   for (i = 0; i < 2; i++)
@@ -3655,7 +3542,7 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
        }
       else if (INTEGERP (item))
        {
-         ialpha = XINT (item);
+         EMACS_INT ialpha = XINT (item);
          if (ialpha < 0 || 100 < ialpha)
            args_out_of_range (make_number (0), make_number (100));
          else
@@ -3687,13 +3574,13 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 void
 validate_x_resource_name (void)
 {
-  int len = 0;
+  ptrdiff_t len = 0;
   /* Number of valid characters in the resource name.  */
-  int good_count = 0;
+  ptrdiff_t good_count = 0;
   /* Number of invalid characters in the resource name.  */
-  int bad_count = 0;
+  ptrdiff_t bad_count = 0;
   Lisp_Object new;
-  int i;
+  ptrdiff_t i;
 
   if (!STRINGP (Vx_resource_class))
     Vx_resource_class = build_string (EMACS_CLASS);
@@ -3726,8 +3613,9 @@ validate_x_resource_name (void)
   if (bad_count == 0)
     return;
 
-  /* If name is entirely invalid, or nearly so, use `emacs'.  */
-  if (good_count < 2)
+  /* If name is entirely invalid, or nearly so, or is so implausibly
+     large that alloca might not work, use `emacs'.  */
+  if (good_count < 2 || MAX_ALLOCA - sizeof ".customization" < len)
     {
       Vx_resource_name = build_string ("emacs");
       return;
@@ -3856,20 +3744,24 @@ x_get_resource_string (const char *attribute, const char *class)
 {
   char *name_key;
   char *class_key;
+  char *result;
   struct frame *sf = SELECTED_FRAME ();
+  ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name);
+  USE_SAFE_ALLOCA;
 
   /* Allocate space for the components, the dots which separate them,
      and the final '\0'.  */
-  name_key = (char *) alloca (SBYTES (Vinvocation_name)
-                             + strlen (attribute) + 2);
+  SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2);
   class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
                               + strlen (class) + 2);
 
-  sprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
+  esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
   sprintf (class_key, "%s.%s", EMACS_CLASS, class);
 
-  return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
-                               name_key, class_key);
+  result = x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,
+                                 name_key, class_key);
+  SAFE_FREE ();
+  return result;
 }
 #endif
 
@@ -4142,11 +4034,15 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p)
       if (!EQ (tem0, Qunbound))
        {
          CHECK_NUMBER (tem0);
+         if (! (0 <= XINT (tem0) && XINT (tem0) <= INT_MAX))
+           xsignal1 (Qargs_out_of_range, tem0);
          FRAME_LINES (f) = XINT (tem0);
        }
       if (!EQ (tem1, Qunbound))
        {
          CHECK_NUMBER (tem1);
+         if (! (0 <= XINT (tem1) && XINT (tem1) <= INT_MAX))
+           xsignal1 (Qargs_out_of_range, tem1);
          SET_FRAME_COLS (f, XINT (tem1));
        }
       if (!NILP (tem2) && !EQ (tem2, Qunbound))
@@ -4177,12 +4073,10 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p)
                ? tool_bar_button_relief
                : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
 
-      if (INTEGERP (Vtool_bar_button_margin)
-         && XINT (Vtool_bar_button_margin) > 0)
+      if (RANGED_INTEGERP (1, Vtool_bar_button_margin, INT_MAX))
        margin = XFASTINT (Vtool_bar_button_margin);
       else if (CONSP (Vtool_bar_button_margin)
-              && INTEGERP (XCDR (Vtool_bar_button_margin))
-              && XINT (XCDR (Vtool_bar_button_margin)) > 0)
+              && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin), INT_MAX))
        margin = XFASTINT (XCDR (Vtool_bar_button_margin));
       else
        margin = 0;
@@ -4208,14 +4102,14 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p)
        }
       else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)
               && CONSP (XCDR (tem0))
-              && INTEGERP (XCAR (XCDR (tem0))))
+              && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (tem0)), INT_MAX))
        {
          f->top_pos = - XINT (XCAR (XCDR (tem0)));
          window_prompting |= YNegative;
        }
       else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)
               && CONSP (XCDR (tem0))
-              && INTEGERP (XCAR (XCDR (tem0))))
+              && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem0))))
        {
          f->top_pos = XINT (XCAR (XCDR (tem0)));
        }
@@ -4236,14 +4130,14 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, int toolbar_p)
        }
       else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)
               && CONSP (XCDR (tem1))
-              && INTEGERP (XCAR (XCDR (tem1))))
+              && RANGED_INTEGERP (-INT_MAX, XCAR (XCDR (tem1)), INT_MAX))
        {
          f->left_pos = - XINT (XCAR (XCDR (tem1)));
          window_prompting |= XNegative;
        }
       else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)
               && CONSP (XCDR (tem1))
-              && INTEGERP (XCAR (XCDR (tem1))))
+              && TYPE_RANGED_INTEGERP (int, XCAR (XCDR (tem1))))
        {
          f->left_pos = XINT (XCAR (XCDR (tem1)));
        }
@@ -4349,104 +4243,58 @@ selected frame.  This is useful when `make-pointer-invisible' is set.  */)
 void
 syms_of_frame (void)
 {
-  Qframep = intern_c_string ("framep");
-  staticpro (&Qframep);
-  Qframe_live_p = intern_c_string ("frame-live-p");
-  staticpro (&Qframe_live_p);
-  Qexplicit_name = intern_c_string ("explicit-name");
-  staticpro (&Qexplicit_name);
-  Qheight = intern_c_string ("height");
-  staticpro (&Qheight);
-  Qicon = intern_c_string ("icon");
-  staticpro (&Qicon);
-  Qminibuffer = intern_c_string ("minibuffer");
-  staticpro (&Qminibuffer);
-  Qmodeline = intern_c_string ("modeline");
-  staticpro (&Qmodeline);
-  Qonly = intern_c_string ("only");
-  staticpro (&Qonly);
-  Qwidth = intern_c_string ("width");
-  staticpro (&Qwidth);
-  Qgeometry = intern_c_string ("geometry");
-  staticpro (&Qgeometry);
-  Qicon_left = intern_c_string ("icon-left");
-  staticpro (&Qicon_left);
-  Qicon_top = intern_c_string ("icon-top");
-  staticpro (&Qicon_top);
-  Qtooltip = intern_c_string ("tooltip");
-  staticpro (&Qtooltip);
-  Qleft = intern_c_string ("left");
-  staticpro (&Qleft);
-  Qright = intern_c_string ("right");
-  staticpro (&Qright);
-  Quser_position = intern_c_string ("user-position");
-  staticpro (&Quser_position);
-  Quser_size = intern_c_string ("user-size");
-  staticpro (&Quser_size);
-  Qwindow_id = intern_c_string ("window-id");
-  staticpro (&Qwindow_id);
+  DEFSYM (Qframep, "framep");
+  DEFSYM (Qframe_live_p, "frame-live-p");
+  DEFSYM (Qexplicit_name, "explicit-name");
+  DEFSYM (Qheight, "height");
+  DEFSYM (Qicon, "icon");
+  DEFSYM (Qminibuffer, "minibuffer");
+  DEFSYM (Qmodeline, "modeline");
+  DEFSYM (Qonly, "only");
+  DEFSYM (Qwidth, "width");
+  DEFSYM (Qgeometry, "geometry");
+  DEFSYM (Qicon_left, "icon-left");
+  DEFSYM (Qicon_top, "icon-top");
+  DEFSYM (Qtooltip, "tooltip");
+  DEFSYM (Qleft, "left");
+  DEFSYM (Qright, "right");
+  DEFSYM (Quser_position, "user-position");
+  DEFSYM (Quser_size, "user-size");
+  DEFSYM (Qwindow_id, "window-id");
 #ifdef HAVE_X_WINDOWS
-  Qouter_window_id = intern_c_string ("outer-window-id");
-  staticpro (&Qouter_window_id);
+  DEFSYM (Qouter_window_id, "outer-window-id");
 #endif
-  Qparent_id = intern_c_string ("parent-id");
-  staticpro (&Qparent_id);
-  Qx = intern_c_string ("x");
-  staticpro (&Qx);
-  Qw32 = intern_c_string ("w32");
-  staticpro (&Qw32);
-  Qpc = intern_c_string ("pc");
-  staticpro (&Qpc);
-  Qmac = intern_c_string ("mac");
-  staticpro (&Qmac);
-  Qns = intern_c_string ("ns");
-  staticpro (&Qns);
-  Qvisible = intern_c_string ("visible");
-  staticpro (&Qvisible);
-  Qbuffer_predicate = intern_c_string ("buffer-predicate");
-  staticpro (&Qbuffer_predicate);
-  Qbuffer_list = intern_c_string ("buffer-list");
-  staticpro (&Qbuffer_list);
-  Qburied_buffer_list = intern_c_string ("buried-buffer-list");
-  staticpro (&Qburied_buffer_list);
-  Qdisplay_type = intern_c_string ("display-type");
-  staticpro (&Qdisplay_type);
-  Qbackground_mode = intern_c_string ("background-mode");
-  staticpro (&Qbackground_mode);
-  Qnoelisp = intern_c_string ("noelisp");
-  staticpro (&Qnoelisp);
-  Qtty_color_mode = intern_c_string ("tty-color-mode");
-  staticpro (&Qtty_color_mode);
-  Qtty = intern_c_string ("tty");
-  staticpro (&Qtty);
-  Qtty_type = intern_c_string ("tty-type");
-  staticpro (&Qtty_type);
-
-  Qface_set_after_frame_default = intern_c_string ("face-set-after-frame-default");
-  staticpro (&Qface_set_after_frame_default);
-
-  Qfullwidth = intern_c_string ("fullwidth");
-  staticpro (&Qfullwidth);
-  Qfullheight = intern_c_string ("fullheight");
-  staticpro (&Qfullheight);
-  Qfullboth = intern_c_string ("fullboth");
-  staticpro (&Qfullboth);
-  Qmaximized = intern_c_string ("maximized");
-  staticpro (&Qmaximized);
-  Qx_resource_name = intern_c_string ("x-resource-name");
-  staticpro (&Qx_resource_name);
-
-  Qx_frame_parameter = intern_c_string ("x-frame-parameter");
-  staticpro (&Qx_frame_parameter);
-
-  Qterminal = intern_c_string ("terminal");
-  staticpro (&Qterminal);
-  Qterminal_live_p = intern_c_string ("terminal-live-p");
-  staticpro (&Qterminal_live_p);
+  DEFSYM (Qparent_id, "parent-id");
+  DEFSYM (Qx, "x");
+  DEFSYM (Qw32, "w32");
+  DEFSYM (Qpc, "pc");
+  DEFSYM (Qmac, "mac");
+  DEFSYM (Qns, "ns");
+  DEFSYM (Qvisible, "visible");
+  DEFSYM (Qbuffer_predicate, "buffer-predicate");
+  DEFSYM (Qbuffer_list, "buffer-list");
+  DEFSYM (Qburied_buffer_list, "buried-buffer-list");
+  DEFSYM (Qdisplay_type, "display-type");
+  DEFSYM (Qbackground_mode, "background-mode");
+  DEFSYM (Qnoelisp, "noelisp");
+  DEFSYM (Qtty_color_mode, "tty-color-mode");
+  DEFSYM (Qtty, "tty");
+  DEFSYM (Qtty_type, "tty-type");
+
+  DEFSYM (Qface_set_after_frame_default, "face-set-after-frame-default");
+
+  DEFSYM (Qfullwidth, "fullwidth");
+  DEFSYM (Qfullheight, "fullheight");
+  DEFSYM (Qfullboth, "fullboth");
+  DEFSYM (Qmaximized, "maximized");
+  DEFSYM (Qx_resource_name, "x-resource-name");
+  DEFSYM (Qx_frame_parameter, "x-frame-parameter");
+
+  DEFSYM (Qterminal, "terminal");
+  DEFSYM (Qterminal_live_p, "terminal-live-p");
 
 #ifdef HAVE_NS
-  Qns_parse_geometry = intern_c_string ("ns-parse-geometry");
-  staticpro (&Qns_parse_geometry);
+  DEFSYM (Qns_parse_geometry, "ns-parse-geometry");
 #endif
 
   {
@@ -4515,7 +4363,7 @@ Setting this variable does not affect existing frames, only new ones.  */);
   DEFVAR_LISP ("default-frame-scroll-bars", Vdefault_frame_scroll_bars,
               doc: /* Default position of scroll bars on this window-system.  */);
 #ifdef HAVE_WINDOW_SYSTEM
-#if defined(HAVE_NTGUI) || defined(NS_IMPL_COCOA) || (defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS))
+#if defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA) || (defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS))
   /* MS-Windows, Mac OS X, and GTK have scroll bars on the right by
      default.  */
   Vdefault_frame_scroll_bars = Qright;
@@ -4560,8 +4408,7 @@ actually deleted, or some time later (or even both when an earlier function
 in `delete-frame-functions' (indirectly) calls `delete-frame'
 recursively).  */);
   Vdelete_frame_functions = Qnil;
-  Qdelete_frame_functions = intern_c_string ("delete-frame-functions");
-  staticpro (&Qdelete_frame_functions);
+  DEFSYM (Qdelete_frame_functions, "delete-frame-functions");
 
   DEFVAR_LISP ("menu-bar-mode", Vmenu_bar_mode,
                doc: /* Non-nil if Menu-Bar mode is enabled.
@@ -4607,7 +4454,6 @@ automatically.  See also `mouse-autoselect-window'.  */);
 
   staticpro (&Vframe_list);
 
-  defsubr (&Sactive_minibuffer_window);
   defsubr (&Sframep);
   defsubr (&Sframe_live_p);
   defsubr (&Swindow_system);
@@ -4615,11 +4461,6 @@ automatically.  See also `mouse-autoselect-window'.  */);
   defsubr (&Shandle_switch_frame);
   defsubr (&Sselect_frame);
   defsubr (&Sselected_frame);
-  defsubr (&Swindow_frame);
-  defsubr (&Sframe_root_window);
-  defsubr (&Sframe_first_window);
-  defsubr (&Sframe_selected_window);
-  defsubr (&Sset_frame_selected_window);
   defsubr (&Sframe_list);
   defsubr (&Snext_frame);
   defsubr (&Sprevious_frame);