* repeat the last command n times
@ 2006-03-12 13:59 Florian Kaufmann
2006-03-13 21:11 ` Drew Adams
[not found] ` <mailman.10.1142284306.30034.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 5+ messages in thread
From: Florian Kaufmann @ 2006-03-12 13:59 UTC (permalink / raw)
Hello
I am searching for a command that repeats the last command n times. I
know there is repeat, usually bound to C-x z. However, if y want to
repeat the last command 12 times, I have to press z 12 times. Id rather
liked to enter 12 directly.
Using universal-argument, usually bound to C-u, also doesn't fit, since
its only an argument for the next command, and not in every case a
repeat count. For example I cant use it to repeat yank.
I thought I could write a little lisp function by myself and use the
command-history. But as its descriptions says it only contains commands
that read an argument from command line. It doesn't contain commands
like yank.
Using the output of view-lossage might be quite tricky, since I think
its not so easy to find out from this information which the last
command was.
Last but not least I could make use of keyboard macros. But then again,
(start-kbd-macro)[command-to-repeat](end-kbd-macro)(universal-argument)[repeat-count](call-last-kbd-macro)
seems quite more cumbersome than a simple
[command-to-repeat][my-super-repeat-command][repeat-count] or a
[my-super-repeat-next-command][repeat-command][command-to-repeat]
Any further ideas?
Greetings
Florian Kaufmann
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: repeat the last command n times
2006-03-12 13:59 repeat the last command n times Florian Kaufmann
@ 2006-03-13 21:11 ` Drew Adams
[not found] ` <mailman.10.1142284306.30034.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 5+ messages in thread
From: Drew Adams @ 2006-03-13 21:11 UTC (permalink / raw)
I am searching for a command that repeats the last command n times. I
know there is repeat, usually bound to C-x z. However, if y want to
repeat the last command 12 times, I have to press z 12 times. Id rather
liked to enter 12 directly.
Did you try this? M-x my-command C-u 12 C-x z
However, that doesn't seem to work for all commands. It works, for instance,
for character insertion, but not for `yank'. For example, `a C-u 12 C-x z'
inserts 13 a's, but `C-y C-u 12 C-x z' does not perform 13 yanks.
I don't know if this inconsistency is a bug or a feature, but it is the same
going back to at least Emacs 20. The doc string doesn't help much in this
regard. It seems to indicate that the prefix arg should always be applied.
Here's the doc for `C-x z' (`repeat'):
Repeat most recently executed command.
With prefix arg, apply new prefix arg to that command; otherwise, use
the prefix arg that was used before (if any).
If this command is invoked by a multi-character key sequence, it can then
be repeated by repeating the final character of that sequence. This
behavior
can be modified by the global variable `repeat-on-final-keystroke'."
Those who are familiar with what this command does or should do: Should the
doc string clarify the different cases where `C-u' does not have the
indicated effect?
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.10.1142284306.30034.help-gnu-emacs@gnu.org>]
* Re: repeat the last command n times
[not found] ` <mailman.10.1142284306.30034.help-gnu-emacs@gnu.org>
@ 2006-03-13 21:43 ` Johan Bockgård
2006-03-13 22:58 ` Florian Kaufmann
1 sibling, 0 replies; 5+ messages in thread
From: Johan Bockgård @ 2006-03-13 21:43 UTC (permalink / raw)
"Drew Adams" <drew.adams@oracle.com> writes:
> Here's the doc for `C-x z' (`repeat'):
>
> Repeat most recently executed command.
> With prefix arg, apply new prefix arg to that command; otherwise, use
> the prefix arg that was used before (if any).
>
> If this command is invoked by a multi-character key sequence, it can then
> be repeated by repeating the final character of that sequence. This
> behavior
> can be modified by the global variable `repeat-on-final-keystroke'."
>
> Those who are familiar with what this command does or should do:
> Should the doc string clarify the different cases where `C-u' does
> not have the indicated effect?
It works just as indicated.
--
Johan Bockgård
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: repeat the last command n times
[not found] ` <mailman.10.1142284306.30034.help-gnu-emacs@gnu.org>
2006-03-13 21:43 ` Johan Bockgård
@ 2006-03-13 22:58 ` Florian Kaufmann
2006-03-17 4:36 ` Drew Adams
1 sibling, 1 reply; 5+ messages in thread
From: Florian Kaufmann @ 2006-03-13 22:58 UTC (permalink / raw)
As John said, it works as indicated. That is, it doesn't work together
with yank, because yank doesn't take the argument as a repeat count.
The existence of an argument just tells yank that the point should be
at the beginning of the inserted sequence after insertion. C-u 12 C-y
doesn't make 12 yanks, but 1 yank with the point being at beginning of
the inserted string. Now the documentation of repeat (that is C-x z)
sais that it passes the argument to the command to be repeated. Thus
C-y C-u 12 C-x z makes first a yank, then repeats it one time. After
the second yank, the repeated one, the point will be at the beginning
of the inserted string.
Flo
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: repeat the last command n times
2006-03-13 22:58 ` Florian Kaufmann
@ 2006-03-17 4:36 ` Drew Adams
0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2006-03-17 4:36 UTC (permalink / raw)
As John said, it works as indicated. That is, it doesn't work together
with yank, because yank doesn't take the argument as a repeat count.
The existence of an argument just tells yank that the point should be
at the beginning of the inserted sequence after insertion. C-u 12 C-y
doesn't make 12 yanks, but 1 yank with the point being at beginning of
the inserted string. Now the documentation of repeat (that is C-x z)
sais that it passes the argument to the command to be repeated. Thus
C-y C-u 12 C-x z makes first a yank, then repeats it one time. After
the second yank, the repeated one, the point will be at the beginning
of the inserted string.
Thank you for making it clear, Florian. The main point is that the prefix
arg is passed to the previous command (the one that is repeated), and it is
that command that interprets the arg as it likes (as usual).
Actually, a prefix arg for `yank' is more complicated than what you
describe. A plain `C-u' (no number) has the effect you describe. But if a
number N is supplied, then `yank' inserts the Nth most recent entry in the
kill-ring. In the example given, `C-u 12 C-y' inserts the 12th most recently
killed span of text.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-03-17 4:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-12 13:59 repeat the last command n times Florian Kaufmann
2006-03-13 21:11 ` Drew Adams
[not found] ` <mailman.10.1142284306.30034.help-gnu-emacs@gnu.org>
2006-03-13 21:43 ` Johan Bockgård
2006-03-13 22:58 ` Florian Kaufmann
2006-03-17 4:36 ` Drew Adams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).