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

>> With your code, if user changes org-menu-system value manually, at run
>> time, after some menu is loaded, the change will be ignored.
>
> It works for me: I can open an article, follow a reference, change the
> value of org-menu-system to another function and the system
> uses this new value the next time I follow a citation. Did I
> misunderstand the problem?

No. It is me who got confused when reading the code.
I've read (menu-system 'org-menu-system) as
(menu-system org-menu-system)

>> In addition, I would try to implement org-attach menu using the new
>> system. org-attach menu is more or less a keymap menu (with buffer
>> popup). It should be possible to translate to transient or simple menu.
>> But there is a twist - the attach keymap is dynamically generated from
>> (mapcar #'caar org-attach-commands).
>
> I did it so that org-menu-define can accept a function as the :menu
> parameter. This is another twist though - the naive implementation below works
> well for the simple case och attaching to a heading in an org document,
> but not for attaching to an org-agenda item:
>
> (defun org-attach--commands-to-transient-specification ()
>   "Produces a transient menu specification from `org-attach-commands'"
>   `[["Select an Attachment Command:"
>      ,@(seq-map (lambda (item)
>                   (pcase item
>                     (`(,keys ,command ,docstring)
>                      `(,(substring-no-properties (prin1-char (car keys)) 1)
>                        ,docstring
>                        (command-execute #',command)))))
>                 org-attach-commands)]])

I think all you need to do is wrapping (command-execute #',command)
into (org-with-point-at ...) and other things that org-attach currently
does.

> (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 (command-execute #'org-attach-attach)
>   (interactive))

Why do you need (interactive)? I think it should be optional.

Also, by default, we should show the old menu somehow.
Some users may prefer the old menu for org-attach while using transient
or, generally, org-menu-system, for other menus.

-- 
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