Ihor Radchenko <yanta...@posteo.net> writes: > Thanks! This looks much more clean. > Even better would be having a defcustom that defines the transient > layout. The idea is to avoid hard-coding [["Open" ... ] ["Copy" ...] > ...] and instead make it defcustom.
Here is a solution that works for me. Is this an OK use of eval, or is there a better way of doing this? (defcustom org-cite-basic-follow-actions '[["Open" ("b" "bibliography entry" org-cite-basic-follow.open-bibliography)] ["Copy" ("d" "DOI" org-cite-basic-follow.copy-doi)] ["Browse" ("u" "url" org-cite-basic-follow.browse-url)]] "Contents of the org-cite-basic-follow transient menu. This can be customized directly using the customization interface. Use setopt instead of setq if you change this option in elisp, to ensure that the transient is rebuilt. Further actions can be added using transient-define-suffix." :group 'org-cite :type 'sexp :set (lambda (option-name new-value) (eval `(transient-define-prefix org-cite-basic-follow (citation &optional prefix) "Follow a citation reference. The contents of this transient menu is set in org-cite-basic-follow-actions." ,new-value (interactive) (if (or org-cite-basic-follow-ask prefix) (transient-setup 'org-cite-basic-follow nil nil :scope (list citation prefix)) (org-cite-basic-goto citation prefix)))) (set-default-toplevel-value option-name new-value))) >> (transient-define-suffix org-cite-basic-follow.open-bibliography (citation >> prefix) >> "Find bibliography entry for citation" >> (interactive (oref (transient-prefix-object) scope)) >> (org-cite-basic-goto citation prefix)) >> >> ... > > (oref (transient-prefix-object) scope) is equivalent to (transient-scope) > Ah, thanks! >> And I can then for example add my own pdf-action like this: >> >> (transient-append-suffix 'org-cite-basic-follow "b" >> '("p" "pdf" >> (lambda (citation prefix) >> (interactive (oref (transient-prefix-object) scope)) >> (find-file-other-window >> (concat >> tbc/projektet >> "Referensartiklar" >> "/" >> (org-element-property :key citation) >> ".pdf"))))) > > It feels a bit too complex to demand knowledge of these transient > details (how to get the arglist) from users. > > I am wondering if we can somehow plug the existing commands passing the > arguments without any extra setup on the user side. The lambda form is much neater with your (transient-scope) suggestion: (lambda (citation prefix) (interactive (transient-scope)) ...) Is this simple enough? I don't feel a macro would improve the situation. Best regards, Tor-björn