From: Miles Bader <miles@gnu.org>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: "Stephen J. Turnbull" <stephen@xemacs.org>,
Teemu Likonen <tlikonen@iki.fi>,
emacs-devel@gnu.org
Subject: Re: substitute-key-definition vs. define-key MAP [remap ...]
Date: Fri, 23 Jul 2010 18:32:55 +0900 [thread overview]
Message-ID: <buo4ofqbl14.fsf@dhlpc061.dev.necel.com> (raw)
In-Reply-To: <jwvk4omr1th.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 23 Jul 2010 11:26:47 +0200")
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
> The `remap' thingy operates at the level of `key-binding'. I.e. after
> the command loop reads a key-sequence, it looks it up in the keymaps to
> turn the key-sequence into a command, and then it looks this up in the
> `remap' sub-keymap(s) to see if it got remapped.
And it's _extremely_ handy for some uses... e.g., one of my favorite
tricks is little minor-modes that bind [remap self-insert-command]...
E.g.:
;;; caps-lock-mode, Miles Bader <miles@gnu.org>
(defvar caps-lock-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [remap self-insert-command] 'self-insert-upcased)
map))
(define-minor-mode caps-lock-mode
"When enabled, convert all self-inserting characters to uppercase."
:lighter " CapsLock")
(defun self-insert-upcased (arg)
(interactive "p")
(setq last-command-char (upcase last-command-char))
(self-insert-command arg))
-miles
--
Politics, n. A strife of interests masquerading as a contest of
principles. The conduct of public affairs for private advantage.
next prev parent reply other threads:[~2010-07-23 9:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-15 8:25 substitute-key-definition vs. define-key MAP [remap ...] Teemu Likonen
2010-07-22 22:36 ` Stefan Monnier
2010-07-23 3:50 ` Stephen J. Turnbull
2010-07-23 9:26 ` Stefan Monnier
2010-07-23 9:32 ` Miles Bader [this message]
2010-07-24 7:08 ` Stephen J. Turnbull
2010-07-24 8:19 ` David Kastrup
2010-07-24 9:33 ` Miles Bader
2010-07-24 14:25 ` Stephen J. Turnbull
2010-07-25 3:21 ` Miles Bader
2010-07-25 10:19 ` Stephen J. Turnbull
2010-07-25 13:43 ` Miles Bader
2010-07-23 10:03 ` David Kastrup
2010-07-24 6:27 ` Stephen J. Turnbull
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=buo4ofqbl14.fsf@dhlpc061.dev.necel.com \
--to=miles@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
--cc=stephen@xemacs.org \
--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.
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).