From: Drew Adams <drew.adams@oracle.com>
To: "'Le Wang'" <l26wang@gmail.com>, "'Teemu Likonen'" <tlikonen@iki.fi>
Cc: help-gnu-emacs@gnu.org
Subject: RE: Indenting paragraphs manually
Date: Mon, 7 Mar 2011 07:04:13 -0800 (PST) [thread overview]
Message-ID: <93CA043C1044490BAF61AFC312FEF9EF@us.oracle.com> (raw)
In-Reply-To: <AANLkTinQ3-5PuvsoPMX9sj1f2A-putqi0QXLz+QJmbr-@mail.gmail.com>
(let ((repeat-message-function 'ignore))
(setq last-repeatable-command 'indent-rigidly)
(repeat nil)))
> Wow, this repeat bit is a /COOL/ trick. I'll have to file this
> snippet away. Region stays active, and deactivates when
> repeating stops (no mucking with deactivate-mark manually)
> ... very cool. Thanks for sharing!
You're welcome. It dawned on me one day, and I've used it a lot ever since.
Actually, I define a repeatabilizer function like this:
(defun bmkp-repeat-command (command)
"Repeat COMMAND."
(let ((repeat-message-function 'ignore))
(setq last-repeatable-command command)
(repeat nil)))
Then I pass any number of ordinary, non-repeatable commands to that, to create
repeatable versions of them. Then I bind the repeatable ones. Example (from
Bookmark+):
(defun bmkp-next-bookmark-repeat (arg) ; `C-x p right', `C-x p f'
"Jump to the Nth-next bookmark in the bookmark navigation list.
This is a repeatable version of `bmkp-next-bookmark'.
N defaults to 1, meaning the next bookmark.
Plain `C-u' means start over at the first bookmark (and no repeat)."
(interactive "P")
(require 'repeat)
(bmkp-repeat-command 'bmkp-next-bookmark))
(define-key bookmark-map [right] 'bmkp-next-bookmark-repeat)
(define-key bookmark-map "f" 'bmkp-next-bookmark-repeat)
You can put a repeatable command on a prefix key, to save keys. For example, in
Bookmark+ `bookmark-map' is bound to the prefix key `C-x p' - it is available by
default for all bookmark commands.
There are several repeatable commands on this prefix key: `C-x p f', `C-x p
right', `C-x p down', etc. So you can use `C-x p f f f f f f f'... to cycle one
thing, `C-x p down down down'... to cycle another, etc., and still have lots of
other, non-repeatable keys on the same prefix `C-x p'.
You can even put (repeatable) mouse-wheel rotations on a prefix key:
(define-key bookmark-map (vector (list mouse-wheel-up-event))
'bmkp-next-bookmark-this-buffer-repeat)
Using a common prefix key gives users a quick way to see all of the related
default key bindings: `C-x p C-h'. (They can always define shortcut keys if
they want.)
Here is an example where `s' is both a prefix key and a suffix for the prefix
key (different keymap here):
(defun bmkp-bmenu-change-sort-order-repeat (arg) ; `s s'... in bookmark list
"Cycle to the next sort order.
With a prefix arg, reverse current sort order.
This is a repeatable version of `bmkp-bmenu-change-sort-order'."
(interactive "P")
(require 'repeat)
(bmkp-repeat-command 'bmkp-bmenu-change-sort-order))
(define-key bookmark-bmenu-mode-map "ss"
'bmkp-bmenu-change-sort-order-repeat)
Here is a related thread based on this idea of using a prefix key as its own
suffix:
http://lists.gnu.org/archive/html/emacs-devel/2009-08/msg01153.html
next prev parent reply other threads:[~2011-03-07 15:04 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-04 23:17 Indenting paragraphs manually Dani Moncayo
2011-03-05 20:26 ` Andrea Crotti
2011-03-05 22:23 ` Harry Putnam
2011-03-06 11:47 ` Dani Moncayo
2011-03-06 13:50 ` Peter Dyballa
2011-03-06 14:12 ` Dani Moncayo
[not found] ` <mailman.1.1299419427.17199.help-gnu-emacs@gnu.org>
2011-03-06 14:18 ` Pascal J. Bourguignon
2011-03-07 5:04 ` Le Wang
2011-03-07 7:32 ` Dani Moncayo
2011-03-05 22:01 ` Peter Dyballa
2011-03-06 11:50 ` Dani Moncayo
2011-03-05 23:28 ` PJ Weisberg
2011-03-06 2:29 ` Le Wang
2011-03-06 3:08 ` PJ Weisberg
2011-03-06 8:37 ` Le Wang
[not found] ` <mailman.4.1299367745.22865.help-gnu-emacs@gnu.org>
2011-03-06 8:18 ` rusi
2011-03-06 9:10 ` Le Wang
2011-03-06 16:30 ` I filed two bug reports (was: Re: Indenting paragraphs manually) Gregor Zattler
2011-03-06 16:50 ` Dani Moncayo
[not found] ` <mailman.16.1299356823.24947.help-gnu-emacs@gnu.org>
2011-03-06 17:58 ` Indenting paragraphs manually Uday Reddy
2011-03-06 19:17 ` Dani Moncayo
2011-03-06 19:27 ` Teemu Likonen
2011-03-06 19:42 ` Dani Moncayo
2011-03-06 20:26 ` Drew Adams
2011-03-06 20:57 ` Dani Moncayo
2011-03-06 21:42 ` Drew Adams
2011-03-07 21:58 ` Perry Smith
2011-03-07 22:14 ` Drew Adams
2011-03-06 21:44 ` Teemu Likonen
2011-03-07 8:18 ` Teemu Likonen
2011-03-07 13:42 ` Le Wang
2011-03-07 14:38 ` Le Wang
2011-03-07 14:52 ` Teemu Likonen
2011-03-07 15:13 ` Drew Adams
2011-03-07 15:04 ` Drew Adams [this message]
[not found] ` <mailman.14.1299485912.29721.help-gnu-emacs@gnu.org>
2011-03-07 16:09 ` Stefan Monnier
2011-03-07 17:02 ` Teemu Likonen
2011-03-06 19:44 ` Drew Adams
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=93CA043C1044490BAF61AFC312FEF9EF@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=l26wang@gmail.com \
--cc=tlikonen@iki.fi \
/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.
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).