]> code.delx.au - gnu-emacs/blobdiff - src/keyboard.c
* buffer.c: Integer signedness fixes.
[gnu-emacs] / src / keyboard.c
index 7a8451d837598db6835ca6eb159c337882907a37..16300e6154c86db3583fba7c722ac12fd1ac58da 100644 (file)
@@ -96,16 +96,25 @@ int pending_signals;
 KBOARD *initial_kboard;
 KBOARD *current_kboard;
 KBOARD *all_kboards;
-int single_kboard;
+
+/* Nonzero in the single-kboard state, 0 in the any-kboard state.  */
+static int single_kboard;
 
 /* Non-nil disable property on a command means
    do not execute it; call disabled-command-function's value instead.  */
-Lisp_Object Qdisabled, Qdisabled_command_function;
+Lisp_Object Qdisabled;
+static Lisp_Object Qdisabled_command_function;
 
 #define NUM_RECENT_KEYS (300)
-int recent_keys_index; /* Index for storing next element into recent_keys */
-int total_keys;                /* Total number of elements stored into recent_keys */
-Lisp_Object recent_keys; /* Vector holds the last NUM_RECENT_KEYS keystrokes */
+
+/* Index for storing next element into recent_keys.  */
+static int recent_keys_index;
+
+/* Total number of elements stored into recent_keys.  */
+static int total_keys;
+
+/* This vector holds the last NUM_RECENT_KEYS keystrokes.  */
+static Lisp_Object recent_keys;
 
 /* Vector holding the key sequence that invoked the current command.
    It is reused for each command, and it may be longer than the current
@@ -117,20 +126,20 @@ int this_command_key_count;
 
 /* 1 after calling Freset_this_command_lengths.
    Usually it is 0.  */
-int this_command_key_count_reset;
+static int this_command_key_count_reset;
 
 /* This vector is used as a buffer to record the events that were actually read
    by read_key_sequence.  */
-Lisp_Object raw_keybuf;
-int raw_keybuf_count;
+static Lisp_Object raw_keybuf;
+static int raw_keybuf_count;
 
 #define GROW_RAW_KEYBUF                                                        \
- if (raw_keybuf_count == XVECTOR (raw_keybuf)->size)                   \
+ if (raw_keybuf_count == ASIZE (raw_keybuf))                           \
    raw_keybuf = larger_vector (raw_keybuf, raw_keybuf_count * 2, Qnil)  \
 
 /* Number of elements of this_command_keys
    that precede this key sequence.  */
-int this_single_command_key_start;
+static int this_single_command_key_start;
 
 /* Record values of this_command_key_count and echo_length ()
    before this command was read.  */
@@ -146,7 +155,7 @@ int waiting_for_input;
 
 /* True while displaying for echoing.   Delays C-g throwing.  */
 
-int echoing;
+static int echoing;
 
 /* Non-null means we can start echoing at the next input pause even
    though there is something in the echo area.  */
@@ -206,19 +215,19 @@ size_t num_input_events;
 
 /* Value of num_nonmacro_input_events as of last auto save.  */
 
-int last_auto_save;
+static int last_auto_save;
 
 /* This is like Vthis_command, except that commands never set it.  */
 Lisp_Object real_this_command;
 
 /* The value of point when the last command was started.  */
-EMACS_INT last_point_position;
+static EMACS_INT last_point_position;
 
 /* The buffer that was current when the last command was started.  */
-Lisp_Object last_point_position_buffer;
+static Lisp_Object last_point_position_buffer;
 
 /* The window that was selected when the last command was started.  */
-Lisp_Object last_point_position_window;
+static Lisp_Object last_point_position_window;
 
 /* The frame in which the last input event occurred, or Qmacro if the
    last event came from a macro.  We use this to determine when to
@@ -229,39 +238,44 @@ Lisp_Object internal_last_event_frame;
 
 /* The timestamp of the last input event we received from the X server.
    X Windows wants this for selection ownership.  */
-unsigned long last_event_timestamp;
+Time last_event_timestamp;
 
-Lisp_Object Qx_set_selection, QPRIMARY, Qhandle_switch_frame;
+static Lisp_Object Qx_set_selection, Qhandle_switch_frame;
+Lisp_Object QPRIMARY;
 
-Lisp_Object Qself_insert_command;
-Lisp_Object Qforward_char;
-Lisp_Object Qbackward_char;
+static Lisp_Object Qself_insert_command;
+static Lisp_Object Qforward_char;
+static Lisp_Object Qbackward_char;
 Lisp_Object Qundefined;
-Lisp_Object Qtimer_event_handler;
+static Lisp_Object Qtimer_event_handler;
 
 /* read_key_sequence stores here the command definition of the
    key sequence that it reads.  */
-Lisp_Object read_key_sequence_cmd;
+static Lisp_Object read_key_sequence_cmd;
 
-Lisp_Object Qinput_method_function;
+static Lisp_Object Qinput_method_function;
 
-Lisp_Object Qdeactivate_mark;
+static Lisp_Object Qdeactivate_mark;
 
 Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
 
-Lisp_Object Qecho_area_clear_hook;
+static Lisp_Object Qecho_area_clear_hook;
 
 /* Hooks to run before and after each command.  */
-Lisp_Object Qpre_command_hook;
-Lisp_Object Qpost_command_hook;
+static Lisp_Object Qpre_command_hook;
+static Lisp_Object Qpost_command_hook;
 
-Lisp_Object Qdeferred_action_function;
+static Lisp_Object Qdeferred_action_function;
 
-Lisp_Object Qinput_method_exit_on_first_char;
-Lisp_Object Qinput_method_use_echo_area;
+static Lisp_Object Qdelayed_warnings_hook;
+
+static Lisp_Object Qinput_method_exit_on_first_char;
+static Lisp_Object Qinput_method_use_echo_area;
+
+static Lisp_Object Qhelp_form_show;
 
 /* File in which we write all commands we read.  */
-FILE *dribble;
+static FILE *dribble;
 
 /* Nonzero if input is available.  */
 int input_pending;
@@ -291,42 +305,49 @@ static struct input_event * volatile kbd_store_ptr;
    at inopportune times.  */
 
 /* Symbols to head events.  */
-Lisp_Object Qmouse_movement;
-Lisp_Object Qscroll_bar_movement;
+static Lisp_Object Qmouse_movement;
+static Lisp_Object Qscroll_bar_movement;
 Lisp_Object Qswitch_frame;
-Lisp_Object Qdelete_frame;
-Lisp_Object Qiconify_frame;
-Lisp_Object Qmake_frame_visible;
-Lisp_Object Qselect_window;
+static Lisp_Object Qdelete_frame;
+static Lisp_Object Qiconify_frame;
+static Lisp_Object Qmake_frame_visible;
+static Lisp_Object Qselect_window;
 Lisp_Object Qhelp_echo;
 
 #if defined (HAVE_MOUSE) || defined (HAVE_GPM)
-Lisp_Object Qmouse_fixup_help_message;
+static Lisp_Object Qmouse_fixup_help_message;
 #endif
 
 /* Symbols to denote kinds of events.  */
-Lisp_Object Qfunction_key;
+static Lisp_Object Qfunction_key;
 Lisp_Object Qmouse_click;
 #if defined (WINDOWSNT)
 Lisp_Object Qlanguage_change;
 #endif
-Lisp_Object Qdrag_n_drop;
-Lisp_Object Qsave_session;
+static Lisp_Object Qdrag_n_drop;
+static Lisp_Object Qsave_session;
 #ifdef HAVE_DBUS
-Lisp_Object Qdbus_event;
+static Lisp_Object Qdbus_event;
 #endif
-Lisp_Object Qconfig_changed_event;
+static Lisp_Object Qconfig_changed_event;
 
 /* Lisp_Object Qmouse_movement; - also an event header */
 
 /* Properties of event headers.  */
 Lisp_Object Qevent_kind;
-Lisp_Object Qevent_symbol_elements;
+static Lisp_Object Qevent_symbol_elements;
 
 /* menu and tool bar item parts */
-Lisp_Object Qmenu_enable;
-Lisp_Object QCenable, QCvisible, QChelp, QCfilter, QCkeys, QCkey_sequence;
-Lisp_Object QCbutton, QCtoggle, QCradio, QClabel, QCvert_only;
+static Lisp_Object Qmenu_enable;
+static Lisp_Object QCenable, QCvisible, QChelp, QCkeys, QCkey_sequence;
+Lisp_Object QCfilter;
+
+/* Non-nil disable property on a command means
+   do not execute it; call disabled-command-function's value instead.  */
+Lisp_Object QCtoggle, QCradio;
+static Lisp_Object QCbutton, QClabel;
+
+static Lisp_Object QCvert_only;
 
 /* An event header symbol HEAD may have a property named
    Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS);
@@ -339,23 +360,24 @@ Lisp_Object Qevent_symbol_element_mask;
    Qmodifier_cache, which is an alist mapping modifier masks onto
    modified versions of BASE.  If present, this helps speed up
    apply_modifiers.  */
-Lisp_Object Qmodifier_cache;
+static Lisp_Object Qmodifier_cache;
 
 /* Symbols to use for parts of windows.  */
 Lisp_Object Qmode_line;
 Lisp_Object Qvertical_line;
-Lisp_Object Qvertical_scroll_bar;
+static Lisp_Object Qvertical_scroll_bar;
 Lisp_Object Qmenu_bar;
 
-Lisp_Object recursive_edit_unwind (Lisp_Object buffer), command_loop (void);
-Lisp_Object Fthis_command_keys (void);
-Lisp_Object Qextended_command_history;
+static Lisp_Object recursive_edit_unwind (Lisp_Object buffer);
+static Lisp_Object command_loop (void);
+static Lisp_Object Qextended_command_history;
 EMACS_TIME timer_check (void);
 
 static void record_menu_key (Lisp_Object c);
+static void echo_now (void);
 static int echo_length (void);
 
-Lisp_Object Qpolling_period;
+static Lisp_Object Qpolling_period;
 
 /* Incremented whenever a timer is run.  */
 int timers_run;
@@ -408,7 +430,7 @@ static EMACS_TIME timer_last_idleness_start_time;
 #define READABLE_EVENTS_IGNORE_SQUEEZABLES     (1 << 2)
 
 /* Function for init_keyboard to call with no args (if nonzero).  */
-void (*keyboard_init_hook) (void);
+static void (*keyboard_init_hook) (void);
 
 static int read_avail_input (int);
 static void get_input_pending (int *, int);
@@ -426,8 +448,9 @@ static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object,
 #endif
 static Lisp_Object modify_event_symbol (EMACS_INT, unsigned, Lisp_Object,
                                         Lisp_Object, const char *const *,
-                                        Lisp_Object *, unsigned);
+                                        Lisp_Object *, EMACS_INT);
 static Lisp_Object make_lispy_switch_frame (Lisp_Object);
+static int help_char_p (Lisp_Object);
 static void save_getcjmp (jmp_buf);
 static void restore_getcjmp (jmp_buf);
 static Lisp_Object apply_modifiers (int, Lisp_Object);
@@ -437,7 +460,10 @@ static void interrupt_signal (int signalnum);
 #ifdef SIGIO
 static void input_available_signal (int signo);
 #endif
+static Lisp_Object (Fcommand_execute) (Lisp_Object, Lisp_Object, Lisp_Object,
+                                      Lisp_Object);
 static void handle_interrupt (void);
+static void quit_throw_to_read_char (void) NO_RETURN;
 static void timer_start_idle (void);
 static void timer_stop_idle (void);
 static void timer_resume_idle (void);
@@ -581,7 +607,7 @@ echo_dash (void)
 /* Display the current echo string, and begin echoing if not already
    doing so.  */
 
-void
+static void
 echo_now (void)
 {
   if (!current_kboard->immediate_echo)
@@ -748,6 +774,7 @@ record_auto_save (void)
 
 /* Make an auto save happen as soon as possible at command level.  */
 
+#ifdef SIGDANGER
 void
 force_auto_save_soon (void)
 {
@@ -755,6 +782,7 @@ force_auto_save_soon (void)
 
   record_asynch_buffer_change ();
 }
+#endif
 \f
 DEFUN ("recursive-edit", Frecursive_edit, Srecursive_edit, 0, 0, "",
        doc: /* Invoke the editor command loop recursively.
@@ -1077,8 +1105,8 @@ cmd_error_internal (Lisp_Object data, const char *context)
 }
 \f
 Lisp_Object command_loop_1 (void);
-Lisp_Object command_loop_2 (Lisp_Object);
-Lisp_Object top_level_1 (Lisp_Object);
+static Lisp_Object command_loop_2 (Lisp_Object);
+static Lisp_Object top_level_1 (Lisp_Object);
 
 /* Entry to editor-command-loop.
    This level has the catches for exiting/returning to editor command loop.
@@ -1168,7 +1196,7 @@ This also exits all active minibuffers.  */)
   Fthrow (Qtop_level, Qnil);
 }
 
-Lisp_Object Fexit_recursive_edit (void) NO_RETURN;
+static 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,7 +1207,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;
+static 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)
@@ -1242,6 +1270,9 @@ usage: (track-mouse BODY...)  */)
    If ignore_mouse_drag_p is non-zero, ignore (implicit) mouse movement
    after resizing the tool-bar window.  */
 
+#if !defined HAVE_WINDOW_SYSTEM || defined USE_GTK || defined HAVE_NS
+static
+#endif
 int ignore_mouse_drag_p;
 
 static FRAME_PTR
@@ -1327,6 +1358,10 @@ command_loop_1 (void)
       if (!NILP (echo_area_buffer[0]))
        resize_echo_area_exactly ();
 
+      /* If there are warnings waiting, process them.  */
+      if (!NILP (Vdelayed_warnings_list))
+        safe_run_hooks (Qdelayed_warnings_hook);
+
       if (!NILP (Vdeferred_action_list))
        safe_run_hooks (Qdeferred_action_function);
     }
@@ -1504,7 +1539,18 @@ command_loop_1 (void)
          message_with_string ("%s is undefined", keys, 0);
          KVAR (current_kboard, defining_kbd_macro) = Qnil;
          update_mode_lines = 1;
-         KVAR (current_kboard, Vprefix_arg) = Qnil;
+         /* If this is a down-mouse event, don't reset prefix-arg;
+            pass it to the command run by the up event.  */
+         if (EVENT_HAS_PARAMETERS (last_command_event))
+           {
+             Lisp_Object breakdown
+               = parse_modifiers (EVENT_HEAD (last_command_event));
+             int modifiers = XINT (XCAR (XCDR (breakdown)));
+             if (!(modifiers & down_modifier))
+               KVAR (current_kboard, Vprefix_arg) = Qnil;
+           }
+         else
+           KVAR (current_kboard, Vprefix_arg) = Qnil;
        }
       else
        {
@@ -1544,6 +1590,10 @@ command_loop_1 (void)
       if (!NILP (echo_area_buffer[0]))
        resize_echo_area_exactly ();
 
+      /* If there are warnings waiting, process them.  */
+      if (!NILP (Vdelayed_warnings_list))
+        safe_run_hooks (Qdelayed_warnings_hook);
+
       safe_run_hooks (Qdeferred_action_function);
 
       /* If there is a prefix argument,
@@ -1690,7 +1740,7 @@ adjust_point_for_property (EMACS_INT last_pt, int modified)
          && PT > BEGV && PT < ZV
          && !NILP (val = get_char_property_and_overlay
                              (make_number (PT), Qdisplay, Qnil, &overlay))
-         && display_prop_intangible_p (val)
+         && display_prop_intangible_p (val, overlay, PT, PT_BYTE)
          && (!OVERLAYP (overlay)
              ? get_property_and_range (PT, Qdisplay, &val, &beg, &end, Qnil)
              : (beg = OVERLAY_POSITION (OVERLAY_START (overlay)),
@@ -1862,7 +1912,7 @@ safe_run_hooks_error (Lisp_Object error_data)
 }
 
 static Lisp_Object
-safe_run_hook_funcall (size_t nargs, Lisp_Object *args)
+safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args)
 {
   eassert (nargs == 1);
   if (CONSP (Vinhibit_quit))
@@ -1899,7 +1949,7 @@ int poll_suppress_count;
 
 /* Asynchronous timer for polling.  */
 
-struct atimer *poll_timer;
+static struct atimer *poll_timer;
 
 
 #ifdef POLL_FOR_INPUT
@@ -2166,7 +2216,6 @@ show_help_echo (Lisp_Object help, Lisp_Object window, Lisp_Object object,
 \f
 /* Input of single characters from keyboard */
 
-Lisp_Object print_help (Lisp_Object object);
 static Lisp_Object kbd_buffer_get_event (KBOARD **kbp, int *used_mouse_menu,
                                         struct timeval *end_time);
 static void record_char (Lisp_Object c);
@@ -2231,7 +2280,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
   volatile Lisp_Object also_record;
   volatile int reread;
   struct gcpro gcpro1, gcpro2;
-  int polling_stopped_here = 0;
+  int volatile polling_stopped_here = 0;
   struct kboard *orig_kboard = current_kboard;
 
   also_record = Qnil;
@@ -2357,8 +2406,8 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
 
       c = Faref (Vexecuting_kbd_macro, make_number (executing_kbd_macro_index));
       if (STRINGP (Vexecuting_kbd_macro)
-         && (XINT (c) & 0x80) && (XUINT (c) <= 0xff))
-       XSETFASTINT (c, CHAR_META | (XINT (c) & ~0x80));
+         && (XFASTINT (c) & 0x80) && (XFASTINT (c) <= 0xff))
+       XSETFASTINT (c, CHAR_META | (XFASTINT (c) & ~0x80));
 
       executing_kbd_macro_index++;
 
@@ -2868,9 +2917,13 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
        goto exit;
 
       if ((STRINGP (KVAR (current_kboard, Vkeyboard_translate_table))
-          && SCHARS (KVAR (current_kboard, Vkeyboard_translate_table)) > (unsigned) XFASTINT (c))
+          && UNSIGNED_CMP (XFASTINT (c), <,
+                           SCHARS (KVAR (current_kboard,
+                                         Vkeyboard_translate_table))))
          || (VECTORP (KVAR (current_kboard, Vkeyboard_translate_table))
-             && XVECTOR (KVAR (current_kboard, Vkeyboard_translate_table))->size > (unsigned) XFASTINT (c))
+             && UNSIGNED_CMP (XFASTINT (c), <,
+                              ASIZE (KVAR (current_kboard,
+                                           Vkeyboard_translate_table))))
          || (CHAR_TABLE_P (KVAR (current_kboard, Vkeyboard_translate_table))
              && CHARACTERP (c)))
        {
@@ -2917,9 +2970,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
      save the echo area contents for it to refer to.  */
   if (INTEGERP (c)
       && ! NILP (Vinput_method_function)
-      && (unsigned) XINT (c) >= ' '
-      && (unsigned) XINT (c) != 127
-      && (unsigned) XINT (c) < 256)
+      && ' ' <= XINT (c) && XINT (c) < 256 && XINT (c) != 127)
     {
       previous_echo_area_message = Fcurrent_message ();
       Vinput_method_previous_message = previous_echo_area_message;
@@ -2944,9 +2995,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
       /* Don't run the input method within a key sequence,
         after the first event of the key sequence.  */
       && NILP (prev_event)
-      && (unsigned) XINT (c) >= ' '
-      && (unsigned) XINT (c) != 127
-      && (unsigned) XINT (c) < 256)
+      && ' ' <= XINT (c) && XINT (c) < 256 && XINT (c) != 127)
     {
       Lisp_Object keys;
       int key_count, key_count_reset;
@@ -3088,17 +3137,13 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
   /* Process the help character specially if enabled */
   if (!NILP (Vhelp_form) && help_char_p (c))
     {
-      Lisp_Object tem0;
       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, Qnil);
-      if (STRINGP (tem0))
-       internal_with_output_to_temp_buffer ("*Help*", print_help, tem0);
+      call0 (Qhelp_form_show);
 
       cancel_echoing ();
       do
@@ -3164,7 +3209,7 @@ record_menu_key (Lisp_Object c)
 
 /* Return 1 if should recognize C as "the help character".  */
 
-int
+static int
 help_char_p (Lisp_Object c)
 {
   Lisp_Object tail;
@@ -3287,9 +3332,9 @@ record_char (Lisp_Object c)
       if (INTEGERP (c))
        {
          if (XUINT (c) < 0x100)
-           putc (XINT (c), dribble);
+           putc (XUINT (c), dribble);
          else
-           fprintf (dribble, " 0x%x", (int) XUINT (c));
+           fprintf (dribble, " 0x%"pI"x", XUINT (c));
        }
       else
        {
@@ -3313,17 +3358,6 @@ record_char (Lisp_Object c)
     }
 }
 
-Lisp_Object
-print_help (Lisp_Object object)
-{
-  struct buffer *old = current_buffer;
-  Fprinc (object, Qnil);
-  set_buffer_internal (XBUFFER (Vstandard_output));
-  call0 (intern ("help-mode"));
-  set_buffer_internal (old);
-  return Qnil;
-}
-
 /* Copy out or in the info on where C-g should throw to.
    This is used when running Lisp code from within get_char,
    in case get_char is called recursively.
@@ -3415,7 +3449,7 @@ readable_events (int flags)
 }
 
 /* Set this for debugging, to have a way to get out */
-int stop_character;
+int stop_character EXTERNALLY_VISIBLE;
 
 static KBOARD *
 event_to_kboard (struct input_event *event)
@@ -3719,7 +3753,7 @@ kbd_buffer_events_waiting (int discard)
 \f
 /* Clear input event EVENT.  */
 
-static INLINE void
+static inline void
 clear_event (struct input_event *event)
 {
   event->kind = NO_EVENT;
@@ -4062,7 +4096,7 @@ kbd_buffer_get_event (KBOARD **kbp,
       Lisp_Object bar_window;
       enum scroll_bar_part part;
       Lisp_Object x, y;
-      unsigned long t;
+      Time t;
 
       *kbp = current_kboard;
       /* Note that this uses F to determine which terminal to look at.
@@ -4185,7 +4219,7 @@ timer_start_idle (void)
 
       timer = XCAR (timers);
 
-      if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
+      if (!VECTORP (timer) || ASIZE (timer) != 8)
        continue;
       XVECTOR (timer)->contents[0] = Qnil;
     }
@@ -4211,7 +4245,7 @@ timer_resume_idle (void)
 }
 
 /* This is only for debugging.  */
-struct input_event last_timer_event;
+struct input_event last_timer_event EXTERNALLY_VISIBLE;
 
 /* List of elisp functions to call, delayed because they were generated in
    a context where Elisp could not be safely run (e.g. redisplay, signal,
@@ -4280,7 +4314,7 @@ timer_check_2 (void)
       if (CONSP (timers))
        {
          timer = XCAR (timers);
-         if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
+         if (!VECTORP (timer) || ASIZE (timer) != 8)
            {
              timers = XCDR (timers);
              continue;
@@ -4298,7 +4332,7 @@ timer_check_2 (void)
       if (CONSP (idle_timers))
        {
          timer = XCAR (idle_timers);
-         if (!VECTORP (timer) || XVECTOR (timer)->size != 8)
+         if (!VECTORP (timer) || ASIZE (timer) != 8)
            {
              idle_timers = XCDR (idle_timers);
              continue;
@@ -5019,7 +5053,7 @@ static const char *const iso_lispy_function_keys[] =
 
 #endif /* not HAVE_NTGUI */
 
-Lisp_Object Vlispy_mouse_stem;
+static Lisp_Object Vlispy_mouse_stem;
 
 static const char *const lispy_wheel_names[] =
 {
@@ -5034,9 +5068,11 @@ static const char *const lispy_drag_n_drop_names[] =
 };
 
 /* Scroll bar parts.  */
-Lisp_Object Qabove_handle, Qhandle, Qbelow_handle;
-Lisp_Object Qup, Qdown, Qbottom, Qend_scroll;
-Lisp_Object Qtop, Qratio;
+static Lisp_Object Qabove_handle, Qhandle, Qbelow_handle;
+Lisp_Object Qup, Qdown, Qbottom;
+static Lisp_Object Qend_scroll;
+Lisp_Object Qtop;
+static Lisp_Object Qratio;
 
 /* An array of scroll bar parts, indexed by an enum scroll_bar_part value.  */
 static Lisp_Object *const scroll_bar_parts[] = {
@@ -5063,18 +5099,18 @@ static Lisp_Object button_down_location;
 static int last_mouse_button;
 static int last_mouse_x;
 static int last_mouse_y;
-static unsigned long button_down_time;
+static Time button_down_time;
 
 /* The number of clicks in this multiple-click. */
 
-int double_click_count;
+static int double_click_count;
 
 /* X and Y are frame-relative coordinates for a click or wheel event.
    Return a Lisp-style event list.  */
 
 static Lisp_Object
 make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
-                    unsigned long t)
+                    Time t)
 {
   enum window_part part;
   Lisp_Object posn = Qnil;
@@ -5366,7 +5402,7 @@ make_lispy_event (struct input_event *event)
                                      Qfunction_key,
                                      KVAR (current_kboard, Vsystem_key_alist),
                                      0, &KVAR (current_kboard, system_key_syms),
-                                     (unsigned) -1);
+                                     TYPE_MAXIMUM (EMACS_INT));
        }
 
       return modify_event_symbol (event->code - FUNCTION_KEY_OFFSET,
@@ -5440,12 +5476,11 @@ make_lispy_event (struct input_event *event)
                && (event->modifiers & down_modifier))
              {
                Lisp_Object items, item;
-               int i;
 
                /* Find the menu bar item under `column'.  */
                item = Qnil;
                items = FRAME_MENU_BAR_ITEMS (f);
-               for (i = 0; i < XVECTOR (items)->size; i += 4)
+               for (i = 0; i < ASIZE (items); i += 4)
                  {
                    Lisp_Object pos, string;
                    string = AREF (items, i + 1);
@@ -5532,9 +5567,9 @@ make_lispy_event (struct input_event *event)
                       && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
                       && button_down_time != 0
                       && (EQ (Vdouble_click_time, Qt)
-                          || (INTEGERP (Vdouble_click_time)
-                              && ((int)(event->timestamp - button_down_time)
-                                  < XINT (Vdouble_click_time)))));
+                          || (NATNUMP (Vdouble_click_time)
+                              && (event->timestamp - button_down_time
+                                  < XFASTINT (Vdouble_click_time)))));
        }
 
        last_mouse_button = button;
@@ -5638,7 +5673,7 @@ make_lispy_event (struct input_event *event)
                                      Qmouse_click, Vlispy_mouse_stem,
                                      NULL,
                                      &mouse_syms,
-                                     XVECTOR (mouse_syms)->size);
+                                     ASIZE (mouse_syms));
          if (event->modifiers & drag_modifier)
            return Fcons (head,
                          Fcons (start_pos,
@@ -5718,9 +5753,9 @@ make_lispy_event (struct input_event *event)
                       && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
                       && button_down_time != 0
                       && (EQ (Vdouble_click_time, Qt)
-                          || (INTEGERP (Vdouble_click_time)
-                              && ((int)(event->timestamp - button_down_time)
-                                  < XINT (Vdouble_click_time)))));
+                          || (NATNUMP (Vdouble_click_time)
+                              && (event->timestamp - button_down_time
+                                  < XFASTINT (Vdouble_click_time)))));
          if (is_double)
            {
              double_click_count++;
@@ -5809,7 +5844,7 @@ make_lispy_event (struct input_event *event)
                                    Qmouse_click,
                                    Vlispy_mouse_stem,
                                    NULL, &mouse_syms,
-                                   XVECTOR (mouse_syms)->size);
+                                   ASIZE (mouse_syms));
        return Fcons (head, Fcons (position, Qnil));
       }
 
@@ -5929,7 +5964,7 @@ make_lispy_event (struct input_event *event)
                                    Qmouse_click, Vlispy_mouse_stem,
                                    NULL,
                                    &mouse_syms,
-                                   XVECTOR (mouse_syms)->size);
+                                   ASIZE (mouse_syms));
 
        if (event->modifiers & drag_modifier)
          return Fcons (head,
@@ -5963,7 +5998,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 t)
+                    Lisp_Object x, Lisp_Object y, Time t)
 {
   /* Is it a scroll bar movement?  */
   if (frame && ! NILP (bar_window))
@@ -6346,7 +6381,7 @@ reorder_modifiers (Lisp_Object symbol)
   Lisp_Object parsed;
 
   parsed = parse_modifiers (symbol);
-  return apply_modifiers ((int) XINT (XCAR (XCDR (parsed))),
+  return apply_modifiers (XFASTINT (XCAR (XCDR (parsed))),
                          XCAR (parsed));
 }
 
@@ -6386,7 +6421,7 @@ reorder_modifiers (Lisp_Object symbol)
 static Lisp_Object
 modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object symbol_kind,
                     Lisp_Object name_alist_or_stem, const char *const *name_table,
-                    Lisp_Object *symbol_table, unsigned int table_size)
+                    Lisp_Object *symbol_table, EMACS_INT table_size)
 {
   Lisp_Object value;
   Lisp_Object symbol_int;
@@ -6408,7 +6443,7 @@ modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object s
   else
     {
       if (! VECTORP (*symbol_table)
-         || XVECTOR (*symbol_table)->size != table_size)
+         || ASIZE (*symbol_table) != table_size)
        {
          Lisp_Object size;
 
@@ -6429,8 +6464,8 @@ modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object s
        {
          int len = SBYTES (name_alist_or_stem);
          char *buf = (char *) alloca (len + 50);
-          sprintf (buf, "%s-%ld", SDATA (name_alist_or_stem),
-                   (long) XINT (symbol_int) + 1);
+          sprintf (buf, "%s-%"pI"d", SDATA (name_alist_or_stem),
+                   XINT (symbol_int) + 1);
          value = intern (buf);
        }
       else if (name_table != 0 && name_table[symbol_num])
@@ -6448,7 +6483,7 @@ modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object s
       if (NILP (value))
        {
          char buf[20];
-         sprintf (buf, "key-%ld", (long)symbol_num);
+         sprintf (buf, "key-%"pI"d", symbol_num);
          value = intern (buf);
        }
 
@@ -7214,12 +7249,29 @@ handle_user_signal (int sig)
 {
   int old_errno = errno;
   struct user_signal_info *p;
+  const char *special_event_name = NULL;
 
   SIGNAL_THREAD_CHECK (sig);
 
+  if (SYMBOLP (Vdebug_on_event))
+    special_event_name = SSDATA (SYMBOL_NAME (Vdebug_on_event));
+
   for (p = user_signals; p; p = p->next)
     if (p->sig == sig)
       {
+        if (special_event_name &&
+            strcmp (special_event_name, p->name) == 0)
+          {
+            /* Enter the debugger in many ways.  */
+            debug_on_next_call = 1;
+            debug_on_quit = 1;
+            Vquit_flag = Qt;
+            Vinhibit_quit = Qnil;
+
+            /* Eat the event.  */
+            break;
+          }
+
        p->npending++;
 #ifdef SIGIO
        if (interrupt_input)
@@ -7429,7 +7481,7 @@ menu_bar_items (Lisp_Object old)
        if (CONSP (def))
          {
            menu_bar_one_keymap_changed_items = Qnil;
-           map_keymap (def, menu_bar_item, Qnil, NULL, 1);
+           map_keymap_canonical (def, menu_bar_item, Qnil, NULL);
          }
       }
 
@@ -7465,7 +7517,7 @@ menu_bar_items (Lisp_Object old)
   /* Add nil, nil, nil, nil at the end.  */
   {
     int i = menu_bar_items_index;
-    if (i + 4 > XVECTOR (menu_bar_items_vector)->size)
+    if (i + 4 > ASIZE (menu_bar_items_vector))
       menu_bar_items_vector =
        larger_vector (menu_bar_items_vector, 2 * i, Qnil);
     /* Add this item.  */
@@ -7537,7 +7589,7 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
   if (i == menu_bar_items_index)
     {
       /* If vector is too small, get a bigger one.  */
-      if (i + 4 > XVECTOR (menu_bar_items_vector)->size)
+      if (i + 4 > ASIZE (menu_bar_items_vector))
        menu_bar_items_vector = larger_vector (menu_bar_items_vector, 2 * i, Qnil);
       /* Add this item.  */
       XVECTOR (menu_bar_items_vector)->contents[i++] = key;
@@ -7770,7 +7822,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
   /* If we got no definition, this item is just unselectable text which
      is OK in a submenu but not in the menubar.  */
   if (NILP (def))
-    return (inmenubar ? 0 : 1);
+    return (!inmenubar);
 
   /* See if this is a separate pane or a submenu.  */
   def = AREF (item_properties, ITEM_PROPERTY_DEF);
@@ -7891,8 +7943,8 @@ static int ntool_bar_items;
 
 /* The symbols `:image' and `:rtl'.  */
 
-Lisp_Object QCimage;
-Lisp_Object Qrtl;
+static Lisp_Object QCimage;
+static Lisp_Object QCrtl;
 
 /* Function prototypes.  */
 
@@ -8184,7 +8236,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
           /* `:label LABEL-STRING'.  */
           PROP (TOOL_BAR_ITEM_LABEL) = STRINGP (value)
             ? value
-            : make_string (bad_label, strlen (bad_label));
+            : build_string (bad_label);
           have_label = 1;
         }
       else if (EQ (ikey, QCfilter))
@@ -8205,11 +8257,11 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
        }
       else if (EQ (ikey, QCimage)
               && (CONSP (value)
-                  || (VECTORP (value) && XVECTOR (value)->size == 4)))
+                  || (VECTORP (value) && ASIZE (value) == 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 (ikey, Qrtl))
+      else if (EQ (ikey, QCrtl))
         /* ':rtl STRING' */
        PROP (TOOL_BAR_ITEM_RTL_IMAGE) = value;
     }
@@ -8250,12 +8302,12 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
       else
        label = "";
 
-      new_lbl = Fupcase_initials (make_string (label, strlen (label)));
+      new_lbl = Fupcase_initials (build_string (label));
       if (SCHARS (new_lbl) <= tool_bar_max_label_size)
         PROP (TOOL_BAR_ITEM_LABEL) = new_lbl;
       else
         PROP (TOOL_BAR_ITEM_LABEL) = make_string ("", 0);
-      free (buf);
+      xfree (buf);
     }
 
   /* If got a filter apply it on binding.  */
@@ -8309,10 +8361,10 @@ append_tool_bar_item (void)
 
   /* Enlarge tool_bar_items_vector if necessary.  */
   if (ntool_bar_items + TOOL_BAR_ITEM_NSLOTS
-      >= XVECTOR (tool_bar_items_vector)->size)
+      >= ASIZE (tool_bar_items_vector))
     tool_bar_items_vector
       = larger_vector (tool_bar_items_vector,
-                      2 * XVECTOR (tool_bar_items_vector)->size, Qnil);
+                      2 * ASIZE (tool_bar_items_vector), Qnil);
 
   /* Append entries from tool_bar_item_properties to the end of
      tool_bar_items_vector.  */
@@ -8634,7 +8686,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
                }
 
              /* Move past this element.  */
-             if (idx >= 0 && idx + 1 >= XVECTOR (vector)->size)
+             if (idx >= 0 && idx + 1 >= ASIZE (vector))
                /* Handle reaching end of dense table.  */
                idx = -1;
              if (idx >= 0)
@@ -9912,7 +9964,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
              /* Treat uppercase keys as shifted.  */
              || (INTEGERP (key)
                  && (KEY_TO_CHAR (key)
-                     < XCHAR_TABLE (BVAR (current_buffer, downcase_table))->size)
+                     < XCHAR_TABLE (BVAR (current_buffer, downcase_table))->header.size)
                  && uppercasep (KEY_TO_CHAR (key))))
            {
              Lisp_Object new_key
@@ -10278,7 +10330,7 @@ give to the command you invoke, if it asks for an argument.  */)
     this_single_command_key_start = 0;
 
     keys = XVECTOR (saved_keys)->contents;
-    for (i = 0; i < XVECTOR (saved_keys)->size; i++)
+    for (i = 0; i < ASIZE (saved_keys); i++)
       add_command_key (keys[i]);
 
     for (i = 0; i < SCHARS (function); i++)
@@ -10571,7 +10623,7 @@ KEEP-RECORD is non-nil.  */)
 
   if (NILP (keep_record))
     {
-      for (i = 0; i < XVECTOR (recent_keys)->size; ++i)
+      for (i = 0; i < ASIZE (recent_keys); ++i)
        XVECTOR (recent_keys)->contents[i] = Qnil;
       total_keys = 0;
       recent_keys_index = 0;
@@ -10936,7 +10988,7 @@ handle_interrupt (void)
 
 /* Handle a C-g by making read_char return C-g.  */
 
-void
+static void
 quit_throw_to_read_char (void)
 {
   sigfree ();
@@ -10964,7 +11016,8 @@ quit_throw_to_read_char (void)
   _longjmp (getcjmp, 1);
 }
 \f
-DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode, Sset_input_interrupt_mode, 1, 1, 0,
+DEFUN ("set-input-interrupt-mode", Fset_input_interrupt_mode,
+       Sset_input_interrupt_mode, 1, 1, 0,
        doc: /* Set interrupt mode of reading keyboard input.
 If INTERRUPT is non-nil, Emacs will use input interrupts;
 otherwise Emacs uses CBREAK mode.
@@ -11441,14 +11494,9 @@ syms_of_keyboard (void)
   staticpro (&Vlispy_mouse_stem);
 
   /* Tool-bars.  */
-  QCimage = intern_c_string (":image");
-  staticpro (&QCimage);
-
-  staticpro (&Qhelp_echo);
-  Qhelp_echo = intern_c_string ("help-echo");
-
-  staticpro (&Qrtl);
-  Qrtl = intern_c_string (":rtl");
+  DEFSYM (QCimage, ":image");
+  DEFSYM (Qhelp_echo, "help-echo");
+  DEFSYM (QCrtl, ":rtl");
 
   staticpro (&item_properties);
   item_properties = Qnil;
@@ -11461,147 +11509,82 @@ syms_of_keyboard (void)
   staticpro (&real_this_command);
   real_this_command = Qnil;
 
-  Qtimer_event_handler = intern_c_string ("timer-event-handler");
-  staticpro (&Qtimer_event_handler);
-
-  Qdisabled_command_function = intern_c_string ("disabled-command-function");
-  staticpro (&Qdisabled_command_function);
-
-  Qself_insert_command = intern_c_string ("self-insert-command");
-  staticpro (&Qself_insert_command);
-
-  Qforward_char = intern_c_string ("forward-char");
-  staticpro (&Qforward_char);
+  DEFSYM (Qtimer_event_handler, "timer-event-handler");
+  DEFSYM (Qdisabled_command_function, "disabled-command-function");
+  DEFSYM (Qself_insert_command, "self-insert-command");
+  DEFSYM (Qforward_char, "forward-char");
+  DEFSYM (Qbackward_char, "backward-char");
+  DEFSYM (Qdisabled, "disabled");
+  DEFSYM (Qundefined, "undefined");
+  DEFSYM (Qpre_command_hook, "pre-command-hook");
+  DEFSYM (Qpost_command_hook, "post-command-hook");
+  DEFSYM (Qdeferred_action_function, "deferred-action-function");
+  DEFSYM (Qdelayed_warnings_hook, "delayed-warnings-hook");
+  DEFSYM (Qfunction_key, "function-key");
+  DEFSYM (Qmouse_click, "mouse-click");
+  DEFSYM (Qdrag_n_drop, "drag-n-drop");
+  DEFSYM (Qsave_session, "save-session");
+  DEFSYM (Qconfig_changed_event, "config-changed-event");
+  DEFSYM (Qmenu_enable, "menu-enable");
 
-  Qbackward_char = intern_c_string ("backward-char");
-  staticpro (&Qbackward_char);
+#if defined (WINDOWSNT)
+  DEFSYM (Qlanguage_change, "language-change");
+#endif
 
-  Qdisabled = intern_c_string ("disabled");
-  staticpro (&Qdisabled);
+#ifdef HAVE_DBUS
+  DEFSYM (Qdbus_event, "dbus-event");
+#endif
+
+  DEFSYM (QCenable, ":enable");
+  DEFSYM (QCvisible, ":visible");
+  DEFSYM (QChelp, ":help");
+  DEFSYM (QCfilter, ":filter");
+  DEFSYM (QCbutton, ":button");
+  DEFSYM (QCkeys, ":keys");
+  DEFSYM (QCkey_sequence, ":key-sequence");
+  DEFSYM (QCtoggle, ":toggle");
+  DEFSYM (QCradio, ":radio");
+  DEFSYM (QClabel, ":label");
+  DEFSYM (QCvert_only, ":vert-only");
+
+  DEFSYM (Qmode_line, "mode-line");
+  DEFSYM (Qvertical_line, "vertical-line");
+  DEFSYM (Qvertical_scroll_bar, "vertical-scroll-bar");
+  DEFSYM (Qmenu_bar, "menu-bar");
 
-  Qundefined = intern_c_string ("undefined");
-  staticpro (&Qundefined);
+#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
+  DEFSYM (Qmouse_fixup_help_message, "mouse-fixup-help-message");
+#endif
 
-  Qpre_command_hook = intern_c_string ("pre-command-hook");
-  staticpro (&Qpre_command_hook);
+  DEFSYM (Qabove_handle, "above-handle");
+  DEFSYM (Qhandle, "handle");
+  DEFSYM (Qbelow_handle, "below-handle");
+  DEFSYM (Qup, "up");
+  DEFSYM (Qdown, "down");
+  DEFSYM (Qtop, "top");
+  DEFSYM (Qbottom, "bottom");
+  DEFSYM (Qend_scroll, "end-scroll");
+  DEFSYM (Qratio, "ratio");
 
-  Qpost_command_hook = intern_c_string ("post-command-hook");
-  staticpro (&Qpost_command_hook);
+  DEFSYM (Qevent_kind, "event-kind");
+  DEFSYM (Qevent_symbol_elements, "event-symbol-elements");
+  DEFSYM (Qevent_symbol_element_mask, "event-symbol-element-mask");
+  DEFSYM (Qmodifier_cache, "modifier-cache");
 
-  Qdeferred_action_function = intern_c_string ("deferred-action-function");
-  staticpro (&Qdeferred_action_function);
+  DEFSYM (Qrecompute_lucid_menubar, "recompute-lucid-menubar");
+  DEFSYM (Qactivate_menubar_hook, "activate-menubar-hook");
 
-  Qfunction_key = intern_c_string ("function-key");
-  staticpro (&Qfunction_key);
-  Qmouse_click = intern_c_string ("mouse-click");
-  staticpro (&Qmouse_click);
-#if defined (WINDOWSNT)
-  Qlanguage_change = intern_c_string ("language-change");
-  staticpro (&Qlanguage_change);
-#endif
-  Qdrag_n_drop = intern_c_string ("drag-n-drop");
-  staticpro (&Qdrag_n_drop);
+  DEFSYM (Qpolling_period, "polling-period");
 
-  Qsave_session = intern_c_string ("save-session");
-  staticpro (&Qsave_session);
+  DEFSYM (Qx_set_selection, "x-set-selection");
+  DEFSYM (QPRIMARY, "PRIMARY");
+  DEFSYM (Qhandle_switch_frame, "handle-switch-frame");
 
-#ifdef HAVE_DBUS
-  Qdbus_event = intern_c_string ("dbus-event");
-  staticpro (&Qdbus_event);
-#endif
-
-  Qconfig_changed_event = intern_c_string ("config-changed-event");
-  staticpro (&Qconfig_changed_event);
-
-  Qmenu_enable = intern_c_string ("menu-enable");
-  staticpro (&Qmenu_enable);
-  QCenable = intern_c_string (":enable");
-  staticpro (&QCenable);
-  QCvisible = intern_c_string (":visible");
-  staticpro (&QCvisible);
-  QChelp = intern_c_string (":help");
-  staticpro (&QChelp);
-  QCfilter = intern_c_string (":filter");
-  staticpro (&QCfilter);
-  QCbutton = intern_c_string (":button");
-  staticpro (&QCbutton);
-  QCkeys = intern_c_string (":keys");
-  staticpro (&QCkeys);
-  QCkey_sequence = intern_c_string (":key-sequence");
-  staticpro (&QCkey_sequence);
-  QCtoggle = intern_c_string (":toggle");
-  staticpro (&QCtoggle);
-  QCradio = intern_c_string (":radio");
-  staticpro (&QCradio);
-  QClabel = intern_c_string (":label");
-  staticpro (&QClabel);
-  QCvert_only = intern_c_string (":vert-only");
-  staticpro (&QCvert_only);
-
-  Qmode_line = intern_c_string ("mode-line");
-  staticpro (&Qmode_line);
-  Qvertical_line = intern_c_string ("vertical-line");
-  staticpro (&Qvertical_line);
-  Qvertical_scroll_bar = intern_c_string ("vertical-scroll-bar");
-  staticpro (&Qvertical_scroll_bar);
-  Qmenu_bar = intern_c_string ("menu-bar");
-  staticpro (&Qmenu_bar);
+  DEFSYM (Qinput_method_function, "input-method-function");
+  DEFSYM (Qinput_method_exit_on_first_char, "input-method-exit-on-first-char");
+  DEFSYM (Qinput_method_use_echo_area, "input-method-use-echo-area");
 
-#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
-  Qmouse_fixup_help_message = intern_c_string ("mouse-fixup-help-message");
-  staticpro (&Qmouse_fixup_help_message);
-#endif
-
-  Qabove_handle = intern_c_string ("above-handle");
-  staticpro (&Qabove_handle);
-  Qhandle = intern_c_string ("handle");
-  staticpro (&Qhandle);
-  Qbelow_handle = intern_c_string ("below-handle");
-  staticpro (&Qbelow_handle);
-  Qup = intern_c_string ("up");
-  staticpro (&Qup);
-  Qdown = intern_c_string ("down");
-  staticpro (&Qdown);
-  Qtop = intern_c_string ("top");
-  staticpro (&Qtop);
-  Qbottom = intern_c_string ("bottom");
-  staticpro (&Qbottom);
-  Qend_scroll = intern_c_string ("end-scroll");
-  staticpro (&Qend_scroll);
-  Qratio = intern_c_string ("ratio");
-  staticpro (&Qratio);
-
-  Qevent_kind = intern_c_string ("event-kind");
-  staticpro (&Qevent_kind);
-  Qevent_symbol_elements = intern_c_string ("event-symbol-elements");
-  staticpro (&Qevent_symbol_elements);
-  Qevent_symbol_element_mask = intern_c_string ("event-symbol-element-mask");
-  staticpro (&Qevent_symbol_element_mask);
-  Qmodifier_cache = intern_c_string ("modifier-cache");
-  staticpro (&Qmodifier_cache);
-
-  Qrecompute_lucid_menubar = intern_c_string ("recompute-lucid-menubar");
-  staticpro (&Qrecompute_lucid_menubar);
-  Qactivate_menubar_hook = intern_c_string ("activate-menubar-hook");
-  staticpro (&Qactivate_menubar_hook);
-
-  Qpolling_period = intern_c_string ("polling-period");
-  staticpro (&Qpolling_period);
-
-  Qinput_method_function = intern_c_string ("input-method-function");
-  staticpro (&Qinput_method_function);
-
-  Qx_set_selection = intern_c_string ("x-set-selection");
-  staticpro (&Qx_set_selection);
-  QPRIMARY = intern_c_string ("PRIMARY");
-  staticpro (&QPRIMARY);
-  Qhandle_switch_frame = intern_c_string ("handle-switch-frame");
-  staticpro (&Qhandle_switch_frame);
-
-  Qinput_method_exit_on_first_char = intern_c_string ("input-method-exit-on-first-char");
-  staticpro (&Qinput_method_exit_on_first_char);
-  Qinput_method_use_echo_area = intern_c_string ("input-method-use-echo-area");
-  staticpro (&Qinput_method_use_echo_area);
+  DEFSYM (Qhelp_form_show, "help-form-show");
 
   Fset (Qinput_method_exit_on_first_char, Qnil);
   Fset (Qinput_method_use_echo_area, Qnil);
@@ -11652,9 +11635,8 @@ syms_of_keyboard (void)
   raw_keybuf = Fmake_vector (make_number (30), Qnil);
   staticpro (&raw_keybuf);
 
-  Qextended_command_history = intern_c_string ("extended-command-history");
+  DEFSYM (Qextended_command_history, "extended-command-history");
   Fset (Qextended_command_history, Qnil);
-  staticpro (&Qextended_command_history);
 
   accent_key_syms = Qnil;
   staticpro (&accent_key_syms);
@@ -11955,8 +11937,7 @@ The command loop sets this to nil before each command,
 and tests the value when the command returns.
 Buffer modification stores t in this variable.  */);
   Vdeactivate_mark = Qnil;
-  Qdeactivate_mark = intern_c_string ("deactivate-mark");
-  staticpro (&Qdeactivate_mark);
+  DEFSYM (Qdeactivate_mark, "deactivate-mark");
 
   DEFVAR_LISP ("pre-command-hook", Vpre_command_hook,
               doc: /* Normal hook run before each command is executed.
@@ -11976,8 +11957,7 @@ otherwise the error might happen repeatedly and make Emacs nonfunctional.  */);
   DEFVAR_LISP ("echo-area-clear-hook", ...,
               doc: /* Normal hook run when clearing the echo area.  */);
 #endif
-  Qecho_area_clear_hook = intern_c_string ("echo-area-clear-hook");
-  staticpro (&Qecho_area_clear_hook);
+  DEFSYM (Qecho_area_clear_hook, "echo-area-clear-hook");
   Fset (Qecho_area_clear_hook, Qnil);
 
   DEFVAR_LISP ("lucid-menu-bar-dirty-flag", Vlucid_menu_bar_dirty_flag,
@@ -12111,6 +12091,14 @@ This function is called with no arguments after each command
 whenever `deferred-action-list' is non-nil.  */);
   Vdeferred_action_function = Qnil;
 
+  DEFVAR_LISP ("delayed-warnings-list", Vdelayed_warnings_list,
+               doc: /* List of warnings to be displayed as soon as possible.
+Each element must be a list (TYPE MESSAGE [LEVEL [BUFFER-NAME]]),
+as per the args of `display-warning' (which see).
+If this variable is non-nil, `delayed-warnings-hook' will be run
+immediately after running `post-command-hook'.  */);
+  Vdelayed_warnings_list = Qnil;
+
   DEFVAR_LISP ("suggest-key-bindings", Vsuggest_key_bindings,
               doc: /* *Non-nil means show the equivalent key-binding when M-x command has one.
 The value can be a length of time to show the message for.
@@ -12224,6 +12212,17 @@ text in the region before modifying the buffer.  The next
 `deactivate-mark' call uses this to set the window selection.  */);
   Vsaved_region_selection = Qnil;
 
+  DEFVAR_LISP ("debug-on-event",
+               Vdebug_on_event,
+               doc: /* Enter debugger on this event.  When Emacs
+receives the special event specifed by this variable, it will try to
+break into the debugger as soon as possible instead of processing the
+event normally through `special-event-map'.
+
+Currently, the only supported values for this
+variable are `sigusr1' and `sigusr2'.  */);
+  Vdebug_on_event = intern_c_string ("sigusr2");
+
   /* Create the initial keyboard. */
   initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
   init_kboard (initial_kboard);