GNU bug report logs -
#78834
Feature request: make keymapp dereference symbol value slot
Previous Next
Full log
Message #11 received at 78834 <at> debbugs.gnu.org (full text, mbox):
> because one is fbound and the other is not. The background for this is
> that I want to collect all loaded keymaps in the system:
>
> (defun collect-keymaps ()
> (cl-loop for k being the symbol when (keymapp k) collect k))
The fix here is to always check the `(symbol-value k)` never `k`.
IOW think of it "I'm looking for all the loaded strings" except that
you're looking for keymaps instead of strings. You wouldn't do
`(stringp k)` but `(stringp (symbol-value k))`, right?
It is rue that keymaps (contrary to strings) can *also* be represented
by symbols (where it works much like it does for functions). I don't
know why this was done, but I consider as an historical accident and
don't recommend making use of that "feature".
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`.
> As a suggestion, the attached patch dereferences symbol value slots
> as well.
It's simpler to fix *your* code rather than the rest of the world's. 🙂
> If it is not a wrong thing to do for some reason I am not aware
> of, I would like to suggest it as a "fix" or a "feature request",
> whichever is best describing the issue.
It would break existing uses when the symbol has both
a `symbol-function` value and a `symbol-value` value. We could consider
adding it as a fallback (i.e. use the `symbol-value` slot only *after*
checking the `symbol-function` slot), but that would be
a somewhat weird/unreliable feature, so we'd need a compelling use-case
(the only advantage I can see of using `symbol-value` over
`symbol-function` is that it can be made buffer-local, so you could
e.g. make a keymap whose parent changes dynamically depending on the
current-buffer, but I don't know what would be the corresponding
"compelling use-case").
Stefan
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.