diff options
| author | Richard M. Stallman | 1995-01-24 22:13:07 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-01-24 22:13:07 +0000 |
| commit | 309b0fc8c67d9fe7a81b357651e8b10e80997335 (patch) | |
| tree | d058aabdce6e993e4ad7d40760a25810bc8cc9af /src | |
| parent | 2ff4775b139cc64fa9a2443bd2b17173e11f59f4 (diff) | |
| download | emacs-309b0fc8c67d9fe7a81b357651e8b10e80997335.tar.gz emacs-309b0fc8c67d9fe7a81b357651e8b10e80997335.zip | |
(read_key_sequence): New arg dont_downcase_last
inhibits downcasing the last event, when it's uppercase and undefined.
(Fread_key_sequence): Likewise new arg.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 23f9fccbbb5..caba4bbbcc3 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1059,7 +1059,7 @@ command_loop_1 () | |||
| 1059 | call0 (Qrecompute_lucid_menubar); | 1059 | call0 (Qrecompute_lucid_menubar); |
| 1060 | 1060 | ||
| 1061 | /* Read next key sequence; i gets its length. */ | 1061 | /* Read next key sequence; i gets its length. */ |
| 1062 | i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), Qnil); | 1062 | i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), Qnil, 0); |
| 1063 | 1063 | ||
| 1064 | ++num_input_keys; | 1064 | ++num_input_keys; |
| 1065 | 1065 | ||
| @@ -4463,10 +4463,11 @@ follow_key (key, nmaps, current, defs, next) | |||
| 4463 | read_char will return it. */ | 4463 | read_char will return it. */ |
| 4464 | 4464 | ||
| 4465 | static int | 4465 | static int |
| 4466 | read_key_sequence (keybuf, bufsize, prompt) | 4466 | read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last) |
| 4467 | Lisp_Object *keybuf; | 4467 | Lisp_Object *keybuf; |
| 4468 | int bufsize; | 4468 | int bufsize; |
| 4469 | Lisp_Object prompt; | 4469 | Lisp_Object prompt; |
| 4470 | int dont_downcase_last; | ||
| 4470 | { | 4471 | { |
| 4471 | int count = specpdl_ptr - specpdl; | 4472 | int count = specpdl_ptr - specpdl; |
| 4472 | 4473 | ||
| @@ -4542,8 +4543,11 @@ read_key_sequence (keybuf, bufsize, prompt) | |||
| 4542 | Lisp_Object first_event; | 4543 | Lisp_Object first_event; |
| 4543 | #endif | 4544 | #endif |
| 4544 | 4545 | ||
| 4546 | Lisp_Object original_uppercase; | ||
| 4547 | int original_uppercase_position = -1; | ||
| 4548 | |||
| 4545 | /* Gets around Microsoft compiler limitations. */ | 4549 | /* Gets around Microsoft compiler limitations. */ |
| 4546 | int dummyFlag = 0; | 4550 | int dummyflag = 0; |
| 4547 | 4551 | ||
| 4548 | struct buffer *starting_buffer; | 4552 | struct buffer *starting_buffer; |
| 4549 | 4553 | ||
| @@ -4742,7 +4746,7 @@ read_key_sequence (keybuf, bufsize, prompt) | |||
| 4742 | t = 0; | 4746 | t = 0; |
| 4743 | /* The Microsoft C compiler can't handle the goto that | 4747 | /* The Microsoft C compiler can't handle the goto that |
| 4744 | would go here. */ | 4748 | would go here. */ |
| 4745 | dummyFlag = 1; | 4749 | dummyflag = 1; |
| 4746 | break; | 4750 | break; |
| 4747 | } | 4751 | } |
| 4748 | 4752 | ||
| @@ -4949,7 +4953,7 @@ read_key_sequence (keybuf, bufsize, prompt) | |||
| 4949 | last_nonmenu_event = key; | 4953 | last_nonmenu_event = key; |
| 4950 | /* The Microsoft C compiler can't handle the goto that | 4954 | /* The Microsoft C compiler can't handle the goto that |
| 4951 | would go here. */ | 4955 | would go here. */ |
| 4952 | dummyFlag = 1; | 4956 | dummyflag = 1; |
| 4953 | break; | 4957 | break; |
| 4954 | } | 4958 | } |
| 4955 | 4959 | ||
| @@ -5291,6 +5295,9 @@ read_key_sequence (keybuf, bufsize, prompt) | |||
| 5291 | && UPPERCASEP (XINT (key) & 0x3ffff)) | 5295 | && UPPERCASEP (XINT (key) & 0x3ffff)) |
| 5292 | || (XINT (key) & shift_modifier))) | 5296 | || (XINT (key) & shift_modifier))) |
| 5293 | { | 5297 | { |
| 5298 | original_uppercase = key; | ||
| 5299 | original_uppercase_position = t - 1; | ||
| 5300 | |||
| 5294 | if (XINT (key) & shift_modifier) | 5301 | if (XINT (key) & shift_modifier) |
| 5295 | XSETINT (key, XINT (key) & ~shift_modifier); | 5302 | XSETINT (key, XINT (key) & ~shift_modifier); |
| 5296 | else | 5303 | else |
| @@ -5312,6 +5319,9 @@ read_key_sequence (keybuf, bufsize, prompt) | |||
| 5312 | Lisp_Object breakdown; | 5319 | Lisp_Object breakdown; |
| 5313 | int modifiers; | 5320 | int modifiers; |
| 5314 | 5321 | ||
| 5322 | original_uppercase = key; | ||
| 5323 | original_uppercase_position = t - 1; | ||
| 5324 | |||
| 5315 | breakdown = parse_modifiers (key); | 5325 | breakdown = parse_modifiers (key); |
| 5316 | modifiers = XINT (XCONS (XCONS (breakdown)->cdr)->car); | 5326 | modifiers = XINT (XCONS (XCONS (breakdown)->cdr)->car); |
| 5317 | if (modifiers & shift_modifier) | 5327 | if (modifiers & shift_modifier) |
| @@ -5327,7 +5337,7 @@ read_key_sequence (keybuf, bufsize, prompt) | |||
| 5327 | } | 5337 | } |
| 5328 | } | 5338 | } |
| 5329 | 5339 | ||
| 5330 | if (!dummyFlag) | 5340 | if (!dummyflag) |
| 5331 | read_key_sequence_cmd = (first_binding < nmaps | 5341 | read_key_sequence_cmd = (first_binding < nmaps |
| 5332 | ? defs[first_binding] | 5342 | ? defs[first_binding] |
| 5333 | : Qnil); | 5343 | : Qnil); |
| @@ -5335,6 +5345,9 @@ read_key_sequence (keybuf, bufsize, prompt) | |||
| 5335 | unread_switch_frame = delayed_switch_frame; | 5345 | unread_switch_frame = delayed_switch_frame; |
| 5336 | unbind_to (count, Qnil); | 5346 | unbind_to (count, Qnil); |
| 5337 | 5347 | ||
| 5348 | if (dont_downcase_last && t - 1 == original_uppercase_position) | ||
| 5349 | keybuf[t - 1] = original_uppercase; | ||
| 5350 | |||
| 5338 | /* Occasionally we fabricate events, perhaps by expanding something | 5351 | /* Occasionally we fabricate events, perhaps by expanding something |
| 5339 | according to function-key-map, or by adding a prefix symbol to a | 5352 | according to function-key-map, or by adding a prefix symbol to a |
| 5340 | mouse click in the scroll bar or modeline. In this cases, return | 5353 | mouse click in the scroll bar or modeline. In this cases, return |
| @@ -5365,6 +5378,12 @@ First arg PROMPT is a prompt string. If nil, do not prompt specially.\n\ | |||
| 5365 | Second (optional) arg CONTINUE-ECHO, if non-nil, means this key echos\n\ | 5378 | Second (optional) arg CONTINUE-ECHO, if non-nil, means this key echos\n\ |
| 5366 | as a continuation of the previous key.\n\ | 5379 | as a continuation of the previous key.\n\ |
| 5367 | \n\ | 5380 | \n\ |
| 5381 | The third (optional) arg DONT-DOWNCASE-LAST, if non-nil, means do not\n\ | ||
| 5382 | convert the last event to lower case. (Normally any upper case event\n\ | ||
| 5383 | is converted to lower case if the original event is undefined and the lower\n\ | ||
| 5384 | case equivalent is defined.) A non-nil value is appropriate for reading\n\ | ||
| 5385 | a key sequence to be defined.\n\ | ||
| 5386 | \n\ | ||
| 5368 | A C-g typed while in this function is treated like any other character,\n\ | 5387 | A C-g typed while in this function is treated like any other character,\n\ |
| 5369 | and `quit-flag' is not set.\n\ | 5388 | and `quit-flag' is not set.\n\ |
| 5370 | \n\ | 5389 | \n\ |
| @@ -5392,10 +5411,10 @@ sequences, where they wouldn't conflict with ordinary bindings. See\n\ | |||
| 5392 | (prompt, continue_echo) | 5411 | (prompt, continue_echo) |
| 5393 | #endif | 5412 | #endif |
| 5394 | 5413 | ||
| 5395 | DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 2, 0, | 5414 | DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 3, 0, |
| 5396 | 0) | 5415 | 0) |
| 5397 | (prompt, continue_echo) | 5416 | (prompt, continue_echo, dont_downcase_last) |
| 5398 | Lisp_Object prompt, continue_echo; | 5417 | Lisp_Object prompt, continue_echo, dont_downcase_last; |
| 5399 | { | 5418 | { |
| 5400 | Lisp_Object keybuf[30]; | 5419 | Lisp_Object keybuf[30]; |
| 5401 | register int i; | 5420 | register int i; |
| @@ -5412,7 +5431,8 @@ DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 2, 0, | |||
| 5412 | if (NILP (continue_echo)) | 5431 | if (NILP (continue_echo)) |
| 5413 | this_command_key_count = 0; | 5432 | this_command_key_count = 0; |
| 5414 | 5433 | ||
| 5415 | i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])), prompt); | 5434 | i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])), |
| 5435 | prompt, ! NILP (dont_downcase_last)); | ||
| 5416 | 5436 | ||
| 5417 | if (i == -1) | 5437 | if (i == -1) |
| 5418 | { | 5438 | { |