aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-06-20 14:56:35 +0000
committerRichard M. Stallman1995-06-20 14:56:35 +0000
commit71918b7522e25fa8112d547a44bb3c3df805bd47 (patch)
treee592187d94b9f13ef263f3a0cbddb6f0a5ce2a4e /src
parent0de84e16f194ac5db9079b0884ad0b9fb7d494b6 (diff)
downloademacs-71918b7522e25fa8112d547a44bb3c3df805bd47.tar.gz
emacs-71918b7522e25fa8112d547a44bb3c3df805bd47.zip
(Freset_this_command_lengths): New function.
(before_command_key_count, before_command_echo_length) (before_command_restore_flag): New variables. (add_command_key): If requested, reset the lengths. (command_loop_1): Record current lengths before reading cmd. (read_char): Update the recorded length before echoing.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 2aa93ac023b..8f0efb36f32 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -120,6 +120,18 @@ Lisp_Object recent_keys; /* A vector, holding the last 100 keystrokes */
120Lisp_Object this_command_keys; 120Lisp_Object this_command_keys;
121int this_command_key_count; 121int this_command_key_count;
122 122
123/* Record values of this_command_key_count and echo_length ()
124 before this command was read. */
125static int before_command_key_count;
126static int before_command_echo_length;
127/* Values of before_command_key_count and before_command_echo_length
128 saved by reset-this-command-lengths. */
129static int before_command_key_count_1;
130static int before_command_echo_length_1;
131/* Flag set by reset-this-command-lengths,
132 saying to reset the lengths when add_command_key is called. */
133static int before_command_restore_flag;
134
123extern int minbuf_level; 135extern int minbuf_level;
124 136
125extern struct backtrace *backtrace_list; 137extern struct backtrace *backtrace_list;
@@ -667,6 +679,15 @@ add_command_key (key)
667{ 679{
668 int size = XVECTOR (this_command_keys)->size; 680 int size = XVECTOR (this_command_keys)->size;
669 681
682 /* If reset-this-command-length was called recently, obey it now.
683 See the doc string of that function for an explanation of why. */
684 if (before_command_restore_flag)
685 {
686 this_command_key_count = before_command_key_count_1;
687 echo_truncate (before_command_echo_length_1);
688 before_command_restore_flag = 0;
689 }
690
670 if (this_command_key_count >= size) 691 if (this_command_key_count >= size)
671 { 692 {
672 Lisp_Object new_keys; 693 Lisp_Object new_keys;
@@ -1134,6 +1155,9 @@ command_loop_1 ()
1134 && !NILP (Ffboundp (Qrecompute_lucid_menubar))) 1155 && !NILP (Ffboundp (Qrecompute_lucid_menubar)))
1135 call0 (Qrecompute_lucid_menubar); 1156 call0 (Qrecompute_lucid_menubar);
1136 1157
1158 before_command_key_count = this_command_key_count;
1159 before_command_echo_length = echo_length ();
1160
1137 /* Read next key sequence; i gets its length. */ 1161 /* Read next key sequence; i gets its length. */
1138 i = read_key_sequence (keybuf, sizeof keybuf / sizeof keybuf[0], 1162 i = read_key_sequence (keybuf, sizeof keybuf / sizeof keybuf[0],
1139 Qnil, 0, 1); 1163 Qnil, 0, 1);
@@ -1624,6 +1648,9 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1624 Lisp_Object also_record; 1648 Lisp_Object also_record;
1625 also_record = Qnil; 1649 also_record = Qnil;
1626 1650
1651 before_command_key_count = this_command_key_count;
1652 before_command_echo_length = echo_length ();
1653
1627 if (CONSP (Vunread_command_events)) 1654 if (CONSP (Vunread_command_events))
1628 { 1655 {
1629 c = XCONS (Vunread_command_events)->car; 1656 c = XCONS (Vunread_command_events)->car;
@@ -1646,6 +1673,10 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1646 goto reread; 1673 goto reread;
1647 } 1674 }
1648 1675
1676 /* If there is no function key translated before
1677 reset-this-command-lengths takes effect, forget about it. */
1678 before_command_restore_flag = 0;
1679
1649 if (!NILP (Vexecuting_macro)) 1680 if (!NILP (Vexecuting_macro))
1650 { 1681 {
1651#ifdef MULTI_FRAME 1682#ifdef MULTI_FRAME
@@ -2033,6 +2064,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
2033 2064
2034 from_macro: 2065 from_macro:
2035 reread_first: 2066 reread_first:
2067 before_command_key_count = this_command_key_count;
2068 before_command_echo_length = echo_length ();
2036 2069
2037 /* Don't echo mouse motion events. */ 2070 /* Don't echo mouse motion events. */
2038 if (echo_keystrokes 2071 if (echo_keystrokes
@@ -6231,6 +6264,26 @@ The value is a string or a vector.")
6231 XVECTOR (this_command_keys)->contents); 6264 XVECTOR (this_command_keys)->contents);
6232} 6265}
6233 6266
6267DEFUN ("reset-this-command-lengths", Freset_this_command_lengths,
6268 Sreset_this_command_lengths, 0, 0, 0,
6269 "Used for complicated reasons in `universal-argument-other-key'.\n\
6270\n\
6271`universal-argument-other-key' rereads the event just typed.\n\
6272It then gets translated through `function-key-map'.\n\
6273The translated event gets included in the echo area and in\n\
6274the value of `this-command-keys' in addition to the raw original event.\n\
6275That is not right.\n\
6276\n\
6277Calling this function directs the translated event to replace\n\
6278the original event, so that only one version of the event actually\n\
6279appears in the echo area and in the value of `this-command-keys.'.")
6280 ()
6281{
6282 before_command_restore_flag = 1;
6283 before_command_key_count_1 = before_command_key_count;
6284 before_command_echo_length_1 = before_command_echo_length;
6285}
6286
6234DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0, 6287DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0,
6235 "Return the current depth in recursive edits.") 6288 "Return the current depth in recursive edits.")
6236 () 6289 ()
@@ -6935,6 +6988,7 @@ syms_of_keyboard ()
6935 defsubr (&Scommand_execute); 6988 defsubr (&Scommand_execute);
6936 defsubr (&Srecent_keys); 6989 defsubr (&Srecent_keys);
6937 defsubr (&Sthis_command_keys); 6990 defsubr (&Sthis_command_keys);
6991 defsubr (&Sreset_this_command_lengths);
6938 defsubr (&Ssuspend_emacs); 6992 defsubr (&Ssuspend_emacs);
6939 defsubr (&Sabort_recursive_edit); 6993 defsubr (&Sabort_recursive_edit);
6940 defsubr (&Sexit_recursive_edit); 6994 defsubr (&Sexit_recursive_edit);