• Stefan Monnier's avatar
    Generalize the prefix-command machinery of C-u · 5dc644a6
    Stefan Monnier authored
    * 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.
    5dc644a6
NEWS 49.5 KB