unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: "Stephen J. Turnbull" <stephen@xemacs.org>
Cc: Teemu Likonen <tlikonen@iki.fi>, emacs-devel@gnu.org
Subject: Re: substitute-key-definition vs. define-key MAP [remap ...]
Date: Fri, 23 Jul 2010 11:26:47 +0200	[thread overview]
Message-ID: <jwvk4omr1th.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87aapiyhzo.fsf@uwakimon.sk.tsukuba.ac.jp> (Stephen J. Turnbull's message of "Fri, 23 Jul 2010 12:50:03 +0900")

> If I understand you correctly, that won't get into XEmacs any time
> soon.  Do you really mean that `define-key' is allowed to effectively
> change the command binding of a symbol globally, so that its function
> definition is ignored in the context of interpreting keystrokes?  Ie,
> `define-key' now turns Emacs into what is effectively a LISP-3?

I don't know what "ignored in the context of interpreting keystrokes"
means, nor what LISP-3 means.

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.

So if you want to bind the original command to a key, you have to trick
the remapping by using another command name, e.g.:

  (defalias 'new-name-for-old-command 'old-remapped-command)
  (define-key MAP [KEYS] 'new-name-for-old-command)

since the remapping will apply to `old-remapped-command' but not to
`new-name-for-old-command'.  There are other ways, of course, such as:

  (define-key MAP [KEYS]
    (lambda () (interactive) (call-interactively 'old-remapped-command)))


-- Stefan



  reply	other threads:[~2010-07-23  9:26 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 [this message]
2010-07-23  9:32       ` Miles Bader
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=jwvk4omr1th.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --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).