Use INTERNAL_FIELD for symbols.
[bpt/emacs.git] / src / keyboard.c
index 9f3bc47..d14d510 100644 (file)
@@ -800,7 +800,7 @@ This function is called by the editor initialization to begin editing.  */)
   update_mode_lines = 1;
 
   if (command_loop_level
-      && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer))
+      && current_buffer != XBUFFER (WVAR (XWINDOW (selected_window), buffer)))
     buffer = Fcurrent_buffer ();
   else
     buffer = Qnil;
@@ -1382,8 +1382,8 @@ command_loop_1 (void)
        Fkill_emacs (Qnil);
 
       /* Make sure the current window's buffer is selected.  */
-      if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer)
-       set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
+      if (XBUFFER (WVAR (XWINDOW (selected_window), buffer)) != current_buffer)
+       set_buffer_internal (XBUFFER (WVAR (XWINDOW (selected_window), buffer)));
 
       /* Display any malloc warning that just came out.  Use while because
         displaying one warning can cause another.  */
@@ -1452,8 +1452,8 @@ command_loop_1 (void)
       /* A filter may have run while we were reading the input.  */
       if (! FRAME_LIVE_P (XFRAME (selected_frame)))
        Fkill_emacs (Qnil);
-      if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer)
-       set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
+      if (XBUFFER (WVAR (XWINDOW (selected_window), buffer)) != current_buffer)
+       set_buffer_internal (XBUFFER (WVAR (XWINDOW (selected_window), buffer)));
 
       ++num_input_keys;
 
@@ -1484,7 +1484,7 @@ command_loop_1 (void)
        {
          struct buffer *b;
          XWINDOW (selected_window)->force_start = 0;
-         b = XBUFFER (XWINDOW (selected_window)->buffer);
+         b = XBUFFER (WVAR (XWINDOW (selected_window), buffer));
          BUF_BEG_UNCHANGED (b) = BUF_END_UNCHANGED (b) = 0;
        }
 
@@ -2185,14 +2185,7 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object,
   if (!NILP (help) && !STRINGP (help))
     {
       if (FUNCTIONP (help))
-       {
-         Lisp_Object args[4];
-         args[0] = help;
-         args[1] = window;
-         args[2] = object;
-         args[3] = pos;
-         help = safe_call (4, args);
-       }
+       help = safe_call (4, help, window, object, pos);
       else
        help = safe_eval (help);
 
@@ -2705,17 +2698,13 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
              && ! CONSP (Vunread_command_events))
            {
              Fdo_auto_save (Qnil, Qnil);
-
-             /* If we have auto-saved and there is still no input
-                available, garbage collect if there has been enough
-                consing going on to make it worthwhile.  */
-             if (!detect_input_pending_run_timers (0)
-                 && consing_since_gc > gc_cons_threshold / 2)
-               Fgarbage_collect ();
-
              redisplay ();
            }
        }
+
+      /* If there is still no input available, ask for GC.  */
+      if (!detect_input_pending_run_timers (0))
+       maybe_gc ();
     }
 
   /* Notify the caller if an autosave hook, or a timer, sentinel or
@@ -5185,8 +5174,8 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
          if (STRINGP (string))
            string_info = Fcons (string, make_number (charpos));
          textpos = (w == XWINDOW (selected_window)
-                    && current_buffer == XBUFFER (w->buffer))
-           ? PT : XMARKER (w->pointm)->charpos;
+                    && current_buffer == XBUFFER (WVAR (w, buffer)))
+           ? PT : XMARKER (WVAR (w, pointm))->charpos;
 
          xret = wx;
          yret = wy;
@@ -5330,7 +5319,7 @@ make_lispy_event (struct input_event *event)
 {
   int i;
 
-  switch (SWITCH_ENUM_CAST (event->kind))
+  switch (event->kind)
     {
       /* A simple keystroke.  */
     case ASCII_KEYSTROKE_EVENT:
@@ -5574,7 +5563,7 @@ make_lispy_event (struct input_event *event)
          int fuzz;
 
          if (WINDOWP (event->frame_or_window))
-           f = XFRAME (XWINDOW (event->frame_or_window)->frame);
+           f = XFRAME (WVAR (XWINDOW (event->frame_or_window), frame));
          else if (FRAMEP (event->frame_or_window))
            f = XFRAME (event->frame_or_window);
          else
@@ -5742,7 +5731,7 @@ make_lispy_event (struct input_event *event)
          int is_double;
 
          if (WINDOWP (event->frame_or_window))
-           fr = XFRAME (XWINDOW (event->frame_or_window)->frame);
+           fr = XFRAME (WVAR (XWINDOW (event->frame_or_window), frame));
          else if (FRAMEP (event->frame_or_window))
            fr = XFRAME (event->frame_or_window);
          else
@@ -7905,7 +7894,8 @@ parse_menu_item (Lisp_Object item, int inmenubar)
                    /* If the command is an alias for another
                       (such as lmenu.el set it up), check if the
                       original command matches the cached command.  */
-                   && !(SYMBOLP (def) && EQ (tem, XSYMBOL (def)->function))))
+                   && !(SYMBOLP (def)
+                        && EQ (tem, SVAR (XSYMBOL (def), function)))))
              keys = Qnil;
          }
 
@@ -8831,18 +8821,12 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
 
   next = access_keymap (map, key, 1, 0, 1);
 
-  /* Handle symbol with autoload definition.  */
-  if (SYMBOLP (next) && !NILP (Ffboundp (next))
-      && CONSP (XSYMBOL (next)->function)
-      && EQ (XCAR (XSYMBOL (next)->function), Qautoload))
-    do_autoload (XSYMBOL (next)->function, next);
-
   /* Handle a symbol whose function definition is a keymap
      or an array.  */
   if (SYMBOLP (next) && !NILP (Ffboundp (next))
-      && (ARRAYP (XSYMBOL (next)->function)
-         || KEYMAPP (XSYMBOL (next)->function)))
-    next = XSYMBOL (next)->function;
+      && (ARRAYP (SVAR (XSYMBOL (next), function))
+         || KEYMAPP (SVAR (XSYMBOL (next), function))))
+    next = Fautoload_do_load (SVAR (XSYMBOL (next), function), next, Qnil);
 
   /* If the keymap gives a function, not an
      array, then call the function with one arg and use
@@ -9412,8 +9396,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
                {
                  if (! FRAME_LIVE_P (XFRAME (selected_frame)))
                    Fkill_emacs (Qnil);
-                 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer)
-                   Fset_buffer (XWINDOW (selected_window)->buffer);
+                 if (XBUFFER (WVAR (XWINDOW (selected_window), buffer)) != current_buffer)
+                   Fset_buffer (WVAR (XWINDOW (selected_window), buffer));
                }
 
              orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
@@ -9505,8 +9489,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
                     not the current buffer.  If we're at the
                     beginning of a key sequence, switch buffers.  */
                  if (WINDOWP (window)
-                     && BUFFERP (XWINDOW (window)->buffer)
-                     && XBUFFER (XWINDOW (window)->buffer) != current_buffer)
+                     && BUFFERP (WVAR (XWINDOW (window), buffer))
+                     && XBUFFER (WVAR (XWINDOW (window), buffer)) != current_buffer)
                    {
                      ASET (raw_keybuf, raw_keybuf_count, key);
                      raw_keybuf_count++;
@@ -9527,7 +9511,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
 
                      if (! FRAME_LIVE_P (XFRAME (selected_frame)))
                        Fkill_emacs (Qnil);
-                     set_buffer_internal (XBUFFER (XWINDOW (window)->buffer));
+                     set_buffer_internal (XBUFFER (WVAR (XWINDOW (window), buffer)));
                      orig_local_map = get_local_map (PT, current_buffer,
                                                      Qlocal_map);
                      orig_keymap = get_local_map (PT, current_buffer,
@@ -10286,7 +10270,7 @@ a special event, so ignore the prefix argument and don't clear it.  */)
          struct gcpro gcpro1, gcpro2;
 
          GCPRO2 (cmd, prefixarg);
-         do_autoload (final, cmd);
+         Fautoload_do_load (final, cmd, Qnil);
          UNGCPRO;
        }
       else
@@ -11211,7 +11195,7 @@ The `posn-' functions access elements of such lists.  */)
                      ? window_box_left_offset (w, TEXT_AREA)
                      : 0)));
       XSETINT (y, WINDOW_TO_FRAME_PIXEL_Y (w, XINT (y)));
-      frame_or_window = w->frame;
+      frame_or_window = WVAR (w, frame);
     }
 
   CHECK_LIVE_FRAME (frame_or_window);
@@ -12236,6 +12220,10 @@ keys_of_keyboard (void)
 
   initial_define_lispy_key (Vspecial_event_map, "config-changed-event",
                            "ignore");
+#if defined (WINDOWSNT)
+  initial_define_lispy_key (Vspecial_event_map, "language-change",
+                           "ignore");
+#endif
 }
 
 /* Mark the pointers in the kboard objects.