Refill some long/short copyright headers.
[bpt/emacs.git] / src / keyboard.c
index 872f787..8ae6eb9 100644 (file)
@@ -1,7 +1,6 @@
 /* Keyboard and mouse input; editor command loop.
-   Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995,
-                 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
-                 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (C) 1985-1989, 1993-1997, 1999-2011  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -58,13 +57,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "syssignal.h"
 
 #include <sys/types.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
-#endif
 
 /* This is to get the definitions of the XK_ symbols.  */
 #ifdef HAVE_X_WINDOWS
@@ -130,9 +124,6 @@ int this_command_key_count_reset;
 Lisp_Object raw_keybuf;
 int raw_keybuf_count;
 
-/* Non-nil if the present key sequence was obtained by shift translation.  */
-Lisp_Object Vthis_command_keys_shift_translated;
-
 #define GROW_RAW_KEYBUF                                                        \
  if (raw_keybuf_count == XVECTOR (raw_keybuf)->size)                   \
    raw_keybuf = larger_vector (raw_keybuf, raw_keybuf_count * 2, Qnil)  \
@@ -146,23 +137,6 @@ int this_single_command_key_start;
 static int before_command_key_count;
 static int before_command_echo_length;
 
-extern int minbuf_level;
-
-extern int message_enable_multibyte;
-
-/* If non-nil, the function that implements the display of help.
-   It's called with one argument, the help string to display.  */
-
-Lisp_Object Vshow_help_function;
-
-/* Nonzero means do menu prompting.  */
-
-static int menu_prompting;
-
-/* Character to see next line of menu prompt.  */
-
-static Lisp_Object menu_prompt_more_char;
-
 /* For longjmp to where kbd input is being done.  */
 
 static jmp_buf getcjmp;
@@ -191,43 +165,9 @@ struct kboard *echo_kboard;
 
 Lisp_Object echo_message_buffer;
 
-/* Nonzero means disregard local maps for the menu bar.  */
-static int inhibit_local_menu_bar_menus;
-
 /* Nonzero means C-g should cause immediate error-signal.  */
 int immediate_quit;
 
-/* The user's hook function for outputting an error message.  */
-Lisp_Object Vcommand_error_function;
-
-/* The user's ERASE setting.  */
-Lisp_Object Vtty_erase_char;
-
-/* Character to recognize as the help char.  */
-Lisp_Object Vhelp_char;
-
-/* List of other event types to recognize as meaning "help".  */
-Lisp_Object Vhelp_event_list;
-
-/* Form to execute when help char is typed.  */
-Lisp_Object Vhelp_form;
-
-/* Command to run when the help character follows a prefix key.  */
-Lisp_Object Vprefix_help_command;
-
-/* List of items that should move to the end of the menu bar.  */
-Lisp_Object Vmenu_bar_final_items;
-
-/* Non-nil means show the equivalent key-binding for
-   any M-x command that has one.
-   The value can be a length of time to show the message for.
-   If the value is non-nil and not a number, we wait 2 seconds.  */
-Lisp_Object Vsuggest_key_bindings;
-
-/* How long to display an echo-area message when the minibuffer is active.
-   If the value is not a number, such messages don't time out.  */
-Lisp_Object Vminibuffer_message_timeout;
-
 /* Character that causes a quit.  Normally C-g.
 
    If we are running on an ordinary terminal, this must be an ordinary
@@ -246,46 +186,9 @@ Lisp_Object Vminibuffer_message_timeout;
    ASCII character.  */
 int quit_char;
 
-/* If non-nil, this is a map that overrides all other local maps.  */
-Lisp_Object Voverriding_local_map;
-
-/* If non-nil, Voverriding_local_map applies to the menu bar.  */
-Lisp_Object Voverriding_local_map_menu_flag;
-
-/* Keymap that defines special misc events that should
-   be processed immediately at a low level.  */
-Lisp_Object Vspecial_event_map;
-
 /* Current depth in recursive edits.  */
 int command_loop_level;
 
-/* Total number of times command_loop has read a key sequence.  */
-EMACS_INT num_input_keys;
-
-/* Last input event read as a command.  */
-Lisp_Object last_command_event;
-
-/* Last input character read as a command, not counting menus
-   reached by the mouse.  */
-Lisp_Object last_nonmenu_event;
-
-/* Last input event read for any purpose.  */
-Lisp_Object last_input_event;
-
-/* If not Qnil, a list of objects to be read as subsequent command input.  */
-Lisp_Object Vunread_command_events;
-
-/* If not Qnil, a list of objects to be read as subsequent command input
-   including input method processing.  */
-Lisp_Object Vunread_input_method_events;
-
-/* If not Qnil, a list of objects to be read as subsequent command input
-   but NOT including input method processing.  */
-Lisp_Object Vunread_post_input_method_events;
-
-/* If not -1, an event to be read as subsequent command input.  */
-EMACS_INT unread_command_char;
-
 /* If not Qnil, this is a switch-frame event which we decided to put
    off until the end of a key sequence.  This should be read as the
    next command input, after any unread_command_events.
@@ -295,49 +198,21 @@ EMACS_INT unread_command_char;
    events until a non-ASCII event is acceptable as input.  */
 Lisp_Object unread_switch_frame;
 
-/* A mask of extra modifier bits to put into every keyboard char.  */
-EMACS_INT extra_keyboard_modifiers;
-
-/* Char to use as prefix when a meta character is typed in.
-   This is bound on entry to minibuffer in case ESC is changed there.  */
-
-Lisp_Object meta_prefix_char;
-
 /* Last size recorded for a current buffer which is not a minibuffer.  */
-static int last_non_minibuf_size;
-
-/* Number of idle seconds before an auto-save and garbage collection.  */
-static Lisp_Object Vauto_save_timeout;
+static EMACS_INT last_non_minibuf_size;
 
 /* Total number of times read_char has returned.  */
 int num_input_events;
 
-/* Total number of times read_char has returned, outside of macros.  */
-EMACS_INT num_nonmacro_input_events;
-
-/* Auto-save automatically when this many characters have been typed
-   since the last time.  */
-
-static EMACS_INT auto_save_interval;
-
 /* Value of num_nonmacro_input_events as of last auto save.  */
 
 int last_auto_save;
 
-/* The command being executed by the command loop.
-   Commands may set this, and the value set will be copied into
-   current_kboard->Vlast_command instead of the actual command.  */
-Lisp_Object Vthis_command;
-
 /* This is like Vthis_command, except that commands never set it.  */
 Lisp_Object real_this_command;
 
-/* If the lookup of the command returns a binding, the original
-   command is stored in this-original-command.  It is nil otherwise.  */
-Lisp_Object Vthis_original_command;
-
 /* The value of point when the last command was started.  */
-int last_point_position;
+EMACS_INT last_point_position;
 
 /* The buffer that was current when the last command was started.  */
 Lisp_Object last_point_position_buffer;
@@ -352,15 +227,12 @@ Lisp_Object last_point_position_window;
    generated by the next character.  */
 Lisp_Object internal_last_event_frame;
 
-/* A user-visible version of the above, intended to allow users to
-   figure out where the last event came from, if the event doesn't
-   carry that information itself (i.e. if it was a character).  */
-Lisp_Object Vlast_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;
 
+Lisp_Object Qx_set_selection, QPRIMARY, Qhandle_switch_frame;
+
 Lisp_Object Qself_insert_command;
 Lisp_Object Qforward_char;
 Lisp_Object Qbackward_char;
@@ -371,48 +243,19 @@ Lisp_Object Qtimer_event_handler;
    key sequence that it reads.  */
 Lisp_Object read_key_sequence_cmd;
 
-/* Echo unfinished commands after this many seconds of pause.  */
-Lisp_Object Vecho_keystrokes;
-
-/* Form to evaluate (if non-nil) when Emacs is started.  */
-Lisp_Object Vtop_level;
-
-/* If non-nil, this implements the current input method.  */
-Lisp_Object Vinput_method_function;
 Lisp_Object Qinput_method_function;
 
-/* When we call Vinput_method_function,
-   this holds the echo area message that was just erased.  */
-Lisp_Object Vinput_method_previous_message;
-
-/* Non-nil means deactivate the mark at end of this command.  */
-Lisp_Object Vdeactivate_mark;
 Lisp_Object Qdeactivate_mark;
 
-/* Menu bar specified in Lucid Emacs fashion.  */
-
-Lisp_Object Vlucid_menu_bar_dirty_flag;
 Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
 
 Lisp_Object Qecho_area_clear_hook;
 
 /* Hooks to run before and after each command.  */
-Lisp_Object Qpre_command_hook, Vpre_command_hook;
-Lisp_Object Qpost_command_hook, Vpost_command_hook;
-Lisp_Object Qcommand_hook_internal, Vcommand_hook_internal;
-
-/* Parent keymap of terminal-local function-key-map instances.  */
-Lisp_Object Vfunction_key_map;
+Lisp_Object Qpre_command_hook;
+Lisp_Object Qpost_command_hook;
+Lisp_Object Qcommand_hook_internal;
 
-/* Keymap of key translations that can override keymaps.  */
-Lisp_Object Vkey_translation_map;
-
-/* List of deferred actions to be performed at a later time.
-   The precise format isn't relevant here; we just check whether it is nil.  */
-Lisp_Object Vdeferred_action_list;
-
-/* Function to call to handle deferred actions, when there are any.  */
-Lisp_Object Vdeferred_action_function;
 Lisp_Object Qdeferred_action_function;
 
 Lisp_Object Qinput_method_exit_on_first_char;
@@ -424,8 +267,6 @@ FILE *dribble;
 /* Nonzero if input is available.  */
 int input_pending;
 
-extern char *pending_malloc_warning;
-
 /* Circular buffer for pre-read keyboard input.  */
 
 static struct input_event kbd_buffer[KBD_BUFFER_SIZE];
@@ -450,11 +291,6 @@ static struct input_event * volatile kbd_store_ptr;
    dequeuing functions?  Such a flag could be screwed up by interrupts
    at inopportune times.  */
 
-/* If this flag is non-nil, we check mouse_moved to see when the
-   mouse moves, and motion events will appear in the input stream.
-   Otherwise, mouse motion is ignored.  */
-Lisp_Object do_mouse_tracking;
-
 /* Symbols to head events.  */
 Lisp_Object Qmouse_movement;
 Lisp_Object Qscroll_bar_movement;
@@ -488,10 +324,10 @@ Lisp_Object Qconfig_changed_event;
 Lisp_Object Qevent_kind;
 Lisp_Object Qevent_symbol_elements;
 
-/* menu item parts */
+/* 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;
+Lisp_Object QCbutton, QCtoggle, QCradio, QClabel, QCvert_only;
 
 /* An event header symbol HEAD may have a property named
    Qevent_symbol_element_mask, which is of the form (BASE MODIFIERS);
@@ -522,12 +358,6 @@ static int echo_length (void);
 
 Lisp_Object Qpolling_period;
 
-/* List of absolute timers.  Appears in order of next scheduled event.  */
-Lisp_Object Vtimer_list;
-
-/* List of idle time timers.  Appears in order of next scheduled event.  */
-Lisp_Object Vtimer_idle_list;
-
 /* Incremented whenever a timer is run.  */
 int timers_run;
 
@@ -561,18 +391,6 @@ int interrupts_deferred;
 #define POLL_FOR_INPUT
 #endif
 
-/* After a command is executed, if point is moved into a region that
-   has specific properties (e.g. composition, display), we adjust
-   point to the boundary of the region.  But, if a command sets this
-   variable to non-nil, we suppress this point adjustment.  This
-   variable is set to nil before reading a command.  */
-
-Lisp_Object Vdisable_point_adjustment;
-
-/* If non-nil, always disable point adjustment.  */
-
-Lisp_Object Vglobal_disable_point_adjustment;
-
 /* The time when Emacs started being idle.  */
 
 static EMACS_TIME timer_idleness_start_time;
@@ -582,11 +400,6 @@ static EMACS_TIME timer_idleness_start_time;
 
 static EMACS_TIME timer_last_idleness_start_time;
 
-/* If non-nil, events produced by disabled menu items and tool-bar
-   buttons are not ignored.  Help functions bind this to allow help on
-   those items and buttons.  */
-Lisp_Object Venable_disabled_menus_and_buttons;
-
 \f
 /* Global variable declarations.  */
 
@@ -612,8 +425,8 @@ static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object,
                                         Lisp_Object, Lisp_Object,
                                         unsigned long);
 #endif
-static Lisp_Object modify_event_symbol (int, unsigned, Lisp_Object,
-                                        Lisp_Object, const char **,
+static Lisp_Object modify_event_symbol (EMACS_INT, unsigned, Lisp_Object,
+                                        Lisp_Object, const char *const *,
                                         Lisp_Object *, unsigned);
 static Lisp_Object make_lispy_switch_frame (Lisp_Object);
 static void save_getcjmp (jmp_buf);
@@ -633,23 +446,7 @@ static SIGTYPE handle_user_signal (int);
 static char *find_user_signal_name (int);
 static int store_user_signal_events (void);
 
-/* Nonzero means don't try to suspend even if the operating system seems
-   to support it.  */
-static int cannot_suspend;
-
 \f
-/* Install the string STR as the beginning of the string of echoing,
-   so that it serves as a prompt for the next character.
-   Also start echoing.  */
-
-void
-echo_prompt (Lisp_Object str)
-{
-  current_kboard->echo_string = str;
-  current_kboard->echo_after_prompt = SCHARS (str);
-  echo_now ();
-}
-
 /* Add C to the echo string, if echoing is going on.
    C can be a character, which is printed prettily ("M-C-x" and all that
    jazz), or a symbol, whose name is printed.  */
@@ -748,6 +545,9 @@ echo_dash (void)
   if (NILP (current_kboard->echo_string))
     return;
 
+  if (this_command_key_count == 0)
+    return;
+
   if (!current_kboard->immediate_echo
       && SCHARS (current_kboard->echo_string) == 0)
     return;
@@ -858,7 +658,7 @@ echo_length (void)
    switches frames while entering a key sequence.  */
 
 static void
-echo_truncate (int nchars)
+echo_truncate (EMACS_INT nchars)
 {
   if (STRINGP (current_kboard->echo_string))
     current_kboard->echo_string
@@ -1471,7 +1271,7 @@ some_mouse_moved (void)
 static int read_key_sequence (Lisp_Object *, int, Lisp_Object,
                               int, int, int);
 void safe_run_hooks (Lisp_Object);
-static void adjust_point_for_property (int, int);
+static void adjust_point_for_property (EMACS_INT, int);
 
 /* Cancel hourglass from protect_unwind.
    ARG is not used.  */
@@ -1484,6 +1284,11 @@ cancel_hourglass_unwind (Lisp_Object arg)
 }
 #endif
 
+/* FIXME: This is wrong rather than test window-system, we should call
+   a new set-selection, which will then dispatch to x-set-selection, or
+   tty-set-selection, or w32-set-selection, ...  */
+EXFUN (Fwindow_system, 1);
+
 Lisp_Object
 command_loop_1 (void)
 {
@@ -1772,7 +1577,8 @@ command_loop_1 (void)
          this_single_command_key_start = 0;
        }
 
-      if (!NILP (current_buffer->mark_active) && !NILP (Vrun_hooks))
+      if (!NILP (current_buffer->mark_active)
+         && !NILP (Vrun_hooks))
        {
          /* In Emacs 22, setting transient-mark-mode to `only' was a
             way of turning it on for just one command.  This usage is
@@ -1783,9 +1589,40 @@ command_loop_1 (void)
            Vtransient_mark_mode = Qidentity;
 
          if (!NILP (Vdeactivate_mark))
+           /* If `select-active-regions' is non-nil, this call to
+              `deactivate-mark' also sets the PRIMARY selection.  */
            call0 (Qdeactivate_mark);
-         else if (current_buffer != prev_buffer || MODIFF != prev_modiff)
-           call1 (Vrun_hooks, intern ("activate-mark-hook"));
+         else
+           {
+             /* Even if not deactivating the mark, set PRIMARY if
+                `select-active-regions' is non-nil.  */
+             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
+                 && (EQ (Vselect_active_regions, Qonly)
+                     ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
+                     : (!NILP (Vselect_active_regions)
+                        && !NILP (Vtransient_mark_mode)))
+                 && !EQ (Vthis_command, Qhandle_switch_frame))
+               {
+                 EMACS_INT beg =
+                   XINT (Fmarker_position (current_buffer->mark));
+                 EMACS_INT end = PT;
+                 if (beg < end)
+                   call2 (Qx_set_selection, QPRIMARY,
+                          make_buffer_string (beg, end, 0));
+                 else if (beg > end)
+                   call2 (Qx_set_selection, QPRIMARY,
+                          make_buffer_string (end, beg, 0));
+                 /* Don't set empty selections.  */
+               }
+
+             if (current_buffer != prev_buffer || MODIFF != prev_modiff)
+               call1 (Vrun_hooks, intern ("activate-mark-hook"));
+           }
+
+         Vsaved_region_selection = Qnil;
        }
 
     finalize:
@@ -1828,7 +1665,7 @@ command_loop_1 (void)
    LAST_PT is the last position of point.  */
 
 static void
-adjust_point_for_property (int last_pt, int modified)
+adjust_point_for_property (EMACS_INT last_pt, int modified)
 {
   EMACS_INT beg, end;
   Lisp_Object val, overlay, tmp;
@@ -1837,7 +1674,7 @@ adjust_point_for_property (int last_pt, int modified)
      user can keep inserting another character at point or keep
      deleting characters around point.  */
   int check_composition = ! modified, check_display = 1, check_invisible = 1;
-  int orig_pt = PT;
+  EMACS_INT orig_pt = PT;
 
   /* FIXME: cycling is probably not necessary because these properties
      can't be usefully combined anyway.  */
@@ -2014,11 +1851,6 @@ safe_run_hooks (Lisp_Object hook)
 }
 
 \f
-/* Number of seconds between polling for input.  This is a Lisp
-   variable that can be bound.  */
-
-EMACS_INT polling_period;
-
 /* Nonzero means polling for input is temporarily suppressed.  */
 
 int poll_suppress_count;
@@ -2740,7 +2572,8 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
 
   if (INTERACTIVE && NILP (c))
     {
-      int delay_level, buffer_size;
+      int delay_level;
+      EMACS_INT buffer_size;
 
       /* Slow down auto saves logarithmically in size of current buffer,
         and garbage collect while we're at it.  */
@@ -3479,12 +3312,6 @@ restore_getcjmp (jmp_buf temp)
 static int
 readable_events (int flags)
 {
-#ifdef HAVE_DBUS
-  /* Check whether a D-Bus message has arrived.  */
-  if (xd_pending_messages () > 0)
-    return 1;
-#endif /* HAVE_DBUS */
-
   if (flags & READABLE_EVENTS_DO_TIMERS_NOW)
     timer_check (1);
 
@@ -3571,6 +3398,7 @@ event_to_kboard (struct input_event *event)
     return FRAME_KBOARD (XFRAME (frame));
 }
 
+#ifdef subprocesses
 /* Return the number of slots occupied in kbd_buffer.  */
 
 static int
@@ -3583,10 +3411,7 @@ kbd_buffer_nr_stored (void)
        : ((kbd_buffer + KBD_BUFFER_SIZE) - kbd_fetch_ptr
           + (kbd_store_ptr - kbd_buffer)));
 }
-
-Lisp_Object Vthrow_on_input;
-
-/* Store an event obtained at interrupt level into kbd_buffer, fifo */
+#endif /* Store an event obtained at interrupt level into kbd_buffer, fifo */
 
 void
 kbd_buffer_store_event (register struct input_event *event)
@@ -3704,6 +3529,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
     {
       *kbd_store_ptr = *event;
       ++kbd_store_ptr;
+#ifdef subprocesses
       if (kbd_buffer_nr_stored () > KBD_BUFFER_SIZE/2 && ! kbd_on_hold_p ())
         {
           /* Don't read keyboard input until we have processed kbd_buffer.
@@ -3715,6 +3541,7 @@ kbd_buffer_store_event_hold (register struct input_event *event,
 #endif
           stop_polling ();
         }
+#endif /* subprocesses */
     }
 
   /* If we're inside while-no-input, and this event qualifies
@@ -3754,22 +3581,20 @@ kbd_buffer_unget_event (register struct input_event *event)
 }
 
 
-/* Generate HELP_EVENT input_events in BUFP which has room for
-   SIZE events.  If there's not enough room in BUFP, ignore this
-   event.
+/* Generate a HELP_EVENT input_event and store it in the keyboard
+   buffer.
 
    HELP is the help form.
 
-   FRAME is the frame on which the help is generated.  OBJECT is the
-   Lisp object where the help was found (a buffer, a string, an
-   overlay, or nil if neither from a string nor from a buffer.  POS is
-   the position within OBJECT where the help was found.
-
-   Value is the number of input_events generated.  */
+   FRAME and WINDOW are the frame and window where the help is
+   generated.  OBJECT is the Lisp object where the help was found (a
+   buffer, a string, an overlay, or nil if neither from a string nor
+   from a buffer).  POS is the position within OBJECT where the help
+   was found.  */
 
 void
 gen_help_event (Lisp_Object help, Lisp_Object frame, Lisp_Object window,
-               Lisp_Object object, int pos)
+               Lisp_Object object, EMACS_INT pos)
 {
   struct input_event event;
 
@@ -3877,6 +3702,7 @@ kbd_buffer_get_event (KBOARD **kbp,
   register int c;
   Lisp_Object obj;
 
+#ifdef subprocesses
   if (kbd_on_hold_p () && kbd_buffer_nr_stored () < KBD_BUFFER_SIZE/4)
     {
       /* Start reading input again, we have processed enough so we can
@@ -3888,6 +3714,7 @@ kbd_buffer_get_event (KBOARD **kbp,
 #endif /* SIGIO */
       start_polling ();
     }
+#endif /* subprocesses */
 
   if (noninteractive
       /* In case we are running as a daemon, only do this before
@@ -4074,7 +3901,7 @@ kbd_buffer_get_event (KBOARD **kbp,
 #endif
       else if (event->kind == SAVE_SESSION_EVENT)
         {
-          obj = Fcons (Qsave_session, Qnil);
+          obj = Fcons (Qsave_session, Fcons (event->arg, Qnil));
          kbd_fetch_ptr = event + 1;
         }
       /* Just discard these, by returning nil.
@@ -4724,7 +4551,7 @@ static const int lispy_accent_codes[] =
 /* This is a list of Lisp names for special "accent" characters.
    It parallels lispy_accent_codes.  */
 
-static const char *lispy_accent_keys[] =
+static const char *const lispy_accent_keys[] =
 {
   "dead-circumflex",
   "dead-grave",
@@ -4751,7 +4578,7 @@ static const char *lispy_accent_keys[] =
 #ifdef HAVE_NTGUI
 #define FUNCTION_KEY_OFFSET 0x0
 
-char const *lispy_function_keys[] =
+const char *const lispy_function_keys[] =
   {
     0,                /* 0                      */
 
@@ -4914,9 +4741,9 @@ char const *lispy_function_keys[] =
     0,               /* VK_OEM_102        0xE2 */
     "ico-help",      /* VK_ICO_HELP       0xE3 */
     "ico-00",        /* VK_ICO_00         0xE4 */
-    0,               /* VK_PROCESSKEY     0xE5 */
+    0,               /* VK_PROCESSKEY     0xE5 - used by IME */
     "ico-clear",     /* VK_ICO_CLEAR      0xE6 */
-    "packet",        /* VK_PACKET         0xE7 */
+    0,               /* VK_PACKET         0xE7  - used to pass unicode chars */
     0,               /*                   0xE8 */
     "reset",         /* VK_OEM_RESET      0xE9 */
     "jump",          /* VK_OEM_JUMP       0xEA */
@@ -4945,7 +4772,7 @@ char const *lispy_function_keys[] =
 
 /* Some of these duplicate the "Media keys" on newer keyboards,
    but they are delivered to the application in a different way.  */
-static const char *lispy_multimedia_keys[] =
+static const char *const lispy_multimedia_keys[] =
   {
     0,
     "browser-back",
@@ -5009,7 +4836,7 @@ static const char *lispy_multimedia_keys[] =
    the XK_kana_A case below.  */
 #if 0
 #ifdef XK_kana_A
-static const char *lispy_kana_keys[] =
+static const char *const lispy_kana_keys[] =
   {
     /* X Keysym value */
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,   /* 0x400 .. 0x40f */
@@ -5048,7 +4875,7 @@ static const char *lispy_kana_keys[] =
 
 /* You'll notice that this table is arranged to be conveniently
    indexed by X Windows keysym values.  */
-static const char *lispy_function_keys[] =
+static const char *const lispy_function_keys[] =
   {
     /* X Keysym value */
 
@@ -5134,7 +4961,7 @@ static const char *lispy_function_keys[] =
 /* ISO 9995 Function and Modifier Keys; the first byte is 0xFE.  */
 #define ISO_FUNCTION_KEY_OFFSET 0xfe00
 
-static const char *iso_lispy_function_keys[] =
+static const char *const iso_lispy_function_keys[] =
   {
     0, 0, 0, 0, 0, 0, 0, 0,    /* 0xfe00 */
     0, 0, 0, 0, 0, 0, 0, 0,    /* 0xfe08 */
@@ -5157,14 +4984,14 @@ static const char *iso_lispy_function_keys[] =
 
 Lisp_Object Vlispy_mouse_stem;
 
-static const char *lispy_wheel_names[] =
+static const char *const lispy_wheel_names[] =
 {
   "wheel-up", "wheel-down", "wheel-left", "wheel-right"
 };
 
 /* drag-n-drop events are generated when a set of selected files are
    dragged from another application and dropped onto an Emacs window.  */
-static const char *lispy_drag_n_drop_names[] =
+static const char *const lispy_drag_n_drop_names[] =
 {
   "drag-n-drop"
 };
@@ -5175,7 +5002,7 @@ Lisp_Object Qup, Qdown, Qbottom, Qend_scroll;
 Lisp_Object Qtop, Qratio;
 
 /* An array of scroll bar parts, indexed by an enum scroll_bar_part value.  */
-const Lisp_Object *scroll_bar_parts[] = {
+static Lisp_Object *const scroll_bar_parts[] = {
   &Qabove_handle, &Qhandle, &Qbelow_handle,
   &Qup, &Qdown, &Qtop, &Qbottom, &Qend_scroll, &Qratio
 };
@@ -5201,140 +5028,141 @@ static int last_mouse_x;
 static int last_mouse_y;
 static unsigned long button_down_time;
 
-/* The maximum time between clicks to make a double-click, or Qnil to
-   disable double-click detection, or Qt for no time limit.  */
-
-Lisp_Object Vdouble_click_time;
-
-/* Maximum number of pixels the mouse may be moved between clicks
-   to make a double-click.  */
-
-EMACS_INT double_click_fuzz;
-
 /* The number of clicks in this multiple-click. */
 
 int double_click_count;
 
-/* Return position of a mouse click or wheel event */
+/* 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,
+make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
                     unsigned long time)
 {
-  Lisp_Object window;
   enum window_part part;
   Lisp_Object posn = Qnil;
   Lisp_Object extra_info = Qnil;
-  int wx, wy;
-
-  /* Set `window' to the window under frame pixel coordinates (x,y)  */
-  if (f)
-    window = window_from_coordinates (f, XINT (*x), XINT (*y),
-                                     &part, &wx, &wy, 0);
-  else
-    window = Qnil;
+  /* Coordinate pixel positions to return.  */
+  int xret = 0, yret = 0;
+  /* The window under frame pixel coordinates (x,y)  */
+  Lisp_Object window = f
+    ? window_from_coordinates (f, XINT (x), XINT (y), &part, 0)
+    : Qnil;
 
   if (WINDOWP (window))
     {
       /* It's a click in window window at frame coordinates (x,y)  */
       struct window *w = XWINDOW (window);
       Lisp_Object string_info = Qnil;
-      int textpos = -1, rx = -1, ry = -1;
-      int dx = -1, dy = -1;
+      EMACS_INT textpos = -1;
+      int col = -1, row = -1;
+      int dx  = -1, dy  = -1;
       int width = -1, height = -1;
       Lisp_Object object = Qnil;
 
-      /* Set event coordinates to window-relative coordinates
-        for constructing the Lisp event below.  */
-      XSETINT (*x, wx);
-      XSETINT (*y, wy);
+      /* Pixel coordinates relative to the window corner.  */
+      int wx = XINT (x) - WINDOW_LEFT_EDGE_X (w);
+      int wy = XINT (y) - WINDOW_TOP_EDGE_Y (w);
 
+      /* For text area clicks, return X, Y relative to the corner of
+        this text area.  Note that dX, dY etc are set below, by
+        buffer_posn_from_coords.  */
       if (part == ON_TEXT)
        {
-         wx += WINDOW_LEFT_MARGIN_WIDTH (w);
+         xret = XINT (x) - window_box_left (w, TEXT_AREA);
+         yret = wy - WINDOW_HEADER_LINE_HEIGHT (w);
        }
+      /* For mode line and header line clicks, return X, Y relative to
+        the left window edge.  Use mode_line_string to look for a
+        string on the click position.  */
       else if (part == ON_MODE_LINE || part == ON_HEADER_LINE)
        {
-         /* Mode line or header line.  Look for a string under
-            the mouse that may have a `local-map' property.  */
          Lisp_Object string;
-         int charpos;
-
-         posn = part == ON_MODE_LINE ? Qmode_line : Qheader_line;
-         rx = wx, ry = wy;
-         string = mode_line_string (w, part, &rx, &ry, &charpos,
+         EMACS_INT charpos;
+
+         posn = (part == ON_MODE_LINE) ? Qmode_line : Qheader_line;
+         /* Note that mode_line_string takes COL, ROW as pixels and
+            converts them to characters.  */
+         col = wx;
+         row = wy;
+         string = mode_line_string (w, part, &col, &row, &charpos,
                                     &object, &dx, &dy, &width, &height);
          if (STRINGP (string))
            string_info = Fcons (string, make_number (charpos));
-         if (w == XWINDOW (selected_window)
-             && current_buffer == XBUFFER (w->buffer))
-           textpos = PT;
-         else
-           textpos = XMARKER (w->pointm)->charpos;
-       }
-      else if (part == ON_VERTICAL_BORDER)
-       {
-         posn = Qvertical_line;
-         wx = -1;
-         dx = 0;
-         width = 1;
+         textpos = (w == XWINDOW (selected_window)
+                    && current_buffer == XBUFFER (w->buffer))
+           ? PT : XMARKER (w->pointm)->charpos;
+
+         xret = wx;
+         yret = wy;
        }
+      /* For fringes and margins, Y is relative to the area's (and the
+        window's) top edge, while X is meaningless.  */
       else if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN)
        {
          Lisp_Object string;
-         int charpos;
+         EMACS_INT charpos;
 
          posn = (part == ON_LEFT_MARGIN) ? Qleft_margin : Qright_margin;
-         rx = wx, ry = wy;
-         string = marginal_area_string (w, part, &rx, &ry, &charpos,
+         col = wx;
+         row = wy;
+         string = marginal_area_string (w, part, &col, &row, &charpos,
                                         &object, &dx, &dy, &width, &height);
          if (STRINGP (string))
            string_info = Fcons (string, make_number (charpos));
-         if (part == ON_LEFT_MARGIN)
-           wx = 0;
-         else
-           wx = window_box_right_offset (w, TEXT_AREA) - 1;
+         yret = wy - WINDOW_HEADER_LINE_HEIGHT (w);
        }
       else if (part == ON_LEFT_FRINGE)
        {
          posn = Qleft_fringe;
-         rx = 0;
-         dx = wx;
-         wx = (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
-               ? 0
-               : window_box_width (w, LEFT_MARGIN_AREA));
-         dx -= wx;
+         col = 0;
+         dx = wx
+           - (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
+              ? 0 : window_box_width (w, LEFT_MARGIN_AREA));
+         dy = yret = wy - WINDOW_HEADER_LINE_HEIGHT (w);
        }
       else if (part == ON_RIGHT_FRINGE)
        {
          posn = Qright_fringe;
-         rx = 0;
-         dx = wx;
-         wx = (window_box_width (w, LEFT_MARGIN_AREA)
-               + window_box_width (w, TEXT_AREA)
-               + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
-                  ? window_box_width (w, RIGHT_MARGIN_AREA)
-                  : 0));
-         dx -= wx;
+         col = 0;
+         dx = wx
+           - window_box_width (w, LEFT_MARGIN_AREA)
+           - window_box_width (w, TEXT_AREA)
+           - (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
+              ? window_box_width (w, RIGHT_MARGIN_AREA)
+              : 0);
+         dy = yret = wy - WINDOW_HEADER_LINE_HEIGHT (w);
        }
-      else
+      else if (part == ON_VERTICAL_BORDER)
        {
-         /* Note: We have no special posn for part == ON_SCROLL_BAR.  */
-         wx = max (WINDOW_LEFT_MARGIN_WIDTH (w), wx);
+         posn = Qvertical_line;
+         width = 1;
+         dx = 0;
+         dy = yret = wy;
        }
+      /* Nothing special for part == ON_SCROLL_BAR.  */
 
+      /* For clicks in the text area, fringes, or margins, call
+        buffer_posn_from_coords to extract TEXTPOS, the buffer
+        position nearest to the click.  */
       if (textpos < 0)
        {
          Lisp_Object string2, object2 = Qnil;
          struct display_pos p;
          int dx2, dy2;
          int width2, height2;
-         string2 = buffer_posn_from_coords (w, &wx, &wy, &p,
+         /* The pixel X coordinate passed to buffer_posn_from_coords
+            is the X coordinate relative to the text area for
+            text-area clicks, zero otherwise.  */
+         int x2 = (part == ON_TEXT) ? xret : 0;
+         int y2 = wy;
+
+         string2 = buffer_posn_from_coords (w, &x2, &y2, &p,
                                             &object2, &dx2, &dy2,
                                             &width2, &height2);
          textpos = CHARPOS (p.pos);
-         if (rx < 0) rx = wx;
-         if (ry < 0) ry = wy;
+         if (col < 0) col = x2;
+         if (row < 0) row = y2;
          if (dx < 0) dx = dx2;
          if (dy < 0) dy = dy2;
          if (width < 0) width = width2;
@@ -5365,34 +5193,27 @@ make_lispy_position (struct frame *f, Lisp_Object *x, Lisp_Object *y,
 #endif
 
       /* Object info */
-      extra_info = Fcons (object,
-                         Fcons (Fcons (make_number (dx),
-                                       make_number (dy)),
-                                Fcons (Fcons (make_number (width),
-                                              make_number (height)),
-                                       Qnil)));
+      extra_info
+       = list3 (object,
+                Fcons (make_number (dx), make_number (dy)),
+                Fcons (make_number (width), make_number (height)));
 
       /* String info */
       extra_info = Fcons (string_info,
                          Fcons (make_number (textpos),
-                                Fcons (Fcons (make_number (rx),
-                                              make_number (ry)),
+                                Fcons (Fcons (make_number (col),
+                                              make_number (row)),
                                        extra_info)));
     }
   else if (f != 0)
-    {
-      XSETFRAME (window, f);
-    }
+    XSETFRAME (window, f);
   else
-    {
-      window = Qnil;
-      XSETFASTINT (*x, 0);
-      XSETFASTINT (*y, 0);
-    }
+    window = Qnil;
 
   return Fcons (window,
                Fcons (posn,
-                      Fcons (Fcons (*x, *y),
+                      Fcons (Fcons (make_number (xret),
+                                    make_number (yret)),
                              Fcons (make_number (time),
                                     extra_info))));
 }
@@ -5417,7 +5238,7 @@ make_lispy_event (struct input_event *event)
     case MULTIBYTE_CHAR_KEYSTROKE_EVENT:
       {
        Lisp_Object lispy_c;
-       int c = event->code;
+       EMACS_INT c = event->code;
        if (event->kind == ASCII_KEYSTROKE_EVENT)
          {
            c &= 0377;
@@ -5581,14 +5402,6 @@ make_lispy_event (struct input_event *event)
                int hpos;
                int i;
 
-#if 0
-               /* Activate the menu bar on the down event.  If the
-                  up event comes in before the menu code can deal with it,
-                  just ignore it.  */
-               if (! (event->modifiers & down_modifier))
-                 return Qnil;
-#endif
-
                /* Find the menu bar item under `column'.  */
                item = Qnil;
                items = FRAME_MENU_BAR_ITEMS (f);
@@ -5620,7 +5433,7 @@ make_lispy_event (struct input_event *event)
              }
 #endif /* not USE_X_TOOLKIT && not USE_GTK && not HAVE_NS */
 
-           position = make_lispy_position (f, &event->x, &event->y,
+           position = make_lispy_position (f, event->x, event->y,
                                            event->timestamp);
          }
 #ifndef USE_TOOLKIT_SCROLL_BARS
@@ -5720,23 +5533,21 @@ make_lispy_event (struct input_event *event)
              return Qnil;
 
            event->modifiers &= ~up_modifier;
-#if 0 /* Formerly we treated an up with no down as a click event.  */
-           if (!CONSP (start_pos))
-             event->modifiers |= click_modifier;
-           else
-#endif
+
              {
-               Lisp_Object down;
+               Lisp_Object new_down, down;
                EMACS_INT xdiff = double_click_fuzz, ydiff = double_click_fuzz;
 
                /* The third element of every position
                   should be the (x,y) pair.  */
                down = Fcar (Fcdr (Fcdr (start_pos)));
+               new_down = Fcar (Fcdr (Fcdr (position)));
+
                if (CONSP (down)
                    && INTEGERP (XCAR (down)) && INTEGERP (XCDR (down)))
                  {
-                   xdiff = XINT (event->x) - XINT (XCAR (down));
-                   ydiff = XINT (event->y) - XINT (XCDR (down));
+                   xdiff = XINT (XCAR (new_down)) - XINT (XCAR (down));
+                   ydiff = XINT (XCDR (new_down)) - XINT (XCDR (down));
                  }
 
                if (ignore_mouse_drag_p)
@@ -5819,7 +5630,7 @@ make_lispy_event (struct input_event *event)
        if (! FRAME_LIVE_P (f))
          return Qnil;
 
-       position = make_lispy_position (f, &event->x, &event->y,
+       position = make_lispy_position (f, event->x, event->y,
                                        event->timestamp);
 
        /* Set double or triple modifiers to indicate the wheel speed.  */
@@ -5839,10 +5650,8 @@ make_lispy_event (struct input_event *event)
          else
            abort ();
 
-         if (FRAME_WINDOW_P (f))
-           fuzz = double_click_fuzz;
-         else
-           fuzz = double_click_fuzz / 8;
+         fuzz = FRAME_WINDOW_P (f)
+           ? double_click_fuzz : double_click_fuzz / 8;
 
          if (event->modifiers & up_modifier)
            {
@@ -5980,7 +5789,7 @@ make_lispy_event (struct input_event *event)
        if (! FRAME_LIVE_P (f))
          return Qnil;
 
-       position = make_lispy_position (f, &event->x, &event->y,
+       position = make_lispy_position (f, event->x, event->y,
                                        event->timestamp);
 
        head = modify_event_symbol (0, event->modifiers,
@@ -6063,8 +5872,8 @@ make_lispy_event (struct input_event *event)
        start_pos_ptr = &AREF (button_down_location, button);
        start_pos = *start_pos_ptr;
 
-       position = make_lispy_position (f, &event->x, &event->y,
-                                           event->timestamp);
+       position = make_lispy_position (f, event->x, event->y,
+                                       event->timestamp);
 
        if (event->modifiers & down_modifier)
          *start_pos_ptr = Fcopy_alist (position);
@@ -6123,25 +5932,19 @@ make_lispy_movement (FRAME_PTR frame, Lisp_Object bar_window, enum scroll_bar_pa
 
       part_sym = *scroll_bar_parts[(int) part];
       return Fcons (Qscroll_bar_movement,
-                   (Fcons (Fcons (bar_window,
-                                  Fcons (Qvertical_scroll_bar,
-                                         Fcons (Fcons (x, y),
-                                                Fcons (make_number (time),
-                                                       Fcons (part_sym,
-                                                              Qnil))))),
-                           Qnil)));
+                   Fcons (list5 (bar_window,
+                                 Qvertical_scroll_bar,
+                                 Fcons (x, y),
+                                 make_number (time),
+                                 part_sym),
+                          Qnil));
     }
-
   /* Or is it an ordinary mouse movement?  */
   else
     {
       Lisp_Object position;
-
-      position = make_lispy_position (frame, &x, &y, time);
-
-      return Fcons (Qmouse_movement,
-                   Fcons (position,
-                          Qnil));
+      position = make_lispy_position (frame, x, y, time);
+      return list2 (Qmouse_movement, position);
     }
 }
 
@@ -6322,7 +6125,7 @@ apply_modifiers_uncached (int modifiers, char *base, int base_len, int base_len_
 }
 
 
-static const char *modifier_names[] =
+static const char *const modifier_names[] =
 {
   "up", "down", "drag", "click", "double", "triple", 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -6541,8 +6344,8 @@ reorder_modifiers (Lisp_Object symbol)
    in the symbol's name.  */
 
 static Lisp_Object
-modify_event_symbol (int symbol_num, unsigned int modifiers, Lisp_Object symbol_kind,
-                    Lisp_Object name_alist_or_stem, const char **name_table,
+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 value;
@@ -6605,7 +6408,7 @@ modify_event_symbol (int symbol_num, unsigned int modifiers, Lisp_Object symbol_
       if (NILP (value))
        {
          char buf[20];
-         sprintf (buf, "key-%d", symbol_num);
+         sprintf (buf, "key-%ld", (long)symbol_num);
          value = intern (buf);
        }
 
@@ -6835,11 +6638,6 @@ get_input_pending (int *addr, int flags)
 void
 gobble_input (int expected)
 {
-#ifdef HAVE_DBUS
-  /* Read D-Bus messages.  */
-  xd_read_queued_messages ();
-#endif /* HAVE_DBUS */
-
 #ifdef SIGIO
   if (interrupt_input)
     {
@@ -7050,10 +6848,12 @@ tty_read_avail_input (struct terminal *terminal,
   int n_to_read, i;
   struct tty_display_info *tty = terminal->display_info.tty;
   int nread = 0;
+#ifdef subprocesses
   int buffer_free = KBD_BUFFER_SIZE - kbd_buffer_nr_stored () - 1;
 
   if (kbd_on_hold_p () || buffer_free <= 0)
     return 0;
+#endif /* subprocesses */
 
   if (!terminal->name)         /* Don't read from a dead terminal. */
     return 0;
@@ -7135,9 +6935,11 @@ tty_read_avail_input (struct terminal *terminal,
 #endif
 #endif
 
+#ifdef subprocesses
   /* Don't read more than we can store.  */
   if (n_to_read > buffer_free)
     n_to_read = buffer_free;
+#endif /* subprocesses */
 
   /* Now read; for one reason or another, this will not block.
      NREAD is set to the number of chars read.  */
@@ -7451,6 +7253,54 @@ static Lisp_Object menu_bar_one_keymap_changed_items;
 static Lisp_Object menu_bar_items_vector;
 static int menu_bar_items_index;
 
+
+static const char* separator_names[] = {
+  "space",
+  "no-line",
+  "single-line",
+  "double-line",
+  "single-dashed-line",
+  "double-dashed-line",
+  "shadow-etched-in",
+  "shadow-etched-out",
+  "shadow-etched-in-dash",
+  "shadow-etched-out-dash",
+  "shadow-double-etched-in",
+  "shadow-double-etched-out",
+  "shadow-double-etched-in-dash",
+  "shadow-double-etched-out-dash",
+  0,
+};
+
+/* Return non-zero if LABEL specifies a separator.  */
+
+int
+menu_separator_name_p (const char *label)
+{
+  if (!label)
+    return 0;
+  else if (strlen (label) > 3
+          && strncmp (label, "--", 2) == 0
+          && label[2] != '-')
+    {
+      int i;
+      label += 2;
+      for (i = 0; separator_names[i]; ++i)
+       if (strcmp (label, separator_names[i]) == 0)
+          return 1;
+    }
+  else
+    {
+      /* It's a separator if it contains only dashes.  */
+      while (*label == '-')
+       ++label;
+      return (*label == 0);
+    }
+
+  return 0;
+}
+
+
 /* Return a vector of menu items for a menu bar, appropriate
    to the current buffer.  Each item has three elements in the vector:
    KEY STRING MAPLIST.
@@ -7901,7 +7751,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
     /* The previous code preferred :key-sequence to :keys, so we
        preserve this behavior.  */
     if (STRINGP (keyeq) && !CONSP (keyhint))
-      keyeq = Fsubstitute_command_keys (keyeq);
+      keyeq = concat2 (build_string ("  "), Fsubstitute_command_keys (keyeq));
     else
       {
        Lisp_Object prefix = keyeq;
@@ -8188,10 +8038,14 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
      Rule out items that aren't lists, don't start with
      `menu-item' or whose rest following `tool-bar-item' is not a
      list.  */
-  if (!CONSP (item)
-      || !EQ (XCAR (item), Qmenu_item)
-      || (item = XCDR (item),
-         !CONSP (item)))
+  if (!CONSP (item))
+    return 0;
+
+  /* As an exception, allow old-style menu separators.  */
+  if (STRINGP (XCAR (item)))
+    item = Fcons (XCAR (item), Qnil);
+  else if (!EQ (XCAR (item), Qmenu_item)
+          || (item = XCDR (item), !CONSP (item)))
     return 0;
 
   /* Create tool_bar_item_properties vector if necessary.  Reset it to
@@ -8221,10 +8075,27 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
     }
   PROP (TOOL_BAR_ITEM_CAPTION) = caption;
 
-  /* Give up if rest following the caption is not a list.  */
+  /* If the rest following the caption is not a list, the menu item is
+     either a separator, or invalid.  */
   item = XCDR (item);
   if (!CONSP (item))
-    return 0;
+    {
+      if (menu_separator_name_p (SDATA (caption)))
+       {
+         PROP (TOOL_BAR_ITEM_TYPE) = Qt;
+#if !defined (USE_GTK) && !defined (HAVE_NS)
+         /* If we use build_desired_tool_bar_string to render the
+            tool bar, the separator is rendered as an image.  */
+         PROP (TOOL_BAR_ITEM_IMAGES)
+           = menu_item_eval_property (Vtool_bar_separator_image_expression);
+         PROP (TOOL_BAR_ITEM_ENABLED_P) = Qnil;
+         PROP (TOOL_BAR_ITEM_SELECTED_P) = Qnil;
+         PROP (TOOL_BAR_ITEM_CAPTION) = Qnil;
+#endif
+         return 1;
+       }
+      return 0;
+    }
 
   /* Store the binding.  */
   PROP (TOOL_BAR_ITEM_BINDING) = XCAR (item);
@@ -8258,12 +8129,18 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
            return 0;
        }
       else if (EQ (key, QChelp))
-       /* `:help HELP-STRING'.  */
-       PROP (TOOL_BAR_ITEM_HELP) = value;
+        /* `:help HELP-STRING'.  */
+        PROP (TOOL_BAR_ITEM_HELP) = value;
+      else if (EQ (key, QCvert_only))
+        /* `:vert-only t/nil'.  */
+        PROP (TOOL_BAR_ITEM_VERT_ONLY) = value;
       else if (EQ (key, QClabel))
         {
+          const char *bad_label = "!!?GARBLED ITEM?!!";
           /* `:label LABEL-STRING'.  */
-          PROP (TOOL_BAR_ITEM_LABEL) = value;
+          PROP (TOOL_BAR_ITEM_LABEL) = STRINGP (value)
+            ? value
+            : make_string (bad_label, strlen (bad_label));
           have_label = 1;
         }
       else if (EQ (key, QCfilter))
@@ -8299,41 +8176,43 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
       /* Try to make one from caption and key.  */
       Lisp_Object key = PROP (TOOL_BAR_ITEM_KEY);
       Lisp_Object capt = PROP (TOOL_BAR_ITEM_CAPTION);
-      char *label = SYMBOLP (key) ? (char *) SDATA (SYMBOL_NAME (key)) : "";
-      char *caption = STRINGP (capt) ? (char *) SDATA (capt) : "";
-      char buf[64];
-      EMACS_INT max_lbl = 2*tool_bar_max_label_size;
+      const char *label = SYMBOLP (key) ? SSDATA (SYMBOL_NAME (key)) : "";
+      const char *caption = STRINGP (capt) ? SSDATA (capt) : "";
+      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);
 
-      if (strlen (caption) < max_lbl && caption[0] != '\0')
+      if (caption_len <= max_lbl && caption[0] != '\0')
         {
           strcpy (buf, caption);
-          while (buf[0] != '\0' &&  buf[strlen (buf) -1] == '.')
-            buf[strlen (buf)-1] = '\0';
-          if (strlen (buf) <= max_lbl)
-            caption = buf;
+          while (caption_len > 0 && buf[caption_len - 1] == '.')
+            caption_len--;
+         buf[caption_len] = '\0';
+         label = caption = buf;
         }
 
-      if (strlen (caption) <= max_lbl)
-        label = caption;
-
       if (strlen (label) <= max_lbl && label[0] != '\0')
         {
           int i;
-          if (label != buf) strcpy (buf, label);
+          if (label != buf)
+           strcpy (buf, label);
 
-          for (i = 0; i < strlen (buf); ++i)
-            {
-              if (buf[i] == '-') buf[i] = ' ';
-            }
+          for (i = 0; buf[i] != '\0'; ++i)
+           if (buf[i] == '-')
+             buf[i] = ' ';
           label = buf;
 
         }
-      else label = "";
+      else
+       label = "";
 
       new_lbl = Fupcase_initials (make_string (label, strlen (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);
     }
 
   /* If got a filter apply it on binding.  */
@@ -9087,7 +8966,14 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
   if (INTERACTIVE)
     {
       if (!NILP (prompt))
-       echo_prompt (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;
+         current_kboard->echo_after_prompt = SCHARS (prompt);
+         echo_now ();
+       }
       else if (cursor_in_echo_area
               && (FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
               && NILP (Fzerop (Vecho_keystrokes)))
@@ -10306,13 +10192,12 @@ give to the command you invoke, if it asks for an argument.  */)
   (Lisp_Object prefixarg)
 {
   Lisp_Object function;
-  char buf[40];
-  int saved_last_point_position;
+  EMACS_INT saved_last_point_position;
   Lisp_Object saved_keys, saved_last_point_position_buffer;
   Lisp_Object bindings, value;
   struct gcpro gcpro1, gcpro2, gcpro3;
 #ifdef HAVE_WINDOW_SYSTEM
-  /* The call to Fcompleting_read wil start and cancel the hourglass,
+  /* The call to Fcompleting_read will start and cancel the hourglass,
      but if the hourglass was already scheduled, this means that no
      hourglass will be shown for the actual M-x command itself.
      So we restart it if it is already scheduled.  Note that checking
@@ -10325,31 +10210,9 @@ give to the command you invoke, if it asks for an argument.  */)
                        XVECTOR (this_command_keys)->contents);
   saved_last_point_position_buffer = last_point_position_buffer;
   saved_last_point_position = last_point_position;
-  buf[0] = 0;
   GCPRO3 (saved_keys, prefixarg, saved_last_point_position_buffer);
 
-  if (EQ (prefixarg, Qminus))
-    strcpy (buf, "- ");
-  else if (CONSP (prefixarg) && XINT (XCAR (prefixarg)) == 4)
-    strcpy (buf, "C-u ");
-  else if (CONSP (prefixarg) && INTEGERP (XCAR (prefixarg)))
-    sprintf (buf, "%ld ", (long) XINT (XCAR (prefixarg)));
-  else if (INTEGERP (prefixarg))
-    sprintf (buf, "%ld ", (long) XINT (prefixarg));
-
-  /* This isn't strictly correct if execute-extended-command
-     is bound to anything else.  Perhaps it should use
-     this_command_keys?  */
-  strcat (buf, "M-x ");
-
-  /* Prompt with buf, and then read a string, completing from and
-     restricting to the set of all defined commands.  Don't provide
-     any initial input.  Save the command read on the extended-command
-     history list. */
-  function = Fcompleting_read (build_string (buf),
-                              Vobarray, Qcommandp,
-                              Qt, Qnil, Qextended_command_history, Qnil,
-                              Qnil);
+  function = call0 (intern ("read-extended-command"));
 
 #ifdef HAVE_WINDOW_SYSTEM
   if (hstarted) start_hourglass ();
@@ -10797,7 +10660,7 @@ stuff_buffered_input (Lisp_Object stuffstring)
 
   if (STRINGP (stuffstring))
     {
-      register int count;
+      register EMACS_INT count;
 
       p = SDATA (stuffstring);
       count = SBYTES (stuffstring);
@@ -11087,10 +10950,10 @@ See also `current-input-mode'.  */)
 #ifndef DOS_NT
       /* this causes startup screen to be restored and messes with the mouse */
       reset_all_sys_modes ();
-#endif
       interrupt_input = new_interrupt_input;
-#ifndef DOS_NT
       init_all_sys_modes ();
+#else
+      interrupt_input = new_interrupt_input;
 #endif
 
 #ifdef POLL_FOR_INPUT
@@ -11314,7 +11177,7 @@ The `posn-' functions access elements of such lists.  */)
 
   CHECK_LIVE_FRAME (frame_or_window);
 
-  return make_lispy_position (XFRAME (frame_or_window), &x, &y, 0);
+  return make_lispy_position (XFRAME (frame_or_window), x, y, 0);
 }
 
 DEFUN ("posn-at-point", Fposn_at_point, Sposn_at_point, 0, 2, 0,
@@ -11467,11 +11330,11 @@ init_keyboard (void)
          Emacs on SIGINT when there are no termcap frames on the
          controlling terminal. */
       signal (SIGINT, interrupt_signal);
-#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
+#ifndef DOS_NT
       /* For systems with SysV TERMIO, C-g is set up for both SIGINT and
         SIGQUIT and we can't tell which one it will give us.  */
       signal (SIGQUIT, interrupt_signal);
-#endif /* HAVE_TERMIO */
+#endif /* not DOS_NT */
     }
 /* Note SIGIO has been undef'd if FIONREAD is missing.  */
 #ifdef SIGIO
@@ -11505,7 +11368,7 @@ init_keyboard (void)
    event header symbols and put properties on them.  */
 struct event_head {
   Lisp_Object *var;
-  char *name;
+  const char *name;
   Lisp_Object *kind;
 };
 
@@ -11628,6 +11491,8 @@ syms_of_keyboard (void)
   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);
@@ -11682,6 +11547,13 @@ syms_of_keyboard (void)
   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");
@@ -11802,19 +11674,19 @@ syms_of_keyboard (void)
   defsubr (&Sposn_at_point);
   defsubr (&Sposn_at_x_y);
 
-  DEFVAR_LISP ("last-command-event", &last_command_event,
+  DEFVAR_LISP ("last-command-event", last_command_event,
                     doc: /* Last input event that was part of a command.  */);
 
-  DEFVAR_LISP ("last-nonmenu-event", &last_nonmenu_event,
+  DEFVAR_LISP ("last-nonmenu-event", last_nonmenu_event,
               doc: /* Last input event in a command, except for mouse menu events.
 Mouse menus give back keys that don't look like mouse events;
 this variable holds the actual mouse event that led to the menu,
 so that you can determine whether the command was run by mouse or not.  */);
 
-  DEFVAR_LISP ("last-input-event", &last_input_event,
+  DEFVAR_LISP ("last-input-event", last_input_event,
               doc: /* Last input event.  */);
 
-  DEFVAR_LISP ("unread-command-events", &Vunread_command_events,
+  DEFVAR_LISP ("unread-command-events", Vunread_command_events,
               doc: /* List of events to be read as the command input.
 These events are processed first, before actual keyboard input.
 Events read from this list are not normally added to `this-command-keys',
@@ -11822,16 +11694,16 @@ as they will already have been added once as they were read for the first time.
 An element of the form (t . EVENT) forces EVENT to be added to that list.  */);
   Vunread_command_events = Qnil;
 
-  DEFVAR_INT ("unread-command-char", &unread_command_char,
+  DEFVAR_INT ("unread-command-char", unread_command_char,
              doc: /* If not -1, an object to be read as next command input event.  */);
 
-  DEFVAR_LISP ("unread-post-input-method-events", &Vunread_post_input_method_events,
+  DEFVAR_LISP ("unread-post-input-method-events", Vunread_post_input_method_events,
               doc: /* List of events to be processed as input by input methods.
 These events are processed before `unread-command-events'
 and actual keyboard input, but are not given to `input-method-function'.  */);
   Vunread_post_input_method_events = Qnil;
 
-  DEFVAR_LISP ("unread-input-method-events", &Vunread_input_method_events,
+  DEFVAR_LISP ("unread-input-method-events", Vunread_input_method_events,
               doc: /* List of events to be processed as input by input methods.
 These events are processed after `unread-command-events', but
 before actual keyboard input.
@@ -11839,7 +11711,7 @@ If there's an active input method, the events are given to
 `input-method-function'.  */);
   Vunread_input_method_events = Qnil;
 
-  DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char,
+  DEFVAR_LISP ("meta-prefix-char", meta_prefix_char,
               doc: /* Meta-prefix character code.
 Meta-foo as command input turns into this character followed by foo.  */);
   XSETINT (meta_prefix_char, 033);
@@ -11869,59 +11741,59 @@ See Info node `(elisp)Multiple Terminals'.  */);
 The last command executed that was not bound to an input event.
 This is the command `repeat' will try to repeat.  */);
 
-  DEFVAR_LISP ("this-command", &Vthis_command,
+  DEFVAR_LISP ("this-command", Vthis_command,
               doc: /* The command now being executed.
 The command can set this variable; whatever is put here
 will be in `last-command' during the following command.  */);
   Vthis_command = Qnil;
 
   DEFVAR_LISP ("this-command-keys-shift-translated",
-              &Vthis_command_keys_shift_translated,
+              Vthis_command_keys_shift_translated,
               doc: /* Non-nil if the key sequence activating this command was shift-translated.
 Shift-translation occurs when there is no binding for the key sequence
 as entered, but a binding was found by changing an upper-case letter
 to lower-case, or a shifted function key to an unshifted one.  */);
   Vthis_command_keys_shift_translated = Qnil;
 
-  DEFVAR_LISP ("this-original-command", &Vthis_original_command,
+  DEFVAR_LISP ("this-original-command", Vthis_original_command,
               doc: /* The command bound to the current key sequence before remapping.
 It equals `this-command' if the original command was not remapped through
 any of the active keymaps.  Otherwise, the value of `this-command' is the
 result of looking up the original command in the active keymaps.  */);
   Vthis_original_command = Qnil;
 
-  DEFVAR_INT ("auto-save-interval", &auto_save_interval,
+  DEFVAR_INT ("auto-save-interval", auto_save_interval,
              doc: /* *Number of input events between auto-saves.
 Zero means disable autosaving due to number of characters typed.  */);
   auto_save_interval = 300;
 
-  DEFVAR_LISP ("auto-save-timeout", &Vauto_save_timeout,
+  DEFVAR_LISP ("auto-save-timeout", Vauto_save_timeout,
               doc: /* *Number of seconds idle time before auto-save.
 Zero or nil means disable auto-saving due to idleness.
 After auto-saving due to this many seconds of idle time,
 Emacs also does a garbage collection if that seems to be warranted.  */);
   XSETFASTINT (Vauto_save_timeout, 30);
 
-  DEFVAR_LISP ("echo-keystrokes", &Vecho_keystrokes,
+  DEFVAR_LISP ("echo-keystrokes", Vecho_keystrokes,
               doc: /* *Nonzero means echo unfinished commands after this many seconds of pause.
 The value may be integer or floating point.  */);
   Vecho_keystrokes = make_number (1);
 
-  DEFVAR_INT ("polling-period", &polling_period,
+  DEFVAR_INT ("polling-period", polling_period,
              doc: /* *Interval between polling for input during Lisp execution.
 The reason for polling is to make C-g work to stop a running program.
 Polling is needed only when using X windows and SIGIO does not work.
 Polling is automatically disabled in all other cases.  */);
   polling_period = 2;
 
-  DEFVAR_LISP ("double-click-time", &Vdouble_click_time,
+  DEFVAR_LISP ("double-click-time", Vdouble_click_time,
               doc: /* *Maximum time between mouse clicks to make a double-click.
 Measured in milliseconds.  The value nil means disable double-click
 recognition; t means double-clicks have no time limit and are detected
 by position only.  */);
   Vdouble_click_time = make_number (500);
 
-  DEFVAR_INT ("double-click-fuzz", &double_click_fuzz,
+  DEFVAR_INT ("double-click-fuzz", double_click_fuzz,
              doc: /* *Maximum mouse movement between clicks to make a double-click.
 On window-system frames, value is the number of pixels the mouse may have
 moved horizontally or vertically between two clicks to make a double-click.
@@ -11932,54 +11804,54 @@ This variable is also the threshold for motion of the mouse
 to count as a drag.  */);
   double_click_fuzz = 3;
 
-  DEFVAR_BOOL ("inhibit-local-menu-bar-menus", &inhibit_local_menu_bar_menus,
+  DEFVAR_BOOL ("inhibit-local-menu-bar-menus", inhibit_local_menu_bar_menus,
               doc: /* *Non-nil means inhibit local map menu bar menus.  */);
   inhibit_local_menu_bar_menus = 0;
 
-  DEFVAR_INT ("num-input-keys", &num_input_keys,
+  DEFVAR_INT ("num-input-keys", num_input_keys,
              doc: /* Number of complete key sequences read as input so far.
 This includes key sequences read from keyboard macros.
 The number is effectively the number of interactive command invocations.  */);
   num_input_keys = 0;
 
-  DEFVAR_INT ("num-nonmacro-input-events", &num_nonmacro_input_events,
+  DEFVAR_INT ("num-nonmacro-input-events", num_nonmacro_input_events,
              doc: /* Number of input events read from the keyboard so far.
 This does not include events generated by keyboard macros.  */);
   num_nonmacro_input_events = 0;
 
-  DEFVAR_LISP ("last-event-frame", &Vlast_event_frame,
+  DEFVAR_LISP ("last-event-frame", Vlast_event_frame,
               doc: /* The frame in which the most recently read event occurred.
 If the last event came from a keyboard macro, this is set to `macro'.  */);
   Vlast_event_frame = Qnil;
 
   /* This variable is set up in sysdep.c.  */
-  DEFVAR_LISP ("tty-erase-char", &Vtty_erase_char,
+  DEFVAR_LISP ("tty-erase-char", Vtty_erase_char,
               doc: /* The ERASE character as set by the user with stty.  */);
 
-  DEFVAR_LISP ("help-char", &Vhelp_char,
+  DEFVAR_LISP ("help-char", Vhelp_char,
               doc: /* Character to recognize as meaning Help.
 When it is read, do `(eval help-form)', and display result if it's a string.
 If the value of `help-form' is nil, this char can be read normally.  */);
   XSETINT (Vhelp_char, Ctl ('H'));
 
-  DEFVAR_LISP ("help-event-list", &Vhelp_event_list,
+  DEFVAR_LISP ("help-event-list", Vhelp_event_list,
               doc: /* List of input events to recognize as meaning Help.
 These work just like the value of `help-char' (see that).  */);
   Vhelp_event_list = Qnil;
 
-  DEFVAR_LISP ("help-form", &Vhelp_form,
+  DEFVAR_LISP ("help-form", Vhelp_form,
               doc: /* Form to execute when character `help-char' is read.
 If the form returns a string, that string is displayed.
 If `help-form' is nil, the help char is not recognized.  */);
   Vhelp_form = Qnil;
 
-  DEFVAR_LISP ("prefix-help-command", &Vprefix_help_command,
+  DEFVAR_LISP ("prefix-help-command", Vprefix_help_command,
               doc: /* Command to run when `help-char' character follows a prefix key.
 This command is used only when there is no actual binding
 for that character after that prefix key.  */);
   Vprefix_help_command = Qnil;
 
-  DEFVAR_LISP ("top-level", &Vtop_level,
+  DEFVAR_LISP ("top-level", Vtop_level,
               doc: /* Form to evaluate when Emacs starts up.
 Useful to set before you dump a modified Emacs.  */);
   Vtop_level = Qnil;
@@ -12000,12 +11872,12 @@ output.  See also `translation-table-for-input'.
 This variable has a separate binding for each terminal.
 See Info node `(elisp)Multiple Terminals'.  */);
 
-  DEFVAR_BOOL ("cannot-suspend", &cannot_suspend,
+  DEFVAR_BOOL ("cannot-suspend", cannot_suspend,
               doc: /* Non-nil means to always spawn a subshell instead of suspending.
 \(Even if the operating system has support for stopping a process.\)  */);
   cannot_suspend = 0;
 
-  DEFVAR_BOOL ("menu-prompting", &menu_prompting,
+  DEFVAR_BOOL ("menu-prompting", menu_prompting,
               doc: /* Non-nil means prompt with menus when appropriate.
 This is done when reading from a keymap that has a prompt string,
 for elements that have prompt strings.
@@ -12015,12 +11887,12 @@ time and the previous event was a mouse click prefix key.
 Otherwise, menu prompting uses the echo area.  */);
   menu_prompting = 1;
 
-  DEFVAR_LISP ("menu-prompt-more-char", &menu_prompt_more_char,
+  DEFVAR_LISP ("menu-prompt-more-char", menu_prompt_more_char,
               doc: /* Character to see next line of menu prompt.
 Type this character while in a menu prompt to rotate around the lines of it.  */);
   XSETINT (menu_prompt_more_char, ' ');
 
-  DEFVAR_INT ("extra-keyboard-modifiers", &extra_keyboard_modifiers,
+  DEFVAR_INT ("extra-keyboard-modifiers", extra_keyboard_modifiers,
              doc: /* A mask of additional modifier keys to use with every keyboard character.
 Emacs applies the modifiers of the character stored here to each keyboard
 character it reads.  For example, after evaluating the expression
@@ -12033,7 +11905,7 @@ with no modifiers; thus, setting `extra-keyboard-modifiers' to zero
 cancels any modification.  */);
   extra_keyboard_modifiers = 0;
 
-  DEFVAR_LISP ("deactivate-mark", &Vdeactivate_mark,
+  DEFVAR_LISP ("deactivate-mark", Vdeactivate_mark,
               doc: /* If an editing command sets this to t, deactivate the mark afterward.
 The command loop sets this to nil before each command,
 and tests the value when the command returns.
@@ -12042,18 +11914,18 @@ Buffer modification stores t in this variable.  */);
   Qdeactivate_mark = intern_c_string ("deactivate-mark");
   staticpro (&Qdeactivate_mark);
 
-  DEFVAR_LISP ("command-hook-internal", &Vcommand_hook_internal,
+  DEFVAR_LISP ("command-hook-internal", Vcommand_hook_internal,
               doc: /* Temporary storage of `pre-command-hook' or `post-command-hook'.  */);
   Vcommand_hook_internal = Qnil;
 
-  DEFVAR_LISP ("pre-command-hook", &Vpre_command_hook,
+  DEFVAR_LISP ("pre-command-hook", Vpre_command_hook,
               doc: /* Normal hook run before each command is executed.
 If an unhandled error happens in running this hook,
 the hook value is set to nil, since otherwise the error
 might happen repeatedly and make Emacs nonfunctional.  */);
   Vpre_command_hook = Qnil;
 
-  DEFVAR_LISP ("post-command-hook", &Vpost_command_hook,
+  DEFVAR_LISP ("post-command-hook", Vpost_command_hook,
               doc: /* Normal hook run after each command is executed.
 If an unhandled error happens in running this hook,
 the hook value is set to nil, since otherwise the error
@@ -12068,15 +11940,21 @@ might happen repeatedly and make Emacs nonfunctional.  */);
   staticpro (&Qecho_area_clear_hook);
   Fset (Qecho_area_clear_hook, Qnil);
 
-  DEFVAR_LISP ("lucid-menu-bar-dirty-flag", &Vlucid_menu_bar_dirty_flag,
+  DEFVAR_LISP ("lucid-menu-bar-dirty-flag", Vlucid_menu_bar_dirty_flag,
               doc: /* Non-nil means menu bar, specified Lucid style, needs to be recomputed.  */);
   Vlucid_menu_bar_dirty_flag = Qnil;
 
-  DEFVAR_LISP ("menu-bar-final-items", &Vmenu_bar_final_items,
+  DEFVAR_LISP ("menu-bar-final-items", Vmenu_bar_final_items,
               doc: /* List of menu bar items to move to the end of the menu bar.
 The elements of the list are event types that may have menu bar bindings.  */);
   Vmenu_bar_final_items = Qnil;
 
+  DEFVAR_LISP ("tool-bar-separator-image-expression", Vtool_bar_separator_image_expression,
+    doc: /* Expression evaluating to the image spec for a tool-bar separator.
+This is used internally by graphical displays that do not render
+tool-bar separators natively.  Otherwise it is unused (e.g. on GTK).  */);
+  Vtool_bar_separator_image_expression = Qnil;
+
   DEFVAR_KBOARD ("overriding-terminal-local-map",
                 Voverriding_terminal_local_map,
                 doc: /* Per-terminal keymap that overrides all other local keymaps.
@@ -12091,23 +11969,23 @@ set up a different keymap for reading the next command.
 terminal device.
 See Info node `(elisp)Multiple Terminals'.  */);
 
-  DEFVAR_LISP ("overriding-local-map", &Voverriding_local_map,
+  DEFVAR_LISP ("overriding-local-map", Voverriding_local_map,
               doc: /* Keymap that overrides all other local keymaps.
 If this variable is non-nil, it is used as a keymap--replacing the
 buffer's local map, the minor mode keymaps, and char property keymaps.  */);
   Voverriding_local_map = Qnil;
 
-  DEFVAR_LISP ("overriding-local-map-menu-flag", &Voverriding_local_map_menu_flag,
+  DEFVAR_LISP ("overriding-local-map-menu-flag", Voverriding_local_map_menu_flag,
               doc: /* Non-nil means `overriding-local-map' applies to the menu bar.
 Otherwise, the menu bar continues to reflect the buffer's local map
 and the minor mode maps regardless of `overriding-local-map'.  */);
   Voverriding_local_map_menu_flag = Qnil;
 
-  DEFVAR_LISP ("special-event-map", &Vspecial_event_map,
+  DEFVAR_LISP ("special-event-map", Vspecial_event_map,
               doc: /* Keymap defining bindings for special events to execute at low level.  */);
   Vspecial_event_map = Fcons (intern_c_string ("keymap"), Qnil);
 
-  DEFVAR_LISP ("track-mouse", &do_mouse_tracking,
+  DEFVAR_LISP ("track-mouse", do_mouse_tracking,
               doc: /* *Non-nil means generate motion events for mouse motion.  */);
 
   DEFVAR_KBOARD ("system-key-alist", Vsystem_key_alist,
@@ -12167,7 +12045,7 @@ themselves looked up in `input-decode-map'.
 
 This variable is keyboard-local.  */);
 
-  DEFVAR_LISP ("function-key-map", &Vfunction_key_map,
+  DEFVAR_LISP ("function-key-map", Vfunction_key_map,
                doc: /* The parent keymap of all `local-function-key-map' instances.
 Function key definitions that apply to all terminal devices should go
 here.  If a mapping is defined in both the current
@@ -12175,39 +12053,39 @@ here.  If a mapping is defined in both the current
 definition will take precendence.  */);
   Vfunction_key_map = Fmake_sparse_keymap (Qnil);
 
-  DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
+  DEFVAR_LISP ("key-translation-map", Vkey_translation_map,
                doc: /* Keymap of key translations that can override keymaps.
 This keymap works like `function-key-map', but comes after that,
 and its non-prefix bindings override ordinary bindings.
 Another difference is that it is global rather than keyboard-local.  */);
   Vkey_translation_map = Fmake_sparse_keymap (Qnil);
 
-  DEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list,
+  DEFVAR_LISP ("deferred-action-list", Vdeferred_action_list,
               doc: /* List of deferred actions to be performed at a later time.
 The precise format isn't relevant here; we just check whether it is nil.  */);
   Vdeferred_action_list = Qnil;
 
-  DEFVAR_LISP ("deferred-action-function", &Vdeferred_action_function,
+  DEFVAR_LISP ("deferred-action-function", Vdeferred_action_function,
               doc: /* Function to call to handle deferred actions, after each command.
 This function is called with no arguments after each command
 whenever `deferred-action-list' is non-nil.  */);
   Vdeferred_action_function = Qnil;
 
-  DEFVAR_LISP ("suggest-key-bindings", &Vsuggest_key_bindings,
+  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.
 If the value is non-nil and not a number, we wait 2 seconds.  */);
   Vsuggest_key_bindings = Qt;
 
-  DEFVAR_LISP ("timer-list", &Vtimer_list,
+  DEFVAR_LISP ("timer-list", Vtimer_list,
               doc: /* List of active absolute time timers in order of increasing time.  */);
   Vtimer_list = Qnil;
 
-  DEFVAR_LISP ("timer-idle-list", &Vtimer_idle_list,
+  DEFVAR_LISP ("timer-idle-list", Vtimer_idle_list,
               doc: /* List of active idle-time timers in order of increasing time.  */);
   Vtimer_idle_list = Qnil;
 
-  DEFVAR_LISP ("input-method-function", &Vinput_method_function,
+  DEFVAR_LISP ("input-method-function", Vinput_method_function,
               doc: /* If non-nil, the function that implements the current input method.
 It's called with one argument, a printing character that was just read.
 \(That means a character with code 040...0176.)
@@ -12229,18 +12107,18 @@ for guidance on what to do.  */);
   Vinput_method_function = Qnil;
 
   DEFVAR_LISP ("input-method-previous-message",
-              &Vinput_method_previous_message,
+              Vinput_method_previous_message,
               doc: /* When `input-method-function' is called, hold the previous echo area message.
 This variable exists because `read-event' clears the echo area
 before running the input method.  It is nil if there was no message.  */);
   Vinput_method_previous_message = Qnil;
 
-  DEFVAR_LISP ("show-help-function", &Vshow_help_function,
+  DEFVAR_LISP ("show-help-function", Vshow_help_function,
               doc: /* If non-nil, the function that implements the display of help.
 It's called with one argument, the help string to display.  */);
   Vshow_help_function = Qnil;
 
-  DEFVAR_LISP ("disable-point-adjustment", &Vdisable_point_adjustment,
+  DEFVAR_LISP ("disable-point-adjustment", Vdisable_point_adjustment,
               doc: /* If non-nil, suppress point adjustment after executing a command.
 
 After a command is executed, if point is moved into a region that has
@@ -12253,7 +12131,7 @@ just after executing the command.  */);
   Vdisable_point_adjustment = Qnil;
 
   DEFVAR_LISP ("global-disable-point-adjustment",
-              &Vglobal_disable_point_adjustment,
+              Vglobal_disable_point_adjustment,
               doc: /* *If non-nil, always suppress point adjustment.
 
 The default value is nil, in which case, point adjustment are
@@ -12261,18 +12139,18 @@ suppressed only after special commands that set
 `disable-point-adjustment' (which see) to non-nil.  */);
   Vglobal_disable_point_adjustment = Qnil;
 
-  DEFVAR_LISP ("minibuffer-message-timeout", &Vminibuffer_message_timeout,
+  DEFVAR_LISP ("minibuffer-message-timeout", Vminibuffer_message_timeout,
               doc: /* *How long to display an echo-area message when the minibuffer is active.
 If the value is not a number, such messages don't time out.  */);
   Vminibuffer_message_timeout = make_number (2);
 
-  DEFVAR_LISP ("throw-on-input", &Vthrow_on_input,
+  DEFVAR_LISP ("throw-on-input", Vthrow_on_input,
               doc: /* If non-nil, any keyboard input throws to this symbol.
 The value of that variable is passed to `quit-flag' and later causes a
 peculiar kind of quitting.  */);
   Vthrow_on_input = Qnil;
 
-  DEFVAR_LISP ("command-error-function", &Vcommand_error_function,
+  DEFVAR_LISP ("command-error-function", Vcommand_error_function,
               doc: /* If non-nil, function to output error messages.
 The arguments are the error data, a list of the form
  (SIGNALED-CONDITIONS . SIGNAL-DATA)
@@ -12282,13 +12160,30 @@ and the Lisp function within which the error was signaled.  */);
   Vcommand_error_function = Qnil;
 
   DEFVAR_LISP ("enable-disabled-menus-and-buttons",
-              &Venable_disabled_menus_and_buttons,
+              Venable_disabled_menus_and_buttons,
               doc: /* If non-nil, don't ignore events produced by disabled menu items and tool-bar.
 
 Help functions bind this to allow help on disabled menu items
 and tool-bar buttons.  */);
   Venable_disabled_menus_and_buttons = Qnil;
 
+  DEFVAR_LISP ("select-active-regions",
+              Vselect_active_regions,
+              doc: /* If non-nil, an active region automatically sets the primary selection.
+If the value is `only', only temporarily active regions (usually made
+by mouse-dragging or shift-selection) set the window selection.
+
+This takes effect only when Transient Mark mode is enabled.  */);
+  Vselect_active_regions = Qt;
+
+  DEFVAR_LISP ("saved-region-selection",
+              Vsaved_region_selection,
+              doc: /* Contents of active region prior to buffer modification.
+If `select-active-regions' is non-nil, Emacs sets this to the
+text in the region before modifying the buffer.  The next
+`deactivate-mark' call uses this to set the window selection.  */);
+  Vsaved_region_selection = Qnil;
+
   /* Create the initial keyboard. */
   initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
   init_kboard (initial_kboard);
@@ -12402,6 +12297,3 @@ mark_kboards (void)
       }
   }
 }
-
-/* arch-tag: 774e34d7-6d31-42f3-8397-e079a4e4c9ca
-   (do not change this comment) */