[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59539: 29.0.50; Commands created with `insert-kbd-macro` are NOT get
From: |
Robert Pluim |
Subject: |
bug#59539: 29.0.50; Commands created with `insert-kbd-macro` are NOT getting repeated. |
Date: |
Thu, 15 Dec 2022 10:45:21 +0100 |
>>>>> On Thu, 15 Dec 2022 09:20:31 +0200, Juri Linkov <juri@linkov.net> said:
Ramesh> (defalias 'my-cmd-a
Ramesh> (kmacro "C-f C-f"))
>>
Ramesh> (defalias 'my-cmd-b
Ramesh> (kmacro "C-b C-b"))
>>
Ramesh> (define-key my-kmacro-keymap (kbd "a") #'my-cmd-a)
Ramesh> (define-key my-kmacro-keymap (kbd "b") #'my-cmd-b)
>>
>> Hmm, with your recipe on emacs master, "<f12> b" repeats, but "<f12>
>> a" doesnʼt. I have no clue why, they call the same underlying
>> infrastructure.
Juri> Sorry, I missed this bug report. This is because 'repeat-check-key'
Juri> is t by default so that unrelated key sequences, for example, 'C-_'
Juri> should not activate the repeat map for 'undo', only 'C-x u' should.
Juri> When the user types 'a', the real key from kmacro is 'C-f'.
Juri> There is no 'f' in the keymap above, so it's ignored,
Juri> when 'repeat-check-key' is not customized to nil.
That explains why '<f12> b' works
Juri> Do you have an idea how to do the right thing and to guess the user's
Juri> intention without checking if there are the same keys in the keymap?
I guess it should be possible to find out what the 'original' key
pressed was. <time passes> How about the below? I guess it changes the
behaviour when you have a command bound to two keys in the same repeat
map, and you use the 'wrong' one to repeat (but I could argue that
people creating such keymaps should use the 'repeat-check-key'
property)
Ramesh,
(put 'my-cmd-a 'repeat-check-key 'no)
(put 'my-cmd-b 'repeat-check-key 'no)
should do the right thing for you regardless of whether we change
Emacs.
Robert
--
diff --git a/lisp/repeat.el b/lisp/repeat.el
index 33e8d98ce3..05bdb5dfd1 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -458,8 +458,11 @@ repeat-post-hook
(when rep-map
(when (and (symbolp rep-map) (boundp rep-map))
(setq rep-map (symbol-value rep-map)))
- (let ((map (copy-keymap rep-map)))
-
+ (let* ((map (copy-keymap rep-map))
+ (internal (where-is-internal real-this-command (list map) t))
+ (real-key last-command-event))
+ (when internal
+ (setq real-key (aref internal 0)))
(when (and
;; Detect changes in the minibuffer state to allow
repetitions
;; in the same minibuffer, but not when the minibuffer is
activated
@@ -467,7 +470,7 @@ repeat-post-hook
(or (< (minibuffer-depth) (car repeat--prev-mb))
(eq current-minibuffer-command (cdr repeat--prev-mb)))
(or (not repeat-keep-prefix) prefix-arg)
- (repeat-check-key last-command-event map))
+ (repeat-check-key real-key map))
;; Messaging
(unless prefix-arg