aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1993-03-07 09:27:28 +0000
committerRichard M. Stallman1993-03-07 09:27:28 +0000
commit86e5706b378b4979f9a5db3709ca9a448c54353a (patch)
treea0565a696bcb554c6f7342924485ef4ac05c78bc /src
parent7bd279cd8e4a94e2706d73fc3286b14a1db65454 (diff)
downloademacs-86e5706b378b4979f9a5db3709ca9a448c54353a.tar.gz
emacs-86e5706b378b4979f9a5db3709ca9a448c54353a.zip
(follow_key): Downcase shift_modifier as well as ASCII.
(command_loop_1): Run pre-command-hook and post-command-hook. Set this_command before running pre-command-hook. (syms_of_keyboard): Set up vars for those hooks. (syms_of_keyboard): Handle gaps in modifier_names. (modifier_names): Reorder to match termhooks.h. (parse_modifiers_uncached): Detect `s-', not `super-'. (apply_modifiers_uncached): Make `s-', not `super-'. (lispy_function_keys): Add codes starting at 0xff00 and running through 0xffff. (read_char): Move metabit when fetching from string macro. (command_loop_1): Clear Vdeactivate_mark before cmd. Clear mark_active if command set Vdeactivate_mark. Run deactivate-mark-hook at that time, or activate-mark-hook. (syms_of_keyboard): Define variable deactivate-mark. (syms_of_keyboard): New lisp var unread-command-char. (Finput_pending_p): Test unread_command_char. (Fdiscard_input, quit_throw_to_read_char, init_keyboard): Set it. (read_char): Fetch from it. (Fthis_command_keys, Fread_key_sequence): Fix calls to make_event_array. (make_lispy_event): Put meta and shift modifiers into an integer. (read_avail_input): Set the modifiers field in the events read. (kbd_buffer_get_event): Pass thru integer event untruncated. (read_char): Likewise. (read_key_sequence, read_char): Only -1 means EOF. (kbd_buffer_store_event): Don't ignore 0200 bit in quit char. (follow_key): Use new meta bit flag.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c200
1 files changed, 159 insertions, 41 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 61c57fe4c7e..a1a0fc536fd 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1,5 +1,5 @@
1/* Keyboard and mouse input; editor command loop. 1/* Keyboard and mouse input; editor command loop.
2 Copyright (C) 1985, 1986, 1987, 1988, 1989, 1992, 1993 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -155,6 +155,9 @@ Lisp_Object last_input_char;
155/* If not Qnil, a list of objects to be read as subsequent command input. */ 155/* If not Qnil, a list of objects to be read as subsequent command input. */
156Lisp_Object unread_command_events; 156Lisp_Object unread_command_events;
157 157
158/* If not -1, an event to be read as subsequent command input. */
159int unread_command_char;
160
158/* If not Qnil, this is a switch-frame event which we decided to put 161/* If not Qnil, this is a switch-frame event which we decided to put
159 off until the end of a key sequence. This should be read as the 162 off until the end of a key sequence. This should be read as the
160 next command input, after any unread_command_events. 163 next command input, after any unread_command_events.
@@ -238,6 +241,13 @@ Lisp_Object Vkeyboard_translate_table;
238/* Keymap mapping ASCII function key sequences onto their preferred forms. */ 241/* Keymap mapping ASCII function key sequences onto their preferred forms. */
239extern Lisp_Object Vfunction_key_map; 242extern Lisp_Object Vfunction_key_map;
240 243
244/* Non-nil means deactivate the mark at end of this command. */
245Lisp_Object Vdeactivate_mark;
246
247/* Hooks to run before and after each command. */
248Lisp_Object Qpre_command_hook, Qpost_command_hook;
249Lisp_Object Vpre_command_hook, Vpost_command_hook;
250
241/* File in which we write all commands we read. */ 251/* File in which we write all commands we read. */
242FILE *dribble; 252FILE *dribble;
243 253
@@ -828,8 +838,11 @@ command_loop_1 ()
828 int i; 838 int i;
829 int no_redisplay; 839 int no_redisplay;
830 int no_direct; 840 int no_direct;
841 int prev_modiff;
842 struct buffer *prev_buffer;
831 843
832 Vprefix_arg = Qnil; 844 Vprefix_arg = Qnil;
845 Vdeactivate_mark = Qnil;
833 waiting_for_input = 0; 846 waiting_for_input = 0;
834 cancel_echoing (); 847 cancel_echoing ();
835 848
@@ -860,6 +873,8 @@ command_loop_1 ()
860 873
861 no_direct = 0; 874 no_direct = 0;
862 875
876 Vdeactivate_mark = Qnil;
877
863 /* If minibuffer on and echo area in use, 878 /* If minibuffer on and echo area in use,
864 wait 2 sec and redraw minibufer. */ 879 wait 2 sec and redraw minibufer. */
865 880
@@ -926,8 +941,15 @@ command_loop_1 ()
926 cases identified below that set no_redisplay to 1. */ 941 cases identified below that set no_redisplay to 1. */
927 no_redisplay = 0; 942 no_redisplay = 0;
928 943
944 prev_buffer = current_buffer;
945 prev_modiff = MODIFF;
946
929 /* Execute the command. */ 947 /* Execute the command. */
930 948
949 this_command = cmd;
950 if (!NILP (Vpre_command_hook))
951 call1 (Vrun_hooks, Qpre_command_hook);
952
931 if (NILP (cmd)) 953 if (NILP (cmd))
932 { 954 {
933 /* nil means key is undefined. */ 955 /* nil means key is undefined. */
@@ -935,10 +957,10 @@ command_loop_1 ()
935 defining_kbd_macro = 0; 957 defining_kbd_macro = 0;
936 update_mode_lines = 1; 958 update_mode_lines = 1;
937 Vprefix_arg = Qnil; 959 Vprefix_arg = Qnil;
960
938 } 961 }
939 else 962 else
940 { 963 {
941 this_command = cmd;
942 if (NILP (Vprefix_arg) && ! no_direct) 964 if (NILP (Vprefix_arg) && ! no_direct)
943 { 965 {
944 /* Recognize some common commands in common situations and 966 /* Recognize some common commands in common situations and
@@ -1042,6 +1064,9 @@ command_loop_1 ()
1042 } 1064 }
1043 directly_done: ; 1065 directly_done: ;
1044 1066
1067 if (!NILP (Vpost_command_hook))
1068 call1 (Vrun_hooks, Qpost_command_hook);
1069
1045 /* If there is a prefix argument, 1070 /* If there is a prefix argument,
1046 1) We don't want last_command to be ``universal-argument'' 1071 1) We don't want last_command to be ``universal-argument''
1047 (that would be dumb), so don't set last_command, 1072 (that would be dumb), so don't set last_command,
@@ -1057,6 +1082,17 @@ command_loop_1 ()
1057 cancel_echoing (); 1082 cancel_echoing ();
1058 this_command_key_count = 0; 1083 this_command_key_count = 0;
1059 } 1084 }
1085
1086 if (!NILP (current_buffer->mark_active))
1087 {
1088 if (!NILP (Vdeactivate_mark) && !NILP (Vtransient_mark_mode))
1089 {
1090 current_buffer->mark_active = Qnil;
1091 call1 (Vrun_hooks, intern ("deactivate-mark-hook"));
1092 }
1093 else if (current_buffer != prev_buffer || MODIFF != prev_modiff)
1094 call1 (Vrun_hooks, intern ("activate-mark-hook"));
1095 }
1060 } 1096 }
1061} 1097}
1062 1098
@@ -1166,6 +1202,17 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1166 goto reread; 1202 goto reread;
1167 } 1203 }
1168 1204
1205 if (unread_command_char != -1)
1206 {
1207 XSET (c, Lisp_Int, unread_command_char);
1208 unread_command_char = -1;
1209
1210 if (this_command_key_count == 0)
1211 goto reread_first;
1212 else
1213 goto reread;
1214 }
1215
1169 if (!NILP (Vexecuting_macro)) 1216 if (!NILP (Vexecuting_macro))
1170 { 1217 {
1171#ifdef MULTI_FRAME 1218#ifdef MULTI_FRAME
@@ -1189,6 +1236,10 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1189 } 1236 }
1190 1237
1191 c = Faref (Vexecuting_macro, make_number (executing_macro_index)); 1238 c = Faref (Vexecuting_macro, make_number (executing_macro_index));
1239 if (XTYPE (Vexecuting_macro) == Lisp_String
1240 && (XINT (c) & 0x80))
1241 XFASTINT (c) = CHAR_META | (XINT (c) & ~0x80);
1242
1192 executing_macro_index++; 1243 executing_macro_index++;
1193 1244
1194 goto from_macro; 1245 goto from_macro;
@@ -1343,12 +1394,9 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1343 if (XTYPE (c) == Lisp_Int) 1394 if (XTYPE (c) == Lisp_Int)
1344 { 1395 {
1345 /* If kbd_buffer_get_event gave us an EOF, return that. */ 1396 /* If kbd_buffer_get_event gave us an EOF, return that. */
1346 if (XINT (c) < 0) 1397 if (XINT (c) == -1)
1347 return c; 1398 return c;
1348 1399
1349 /* Strip the high bits, and maybe the meta bit too. */
1350 XSETINT (c, XINT (c) & (meta_key ? 0377 : 0177));
1351
1352 if (XTYPE (Vkeyboard_translate_table) == Lisp_String 1400 if (XTYPE (Vkeyboard_translate_table) == Lisp_String
1353 && XSTRING (Vkeyboard_translate_table)->size > XFASTINT (c)) 1401 && XSTRING (Vkeyboard_translate_table)->size > XFASTINT (c))
1354 XSETINT (c, XSTRING (Vkeyboard_translate_table)->data[XFASTINT (c)]); 1402 XSETINT (c, XSTRING (Vkeyboard_translate_table)->data[XFASTINT (c)]);
@@ -1537,8 +1585,7 @@ kbd_buffer_store_event (event)
1537 { 1585 {
1538 register int c = XFASTINT (event->code) & 0377; 1586 register int c = XFASTINT (event->code) & 0377;
1539 1587
1540 if (c == quit_char 1588 if (c == quit_char)
1541 || ((c == (0200 | quit_char)) && !meta_key))
1542 { 1589 {
1543 extern SIGTYPE interrupt_signal (); 1590 extern SIGTYPE interrupt_signal ();
1544 1591
@@ -1694,8 +1741,6 @@ kbd_buffer_get_event ()
1694 if (NILP (obj)) 1741 if (NILP (obj))
1695 { 1742 {
1696 obj = make_lispy_event (event); 1743 obj = make_lispy_event (event);
1697 if (XTYPE (obj) == Lisp_Int)
1698 XSET (obj, Lisp_Int, XINT (obj) & (meta_key ? 0377 : 0177));
1699 1744
1700 /* Wipe out this event, to catch bugs. */ 1745 /* Wipe out this event, to catch bugs. */
1701 event->kind = no_event; 1746 event->kind = no_event;
@@ -1766,6 +1811,23 @@ static char *lispy_function_keys[] =
1766 { 1811 {
1767 /* X Keysym value */ 1812 /* X Keysym value */
1768 1813
1814 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff00 */
1815 "backspace",
1816 "tab",
1817 "linefeed",
1818 "clear",
1819 0,
1820 "return",
1821 0, 0,
1822 0, 0, 0, /* 0xff10 */
1823 "pause",
1824 0, 0, 0, 0, 0, 0, 0,
1825 "escape",
1826 0, 0, 0, 0,
1827 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff20...2f */
1828 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff30...3f */
1829 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xff40...4f */
1830
1769 "home", /* 0xff50 */ /* IsCursorKey */ 1831 "home", /* 0xff50 */ /* IsCursorKey */
1770 "left", 1832 "left",
1771 "up", 1833 "up",
@@ -1829,11 +1891,15 @@ static char *lispy_function_keys[] =
1829 0, 0, 1891 0, 0,
1830 "kp-equal", /* 0xffbd */ 1892 "kp-equal", /* 0xffbd */
1831 "f1", /* 0xffbe */ /* IsFunctionKey */ 1893 "f1", /* 0xffbe */ /* IsFunctionKey */
1832 "f2", "f3", "f4", 1894 "f2",
1833 "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", 1895 "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", /* 0xffc0 */
1834 "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", 1896 "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18",
1835 "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", 1897 "f19", "f20", "f21", "f22", "f23", "f24", "f25", "f26", /* 0xffd0 */
1836 "f29", "f30", "f31", "f32", "f33", "f34", "f35" /* 0xffe0 */ 1898 "f27", "f28", "f29", "f30", "f31", "f32", "f33", "f34",
1899 "f35", 0, 0, 0, 0, 0, 0, 0, /* 0xffe0 */
1900 0, 0, 0, 0, 0, 0, 0, 0,
1901 0, 0, 0, 0, 0, 0, 0, 0, /* 0xfff0 */
1902 0, 0, 0, 0, 0, 0, 0, "delete"
1837 }; 1903 };
1838 1904
1839static char *lispy_mouse_names[] = 1905static char *lispy_mouse_names[] =
@@ -1883,8 +1949,21 @@ make_lispy_event (event)
1883 { 1949 {
1884 /* A simple keystroke. */ 1950 /* A simple keystroke. */
1885 case ascii_keystroke: 1951 case ascii_keystroke:
1886 return XFASTINT (event->code); 1952 {
1887 break; 1953 int c = XFASTINT (event->code);
1954 /* Include the bits for control and shift
1955 only if the basic ASCII code can't indicate them. */
1956 if ((event->modifiers & ctrl_modifier)
1957 && c >= 040)
1958 c |= ctrl_modifier;
1959 if (XFASTINT (event->code) < 040
1960 && (event->modifiers & shift_modifier))
1961 c |= shift_modifier;
1962 c |= (event->modifiers
1963 & (meta_modifier | alt_modifier
1964 | hyper_modifier | super_modifier));
1965 return c;
1966 }
1888 1967
1889 /* A function key. The symbol may need to have modifier prefixes 1968 /* A function key. The symbol may need to have modifier prefixes
1890 tacked onto it. */ 1969 tacked onto it. */
@@ -2159,11 +2238,7 @@ parse_modifiers_uncached (symbol, modifier_end)
2159 break; 2238 break;
2160 2239
2161 case 's': 2240 case 's':
2162 if (i + 6 > name->size 2241 SINGLE_LETTER_MOD (super_modifier);
2163 || strncmp (name->data + i, "super-", 6))
2164 goto no_more_modifiers;
2165 modifiers |= super_modifier;
2166 i += 6;
2167 break; 2242 break;
2168 2243
2169 case 'd': 2244 case 'd':
@@ -2217,7 +2292,7 @@ apply_modifiers_uncached (modifiers, base, base_len)
2217 to use Fintern, which expects a genuine Lisp_String, and keeps a 2292 to use Fintern, which expects a genuine Lisp_String, and keeps a
2218 reference to it. */ 2293 reference to it. */
2219 char *new_mods = 2294 char *new_mods =
2220 (char *) alloca (sizeof ("A-C-H-M-S-super-down-drag-")); 2295 (char *) alloca (sizeof ("A-C-H-M-S-s-down-drag-"));
2221 int mod_len; 2296 int mod_len;
2222 2297
2223 { 2298 {
@@ -2233,7 +2308,7 @@ apply_modifiers_uncached (modifiers, base, base_len)
2233 if (modifiers & hyper_modifier) { *p++ = 'H'; *p++ = '-'; } 2308 if (modifiers & hyper_modifier) { *p++ = 'H'; *p++ = '-'; }
2234 if (modifiers & meta_modifier) { *p++ = 'M'; *p++ = '-'; } 2309 if (modifiers & meta_modifier) { *p++ = 'M'; *p++ = '-'; }
2235 if (modifiers & shift_modifier) { *p++ = 'S'; *p++ = '-'; } 2310 if (modifiers & shift_modifier) { *p++ = 'S'; *p++ = '-'; }
2236 if (modifiers & super_modifier) { strcpy (p, "super-"); p += 6; } 2311 if (modifiers & super_modifier) { *p++ = 's'; *p++ = '-'; }
2237 if (modifiers & down_modifier) { strcpy (p, "down-"); p += 5; } 2312 if (modifiers & down_modifier) { strcpy (p, "down-"); p += 5; }
2238 if (modifiers & drag_modifier) { strcpy (p, "drag-"); p += 5; } 2313 if (modifiers & drag_modifier) { strcpy (p, "drag-"); p += 5; }
2239 /* The click modifier is denoted by the absence of other modifiers. */ 2314 /* The click modifier is denoted by the absence of other modifiers. */
@@ -2256,8 +2331,9 @@ apply_modifiers_uncached (modifiers, base, base_len)
2256 2331
2257static char *modifier_names[] = 2332static char *modifier_names[] =
2258{ 2333{
2259 "up", "alt", "control", "hyper", "meta", "shift", "super", "down", "drag", 2334 "up", 0, 0, 0, 0, 0, 0, "down",
2260 "click" 2335 "drag", "click", 0, 0, 0, 0, 0, 0,
2336 0, 0, "alt", "super", "hyper", "shift", "control", "meta"
2261}; 2337};
2262 2338
2263static Lisp_Object modifier_symbols; 2339static Lisp_Object modifier_symbols;
@@ -2608,6 +2684,11 @@ read_avail_input (expected)
2608 for (i = 0; i < nread; i++) 2684 for (i = 0; i < nread; i++)
2609 { 2685 {
2610 buf[i].kind = ascii_keystroke; 2686 buf[i].kind = ascii_keystroke;
2687 buf[i].modifiers = 0;
2688 if (meta_key && (cbuf[i] & 0x80))
2689 buf[i].modifiers = meta_modifier;
2690 cbuf[i] &= ~0x80;
2691
2611 XSET (buf[i].code, Lisp_Int, cbuf[i]); 2692 XSET (buf[i].code, Lisp_Int, cbuf[i]);
2612#ifdef MULTI_FRAME 2693#ifdef MULTI_FRAME
2613 XSET (buf[i].frame_or_window, Lisp_Frame, selected_frame); 2694 XSET (buf[i].frame_or_window, Lisp_Frame, selected_frame);
@@ -2928,8 +3009,7 @@ follow_key (key, nmaps, current, defs, next)
2928 3009
2929 /* If KEY is a meta ASCII character, treat it like meta-prefix-char 3010 /* If KEY is a meta ASCII character, treat it like meta-prefix-char
2930 followed by the corresponding non-meta character. */ 3011 followed by the corresponding non-meta character. */
2931 if (XTYPE (key) == Lisp_Int 3012 if (XTYPE (key) == Lisp_Int && (XINT (key) & CHAR_META))
2932 && XINT (key) >= 0200)
2933 { 3013 {
2934 for (i = 0; i < nmaps; i++) 3014 for (i = 0; i < nmaps; i++)
2935 if (! NILP (current[i])) 3015 if (! NILP (current[i]))
@@ -2946,7 +3026,7 @@ follow_key (key, nmaps, current, defs, next)
2946 next[i] = Qnil; 3026 next[i] = Qnil;
2947 3027
2948 current = next; 3028 current = next;
2949 XSET (key, Lisp_Int, XFASTINT (key) & 0177); 3029 XSET (key, Lisp_Int, XFASTINT (key) & ~CHAR_META);
2950 } 3030 }
2951 3031
2952 first_binding = nmaps; 3032 first_binding = nmaps;
@@ -2967,9 +3047,13 @@ follow_key (key, nmaps, current, defs, next)
2967 lower-case letter, return the bindings for the lower-case letter. */ 3047 lower-case letter, return the bindings for the lower-case letter. */
2968 if (first_binding == nmaps 3048 if (first_binding == nmaps
2969 && XTYPE (key) == Lisp_Int 3049 && XTYPE (key) == Lisp_Int
2970 && UPPERCASEP (XINT (key))) 3050 && (UPPERCASEP (XINT (key) & 0x3ffff)
3051 || (XINT (key) & shift_modifier)))
2971 { 3052 {
2972 XSETINT (key, DOWNCASE (XINT (key))); 3053 if (XINT (key) & shift_modifier)
3054 XSETINT (key, XINT (key) & ~shift_modifier);
3055 else
3056 XSETINT (key, DOWNCASE (XINT (key)));
2973 3057
2974 first_binding = nmaps; 3058 first_binding = nmaps;
2975 for (i = nmaps - 1; i >= 0; i--) 3059 for (i = nmaps - 1; i >= 0; i--)
@@ -2984,7 +3068,7 @@ follow_key (key, nmaps, current, defs, next)
2984 defs[i] = Qnil; 3068 defs[i] = Qnil;
2985 } 3069 }
2986 } 3070 }
2987 3071
2988 /* Given the set of bindings we've found, produce the next set of maps. */ 3072 /* Given the set of bindings we've found, produce the next set of maps. */
2989 if (first_binding < nmaps) 3073 if (first_binding < nmaps)
2990 for (i = 0; i < nmaps; i++) 3074 for (i = 0; i < nmaps; i++)
@@ -3218,7 +3302,7 @@ read_key_sequence (keybuf, bufsize, prompt)
3218 /* read_char returns -1 at the end of a macro. 3302 /* read_char returns -1 at the end of a macro.
3219 Emacs 18 handles this by returning immediately with a 3303 Emacs 18 handles this by returning immediately with a
3220 zero, so that's what we'll do. */ 3304 zero, so that's what we'll do. */
3221 if (XTYPE (key) == Lisp_Int && XINT (key) < 0) 3305 if (XTYPE (key) == Lisp_Int && XINT (key) == -1)
3222 { 3306 {
3223 t = 0; 3307 t = 0;
3224 goto done; 3308 goto done;
@@ -3529,7 +3613,7 @@ sequences, where they wouldn't conflict with ordinary bindings. See\n\
3529 NILP (prompt) ? 0 : XSTRING (prompt)->data); 3613 NILP (prompt) ? 0 : XSTRING (prompt)->data);
3530 3614
3531 UNGCPRO; 3615 UNGCPRO;
3532 return make_array (i, keybuf); 3616 return make_event_array (i, keybuf);
3533} 3617}
3534 3618
3535DEFUN ("command-execute", Fcommand_execute, Scommand_execute, 1, 2, 0, 3619DEFUN ("command-execute", Fcommand_execute, Scommand_execute, 1, 2, 0,
@@ -3695,7 +3779,7 @@ DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0,
3695Actually, the value is nil only if we can be sure that no input is available.") 3779Actually, the value is nil only if we can be sure that no input is available.")
3696 () 3780 ()
3697{ 3781{
3698 if (!NILP (unread_command_events)) 3782 if (!NILP (unread_command_events) || unread_command_char != -1)
3699 return (Qt); 3783 return (Qt);
3700 3784
3701 return detect_input_pending () ? Qt : Qnil; 3785 return detect_input_pending () ? Qt : Qnil;
@@ -3727,8 +3811,8 @@ DEFUN ("this-command-keys", Fthis_command_keys, Sthis_command_keys, 0, 0, 0,
3727 "Return string of the keystrokes that invoked this command.") 3811 "Return string of the keystrokes that invoked this command.")
3728 () 3812 ()
3729{ 3813{
3730 return make_array (this_command_key_count, 3814 return make_event_array (this_command_key_count,
3731 XVECTOR (this_command_keys)->contents); 3815 XVECTOR (this_command_keys)->contents);
3732} 3816}
3733 3817
3734DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0, 3818DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0,
@@ -3769,6 +3853,7 @@ Also cancel any kbd macro being defined.")
3769 update_mode_lines++; 3853 update_mode_lines++;
3770 3854
3771 unread_command_events = Qnil; 3855 unread_command_events = Qnil;
3856 unread_command_char = -1;
3772 3857
3773 discard_tty_input (); 3858 discard_tty_input ();
3774 3859
@@ -4022,6 +4107,7 @@ quit_throw_to_read_char ()
4022 input_pending = 0; 4107 input_pending = 0;
4023 4108
4024 unread_command_events = Qnil; 4109 unread_command_events = Qnil;
4110 unread_command_char = -1;
4025 4111
4026 _longjmp (getcjmp, 1); 4112 _longjmp (getcjmp, 1);
4027} 4113}
@@ -4076,6 +4162,7 @@ init_keyboard ()
4076 immediate_quit = 0; 4162 immediate_quit = 0;
4077 quit_char = Ctl ('g'); 4163 quit_char = Ctl ('g');
4078 unread_command_events = Qnil; 4164 unread_command_events = Qnil;
4165 unread_command_char = -1;
4079 total_keys = 0; 4166 total_keys = 0;
4080 recent_keys_index = 0; 4167 recent_keys_index = 0;
4081 kbd_fetch_ptr = kbd_buffer; 4168 kbd_fetch_ptr = kbd_buffer;
@@ -4167,6 +4254,12 @@ syms_of_keyboard ()
4167 Qdisabled = intern ("disabled"); 4254 Qdisabled = intern ("disabled");
4168 staticpro (&Qdisabled); 4255 staticpro (&Qdisabled);
4169 4256
4257 Qpre_command_hook = intern ("pre-command-hook");
4258 staticpro (&Qpre_command_hook);
4259
4260 Qpost_command_hook = intern ("post-command-hook");
4261 staticpro (&Qpost_command_hook);
4262
4170 Qfunction_key = intern ("function-key"); 4263 Qfunction_key = intern ("function-key");
4171 staticpro (&Qfunction_key); 4264 staticpro (&Qfunction_key);
4172 Qmouse_click = intern ("mouse-click"); 4265 Qmouse_click = intern ("mouse-click");
@@ -4218,7 +4311,8 @@ syms_of_keyboard ()
4218 4311
4219 modifier_symbols = Fmake_vector (make_number (len), Qnil); 4312 modifier_symbols = Fmake_vector (make_number (len), Qnil);
4220 for (i = 0; i < len; i++) 4313 for (i = 0; i < len; i++)
4221 XVECTOR (modifier_symbols)->contents[i] = intern (modifier_names[i]); 4314 if (modifier_names[i])
4315 XVECTOR (modifier_symbols)->contents[i] = intern (modifier_names[i]);
4222 staticpro (&modifier_symbols); 4316 staticpro (&modifier_symbols);
4223 } 4317 }
4224 4318
@@ -4263,20 +4357,29 @@ syms_of_keyboard ()
4263\(has a non-nil `disabled' property)."); 4357\(has a non-nil `disabled' property).");
4264 4358
4265 DEFVAR_LISP ("last-command-char", &last_command_char, 4359 DEFVAR_LISP ("last-command-char", &last_command_char,
4266 "Last terminal input key that was part of a command."); 4360 "Last input event that was part of a command.");
4361
4362 DEFVAR_LISP ("last-command-event", &last_command_char,
4363 "Last input event that was part of a command.");
4267 4364
4268 DEFVAR_LISP ("last-nonmenu-event", &last_nonmenu_event, 4365 DEFVAR_LISP ("last-nonmenu-event", &last_nonmenu_event,
4269 "Last terminal input key in a command, except for mouse menus.\n\ 4366 "Last input event in a command, except for mouse menu events.\n\
4270Mouse menus give back keys that don't look like mouse events;\n\ 4367Mouse menus give back keys that don't look like mouse events;\n\
4271this variable holds the actual mouse event that led to the menu,\n\ 4368this variable holds the actual mouse event that led to the menu,\n\
4272so that you can determine whether the command was run by mouse or not."); 4369so that you can determine whether the command was run by mouse or not.");
4273 4370
4274 DEFVAR_LISP ("last-input-char", &last_input_char, 4371 DEFVAR_LISP ("last-input-char", &last_input_char,
4275 "Last terminal input key."); 4372 "Last input event.");
4373
4374 DEFVAR_LISP ("last-input-event", &last_input_char,
4375 "Last input event.");
4276 4376
4277 DEFVAR_LISP ("unread-command-events", &unread_command_events, 4377 DEFVAR_LISP ("unread-command-events", &unread_command_events,
4278 "List of objects to be read as next command input events."); 4378 "List of objects to be read as next command input events.");
4279 4379
4380 DEFVAR_INT ("unread-command-char", &unread_command_char,
4381 "If not -1, an object to be read as next command input event.");
4382
4280 DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char, 4383 DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char,
4281 "Meta-prefix character code. Meta-foo as command input\n\ 4384 "Meta-prefix character code. Meta-foo as command input\n\
4282turns into this character followed by foo."); 4385turns into this character followed by foo.");
@@ -4373,6 +4476,21 @@ but the control and meta bits work even when you are not using X:\n\
4373 1 -- shift bit 2 -- lock bit\n\ 4476 1 -- shift bit 2 -- lock bit\n\
4374 4 -- control bit 8 -- meta bit."); 4477 4 -- control bit 8 -- meta bit.");
4375 extra_keyboard_modifiers = 0; 4478 extra_keyboard_modifiers = 0;
4479
4480 DEFVAR_LISP ("deactivate-mark", &Vdeactivate_mark,
4481 "If an editing command sets this to t, deactivate the mark afterward.\n\
4482The command loop sets this to nil before each command,\n\
4483and tests the value when the command returns.\n\
4484Buffer modification stores t in this variable.");
4485 Vdeactivate_mark = Qnil;
4486
4487 DEFVAR_LISP ("pre-command-hook", &Vpre_command_hook,
4488 "Normal hook run before each command is executed.");
4489 Vpre_command_hook = Qnil;
4490
4491 DEFVAR_LISP ("post-command-hook", &Vpost_command_hook,
4492 "Normal hook run before each command is executed.");
4493 Vpost_command_hook = Qnil;
4376} 4494}
4377 4495
4378keys_of_keyboard () 4496keys_of_keyboard ()