reddit / emacs

It Bears Repeating: Emacs 28 & Repeat Mode

karthink · 2022-07-05 18:24
jvillasante · 2022-07-05 19:19
I discover it last week and love it, `C-x o` is now usable out of the box without having to install things like `ace-window`.
00-11 · 2022-07-05 19:33
Good presentation; thx. ---- You might also have mentioned this other way of making a repeatable command from one that's not repeatable: (defun repeat-command (command) "Repeat COMMAND." (require 'repeat) ; Define its vars before we let-bind them. (let ((repeat-previous-repeated-command command) (repeat-message-function #'ignore) (last-repeatable-command 'repeat)) (repeat nil))) (defun shrink-window-repeat () "..." (interactive) (require 'repeat) (repeat-command 'shrink-window)) (defun whatever-repeat () "..." (interactive) (require 'repeat) (repeat-command 'whatever)) ... That's not as convenient, of course, as it means giving the repeatable command a binding (e.g. remapping the original command to it): (global-set-key [remap shrink-window] 'shrink-window-repeat) ---- (Minor) > As a bonus [a `repeat-mode` benefit, presumably], you can repeat invocations of the `repeat` command itself with just `z`, so it’s `C-x z z z`... to repeat the last command multiple times. You can already do that, without `repeat-mode`. That's the point of command `repeat` (`C-x z`). Or did I misunderstand what you meant to say there? Probably. My impression is that you're hinting that one needs to use `C-x z` repeatedly: `C-x z C-x z`... But the paragraph before that one shows that you know that `C-x z z`... is what `repeat` itself offers. So just what do you mean by the "bonus" sentence?
MunsterPlop · 2022-07-05 19:48
It's a really good addition. I've been using it ever since it was added and I find myself creating repeat maps for pretty much everything that (in my case) needs it. Now, what's left to make it perfect is maybe a macro to make it simpler to create repeat maps. I know you can do it yourself (e.g. https://tildegit.org/acdw/define-repeat-map.el) but having something in repeat.el would be, imo, a good idea. Last thing would be for repeat-keep-prefix to work properly but it's apparently gonna be fixed in the next release.
karthink · 2022-07-05 19:59
> You might also have mentioned this other way of making a repeatable command from one that's not repeatable Thanks, I hadn't considered this method before. > So just what do you mean by the "bonus" sentence? It's poorly worded. I only meant that you don't have to press the full sequence`C-x z`, just `z` is enough. `repeat-mode` was meant to have no bearing on this fact. I'll reword it.
karthink · 2022-07-05 20:00
[Repeat Help](https://github.com/karthink/repeat-help), the auxiliary package mentioned in the write-up.
00-11 · 2022-07-05 20:23
Thx.
dbk120 · 2022-07-06 18:10
Many thanks for the article. It looks like repeat-mode would be useful for flymake-goto-next-error / previous-error. Any idea why this isn’t built in?
karthink · 2022-07-06 18:53
That's a good point. I have flymake errors hooked up to the regulalr `next-error` and `previous-error` system, so I didn't notice that you can't repeat them.
dbk120 · 2022-07-06 20:10
It hadn’t occurred to me to do that.
[deleted] · 2022-07-06 20:10
[deleted]
biggrben · 2022-07-07 15:48
Great post! Thx! Is there a way to make `C-p`, `C-n`, `C-f`, `C-b` style of navigation comfortable too? Like is there a way to shorten `C-n C-n C-n C-f C-f C-f` to `C-n n n f f f`?
karthink · 2022-07-07 17:04
Yes, you can make any set of commands repeat this way. If you want to set every common command to repeat I'd recommend just using [god-mode](https://github.com/emacsorphanage/god-mode) instead. Otherwise you can modify the windmove repeat code near the end of the post to suit your needs.
_viz_ · 2022-07-08 05:46
Play around with repeat-check-key. This bug report might be worth reading: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51390
AblatedSprocket · 2022-07-09 13:46
Mind providing your config for this? Sounds useful.
karthink · 2022-07-09 19:34
http://ix.io/424y/elisp EDIT: This is from the Centaur Emacs config, IIRC.
_viz_ · 2022-07-14 14:42
Rather than all that, you can simply set next-error-function to flymake-goto-next-error. This makes M-g n go to the next flymake error. cc. u/AblatedSprocket
AblatedSprocket · 2022-07-14 14:43
Thanks! That's much more my speed :)