aboutsummaryrefslogtreecommitdiffstats
path: root/src/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c503
1 files changed, 288 insertions, 215 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 16300e6154c..f791773c352 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1,6 +1,6 @@
1/* Keyboard and mouse input; editor command loop. 1/* Keyboard and mouse input; editor command loop.
2 2
3Copyright (C) 1985-1989, 1993-1997, 1999-2011 Free Software Foundation, Inc. 3Copyright (C) 1985-1989, 1993-1997, 1999-2012 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -44,7 +44,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
44#include "process.h" 44#include "process.h"
45#include <errno.h> 45#include <errno.h>
46 46
47#ifdef HAVE_GTK_AND_PTHREAD 47#ifdef HAVE_PTHREAD
48#include <pthread.h> 48#include <pthread.h>
49#endif 49#endif
50#ifdef MSDOS 50#ifdef MSDOS
@@ -73,7 +73,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
73#include "nsterm.h" 73#include "nsterm.h"
74#endif 74#endif
75 75
76/* Variables for blockinput.h: */ 76/* Variables for blockinput.h: */
77 77
78/* Non-zero if interrupt input is blocked right now. */ 78/* Non-zero if interrupt input is blocked right now. */
79volatile int interrupt_input_blocked; 79volatile int interrupt_input_blocked;
@@ -196,7 +196,7 @@ int immediate_quit;
196int quit_char; 196int quit_char;
197 197
198/* Current depth in recursive edits. */ 198/* Current depth in recursive edits. */
199int command_loop_level; 199EMACS_INT command_loop_level;
200 200
201/* If not Qnil, this is a switch-frame event which we decided to put 201/* If not Qnil, this is a switch-frame event which we decided to put
202 off until the end of a key sequence. This should be read as the 202 off until the end of a key sequence. This should be read as the
@@ -210,8 +210,8 @@ Lisp_Object unread_switch_frame;
210/* Last size recorded for a current buffer which is not a minibuffer. */ 210/* Last size recorded for a current buffer which is not a minibuffer. */
211static EMACS_INT last_non_minibuf_size; 211static EMACS_INT last_non_minibuf_size;
212 212
213/* Total number of times read_char has returned, modulo SIZE_MAX + 1. */ 213/* Total number of times read_char has returned, modulo UINTMAX_MAX + 1. */
214size_t num_input_events; 214uintmax_t num_input_events;
215 215
216/* Value of num_nonmacro_input_events as of last auto save. */ 216/* Value of num_nonmacro_input_events as of last auto save. */
217 217
@@ -252,6 +252,7 @@ static Lisp_Object Qtimer_event_handler;
252/* read_key_sequence stores here the command definition of the 252/* read_key_sequence stores here the command definition of the
253 key sequence that it reads. */ 253 key sequence that it reads. */
254static Lisp_Object read_key_sequence_cmd; 254static Lisp_Object read_key_sequence_cmd;
255static Lisp_Object read_key_sequence_remapped;
255 256
256static Lisp_Object Qinput_method_function; 257static Lisp_Object Qinput_method_function;
257 258
@@ -337,7 +338,7 @@ static Lisp_Object Qconfig_changed_event;
337Lisp_Object Qevent_kind; 338Lisp_Object Qevent_kind;
338static Lisp_Object Qevent_symbol_elements; 339static Lisp_Object Qevent_symbol_elements;
339 340
340/* menu and tool bar item parts */ 341/* Menu and tool bar item parts. */
341static Lisp_Object Qmenu_enable; 342static Lisp_Object Qmenu_enable;
342static Lisp_Object QCenable, QCvisible, QChelp, QCkeys, QCkey_sequence; 343static Lisp_Object QCenable, QCvisible, QChelp, QCkeys, QCkey_sequence;
343Lisp_Object QCfilter; 344Lisp_Object QCfilter;
@@ -408,7 +409,7 @@ int interrupts_deferred;
408 409
409/* If we support a window system, turn on the code to poll periodically 410/* If we support a window system, turn on the code to poll periodically
410 to detect C-g. It isn't actually used when doing interrupt input. */ 411 to detect C-g. It isn't actually used when doing interrupt input. */
411#if defined(HAVE_WINDOW_SYSTEM) && !defined(USE_ASYNC_EVENTS) 412#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_ASYNC_EVENTS)
412#define POLL_FOR_INPUT 413#define POLL_FOR_INPUT
413#endif 414#endif
414 415
@@ -435,16 +436,16 @@ static void (*keyboard_init_hook) (void);
435static int read_avail_input (int); 436static int read_avail_input (int);
436static void get_input_pending (int *, int); 437static void get_input_pending (int *, int);
437static int readable_events (int); 438static int readable_events (int);
438static Lisp_Object read_char_x_menu_prompt (int, Lisp_Object *, 439static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *,
439 Lisp_Object, int *); 440 Lisp_Object, int *);
440static Lisp_Object read_char_minibuf_menu_prompt (int, int, 441static Lisp_Object read_char_minibuf_menu_prompt (int, ptrdiff_t,
441 Lisp_Object *); 442 Lisp_Object *);
442static Lisp_Object make_lispy_event (struct input_event *); 443static Lisp_Object make_lispy_event (struct input_event *);
443#if defined (HAVE_MOUSE) || defined (HAVE_GPM) 444#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
444static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object, 445static Lisp_Object make_lispy_movement (struct frame *, Lisp_Object,
445 enum scroll_bar_part, 446 enum scroll_bar_part,
446 Lisp_Object, Lisp_Object, 447 Lisp_Object, Lisp_Object,
447 unsigned long); 448 Time);
448#endif 449#endif
449static Lisp_Object modify_event_symbol (EMACS_INT, unsigned, Lisp_Object, 450static Lisp_Object modify_event_symbol (EMACS_INT, unsigned, Lisp_Object,
450 Lisp_Object, const char *const *, 451 Lisp_Object, const char *const *,
@@ -463,7 +464,8 @@ static void input_available_signal (int signo);
463static Lisp_Object (Fcommand_execute) (Lisp_Object, Lisp_Object, Lisp_Object, 464static Lisp_Object (Fcommand_execute) (Lisp_Object, Lisp_Object, Lisp_Object,
464 Lisp_Object); 465 Lisp_Object);
465static void handle_interrupt (void); 466static void handle_interrupt (void);
466static void quit_throw_to_read_char (void) NO_RETURN; 467static void quit_throw_to_read_char (int) NO_RETURN;
468static void process_special_events (void);
467static void timer_start_idle (void); 469static void timer_start_idle (void);
468static void timer_stop_idle (void); 470static void timer_stop_idle (void);
469static void timer_resume_idle (void); 471static void timer_resume_idle (void);
@@ -652,7 +654,7 @@ echo_now (void)
652 echo_kboard = current_kboard; 654 echo_kboard = current_kboard;
653 655
654 if (waiting_for_input && !NILP (Vquit_flag)) 656 if (waiting_for_input && !NILP (Vquit_flag))
655 quit_throw_to_read_char (); 657 quit_throw_to_read_char (0);
656} 658}
657 659
658/* Turn off echoing, for the start of a new command. */ 660/* Turn off echoing, for the start of a new command. */
@@ -834,7 +836,7 @@ recursive_edit_unwind (Lisp_Object buffer)
834 836
835 837
836#if 0 /* These two functions are now replaced with 838#if 0 /* These two functions are now replaced with
837 temporarily_switch_to_single_kboard. */ 839 temporarily_switch_to_single_kboard. */
838static void 840static void
839any_kboard_state () 841any_kboard_state ()
840{ 842{
@@ -931,7 +933,7 @@ pop_kboard (void)
931 state later. 933 state later.
932 934
933 If Emacs is already in single_kboard mode, and F's keyboard is 935 If Emacs is already in single_kboard mode, and F's keyboard is
934 locked, then this function will throw an errow. */ 936 locked, then this function will throw an error. */
935 937
936void 938void
937temporarily_switch_to_single_kboard (struct frame *f) 939temporarily_switch_to_single_kboard (struct frame *f)
@@ -998,7 +1000,8 @@ static Lisp_Object
998cmd_error (Lisp_Object data) 1000cmd_error (Lisp_Object data)
999{ 1001{
1000 Lisp_Object old_level, old_length; 1002 Lisp_Object old_level, old_length;
1001 char macroerror[50]; 1003 char macroerror[sizeof "After..kbd macro iterations: "
1004 + INT_STRLEN_BOUND (EMACS_INT)];
1002 1005
1003#ifdef HAVE_WINDOW_SYSTEM 1006#ifdef HAVE_WINDOW_SYSTEM
1004 if (display_hourglass_p) 1007 if (display_hourglass_p)
@@ -1010,7 +1013,7 @@ cmd_error (Lisp_Object data)
1010 if (executing_kbd_macro_iterations == 1) 1013 if (executing_kbd_macro_iterations == 1)
1011 sprintf (macroerror, "After 1 kbd macro iteration: "); 1014 sprintf (macroerror, "After 1 kbd macro iteration: ");
1012 else 1015 else
1013 sprintf (macroerror, "After %d kbd macro iterations: ", 1016 sprintf (macroerror, "After %"pI"d kbd macro iterations: ",
1014 executing_kbd_macro_iterations); 1017 executing_kbd_macro_iterations);
1015 } 1018 }
1016 else 1019 else
@@ -1036,7 +1039,7 @@ cmd_error (Lisp_Object data)
1036 Vquit_flag = Qnil; 1039 Vquit_flag = Qnil;
1037 1040
1038 Vinhibit_quit = Qnil; 1041 Vinhibit_quit = Qnil;
1039#if 0 /* This shouldn't be necessary anymore. --lorentey */ 1042#if 0 /* This shouldn't be necessary anymore. --lorentey */
1040 if (command_loop_level == 0 && minibuf_level == 0) 1043 if (command_loop_level == 0 && minibuf_level == 0)
1041 any_kboard_state (); 1044 any_kboard_state ();
1042#endif 1045#endif
@@ -1058,7 +1061,7 @@ cmd_error_internal (Lisp_Object data, const char *context)
1058 struct frame *sf = SELECTED_FRAME (); 1061 struct frame *sf = SELECTED_FRAME ();
1059 1062
1060 /* The immediate context is not interesting for Quits, 1063 /* The immediate context is not interesting for Quits,
1061 since they are asyncronous. */ 1064 since they are asynchronous. */
1062 if (EQ (XCAR (data), Qquit)) 1065 if (EQ (XCAR (data), Qquit))
1063 Vsignaling_function = Qnil; 1066 Vsignaling_function = Qnil;
1064 1067
@@ -1129,7 +1132,7 @@ command_loop (void)
1129#if 0 /* This shouldn't be necessary anymore. --lorentey */ 1132#if 0 /* This shouldn't be necessary anymore. --lorentey */
1130 /* Reset single_kboard in case top-level set it while 1133 /* Reset single_kboard in case top-level set it while
1131 evaluating an -f option, or we are stuck there for some 1134 evaluating an -f option, or we are stuck there for some
1132 other reason. */ 1135 other reason. */
1133 any_kboard_state (); 1136 any_kboard_state ();
1134#endif 1137#endif
1135 internal_catch (Qtop_level, command_loop_2, Qnil); 1138 internal_catch (Qtop_level, command_loop_2, Qnil);
@@ -1300,7 +1303,7 @@ some_mouse_moved (void)
1300/* This is the actual command reading loop, 1303/* This is the actual command reading loop,
1301 sans error-handling encapsulation. */ 1304 sans error-handling encapsulation. */
1302 1305
1303static int read_key_sequence (Lisp_Object *, size_t, Lisp_Object, 1306static int read_key_sequence (Lisp_Object *, int, Lisp_Object,
1304 int, int, int); 1307 int, int, int);
1305void safe_run_hooks (Lisp_Object); 1308void safe_run_hooks (Lisp_Object);
1306static void adjust_point_for_property (EMACS_INT, int); 1309static void adjust_point_for_property (EMACS_INT, int);
@@ -1490,8 +1493,8 @@ command_loop_1 (void)
1490 if (!NILP (Vquit_flag)) 1493 if (!NILP (Vquit_flag))
1491 { 1494 {
1492 Vexecuting_kbd_macro = Qt; 1495 Vexecuting_kbd_macro = Qt;
1493 QUIT; /* Make some noise. */ 1496 QUIT; /* Make some noise. */
1494 /* Will return since macro now empty. */ 1497 /* Will return since macro now empty. */
1495 } 1498 }
1496 } 1499 }
1497 1500
@@ -1510,17 +1513,13 @@ command_loop_1 (void)
1510 Vdisable_point_adjustment = Qnil; 1513 Vdisable_point_adjustment = Qnil;
1511 1514
1512 /* Process filters and timers may have messed with deactivate-mark. 1515 /* Process filters and timers may have messed with deactivate-mark.
1513 reset it before we execute the command. */ 1516 reset it before we execute the command. */
1514 Vdeactivate_mark = Qnil; 1517 Vdeactivate_mark = Qnil;
1515 1518
1516 /* Remap command through active keymaps */ 1519 /* Remap command through active keymaps. */
1517 Vthis_original_command = cmd; 1520 Vthis_original_command = cmd;
1518 if (SYMBOLP (cmd)) 1521 if (!NILP (read_key_sequence_remapped))
1519 { 1522 cmd = read_key_sequence_remapped;
1520 Lisp_Object cmd1;
1521 if (cmd1 = Fcommand_remapping (cmd, Qnil, Qnil), !NILP (cmd1))
1522 cmd = cmd1;
1523 }
1524 1523
1525 /* Execute the command. */ 1524 /* Execute the command. */
1526 1525
@@ -1554,7 +1553,7 @@ command_loop_1 (void)
1554 } 1553 }
1555 else 1554 else
1556 { 1555 {
1557 /* Here for a command that isn't executed directly */ 1556 /* Here for a command that isn't executed directly. */
1558 1557
1559#ifdef HAVE_WINDOW_SYSTEM 1558#ifdef HAVE_WINDOW_SYSTEM
1560 int scount = SPECPDL_INDEX (); 1559 int scount = SPECPDL_INDEX ();
@@ -1750,7 +1749,9 @@ adjust_point_for_property (EMACS_INT last_pt, int modified)
1750 { 1749 {
1751 xassert (end > PT); 1750 xassert (end > PT);
1752 SET_PT (PT < last_pt 1751 SET_PT (PT < last_pt
1753 ? (STRINGP (val) && SCHARS (val) == 0 ? beg - 1 : beg) 1752 ? (STRINGP (val) && SCHARS (val) == 0
1753 ? max (beg - 1, BEGV)
1754 : beg)
1754 : end); 1755 : end);
1755 check_composition = check_invisible = 1; 1756 check_composition = check_invisible = 1;
1756 } 1757 }
@@ -1962,7 +1963,7 @@ void
1962poll_for_input_1 (void) 1963poll_for_input_1 (void)
1963{ 1964{
1964/* Tell ns_read_socket() it is being called asynchronously so it can avoid 1965/* Tell ns_read_socket() it is being called asynchronously so it can avoid
1965 doing anything dangerous. */ 1966 doing anything dangerous. */
1966#ifdef HAVE_NS 1967#ifdef HAVE_NS
1967 ++handling_signal; 1968 ++handling_signal;
1968#endif 1969#endif
@@ -2002,7 +2003,7 @@ start_polling (void)
2002#ifdef POLL_FOR_INPUT 2003#ifdef POLL_FOR_INPUT
2003 /* XXX This condition was (read_socket_hook && !interrupt_input), 2004 /* XXX This condition was (read_socket_hook && !interrupt_input),
2004 but read_socket_hook is not global anymore. Let's pretend that 2005 but read_socket_hook is not global anymore. Let's pretend that
2005 it's always set. */ 2006 it's always set. */
2006 if (!interrupt_input) 2007 if (!interrupt_input)
2007 { 2008 {
2008 /* Turn alarm handling on unconditionally. It might have 2009 /* Turn alarm handling on unconditionally. It might have
@@ -2039,7 +2040,7 @@ input_polling_used (void)
2039#ifdef POLL_FOR_INPUT 2040#ifdef POLL_FOR_INPUT
2040 /* XXX This condition was (read_socket_hook && !interrupt_input), 2041 /* XXX This condition was (read_socket_hook && !interrupt_input),
2041 but read_socket_hook is not global anymore. Let's pretend that 2042 but read_socket_hook is not global anymore. Let's pretend that
2042 it's always set. */ 2043 it's always set. */
2043 return !interrupt_input; 2044 return !interrupt_input;
2044#else 2045#else
2045 return 0; 2046 return 0;
@@ -2054,7 +2055,7 @@ stop_polling (void)
2054#ifdef POLL_FOR_INPUT 2055#ifdef POLL_FOR_INPUT
2055 /* XXX This condition was (read_socket_hook && !interrupt_input), 2056 /* XXX This condition was (read_socket_hook && !interrupt_input),
2056 but read_socket_hook is not global anymore. Let's pretend that 2057 but read_socket_hook is not global anymore. Let's pretend that
2057 it's always set. */ 2058 it's always set. */
2058 if (!interrupt_input) 2059 if (!interrupt_input)
2059 ++poll_suppress_count; 2060 ++poll_suppress_count;
2060#endif 2061#endif
@@ -2240,8 +2241,8 @@ do { if (polling_stopped_here) start_polling (); \
2240 polling_stopped_here = 0; } while (0) 2241 polling_stopped_here = 0; } while (0)
2241 2242
2242/* read a character from the keyboard; call the redisplay if needed */ 2243/* read a character from the keyboard; call the redisplay if needed */
2243/* commandflag 0 means do not do auto-saving, but do do redisplay. 2244/* commandflag 0 means do not autosave, but do redisplay.
2244 -1 means do not do redisplay, but do do autosaving. 2245 -1 means do not redisplay, but do autosave.
2245 1 means do both. */ 2246 1 means do both. */
2246 2247
2247/* The arguments MAPS and NMAPS are for menu prompting. 2248/* The arguments MAPS and NMAPS are for menu prompting.
@@ -2267,7 +2268,8 @@ do { if (polling_stopped_here) start_polling (); \
2267 Value is t if we showed a menu and the user rejected it. */ 2268 Value is t if we showed a menu and the user rejected it. */
2268 2269
2269Lisp_Object 2270Lisp_Object
2270read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event, 2271read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps,
2272 Lisp_Object prev_event,
2271 int *used_mouse_menu, struct timeval *end_time) 2273 int *used_mouse_menu, struct timeval *end_time)
2272{ 2274{
2273 volatile Lisp_Object c; 2275 volatile Lisp_Object c;
@@ -2391,7 +2393,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
2391 real event came from. Normally, a switch-frame event selects 2393 real event came from. Normally, a switch-frame event selects
2392 internal_last_event_frame after each command is read, but 2394 internal_last_event_frame after each command is read, but
2393 events read from a macro should never cause a new frame to be 2395 events read from a macro should never cause a new frame to be
2394 selected. */ 2396 selected. */
2395 Vlast_event_frame = internal_last_event_frame = Qmacro; 2397 Vlast_event_frame = internal_last_event_frame = Qmacro;
2396 2398
2397 /* Exit the macro if we are at the end. 2399 /* Exit the macro if we are at the end.
@@ -2501,7 +2503,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
2501 Try this before the sit-for, because the sit-for 2503 Try this before the sit-for, because the sit-for
2502 would do the wrong thing if we are supposed to do 2504 would do the wrong thing if we are supposed to do
2503 menu prompting. If EVENT_HAS_PARAMETERS then we are reading 2505 menu prompting. If EVENT_HAS_PARAMETERS then we are reading
2504 after a mouse event so don't try a minibuf menu. */ 2506 after a mouse event so don't try a minibuf menu. */
2505 c = Qnil; 2507 c = Qnil;
2506 if (nmaps > 0 && INTERACTIVE 2508 if (nmaps > 0 && INTERACTIVE
2507 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) 2509 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event)
@@ -2999,7 +3001,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
2999 { 3001 {
3000 Lisp_Object keys; 3002 Lisp_Object keys;
3001 int key_count, key_count_reset; 3003 int key_count, key_count_reset;
3002 struct gcpro inner_gcpro1; 3004 struct gcpro gcpro1;
3003 int count = SPECPDL_INDEX (); 3005 int count = SPECPDL_INDEX ();
3004 3006
3005 /* Save the echo status. */ 3007 /* Save the echo status. */
@@ -3027,7 +3029,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
3027 keys = Fcopy_sequence (this_command_keys); 3029 keys = Fcopy_sequence (this_command_keys);
3028 else 3030 else
3029 keys = Qnil; 3031 keys = Qnil;
3030 GCPRO1_VAR (keys, inner_gcpro); 3032 GCPRO1 (keys);
3031 3033
3032 /* Clear out this_command_keys. */ 3034 /* Clear out this_command_keys. */
3033 this_command_key_count = 0; 3035 this_command_key_count = 0;
@@ -3065,7 +3067,7 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event
3065 if (saved_immediate_echo) 3067 if (saved_immediate_echo)
3066 echo_now (); 3068 echo_now ();
3067 3069
3068 UNGCPRO_VAR (inner_gcpro); 3070 UNGCPRO;
3069 3071
3070 /* The input method can return no events. */ 3072 /* The input method can return no events. */
3071 if (! CONSP (tem)) 3073 if (! CONSP (tem))
@@ -3818,7 +3820,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3818 /* If the quit flag is set, then read_char will return 3820 /* If the quit flag is set, then read_char will return
3819 quit_char, so that counts as "available input." */ 3821 quit_char, so that counts as "available input." */
3820 if (!NILP (Vquit_flag)) 3822 if (!NILP (Vquit_flag))
3821 quit_throw_to_read_char (); 3823 quit_throw_to_read_char (0);
3822 3824
3823 /* One way or another, wait until input is available; then, if 3825 /* One way or another, wait until input is available; then, if
3824 interrupt handlers have not read it, read it now. */ 3826 interrupt handlers have not read it, read it now. */
@@ -3953,7 +3955,7 @@ kbd_buffer_get_event (KBOARD **kbp,
3953 kbd_fetch_ptr = event + 1; 3955 kbd_fetch_ptr = event + 1;
3954 } 3956 }
3955#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \ 3957#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
3956 || defined(HAVE_NS) || defined (USE_GTK) 3958 || defined (HAVE_NS) || defined (USE_GTK)
3957 else if (event->kind == MENU_BAR_ACTIVATE_EVENT) 3959 else if (event->kind == MENU_BAR_ACTIVATE_EVENT)
3958 { 3960 {
3959 kbd_fetch_ptr = event + 1; 3961 kbd_fetch_ptr = event + 1;
@@ -4063,7 +4065,7 @@ kbd_buffer_get_event (KBOARD **kbp,
4063 obj = make_lispy_event (event); 4065 obj = make_lispy_event (event);
4064 4066
4065#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \ 4067#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
4066 || defined(HAVE_NS) || defined (USE_GTK) 4068 || defined (HAVE_NS) || defined (USE_GTK)
4067 /* If this was a menu selection, then set the flag to inhibit 4069 /* If this was a menu selection, then set the flag to inhibit
4068 writing to last_nonmenu_event. Don't do this if the event 4070 writing to last_nonmenu_event. Don't do this if the event
4069 we're returning is (menu-bar), though; that indicates the 4071 we're returning is (menu-bar), though; that indicates the
@@ -4146,37 +4148,61 @@ kbd_buffer_get_event (KBOARD **kbp,
4146 return (obj); 4148 return (obj);
4147} 4149}
4148 4150
4149/* Process any events that are not user-visible, 4151/* Process any non-user-visible events (currently X selection events),
4150 then return, without reading any user-visible events. */ 4152 without reading any user-visible events. */
4151 4153
4152void 4154static void
4153swallow_events (int do_display) 4155process_special_events (void)
4154{ 4156{
4155 int old_timers_run; 4157 struct input_event *event;
4156 4158
4157 while (kbd_fetch_ptr != kbd_store_ptr) 4159 for (event = kbd_fetch_ptr; event != kbd_store_ptr; ++event)
4158 { 4160 {
4159 struct input_event *event; 4161 if (event == kbd_buffer + KBD_BUFFER_SIZE)
4160 4162 {
4161 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE) 4163 event = kbd_buffer;
4162 ? kbd_fetch_ptr 4164 if (event == kbd_store_ptr)
4163 : kbd_buffer); 4165 break;
4164 4166 }
4165 last_event_timestamp = event->timestamp;
4166 4167
4167 /* These two kinds of events get special handling 4168 /* If we find a stored X selection request, handle it now. */
4168 and don't actually appear to the command loop. */
4169 if (event->kind == SELECTION_REQUEST_EVENT 4169 if (event->kind == SELECTION_REQUEST_EVENT
4170 || event->kind == SELECTION_CLEAR_EVENT) 4170 || event->kind == SELECTION_CLEAR_EVENT)
4171 { 4171 {
4172#ifdef HAVE_X11 4172#ifdef HAVE_X11
4173 struct input_event copy;
4174 4173
4175 /* Remove it from the buffer before processing it, 4174 /* Remove the event from the fifo buffer before processing;
4176 since otherwise swallow_events called recursively could see it 4175 otherwise swallow_events called recursively could see it
4177 and process it again. */ 4176 and process it again. To do this, we move the events
4178 copy = *event; 4177 between kbd_fetch_ptr and EVENT one slot to the right,
4179 kbd_fetch_ptr = event + 1; 4178 cyclically. */
4179
4180 struct input_event copy = *event;
4181 struct input_event *beg
4182 = (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
4183 ? kbd_buffer : kbd_fetch_ptr;
4184
4185 if (event > beg)
4186 memmove (beg + 1, beg, (event - beg) * sizeof (struct input_event));
4187 else if (event < beg)
4188 {
4189 if (event > kbd_buffer)
4190 memmove (kbd_buffer + 1, kbd_buffer,
4191 (event - kbd_buffer) * sizeof (struct input_event));
4192 *kbd_buffer = *(kbd_buffer + KBD_BUFFER_SIZE - 1);
4193 if (beg < kbd_buffer + KBD_BUFFER_SIZE - 1)
4194 memmove (beg + 1, beg,
4195 (kbd_buffer + KBD_BUFFER_SIZE - 1 - beg)
4196 * sizeof (struct input_event));
4197 }
4198
4199 if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
4200 kbd_fetch_ptr = kbd_buffer + 1;
4201 else
4202 kbd_fetch_ptr++;
4203
4204 /* X wants last_event_timestamp for selection ownership. */
4205 last_event_timestamp = copy.timestamp;
4180 input_pending = readable_events (0); 4206 input_pending = readable_events (0);
4181 x_handle_selection_event (&copy); 4207 x_handle_selection_event (&copy);
4182#else 4208#else
@@ -4185,9 +4211,18 @@ swallow_events (int do_display)
4185 abort (); 4211 abort ();
4186#endif 4212#endif
4187 } 4213 }
4188 else
4189 break;
4190 } 4214 }
4215}
4216
4217/* Process any events that are not user-visible, run timer events that
4218 are ripe, and return, without reading any user-visible events. */
4219
4220void
4221swallow_events (int do_display)
4222{
4223 int old_timers_run;
4224
4225 process_special_events ();
4191 4226
4192 old_timers_run = timers_run; 4227 old_timers_run = timers_run;
4193 get_input_pending (&input_pending, READABLE_EVENTS_DO_TIMERS_NOW); 4228 get_input_pending (&input_pending, READABLE_EVENTS_DO_TIMERS_NOW);
@@ -4814,7 +4849,7 @@ const char *const lispy_function_keys[] =
4814 "ico-00", /* VK_ICO_00 0xE4 */ 4849 "ico-00", /* VK_ICO_00 0xE4 */
4815 0, /* VK_PROCESSKEY 0xE5 - used by IME */ 4850 0, /* VK_PROCESSKEY 0xE5 - used by IME */
4816 "ico-clear", /* VK_ICO_CLEAR 0xE6 */ 4851 "ico-clear", /* VK_ICO_CLEAR 0xE6 */
4817 0, /* VK_PACKET 0xE7 - used to pass unicode chars */ 4852 0, /* VK_PACKET 0xE7 - used to pass Unicode chars */
4818 0, /* 0xE8 */ 4853 0, /* 0xE8 */
4819 "reset", /* VK_OEM_RESET 0xE9 */ 4854 "reset", /* VK_OEM_RESET 0xE9 */
4820 "jump", /* VK_OEM_JUMP 0xEA */ 4855 "jump", /* VK_OEM_JUMP 0xEA */
@@ -4981,8 +5016,8 @@ static const char *const lispy_function_keys[] =
4981 "break", /* 0xff6b */ 5016 "break", /* 0xff6b */
4982 5017
4983 0, 0, 0, 0, 5018 0, 0, 0, 0,
4984 0, 0, 0, 0, "backtab", 0, 0, 0, /* 0xff70... */ 5019 0, 0, 0, 0, "backtab", 0, 0, 0, /* 0xff70... */
4985 0, 0, 0, 0, 0, 0, 0, "kp-numlock", /* 0xff78... */ 5020 0, 0, 0, 0, 0, 0, 0, "kp-numlock", /* 0xff78... */
4986 "kp-space", /* 0xff80 */ /* IsKeypadKey */ 5021 "kp-space", /* 0xff80 */ /* IsKeypadKey */
4987 0, 0, 0, 0, 0, 0, 0, 0, 5022 0, 0, 0, 0, 0, 0, 0, 0,
4988 "kp-tab", /* 0xff89 */ 5023 "kp-tab", /* 0xff89 */
@@ -5094,14 +5129,14 @@ static Lisp_Object *const scroll_bar_parts[] = {
5094static Lisp_Object button_down_location; 5129static Lisp_Object button_down_location;
5095 5130
5096/* Information about the most recent up-going button event: Which 5131/* Information about the most recent up-going button event: Which
5097 button, what location, and what time. */ 5132 button, what location, and what time. */
5098 5133
5099static int last_mouse_button; 5134static int last_mouse_button;
5100static int last_mouse_x; 5135static int last_mouse_x;
5101static int last_mouse_y; 5136static int last_mouse_y;
5102static Time button_down_time; 5137static Time button_down_time;
5103 5138
5104/* The number of clicks in this multiple-click. */ 5139/* The number of clicks in this multiple-click. */
5105 5140
5106static int double_click_count; 5141static int double_click_count;
5107 5142
@@ -5124,7 +5159,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
5124 5159
5125 if (WINDOWP (window)) 5160 if (WINDOWP (window))
5126 { 5161 {
5127 /* It's a click in window window at frame coordinates (x,y) */ 5162 /* It's a click in window WINDOW at frame coordinates (X,Y) */
5128 struct window *w = XWINDOW (window); 5163 struct window *w = XWINDOW (window);
5129 Lisp_Object string_info = Qnil; 5164 Lisp_Object string_info = Qnil;
5130 EMACS_INT textpos = -1; 5165 EMACS_INT textpos = -1;
@@ -5345,7 +5380,7 @@ make_lispy_event (struct input_event *event)
5345 5380
5346#ifdef HAVE_NS 5381#ifdef HAVE_NS
5347 /* NS_NONKEY_EVENTs are just like NON_ASCII_KEYSTROKE_EVENTs, 5382 /* NS_NONKEY_EVENTs are just like NON_ASCII_KEYSTROKE_EVENTs,
5348 except that they are non-key events (last-nonmenu-event is nil). */ 5383 except that they are non-key events (last-nonmenu-event is nil). */
5349 case NS_NONKEY_EVENT: 5384 case NS_NONKEY_EVENT:
5350#endif 5385#endif
5351 5386
@@ -5394,7 +5429,7 @@ make_lispy_event (struct input_event *event)
5394 || !lispy_function_keys[event->code - FUNCTION_KEY_OFFSET]) 5429 || !lispy_function_keys[event->code - FUNCTION_KEY_OFFSET])
5395 { 5430 {
5396 /* We need to use an alist rather than a vector as the cache 5431 /* We need to use an alist rather than a vector as the cache
5397 since we can't make a vector long enuf. */ 5432 since we can't make a vector long enough. */
5398 if (NILP (KVAR (current_kboard, system_key_syms))) 5433 if (NILP (KVAR (current_kboard, system_key_syms)))
5399 KVAR (current_kboard, system_key_syms) = Fcons (Qnil, Qnil); 5434 KVAR (current_kboard, system_key_syms) = Fcons (Qnil, Qnil);
5400 return modify_event_symbol (event->code, 5435 return modify_event_symbol (event->code,
@@ -5831,7 +5866,7 @@ make_lispy_event (struct input_event *event)
5831 Fcons (make_number (event->timestamp), 5866 Fcons (make_number (event->timestamp),
5832 Fcons (part, Qnil))))); 5867 Fcons (part, Qnil)))));
5833 5868
5834 /* Always treat scroll bar events as clicks. */ 5869 /* Always treat scroll bar events as clicks. */
5835 event->modifiers |= click_modifier; 5870 event->modifiers |= click_modifier;
5836 event->modifiers &= ~up_modifier; 5871 event->modifiers &= ~up_modifier;
5837 5872
@@ -5879,7 +5914,7 @@ make_lispy_event (struct input_event *event)
5879#endif /* HAVE_MOUSE */ 5914#endif /* HAVE_MOUSE */
5880 5915
5881#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \ 5916#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
5882 || defined(HAVE_NS) || defined (USE_GTK) 5917 || defined (HAVE_NS) || defined (USE_GTK)
5883 case MENU_BAR_EVENT: 5918 case MENU_BAR_EVENT:
5884 if (EQ (event->arg, event->frame_or_window)) 5919 if (EQ (event->arg, event->frame_or_window))
5885 /* This is the prefix key. We translate this to 5920 /* This is the prefix key. We translate this to
@@ -5994,7 +6029,7 @@ make_lispy_event (struct input_event *event)
5994 } 6029 }
5995} 6030}
5996 6031
5997#if defined(HAVE_MOUSE) || defined(HAVE_GPM) 6032#if defined (HAVE_MOUSE) || defined (HAVE_GPM)
5998 6033
5999static Lisp_Object 6034static Lisp_Object
6000make_lispy_movement (FRAME_PTR frame, Lisp_Object bar_window, enum scroll_bar_part part, 6035make_lispy_movement (FRAME_PTR frame, Lisp_Object bar_window, enum scroll_bar_part part,
@@ -6462,11 +6497,15 @@ modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object s
6462 value = Fcdr_safe (Fassq (symbol_int, name_alist_or_stem)); 6497 value = Fcdr_safe (Fassq (symbol_int, name_alist_or_stem));
6463 else if (STRINGP (name_alist_or_stem)) 6498 else if (STRINGP (name_alist_or_stem))
6464 { 6499 {
6465 int len = SBYTES (name_alist_or_stem); 6500 char *buf;
6466 char *buf = (char *) alloca (len + 50); 6501 ptrdiff_t len = (SBYTES (name_alist_or_stem)
6467 sprintf (buf, "%s-%"pI"d", SDATA (name_alist_or_stem), 6502 + sizeof "-" + INT_STRLEN_BOUND (EMACS_INT));
6468 XINT (symbol_int) + 1); 6503 USE_SAFE_ALLOCA;
6504 SAFE_ALLOCA (buf, char *, len);
6505 esprintf (buf, "%s-%"pI"d", SDATA (name_alist_or_stem),
6506 XINT (symbol_int) + 1);
6469 value = intern (buf); 6507 value = intern (buf);
6508 SAFE_FREE ();
6470 } 6509 }
6471 else if (name_table != 0 && name_table[symbol_num]) 6510 else if (name_table != 0 && name_table[symbol_num])
6472 value = intern (name_table[symbol_num]); 6511 value = intern (name_table[symbol_num]);
@@ -6482,7 +6521,7 @@ modify_event_symbol (EMACS_INT symbol_num, unsigned int modifiers, Lisp_Object s
6482 6521
6483 if (NILP (value)) 6522 if (NILP (value))
6484 { 6523 {
6485 char buf[20]; 6524 char buf[sizeof "key-" + INT_STRLEN_BOUND (EMACS_INT)];
6486 sprintf (buf, "key-%"pI"d", symbol_num); 6525 sprintf (buf, "key-%"pI"d", symbol_num);
6487 value = intern (buf); 6526 value = intern (buf);
6488 } 6527 }
@@ -6691,7 +6730,7 @@ lucid_event_type_list_p (Lisp_Object object)
6691 If READABLE_EVENTS_FILTER_EVENTS is set in FLAGS, ignore internal 6730 If READABLE_EVENTS_FILTER_EVENTS is set in FLAGS, ignore internal
6692 events (FOCUS_IN_EVENT). 6731 events (FOCUS_IN_EVENT).
6693 If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse 6732 If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse
6694 movements and toolkit scroll bar thumb drags. */ 6733 movements and toolkit scroll bar thumb drags. */
6695 6734
6696static void 6735static void
6697get_input_pending (int *addr, int flags) 6736get_input_pending (int *addr, int flags)
@@ -6725,7 +6764,7 @@ gobble_input (int expected)
6725#ifdef POLL_FOR_INPUT 6764#ifdef POLL_FOR_INPUT
6726 /* XXX This condition was (read_socket_hook && !interrupt_input), 6765 /* XXX This condition was (read_socket_hook && !interrupt_input),
6727 but read_socket_hook is not global anymore. Let's pretend that 6766 but read_socket_hook is not global anymore. Let's pretend that
6728 it's always set. */ 6767 it's always set. */
6729 if (!interrupt_input && poll_suppress_count == 0) 6768 if (!interrupt_input && poll_suppress_count == 0)
6730 { 6769 {
6731 SIGMASKTYPE mask; 6770 SIGMASKTYPE mask;
@@ -6800,7 +6839,7 @@ read_avail_input (int expected)
6800 if (store_user_signal_events ()) 6839 if (store_user_signal_events ())
6801 expected = 0; 6840 expected = 0;
6802 6841
6803 /* Loop through the available terminals, and call their input hooks. */ 6842 /* Loop through the available terminals, and call their input hooks. */
6804 t = terminal_list; 6843 t = terminal_list;
6805 while (t) 6844 while (t)
6806 { 6845 {
@@ -6821,15 +6860,15 @@ read_avail_input (int expected)
6821 expected = 0; 6860 expected = 0;
6822 } 6861 }
6823 6862
6824 if (nr == -1) /* Not OK to read input now. */ 6863 if (nr == -1) /* Not OK to read input now. */
6825 { 6864 {
6826 err = 1; 6865 err = 1;
6827 } 6866 }
6828 else if (nr == -2) /* Non-transient error. */ 6867 else if (nr == -2) /* Non-transient error. */
6829 { 6868 {
6830 /* The terminal device terminated; it should be closed. */ 6869 /* The terminal device terminated; it should be closed. */
6831 6870
6832 /* Kill Emacs if this was our last terminal. */ 6871 /* Kill Emacs if this was our last terminal. */
6833 if (!terminal_list->next_terminal) 6872 if (!terminal_list->next_terminal)
6834 /* Formerly simply reported no input, but that 6873 /* Formerly simply reported no input, but that
6835 sometimes led to a failure of Emacs to terminate. 6874 sometimes led to a failure of Emacs to terminate.
@@ -6841,7 +6880,7 @@ read_avail_input (int expected)
6841 alone in its group. */ 6880 alone in its group. */
6842 kill (getpid (), SIGHUP); 6881 kill (getpid (), SIGHUP);
6843 6882
6844 /* XXX Is calling delete_terminal safe here? It calls delete_frame. */ 6883 /* XXX Is calling delete_terminal safe here? It calls delete_frame. */
6845 { 6884 {
6846 Lisp_Object tmp; 6885 Lisp_Object tmp;
6847 XSETTERMINAL (tmp, t); 6886 XSETTERMINAL (tmp, t);
@@ -6931,7 +6970,7 @@ tty_read_avail_input (struct terminal *terminal,
6931 return 0; 6970 return 0;
6932#endif /* subprocesses */ 6971#endif /* subprocesses */
6933 6972
6934 if (!terminal->name) /* Don't read from a dead terminal. */ 6973 if (!terminal->name) /* Don't read from a dead terminal. */
6935 return 0; 6974 return 0;
6936 6975
6937 if (terminal->type != output_termcap 6976 if (terminal->type != output_termcap
@@ -6939,15 +6978,15 @@ tty_read_avail_input (struct terminal *terminal,
6939 abort (); 6978 abort ();
6940 6979
6941 /* XXX I think the following code should be moved to separate hook 6980 /* XXX I think the following code should be moved to separate hook
6942 functions in system-dependent files. */ 6981 functions in system-dependent files. */
6943#ifdef WINDOWSNT 6982#ifdef WINDOWSNT
6944 return 0; 6983 return 0;
6945#else /* not WINDOWSNT */ 6984#else /* not WINDOWSNT */
6946 if (! tty->term_initted) /* In case we get called during bootstrap. */ 6985 if (! tty->term_initted) /* In case we get called during bootstrap. */
6947 return 0; 6986 return 0;
6948 6987
6949 if (! tty->input) 6988 if (! tty->input)
6950 return 0; /* The terminal is suspended. */ 6989 return 0; /* The terminal is suspended. */
6951 6990
6952#ifdef MSDOS 6991#ifdef MSDOS
6953 n_to_read = dos_keysns (); 6992 n_to_read = dos_keysns ();
@@ -6973,7 +7012,7 @@ tty_read_avail_input (struct terminal *terminal,
6973 Gpm_GetEvent closes gpm_fd and clears it to -1, which is why 7012 Gpm_GetEvent closes gpm_fd and clears it to -1, which is why
6974 we save it in `fd' so close_gpm can remove it from the 7013 we save it in `fd' so close_gpm can remove it from the
6975 select masks. 7014 select masks.
6976 gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal. */ 7015 gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal. */
6977 while (gpm = Gpm_GetEvent (&event), gpm == 1) { 7016 while (gpm = Gpm_GetEvent (&event), gpm == 1) {
6978 nread += handle_one_term_event (tty, &event, &gpm_hold_quit); 7017 nread += handle_one_term_event (tty, &event, &gpm_hold_quit);
6979 } 7018 }
@@ -6993,7 +7032,7 @@ tty_read_avail_input (struct terminal *terminal,
6993 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) 7032 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
6994 { 7033 {
6995 if (! noninteractive) 7034 if (! noninteractive)
6996 return -2; /* Close this terminal. */ 7035 return -2; /* Close this terminal. */
6997 else 7036 else
6998 n_to_read = 0; 7037 n_to_read = 0;
6999 } 7038 }
@@ -7002,7 +7041,7 @@ tty_read_avail_input (struct terminal *terminal,
7002 if (n_to_read > sizeof cbuf) 7041 if (n_to_read > sizeof cbuf)
7003 n_to_read = sizeof cbuf; 7042 n_to_read = sizeof cbuf;
7004#else /* no FIONREAD */ 7043#else /* no FIONREAD */
7005#if defined (USG) || defined(CYGWIN) 7044#if defined (USG) || defined (CYGWIN)
7006 /* Read some input if available, but don't wait. */ 7045 /* Read some input if available, but don't wait. */
7007 n_to_read = sizeof cbuf; 7046 n_to_read = sizeof cbuf;
7008 fcntl (fileno (tty->input), F_SETFL, O_NDELAY); 7047 fcntl (fileno (tty->input), F_SETFL, O_NDELAY);
@@ -7026,16 +7065,16 @@ tty_read_avail_input (struct terminal *terminal,
7026 process group won't get SIGHUP's at logout time. BSDI adheres to 7065 process group won't get SIGHUP's at logout time. BSDI adheres to
7027 this part standard and returns -1 from read (0) with errno==EIO 7066 this part standard and returns -1 from read (0) with errno==EIO
7028 when the control tty is taken away. 7067 when the control tty is taken away.
7029 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ 7068 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */
7030 if (nread == -1 && errno == EIO) 7069 if (nread == -1 && errno == EIO)
7031 return -2; /* Close this terminal. */ 7070 return -2; /* Close this terminal. */
7032#if defined (AIX) && defined (_BSD) 7071#if defined (AIX) && defined (_BSD)
7033 /* The kernel sometimes fails to deliver SIGHUP for ptys. 7072 /* The kernel sometimes fails to deliver SIGHUP for ptys.
7034 This looks incorrect, but it isn't, because _BSD causes 7073 This looks incorrect, but it isn't, because _BSD causes
7035 O_NDELAY to be defined in fcntl.h as O_NONBLOCK, 7074 O_NDELAY to be defined in fcntl.h as O_NONBLOCK,
7036 and that causes a value other than 0 when there is no input. */ 7075 and that causes a value other than 0 when there is no input. */
7037 if (nread == 0) 7076 if (nread == 0)
7038 return -2; /* Close this terminal. */ 7077 return -2; /* Close this terminal. */
7039#endif 7078#endif
7040 } 7079 }
7041 while ( 7080 while (
@@ -7113,7 +7152,7 @@ tty_read_avail_input (struct terminal *terminal,
7113 buf.code = cbuf[i]; 7152 buf.code = cbuf[i];
7114 /* Set the frame corresponding to the active tty. Note that the 7153 /* Set the frame corresponding to the active tty. Note that the
7115 value of selected_frame is not reliable here, redisplay tends 7154 value of selected_frame is not reliable here, redisplay tends
7116 to temporarily change it. */ 7155 to temporarily change it. */
7117 buf.frame_or_window = tty->top_frame; 7156 buf.frame_or_window = tty->top_frame;
7118 buf.arg = Qnil; 7157 buf.arg = Qnil;
7119 7158
@@ -7136,7 +7175,7 @@ handle_async_input (void)
7136 pending_signals = pending_atimers; 7175 pending_signals = pending_atimers;
7137#endif 7176#endif
7138/* Tell ns_read_socket() it is being called asynchronously so it can avoid 7177/* Tell ns_read_socket() it is being called asynchronously so it can avoid
7139 doing anything dangerous. */ 7178 doing anything dangerous. */
7140#ifdef HAVE_NS 7179#ifdef HAVE_NS
7141 ++handling_signal; 7180 ++handling_signal;
7142#endif 7181#endif
@@ -7194,7 +7233,7 @@ input_available_signal (int signo)
7194 This function exists so that the UNBLOCK_INPUT macro in 7233 This function exists so that the UNBLOCK_INPUT macro in
7195 blockinput.h can have some way to take care of input we put off 7234 blockinput.h can have some way to take care of input we put off
7196 dealing with, without assuming that every file which uses 7235 dealing with, without assuming that every file which uses
7197 UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */ 7236 UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */
7198void 7237void
7199reinvoke_input_signal (void) 7238reinvoke_input_signal (void)
7200{ 7239{
@@ -7221,7 +7260,7 @@ struct user_signal_info
7221 struct user_signal_info *next; 7260 struct user_signal_info *next;
7222}; 7261};
7223 7262
7224/* List of user signals. */ 7263/* List of user signals. */
7225static struct user_signal_info *user_signals = NULL; 7264static struct user_signal_info *user_signals = NULL;
7226 7265
7227void 7266void
@@ -7405,7 +7444,7 @@ menu_bar_items (Lisp_Object old)
7405{ 7444{
7406 /* The number of keymaps we're scanning right now, and the number of 7445 /* The number of keymaps we're scanning right now, and the number of
7407 keymaps we have allocated space for. */ 7446 keymaps we have allocated space for. */
7408 int nmaps; 7447 ptrdiff_t nmaps;
7409 7448
7410 /* maps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1] 7449 /* maps[0..nmaps-1] are the prefix definitions of KEYBUF[0..t-1]
7411 in the current keymaps, or nil where it is not a prefix. */ 7450 in the current keymaps, or nil where it is not a prefix. */
@@ -7413,7 +7452,7 @@ menu_bar_items (Lisp_Object old)
7413 7452
7414 Lisp_Object def, tail; 7453 Lisp_Object def, tail;
7415 7454
7416 int mapno; 7455 ptrdiff_t mapno;
7417 Lisp_Object oquit; 7456 Lisp_Object oquit;
7418 7457
7419 /* In order to build the menus, we need to call the keymap 7458 /* In order to build the menus, we need to call the keymap
@@ -7458,7 +7497,7 @@ menu_bar_items (Lisp_Object old)
7458 recognized when the menu-bar (or mode-line) is updated, 7497 recognized when the menu-bar (or mode-line) is updated,
7459 which does not normally happen after every command. */ 7498 which does not normally happen after every command. */
7460 Lisp_Object tem; 7499 Lisp_Object tem;
7461 int nminor; 7500 ptrdiff_t nminor;
7462 nminor = current_minor_maps (NULL, &tmaps); 7501 nminor = current_minor_maps (NULL, &tmaps);
7463 maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0])); 7502 maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0]));
7464 nmaps = 0; 7503 nmaps = 0;
@@ -7758,7 +7797,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
7758 { 7797 {
7759 tem = XCAR (item); 7798 tem = XCAR (item);
7760 if (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem)) 7799 if (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem))
7761 /* Be GC protected. Set keyhint to item instead of tem. */ 7800 /* Be GC protected. Set keyhint to item instead of tem. */
7762 keyhint = item; 7801 keyhint = item;
7763 } 7802 }
7764 else if (EQ (tem, QCkeys)) 7803 else if (EQ (tem, QCkeys))
@@ -7841,7 +7880,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
7841 if (inmenubar > 0) 7880 if (inmenubar > 0)
7842 return 1; 7881 return 1;
7843 7882
7844 { /* This is a command. See if there is an equivalent key binding. */ 7883 { /* This is a command. See if there is an equivalent key binding. */
7845 Lisp_Object keyeq = AREF (item_properties, ITEM_PROPERTY_KEYEQ); 7884 Lisp_Object keyeq = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
7846 7885
7847 /* The previous code preferred :key-sequence to :keys, so we 7886 /* The previous code preferred :key-sequence to :keys, so we
@@ -7962,7 +8001,7 @@ Lisp_Object
7962tool_bar_items (Lisp_Object reuse, int *nitems) 8001tool_bar_items (Lisp_Object reuse, int *nitems)
7963{ 8002{
7964 Lisp_Object *maps; 8003 Lisp_Object *maps;
7965 int nmaps, i; 8004 ptrdiff_t nmaps, i;
7966 Lisp_Object oquit; 8005 Lisp_Object oquit;
7967 Lisp_Object *tmaps; 8006 Lisp_Object *tmaps;
7968 8007
@@ -8002,7 +8041,7 @@ tool_bar_items (Lisp_Object reuse, int *nitems)
8002 recognized when the tool-bar (or mode-line) is updated, 8041 recognized when the tool-bar (or mode-line) is updated,
8003 which does not normally happen after every command. */ 8042 which does not normally happen after every command. */
8004 Lisp_Object tem; 8043 Lisp_Object tem;
8005 int nminor; 8044 ptrdiff_t nminor;
8006 nminor = current_minor_maps (NULL, &tmaps); 8045 nminor = current_minor_maps (NULL, &tmaps);
8007 maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0])); 8046 maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0]));
8008 nmaps = 0; 8047 nmaps = 0;
@@ -8130,7 +8169,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
8130 Lisp_Object caption; 8169 Lisp_Object caption;
8131 int i, have_label = 0; 8170 int i, have_label = 0;
8132 8171
8133 /* Defininition looks like `(menu-item CAPTION BINDING PROPS...)'. 8172 /* Definition looks like `(menu-item CAPTION BINDING PROPS...)'.
8134 Rule out items that aren't lists, don't start with 8173 Rule out items that aren't lists, don't start with
8135 `menu-item' or whose rest following `tool-bar-item' is not a 8174 `menu-item' or whose rest following `tool-bar-item' is not a
8136 list. */ 8175 list. */
@@ -8274,10 +8313,11 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
8274 Lisp_Object tcapt = PROP (TOOL_BAR_ITEM_CAPTION); 8313 Lisp_Object tcapt = PROP (TOOL_BAR_ITEM_CAPTION);
8275 const char *label = SYMBOLP (tkey) ? SSDATA (SYMBOL_NAME (tkey)) : ""; 8314 const char *label = SYMBOLP (tkey) ? SSDATA (SYMBOL_NAME (tkey)) : "";
8276 const char *capt = STRINGP (tcapt) ? SSDATA (tcapt) : ""; 8315 const char *capt = STRINGP (tcapt) ? SSDATA (tcapt) : "";
8277 EMACS_INT max_lbl = 2 * tool_bar_max_label_size; 8316 ptrdiff_t max_lbl =
8317 2 * max (0, min (tool_bar_max_label_size, STRING_BYTES_BOUND / 2));
8278 char *buf = (char *) xmalloc (max_lbl + 1); 8318 char *buf = (char *) xmalloc (max_lbl + 1);
8279 Lisp_Object new_lbl; 8319 Lisp_Object new_lbl;
8280 size_t caption_len = strlen (capt); 8320 ptrdiff_t caption_len = strlen (capt);
8281 8321
8282 if (caption_len <= max_lbl && capt[0] != '\0') 8322 if (caption_len <= max_lbl && capt[0] != '\0')
8283 { 8323 {
@@ -8290,7 +8330,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
8290 8330
8291 if (strlen (label) <= max_lbl && label[0] != '\0') 8331 if (strlen (label) <= max_lbl && label[0] != '\0')
8292 { 8332 {
8293 int j; 8333 ptrdiff_t j;
8294 if (label != buf) 8334 if (label != buf)
8295 strcpy (buf, label); 8335 strcpy (buf, label);
8296 8336
@@ -8396,13 +8436,13 @@ append_tool_bar_item (void)
8396 These are done in different ways, depending on how the input will be read. 8436 These are done in different ways, depending on how the input will be read.
8397 Menus using X are done after auto-saving in read-char, getting the input 8437 Menus using X are done after auto-saving in read-char, getting the input
8398 event from Fx_popup_menu; menus using the minibuf use read_char recursively 8438 event from Fx_popup_menu; menus using the minibuf use read_char recursively
8399 and do auto-saving in the inner call of read_char. */ 8439 and do auto-saving in the inner call of read_char. */
8400 8440
8401static Lisp_Object 8441static Lisp_Object
8402read_char_x_menu_prompt (int nmaps, Lisp_Object *maps, Lisp_Object prev_event, 8442read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps,
8403 int *used_mouse_menu) 8443 Lisp_Object prev_event, int *used_mouse_menu)
8404{ 8444{
8405 int mapno; 8445 ptrdiff_t mapno;
8406 8446
8407 if (used_mouse_menu) 8447 if (used_mouse_menu)
8408 *used_mouse_menu = 0; 8448 *used_mouse_menu = 0;
@@ -8430,7 +8470,7 @@ read_char_x_menu_prompt (int nmaps, Lisp_Object *maps, Lisp_Object prev_event,
8430 Lisp_Object *realmaps 8470 Lisp_Object *realmaps
8431 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object)); 8471 = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object));
8432 Lisp_Object value; 8472 Lisp_Object value;
8433 int nmaps1 = 0; 8473 ptrdiff_t nmaps1 = 0;
8434 8474
8435 /* Use the maps that are not nil. */ 8475 /* Use the maps that are not nil. */
8436 for (mapno = 0; mapno < nmaps; mapno++) 8476 for (mapno = 0; mapno < nmaps; mapno++)
@@ -8481,17 +8521,18 @@ read_char_x_menu_prompt (int nmaps, Lisp_Object *maps, Lisp_Object prev_event,
8481 We make this bigger when necessary, and never free it. */ 8521 We make this bigger when necessary, and never free it. */
8482static char *read_char_minibuf_menu_text; 8522static char *read_char_minibuf_menu_text;
8483/* Size of that buffer. */ 8523/* Size of that buffer. */
8484static int read_char_minibuf_menu_width; 8524static ptrdiff_t read_char_minibuf_menu_width;
8485 8525
8486static Lisp_Object 8526static Lisp_Object
8487read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps) 8527read_char_minibuf_menu_prompt (int commandflag,
8528 ptrdiff_t nmaps, Lisp_Object *maps)
8488{ 8529{
8489 int mapno; 8530 ptrdiff_t mapno;
8490 register Lisp_Object name; 8531 register Lisp_Object name;
8491 int nlength; 8532 ptrdiff_t nlength;
8492 /* FIXME: Use the minibuffer's frame width. */ 8533 /* FIXME: Use the minibuffer's frame width. */
8493 int width = FRAME_COLS (SELECTED_FRAME ()) - 4; 8534 ptrdiff_t width = FRAME_COLS (SELECTED_FRAME ()) - 4;
8494 int idx = -1; 8535 ptrdiff_t idx = -1;
8495 int nobindings = 1; 8536 int nobindings = 1;
8496 Lisp_Object rest, vector; 8537 Lisp_Object rest, vector;
8497 char *menu; 8538 char *menu;
@@ -8516,16 +8557,13 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
8516 8557
8517 /* Make sure we have a big enough buffer for the menu text. */ 8558 /* Make sure we have a big enough buffer for the menu text. */
8518 width = max (width, SBYTES (name)); 8559 width = max (width, SBYTES (name));
8519 if (read_char_minibuf_menu_text == 0) 8560 if (STRING_BYTES_BOUND - 4 < width)
8561 memory_full (SIZE_MAX);
8562 if (width + 4 > read_char_minibuf_menu_width)
8520 { 8563 {
8521 read_char_minibuf_menu_width = width + 4;
8522 read_char_minibuf_menu_text = (char *) xmalloc (width + 4);
8523 }
8524 else if (width + 4 > read_char_minibuf_menu_width)
8525 {
8526 read_char_minibuf_menu_width = width + 4;
8527 read_char_minibuf_menu_text 8564 read_char_minibuf_menu_text
8528 = (char *) xrealloc (read_char_minibuf_menu_text, width + 4); 8565 = (char *) xrealloc (read_char_minibuf_menu_text, width + 4);
8566 read_char_minibuf_menu_width = width + 4;
8529 } 8567 }
8530 menu = read_char_minibuf_menu_text; 8568 menu = read_char_minibuf_menu_text;
8531 8569
@@ -8544,7 +8582,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
8544 while (1) 8582 while (1)
8545 { 8583 {
8546 int notfirst = 0; 8584 int notfirst = 0;
8547 int i = nlength; 8585 ptrdiff_t i = nlength;
8548 Lisp_Object obj; 8586 Lisp_Object obj;
8549 Lisp_Object orig_defn_macro; 8587 Lisp_Object orig_defn_macro;
8550 8588
@@ -8618,14 +8656,14 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
8618 tem 8656 tem
8619 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ]; 8657 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ];
8620 if (!NILP (tem)) 8658 if (!NILP (tem))
8621 /* Insert equivalent keybinding. */ 8659 /* Insert equivalent keybinding. */
8622 s = concat2 (s, tem); 8660 s = concat2 (s, tem);
8623#endif 8661#endif
8624 tem 8662 tem
8625 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE]; 8663 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE];
8626 if (EQ (tem, QCradio) || EQ (tem, QCtoggle)) 8664 if (EQ (tem, QCradio) || EQ (tem, QCtoggle))
8627 { 8665 {
8628 /* Insert button prefix. */ 8666 /* Insert button prefix. */
8629 Lisp_Object selected 8667 Lisp_Object selected
8630 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED]; 8668 = XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED];
8631 if (EQ (tem, QCradio)) 8669 if (EQ (tem, QCradio))
@@ -8643,7 +8681,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
8643 < width 8681 < width
8644 || !notfirst) 8682 || !notfirst)
8645 { 8683 {
8646 int thiswidth; 8684 ptrdiff_t thiswidth;
8647 8685
8648 /* Punctuate between strings. */ 8686 /* Punctuate between strings. */
8649 if (notfirst) 8687 if (notfirst)
@@ -8659,9 +8697,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
8659 if (! char_matches) 8697 if (! char_matches)
8660 { 8698 {
8661 /* Add as much of string as fits. */ 8699 /* Add as much of string as fits. */
8662 thiswidth = SCHARS (desc); 8700 thiswidth = min (SCHARS (desc), width - i);
8663 if (thiswidth + i > width)
8664 thiswidth = width - i;
8665 memcpy (menu + i, SDATA (desc), thiswidth); 8701 memcpy (menu + i, SDATA (desc), thiswidth);
8666 i += thiswidth; 8702 i += thiswidth;
8667 strcpy (menu + i, " = "); 8703 strcpy (menu + i, " = ");
@@ -8669,9 +8705,7 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
8669 } 8705 }
8670 8706
8671 /* Add as much of string as fits. */ 8707 /* Add as much of string as fits. */
8672 thiswidth = SCHARS (s); 8708 thiswidth = min (SCHARS (s), width - i);
8673 if (thiswidth + i > width)
8674 thiswidth = width - i;
8675 memcpy (menu + i, SDATA (s), thiswidth); 8709 memcpy (menu + i, SDATA (s), thiswidth);
8676 i += thiswidth; 8710 i += thiswidth;
8677 menu[i] = 0; 8711 menu[i] = 0;
@@ -8746,10 +8780,10 @@ read_char_minibuf_menu_prompt (int commandflag, int nmaps, Lisp_Object *maps)
8746 NEXT may be the same array as CURRENT. */ 8780 NEXT may be the same array as CURRENT. */
8747 8781
8748static int 8782static int
8749follow_key (Lisp_Object key, int nmaps, Lisp_Object *current, Lisp_Object *defs, 8783follow_key (Lisp_Object key, ptrdiff_t nmaps, Lisp_Object *current,
8750 Lisp_Object *next) 8784 Lisp_Object *defs, Lisp_Object *next)
8751{ 8785{
8752 int i, first_binding; 8786 ptrdiff_t i, first_binding;
8753 8787
8754 first_binding = nmaps; 8788 first_binding = nmaps;
8755 for (i = nmaps - 1; i >= 0; i--) 8789 for (i = nmaps - 1; i >= 0; i--)
@@ -8784,7 +8818,7 @@ typedef struct keyremap
8784 /* Positions [START, END) in the key sequence buffer 8818 /* Positions [START, END) in the key sequence buffer
8785 are the key that we have scanned so far. 8819 are the key that we have scanned so far.
8786 Those events are the ones that we will replace 8820 Those events are the ones that we will replace
8787 if PAREHT maps them into a key sequence. */ 8821 if PARENT maps them into a key sequence. */
8788 int start, end; 8822 int start, end;
8789} keyremap; 8823} keyremap;
8790 8824
@@ -8849,7 +8883,7 @@ access_keymap_keyremap (Lisp_Object map, Lisp_Object key, Lisp_Object prompt,
8849 The return value is non-zero if the remapping actually took place. */ 8883 The return value is non-zero if the remapping actually took place. */
8850 8884
8851static int 8885static int
8852keyremap_step (Lisp_Object *keybuf, size_t bufsize, volatile keyremap *fkey, 8886keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey,
8853 int input, int doit, int *diff, Lisp_Object prompt) 8887 int input, int doit, int *diff, Lisp_Object prompt)
8854{ 8888{
8855 Lisp_Object next, key; 8889 Lisp_Object next, key;
@@ -8863,7 +8897,7 @@ keyremap_step (Lisp_Object *keybuf, size_t bufsize, volatile keyremap *fkey,
8863 8897
8864 /* If keybuf[fkey->start..fkey->end] is bound in the 8898 /* If keybuf[fkey->start..fkey->end] is bound in the
8865 map and we're in a position to do the key remapping, replace it with 8899 map and we're in a position to do the key remapping, replace it with
8866 the binding and restart with fkey->start at the end. */ 8900 the binding and restart with fkey->start at the end. */
8867 if ((VECTORP (next) || STRINGP (next)) && doit) 8901 if ((VECTORP (next) || STRINGP (next)) && doit)
8868 { 8902 {
8869 int len = XFASTINT (Flength (next)); 8903 int len = XFASTINT (Flength (next));
@@ -8871,7 +8905,7 @@ keyremap_step (Lisp_Object *keybuf, size_t bufsize, volatile keyremap *fkey,
8871 8905
8872 *diff = len - (fkey->end - fkey->start); 8906 *diff = len - (fkey->end - fkey->start);
8873 8907
8874 if (input + *diff >= bufsize) 8908 if (bufsize - input <= *diff)
8875 error ("Key sequence too long"); 8909 error ("Key sequence too long");
8876 8910
8877 /* Shift the keys that follow fkey->end. */ 8911 /* Shift the keys that follow fkey->end. */
@@ -8904,6 +8938,14 @@ keyremap_step (Lisp_Object *keybuf, size_t bufsize, volatile keyremap *fkey,
8904 return 0; 8938 return 0;
8905} 8939}
8906 8940
8941static int
8942test_undefined (Lisp_Object binding)
8943{
8944 return (EQ (binding, Qundefined)
8945 || (!NILP (binding) && SYMBOLP (binding)
8946 && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined)));
8947}
8948
8907/* Read a sequence of keys that ends with a non prefix character, 8949/* Read a sequence of keys that ends with a non prefix character,
8908 storing it in KEYBUF, a buffer of size BUFSIZE. 8950 storing it in KEYBUF, a buffer of size BUFSIZE.
8909 Prompt with PROMPT. 8951 Prompt with PROMPT.
@@ -8942,7 +8984,7 @@ keyremap_step (Lisp_Object *keybuf, size_t bufsize, volatile keyremap *fkey,
8942 from the selected window's buffer. */ 8984 from the selected window's buffer. */
8943 8985
8944static int 8986static int
8945read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt, 8987read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
8946 int dont_downcase_last, int can_return_switch_frame, 8988 int dont_downcase_last, int can_return_switch_frame,
8947 int fix_current_buffer) 8989 int fix_current_buffer)
8948{ 8990{
@@ -8959,8 +9001,8 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
8959 9001
8960 /* The number of keymaps we're scanning right now, and the number of 9002 /* The number of keymaps we're scanning right now, and the number of
8961 keymaps we have allocated space for. */ 9003 keymaps we have allocated space for. */
8962 int nmaps; 9004 ptrdiff_t nmaps;
8963 int nmaps_allocated = 0; 9005 ptrdiff_t nmaps_allocated = 0;
8964 9006
8965 /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in 9007 /* defs[0..nmaps-1] are the definitions of KEYBUF[0..t-1] in
8966 the current keymaps. */ 9008 the current keymaps. */
@@ -8984,7 +9026,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
8984 /* The index in submaps[] of the first keymap that has a binding for 9026 /* The index in submaps[] of the first keymap that has a binding for
8985 this key sequence. In other words, the lowest i such that 9027 this key sequence. In other words, the lowest i such that
8986 submaps[i] is non-nil. */ 9028 submaps[i] is non-nil. */
8987 int first_binding; 9029 ptrdiff_t first_binding;
8988 /* Index of the first key that has no binding. 9030 /* Index of the first key that has no binding.
8989 It is useless to try fkey.start larger than that. */ 9031 It is useless to try fkey.start larger than that. */
8990 int first_unbound; 9032 int first_unbound;
@@ -9019,7 +9061,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9019 9061
9020 /* Non-zero if we are trying to map a key by changing an upper-case 9062 /* Non-zero if we are trying to map a key by changing an upper-case
9021 letter to lower case, or a shifted function key to an unshifted 9063 letter to lower case, or a shifted function key to an unshifted
9022 one. */ 9064 one. */
9023 int shift_translated = 0; 9065 int shift_translated = 0;
9024 9066
9025 /* If we receive a `switch-frame' or `select-window' event in the middle of 9067 /* If we receive a `switch-frame' or `select-window' event in the middle of
@@ -9027,7 +9069,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9027 While we're reading, we keep the event here. */ 9069 While we're reading, we keep the event here. */
9028 Lisp_Object delayed_switch_frame; 9070 Lisp_Object delayed_switch_frame;
9029 9071
9030 /* See the comment below... */ 9072 /* See the comment below... */
9031#if defined (GOBBLE_FIRST_EVENT) 9073#if defined (GOBBLE_FIRST_EVENT)
9032 Lisp_Object first_event; 9074 Lisp_Object first_event;
9033#endif 9075#endif
@@ -9047,9 +9089,9 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9047 int junk; 9089 int junk;
9048#endif 9090#endif
9049 9091
9050 struct gcpro outer_gcpro1; 9092 struct gcpro gcpro1;
9051 9093
9052 GCPRO1_VAR (fake_prefixed_keys, outer_gcpro); 9094 GCPRO1 (fake_prefixed_keys);
9053 raw_keybuf_count = 0; 9095 raw_keybuf_count = 0;
9054 9096
9055 last_nonmenu_event = Qnil; 9097 last_nonmenu_event = Qnil;
@@ -9145,8 +9187,8 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9145 } 9187 }
9146 else 9188 else
9147 { 9189 {
9148 int nminor; 9190 ptrdiff_t nminor;
9149 int total; 9191 ptrdiff_t total;
9150 Lisp_Object *maps; 9192 Lisp_Object *maps;
9151 9193
9152 nminor = current_minor_maps (0, &maps); 9194 nminor = current_minor_maps (0, &maps);
@@ -9212,7 +9254,8 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9212 echo_local_start and keys_local_start allow us to throw away 9254 echo_local_start and keys_local_start allow us to throw away
9213 just one key. */ 9255 just one key. */
9214 int echo_local_start IF_LINT (= 0); 9256 int echo_local_start IF_LINT (= 0);
9215 int keys_local_start, local_first_binding; 9257 int keys_local_start;
9258 ptrdiff_t local_first_binding;
9216 9259
9217 eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); 9260 eassert (indec.end == t || (indec.end > t && indec.end <= mock_input));
9218 eassert (indec.start <= indec.end); 9261 eassert (indec.start <= indec.end);
@@ -9301,7 +9344,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9301 if (!found) 9344 if (!found)
9302 { 9345 {
9303 /* Don't touch interrupted_kboard when it's been 9346 /* Don't touch interrupted_kboard when it's been
9304 deleted. */ 9347 deleted. */
9305 delayed_switch_frame = Qnil; 9348 delayed_switch_frame = Qnil;
9306 goto replay_entire_sequence; 9349 goto replay_entire_sequence;
9307 } 9350 }
@@ -9344,7 +9387,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9344 if (EQ (key, Qt)) 9387 if (EQ (key, Qt))
9345 { 9388 {
9346 unbind_to (count, Qnil); 9389 unbind_to (count, Qnil);
9347 UNGCPRO_VAR (outer_gcpro); 9390 UNGCPRO;
9348 return -1; 9391 return -1;
9349 } 9392 }
9350 9393
@@ -9409,7 +9452,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9409 { 9452 {
9410 /* If we're at the beginning of a key sequence, and the caller 9453 /* If we're at the beginning of a key sequence, and the caller
9411 says it's okay, go ahead and return this event. If we're 9454 says it's okay, go ahead and return this event. If we're
9412 in the midst of a key sequence, delay it until the end. */ 9455 in the midst of a key sequence, delay it until the end. */
9413 if (t > 0 || !can_return_switch_frame) 9456 if (t > 0 || !can_return_switch_frame)
9414 { 9457 {
9415 delayed_switch_frame = key; 9458 delayed_switch_frame = key;
@@ -9549,7 +9592,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9549 && (NILP (fake_prefixed_keys) 9592 && (NILP (fake_prefixed_keys)
9550 || NILP (Fmemq (key, fake_prefixed_keys)))) 9593 || NILP (Fmemq (key, fake_prefixed_keys))))
9551 { 9594 {
9552 if (t + 1 >= bufsize) 9595 if (bufsize - t <= 1)
9553 error ("Key sequence too long"); 9596 error ("Key sequence too long");
9554 9597
9555 keybuf[t] = posn; 9598 keybuf[t] = posn;
@@ -9630,7 +9673,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9630 insert the dummy prefix event `menu-bar'. */ 9673 insert the dummy prefix event `menu-bar'. */
9631 if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar)) 9674 if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar))
9632 { 9675 {
9633 if (t + 1 >= bufsize) 9676 if (bufsize - t <= 1)
9634 error ("Key sequence too long"); 9677 error ("Key sequence too long");
9635 keybuf[t] = posn; 9678 keybuf[t] = posn;
9636 keybuf[t+1] = key; 9679 keybuf[t+1] = key;
@@ -9706,7 +9749,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9706 Down-clicks are eliminated. 9749 Down-clicks are eliminated.
9707 Double-downs reduce to downs, then are eliminated. 9750 Double-downs reduce to downs, then are eliminated.
9708 Triple-downs reduce to double-downs, then to downs, 9751 Triple-downs reduce to double-downs, then to downs,
9709 then are eliminated. */ 9752 then are eliminated. */
9710 if (modifiers & (down_modifier | drag_modifier 9753 if (modifiers & (down_modifier | drag_modifier
9711 | double_modifier | triple_modifier)) 9754 | double_modifier | triple_modifier))
9712 { 9755 {
@@ -9853,7 +9896,9 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9853 } 9896 }
9854 } 9897 }
9855 9898
9856 if (first_binding < nmaps && NILP (submaps[first_binding]) 9899 if (first_binding < nmaps
9900 && NILP (submaps[first_binding])
9901 && !test_undefined (defs[first_binding])
9857 && indec.start >= t) 9902 && indec.start >= t)
9858 /* There is a binding and it's not a prefix. 9903 /* There is a binding and it's not a prefix.
9859 (and it doesn't have any input-decode-map translation pending). 9904 (and it doesn't have any input-decode-map translation pending).
@@ -9880,7 +9925,9 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9880 /* If there's a binding (i.e. 9925 /* If there's a binding (i.e.
9881 first_binding >= nmaps) we don't want 9926 first_binding >= nmaps) we don't want
9882 to apply this function-key-mapping. */ 9927 to apply this function-key-mapping. */
9883 fkey.end + 1 == t && first_binding >= nmaps, 9928 fkey.end + 1 == t
9929 && (first_binding >= nmaps
9930 || test_undefined (defs[first_binding])),
9884 &diff, prompt); 9931 &diff, prompt);
9885 UNGCPRO; 9932 UNGCPRO;
9886 if (done) 9933 if (done)
@@ -9997,6 +10044,13 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
9997 read_key_sequence_cmd = (first_binding < nmaps 10044 read_key_sequence_cmd = (first_binding < nmaps
9998 ? defs[first_binding] 10045 ? defs[first_binding]
9999 : Qnil); 10046 : Qnil);
10047 read_key_sequence_remapped
10048 /* Remap command through active keymaps.
10049 Do the remapping here, before the unbind_to so it uses the keymaps
10050 of the appropriate buffer. */
10051 = SYMBOLP (read_key_sequence_cmd)
10052 ? Fcommand_remapping (read_key_sequence_cmd, Qnil, Qnil)
10053 : Qnil;
10000 10054
10001 unread_switch_frame = delayed_switch_frame; 10055 unread_switch_frame = delayed_switch_frame;
10002 unbind_to (count, Qnil); 10056 unbind_to (count, Qnil);
@@ -10031,7 +10085,7 @@ read_key_sequence (Lisp_Object *keybuf, size_t bufsize, Lisp_Object prompt,
10031 add_command_key (keybuf[t]); 10085 add_command_key (keybuf[t]);
10032 } 10086 }
10033 10087
10034 UNGCPRO_VAR (outer_gcpro); 10088 UNGCPRO;
10035 return t; 10089 return t;
10036} 10090}
10037 10091
@@ -10119,7 +10173,7 @@ will read just one key sequence. */)
10119 ! NILP (can_return_switch_frame), 0); 10173 ! NILP (can_return_switch_frame), 0);
10120 10174
10121#if 0 /* The following is fine for code reading a key sequence and 10175#if 0 /* The following is fine for code reading a key sequence and
10122 then proceeding with a lenghty computation, but it's not good 10176 then proceeding with a lengthy computation, but it's not good
10123 for code reading keys in a loop, like an input method. */ 10177 for code reading keys in a loop, like an input method. */
10124#ifdef HAVE_WINDOW_SYSTEM 10178#ifdef HAVE_WINDOW_SYSTEM
10125 if (display_hourglass_p) 10179 if (display_hourglass_p)
@@ -10385,19 +10439,21 @@ give to the command you invoke, if it asks for an argument. */)
10385 char *newmessage; 10439 char *newmessage;
10386 int message_p = push_message (); 10440 int message_p = push_message ();
10387 int count = SPECPDL_INDEX (); 10441 int count = SPECPDL_INDEX ();
10442 ptrdiff_t newmessage_len, newmessage_alloc;
10443 USE_SAFE_ALLOCA;
10388 10444
10389 record_unwind_protect (pop_message_unwind, Qnil); 10445 record_unwind_protect (pop_message_unwind, Qnil);
10390 binding = Fkey_description (bindings, Qnil); 10446 binding = Fkey_description (bindings, Qnil);
10391 10447 newmessage_alloc =
10392 newmessage 10448 (sizeof "You can run the command `' with "
10393 = (char *) alloca (SCHARS (SYMBOL_NAME (function)) 10449 + SBYTES (SYMBOL_NAME (function)) + SBYTES (binding));
10394 + SBYTES (binding) 10450 SAFE_ALLOCA (newmessage, char *, newmessage_alloc);
10395 + 100); 10451 newmessage_len =
10396 sprintf (newmessage, "You can run the command `%s' with %s", 10452 esprintf (newmessage, "You can run the command `%s' with %s",
10397 SDATA (SYMBOL_NAME (function)), 10453 SDATA (SYMBOL_NAME (function)),
10398 SDATA (binding)); 10454 SDATA (binding));
10399 message2 (newmessage, 10455 message2 (newmessage,
10400 strlen (newmessage), 10456 newmessage_len,
10401 STRING_MULTIBYTE (binding)); 10457 STRING_MULTIBYTE (binding));
10402 if (NUMBERP (Vsuggest_key_bindings)) 10458 if (NUMBERP (Vsuggest_key_bindings))
10403 waited = sit_for (Vsuggest_key_bindings, 0, 2); 10459 waited = sit_for (Vsuggest_key_bindings, 0, 2);
@@ -10407,6 +10463,7 @@ give to the command you invoke, if it asks for an argument. */)
10407 if (!NILP (waited) && message_p) 10463 if (!NILP (waited) && message_p)
10408 restore_message (); 10464 restore_message ();
10409 10465
10466 SAFE_FREE ();
10410 unbind_to (count, Qnil); 10467 unbind_to (count, Qnil);
10411 } 10468 }
10412 } 10469 }
@@ -10501,6 +10558,9 @@ if there is a doubt, the value is t. */)
10501 || !NILP (Vunread_input_method_events)) 10558 || !NILP (Vunread_input_method_events))
10502 return (Qt); 10559 return (Qt);
10503 10560
10561 /* Process non-user-visible events (Bug#10195). */
10562 process_special_events ();
10563
10504 get_input_pending (&input_pending, 10564 get_input_pending (&input_pending,
10505 READABLE_EVENTS_DO_TIMERS_NOW 10565 READABLE_EVENTS_DO_TIMERS_NOW
10506 | READABLE_EVENTS_FILTER_EVENTS); 10566 | READABLE_EVENTS_FILTER_EVENTS);
@@ -10636,14 +10696,17 @@ DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0,
10636 (void) 10696 (void)
10637{ 10697{
10638 Lisp_Object temp; 10698 Lisp_Object temp;
10639 XSETFASTINT (temp, command_loop_level + minibuf_level); 10699 /* Wrap around reliably on integer overflow. */
10700 EMACS_INT sum = (command_loop_level & INTMASK) + (minibuf_level & INTMASK);
10701 XSETINT (temp, sum);
10640 return temp; 10702 return temp;
10641} 10703}
10642 10704
10643DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1, 10705DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1,
10644 "FOpen dribble file: ", 10706 "FOpen dribble file: ",
10645 doc: /* Start writing all keyboard characters to a dribble file called FILE. 10707 doc: /* Start writing all keyboard characters to a dribble file called FILE.
10646If FILE is nil, close any open dribble file. */) 10708If FILE is nil, close any open dribble file.
10709The file will be closed when Emacs exits. */)
10647 (Lisp_Object file) 10710 (Lisp_Object file)
10648{ 10711{
10649 if (dribble) 10712 if (dribble)
@@ -10798,9 +10861,9 @@ set_waiting_for_input (struct timeval *time_to_clear)
10798 waiting_for_input = 1; 10861 waiting_for_input = 1;
10799 10862
10800 /* If handle_interrupt was called before and buffered a C-g, 10863 /* If handle_interrupt was called before and buffered a C-g,
10801 make it run again now, to avoid timing error. */ 10864 make it run again now, to avoid timing error. */
10802 if (!NILP (Vquit_flag)) 10865 if (!NILP (Vquit_flag))
10803 quit_throw_to_read_char (); 10866 quit_throw_to_read_char (0);
10804} 10867}
10805 10868
10806void 10869void
@@ -10815,11 +10878,11 @@ clear_waiting_for_input (void)
10815 10878
10816 If we have a frame on the controlling tty, we assume that the 10879 If we have a frame on the controlling tty, we assume that the
10817 SIGINT was generated by C-g, so we call handle_interrupt. 10880 SIGINT was generated by C-g, so we call handle_interrupt.
10818 Otherwise, the handler kills Emacs. */ 10881 Otherwise, tell QUIT to kill Emacs. */
10819 10882
10820static void 10883static void
10821interrupt_signal (int signalnum) /* If we don't have an argument, some */ 10884interrupt_signal (int signalnum) /* If we don't have an argument, some */
10822 /* compilers complain in signal calls. */ 10885 /* compilers complain in signal calls. */
10823{ 10886{
10824 /* Must preserve main program's value of errno. */ 10887 /* Must preserve main program's value of errno. */
10825 int old_errno = errno; 10888 int old_errno = errno;
@@ -10827,13 +10890,15 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */
10827 10890
10828 SIGNAL_THREAD_CHECK (signalnum); 10891 SIGNAL_THREAD_CHECK (signalnum);
10829 10892
10830 /* See if we have an active terminal on our controlling tty. */ 10893 /* See if we have an active terminal on our controlling tty. */
10831 terminal = get_named_tty ("/dev/tty"); 10894 terminal = get_named_tty ("/dev/tty");
10832 if (!terminal) 10895 if (!terminal)
10833 { 10896 {
10834 /* If there are no frames there, let's pretend that we are a 10897 /* If there are no frames there, let's pretend that we are a
10835 well-behaving UN*X program and quit. */ 10898 well-behaving UN*X program and quit. We must not call Lisp
10836 Fkill_emacs (Qnil); 10899 in a signal handler, so tell QUIT to exit when it is
10900 safe. */
10901 Vquit_flag = Qkill_emacs;
10837 } 10902 }
10838 else 10903 else
10839 { 10904 {
@@ -10860,7 +10925,7 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */
10860 10925
10861 Otherwise it sets the Lisp variable quit-flag not-nil. This causes 10926 Otherwise it sets the Lisp variable quit-flag not-nil. This causes
10862 eval to throw, when it gets a chance. If quit-flag is already 10927 eval to throw, when it gets a chance. If quit-flag is already
10863 non-nil, it stops the job right away. */ 10928 non-nil, it stops the job right away. */
10864 10929
10865static void 10930static void
10866handle_interrupt (void) 10931handle_interrupt (void)
@@ -10869,7 +10934,7 @@ handle_interrupt (void)
10869 10934
10870 cancel_echoing (); 10935 cancel_echoing ();
10871 10936
10872 /* XXX This code needs to be revised for multi-tty support. */ 10937 /* XXX This code needs to be revised for multi-tty support. */
10873 if (!NILP (Vquit_flag) && get_named_tty ("/dev/tty")) 10938 if (!NILP (Vquit_flag) && get_named_tty ("/dev/tty"))
10874 { 10939 {
10875 /* If SIGINT isn't blocked, don't let us be interrupted by 10940 /* If SIGINT isn't blocked, don't let us be interrupted by
@@ -10979,18 +11044,23 @@ handle_interrupt (void)
10979 wait_reading_process_output() under HAVE_NS because of the call 11044 wait_reading_process_output() under HAVE_NS because of the call
10980 to ns_select there (needed because otherwise events aren't picked up 11045 to ns_select there (needed because otherwise events aren't picked up
10981 outside of polling since we don't get SIGIO like X and we don't have a 11046 outside of polling since we don't get SIGIO like X and we don't have a
10982 separate event loop thread like W32. */ 11047 separate event loop thread like W32. */
10983#ifndef HAVE_NS 11048#ifndef HAVE_NS
10984 if (waiting_for_input && !echoing) 11049 if (waiting_for_input && !echoing)
10985 quit_throw_to_read_char (); 11050 quit_throw_to_read_char (1);
10986#endif 11051#endif
10987} 11052}
10988 11053
10989/* Handle a C-g by making read_char return C-g. */ 11054/* Handle a C-g by making read_char return C-g. */
10990 11055
10991static void 11056static void
10992quit_throw_to_read_char (void) 11057quit_throw_to_read_char (int from_signal)
10993{ 11058{
11059 /* When not called from a signal handler it is safe to call
11060 Lisp. */
11061 if (!from_signal && EQ (Vquit_flag, Qkill_emacs))
11062 Fkill_emacs (Qnil);
11063
10994 sigfree (); 11064 sigfree ();
10995 /* Prevent another signal from doing this before we finish. */ 11065 /* Prevent another signal from doing this before we finish. */
10996 clear_waiting_for_input (); 11066 clear_waiting_for_input ();
@@ -11428,7 +11498,7 @@ init_keyboard (void)
11428 session may have multiple display types, so we always handle 11498 session may have multiple display types, so we always handle
11429 SIGINT. There is special code in interrupt_signal to exit 11499 SIGINT. There is special code in interrupt_signal to exit
11430 Emacs on SIGINT when there are no termcap frames on the 11500 Emacs on SIGINT when there are no termcap frames on the
11431 controlling terminal. */ 11501 controlling terminal. */
11432 signal (SIGINT, interrupt_signal); 11502 signal (SIGINT, interrupt_signal);
11433#ifndef DOS_NT 11503#ifndef DOS_NT
11434 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and 11504 /* For systems with SysV TERMIO, C-g is set up for both SIGINT and
@@ -11655,6 +11725,8 @@ syms_of_keyboard (void)
11655 11725
11656 read_key_sequence_cmd = Qnil; 11726 read_key_sequence_cmd = Qnil;
11657 staticpro (&read_key_sequence_cmd); 11727 staticpro (&read_key_sequence_cmd);
11728 read_key_sequence_remapped = Qnil;
11729 staticpro (&read_key_sequence_remapped);
11658 11730
11659 menu_bar_one_keymap_changed_items = Qnil; 11731 menu_bar_one_keymap_changed_items = Qnil;
11660 staticpro (&menu_bar_one_keymap_changed_items); 11732 staticpro (&menu_bar_one_keymap_changed_items);
@@ -11789,38 +11861,39 @@ result of looking up the original command in the active keymaps. */);
11789 Vthis_original_command = Qnil; 11861 Vthis_original_command = Qnil;
11790 11862
11791 DEFVAR_INT ("auto-save-interval", auto_save_interval, 11863 DEFVAR_INT ("auto-save-interval", auto_save_interval,
11792 doc: /* *Number of input events between auto-saves. 11864 doc: /* Number of input events between auto-saves.
11793Zero means disable autosaving due to number of characters typed. */); 11865Zero means disable autosaving due to number of characters typed. */);
11794 auto_save_interval = 300; 11866 auto_save_interval = 300;
11795 11867
11796 DEFVAR_LISP ("auto-save-timeout", Vauto_save_timeout, 11868 DEFVAR_LISP ("auto-save-timeout", Vauto_save_timeout,
11797 doc: /* *Number of seconds idle time before auto-save. 11869 doc: /* Number of seconds idle time before auto-save.
11798Zero or nil means disable auto-saving due to idleness. 11870Zero or nil means disable auto-saving due to idleness.
11799After auto-saving due to this many seconds of idle time, 11871After auto-saving due to this many seconds of idle time,
11800Emacs also does a garbage collection if that seems to be warranted. */); 11872Emacs also does a garbage collection if that seems to be warranted. */);
11801 XSETFASTINT (Vauto_save_timeout, 30); 11873 XSETFASTINT (Vauto_save_timeout, 30);
11802 11874
11803 DEFVAR_LISP ("echo-keystrokes", Vecho_keystrokes, 11875 DEFVAR_LISP ("echo-keystrokes", Vecho_keystrokes,
11804 doc: /* *Nonzero means echo unfinished commands after this many seconds of pause. 11876 doc: /* Nonzero means echo unfinished commands after this many seconds of pause.
11805The value may be integer or floating point. */); 11877The value may be integer or floating point.
11878If the value is zero, don't echo at all. */);
11806 Vecho_keystrokes = make_number (1); 11879 Vecho_keystrokes = make_number (1);
11807 11880
11808 DEFVAR_INT ("polling-period", polling_period, 11881 DEFVAR_INT ("polling-period", polling_period,
11809 doc: /* *Interval between polling for input during Lisp execution. 11882 doc: /* Interval between polling for input during Lisp execution.
11810The reason for polling is to make C-g work to stop a running program. 11883The reason for polling is to make C-g work to stop a running program.
11811Polling is needed only when using X windows and SIGIO does not work. 11884Polling is needed only when using X windows and SIGIO does not work.
11812Polling is automatically disabled in all other cases. */); 11885Polling is automatically disabled in all other cases. */);
11813 polling_period = 2; 11886 polling_period = 2;
11814 11887
11815 DEFVAR_LISP ("double-click-time", Vdouble_click_time, 11888 DEFVAR_LISP ("double-click-time", Vdouble_click_time,
11816 doc: /* *Maximum time between mouse clicks to make a double-click. 11889 doc: /* Maximum time between mouse clicks to make a double-click.
11817Measured in milliseconds. The value nil means disable double-click 11890Measured in milliseconds. The value nil means disable double-click
11818recognition; t means double-clicks have no time limit and are detected 11891recognition; t means double-clicks have no time limit and are detected
11819by position only. */); 11892by position only. */);
11820 Vdouble_click_time = make_number (500); 11893 Vdouble_click_time = make_number (500);
11821 11894
11822 DEFVAR_INT ("double-click-fuzz", double_click_fuzz, 11895 DEFVAR_INT ("double-click-fuzz", double_click_fuzz,
11823 doc: /* *Maximum mouse movement between clicks to make a double-click. 11896 doc: /* Maximum mouse movement between clicks to make a double-click.
11824On window-system frames, value is the number of pixels the mouse may have 11897On window-system frames, value is the number of pixels the mouse may have
11825moved horizontally or vertically between two clicks to make a double-click. 11898moved horizontally or vertically between two clicks to make a double-click.
11826On non window-system frames, value is interpreted in units of 1/8 characters 11899On non window-system frames, value is interpreted in units of 1/8 characters
@@ -11831,7 +11904,7 @@ to count as a drag. */);
11831 double_click_fuzz = 3; 11904 double_click_fuzz = 3;
11832 11905
11833 DEFVAR_BOOL ("inhibit-local-menu-bar-menus", inhibit_local_menu_bar_menus, 11906 DEFVAR_BOOL ("inhibit-local-menu-bar-menus", inhibit_local_menu_bar_menus,
11834 doc: /* *Non-nil means inhibit local map menu bar menus. */); 11907 doc: /* Non-nil means inhibit local map menu bar menus. */);
11835 inhibit_local_menu_bar_menus = 0; 11908 inhibit_local_menu_bar_menus = 0;
11836 11909
11837 DEFVAR_INT ("num-input-keys", num_input_keys, 11910 DEFVAR_INT ("num-input-keys", num_input_keys,
@@ -12006,7 +12079,7 @@ and the minor mode maps regardless of `overriding-local-map'. */);
12006 Vspecial_event_map = Fcons (intern_c_string ("keymap"), Qnil); 12079 Vspecial_event_map = Fcons (intern_c_string ("keymap"), Qnil);
12007 12080
12008 DEFVAR_LISP ("track-mouse", do_mouse_tracking, 12081 DEFVAR_LISP ("track-mouse", do_mouse_tracking,
12009 doc: /* *Non-nil means generate motion events for mouse motion. */); 12082 doc: /* Non-nil means generate motion events for mouse motion. */);
12010 12083
12011 DEFVAR_KBOARD ("system-key-alist", Vsystem_key_alist, 12084 DEFVAR_KBOARD ("system-key-alist", Vsystem_key_alist,
12012 doc: /* Alist of system-specific X windows key symbols. 12085 doc: /* Alist of system-specific X windows key symbols.
@@ -12070,7 +12143,7 @@ This variable is keyboard-local. */);
12070Function key definitions that apply to all terminal devices should go 12143Function key definitions that apply to all terminal devices should go
12071here. If a mapping is defined in both the current 12144here. If a mapping is defined in both the current
12072`local-function-key-map' binding and this variable, then the local 12145`local-function-key-map' binding and this variable, then the local
12073definition will take precendence. */); 12146definition will take precedence. */);
12074 Vfunction_key_map = Fmake_sparse_keymap (Qnil); 12147 Vfunction_key_map = Fmake_sparse_keymap (Qnil);
12075 12148
12076 DEFVAR_LISP ("key-translation-map", Vkey_translation_map, 12149 DEFVAR_LISP ("key-translation-map", Vkey_translation_map,
@@ -12100,7 +12173,7 @@ immediately after running `post-command-hook'. */);
12100 Vdelayed_warnings_list = Qnil; 12173 Vdelayed_warnings_list = Qnil;
12101 12174
12102 DEFVAR_LISP ("suggest-key-bindings", Vsuggest_key_bindings, 12175 DEFVAR_LISP ("suggest-key-bindings", Vsuggest_key_bindings,
12103 doc: /* *Non-nil means show the equivalent key-binding when M-x command has one. 12176 doc: /* Non-nil means show the equivalent key-binding when M-x command has one.
12104The value can be a length of time to show the message for. 12177The value can be a length of time to show the message for.
12105If the value is non-nil and not a number, we wait 2 seconds. */); 12178If the value is non-nil and not a number, we wait 2 seconds. */);
12106 Vsuggest_key_bindings = Qt; 12179 Vsuggest_key_bindings = Qt;
@@ -12160,7 +12233,7 @@ just after executing the command. */);
12160 12233
12161 DEFVAR_LISP ("global-disable-point-adjustment", 12234 DEFVAR_LISP ("global-disable-point-adjustment",
12162 Vglobal_disable_point_adjustment, 12235 Vglobal_disable_point_adjustment,
12163 doc: /* *If non-nil, always suppress point adjustment. 12236 doc: /* If non-nil, always suppress point adjustment.
12164 12237
12165The default value is nil, in which case, point adjustment are 12238The default value is nil, in which case, point adjustment are
12166suppressed only after special commands that set 12239suppressed only after special commands that set
@@ -12168,7 +12241,7 @@ suppressed only after special commands that set
12168 Vglobal_disable_point_adjustment = Qnil; 12241 Vglobal_disable_point_adjustment = Qnil;
12169 12242
12170 DEFVAR_LISP ("minibuffer-message-timeout", Vminibuffer_message_timeout, 12243 DEFVAR_LISP ("minibuffer-message-timeout", Vminibuffer_message_timeout,
12171 doc: /* *How long to display an echo-area message when the minibuffer is active. 12244 doc: /* How long to display an echo-area message when the minibuffer is active.
12172If the value is not a number, such messages don't time out. */); 12245If the value is not a number, such messages don't time out. */);
12173 Vminibuffer_message_timeout = make_number (2); 12246 Vminibuffer_message_timeout = make_number (2);
12174 12247
@@ -12215,7 +12288,7 @@ text in the region before modifying the buffer. The next
12215 DEFVAR_LISP ("debug-on-event", 12288 DEFVAR_LISP ("debug-on-event",
12216 Vdebug_on_event, 12289 Vdebug_on_event,
12217 doc: /* Enter debugger on this event. When Emacs 12290 doc: /* Enter debugger on this event. When Emacs
12218receives the special event specifed by this variable, it will try to 12291receives the special event specified by this variable, it will try to
12219break into the debugger as soon as possible instead of processing the 12292break into the debugger as soon as possible instead of processing the
12220event normally through `special-event-map'. 12293event normally through `special-event-map'.
12221 12294
@@ -12223,7 +12296,7 @@ Currently, the only supported values for this
12223variable are `sigusr1' and `sigusr2'. */); 12296variable are `sigusr1' and `sigusr2'. */);
12224 Vdebug_on_event = intern_c_string ("sigusr2"); 12297 Vdebug_on_event = intern_c_string ("sigusr2");
12225 12298
12226 /* Create the initial keyboard. */ 12299 /* Create the initial keyboard. */
12227 initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); 12300 initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
12228 init_kboard (initial_kboard); 12301 init_kboard (initial_kboard);
12229 /* Vwindow_system is left at t for now. */ 12302 /* Vwindow_system is left at t for now. */