From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id oEBHGaPWHGf1FwAAe85BDQ:P1 (envelope-from ) for ; Sat, 26 Oct 2024 11:46:43 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id oEBHGaPWHGf1FwAAe85BDQ (envelope-from ) for ; Sat, 26 Oct 2024 13:46:43 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=B9Gy8Y7k; dmarc=pass (policy=reject) header.from=bernoul.li; 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=1729943203; a=rsa-sha256; cv=none; b=jC34h5A1I34eSZN0ih9AJc2WmBdhR9/mRwk+j2Qskqe8wOzAt1gFIpepnwtZTLzG14LqSJ ib48L5AEM4c/saiKbiNKQfPxL+13sVIJXCna9n1upfqPmLqET/zTCXLMTpX8rz1BDXn3sm lmKb6bwZ/UWN45EzFWlUbyc79bIX1h6Fis8qpbEElrikkHDAWBAHQ5xfU2XJxTTHSvl993 QZe3aMUXScTu1Rl2oMvXCKw1t4K3F8+AQWFv65qZ+xTQiVRmgKX/Ubd48+N7meFafiyI5t 9bITwVVUOHh4NACmYSplJTo7HA/I+AoGneEwPqfIawF94R3QjxsypIKg6hmyQg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=B9Gy8Y7k; dmarc=pass (policy=reject) header.from=bernoul.li; 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=1729943203; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=7ANwUvwzZy3luH+SoD843Rq6ceCeHNAx6ZDbyarMalE=; b=SQkHISfMNBc9iihAtURRznQ8t7e2JlCswRvDUQSqrE0jBkvjWQn3U7zr/Z0wjCM+vkmSEe Iluo+fqtu8UQ5ksnH/dLAcNYBmrmA8eF1viGOyRoxa0WkydArU+Dq777sMfw3GUWhitOhm //Gg7oPIaMhnBp0PUk/+WWlwxQsEO6hqgvletI8rEbAFmZ+oGEOnAl3xLIb9DZBtju8oCO fq7dVFQGGUBoXtxEPeu7pu3FwbtYR9oi7JpGFEImxn8fDXRRnTCMErk1Ztzefrn0z4PpLR ATWlVRW+BSDlY7QYxnnDfsDLcDIe/Ij/81aLGUniAq8V4hxhHprfDHcSXkpGYw== 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 D197B73A64 for ; Sat, 26 Oct 2024 13:46:42 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4fF5-00077e-6m; Sat, 26 Oct 2024 07:46:03 -0400 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 1t4fF0-00076d-JA for emacs-orgmode@gnu.org; Sat, 26 Oct 2024 07:45:58 -0400 Received: from mail.hostpark.net ([212.243.197.30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4fEy-00032C-1l for emacs-orgmode@gnu.org; Sat, 26 Oct 2024 07:45:58 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 33D0E1657F; Sat, 26 Oct 2024 13:45:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h= content-type:content-type:mime-version:message-id:date:date :references:in-reply-to:subject:subject:from:from; s=sel2011a; t=1729943146; bh=42xo+m25UhkAVamgm+8ny+vaGLF9FRwa3Gjqgfyeqog=; b= B9Gy8Y7kk+FNM55dxS1fdXI7zDO6aCS2rcYGKsLkMKuBlgQPw0k2O5txfGKW3oju bimOOR16BjKBRewWR31qMK7PRwV1TV00Jshhk3PpKUSMsrAFgZq6BZvAgVxuaoaJ Qau8trqHhxQbMjXTA4p9O3GHbN6u4PUhNdyO2/QuuYg= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id MEqN8wikxv85; Sat, 26 Oct 2024 13:45:46 +0200 (CEST) Received: from customer (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id 8A0AF161E1; Sat, 26 Oct 2024 13:45:44 +0200 (CEST) From: Jonas Bernoulli To: Ihor Radchenko Cc: =?utf-8?Q?Tor-bj=C3=B6rn?= Claesson , emacs-orgmode@gnu.org Subject: Re: Org-cite: Replace basic follow-processor with transient menu? In-Reply-To: <87bjz9o188.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> <87r085vb1s.fsf@bernoul.li> <87bjz9o188.fsf@localhost> Date: Sat, 26 Oct 2024 13:45:43 +0200 Message-ID: <87r0839jfc.fsf@bernoul.li> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=212.243.197.30; envelope-from=jonas@bernoul.li; helo=mail.hostpark.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.51 X-Spam-Score: -2.51 X-Migadu-Queue-Id: D197B73A64 X-Migadu-Scanner: mx10.migadu.com X-TUID: /Y56cmxtqqj7 Ihor Radchenko writes: > Jonas Bernoulli writes: > >>> :set (lambda (option-name new-value) >>> (eval >>> `(transient-define-prefix org-cite-basic-follow (citation &optional prefix) >>> "Follow a citation reference. >> ... >> >> (transient-define-prefix org-cite-basic-follow (citation &optional prefix) >> [org-cite-basic-follow-actions] >> ... > > This is more compact indeed. Thanks! > >> I use something similar in Forge (forge--lists-group et al.), but >> there the purpose is to share groups between different prefixes, not >> to make them customizable. > > And this is the problem. See the above :set we have to add in order to > re-evaluate the prefix definition. > > It would be nice if the layout could be calculated dynamically rather > than frozen in place in the "defun". Look at notmuch-tag-transient from notmuch-transient.el [1]. It does exactly that. I.e., the :setup-children slot is what you are looking for. [1] https://github.com/tarsius/notmuch-transient >> To let users choose what commands to offer in the menu, I would >> recommend directing users towards Transient's "layer" mechanism instead >> of adding an option. >> >> See [[info:transient#Enabling and Disabling Suffixes]]. To try it enter >> any prefix (magit-diff would do) and type "C-x l". Usage information is >> displayed after that. > > This will indeed help with customizing *pre-existing suffixes*. However, > what we really want here is different - we want a minimal set of > suffixes to be provided by Org mode, and more suffixes to be contributed > by individual packages or by users themselves. > > In other words, we need some way to add new suffixes to the > org-cite-basic-follow prefix menu. The recommended way of adding bindings is transient-insert-suffix, but that won't work here because of the "we need to wrap the command" issue. >>> :scope (list citation prefix) >> >> Shouldn't that be just be >> :scope citation >> and then >> (interactive (list (magit-scope))) >> to access it? > > We want the [suffix] commands to have information about the prefix argument used > to call `org-cite-basic-follow'. I asked because none of the provided examples actually used that information (or maybe I just overlooked that). But sure, if that information is needed, then that's the way to provide it. >> Yes, obviously you have to call transient-scope somewhere. >> >> I haven't seen enough of the commands you want to add as suffixes to >> know whether it would make sense, and is even possible, to add an >> abstraction, and the few examples I have seen already contain >> non-commands and "find as pdf" doesn't even exist as a named function. >> >> That being said, if there are multiple commands like >> >> (defun do-something-with-citation (citation) >> (interactive (list (read-citation "Do something with citation: "))) >> ...) >> >> it might make sense to change read-citation like this >> >> (defun read-citation (prompt) >> (if (eq transient-current-prefix 'org-cite-basic-follow) >> (org-element-property :key (transient-scope)) >> ...old body here...)) > > This is precisely what I want to avoid. I don't think I got my point across. I am not saying that you should modify the interactive form of every command, or each command's individual reader function. Instead I am saying that IFF "all" of these commands already happen to use the same reader function, then it would make sense to trivially address the issue by adding the following two lines to that reader, and be done with it. (defun read-citation (prompt) + (if (eq transient-current-prefix 'org-cite-basic-follow) + (org-element-property :key (transient-scope) ...old body here...)) But that doesn't seem to be the case, so... > What we want is having normal commands/functions and then allowing to > add them as suffixes without having to change their interactive spec or > source code in general. > > Currently, if we want suffix that is calling a function not specially > designed with transient support in mind, we need to do the ugly juggle > like (That code was unreadable in my mua, so I am trimming it to the relevant part.) > [["Open" > ("b" "bibliography entry" org-cite-basic-goto > :args (transient-args))]] I was planning to suggest something vaguely along those lines, after confirming that the "slightly modify the universally used reader" approach above, turns out to not be applicable. Adding a new slot for that makes sense but would need a new class. See the `forge--topic-set-state-command' class and the commands that use it, for an example where I felt that approach makes sense. But the approach I used for `notmuch-tag-transient' is more applicable here. Hm, that actually also adds a new class, which we *might* be able to avoid here, let's look at the simpler `notmuch-search-transient' for inspiration. [Obviously completely untested:] (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 (...))]] ...) (transient-define-prefix org-cite-basic-follow (citation &optional prefix) [:class transient-column :setup-children org-cite-basic-follow--setup :pad-keys t] (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))) (defun org-cite-basic-follow--setup (_) (transient-parse-suffixes 'notmuch-search-transient (mapcar (pcase-lambda (`(,key ,desc ,fn ,transform)) (list ,key ,desc (lambda () (interactive) (apply fn (eval transform))))) org-cite-basic-follow-actions))) Cheers, Jonas