diff options
author | Stefan Kangas <stefan@marxist.se> | 2021-12-01 06:30:22 +0100 |
---|---|---|
committer | Stefan Kangas <stefan@marxist.se> | 2021-12-01 06:30:22 +0100 |
commit | 93d9bc09f4167100664ac5a3a1cd686e6d7be9a8 (patch) | |
tree | af395ae58f0bf8c764be5a995657728927305571 /lisp/repeat.el | |
parent | 6adf37b4a5a954ac981c2f89ea2c343658f532c2 (diff) | |
parent | e632b83a281fedf652d254ceaa210438301e2513 (diff) | |
download | emacs-93d9bc09f4167100664ac5a3a1cd686e6d7be9a8.tar.gz |
Merge from origin/emacs-28
e632b83a28 Update authors.el for Emacs 28
e9fdb11903 ; * ChangeLog.3: Some additional fixes.
8fa4749df1 ; * ChangeLog.3: Filename fixes.
ea5a90b4f4 * lisp/repeat.el: Fix long-standing problem when a random ...
ef4954b69c * lisp/repeat.el (repeat-keep-prefix): Change default to nil.
6d5886e780 * test/lisp/repeat-tests.el (repeat-tests-call-b): Test fo...
9e16c6a96d ; * src/comp.c (syms_of_comp) <comp-no-native-file-h>: Doc...
9aa8fd6e62 * src/callint.c (Fcall_interactively): Fix inhibit_mouse_e...
70c229b1fc Fix regression in gdb-frame-handler
cd9dd26d24 Format and index concept 'predicate' in ELisp Intro
ab291656d0 ; * ChangeLog.3: Fix typos.
354f6c5609 ; * ChangeLog.3: Formatting fixes.
6192525a96 ; make change-history-commit
Diffstat (limited to 'lisp/repeat.el')
-rw-r--r-- | lisp/repeat.el | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/lisp/repeat.el b/lisp/repeat.el index 7bbb398873c..5930219bd5d 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -354,12 +354,30 @@ of the specified number of seconds." (defvar repeat-exit-timer nil "Timer activated after the last key typed in the repeating key sequence.") -(defcustom repeat-keep-prefix t +(defcustom repeat-keep-prefix nil "Whether to keep the prefix arg of the previous command when repeating." :type 'boolean :group 'convenience :version "28.1") +(defcustom repeat-check-key t + "Whether to check that the last key exists in the repeat map. +When non-nil and the last typed key (with or without modifiers) +doesn't exist in the keymap attached by the `repeat-map' property, +then don't activate that keymap for the next command. So only the +same keys among repeatable keys are allowed in the repeating sequence. +For example, with a non-nil value, only `C-x u u' repeats undo, +whereas `C-/ u' doesn't. + +You can also set the property `repeat-check-key' on the command symbol. +This property can override the value of this variable. +When the variable value is non-nil, but the property value is `no', +then don't check the last key. Also when the variable value is nil, +but the property value is `t', then check the last key." + :type 'boolean + :group 'convenience + :version "28.1") + (defcustom repeat-echo-function #'repeat-echo-message "Function to display a hint about available keys. Function is called after every repeatable command with one argument: @@ -405,16 +423,26 @@ See `describe-repeat-maps' for a list of all repeatable commands." (defvar repeat--prev-mb '(0) "Previous minibuffer state.") +(defun repeat--command-property (property) + (or (and (symbolp this-command) + (get this-command property)) + (and (symbolp real-this-command) + (get real-this-command property)))) + +(defun repeat-check-key (key map) + "Check if the last key is suitable to activate the repeating MAP." + (let ((property (repeat--command-property 'repeat-check-key))) + (or (if repeat-check-key (eq property 'no) (not (eq property t))) + (lookup-key map (vector key)) + ;; Try without modifiers: + (lookup-key map (vector (event-basic-type key)))))) + (defun repeat-post-hook () "Function run after commands to set transient keymap for repeatable keys." (let ((was-in-progress repeat-in-progress)) (setq repeat-in-progress nil) (when repeat-mode - (let ((rep-map (or repeat-map - (and (symbolp this-command) - (get this-command 'repeat-map)) - (and (symbolp real-this-command) - (get real-this-command 'repeat-map))))) + (let ((rep-map (or repeat-map (repeat--command-property 'repeat-map)))) (when rep-map (when (and (symbolp rep-map) (boundp rep-map)) (setq rep-map (symbol-value rep-map))) @@ -426,10 +454,8 @@ See `describe-repeat-maps' for a list of all repeatable commands." ;; in the middle of repeating sequence (bug#47566). (or (< (minibuffer-depth) (car repeat--prev-mb)) (eq current-minibuffer-command (cdr repeat--prev-mb))) - ;; Exit when the last char is not among repeatable keys, - ;; so e.g. `C-x u u' repeats undo, whereas `C-/ u' doesn't. - (or (lookup-key map (this-command-keys-vector)) - prefix-arg)) + (or (not repeat-keep-prefix) prefix-arg) + (repeat-check-key last-command-event map)) ;; Messaging (unless prefix-arg |