From: Drew Adams <drew.adams@oracle.com>
To: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>,
"Antoine Kalmbach" <ane@iki.fi>
Cc: Andreas Schwab <schwab@linux-m68k.org>,
Richard Stallman <rms@gnu.org>,
Thibaut Verron <thibaut.verron@gmail.com>,
emacs-devel <emacs-devel@gnu.org>
Subject: RE: Patch for emacs/basic.texi
Date: Wed, 16 Sep 2020 16:59:14 +0000 (UTC) [thread overview]
Message-ID: <d5fc094c-7a0f-4f14-a852-45668b70cb1e@default> (raw)
In-Reply-To: <87363hg21r.fsf@gmail.com>
> > Isn't `C-x u` also a default keybinding? Although it requires two
> > keypresses, that should work on all keyboard layouts.
>
> It is a default binding, but it's more cumbersome for "undo bursts"
> (repeating "undo" a bunch of times).
>
> (It's one of those bindings, along with with "C-x o", that I wish came
> with a "C-x z"-like transient map.)
It's trivial to create a repeating command, so you
can use `C-x u u u u ...'.
Either of the definitions below for this (`undo-repeat')
works. The second one is not specific to any key binding
- use it with any prefix key, not just `C-x u'.
Then use this binding:
(global-set-key [remap undo] 'undo-repeat)
1.
(defun undo-repeat (arg)
"Same as `undo', but repeatable even on a prefix key.
E.g., if bound to `C-x u' then you can use `C-x u u u...' to repeat."
(interactive "*P")
(undo arg)
(set-transient-map (let ((map (make-sparse-keymap)))
(define-key map "u" 'undo-repeat)
map)))
2.
(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 undo-repeat (arg)
"Same as `undo', but repeatable even on a prefix key.
E.g., if bound to `C-x u' then you can use `C-x u u u...' to repeat."
(interactive "*P")
(repeat-command 'undo))
Similarly, for `C-x o' (`other-window'):
(defun other-window-repeat ()
"Same as `other-window', but repeatable even on a prefix key.
E.g., if bound to `C-x o' then you can use `C-x o o o...' to repeat."
(interactive)
(repeat-command 'other-window))
(global-set-key [remap other-window] 'other-window-repeat)
I do this all over the place, where it makes sense.
next prev parent reply other threads:[~2020-09-16 16:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 5:05 Patch for emacs/basic.texi Richard Stallman
2020-09-16 5:14 ` Alfred M. Szmidt
2020-09-16 14:17 ` Eli Zaretskii
2020-09-16 15:11 ` Alfred M. Szmidt
2020-09-16 6:00 ` Thibaut Verron
2020-09-16 6:20 ` Kévin Le Gouguec
2020-09-16 6:53 ` Andreas Schwab
2020-09-16 9:19 ` Antoine Kalmbach
2020-09-16 15:43 ` Kévin Le Gouguec
2020-09-16 16:59 ` Drew Adams [this message]
2020-09-16 18:26 ` Repeating commands (was: Patch for emacs/basic.texi) Kévin Le Gouguec
2020-09-16 12:40 ` Patch for emacs/basic.texi Stefan Kangas
2020-09-17 3:53 ` Richard Stallman
2020-09-18 4:04 ` Richard Stallman
2020-09-18 6:09 ` Thibaut Verron
2020-09-18 6:35 ` Mathias Dahl
2020-09-16 13:40 ` Stefan Monnier
2020-09-17 3:57 ` Richard Stallman
2020-09-18 7:53 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d5fc094c-7a0f-4f14-a852-45668b70cb1e@default \
--to=drew.adams@oracle.com \
--cc=ane@iki.fi \
--cc=emacs-devel@gnu.org \
--cc=kevin.legouguec@gmail.com \
--cc=rms@gnu.org \
--cc=schwab@linux-m68k.org \
--cc=thibaut.verron@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).