Subject: Re: bug#52973: Adding a few context-menu-mode commands

From: Juri Linkov <[email-masked]>
Date: Sat, 08 Jan 2022 20:30:06 +0200

>> Unless I have missed it, do mean that all context menus should be loaded
>> by default (auto loading all *-context-menu functions and adding all of
>> them to the default value value of context-menu-functions), or that each
>> context menu definition should be accompanied by a add-to-list on
>> context-menu-functions?
>
> I'm not sure I understand why any of what you say should follow.  I'm
> probably missing something.
>
> My mental picture is that context menus are specific to modes.  When a
> buffer has certain modes turned on (one major mode and one or more
> minor modes), those modes are already loaded, and so any functions
> those modes define are already defined.  So when the user right-clicks
> some spot on display, and one or more modes have defined context-menu
> items for this spot, the code which does that is already loaded, and
> calling the functions to produce the menu should not need any
> autoloading.
>
> As for add-to-list, if the implementation of context menus requires
> adding stuff to some list only when the menu is about to be popped up,
> then yes, the add-to-list should be done only when the user clicks.
> But if adding to the list is done when a mode is loaded, then again,
> since all the relevant modes are already loaded, these functions will
> have been added to that list already.
>
> What am I missing?

None of the proposed functions is specific to a mode.
When the global value of context-menu-functions
contains one of the proposed functions, right-clicking anywhere
will autoload every package where such context functions are defined.