unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: where-is-internal question
Date: Tue, 6 Sep 2005 17:54:55 -0700	[thread overview]
Message-ID: <MEEKKIABFKKDFJMPIOEBMEMHCMAA.drew.adams@oracle.com> (raw)

I haven't looked into this in detail - forgive my incomplete understanding.
I'm looking for help on where-is-internal - as regards command remapping (I
guess).

In previous Emacs versions, I could do this, to bind stuff that is bound to
self-insert-command in the global map:

 (dolist (key (where-is-internal 'self-insert-command global-map))
   (define-key my-map key 'my-command))

Now, however, it looks like I need to do something like the following. Let
me know if I'm missing something, and there is a simpler way.

(dolist (key (or (condition-case nil
                     (where-is-internal 'self-insert-command global-map nil
nil t)
                   (wrong-number-of-arguments nil))
                 (where-is-internal 'self-insert-command global-map))) ; use
old version
  (define-key my-map key 'my-command))

IIUC (probably not), the 5th arg to where-is-internal is needed here,
because of some remapping done to self-insert-command (?). The NEWS file
says this, for Emacs 22.1:

  `where-is-internal' now returns nil for a remapped command (e.g.
  `kill-line', when `my-mode' is enabled), and the actual key binding for
  the command it is remapped to (e.g. C-k for my-kill-line).
  It also has a new optional fifth argument, NO-REMAP, which inhibits
  remapping if non-nil (e.g. it returns "C-k" for `kill-line', and
  "<kill-line>" for `my-kill-line')

I guess that explains what's going on here, but I don't quite follow it. I
also searched NEWS for info on self-insert, but I didn't see anything that I
understood as being related. All I know is that if I don't use a non-nil 5th
argument, I don't get the bindings I'm after; if I do use it, that works.

I'm guessing that self-insert-command must be remapped, and that is why I
need to use a non-nil 5th arg - to prevent where-is-internal from returning
nil for each of the (remapped) self-insert-command bindings.

Could someone please clear up for me just what is going on here?

In ignorance, I'm thinking that the new 5th arg should be defined the other
way 'round: nil should do what t does now, to give better backward
compatibility. That way (I think), I would be able to do just
(where-is-internal 'self-insert-command global-map) in all Emacs versions.

Please let me know what I'm missing (>= 80%, I'm sure). Thanks.

             reply	other threads:[~2005-09-07  0:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-07  0:54 Drew Adams [this message]
2005-09-07  3:19 ` where-is-internal question Drew Adams
2005-09-07  8:37   ` Kim F. Storm
2005-09-08  2:41     ` Richard M. Stallman
2005-09-08 10:14       ` Kim F. Storm
2005-09-07  8:28 ` Kim F. Storm
2005-09-07 12:12   ` Stefan Monnier
2005-09-07 13:05     ` Kim F. Storm
2005-09-07 13:52   ` Drew Adams
2005-09-07 15:11     ` Stefan Monnier
2005-09-07 16:03       ` Drew Adams
2005-09-07 20:04     ` Drew Adams
2005-09-07 20:25       ` Stefan Monnier
2005-09-08  1:59         ` Drew Adams
2005-09-08  9:04         ` Richard M. Stallman

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=MEEKKIABFKKDFJMPIOEBMEMHCMAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.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).