I want to create a command that, when you call it for the first time, it's executed normally, but when you repeat it with C-x z
, some other command is executed and the original command is never called.
I tried defining it like that (I want forward-line
to be called when repeating foo
):
(defun foo ()
(interactive)
(message "foo")
(setq this-command 'forward-line))
but M-x foo
and then C-x z
just displays "foo" twice and never calls 'forward-line
this-command
tolast-repeatable-command
didn't work, but when I looked at the doc of the latter, it mentioned that the value of this variable is taken fromreal-this-command
. I replacedthis-command
withreal-this-command
and it works exactly how I want. Thanks! – mkcms Dec 20 '17 at 19:25repeat-is-really-this-command
. – mkcms Dec 20 '17 at 19:40