Tor-björn Claesson <[email protected]> writes:

> Ihor Radchenko <[email protected]> writes:
>>
>> I am leaning towards (2). We may want an override to be specific menu
>> system rather than custom function. Imagine some menu that can only work
>> in full using transient, but not alternative menus. We then want to have
>> a way to use transient even if global menu system is something else.
>>
>> As for writing a custom menu system, I think it should be easy to do, if
>> we change `org-menu-define' to pass ARGLIST to the menu system, in
>> addition to (org-menu--bind-specification bound-arguments ,menu-actions)
>> Then, the custom menu system will simply look like
>> (defun custom-menu-system (_ _ &rest args)
>>   (apply #'old-command args))
>
> One downside with this is that the custom menu system would only be
> available for that specific command, I think it is neat if it can be
> used for any menu.
>
> I made a new menu system, `org-menu-attach-style-prompt', which presents
> a menu in the same style as the old org-attach command. The drawback
> here is that it ignores org-attach-expert, which is not visible from
> om.el. Is there something similar to declare-function for variables? In
> that case I could special case the org-attach menu.

I think you can simply make it an internal helper function inside
org-attach.el. Then, you will not have problems with variables.
Aside, the way to declare external variable is (defvar variable), but
that should normally be the last resort (Org overuses this technique,
leading to many internal dependency issues)

If you want to generalize that specific menu layout, it is a good idea
to find another existing command that will also use it. Otherwise, IMHO,
it will be overengineering. (Can be done, but probably not worth the
effort *now*).

> I have one problem: when compiling org-mode, I get a
>
> org-agenda.el:2499:46: Warning: the function ‘org-attach’ is not known
> to be defined.
>
> I'm not sure how I can tell the compiler that org-attach is defined?

declare-function. Although I am not really sure how your changes
triggered this warning. There are many examples in org-agenda.el at the
beginning of the file.

> Also, if we port org-attach to org-menu, should we enable org-menu-mode
> by default?  That will change the behaviour of the basic citation
> handler, but this feels more like a feature enhancement than something
> that would upset people.

Good question.
The dumbest thing we can do here is simply

(org-menu-define org-attach ()
  "The dispatcher for attachment commands.
Shows a list of commands defined in `org-attach-commands' using `org-menu'."
  :menu org-attach--commands-to-transient-specification
  :default-action (org-attach--old-org-attach-menu-system nil nil)
  :override org-attach--old-org-attach-menu-system)

> +(defcustom org-menu-disable-overrides nil
> +  "If this is true, `org-menu-system-overrides' will be ignored."
> +  :group 'org-menu
> +  :package-version '(Org . "9.8")
> +  :type 'boolean)

Not sure about this one. Some commands simply cannot support transient
or other menu systems.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to