emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: accessible-keymaps gives wrong result for autoloaded prefix keys


From: Stefan Monnier
Subject: Re: accessible-keymaps gives wrong result for autoloaded prefix keys
Date: Tue, 03 Oct 2006 10:08:41 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> M-: (accessible-keymaps (current-global-map) [f2])

> This returns nil.

> (accessible-keymaps (current-global-map) []) shows this in the global
> map: (f2 . 2C-command).

> The problem is that the `symbol-function' of `2C-command' is (autoload
> "two-column" nil t keymap).

> `accessible-keymaps' cannot do its job correctly, and return a correct
> result, unless it loads two-column.el when it needs to.  Emacs should
> consider that using `accessible-keymaps' this way should load the
> file, just as using `C-h k f2' or `C-h f 2C-command' loads it.

> The same is true for all other autoloaded commands bound to keymaps
> (prefix keys).

Currently accessible-keymaps indeed does not execute any elisp code (and
hence doesn't autoload keymaps either), so that as to guarantee not to call
the garbage collector.
IIRC this is necessary because it's used in where-is-internal, itself called
from the menu-construction code at a place where GC could screw things up.

Furthermore, if keymaps were autoloaded by accessible-keymaps, it would mean
that all keymaps would be autoloaded at the first use of where-is-internal,
which basically means "immediately" since where-is-internal is used very
often (e.g. after M-x, or to build menus, or ...).

I'm not saying it's not a bug, but just giving some explanation for the
current situation.

One possible fix is to change accessible-keymaps so that it returns
(([f2] . 2C-command)) rather than nil.  The patch below does just that.

Could you explain why it matters to you?


        Stefan


--- orig/src/keymap.c
+++ mod/src/keymap.c
@@ -2035,7 +2035,7 @@
         if the prefix is not defined in this particular map.
         It might even give us a list that isn't a keymap.  */
       tem = get_keymap (tem, 0, 0);
-      if (CONSP (tem))
+      if (!NILP (tem))
        {
          /* Convert PREFIX to a vector now, so that later on
             we don't have to deal with the possibility of a string.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]