GNU bug report logs - #78834
Feature request: make keymapp dereference symbol value slot

Previous Next

Package: emacs;

Reported by: arthur miller <arthur.miller <at> live.com>

Date: Wed, 18 Jun 2025 22:34:01 UTC

Severity: wishlist

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: 78834 <at> debbugs.gnu.org
Cc: monnier <at> iro.umontreal.ca, arthur.miller <at> live.com
Subject: bug#78834: Feature request: make keymapp dereference symbol value slot
Date: Fri, 20 Jun 2025 00:45:35 +0200
Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:

>>> It's mostly used in very old code that uses the weird
>>> `define-prefix-command` function, such as the code that sets up some of
>>> the "core" keymaps like `ctl-x-5-prefix` `ESC-prefix` `ctl-x-4-prefix`,
>>> `Control-X-prefix`.
>> I was actually wondering why this was done, if it is just an
>> optimization or if there is some other reason?  I am just curious, I
>> don't really understand the idea behind.
>
> You'd have to ask Richard.  IIUC one of the benefit is that you can
> refer (by name) to a keymap before it's defined.  E.g. you can do
>
>     (global-set-key [?\C-z] 'my-z-keymap)
>
> and then have `my-z-keymap` autoloaded from some library the first time
> you hit `C-z`.  I can't remember the last time I've seen this used
> successfully (I tried to use it a few times, but the keymap always
> ended up being "accidentally" autoloaded much too eagerly).

In a bunch of my packages I use the prefix keymap autoloading
functionality successfully. See for example `cape-prefix-map' or
`osm-prefix-map'. I bind `osm-prefix-map' to `s-m', such that I can
invoke `osm-home' via `s-m h'. I've not observed that osm.el gets loaded
too eagerly.

> Maybe it was done simply because Richard thought of keymaps as kinds of
> commands?

I'd suspect it was done like this because of autoloading.

Daniel




This bug report was last modified 12 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.