aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1996-05-02 22:33:51 +0000
committerRichard M. Stallman1996-05-02 22:33:51 +0000
commit6321824f3308ee84e9a3ccad4c913e5b4afabd89 (patch)
tree256b1a9e01646d89a79462d585e3e1c51ffed672 /src
parent377f24f59587f1af53ba7d3927efbf9249e1d976 (diff)
downloademacs-6321824f3308ee84e9a3ccad4c913e5b4afabd89.tar.gz
emacs-6321824f3308ee84e9a3ccad4c913e5b4afabd89.zip
(Fthis_single_command_keys): New function.
(syms_of_keyboard): defsubr it. (this_single_command_key_start): New variable. (add_command_key): Reduce this_single_command_key_start if nec. (command_loop_1): Clear this_single_command_key_start if nec. (Fread_key_sequence, Fexecute_extended_command): Likewise. (read_key_sequence): Set this_single_command_key_start.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index d8c46e0d3db..db9d6a50639 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -125,6 +125,10 @@ Lisp_Object recent_keys; /* A vector, holding the last 100 keystrokes */
125Lisp_Object this_command_keys; 125Lisp_Object this_command_keys;
126int this_command_key_count; 126int this_command_key_count;
127 127
128/* Number of elements of this_command_keys
129 that precede this key sequence. */
130int this_single_command_key_start;
131
128/* Record values of this_command_key_count and echo_length () 132/* Record values of this_command_key_count and echo_length ()
129 before this command was read. */ 133 before this command was read. */
130static int before_command_key_count; 134static int before_command_key_count;
@@ -715,6 +719,8 @@ add_command_key (key)
715 if (before_command_restore_flag) 719 if (before_command_restore_flag)
716 { 720 {
717 this_command_key_count = before_command_key_count_1; 721 this_command_key_count = before_command_key_count_1;
722 if (this_command_key_count < this_single_command_key_start)
723 this_single_command_key_start = this_command_key_count;
718 echo_truncate (before_command_echo_length_1); 724 echo_truncate (before_command_echo_length_1);
719 before_command_restore_flag = 0; 725 before_command_restore_flag = 0;
720 } 726 }
@@ -1068,6 +1074,7 @@ command_loop_1 ()
1068 nonundocount = 0; 1074 nonundocount = 0;
1069 no_redisplay = 0; 1075 no_redisplay = 0;
1070 this_command_key_count = 0; 1076 this_command_key_count = 0;
1077 this_single_command_key_start = 0;
1071 1078
1072 /* Make sure this hook runs after commands that get errors and 1079 /* Make sure this hook runs after commands that get errors and
1073 throw to top level. */ 1080 throw to top level. */
@@ -1174,6 +1181,7 @@ command_loop_1 ()
1174 { 1181 {
1175 cancel_echoing (); 1182 cancel_echoing ();
1176 this_command_key_count = 0; 1183 this_command_key_count = 0;
1184 this_single_command_key_start = 0;
1177 goto finalize; 1185 goto finalize;
1178 } 1186 }
1179 1187
@@ -1398,6 +1406,7 @@ command_loop_1 ()
1398 current_kboard->Vlast_command = this_command; 1406 current_kboard->Vlast_command = this_command;
1399 cancel_echoing (); 1407 cancel_echoing ();
1400 this_command_key_count = 0; 1408 this_command_key_count = 0;
1409 this_single_command_key_start = 0;
1401 } 1410 }
1402 1411
1403 if (!NILP (current_buffer->mark_active) && !NILP (Vrun_hooks)) 1412 if (!NILP (current_buffer->mark_active) && !NILP (Vrun_hooks))
@@ -5819,6 +5828,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
5819 if (INTERACTIVE) 5828 if (INTERACTIVE)
5820 echo_start = echo_length (); 5829 echo_start = echo_length ();
5821 keys_start = this_command_key_count; 5830 keys_start = this_command_key_count;
5831 this_single_command_key_start = keys_start;
5822 5832
5823#if defined (GOBBLE_FIRST_EVENT) 5833#if defined (GOBBLE_FIRST_EVENT)
5824 /* This doesn't quite work, because some of the things that read_char 5834 /* This doesn't quite work, because some of the things that read_char
@@ -6336,6 +6346,9 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
6336 if (!used_mouse_menu) 6346 if (!used_mouse_menu)
6337 last_nonmenu_event = key; 6347 last_nonmenu_event = key;
6338 6348
6349 /* Record what part of this_command_keys is the current key sequence. */
6350 this_single_command_key_start = this_command_key_count - t;
6351
6339 prev_fkey_map = fkey_map; 6352 prev_fkey_map = fkey_map;
6340 prev_fkey_start = fkey_start; 6353 prev_fkey_start = fkey_start;
6341 prev_fkey_end = fkey_end; 6354 prev_fkey_end = fkey_end;
@@ -6404,7 +6417,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
6404 (To ignore it safely, we would need to gcpro a bunch of 6417 (To ignore it safely, we would need to gcpro a bunch of
6405 other variables.) */ 6418 other variables.) */
6406 if (! (VECTORP (fkey_next) || STRINGP (fkey_next))) 6419 if (! (VECTORP (fkey_next) || STRINGP (fkey_next)))
6407 error ("Function in function-key-map returns invalid key sequence"); 6420 error ("Function in key-translation-map returns invalid key sequence");
6408 } 6421 }
6409 6422
6410 function_key_possible = ! NILP (fkey_next); 6423 function_key_possible = ! NILP (fkey_next);
@@ -6738,7 +6751,10 @@ DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 4, 0,
6738 gcpro1.nvars = (sizeof keybuf/sizeof (keybuf[0])); 6751 gcpro1.nvars = (sizeof keybuf/sizeof (keybuf[0]));
6739 6752
6740 if (NILP (continue_echo)) 6753 if (NILP (continue_echo))
6741 this_command_key_count = 0; 6754 {
6755 this_command_key_count = 0;
6756 this_single_command_key_start = 0;
6757 }
6742 6758
6743 i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])), 6759 i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])),
6744 prompt, ! NILP (dont_downcase_last), 6760 prompt, ! NILP (dont_downcase_last),
@@ -6760,7 +6776,7 @@ Optional second arg RECORD-FLAG non-nil\n\
6760means unconditionally put this command in `command-history'.\n\ 6776means unconditionally put this command in `command-history'.\n\
6761Otherwise, that is done only if an arg is read using the minibuffer.\n\ 6777Otherwise, that is done only if an arg is read using the minibuffer.\n\
6762The argument KEYS specifies the value to use instead of (this-command-keys)\n\ 6778The argument KEYS specifies the value to use instead of (this-command-keys)\n\
6763when reading the arguments; if it is nil, (this_command_key_count) is used.\n\ 6779when reading the arguments; if it is nil, (this-command-keys) is used.\n\
6764The argument SPECIAL, if non-nil, means that this command is executing\n\ 6780The argument SPECIAL, if non-nil, means that this command is executing\n\
6765a special event, so ignore the prefix argument and don't clear it.") 6781a special event, so ignore the prefix argument and don't clear it.")
6766 (cmd, record_flag, keys, special) 6782 (cmd, record_flag, keys, special)
@@ -6898,6 +6914,7 @@ DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_
6898 Lisp_Object tem; 6914 Lisp_Object tem;
6899 6915
6900 this_command_key_count = 0; 6916 this_command_key_count = 0;
6917 this_single_command_key_start = 0;
6901 6918
6902 keys = XVECTOR (saved_keys)->contents; 6919 keys = XVECTOR (saved_keys)->contents;
6903 for (i = 0; i < XVECTOR (saved_keys)->size; i++) 6920 for (i = 0; i < XVECTOR (saved_keys)->size; i++)
@@ -7062,6 +7079,20 @@ The value is a string or a vector.")
7062 XVECTOR (this_command_keys)->contents); 7079 XVECTOR (this_command_keys)->contents);
7063} 7080}
7064 7081
7082DEFUN ("this-single-command-keys", Fthis_single_command_keys,
7083 Sthis_single_command_keys, 0, 0, 0,
7084 "Return the key sequence that invoked this command.\n\
7085Unlike `this-command-keys', this function's value\n\
7086does not include prefix arguments.\n\
7087The value is a string or a vector.")
7088 ()
7089{
7090 return make_event_array (this_command_key_count
7091 - this_single_command_key_start,
7092 (XVECTOR (this_command_keys)->contents
7093 + this_single_command_key_start));
7094}
7095
7065DEFUN ("reset-this-command-lengths", Freset_this_command_lengths, 7096DEFUN ("reset-this-command-lengths", Freset_this_command_lengths,
7066 Sreset_this_command_lengths, 0, 0, 0, 7097 Sreset_this_command_lengths, 0, 0, 0,
7067 "Used for complicated reasons in `universal-argument-other-key'.\n\ 7098 "Used for complicated reasons in `universal-argument-other-key'.\n\
@@ -7814,6 +7845,7 @@ syms_of_keyboard ()
7814 defsubr (&Scommand_execute); 7845 defsubr (&Scommand_execute);
7815 defsubr (&Srecent_keys); 7846 defsubr (&Srecent_keys);
7816 defsubr (&Sthis_command_keys); 7847 defsubr (&Sthis_command_keys);
7848 defsubr (&Sthis_single_command_keys);
7817 defsubr (&Sreset_this_command_lengths); 7849 defsubr (&Sreset_this_command_lengths);
7818 defsubr (&Ssuspend_emacs); 7850 defsubr (&Ssuspend_emacs);
7819 defsubr (&Sabort_recursive_edit); 7851 defsubr (&Sabort_recursive_edit);