diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-09-01 21:14:18 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-09-01 21:14:18 -0400 |
commit | 5dc644a6b01e2cf950ff617ab15be4bf1917c38c (patch) | |
tree | f5572fd4d2c5cc68ac54e48fbd7541bd8043fadc /lisp/emulation | |
parent | afe1cf00713847c1d8f3a9d95d4980d705ec39f1 (diff) | |
download | emacs-5dc644a6b01e2cf950ff617ab15be4bf1917c38c.tar.gz emacs-5dc644a6b01e2cf950ff617ab15be4bf1917c38c.tar.bz2 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 'lisp/emulation')
-rw-r--r-- | lisp/emulation/cua-base.el | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index e91ce80bbe2..52e1647ede7 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el @@ -685,7 +685,7 @@ a cons (TYPE . COLOR), then both properties are affected." (defvar cua--prefix-override-timer nil) (defvar cua--prefix-override-length nil) -(defun cua--prefix-override-replay (arg repeat) +(defun cua--prefix-override-replay (repeat) (let* ((keys (this-command-keys)) (i (length keys)) (key (aref keys (1- i)))) @@ -705,21 +705,23 @@ a cons (TYPE . COLOR), then both properties are affected." ;; Don't record this command (setq this-command last-command) ;; Restore the prefix arg - (setq prefix-arg arg) - (reset-this-command-lengths) + ;; This should make it so that exchange-point-and-mark gets the prefix when + ;; you do C-u C-x C-x C-x work (where the C-u is properly passed to the C-x + ;; C-x binding after the first C-x C-x was rewritten to just C-x). + (prefix-command-preserve-state) ;; Push the key back on the event queue (setq unread-command-events (cons key unread-command-events)))) -(defun cua--prefix-override-handler (arg) +(defun cua--prefix-override-handler () "Start timer waiting for prefix key to be followed by another key. Repeating prefix key when region is active works as a single prefix key." - (interactive "P") - (cua--prefix-override-replay arg 0)) + (interactive) + (cua--prefix-override-replay 0)) -(defun cua--prefix-repeat-handler (arg) +(defun cua--prefix-repeat-handler () "Repeating prefix key when region is active works as a single prefix key." - (interactive "P") - (cua--prefix-override-replay arg 1)) + (interactive) + (cua--prefix-override-replay 1)) (defun cua--prefix-copy-handler (arg) "Copy region/rectangle, then replay last key." @@ -742,7 +744,8 @@ Repeating prefix key when region is active works as a single prefix key." (when (= (length (this-command-keys)) cua--prefix-override-length) (setq unread-command-events (cons 'timeout unread-command-events)) (if prefix-arg - (reset-this-command-lengths) + nil + ;; FIXME: Why? (setq overriding-terminal-local-map nil)) (cua--select-keymaps))) @@ -755,8 +758,9 @@ Repeating prefix key when region is active works as a single prefix key." (call-interactively this-command)) (defun cua--keep-active () - (setq mark-active t - deactivate-mark nil)) + (when (mark t) + (setq mark-active t + deactivate-mark nil))) (defun cua--deactivate (&optional now) (if (not now) @@ -944,7 +948,7 @@ See also `exchange-point-and-mark'." (cond ((null cua-enable-cua-keys) (exchange-point-and-mark arg)) (arg - (setq mark-active t)) + (when (mark t) (setq mark-active t))) (t (let (mark-active) (exchange-point-and-mark) @@ -1212,25 +1216,28 @@ If ARG is the atom `-', scroll upward by nearly full screen." (defvar cua--keymaps-initialized nil) -(defun cua--shift-control-prefix (prefix arg) +(defun cua--shift-control-prefix (prefix) ;; handle S-C-x and S-C-c by emulating the fast double prefix function. ;; Don't record this command (setq this-command last-command) ;; Restore the prefix arg - (setq prefix-arg arg) - (reset-this-command-lengths) + ;; This should make it so that exchange-point-and-mark gets the prefix when + ;; you do C-u S-C-x C-x work (where the C-u is properly passed to the C-x + ;; C-x binding after the first S-C-x was rewritten to just C-x). + (prefix-command-preserve-state) ;; Activate the cua--prefix-repeat-keymap (setq cua--prefix-override-timer 'shift) ;; Push duplicate keys back on the event queue - (setq unread-command-events (cons prefix (cons prefix unread-command-events)))) + (setq unread-command-events + (cons prefix (cons prefix unread-command-events)))) -(defun cua--shift-control-c-prefix (arg) - (interactive "P") - (cua--shift-control-prefix ?\C-c arg)) +(defun cua--shift-control-c-prefix () + (interactive) + (cua--shift-control-prefix ?\C-c)) -(defun cua--shift-control-x-prefix (arg) - (interactive "P") - (cua--shift-control-prefix ?\C-x arg)) +(defun cua--shift-control-x-prefix () + (interactive) + (cua--shift-control-prefix ?\C-x)) (defun cua--init-keymaps () ;; Cache actual rectangle modifier key. |