Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs multi-keystroke binding [duplicate]

Tags:

emacs

elisp

I'm still very new to EMACS, but are getting familiar when i'm going through the emacs and elisp manual. But right now i'm stuck on this:

Is there a simple way to bind input sequences in regexp style?

eg: the default binding for function enlarge-window-horizontally is "C-x {", is it possible to rebind it to something like "C-x ({)+" so that enlarge-window-horizontally can be called repeatedly by repeating "{" character, instead of release Ctrl key multiple times?

like image 423
altkatz Avatar asked Jan 28 '26 14:01

altkatz


1 Answers

There is another way to archive what you desire:

The first time you want to repeat the last command, press C-x z, afterwards you may repeat your command as often as desired by just pressing z.

The advantage of this approach is that it works with every command you use and not just for a specific one.

For additional reference here is the output of C-h f

8.11 Repeating a Command

Many simple commands, such as those invoked with a single key or with M-x COMMAND-NAME , can be repeated by invoking them with a numeric argument that serves as a repeat count (*note Arguments::). However, if the command you want to repeat prompts for input, or uses a numeric argument in another way, that method won't work.

The command C-x z (`repeat') provides another way to repeat an Emacs command many times. This command repeats the previous Emacs command, whatever that was. Repeating a command uses the same arguments that were used before; it does not read new arguments each time.

To repeat the command more than once, type additional z's: each z repeats the command one more time. Repetition ends when you type a character other than z, or press a mouse button.

For example, suppose you type C-u 2 0 C-d to delete 20 characters. You can repeat that command (including its argument) three additional times, to delete a total of 80 characters, by typing C-x z z z. The first C-x z repeats the command once, and each subsequent z repeats it once again.

like image 120
Thilo Avatar answered Jan 30 '26 04:01

Thilo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!