emacs-devel
[Top][All Lists]
Advanced

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

easy-menu-define keys for key-valid-p (was: Info-mode patch)


From: Juri Linkov
Subject: easy-menu-define keys for key-valid-p (was: Info-mode patch)
Date: Tue, 04 Jul 2023 09:50:47 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)

>> >> >> >> It seems you found a bug in 'key-valid-p'!
>> >> >> >> And indeed it returns nil:
>> >> >> >>
>> >> >> >>   (key-valid-p "<tool-bar> <C-Back in history>")
>> >> >> >
>> >> >> > Why is it a bug?  "<tool-bar> <C-Back in history>" has no meaning,
>> >> >> > since it isn't a mouse event.
>> >> >>
>> >> >> Is "remap" a mouse event?
>> >> >
>> >> > Why is "remap" relevant to the issue at hand?
>> >>
>> >> I converted from "old idiom" in info.el to new defvar-keymap. When
>> >> seeing "remap" (a dummy event) works, I just expected defvar-keymap was
>> >> done the way that it is possible to use all keys, fake-kyes, events,
>> >> and whatnot the same way. Similar as I expected 'frame to have same
>> >> meaning everywhere for the uniformity.
>> >>
>> >> Would look more tidy if it was possible to keep all key definitions in
>> >> the same place as in the old code.
>> >
>> > Do you mean that we had a binding like [tool-bar C-Back\ in\ history]
>> > somewhere?
>>
>> This symbol is generated automatically by 'easy-menu-define'
>> from the menu item "Back in History" with spaces inside.
>
> key-valid-p invalidates keys that have embedded whitespace, so we need
> to decide whether we want to add that or modify easy-menu-define to
> produce more reasonable symbols.

Currently easy-menu-intern keeps spaces in strings:

  (defsubst easy-menu-intern (s)
    (if (stringp s) (intern s) s))

Replacing it with:

  (defsubst easy-menu-intern (s)
    (if (stringp s) (intern (string-replace " " "-" (downcase s))) s))

produces from the menu item "Back in History" a more reasonable
symbol 'back-in-history' for which

  (key-valid-p "<tool-bar> C-<back-in-history>")

returns t and can be used in defvar-keymap.

OTOH, [tool-bar C-Back\ in\ history] worked in 27.2 but broke in 28.2
with "<tool-bar> C-<Back in History> is undefined".

After the change above, [tool-bar C-back-in-history] works again.



reply via email to

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