diff options
| author | Stefan Monnier | 2015-09-01 21:14:18 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2015-09-01 21:14:18 -0400 |
| commit | 5dc644a6b01e2cf950ff617ab15be4bf1917c38c (patch) | |
| tree | f5572fd4d2c5cc68ac54e48fbd7541bd8043fadc /src | |
| parent | afe1cf00713847c1d8f3a9d95d4980d705ec39f1 (diff) | |
| download | emacs-5dc644a6b01e2cf950ff617ab15be4bf1917c38c.tar.gz emacs-5dc644a6b01e2cf950ff617ab15be4bf1917c38c.zip | |
Generalize the prefix-command machinery of C-u
* lisp/simple.el (prefix-command-echo-keystrokes-functions)
(prefix-command-preserve-state-hook): New hooks.
(internal-echo-keystrokes-prefix): New function.
(prefix-command--needs-update, prefix-command--last-echo): New vars.
(prefix-command-update, prefix-command-preserve): New functions.
(reset-this-command-lengths): New compatibility definition.
(universal-argument--mode): Call prefix-command-update.
(universal-argument, universal-argument-more, negative-argument)
(digit-argument): Call prefix-command-preserve-state.
* src/keyboard.c: Call internal-echo-keystrokes-prefix to build
the "prefix argument" to echo.
(this_command_key_count_reset, before_command_key_count)
(before_command_echo_length): Delete variables.
(echo_add_key): Always add a space.
(echo_char): Remove.
(echo_dash): Don't give up when this_command_key_count is 0, since that
is now the case after a prefix command.
(echo_update): New function, extracted from echo_now.
(echo_now): Use it.
(add_command_key, read_char, record_menu_key): Remove old disabled code.
(command_loop_1): Don't refrain from pushing an undo boundary when
prefix-arg is set. Remove other prefix-arg special case, now handled
directly in the prefix commands instead. But call echo_now if there's
a prefix state to echo.
(read_char, record_menu_key): Use echo_update instead of echo_char.
(read_key_sequence): Use echo_now rather than echo_dash/echo_char.
(Freset_this_command_lengths): Delete function.
(syms_of_keyboard): Define Qinternal_echo_keystrokes_prefix.
(syms_of_keyboard): Don't defsubr Sreset_this_command_lengths.
* lisp/simple.el: Use those new hooks for C-u.
(universal-argument--description): New function.
(prefix-command-echo-keystrokes-functions): Use it.
(universal-argument--preserve): New function.
(prefix-command-preserve-state-hook): Use it.
(command-execute): Call prefix-command-update if needed.
* lisp/kmacro.el (kmacro-step-edit-prefix-commands)
(kmacro-step-edit-prefix-index): Delete variables.
(kmacro-step-edit-query, kmacro-step-edit-insert): Remove ad-hoc
support for prefix arg commands.
(kmacro-step-edit-macro): Don't bind kmacro-step-edit-prefix-index.
* lisp/emulation/cua-base.el (cua--prefix-override-replay)
(cua--shift-control-prefix): Use prefix-command-preserve-state.
Remove now unused arg `arg'.
(cua--prefix-override-handler, cua--prefix-repeat-handler)
(cua--shift-control-c-prefix, cua--shift-control-x-prefix):
Update accordingly.
(cua--prefix-override-timeout): Don't call reset-this-command-lengths
any more.
(cua--keep-active, cua-exchange-point-and-mark): Don't set mark-active
if the mark is not set.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 278 |
1 files changed, 67 insertions, 211 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index d7a533b80b7..a8b1e9828bf 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -107,10 +107,6 @@ static Lisp_Object recent_keys; | |||
| 107 | Lisp_Object this_command_keys; | 107 | Lisp_Object this_command_keys; |
| 108 | ptrdiff_t this_command_key_count; | 108 | ptrdiff_t this_command_key_count; |
| 109 | 109 | ||
| 110 | /* True after calling Freset_this_command_lengths. | ||
| 111 | Usually it is false. */ | ||
| 112 | static bool this_command_key_count_reset; | ||
| 113 | |||
| 114 | /* This vector is used as a buffer to record the events that were actually read | 110 | /* This vector is used as a buffer to record the events that were actually read |
| 115 | by read_key_sequence. */ | 111 | by read_key_sequence. */ |
| 116 | static Lisp_Object raw_keybuf; | 112 | static Lisp_Object raw_keybuf; |
| @@ -124,11 +120,6 @@ static int raw_keybuf_count; | |||
| 124 | that precede this key sequence. */ | 120 | that precede this key sequence. */ |
| 125 | static ptrdiff_t this_single_command_key_start; | 121 | static ptrdiff_t this_single_command_key_start; |
| 126 | 122 | ||
| 127 | /* Record values of this_command_key_count and echo_length () | ||
| 128 | before this command was read. */ | ||
| 129 | static ptrdiff_t before_command_key_count; | ||
| 130 | static ptrdiff_t before_command_echo_length; | ||
| 131 | |||
| 132 | #ifdef HAVE_STACK_OVERFLOW_HANDLING | 123 | #ifdef HAVE_STACK_OVERFLOW_HANDLING |
| 133 | 124 | ||
| 134 | /* For longjmp to recover from C stack overflow. */ | 125 | /* For longjmp to recover from C stack overflow. */ |
| @@ -441,10 +432,12 @@ echo_add_key (Lisp_Object c) | |||
| 441 | ptrdiff_t size = sizeof initbuf; | 432 | ptrdiff_t size = sizeof initbuf; |
| 442 | char *buffer = initbuf; | 433 | char *buffer = initbuf; |
| 443 | char *ptr = buffer; | 434 | char *ptr = buffer; |
| 444 | Lisp_Object echo_string; | 435 | Lisp_Object echo_string = KVAR (current_kboard, echo_string); |
| 445 | USE_SAFE_ALLOCA; | 436 | USE_SAFE_ALLOCA; |
| 446 | 437 | ||
| 447 | echo_string = KVAR (current_kboard, echo_string); | 438 | if (STRINGP (echo_string) && SCHARS (echo_string) > 0) |
| 439 | /* Add a space at the end as a separator between keys. */ | ||
| 440 | ptr++[0] = ' '; | ||
| 448 | 441 | ||
| 449 | /* If someone has passed us a composite event, use its head symbol. */ | 442 | /* If someone has passed us a composite event, use its head symbol. */ |
| 450 | c = EVENT_HEAD (c); | 443 | c = EVENT_HEAD (c); |
| @@ -486,48 +479,12 @@ echo_add_key (Lisp_Object c) | |||
| 486 | ptr += len; | 479 | ptr += len; |
| 487 | } | 480 | } |
| 488 | 481 | ||
| 489 | /* Replace a dash from echo_dash with a space, otherwise add a space | ||
| 490 | at the end as a separator between keys. */ | ||
| 491 | AUTO_STRING (space, " "); | ||
| 492 | if (STRINGP (echo_string) && SCHARS (echo_string) > 1) | ||
| 493 | { | ||
| 494 | Lisp_Object last_char, prev_char, idx; | ||
| 495 | |||
| 496 | idx = make_number (SCHARS (echo_string) - 2); | ||
| 497 | prev_char = Faref (echo_string, idx); | ||
| 498 | |||
| 499 | idx = make_number (SCHARS (echo_string) - 1); | ||
| 500 | last_char = Faref (echo_string, idx); | ||
| 501 | |||
| 502 | /* We test PREV_CHAR to make sure this isn't the echoing of a | ||
| 503 | minus-sign. */ | ||
| 504 | if (XINT (last_char) == '-' && XINT (prev_char) != ' ') | ||
| 505 | Faset (echo_string, idx, make_number (' ')); | ||
| 506 | else | ||
| 507 | echo_string = concat2 (echo_string, space); | ||
| 508 | } | ||
| 509 | else if (STRINGP (echo_string) && SCHARS (echo_string) > 0) | ||
| 510 | echo_string = concat2 (echo_string, space); | ||
| 511 | |||
| 512 | kset_echo_string | 482 | kset_echo_string |
| 513 | (current_kboard, | 483 | (current_kboard, |
| 514 | concat2 (echo_string, make_string (buffer, ptr - buffer))); | 484 | concat2 (echo_string, make_string (buffer, ptr - buffer))); |
| 515 | SAFE_FREE (); | 485 | SAFE_FREE (); |
| 516 | } | 486 | } |
| 517 | 487 | ||
| 518 | /* Add C to the echo string, if echoing is going on. C can be a | ||
| 519 | character or a symbol. */ | ||
| 520 | |||
| 521 | static void | ||
| 522 | echo_char (Lisp_Object c) | ||
| 523 | { | ||
| 524 | if (current_kboard->immediate_echo) | ||
| 525 | { | ||
| 526 | echo_add_key (c); | ||
| 527 | echo_now (); | ||
| 528 | } | ||
| 529 | } | ||
| 530 | |||
| 531 | /* Temporarily add a dash to the end of the echo string if it's not | 488 | /* Temporarily add a dash to the end of the echo string if it's not |
| 532 | empty, so that it serves as a mini-prompt for the very next | 489 | empty, so that it serves as a mini-prompt for the very next |
| 533 | character. */ | 490 | character. */ |
| @@ -539,9 +496,6 @@ echo_dash (void) | |||
| 539 | if (NILP (KVAR (current_kboard, echo_string))) | 496 | if (NILP (KVAR (current_kboard, echo_string))) |
| 540 | return; | 497 | return; |
| 541 | 498 | ||
| 542 | if (this_command_key_count == 0) | ||
| 543 | return; | ||
| 544 | |||
| 545 | if (!current_kboard->immediate_echo | 499 | if (!current_kboard->immediate_echo |
| 546 | && SCHARS (KVAR (current_kboard, echo_string)) == 0) | 500 | && SCHARS (KVAR (current_kboard, echo_string)) == 0) |
| 547 | return; | 501 | return; |
| @@ -574,39 +528,39 @@ echo_dash (void) | |||
| 574 | echo_now (); | 528 | echo_now (); |
| 575 | } | 529 | } |
| 576 | 530 | ||
| 577 | /* Display the current echo string, and begin echoing if not already | ||
| 578 | doing so. */ | ||
| 579 | |||
| 580 | static void | 531 | static void |
| 581 | echo_now (void) | 532 | echo_update (void) |
| 582 | { | 533 | { |
| 583 | if (!current_kboard->immediate_echo) | 534 | if (current_kboard->immediate_echo) |
| 584 | { | 535 | { |
| 585 | ptrdiff_t i; | 536 | ptrdiff_t i; |
| 586 | current_kboard->immediate_echo = true; | 537 | kset_echo_string (current_kboard, |
| 538 | call0 (Qinternal_echo_keystrokes_prefix)); | ||
| 587 | 539 | ||
| 588 | for (i = 0; i < this_command_key_count; i++) | 540 | for (i = 0; i < this_command_key_count; i++) |
| 589 | { | 541 | { |
| 590 | Lisp_Object c; | 542 | Lisp_Object c; |
| 591 | 543 | ||
| 592 | /* Set before_command_echo_length to the value that would | ||
| 593 | have been saved before the start of this subcommand in | ||
| 594 | command_loop_1, if we had already been echoing then. */ | ||
| 595 | if (i == this_single_command_key_start) | ||
| 596 | before_command_echo_length = echo_length (); | ||
| 597 | |||
| 598 | c = AREF (this_command_keys, i); | 544 | c = AREF (this_command_keys, i); |
| 599 | if (! (EVENT_HAS_PARAMETERS (c) | 545 | if (! (EVENT_HAS_PARAMETERS (c) |
| 600 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) | 546 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) |
| 601 | echo_char (c); | 547 | echo_add_key (c); |
| 602 | } | 548 | } |
| 603 | 549 | ||
| 604 | /* Set before_command_echo_length to the value that would | 550 | echo_now (); |
| 605 | have been saved before the start of this subcommand in | 551 | } |
| 606 | command_loop_1, if we had already been echoing then. */ | 552 | } |
| 607 | if (this_command_key_count == this_single_command_key_start) | 553 | |
| 608 | before_command_echo_length = echo_length (); | 554 | /* Display the current echo string, and begin echoing if not already |
| 555 | doing so. */ | ||
| 609 | 556 | ||
| 557 | static void | ||
| 558 | echo_now (void) | ||
| 559 | { | ||
| 560 | if (!current_kboard->immediate_echo) | ||
| 561 | { | ||
| 562 | current_kboard->immediate_echo = true; | ||
| 563 | echo_update (); | ||
| 610 | /* Put a dash at the end to invite the user to type more. */ | 564 | /* Put a dash at the end to invite the user to type more. */ |
| 611 | echo_dash (); | 565 | echo_dash (); |
| 612 | } | 566 | } |
| @@ -666,20 +620,6 @@ echo_truncate (ptrdiff_t nchars) | |||
| 666 | static void | 620 | static void |
| 667 | add_command_key (Lisp_Object key) | 621 | add_command_key (Lisp_Object key) |
| 668 | { | 622 | { |
| 669 | #if 0 /* Not needed after we made Freset_this_command_lengths | ||
| 670 | do the job immediately. */ | ||
| 671 | /* If reset-this-command-length was called recently, obey it now. | ||
| 672 | See the doc string of that function for an explanation of why. */ | ||
| 673 | if (before_command_restore_flag) | ||
| 674 | { | ||
| 675 | this_command_key_count = before_command_key_count_1; | ||
| 676 | if (this_command_key_count < this_single_command_key_start) | ||
| 677 | this_single_command_key_start = this_command_key_count; | ||
| 678 | echo_truncate (before_command_echo_length_1); | ||
| 679 | before_command_restore_flag = 0; | ||
| 680 | } | ||
| 681 | #endif | ||
| 682 | |||
| 683 | if (this_command_key_count >= ASIZE (this_command_keys)) | 623 | if (this_command_key_count >= ASIZE (this_command_keys)) |
| 684 | this_command_keys = larger_vector (this_command_keys, 1, -1); | 624 | this_command_keys = larger_vector (this_command_keys, 1, -1); |
| 685 | 625 | ||
| @@ -1285,10 +1225,6 @@ static void adjust_point_for_property (ptrdiff_t, bool); | |||
| 1285 | /* The last boundary auto-added to buffer-undo-list. */ | 1225 | /* The last boundary auto-added to buffer-undo-list. */ |
| 1286 | Lisp_Object last_undo_boundary; | 1226 | Lisp_Object last_undo_boundary; |
| 1287 | 1227 | ||
| 1288 | /* FIXME: This is wrong rather than test window-system, we should call | ||
| 1289 | a new set-selection, which will then dispatch to x-set-selection, or | ||
| 1290 | tty-set-selection, or w32-set-selection, ... */ | ||
| 1291 | |||
| 1292 | Lisp_Object | 1228 | Lisp_Object |
| 1293 | command_loop_1 (void) | 1229 | command_loop_1 (void) |
| 1294 | { | 1230 | { |
| @@ -1306,7 +1242,6 @@ command_loop_1 (void) | |||
| 1306 | cancel_echoing (); | 1242 | cancel_echoing (); |
| 1307 | 1243 | ||
| 1308 | this_command_key_count = 0; | 1244 | this_command_key_count = 0; |
| 1309 | this_command_key_count_reset = false; | ||
| 1310 | this_single_command_key_start = 0; | 1245 | this_single_command_key_start = 0; |
| 1311 | 1246 | ||
| 1312 | if (NILP (Vmemory_full)) | 1247 | if (NILP (Vmemory_full)) |
| @@ -1394,9 +1329,6 @@ command_loop_1 (void) | |||
| 1394 | && !NILP (Ffboundp (Qrecompute_lucid_menubar))) | 1329 | && !NILP (Ffboundp (Qrecompute_lucid_menubar))) |
| 1395 | call0 (Qrecompute_lucid_menubar); | 1330 | call0 (Qrecompute_lucid_menubar); |
| 1396 | 1331 | ||
| 1397 | before_command_key_count = this_command_key_count; | ||
| 1398 | before_command_echo_length = echo_length (); | ||
| 1399 | |||
| 1400 | Vthis_command = Qnil; | 1332 | Vthis_command = Qnil; |
| 1401 | Vreal_this_command = Qnil; | 1333 | Vreal_this_command = Qnil; |
| 1402 | Vthis_original_command = Qnil; | 1334 | Vthis_original_command = Qnil; |
| @@ -1424,7 +1356,6 @@ command_loop_1 (void) | |||
| 1424 | { | 1356 | { |
| 1425 | cancel_echoing (); | 1357 | cancel_echoing (); |
| 1426 | this_command_key_count = 0; | 1358 | this_command_key_count = 0; |
| 1427 | this_command_key_count_reset = false; | ||
| 1428 | this_single_command_key_start = 0; | 1359 | this_single_command_key_start = 0; |
| 1429 | goto finalize; | 1360 | goto finalize; |
| 1430 | } | 1361 | } |
| @@ -1509,14 +1440,13 @@ command_loop_1 (void) | |||
| 1509 | } | 1440 | } |
| 1510 | #endif | 1441 | #endif |
| 1511 | 1442 | ||
| 1512 | if (NILP (KVAR (current_kboard, Vprefix_arg))) /* FIXME: Why? --Stef */ | 1443 | { |
| 1513 | { | 1444 | Lisp_Object undo = BVAR (current_buffer, undo_list); |
| 1514 | Lisp_Object undo = BVAR (current_buffer, undo_list); | 1445 | Fundo_boundary (); |
| 1515 | Fundo_boundary (); | 1446 | last_undo_boundary |
| 1516 | last_undo_boundary | 1447 | = (EQ (undo, BVAR (current_buffer, undo_list)) |
| 1517 | = (EQ (undo, BVAR (current_buffer, undo_list)) | 1448 | ? Qnil : BVAR (current_buffer, undo_list)); |
| 1518 | ? Qnil : BVAR (current_buffer, undo_list)); | 1449 | } |
| 1519 | } | ||
| 1520 | call1 (Qcommand_execute, Vthis_command); | 1450 | call1 (Qcommand_execute, Vthis_command); |
| 1521 | 1451 | ||
| 1522 | #ifdef HAVE_WINDOW_SYSTEM | 1452 | #ifdef HAVE_WINDOW_SYSTEM |
| @@ -1544,31 +1474,23 @@ command_loop_1 (void) | |||
| 1544 | 1474 | ||
| 1545 | safe_run_hooks (Qdeferred_action_function); | 1475 | safe_run_hooks (Qdeferred_action_function); |
| 1546 | 1476 | ||
| 1547 | /* If there is a prefix argument, | 1477 | kset_last_command (current_kboard, Vthis_command); |
| 1548 | 1) We don't want Vlast_command to be ``universal-argument'' | 1478 | kset_real_last_command (current_kboard, Vreal_this_command); |
| 1549 | (that would be dumb), so don't set Vlast_command, | 1479 | if (!CONSP (last_command_event)) |
| 1550 | 2) we want to leave echoing on so that the prefix will be | 1480 | kset_last_repeatable_command (current_kboard, Vreal_this_command); |
| 1551 | echoed as part of this key sequence, so don't call | 1481 | |
| 1552 | cancel_echoing, and | 1482 | this_command_key_count = 0; |
| 1553 | 3) we want to leave this_command_key_count non-zero, so that | 1483 | this_single_command_key_start = 0; |
| 1554 | read_char will realize that it is re-reading a character, and | 1484 | |
| 1555 | not echo it a second time. | 1485 | if (current_kboard->immediate_echo |
| 1556 | 1486 | && !NILP (call0 (Qinternal_echo_keystrokes_prefix))) | |
| 1557 | If the command didn't actually create a prefix arg, | ||
| 1558 | but is merely a frame event that is transparent to prefix args, | ||
| 1559 | then the above doesn't apply. */ | ||
| 1560 | if (NILP (KVAR (current_kboard, Vprefix_arg)) | ||
| 1561 | || CONSP (last_command_event)) | ||
| 1562 | { | 1487 | { |
| 1563 | kset_last_command (current_kboard, Vthis_command); | 1488 | current_kboard->immediate_echo = false; |
| 1564 | kset_real_last_command (current_kboard, Vreal_this_command); | 1489 | /* Refresh the echo message. */ |
| 1565 | if (!CONSP (last_command_event)) | 1490 | echo_now (); |
| 1566 | kset_last_repeatable_command (current_kboard, Vreal_this_command); | ||
| 1567 | cancel_echoing (); | ||
| 1568 | this_command_key_count = 0; | ||
| 1569 | this_command_key_count_reset = false; | ||
| 1570 | this_single_command_key_start = 0; | ||
| 1571 | } | 1491 | } |
| 1492 | else | ||
| 1493 | cancel_echoing (); | ||
| 1572 | 1494 | ||
| 1573 | if (!NILP (BVAR (current_buffer, mark_active)) | 1495 | if (!NILP (BVAR (current_buffer, mark_active)) |
| 1574 | && !NILP (Vrun_hooks)) | 1496 | && !NILP (Vrun_hooks)) |
| @@ -2389,10 +2311,6 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2389 | 2311 | ||
| 2390 | also_record = Qnil; | 2312 | also_record = Qnil; |
| 2391 | 2313 | ||
| 2392 | #if 0 /* This was commented out as part of fixing echo for C-u left. */ | ||
| 2393 | before_command_key_count = this_command_key_count; | ||
| 2394 | before_command_echo_length = echo_length (); | ||
| 2395 | #endif | ||
| 2396 | c = Qnil; | 2314 | c = Qnil; |
| 2397 | previous_echo_area_message = Qnil; | 2315 | previous_echo_area_message = Qnil; |
| 2398 | 2316 | ||
| @@ -2471,8 +2389,6 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2471 | goto reread_for_input_method; | 2389 | goto reread_for_input_method; |
| 2472 | } | 2390 | } |
| 2473 | 2391 | ||
| 2474 | this_command_key_count_reset = false; | ||
| 2475 | |||
| 2476 | if (!NILP (Vexecuting_kbd_macro)) | 2392 | if (!NILP (Vexecuting_kbd_macro)) |
| 2477 | { | 2393 | { |
| 2478 | /* We set this to Qmacro; since that's not a frame, nobody will | 2394 | /* We set this to Qmacro; since that's not a frame, nobody will |
| @@ -2570,7 +2486,7 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2570 | 2486 | ||
| 2571 | (3) There's only one place in 20.x where ok_to_echo_at_next_pause | 2487 | (3) There's only one place in 20.x where ok_to_echo_at_next_pause |
| 2572 | is set to a non-null value. This is done in read_char and it is | 2488 | is set to a non-null value. This is done in read_char and it is |
| 2573 | set to echo_area_glyphs after a call to echo_char. That means | 2489 | set to echo_area_glyphs. That means |
| 2574 | ok_to_echo_at_next_pause is either null or | 2490 | ok_to_echo_at_next_pause is either null or |
| 2575 | current_kboard->echobuf with the appropriate current_kboard at | 2491 | current_kboard->echobuf with the appropriate current_kboard at |
| 2576 | that time. | 2492 | that time. |
| @@ -2674,7 +2590,8 @@ read_char (int commandflag, Lisp_Object map, | |||
| 2674 | if (minibuf_level == 0 | 2590 | if (minibuf_level == 0 |
| 2675 | && !end_time | 2591 | && !end_time |
| 2676 | && !current_kboard->immediate_echo | 2592 | && !current_kboard->immediate_echo |
| 2677 | && this_command_key_count > 0 | 2593 | && (this_command_key_count > 0 |
| 2594 | || !NILP (call0 (Qinternal_echo_keystrokes_prefix))) | ||
| 2678 | && ! noninteractive | 2595 | && ! noninteractive |
| 2679 | && echo_keystrokes_p () | 2596 | && echo_keystrokes_p () |
| 2680 | && (/* No message. */ | 2597 | && (/* No message. */ |
| @@ -3018,7 +2935,6 @@ read_char (int commandflag, Lisp_Object map, | |||
| 3018 | { | 2935 | { |
| 3019 | Lisp_Object keys; | 2936 | Lisp_Object keys; |
| 3020 | ptrdiff_t key_count; | 2937 | ptrdiff_t key_count; |
| 3021 | bool key_count_reset; | ||
| 3022 | ptrdiff_t command_key_start; | 2938 | ptrdiff_t command_key_start; |
| 3023 | ptrdiff_t count = SPECPDL_INDEX (); | 2939 | ptrdiff_t count = SPECPDL_INDEX (); |
| 3024 | 2940 | ||
| @@ -3028,20 +2944,8 @@ read_char (int commandflag, Lisp_Object map, | |||
| 3028 | Lisp_Object saved_echo_string = KVAR (current_kboard, echo_string); | 2944 | Lisp_Object saved_echo_string = KVAR (current_kboard, echo_string); |
| 3029 | ptrdiff_t saved_echo_after_prompt = current_kboard->echo_after_prompt; | 2945 | ptrdiff_t saved_echo_after_prompt = current_kboard->echo_after_prompt; |
| 3030 | 2946 | ||
| 3031 | #if 0 | ||
| 3032 | if (before_command_restore_flag) | ||
| 3033 | { | ||
| 3034 | this_command_key_count = before_command_key_count_1; | ||
| 3035 | if (this_command_key_count < this_single_command_key_start) | ||
| 3036 | this_single_command_key_start = this_command_key_count; | ||
| 3037 | echo_truncate (before_command_echo_length_1); | ||
| 3038 | before_command_restore_flag = 0; | ||
| 3039 | } | ||
| 3040 | #endif | ||
| 3041 | |||
| 3042 | /* Save the this_command_keys status. */ | 2947 | /* Save the this_command_keys status. */ |
| 3043 | key_count = this_command_key_count; | 2948 | key_count = this_command_key_count; |
| 3044 | key_count_reset = this_command_key_count_reset; | ||
| 3045 | command_key_start = this_single_command_key_start; | 2949 | command_key_start = this_single_command_key_start; |
| 3046 | 2950 | ||
| 3047 | if (key_count > 0) | 2951 | if (key_count > 0) |
| @@ -3051,7 +2955,6 @@ read_char (int commandflag, Lisp_Object map, | |||
| 3051 | 2955 | ||
| 3052 | /* Clear out this_command_keys. */ | 2956 | /* Clear out this_command_keys. */ |
| 3053 | this_command_key_count = 0; | 2957 | this_command_key_count = 0; |
| 3054 | this_command_key_count_reset = false; | ||
| 3055 | this_single_command_key_start = 0; | 2958 | this_single_command_key_start = 0; |
| 3056 | 2959 | ||
| 3057 | /* Now wipe the echo area. */ | 2960 | /* Now wipe the echo area. */ |
| @@ -3075,7 +2978,6 @@ read_char (int commandflag, Lisp_Object map, | |||
| 3075 | /* Restore the saved echoing state | 2978 | /* Restore the saved echoing state |
| 3076 | and this_command_keys state. */ | 2979 | and this_command_keys state. */ |
| 3077 | this_command_key_count = key_count; | 2980 | this_command_key_count = key_count; |
| 3078 | this_command_key_count_reset = key_count_reset; | ||
| 3079 | this_single_command_key_start = command_key_start; | 2981 | this_single_command_key_start = command_key_start; |
| 3080 | if (key_count > 0) | 2982 | if (key_count > 0) |
| 3081 | this_command_keys = keys; | 2983 | this_command_keys = keys; |
| @@ -3141,28 +3043,23 @@ read_char (int commandflag, Lisp_Object map, | |||
| 3141 | goto retry; | 3043 | goto retry; |
| 3142 | } | 3044 | } |
| 3143 | 3045 | ||
| 3144 | if ((! reread || this_command_key_count == 0 | 3046 | if ((! reread || this_command_key_count == 0) |
| 3145 | || this_command_key_count_reset) | ||
| 3146 | && !end_time) | 3047 | && !end_time) |
| 3147 | { | 3048 | { |
| 3148 | 3049 | ||
| 3149 | /* Don't echo mouse motion events. */ | 3050 | /* Don't echo mouse motion events. */ |
| 3150 | if (echo_keystrokes_p () | 3051 | if (! (EVENT_HAS_PARAMETERS (c) |
| 3151 | && ! (EVENT_HAS_PARAMETERS (c) | 3052 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) |
| 3152 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) | 3053 | /* Once we reread a character, echoing can happen |
| 3153 | { | 3054 | the next time we pause to read a new one. */ |
| 3154 | echo_char (c); | 3055 | ok_to_echo_at_next_pause = current_kboard; |
| 3155 | if (! NILP (also_record)) | ||
| 3156 | echo_char (also_record); | ||
| 3157 | /* Once we reread a character, echoing can happen | ||
| 3158 | the next time we pause to read a new one. */ | ||
| 3159 | ok_to_echo_at_next_pause = current_kboard; | ||
| 3160 | } | ||
| 3161 | 3056 | ||
| 3162 | /* Record this character as part of the current key. */ | 3057 | /* Record this character as part of the current key. */ |
| 3163 | add_command_key (c); | 3058 | add_command_key (c); |
| 3164 | if (! NILP (also_record)) | 3059 | if (! NILP (also_record)) |
| 3165 | add_command_key (also_record); | 3060 | add_command_key (also_record); |
| 3061 | |||
| 3062 | echo_update (); | ||
| 3166 | } | 3063 | } |
| 3167 | 3064 | ||
| 3168 | last_input_event = c; | 3065 | last_input_event = c; |
| @@ -3218,23 +3115,13 @@ record_menu_key (Lisp_Object c) | |||
| 3218 | 3115 | ||
| 3219 | record_char (c); | 3116 | record_char (c); |
| 3220 | 3117 | ||
| 3221 | #if 0 | 3118 | /* Once we reread a character, echoing can happen |
| 3222 | before_command_key_count = this_command_key_count; | 3119 | the next time we pause to read a new one. */ |
| 3223 | before_command_echo_length = echo_length (); | 3120 | ok_to_echo_at_next_pause = NULL; |
| 3224 | #endif | ||
| 3225 | |||
| 3226 | /* Don't echo mouse motion events. */ | ||
| 3227 | if (echo_keystrokes_p ()) | ||
| 3228 | { | ||
| 3229 | echo_char (c); | ||
| 3230 | |||
| 3231 | /* Once we reread a character, echoing can happen | ||
| 3232 | the next time we pause to read a new one. */ | ||
| 3233 | ok_to_echo_at_next_pause = 0; | ||
| 3234 | } | ||
| 3235 | 3121 | ||
| 3236 | /* Record this character as part of the current key. */ | 3122 | /* Record this character as part of the current key. */ |
| 3237 | add_command_key (c); | 3123 | add_command_key (c); |
| 3124 | echo_update (); | ||
| 3238 | 3125 | ||
| 3239 | /* Re-reading in the middle of a command. */ | 3126 | /* Re-reading in the middle of a command. */ |
| 3240 | last_input_event = c; | 3127 | last_input_event = c; |
| @@ -9120,11 +9007,12 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9120 | { | 9007 | { |
| 9121 | key = keybuf[t]; | 9008 | key = keybuf[t]; |
| 9122 | add_command_key (key); | 9009 | add_command_key (key); |
| 9123 | if (echo_keystrokes_p () | 9010 | if (current_kboard->immediate_echo) |
| 9124 | && current_kboard->immediate_echo) | ||
| 9125 | { | 9011 | { |
| 9126 | echo_add_key (key); | 9012 | /* Set immediate_echo to false so as to force echo_now to |
| 9127 | echo_dash (); | 9013 | redisplay (it will set immediate_echo right back to true). */ |
| 9014 | current_kboard->immediate_echo = false; | ||
| 9015 | echo_now (); | ||
| 9128 | } | 9016 | } |
| 9129 | } | 9017 | } |
| 9130 | 9018 | ||
| @@ -9788,11 +9676,8 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, | |||
| 9788 | 9676 | ||
| 9789 | Better ideas? */ | 9677 | Better ideas? */ |
| 9790 | for (; t < mock_input; t++) | 9678 | for (; t < mock_input; t++) |
| 9791 | { | 9679 | add_command_key (keybuf[t]); |
| 9792 | if (echo_keystrokes_p ()) | 9680 | echo_update (); |
| 9793 | echo_char (keybuf[t]); | ||
| 9794 | add_command_key (keybuf[t]); | ||
| 9795 | } | ||
| 9796 | 9681 | ||
| 9797 | return t; | 9682 | return t; |
| 9798 | } | 9683 | } |
| @@ -9819,7 +9704,6 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo, | |||
| 9819 | if (NILP (continue_echo)) | 9704 | if (NILP (continue_echo)) |
| 9820 | { | 9705 | { |
| 9821 | this_command_key_count = 0; | 9706 | this_command_key_count = 0; |
| 9822 | this_command_key_count_reset = false; | ||
| 9823 | this_single_command_key_start = 0; | 9707 | this_single_command_key_start = 0; |
| 9824 | } | 9708 | } |
| 9825 | 9709 | ||
| @@ -10076,33 +9960,6 @@ The value is always a vector. */) | |||
| 10076 | return Fvector (raw_keybuf_count, XVECTOR (raw_keybuf)->contents); | 9960 | return Fvector (raw_keybuf_count, XVECTOR (raw_keybuf)->contents); |
| 10077 | } | 9961 | } |
| 10078 | 9962 | ||
| 10079 | DEFUN ("reset-this-command-lengths", Freset_this_command_lengths, | ||
| 10080 | Sreset_this_command_lengths, 0, 0, 0, | ||
| 10081 | doc: /* Make the unread events replace the last command and echo. | ||
| 10082 | Used in `universal-argument-other-key'. | ||
| 10083 | |||
| 10084 | `universal-argument-other-key' rereads the event just typed. | ||
| 10085 | It then gets translated through `function-key-map'. | ||
| 10086 | The translated event has to replace the real events, | ||
| 10087 | both in the value of (this-command-keys) and in echoing. | ||
| 10088 | To achieve this, `universal-argument-other-key' calls | ||
| 10089 | `reset-this-command-lengths', which discards the record of reading | ||
| 10090 | these events the first time. */) | ||
| 10091 | (void) | ||
| 10092 | { | ||
| 10093 | this_command_key_count = before_command_key_count; | ||
| 10094 | if (this_command_key_count < this_single_command_key_start) | ||
| 10095 | this_single_command_key_start = this_command_key_count; | ||
| 10096 | |||
| 10097 | echo_truncate (before_command_echo_length); | ||
| 10098 | |||
| 10099 | /* Cause whatever we put into unread-command-events | ||
| 10100 | to echo as if it were being freshly read from the keyboard. */ | ||
| 10101 | this_command_key_count_reset = true; | ||
| 10102 | |||
| 10103 | return Qnil; | ||
| 10104 | } | ||
| 10105 | |||
| 10106 | DEFUN ("clear-this-command-keys", Fclear_this_command_keys, | 9963 | DEFUN ("clear-this-command-keys", Fclear_this_command_keys, |
| 10107 | Sclear_this_command_keys, 0, 1, 0, | 9964 | Sclear_this_command_keys, 0, 1, 0, |
| 10108 | doc: /* Clear out the vector that `this-command-keys' returns. | 9965 | doc: /* Clear out the vector that `this-command-keys' returns. |
| @@ -10113,7 +9970,6 @@ KEEP-RECORD is non-nil. */) | |||
| 10113 | int i; | 9970 | int i; |
| 10114 | 9971 | ||
| 10115 | this_command_key_count = 0; | 9972 | this_command_key_count = 0; |
| 10116 | this_command_key_count_reset = false; | ||
| 10117 | 9973 | ||
| 10118 | if (NILP (keep_record)) | 9974 | if (NILP (keep_record)) |
| 10119 | { | 9975 | { |
| @@ -11210,6 +11066,7 @@ syms_of_keyboard (void) | |||
| 11210 | staticpro (&raw_keybuf); | 11066 | staticpro (&raw_keybuf); |
| 11211 | 11067 | ||
| 11212 | DEFSYM (Qcommand_execute, "command-execute"); | 11068 | DEFSYM (Qcommand_execute, "command-execute"); |
| 11069 | DEFSYM (Qinternal_echo_keystrokes_prefix, "internal-echo-keystrokes-prefix"); | ||
| 11213 | 11070 | ||
| 11214 | accent_key_syms = Qnil; | 11071 | accent_key_syms = Qnil; |
| 11215 | staticpro (&accent_key_syms); | 11072 | staticpro (&accent_key_syms); |
| @@ -11253,7 +11110,6 @@ syms_of_keyboard (void) | |||
| 11253 | defsubr (&Sthis_command_keys_vector); | 11110 | defsubr (&Sthis_command_keys_vector); |
| 11254 | defsubr (&Sthis_single_command_keys); | 11111 | defsubr (&Sthis_single_command_keys); |
| 11255 | defsubr (&Sthis_single_command_raw_keys); | 11112 | defsubr (&Sthis_single_command_raw_keys); |
| 11256 | defsubr (&Sreset_this_command_lengths); | ||
| 11257 | defsubr (&Sclear_this_command_keys); | 11113 | defsubr (&Sclear_this_command_keys); |
| 11258 | defsubr (&Ssuspend_emacs); | 11114 | defsubr (&Ssuspend_emacs); |
| 11259 | defsubr (&Sabort_recursive_edit); | 11115 | defsubr (&Sabort_recursive_edit); |