From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 8KX2Nv0nMmfwoAAAqHPOHw:P1 (envelope-from ) for ; Mon, 11 Nov 2024 15:51:26 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 8KX2Nv0nMmfwoAAAqHPOHw (envelope-from ) for ; Mon, 11 Nov 2024 16:51:25 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=JNvv97us; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1731340285; a=rsa-sha256; cv=none; b=Li3Vp4BiGetAUUcrGAnsUwaPCZiJ/Oph0pEIBr5BZeYCWpJfUxdlEiAMaeZgdBDxctiJjZ Loy8RSafuZ5Xlcamiv8BOCPVjGzUHRIRSwteTcfPaaolFnbvyq2B2FZAYWm1ZVYQyJMai3 tKRrzlRYCIu4sjhX26qbtJ5c22KrWWyk8hZvsp6TyVWsvC0TRlcDY7/G5O0Vxqgo0lMeEV dbZXmG+/mKydTsSWs7kJsLu4GLSyYmpjIiTdv/taSO+29EboRhE9ndDxK1otpqDPZt8pMA 7gSBmpSYpVE970nqsEGG1um4S40CeIjfq9U0i4JsRGFJkLIZgsURbeEK38Y1ng== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=JNvv97us; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1731340285; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=U/qIczuIvapbQ2ACRBg1Op9bc7QUM+tO0HccGokIXfQ=; b=KtXqQqg0HvFd4fUxcvuBpf0lyeyFaTqtRrK65VQXs+Q9f/A6i0yPicwgppUK9KSooMSC7A f6LW/Vlr4hQXZzJoKZGbkNMLIsDqOfvZrwo59mfT6z3oGsv2a8WkjeQxS1USwEPh0rEl7+ 6RH9Kh40TW2HNSgT+Ug7zTANGr1Fkwp2lrSAREDHcN985ZCO+VttiAUnloqaF0DCVjn+tD qexd/PKFY7Ys/Ch0cRRStE83+C4fKp7wM2bJa03xsFyffVlGbqHZNDMhqtcOxxX2X/TLdd 3KijdzjR/51oaDJL5jY2QDbhEDfEa5gmIwEkd7U5bZedV77TtBG6ZGrfw8e+pQ== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5206462F70 for ; Mon, 11 Nov 2024 16:51:25 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tAWgX-00035X-Hu; Mon, 11 Nov 2024 10:50:37 -0500 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 1tAWgT-00035L-Np for emacs-orgmode@gnu.org; Mon, 11 Nov 2024 10:50:34 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tAWgR-0000Iq-Bx for emacs-orgmode@gnu.org; Mon, 11 Nov 2024 10:50:33 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 72332240103 for ; Mon, 11 Nov 2024 16:50:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1731340226; bh=LZ/K/gTpFnzsVW/419mAskSHnLHYEuPD+Wi56cu/ZfA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=JNvv97usJQavJnjHBAtoYm3L9ekYVRMoRqSV7sFMTwc+Qliq82No+nem8fL2fc9fz aHveDmsgb0pP6XUnJcM3VdQ5HAQ8Ml+r6eVsRPmwQ8x48r2PpwzWPsMDyzPtFI0GOf plFdwV1mH8VpqP6Iqc5Q9AMnV7XhG39f2G8PRt6mBoupSXwxkIG8ra3zb7Zlzr9kSi Wua0NTKLYosuc6E+NuZL+iiXtJJjbUPT/AZGVC69gYUwjOhLprpyLzMaDpXy8TvzBa TnIpEUAETKmfeVZVox+wlMM9og2bgm4aly+6G4hkn0VP/t6vA5K3hFPSeUXEbfmo/F kHHdVWy9S81ag== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4XnDXK4rBNz9rxK; Mon, 11 Nov 2024 16:50:25 +0100 (CET) From: Ihor Radchenko To: =?utf-8?Q?Tor-bj=C3=B6rn?= Claesson Cc: Jonas Bernoulli , emacs-orgmode@gnu.org Subject: Re: Org-cite: Replace basic follow-processor with transient menu? In-Reply-To: References: <8734m28l9a.fsf@gmail.com> <87bjz9o188.fsf@localhost> <87r0839jfc.fsf@bernoul.li> <874j4ueo1x.fsf@localhost> <87bjz2tam2.fsf@gmail.com> <87msil77oi.fsf@localhost> <87ed3wnlv4.fsf@gmail.com> <874j4sccuv.fsf@localhost> <87jzdo2e4m.fsf@gmail.com> <87a5eievav.fsf@localhost> <87wmhlmp83.fsf@gmail.com> <871pzte929.fsf@localhost> <87v7x548ri.fsf@gmail.com> <87y120daue.fsf@localhost> <874j4m9ep6.fsf@gmail.com> <87h68gfqj1.fsf@localhost> <87pln3f3cc.fsf@localhost> Date: Mon, 11 Nov 2024 15:52:03 +0000 Message-ID: <87jzd9ojj0.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.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+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 1.62 X-Spam-Score: 1.62 X-Migadu-Queue-Id: 5206462F70 X-Migadu-Scanner: mx12.migadu.com X-TUID: kora7R28Nt+B Tor-bj=C3=B6rn Claesson writes: > Here is my first attempt. > I have read the commit guidelines, but it is very possible that I have > misunderstood or just missed something, so I'm grateful for any > feedback! Thanks for the patch! See my comments below. > * lisp/oc-basic.el (require 'transient): Pull in transient. Technically, we still support Emacs 27, which does not have transient. But accounting for this would be a pain and Emacs 30 is probably going to be released some time around the beginning of the next year. So, let's not worry about this and accept that Org 9.8-pre (next release) no longer supports Emacs 27. If you are a user of Emacs 27 + Org main branch, and have strong objections, please chime in. > +*** Menu for choosing how to follow citations > +If invoked with a prefix of C-- C-u, following citations with > +the org-cite-basic citation backend will no present a transient menu, > +offering choices for how to follow citations. I imagine C-- C-u more as a toggle - if `org-cite-basic-follow-ask' is t, it disables the menu; enables otherwise. > +(defcustom org-cite-basic-follow-ask nil > + "Should `org-cite-basic' ask how to follow citations? > + > +When this option is nil, `org-cite-basic-follow' opens the bibliography = entry. > +Otherwise, `org-cite-basic-follow' will display a transient menu prompti= ng the=20 > +user for an action. The contents of this menu can be customized in=20 > +`org-cite-basic-follow-actions'." Note: our convention is to use double space between sentences. There are also typos, but that's a minor thing I can fix myself before merging. > +(defcustom org-cite-basic-follow-actions > + '[["Open" > + ("b" "bibliography entry" (org-cite-basic-goto !citation !prefix))]] > + "Actions in the `org-cite-basic-follow' transient menu. > + > +This option uses the same syntax as `transient-define-prefix', see Info = node > +`(transient)Binding Suffix and Infix Commands'. In addition, it is possi= ble=20 > +to specify a function call for the COMMAND part, where !citation,=20 > +!prefix, and !citation-key can be used to access those values.=20 > + > +If COMMAND is a lambda form, it can access the citation and prefix like = this: > + > + (lambda (citation prefix) > + (interactive (transient-scope)) > + ...)" Could we make !prefix, and !citation work in lambdas? We should be able to. > +(transient-define-prefix org-cite-basic-follow (citation &optional prefi= x) > + "Follow citation. > + > +This transient is invoked through `org-open-at-point'.=20 > +When `org-open-at-point' is invoked It should not matter for this command where it is called from. You can simply drop references to `org-open-at-point' We can even make the prefix work as a standalone command. Simply using interactive spec. (interactive (list (let ((obj (org-element-context))) (pcase (org-element-type obj) ((or citation citation-reference) obj) (_ (user-error "No citation at point")))))) > ... with a negative prefix, +or `org-cite-basic-follow-ask' is > non-nil, it will present +a transient menu prompting the user for an > action. Otherwise, +it will open the bibliography entry for the > citation at point. > +Suffixes can not be added to this transient menu using the ordinary > +`transient-append-suffix' or `transient-insert-suffix', instead, the > +contents of the menu are defined in the variable > +`org-cite-basic-follow-actions'." Suffixes can be added. Try (transient-append-suffix 'org-cite-basic-follow nil '[["Other" ("t" "test" (lambda () (interactive) (message "Hello!")))]]) > +(defun org-cite-basic-follow--parse-suffix-specification (specification) > + (pcase specification Please, add the docstring. > + ((and val `(,key ,desc (,fn . ,fn-args) . ,other)) > + (if (eq fn 'lambda) val > + `(,key ,desc > + (lambda () > + (interactive) > + (let ((!citation (car (transient-scope))) > + (!prefix (cadr (transient-scope))) > + (!citation-key > + (org-element-property :key (car (transient-scope)= )))) `org-open-at-point' may be called with point at citation rather than citation reference. Citation object does not have :key property. I think that we should drop !citation-key spec and instead specify that the command may be called with citation or citation-reference object in !ci= tation. > +(defun org-cite-basic-follow--setup (_) > + (transient-parse-suffixes Docstring here as well. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at