From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.orgmode,gmane.emacs.devel Subject: Re: Org-cite: Replace basic follow-processor with transient menu? Date: Tue, 22 Oct 2024 17:58:17 +0000 Message-ID: <8734ko10li.fsf@localhost> References: <8734m28l9a.fsf@gmail.com> <874j6h3rw8.fsf@localhost> <877cbamq2q.fsf@gmail.com> <87cykvrgwr.fsf@localhost> <8734lpmkjn.fsf@gmail.com> <87r08lqlbu.fsf@localhost> <87a5ewfvo1.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11887"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-orgmode@gnu.org, Jonas Bernoulli , emacs-devel@gnu.org To: =?utf-8?Q?Tor-bj=C3=B6rn?= Claesson Original-X-From: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Tue Oct 22 19:57:47 2024 Return-path: Envelope-to: geo-emacs-orgmode@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t3J8c-0002p3-IL for geo-emacs-orgmode@m.gmane-mx.org; Tue, 22 Oct 2024 19:57:46 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3J7i-0002N2-Ty; Tue, 22 Oct 2024 13:56:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3J7X-0002MO-Nb for emacs-orgmode@gnu.org; Tue, 22 Oct 2024 13:56:40 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3J7T-0006NQ-LN for emacs-orgmode@gnu.org; Tue, 22 Oct 2024 13:56:38 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 41D9D240029 for ; Tue, 22 Oct 2024 19:56:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1729619792; bh=TTXiDgl6ixbKYAAwHvUvbhpp7wOAcXx6BGZIvKTpOxw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=ZxUwJ4AXSpiAVTf0sFnfMj5SHcc+OC0DlOZb7gvcreVQ2ZVddPUDl3o5z/86BZGMt MyUV69TgF1S8Om0SEdDoh+8YTGuqyr51MCyElcC50G6cP2SAyiOW6KsUi/+FTwF8Zm c+AeoFK2sIE8fYmCp/BxCfEO58fqjUEmFq24ZFaZWZAx8JgU6zVOTP78CVJvKeMN4c k6NhZdYpOuI8gq0cTo3BPIyaGHRA7H+Xz54MXu+Cq6W6oRVEpOZ9YF2nvx4y76Li2+ LLnn2Ljf6SC1y+5/FsdLMzcNpeS+WCAaYsNVU1xvSq0RM2577OhFoMf1Q/IH8IJfVs BVTnaXjqCZxnQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4XY0H33Wkgz9rxF; Tue, 22 Oct 2024 19:56:31 +0200 (CEST) In-Reply-To: <87a5ewfvo1.fsf@gmail.com> Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Original-Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.orgmode:163701 gmane.emacs.devel:324746 Archived-At: [ CCing emacs-devel and the author of transient; maybe we can have some more suggestions this way ] For some context, we are trying to create a customizeable transient menu with items configured via user option. We are also trying to pass additional arguments from prefix to suffix commands in a way that there is no need to write suffix commands specially just for transient. Tor-bj=C3=B6rn Claesson writes: > Ihor Radchenko 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.=20 > > This can be customized directly using the customization=20 > interface. Use setopt instead of setq if you change this option=20 > in elisp, to ensure that the transient is rebuilt. +1 > 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 &opti= onal prefix) > "Follow a citation reference. > > The contents of this transient menu is set in org-cite-basic-follow-actio= ns." > ,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))) This should work, but maybe Jonas can provide better ideas. >>> 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. It is not too bad, but what I really wanted is to reuse an existing command/function without having to write a tailored interactive statement. Again, I am hoping to get some insight from emacs-devel. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at