Hi!

Thanks all for the great discussion!

Just so I understand: we are talking about simple cases of offering multiple actions (possibly on objects), 
and not more complex things such as the export menu, with async options etc?

> Tentatively, I am thinking about the following:
>
> For a given Emacs "prefix" command (e.g. org-open-at-point), we define a
> set of customizations:
>
> 1. List of possible actions: ((name1 . action1 props) (name2 . action2 ...) ...)
>    PROPS is a plist defining extra properties like key-binding, display
>    string, maybe something else to be used in the future.
> 2. Menu interface to use (transient, context-menu, embark, which-key)
> 3. Layout settings for the specific interfaces. For example, transient
>    layout definition.

Do we need 3? Could we decide on a way to specify layout properties in props?
We could have e.g. a group name which would translate to a transient column.
 
The citation follower prototype works similarly to right click menus of 
mainstream desktop environments - i.e. it allows the user to optionally 
select an alternative action while providing a default. 
You "right click" by -4 prefix, and can also invert this behavior to show
the menu by default, and invoking the default action if called with a -4 prefix.

Den mån 16 dec. 2024 kl 20:06 skrev Ihor Radchenko <yantar92@posteo.net>:

Yeah. I am not 100% sure if adding an abstraction layer is a great idea.
Another idea I was considering is similar to what you propose: have some
kind of hook like `context-menu-functions', but accepting an extra
argument - menu type (context menu, transient, which-key, etc.). Then, it
should produce appropriate menu spec.

However, this will require Elisp to customize things. Also not ideal.

My naive take:

Should we make a macro for creating this kind of simple menu? It would take a name, a docstring, parameters passed to the action, a default action name, and a default list of actions.

It would then create
1. a function that invokes the menu, passing the parameters.
2. a customization group with options for: 
2.1. the actions list. 
2.2. the default action.
2.3. whether to show menu by default (or by -4 prefix)
2.4. the menu system to invoke (default transient)?
3. a transient menu.
 
Does this sound reasonable? I probably miss something. I would be happy to try to make this, but am a bit swamped with the holidays, so it would have to wait a bit.

Cheers,
Tor-björn