Merge from trunk
[bpt/emacs.git] / src / keyboard.c
index 7a5185d..63e7573 100644 (file)
@@ -451,7 +451,7 @@ static int store_user_signal_events (void);
    C can be a character, which is printed prettily ("M-C-x" and all that
    jazz), or a symbol, whose name is printed.  */
 
-void
+static void
 echo_char (Lisp_Object c)
 {
   if (current_kboard->immediate_echo)
@@ -461,7 +461,7 @@ echo_char (Lisp_Object c)
       char *ptr = buffer;
       Lisp_Object echo_string;
 
-      echo_string = current_kboard->echo_string;
+      echo_string = KVAR (current_kboard, echo_string);
 
       /* If someone has passed us a composite event, use its head symbol.  */
       c = EVENT_HEAD (c);
@@ -483,7 +483,7 @@ echo_char (Lisp_Object c)
              ptr = buffer + offset;
            }
 
-         ptr += copy_text (SDATA (name), ptr, nbytes,
+         ptr += copy_text (SDATA (name), (unsigned char *) ptr, nbytes,
                            STRING_MULTIBYTE (name), 1);
        }
 
@@ -528,7 +528,7 @@ echo_char (Lisp_Object c)
       else if (STRINGP (echo_string))
        echo_string = concat2 (echo_string, build_string (" "));
 
-      current_kboard->echo_string
+      KVAR (current_kboard, echo_string)
        = concat2 (echo_string, make_string (buffer, ptr - buffer));
 
       echo_now ();
@@ -538,35 +538,35 @@ echo_char (Lisp_Object c)
 /* Temporarily add a dash to the end of the echo string if it's not
    empty, so that it serves as a mini-prompt for the very next character.  */
 
-void
+static void
 echo_dash (void)
 {
   /* Do nothing if not echoing at all.  */
-  if (NILP (current_kboard->echo_string))
+  if (NILP (KVAR (current_kboard, echo_string)))
     return;
 
   if (this_command_key_count == 0)
     return;
 
   if (!current_kboard->immediate_echo
-      && SCHARS (current_kboard->echo_string) == 0)
+      && SCHARS (KVAR (current_kboard, echo_string)) == 0)
     return;
 
   /* Do nothing if we just printed a prompt.  */
   if (current_kboard->echo_after_prompt
-      == SCHARS (current_kboard->echo_string))
+      == SCHARS (KVAR (current_kboard, echo_string)))
     return;
 
   /* Do nothing if we have already put a dash at the end.  */
-  if (SCHARS (current_kboard->echo_string) > 1)
+  if (SCHARS (KVAR (current_kboard, echo_string)) > 1)
     {
       Lisp_Object last_char, prev_char, idx;
 
-      idx = make_number (SCHARS (current_kboard->echo_string) - 2);
-      prev_char = Faref (current_kboard->echo_string, idx);
+      idx = make_number (SCHARS (KVAR (current_kboard, echo_string)) - 2);
+      prev_char = Faref (KVAR (current_kboard, echo_string), idx);
 
-      idx = make_number (SCHARS (current_kboard->echo_string) - 1);
-      last_char = Faref (current_kboard->echo_string, idx);
+      idx = make_number (SCHARS (KVAR (current_kboard, echo_string)) - 1);
+      last_char = Faref (KVAR (current_kboard, echo_string), idx);
 
       if (XINT (last_char) == '-' && XINT (prev_char) != ' ')
        return;
@@ -574,7 +574,7 @@ echo_dash (void)
 
   /* Put a dash at the end of the buffer temporarily,
      but make it go away when the next character is added.  */
-  current_kboard->echo_string = concat2 (current_kboard->echo_string,
+  KVAR (current_kboard, echo_string) = concat2 (KVAR (current_kboard, echo_string),
                                         build_string ("-"));
   echo_now ();
 }
@@ -617,9 +617,9 @@ echo_now (void)
     }
 
   echoing = 1;
-  message3_nolog (current_kboard->echo_string,
-                 SBYTES (current_kboard->echo_string),
-                 STRING_MULTIBYTE (current_kboard->echo_string));
+  message3_nolog (KVAR (current_kboard, echo_string),
+                 SBYTES (KVAR (current_kboard, echo_string)),
+                 STRING_MULTIBYTE (KVAR (current_kboard, echo_string)));
   echoing = 0;
 
   /* Record in what buffer we echoed, and from which kboard.  */
@@ -637,7 +637,7 @@ cancel_echoing (void)
 {
   current_kboard->immediate_echo = 0;
   current_kboard->echo_after_prompt = -1;
-  current_kboard->echo_string = Qnil;
+  KVAR (current_kboard, echo_string) = Qnil;
   ok_to_echo_at_next_pause = NULL;
   echo_kboard = NULL;
   echo_message_buffer = Qnil;
@@ -648,8 +648,8 @@ cancel_echoing (void)
 static int
 echo_length (void)
 {
-  return (STRINGP (current_kboard->echo_string)
-         ? SCHARS (current_kboard->echo_string)
+  return (STRINGP (KVAR (current_kboard, echo_string))
+         ? SCHARS (KVAR (current_kboard, echo_string))
          : 0);
 }
 
@@ -660,9 +660,9 @@ echo_length (void)
 static void
 echo_truncate (EMACS_INT nchars)
 {
-  if (STRINGP (current_kboard->echo_string))
-    current_kboard->echo_string
-      = Fsubstring (current_kboard->echo_string,
+  if (STRINGP (KVAR (current_kboard, echo_string)))
+    KVAR (current_kboard, echo_string)
+      = Fsubstring (KVAR (current_kboard, echo_string),
                    make_number (0), make_number (nchars));
   truncate_echo_area (nchars);
 }
@@ -967,7 +967,7 @@ restore_kboard_configuration (Lisp_Object was_locked)
 /* Handle errors that are not handled at inner levels
    by printing an error message and returning to the editor command loop.  */
 
-Lisp_Object
+static Lisp_Object
 cmd_error (Lisp_Object data)
 {
   Lisp_Object old_level, old_length;
@@ -993,8 +993,8 @@ cmd_error (Lisp_Object data)
   Vstandard_input = Qt;
   Vexecuting_kbd_macro = Qnil;
   executing_kbd_macro = Qnil;
-  current_kboard->Vprefix_arg = Qnil;
-  current_kboard->Vlast_prefix_arg = Qnil;
+  KVAR (current_kboard, Vprefix_arg) = Qnil;
+  KVAR (current_kboard, Vlast_prefix_arg) = Qnil;
   cancel_echoing ();
 
   /* Avoid unquittable loop if data contains a circular list.  */
@@ -1132,10 +1132,10 @@ command_loop_2 (Lisp_Object ignore)
   return Qnil;
 }
 
-Lisp_Object
+static Lisp_Object
 top_level_2 (void)
 {
-  return Feval (Vtop_level);
+  return Feval (Vtop_level, Qnil);
 }
 
 Lisp_Object
@@ -1169,6 +1169,7 @@ This also exits all active minibuffers.  */)
   Fthrow (Qtop_level, Qnil);
 }
 
+Lisp_Object Fexit_recursive_edit (void) NO_RETURN;
 DEFUN ("exit-recursive-edit", Fexit_recursive_edit, Sexit_recursive_edit, 0, 0, "",
        doc: /* Exit from the innermost recursive edit or minibuffer.  */)
   (void)
@@ -1179,6 +1180,7 @@ DEFUN ("exit-recursive-edit", Fexit_recursive_edit, Sexit_recursive_edit, 0, 0,
   error ("No recursive edit is in progress");
 }
 
+Lisp_Object Fabort_recursive_edit (void) NO_RETURN;
 DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0, 0, "",
        doc: /* Abort the command that requested this recursive edit or minibuffer input.  */)
   (void)
@@ -1302,8 +1304,8 @@ command_loop_1 (void)
 #endif
   int already_adjusted = 0;
 
-  current_kboard->Vprefix_arg = Qnil;
-  current_kboard->Vlast_prefix_arg = Qnil;
+  KVAR (current_kboard, Vprefix_arg) = Qnil;
+  KVAR (current_kboard, Vlast_prefix_arg) = Qnil;
   Vdeactivate_mark = Qnil;
   waiting_for_input = 0;
   cancel_echoing ();
@@ -1331,10 +1333,10 @@ command_loop_1 (void)
     }
 
   /* Do this after running Vpost_command_hook, for consistency.  */
-  current_kboard->Vlast_command = Vthis_command;
-  current_kboard->Vreal_last_command = real_this_command;
+  KVAR (current_kboard, Vlast_command) = Vthis_command;
+  KVAR (current_kboard, Vreal_last_command) = real_this_command;
   if (!CONSP (last_command_event))
-    current_kboard->Vlast_repeatable_command = real_this_command;
+    KVAR (current_kboard, Vlast_repeatable_command) = real_this_command;
 
   while (1)
     {
@@ -1504,9 +1506,9 @@ command_loop_1 (void)
          keys = Fkey_description (keys, Qnil);
          bitch_at_user ();
          message_with_string ("%s is undefined", keys, 0);
-         current_kboard->defining_kbd_macro = Qnil;
+         KVAR (current_kboard, defining_kbd_macro) = Qnil;
          update_mode_lines = 1;
-         current_kboard->Vprefix_arg = Qnil;
+         KVAR (current_kboard, Vprefix_arg) = Qnil;
        }
       else
        {
@@ -1523,7 +1525,7 @@ command_loop_1 (void)
               }
 #endif
 
-            if (NILP (current_kboard->Vprefix_arg)) /* FIXME: Why?  --Stef  */
+            if (NILP (KVAR (current_kboard, Vprefix_arg))) /* FIXME: Why?  --Stef  */
               Fundo_boundary ();
             Fcommand_execute (Vthis_command, Qnil, Qnil, Qnil);
 
@@ -1537,7 +1539,7 @@ command_loop_1 (void)
             unbind_to (scount, Qnil);
 #endif
           }
-      current_kboard->Vlast_prefix_arg = Vcurrent_prefix_arg;
+      KVAR (current_kboard, Vlast_prefix_arg) = Vcurrent_prefix_arg;
 
       /* Note that the value cell will never directly contain nil
         if the symbol is a local variable.  */
@@ -1565,19 +1567,19 @@ command_loop_1 (void)
         If the command didn't actually create a prefix arg,
         but is merely a frame event that is transparent to prefix args,
         then the above doesn't apply.  */
-      if (NILP (current_kboard->Vprefix_arg) || CONSP (last_command_event))
+      if (NILP (KVAR (current_kboard, Vprefix_arg)) || CONSP (last_command_event))
        {
-         current_kboard->Vlast_command = Vthis_command;
-         current_kboard->Vreal_last_command = real_this_command;
+         KVAR (current_kboard, Vlast_command) = Vthis_command;
+         KVAR (current_kboard, Vreal_last_command) = real_this_command;
          if (!CONSP (last_command_event))
-           current_kboard->Vlast_repeatable_command = real_this_command;
+           KVAR (current_kboard, Vlast_repeatable_command) = real_this_command;
          cancel_echoing ();
          this_command_key_count = 0;
          this_command_key_count_reset = 0;
          this_single_command_key_start = 0;
        }
 
-      if (!NILP (current_buffer->mark_active)
+      if (!NILP (BVAR (current_buffer, mark_active))
          && !NILP (Vrun_hooks))
        {
          /* In Emacs 22, setting transient-mark-mode to `only' was a
@@ -1599,7 +1601,7 @@ command_loop_1 (void)
              if (!NILP (Fwindow_system (Qnil))
                  /* Even if mark_active is non-nil, the actual buffer
                     marker may not have been set yet (Bug#7044).  */
-                 && XMARKER (current_buffer->mark)->buffer
+                 && XMARKER (BVAR (current_buffer, mark))->buffer
                  && (EQ (Vselect_active_regions, Qonly)
                      ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
                      : (!NILP (Vselect_active_regions)
@@ -1607,7 +1609,7 @@ command_loop_1 (void)
                  && !EQ (Vthis_command, Qhandle_switch_frame))
                {
                  EMACS_INT beg =
-                   XINT (Fmarker_position (current_buffer->mark));
+                   XINT (Fmarker_position (BVAR (current_buffer, mark)));
                  EMACS_INT end = PT;
                  if (beg < end)
                    call2 (Qx_set_selection, QPRIMARY,
@@ -1649,8 +1651,8 @@ command_loop_1 (void)
 
       /* Install chars successfully executed in kbd macro.  */
 
-      if (!NILP (current_kboard->defining_kbd_macro)
-         && NILP (current_kboard->Vprefix_arg))
+      if (!NILP (KVAR (current_kboard, defining_kbd_macro))
+         && NILP (KVAR (current_kboard, Vprefix_arg)))
        finalize_kbd_macro_chars ();
 #if 0 /* This shouldn't be necessary anymore.  --lorentey  */
       if (!was_locked)
@@ -1885,7 +1887,7 @@ poll_for_input_1 (void)
 /* Timer callback function for poll_timer.  TIMER is equal to
    poll_timer.  */
 
-void
+static void
 poll_for_input (struct atimer *timer)
 {
   if (poll_suppress_count == 0)
@@ -2184,7 +2186,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
           int *used_mouse_menu, struct timeval *end_time)
 {
   volatile Lisp_Object c;
-  int count, jmpcount;
+  int jmpcount;
   jmp_buf local_getcjmp;
   jmp_buf save_jump;
   volatile int key_already_recorded = 0;
@@ -2461,21 +2463,21 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
        KBOARD *kb = FRAME_KBOARD (XFRAME (selected_frame));
        if (kb != current_kboard)
          {
-           Lisp_Object link = kb->kbd_queue;
+           Lisp_Object last = KVAR (kb, kbd_queue);
            /* We shouldn't get here if we were in single-kboard mode!  */
            if (single_kboard)
              abort ();
-           if (CONSP (link))
+           if (CONSP (last))
              {
-               while (CONSP (XCDR (link)))
-                 link = XCDR (link);
-               if (!NILP (XCDR (link)))
+               while (CONSP (XCDR (last)))
+                 last = XCDR (last);
+               if (!NILP (XCDR (last)))
                  abort ();
              }
-           if (!CONSP (link))
-             kb->kbd_queue = Fcons (c, Qnil);
+           if (!CONSP (last))
+             KVAR (kb, kbd_queue) = Fcons (c, Qnil);
            else
-             XSETCDR (link, Fcons (c, Qnil));
+             XSETCDR (last, Fcons (c, Qnil));
            kb->kbd_queue_has_data = 1;
            current_kboard = kb;
            /* This is going to exit from read_char
@@ -2645,12 +2647,12 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
     {
       if (current_kboard->kbd_queue_has_data)
        {
-         if (!CONSP (current_kboard->kbd_queue))
+         if (!CONSP (KVAR (current_kboard, kbd_queue)))
            abort ();
-         c = XCAR (current_kboard->kbd_queue);
-         current_kboard->kbd_queue
-           = XCDR (current_kboard->kbd_queue);
-         if (NILP (current_kboard->kbd_queue))
+         c = XCAR (KVAR (current_kboard, kbd_queue));
+         KVAR (current_kboard, kbd_queue)
+           = XCDR (KVAR (current_kboard, kbd_queue));
+         if (NILP (KVAR (current_kboard, kbd_queue)))
            current_kboard->kbd_queue_has_data = 0;
          input_pending = readable_events (0);
          if (EVENT_HAS_PARAMETERS (c)
@@ -2692,7 +2694,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
 
   if (NILP (c))
     {
-      KBOARD *kb;
+      KBOARD *kb IF_LINT (= NULL);
 
       if (end_time)
        {
@@ -2712,18 +2714,18 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
 
       if (! NILP (c) && (kb != current_kboard))
        {
-         Lisp_Object link = kb->kbd_queue;
-         if (CONSP (link))
+         Lisp_Object last = KVAR (kb, kbd_queue);
+         if (CONSP (last))
            {
-             while (CONSP (XCDR (link)))
-               link = XCDR (link);
-             if (!NILP (XCDR (link)))
+             while (CONSP (XCDR (last)))
+               last = XCDR (last);
+             if (!NILP (XCDR (last)))
                abort ();
            }
-         if (!CONSP (link))
-           kb->kbd_queue = Fcons (c, Qnil);
+         if (!CONSP (last))
+           KVAR (kb, kbd_queue) = Fcons (c, Qnil);
          else
-           XSETCDR (link, Fcons (c, Qnil));
+           XSETCDR (last, Fcons (c, Qnil));
          kb->kbd_queue_has_data = 1;
          c = Qnil;
          if (single_kboard)
@@ -2829,15 +2831,15 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
       if (XINT (c) == -1)
        goto exit;
 
-      if ((STRINGP (current_kboard->Vkeyboard_translate_table)
-          && SCHARS (current_kboard->Vkeyboard_translate_table) > (unsigned) XFASTINT (c))
-         || (VECTORP (current_kboard->Vkeyboard_translate_table)
-             && XVECTOR (current_kboard->Vkeyboard_translate_table)->size > (unsigned) XFASTINT (c))
-         || (CHAR_TABLE_P (current_kboard->Vkeyboard_translate_table)
+      if ((STRINGP (KVAR (current_kboard, Vkeyboard_translate_table))
+          && SCHARS (KVAR (current_kboard, Vkeyboard_translate_table)) > (unsigned) XFASTINT (c))
+         || (VECTORP (KVAR (current_kboard, Vkeyboard_translate_table))
+             && XVECTOR (KVAR (current_kboard, Vkeyboard_translate_table))->size > (unsigned) XFASTINT (c))
+         || (CHAR_TABLE_P (KVAR (current_kboard, Vkeyboard_translate_table))
              && CHARACTERP (c)))
        {
          Lisp_Object d;
-         d = Faref (current_kboard->Vkeyboard_translate_table, c);
+         d = Faref (KVAR (current_kboard, Vkeyboard_translate_table), c);
          /* nil in keyboard-translate-table means no translation.  */
          if (!NILP (d))
            c = d;
@@ -2912,13 +2914,13 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
     {
       Lisp_Object keys;
       int key_count, key_count_reset;
-      struct gcpro gcpro1;
+      struct gcpro inner_gcpro1;
       int count = SPECPDL_INDEX ();
 
       /* Save the echo status.  */
       int saved_immediate_echo = current_kboard->immediate_echo;
       struct kboard *saved_ok_to_echo = ok_to_echo_at_next_pause;
-      Lisp_Object saved_echo_string = current_kboard->echo_string;
+      Lisp_Object saved_echo_string = KVAR (current_kboard, echo_string);
       int saved_echo_after_prompt = current_kboard->echo_after_prompt;
 
 #if 0
@@ -2940,7 +2942,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
        keys = Fcopy_sequence (this_command_keys);
       else
        keys = Qnil;
-      GCPRO1 (keys);
+      GCPRO1_VAR (keys, inner_gcpro);
 
       /* Clear out this_command_keys.  */
       this_command_key_count = 0;
@@ -2973,12 +2975,12 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
 
       cancel_echoing ();
       ok_to_echo_at_next_pause = saved_ok_to_echo;
-      current_kboard->echo_string = saved_echo_string;
+      KVAR (current_kboard, echo_string) = saved_echo_string;
       current_kboard->echo_after_prompt = saved_echo_after_prompt;
       if (saved_immediate_echo)
        echo_now ();
 
-      UNGCPRO;
+      UNGCPRO_VAR (inner_gcpro);
 
       /* The input method can return no events.  */
       if (! CONSP (tem))
@@ -3000,16 +3002,16 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
   if (CONSP (c) && EQ (XCAR (c), Qhelp_echo))
     {
       /* (help-echo FRAME HELP WINDOW OBJECT POS).  */
-      Lisp_Object help, object, position, window, tem;
+      Lisp_Object help, object, position, window, htem;
 
-      tem = Fcdr (XCDR (c));
-      help = Fcar (tem);
-      tem = Fcdr (tem);
-      window = Fcar (tem);
-      tem = Fcdr (tem);
-      object = Fcar (tem);
-      tem = Fcdr (tem);
-      position = Fcar (tem);
+      htem = Fcdr (XCDR (c));
+      help = Fcar (htem);
+      htem = Fcdr (htem);
+      window = Fcar (htem);
+      htem = Fcdr (htem);
+      object = Fcar (htem);
+      htem = Fcdr (htem);
+      position = Fcar (htem);
 
       show_help_echo (help, window, object, position, 0);
 
@@ -3051,14 +3053,14 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
   if (!NILP (Vhelp_form) && help_char_p (c))
     {
       Lisp_Object tem0;
-      count = SPECPDL_INDEX ();
+      int count = SPECPDL_INDEX ();
 
       help_form_saved_window_configs
        = Fcons (Fcurrent_window_configuration (Qnil),
                 help_form_saved_window_configs);
       record_unwind_protect (read_char_help_form_unwind, Qnil);
 
-      tem0 = Feval (Vhelp_form);
+      tem0 = Feval (Vhelp_form, Qnil);
       if (STRINGP (tem0))
        internal_with_output_to_temp_buffer ("*Help*", print_help, tem0);
 
@@ -3459,7 +3461,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
 
          if (single_kboard && kb != current_kboard)
            {
-             kb->kbd_queue
+             KVAR (kb, kbd_queue)
                = Fcons (make_lispy_switch_frame (event->frame_or_window),
                         Fcons (make_number (c), Qnil));
              kb->kbd_queue_has_data = 1;
@@ -4024,7 +4026,7 @@ kbd_buffer_get_event (KBOARD **kbp,
       Lisp_Object bar_window;
       enum scroll_bar_part part;
       Lisp_Object x, y;
-      unsigned long time;
+      unsigned long t;
 
       *kbp = current_kboard;
       /* Note that this uses F to determine which terminal to look at.
@@ -4035,7 +4037,7 @@ kbd_buffer_get_event (KBOARD **kbp,
       /* XXX Can f or mouse_position_hook be NULL here? */
       if (f && FRAME_TERMINAL (f)->mouse_position_hook)
         (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, 0, &bar_window,
-                                                    &part, &x, &y, &time);
+                                                    &part, &x, &y, &t);
 
       obj = Qnil;
 
@@ -4059,7 +4061,7 @@ kbd_buffer_get_event (KBOARD **kbp,
       /* If we didn't decide to make a switch-frame event, go ahead and
         return a mouse-motion event.  */
       if (!NILP (x) && NILP (obj))
-       obj = make_lispy_movement (f, bar_window, part, x, y, time);
+       obj = make_lispy_movement (f, bar_window, part, x, y, t);
     }
 #endif /* HAVE_MOUSE || HAVE GPM */
   else
@@ -5037,7 +5039,7 @@ int double_click_count;
 
 static Lisp_Object
 make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
-                    unsigned long time)
+                    unsigned long t)
 {
   enum window_part part;
   Lisp_Object posn = Qnil;
@@ -5155,7 +5157,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
             is the X coordinate relative to the text area for
             text-area and right-margin clicks, zero otherwise.  */
          int x2
-           = (part == ON_TEXT) ? x2
+           = (part == ON_TEXT) ? xret
            : (part == ON_RIGHT_FRINGE || part == ON_RIGHT_MARGIN)
            ? (XINT (x) - window_box_left (w, TEXT_AREA))
            : 0;
@@ -5218,7 +5220,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
                Fcons (posn,
                       Fcons (Fcons (make_number (xret),
                                     make_number (yret)),
-                             Fcons (make_number (time),
+                             Fcons (make_number (t),
                                     extra_info))));
 }
 
@@ -5322,13 +5324,13 @@ make_lispy_event (struct input_event *event)
        {
          /* We need to use an alist rather than a vector as the cache
             since we can't make a vector long enuf.  */
-         if (NILP (current_kboard->system_key_syms))
-           current_kboard->system_key_syms = Fcons (Qnil, Qnil);
+         if (NILP (KVAR (current_kboard, system_key_syms)))
+           KVAR (current_kboard, system_key_syms) = Fcons (Qnil, Qnil);
          return modify_event_symbol (event->code,
                                      event->modifiers,
                                      Qfunction_key,
-                                     current_kboard->Vsystem_key_alist,
-                                     0, &current_kboard->system_key_syms,
+                                     KVAR (current_kboard, Vsystem_key_alist),
+                                     0, &KVAR (current_kboard, system_key_syms),
                                      (unsigned) -1);
        }
 
@@ -5642,19 +5644,19 @@ make_lispy_event (struct input_event *event)
          /* On window-system frames, use the value of
             double-click-fuzz as is.  On other frames, interpret it
             as a multiple of 1/8 characters.  */
-         struct frame *f;
+         struct frame *fr;
          int fuzz;
          int symbol_num;
          int is_double;
 
          if (WINDOWP (event->frame_or_window))
-           f = XFRAME (XWINDOW (event->frame_or_window)->frame);
+           fr = XFRAME (XWINDOW (event->frame_or_window)->frame);
          else if (FRAMEP (event->frame_or_window))
-           f = XFRAME (event->frame_or_window);
+           fr = XFRAME (event->frame_or_window);
          else
            abort ();
 
-         fuzz = FRAME_WINDOW_P (f)
+         fuzz = FRAME_WINDOW_P (fr)
            ? double_click_fuzz : double_click_fuzz / 8;
 
          if (event->modifiers & up_modifier)
@@ -5927,7 +5929,7 @@ make_lispy_event (struct input_event *event)
 
 static Lisp_Object
 make_lispy_movement (FRAME_PTR frame, Lisp_Object bar_window, enum scroll_bar_part part,
-                    Lisp_Object x, Lisp_Object y, unsigned long time)
+                    Lisp_Object x, Lisp_Object y, unsigned long t)
 {
   /* Is it a scroll bar movement?  */
   if (frame && ! NILP (bar_window))
@@ -5939,7 +5941,7 @@ make_lispy_movement (FRAME_PTR frame, Lisp_Object bar_window, enum scroll_bar_pa
                    Fcons (list5 (bar_window,
                                  Qvertical_scroll_bar,
                                  Fcons (x, y),
-                                 make_number (time),
+                                 make_number (t),
                                  part_sym),
                           Qnil));
     }
@@ -5947,7 +5949,7 @@ make_lispy_movement (FRAME_PTR frame, Lisp_Object bar_window, enum scroll_bar_pa
   else
     {
       Lisp_Object position;
-      position = make_lispy_position (frame, x, y, time);
+      position = make_lispy_position (frame, x, y, t);
       return list2 (Qmouse_movement, position);
     }
 }
@@ -6025,7 +6027,7 @@ parse_modifiers_uncached (Lisp_Object symbol, int *modifier_end)
 
 #define MULTI_LETTER_MOD(BIT, NAME, LEN)                       \
          if (i + LEN + 1 <= SBYTES (name)                      \
-             && ! strncmp (SDATA (name) + i, NAME, LEN))       \
+             && ! strncmp (SSDATA (name) + i, NAME, LEN))      \
            {                                                   \
              this_mod_end = i + LEN;                           \
              this_mod = BIT;                                   \
@@ -6063,13 +6065,13 @@ parse_modifiers_uncached (Lisp_Object symbol, int *modifier_end)
   if (! (modifiers & (down_modifier | drag_modifier
                      | double_modifier | triple_modifier))
       && i + 7 == SBYTES (name)
-      && strncmp (SDATA (name) + i, "mouse-", 6) == 0
+      && strncmp (SSDATA (name) + i, "mouse-", 6) == 0
       && ('0' <= SREF (name, i + 6) && SREF (name, i + 6) <= '9'))
     modifiers |= click_modifier;
 
   if (! (modifiers & (double_modifier | triple_modifier))
       && i + 6 < SBYTES (name)
-      && strncmp (SDATA (name) + i, "wheel-", 6) == 0)
+      && strncmp (SSDATA (name) + i, "wheel-", 6) == 0)
     modifiers |= click_modifier;
 
   if (modifier_end)
@@ -6187,7 +6189,7 @@ parse_modifiers (Lisp_Object symbol)
       Lisp_Object unmodified;
       Lisp_Object mask;
 
-      unmodified = Fintern (make_string (SDATA (SYMBOL_NAME (symbol)) + end,
+      unmodified = Fintern (make_string (SSDATA (SYMBOL_NAME (symbol)) + end,
                                         SBYTES (SYMBOL_NAME (symbol)) - end),
                            Qnil);
 
@@ -6236,7 +6238,7 @@ DEFUN ("internal-event-symbol-parse-modifiers", Fevent_symbol_parse_modifiers,
 static Lisp_Object
 apply_modifiers (int modifiers, Lisp_Object base)
 {
-  Lisp_Object cache, index, entry, new_symbol;
+  Lisp_Object cache, idx, entry, new_symbol;
 
   /* Mask out upper bits.  We don't know where this value's been.  */
   modifiers &= INTMASK;
@@ -6246,8 +6248,8 @@ apply_modifiers (int modifiers, Lisp_Object base)
 
   /* The click modifier never figures into cache indices.  */
   cache = Fget (base, Qmodifier_cache);
-  XSETFASTINT (index, (modifiers & ~click_modifier));
-  entry = assq_no_quit (index, cache);
+  XSETFASTINT (idx, (modifiers & ~click_modifier));
+  entry = assq_no_quit (idx, cache);
 
   if (CONSP (entry))
     new_symbol = XCDR (entry);
@@ -6255,19 +6257,19 @@ apply_modifiers (int modifiers, Lisp_Object base)
     {
       /* We have to create the symbol ourselves.  */
       new_symbol = apply_modifiers_uncached (modifiers,
-                                            SDATA (SYMBOL_NAME (base)),
+                                            SSDATA (SYMBOL_NAME (base)),
                                             SCHARS (SYMBOL_NAME (base)),
                                             SBYTES (SYMBOL_NAME (base)));
 
       /* Add the new symbol to the base's cache.  */
-      entry = Fcons (index, new_symbol);
+      entry = Fcons (idx, new_symbol);
       Fput (base, Qmodifier_cache, Fcons (entry, cache));
 
       /* We have the parsing info now for free, so we could add it to
         the caches:
-         XSETFASTINT (index, modifiers);
+         XSETFASTINT (idx, modifiers);
          Fput (new_symbol, Qevent_symbol_element_mask,
-               Fcons (base, Fcons (index, Qnil)));
+               Fcons (base, Fcons (idx, Qnil)));
          Fput (new_symbol, Qevent_symbol_elements,
                Fcons (base, lispy_modifier_list (modifiers)));
         Sadly, this is only correct if `base' is indeed a base event,
@@ -6518,7 +6520,7 @@ parse_solitary_modifier (Lisp_Object symbol)
 
 #define MULTI_LETTER_MOD(BIT, NAME, LEN)               \
       if (LEN == SBYTES (name)                         \
-         && ! strncmp (SDATA (name), NAME, LEN))       \
+         && ! strncmp (SSDATA (name), NAME, LEN))      \
        return BIT;
 
     case 'A':
@@ -6821,16 +6823,17 @@ decode_keyboard_code (struct tty_display_info *tty,
     return;
   for (i = 0, p = coding->destination; i < coding->produced_char; i++)
     {
-      struct input_event buf;
+      struct input_event event_buf;
 
-      EVENT_INIT (buf);
-      buf.code = STRING_CHAR_ADVANCE (p);
-      buf.kind = (ASCII_CHAR_P (buf.code)
-                 ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
+      EVENT_INIT (event_buf);
+      event_buf.code = STRING_CHAR_ADVANCE (p);
+      event_buf.kind =
+       (ASCII_CHAR_P (event_buf.code)
+        ? ASCII_KEYSTROKE_EVENT : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
       /* See the comment in tty_read_avail_input.  */
-      buf.frame_or_window = tty->top_frame;
-      buf.arg = Qnil;
-      kbd_buffer_store_event (&buf);
+      event_buf.frame_or_window = tty->top_frame;
+      event_buf.arg = Qnil;
+      kbd_buffer_store_event (&event_buf);
     }
 }
 
@@ -6890,11 +6893,11 @@ tty_read_avail_input (struct terminal *terminal,
   if (gpm_tty == tty)
   {
       Gpm_Event event;
-      struct input_event hold_quit;
+      struct input_event gpm_hold_quit;
       int gpm, fd = gpm_fd;
 
-      EVENT_INIT (hold_quit);
-      hold_quit.kind = NO_EVENT;
+      EVENT_INIT (gpm_hold_quit);
+      gpm_hold_quit.kind = NO_EVENT;
 
       /* gpm==1 if event received.
          gpm==0 if the GPM daemon has closed the connection, in which case
@@ -6903,13 +6906,13 @@ tty_read_avail_input (struct terminal *terminal,
                select masks.
          gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal. */
       while (gpm = Gpm_GetEvent (&event), gpm == 1) {
-         nread += handle_one_term_event (tty, &event, &hold_quit);
+         nread += handle_one_term_event (tty, &event, &gpm_hold_quit);
       }
       if (gpm == 0)
        /* Presumably the GPM daemon has closed the connection.  */
        close_gpm (fd);
-      if (hold_quit.kind != NO_EVENT)
-         kbd_buffer_store_event (&hold_quit);
+      if (gpm_hold_quit.kind != NO_EVENT)
+         kbd_buffer_store_event (&gpm_hold_quit);
       if (nread)
          return nread;
   }
@@ -6949,7 +6952,7 @@ tty_read_avail_input (struct terminal *terminal,
      NREAD is set to the number of chars read.  */
   do
     {
-      nread = emacs_read (fileno (tty->input), cbuf, n_to_read);
+      nread = emacs_read (fileno (tty->input), (char *) cbuf, n_to_read);
       /* POSIX infers that processes which are not in the session leader's
          process group won't get SIGHUP's at logout time.  BSDI adheres to
          this part standard and returns -1 from read (0) with errno==EIO
@@ -7056,7 +7059,7 @@ tty_read_avail_input (struct terminal *terminal,
   return nread;
 }
 \f
-void
+static void
 handle_async_input (void)
 {
   interrupt_input_pending = 0;
@@ -7329,8 +7332,6 @@ menu_bar_items (Lisp_Object old)
   int mapno;
   Lisp_Object oquit;
 
-  int i;
-
   /* In order to build the menus, we need to call the keymap
      accessors.  They all call QUIT.  But this function is called
      during redisplay, during which a quit is fatal.  So inhibit
@@ -7360,8 +7361,8 @@ menu_bar_items (Lisp_Object old)
        /* Yes, use them (if non-nil) as well as the global map.  */
        maps = (Lisp_Object *) alloca (3 * sizeof (maps[0]));
        nmaps = 0;
-       if (!NILP (current_kboard->Voverriding_terminal_local_map))
-         maps[nmaps++] = current_kboard->Voverriding_terminal_local_map;
+       if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
+         maps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map);
        if (!NILP (Voverriding_local_map))
          maps[nmaps++] = Voverriding_local_map;
       }
@@ -7432,15 +7433,18 @@ menu_bar_items (Lisp_Object old)
     }
 
   /* Add nil, nil, nil, nil at the end.  */
-  i = menu_bar_items_index;
-  if (i + 4 > XVECTOR (menu_bar_items_vector)->size)
-    menu_bar_items_vector = larger_vector (menu_bar_items_vector, 2 * i, Qnil);
-  /* Add this item.  */
-  XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
-  XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
-  XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
-  XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
-  menu_bar_items_index = i;
+  {
+    int i = menu_bar_items_index;
+    if (i + 4 > XVECTOR (menu_bar_items_vector)->size)
+      menu_bar_items_vector =
+       larger_vector (menu_bar_items_vector, 2 * i, Qnil);
+    /* Add this item.  */
+    XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
+    XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
+    XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
+    XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
+    menu_bar_items_index = i;
+  }
 
   Vinhibit_quit = oquit;
   return menu_bar_items_vector;
@@ -7537,6 +7541,12 @@ menu_item_eval_property_1 (Lisp_Object arg)
   return Qnil;
 }
 
+static Lisp_Object
+eval_dyn (Lisp_Object form)
+{
+  return Feval (form, Qnil);
+}
+
 /* Evaluate an expression and return the result (or nil if something
    went wrong).  Used to evaluate dynamic parts of menu items.  */
 Lisp_Object
@@ -7545,7 +7555,7 @@ menu_item_eval_property (Lisp_Object sexpr)
   int count = SPECPDL_INDEX ();
   Lisp_Object val;
   specbind (Qinhibit_redisplay, Qt);
-  val = internal_condition_case_1 (Feval, sexpr, Qerror,
+  val = internal_condition_case_1 (eval_dyn, sexpr, Qerror,
                                   menu_item_eval_property_1);
   return unbind_to (count, val);
 }
@@ -7897,8 +7907,8 @@ tool_bar_items (Lisp_Object reuse, int *nitems)
       /* Yes, use them (if non-nil) as well as the global map.  */
       maps = (Lisp_Object *) alloca (3 * sizeof (maps[0]));
       nmaps = 0;
-      if (!NILP (current_kboard->Voverriding_terminal_local_map))
-       maps[nmaps++] = current_kboard->Voverriding_terminal_local_map;
+      if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
+       maps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map);
       if (!NILP (Voverriding_local_map))
        maps[nmaps++] = Voverriding_local_map;
     }
@@ -8084,7 +8094,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
   item = XCDR (item);
   if (!CONSP (item))
     {
-      if (menu_separator_name_p (SDATA (caption)))
+      if (menu_separator_name_p (SSDATA (caption)))
        {
          PROP (TOOL_BAR_ITEM_TYPE) = Qt;
 #if !defined (USE_GTK) && !defined (HAVE_NS)
@@ -8112,12 +8122,12 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
   /* Process the rest of the properties.  */
   for (; CONSP (item) && CONSP (XCDR (item)); item = XCDR (XCDR (item)))
     {
-      Lisp_Object key, value;
+      Lisp_Object ikey, value;
 
-      key = XCAR (item);
+      ikey = XCAR (item);
       value = XCAR (XCDR (item));
 
-      if (EQ (key, QCenable))
+      if (EQ (ikey, QCenable))
        {
          /* `:enable FORM'.  */
          if (!NILP (Venable_disabled_menus_and_buttons))
@@ -8125,20 +8135,20 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
          else
            PROP (TOOL_BAR_ITEM_ENABLED_P) = value;
        }
-      else if (EQ (key, QCvisible))
+      else if (EQ (ikey, QCvisible))
        {
          /* `:visible FORM'.  If got a visible property and that
             evaluates to nil then ignore this item.  */
          if (NILP (menu_item_eval_property (value)))
            return 0;
        }
-      else if (EQ (key, QChelp))
+      else if (EQ (ikey, QChelp))
         /* `:help HELP-STRING'.  */
         PROP (TOOL_BAR_ITEM_HELP) = value;
-      else if (EQ (key, QCvert_only))
+      else if (EQ (ikey, QCvert_only))
         /* `:vert-only t/nil'.  */
         PROP (TOOL_BAR_ITEM_VERT_ONLY) = value;
-      else if (EQ (key, QClabel))
+      else if (EQ (ikey, QClabel))
         {
           const char *bad_label = "!!?GARBLED ITEM?!!";
           /* `:label LABEL-STRING'.  */
@@ -8147,10 +8157,10 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
             : make_string (bad_label, strlen (bad_label));
           have_label = 1;
         }
-      else if (EQ (key, QCfilter))
+      else if (EQ (ikey, QCfilter))
        /* ':filter FORM'.  */
        filter = value;
-      else if (EQ (key, QCbutton) && CONSP (value))
+      else if (EQ (ikey, QCbutton) && CONSP (value))
        {
          /* `:button (TYPE . SELECTED)'.  */
          Lisp_Object type, selected;
@@ -8163,13 +8173,13 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
              PROP (TOOL_BAR_ITEM_TYPE) = type;
            }
        }
-      else if (EQ (key, QCimage)
+      else if (EQ (ikey, QCimage)
               && (CONSP (value)
                   || (VECTORP (value) && XVECTOR (value)->size == 4)))
        /* Value is either a single image specification or a vector
           of 4 such specifications for the different button states.  */
        PROP (TOOL_BAR_ITEM_IMAGES) = value;
-      else if (EQ (key, Qrtl))
+      else if (EQ (ikey, Qrtl))
         /* ':rtl STRING' */
        PROP (TOOL_BAR_ITEM_RTL_IMAGE) = value;
     }
@@ -8178,35 +8188,34 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
   if (!have_label)
     {
       /* Try to make one from caption and key.  */
-      Lisp_Object key = PROP (TOOL_BAR_ITEM_KEY);
-      Lisp_Object capt = PROP (TOOL_BAR_ITEM_CAPTION);
-      const char *label = SYMBOLP (key) ? SSDATA (SYMBOL_NAME (key)) : "";
-      const char *caption = STRINGP (capt) ? SSDATA (capt) : "";
+      Lisp_Object tkey = PROP (TOOL_BAR_ITEM_KEY);
+      Lisp_Object tcapt = PROP (TOOL_BAR_ITEM_CAPTION);
+      const char *label = SYMBOLP (tkey) ? SSDATA (SYMBOL_NAME (tkey)) : "";
+      const char *capt = STRINGP (tcapt) ? SSDATA (tcapt) : "";
       EMACS_INT max_lbl = 2 * tool_bar_max_label_size;
       char *buf = (char *) xmalloc (max_lbl + 1);
       Lisp_Object new_lbl;
-      size_t caption_len = strlen (caption);
+      size_t caption_len = strlen (capt);
 
-      if (caption_len <= max_lbl && caption[0] != '\0')
+      if (caption_len <= max_lbl && capt[0] != '\0')
         {
-          strcpy (buf, caption);
+          strcpy (buf, capt);
           while (caption_len > 0 && buf[caption_len - 1] == '.')
             caption_len--;
          buf[caption_len] = '\0';
-         label = caption = buf;
+         label = capt = buf;
         }
 
       if (strlen (label) <= max_lbl && label[0] != '\0')
         {
-          int i;
+          int j;
           if (label != buf)
            strcpy (buf, label);
 
-          for (i = 0; buf[i] != '\0'; ++i)
-           if (buf[i] == '-')
-             buf[i] = ' ';
+          for (j = 0; buf[j] != '\0'; ++j)
+           if (buf[j] == '-')
+             buf[j] = ' ';
           label = buf;
-
         }
       else
        label = "";
@@ -8439,7 +8448,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
   menu = read_char_minibuf_menu_text;
 
   /* Prompt string always starts with map's prompt, and a space.  */
-  strcpy (menu, SDATA (name));
+  strcpy (menu, SSDATA (name));
   nlength = SBYTES (name);
   menu[nlength++] = ':';
   menu[nlength++] = ' ';
@@ -8608,18 +8617,18 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
 
       /* Prompt with that and read response.  */
       message2_nolog (menu, strlen (menu),
-                     ! NILP (current_buffer->enable_multibyte_characters));
+                     ! NILP (BVAR (current_buffer, enable_multibyte_characters)));
 
       /* Make believe its not a keyboard macro in case the help char
         is pressed.  Help characters are not recorded because menu prompting
         is not used on replay.
         */
-      orig_defn_macro = current_kboard->defining_kbd_macro;
-      current_kboard->defining_kbd_macro = Qnil;
+      orig_defn_macro = KVAR (current_kboard, defining_kbd_macro);
+      KVAR (current_kboard, defining_kbd_macro) = Qnil;
       do
        obj = read_char (commandflag, 0, 0, Qt, 0, NULL);
       while (BUFFERP (obj));
-      current_kboard->defining_kbd_macro = orig_defn_macro;
+      KVAR (current_kboard, defining_kbd_macro) = orig_defn_macro;
 
       if (!INTEGERP (obj))
        return obj;
@@ -8632,7 +8641,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
          && (!INTEGERP (menu_prompt_more_char)
              || ! EQ (obj, make_number (Ctl (XINT (menu_prompt_more_char))))))
        {
-         if (!NILP (current_kboard->defining_kbd_macro))
+         if (!NILP (KVAR (current_kboard, defining_kbd_macro)))
            store_kbd_macro_char (obj);
          return obj;
        }
@@ -8865,7 +8874,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
 
   /* The length of the echo buffer when we started reading, and
      the length of this_command_keys when we started reading.  */
-  int echo_start;
+  int echo_start IF_LINT (= 0);
   int keys_start;
 
   /* The number of keymaps we're scanning right now, and the number of
@@ -8943,7 +8952,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
   Lisp_Object first_event;
 #endif
 
-  Lisp_Object original_uppercase;
+  Lisp_Object original_uppercase IF_LINT (= Qnil);
   int original_uppercase_position = -1;
 
   /* Gets around Microsoft compiler limitations.  */
@@ -8958,9 +8967,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
   int junk;
 #endif
 
-  struct gcpro gcpro1;
+  struct gcpro outer_gcpro1;
 
-  GCPRO1 (fake_prefixed_keys);
+  GCPRO1_VAR (fake_prefixed_keys, outer_gcpro);
   raw_keybuf_count = 0;
 
   last_nonmenu_event = Qnil;
@@ -8974,7 +8983,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
          /* Install the string STR as the beginning of the string of
             echoing, so that it serves as a prompt for the next
             character.  */
-         current_kboard->echo_string = prompt;
+         KVAR (current_kboard, echo_string) = prompt;
          current_kboard->echo_after_prompt = SCHARS (prompt);
          echo_now ();
        }
@@ -9012,8 +9021,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
      happens if we switch keyboards between rescans.  */
  replay_entire_sequence:
 
-  indec.map = indec.parent = current_kboard->Vinput_decode_map;
-  fkey.map = fkey.parent = current_kboard->Vlocal_function_key_map;
+  indec.map = indec.parent = KVAR (current_kboard, Vinput_decode_map);
+  fkey.map = fkey.parent = KVAR (current_kboard, Vlocal_function_key_map);
   keytran.map = keytran.parent = Vkey_translation_map;
   indec.start = indec.end = 0;
   fkey.start = fkey.end = 0;
@@ -9034,7 +9043,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
      the initial keymaps from the current buffer.  */
   nmaps = 0;
 
-  if (!NILP (current_kboard->Voverriding_terminal_local_map))
+  if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
     {
       if (2 > nmaps_allocated)
        {
@@ -9042,7 +9051,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
          defs    = (Lisp_Object *) alloca (2 * sizeof (defs[0]));
          nmaps_allocated = 2;
        }
-      submaps[nmaps++] = current_kboard->Voverriding_terminal_local_map;
+      submaps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map);
     }
   else if (!NILP (Voverriding_local_map))
     {
@@ -9122,7 +9131,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
         while those allow us to restart the entire key sequence,
         echo_local_start and keys_local_start allow us to throw away
         just one key.  */
-      int echo_local_start, keys_local_start, local_first_binding;
+      int echo_local_start IF_LINT (= 0);
+      int keys_local_start, local_first_binding;
 
       eassert (indec.end == t || (indec.end > t && indec.end <= mock_input));
       eassert (indec.start <= indec.end);
@@ -9218,29 +9228,29 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
 
                if (!NILP (delayed_switch_frame))
                  {
-                   interrupted_kboard->kbd_queue
+                   KVAR (interrupted_kboard, kbd_queue)
                      = Fcons (delayed_switch_frame,
-                              interrupted_kboard->kbd_queue);
+                              KVAR (interrupted_kboard, kbd_queue));
                    delayed_switch_frame = Qnil;
                  }
 
                while (t > 0)
-                 interrupted_kboard->kbd_queue
-                   = Fcons (keybuf[--t], interrupted_kboard->kbd_queue);
+                 KVAR (interrupted_kboard, kbd_queue)
+                   = Fcons (keybuf[--t], KVAR (interrupted_kboard, kbd_queue));
 
                /* If the side queue is non-empty, ensure it begins with a
                   switch-frame, so we'll replay it in the right context.  */
-               if (CONSP (interrupted_kboard->kbd_queue)
-                   && (key = XCAR (interrupted_kboard->kbd_queue),
+               if (CONSP (KVAR (interrupted_kboard, kbd_queue))
+                   && (key = XCAR (KVAR (interrupted_kboard, kbd_queue)),
                        !(EVENT_HAS_PARAMETERS (key)
                          && EQ (EVENT_HEAD_KIND (EVENT_HEAD (key)),
                                 Qswitch_frame))))
                  {
                    Lisp_Object frame;
                    XSETFRAME (frame, interrupted_frame);
-                   interrupted_kboard->kbd_queue
+                   KVAR (interrupted_kboard, kbd_queue)
                      = Fcons (make_lispy_switch_frame (frame),
-                              interrupted_kboard->kbd_queue);
+                              KVAR (interrupted_kboard, kbd_queue));
                  }
                mock_input = 0;
                orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
@@ -9254,7 +9264,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
          if (EQ (key, Qt))
            {
              unbind_to (count, Qnil);
-             UNGCPRO;
+             UNGCPRO_VAR (outer_gcpro);
              return -1;
            }
 
@@ -9832,7 +9842,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
          && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t
          && INTEGERP (key)
          && ((CHARACTERP (make_number (XINT (key) & ~CHAR_MODIFIER_MASK))
-              && UPPERCASEP (XINT (key) & ~CHAR_MODIFIER_MASK))
+              && uppercasep (XINT (key) & ~CHAR_MODIFIER_MASK))
              || (XINT (key) & shift_modifier)))
        {
          Lisp_Object new_key;
@@ -9843,7 +9853,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
          if (XINT (key) & shift_modifier)
            XSETINT (new_key, XINT (key) & ~shift_modifier);
          else
-           XSETINT (new_key, (DOWNCASE (XINT (key) & ~CHAR_MODIFIER_MASK)
+           XSETINT (new_key, (downcase (XINT (key) & ~CHAR_MODIFIER_MASK)
                               | (XINT (key) & CHAR_MODIFIER_MASK)));
 
          /* We have to do this unconditionally, regardless of whether
@@ -9870,14 +9880,14 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
              /* Treat uppercase keys as shifted.  */
              || (INTEGERP (key)
                  && (KEY_TO_CHAR (key)
-                     < XCHAR_TABLE (current_buffer->downcase_table)->size)
-                 && UPPERCASEP (KEY_TO_CHAR (key))))
+                     < XCHAR_TABLE (BVAR (current_buffer, downcase_table))->size)
+                 && uppercasep (KEY_TO_CHAR (key))))
            {
              Lisp_Object new_key
                = (modifiers & shift_modifier
                   ? apply_modifiers (modifiers & ~shift_modifier,
                                      XCAR (breakdown))
-                  : make_number (DOWNCASE (KEY_TO_CHAR (key)) | modifiers));
+                  : make_number (downcase (KEY_TO_CHAR (key)) | modifiers));
 
              original_uppercase = key;
              original_uppercase_position = t - 1;
@@ -9937,7 +9947,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
       add_command_key (keybuf[t]);
     }
 
-  UNGCPRO;
+  UNGCPRO_VAR (outer_gcpro);
   return t;
 }
 
@@ -9984,11 +9994,11 @@ is nil, then the event will be put off until after the current key sequence.
 sequences, where they wouldn't conflict with ordinary bindings.  See
 `function-key-map' for more details.
 
-The optional fifth argument COMMAND-LOOP, if non-nil, means
+The optional fifth argument CMD-LOOP, if non-nil, means
 that this key sequence is being read by something that will
 read commands one after another.  It should be nil if the caller
 will read just one key sequence.  */)
-  (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object command_loop)
+  (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop)
 {
   Lisp_Object keybuf[30];
   register int i;
@@ -10000,9 +10010,9 @@ will read just one key sequence.  */)
   QUIT;
 
   specbind (Qinput_method_exit_on_first_char,
-           (NILP (command_loop) ? Qt : Qnil));
+           (NILP (cmd_loop) ? Qt : Qnil));
   specbind (Qinput_method_use_echo_area,
-           (NILP (command_loop) ? Qt : Qnil));
+           (NILP (cmd_loop) ? Qt : Qnil));
 
   memset (keybuf, 0, sizeof keybuf);
   GCPRO1 (keybuf[0]);
@@ -10045,7 +10055,7 @@ will read just one key sequence.  */)
 DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector,
        Sread_key_sequence_vector, 1, 5, 0,
        doc: /* Like `read-key-sequence' but always return a vector.  */)
-  (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object command_loop)
+  (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop)
 {
   Lisp_Object keybuf[30];
   register int i;
@@ -10057,9 +10067,9 @@ DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector,
   QUIT;
 
   specbind (Qinput_method_exit_on_first_char,
-           (NILP (command_loop) ? Qt : Qnil));
+           (NILP (cmd_loop) ? Qt : Qnil));
   specbind (Qinput_method_use_echo_area,
-           (NILP (command_loop) ? Qt : Qnil));
+           (NILP (cmd_loop) ? Qt : Qnil));
 
   memset (keybuf, 0, sizeof keybuf);
   GCPRO1 (keybuf[0]);
@@ -10115,9 +10125,9 @@ a special event, so ignore the prefix argument and don't clear it.  */)
 
   if (NILP (special))
     {
-      prefixarg = current_kboard->Vprefix_arg;
+      prefixarg = KVAR (current_kboard, Vprefix_arg);
       Vcurrent_prefix_arg = prefixarg;
-      current_kboard->Vprefix_arg = Qnil;
+      KVAR (current_kboard, Vprefix_arg) = Qnil;
     }
   else
     prefixarg = Qnil;
@@ -10251,7 +10261,7 @@ give to the command you invoke, if it asks for an argument.  */)
   UNGCPRO;
 
   function = Fintern (function, Qnil);
-  current_kboard->Vprefix_arg = prefixarg;
+  KVAR (current_kboard, Vprefix_arg) = prefixarg;
   Vthis_command = function;
   real_this_command = function;
 
@@ -10562,7 +10572,7 @@ If FILE is nil, close any open dribble file.  */)
   if (!NILP (file))
     {
       file = Fexpand_file_name (file, Qnil);
-      dribble = fopen (SDATA (file), "w");
+      dribble = fopen (SSDATA (file), "w");
       if (dribble == 0)
        report_file_error ("Opening dribble", Fcons (file, Qnil));
     }
@@ -10574,7 +10584,7 @@ DEFUN ("discard-input", Fdiscard_input, Sdiscard_input, 0, 0, 0,
 Also end any kbd macro being defined.  */)
   (void)
 {
-  if (!NILP (current_kboard->defining_kbd_macro))
+  if (!NILP (KVAR (current_kboard, defining_kbd_macro)))
     {
       /* Discard the last command from the macro.  */
       Fcancel_kbd_macro_events ();
@@ -11224,30 +11234,30 @@ The `posn-' functions access elements of such lists.  */)
 void
 init_kboard (KBOARD *kb)
 {
-  kb->Voverriding_terminal_local_map = Qnil;
-  kb->Vlast_command = Qnil;
-  kb->Vreal_last_command = Qnil;
-  kb->Vkeyboard_translate_table = Qnil;
-  kb->Vlast_repeatable_command = Qnil;
-  kb->Vprefix_arg = Qnil;
-  kb->Vlast_prefix_arg = Qnil;
-  kb->kbd_queue = Qnil;
+  KVAR (kb, Voverriding_terminal_local_map) = Qnil;
+  KVAR (kb, Vlast_command) = Qnil;
+  KVAR (kb, Vreal_last_command) = Qnil;
+  KVAR (kb, Vkeyboard_translate_table) = Qnil;
+  KVAR (kb, Vlast_repeatable_command) = Qnil;
+  KVAR (kb, Vprefix_arg) = Qnil;
+  KVAR (kb, Vlast_prefix_arg) = Qnil;
+  KVAR (kb, kbd_queue) = Qnil;
   kb->kbd_queue_has_data = 0;
   kb->immediate_echo = 0;
-  kb->echo_string = Qnil;
+  KVAR (kb, echo_string) = Qnil;
   kb->echo_after_prompt = -1;
   kb->kbd_macro_buffer = 0;
   kb->kbd_macro_bufsize = 0;
-  kb->defining_kbd_macro = Qnil;
-  kb->Vlast_kbd_macro = Qnil;
+  KVAR (kb, defining_kbd_macro) = Qnil;
+  KVAR (kb, Vlast_kbd_macro) = Qnil;
   kb->reference_count = 0;
-  kb->Vsystem_key_alist = Qnil;
-  kb->system_key_syms = Qnil;
-  kb->Vwindow_system = Qt;     /* Unset.  */
-  kb->Vinput_decode_map = Fmake_sparse_keymap (Qnil);
-  kb->Vlocal_function_key_map = Fmake_sparse_keymap (Qnil);
-  Fset_keymap_parent (kb->Vlocal_function_key_map, Vfunction_key_map);
-  kb->Vdefault_minibuffer_frame = Qnil;
+  KVAR (kb, Vsystem_key_alist) = Qnil;
+  KVAR (kb, system_key_syms) = Qnil;
+  KVAR (kb, Vwindow_system) = Qt;      /* Unset.  */
+  KVAR (kb, Vinput_decode_map) = Fmake_sparse_keymap (Qnil);
+  KVAR (kb, Vlocal_function_key_map) = Fmake_sparse_keymap (Qnil);
+  Fset_keymap_parent (KVAR (kb, Vlocal_function_key_map), Vfunction_key_map);
+  KVAR (kb, Vdefault_minibuffer_frame) = Qnil;
 }
 
 /*
@@ -11323,7 +11333,7 @@ init_keyboard (void)
   init_kboard (current_kboard);
   /* A value of nil for Vwindow_system normally means a tty, but we also use
      it for the initial terminal since there is no window system there.  */
-  current_kboard->Vwindow_system = Qnil;
+  KVAR (current_kboard, Vwindow_system) = Qnil;
 
   if (!noninteractive)
     {
@@ -12266,23 +12276,23 @@ mark_kboards (void)
       if (kb->kbd_macro_buffer)
        for (p = kb->kbd_macro_buffer; p < kb->kbd_macro_ptr; p++)
          mark_object (*p);
-      mark_object (kb->Voverriding_terminal_local_map);
-      mark_object (kb->Vlast_command);
-      mark_object (kb->Vreal_last_command);
-      mark_object (kb->Vkeyboard_translate_table);
-      mark_object (kb->Vlast_repeatable_command);
-      mark_object (kb->Vprefix_arg);
-      mark_object (kb->Vlast_prefix_arg);
-      mark_object (kb->kbd_queue);
-      mark_object (kb->defining_kbd_macro);
-      mark_object (kb->Vlast_kbd_macro);
-      mark_object (kb->Vsystem_key_alist);
-      mark_object (kb->system_key_syms);
-      mark_object (kb->Vwindow_system);
-      mark_object (kb->Vinput_decode_map);
-      mark_object (kb->Vlocal_function_key_map);
-      mark_object (kb->Vdefault_minibuffer_frame);
-      mark_object (kb->echo_string);
+      mark_object (KVAR (kb, Voverriding_terminal_local_map));
+      mark_object (KVAR (kb, Vlast_command));
+      mark_object (KVAR (kb, Vreal_last_command));
+      mark_object (KVAR (kb, Vkeyboard_translate_table));
+      mark_object (KVAR (kb, Vlast_repeatable_command));
+      mark_object (KVAR (kb, Vprefix_arg));
+      mark_object (KVAR (kb, Vlast_prefix_arg));
+      mark_object (KVAR (kb, kbd_queue));
+      mark_object (KVAR (kb, defining_kbd_macro));
+      mark_object (KVAR (kb, Vlast_kbd_macro));
+      mark_object (KVAR (kb, Vsystem_key_alist));
+      mark_object (KVAR (kb, system_key_syms));
+      mark_object (KVAR (kb, Vwindow_system));
+      mark_object (KVAR (kb, Vinput_decode_map));
+      mark_object (KVAR (kb, Vlocal_function_key_map));
+      mark_object (KVAR (kb, Vdefault_minibuffer_frame));
+      mark_object (KVAR (kb, echo_string));
     }
   {
     struct input_event *event;