From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.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 GAV4CzyRJGeWCAAAe85BDQ:P1 (envelope-from ) for ; Fri, 01 Nov 2024 08:28:44 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id GAV4CzyRJGeWCAAAe85BDQ (envelope-from ) for ; Fri, 01 Nov 2024 09:28:44 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ApL+SCGL; dmarc=pass (policy=none) header.from=gmail.com; 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=1730449723; a=rsa-sha256; cv=none; b=H6W+YkSeNKfvyN8271WShsKruhraRbheSFqTQ4hvXa+RnEF7hV2WrThu2Vzuqgcj82VHsX 3rwrA1Xqz3JAcvf3xSuKpmkfUJBmNUWDieRX8PNbXq+6+y/BOxhcU/KJm3v0LjUjIc8AxG iwhi9aMngma/zzJqHE4V04828Vm/8c6n28CJV8DS1g/LEi3wgkfotD+JY8gd1Up7FV91mg SDjjr+J+bNDps+1p2oC03DuJ37zQvLy6jwIeJrFoRqG0EbgJ99dxowKCOjeMlq8iuEVOsX hAUVoPn039KrFAv6njRcpbO4TCFESoK4zQhVLNwibsueuhH5dy/Nv3eIhn/4FQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ApL+SCGL; dmarc=pass (policy=none) header.from=gmail.com; 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=1730449723; 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=X9cr64zTc4RDjtHj3fMcuLgZSb96Py4e3+E47lMwdLM=; b=uLCBS3Sm/Hd4Z9L02oNcwMf2Nv2VlKR942Ts9ZASr+kZ1gIMR92LZ9L8qNNA0EOpEAd3QC ZtsIi7HhwTz4iFfZHkJsHdvkqQkL+NzxoyEIJ0rWMXsQ4strWU+NQBJFDZ3KKrP7jODAJL Hz2FTxY3fqeasRUHA1rqjsra5ypYTrxTgcv6egSjrp2mrmRy6+AWl6KqNXU6a5U4NVcr1t JA25zJ6VWpDRJl1fDGwQ5fYwm9wt6ocYiMSnH1VEKDX0YidlxJnG46XvipedEpxMydOmTJ qAVuO84f/zbfP7Ou6NibLNgOeDQ7Jh8tQ2YtiId6XPKpWxFnpAHzznd3+J6kuw== 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 A00538616F for ; Fri, 01 Nov 2024 09:28:43 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6n0W-0005E2-CZ; Fri, 01 Nov 2024 04:27:48 -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 1t6n0U-0005Dn-Er for emacs-orgmode@gnu.org; Fri, 01 Nov 2024 04:27:46 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t6n0R-0002jW-MJ for emacs-orgmode@gnu.org; Fri, 01 Nov 2024 04:27:45 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5c9709c9b0cso2558357a12.1 for ; Fri, 01 Nov 2024 01:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730449662; x=1731054462; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=X9cr64zTc4RDjtHj3fMcuLgZSb96Py4e3+E47lMwdLM=; b=ApL+SCGLoVPPX787d1JYz0GxL7pOI7vVetBybwJWyI1loe/BM0YRPuYEwoBl3/90zm GTK7bnsa2YxPJcTTyeoixveBGQ1MBiaJr/FnbymWT8bb3dqNzPczZKzKJs9j95vVEU9G nQo275fGDtQ4HE7QfwMwv8XkpGOfUE5wpIrhog1jptQ78a0p13ytCcoZUmhWK1IHO4d8 uNMIZjeXZCmZN301okTo95wNydOEX29XmKEmw2rHSO3wEreUKvzuM0Mrn1T62v4Yr1rQ AZKlaOi3sA9CWwOxHZB4uPjmiEmFJ5npm3Tc5HpRHL4XCfa8SXoxOZnajMnL3o2Mc/nC CCfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730449662; x=1731054462; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X9cr64zTc4RDjtHj3fMcuLgZSb96Py4e3+E47lMwdLM=; b=aR3P9jv92L2vNMW6352XcgwoYcpoYKMX2qq29o3pie18vE+8lCuT1vo0BsKWUIV68u qs/1B2ZEQh3eDV6QyG4TO6Ke22l1VA4DFIOcuteseEAtTIWKfHrFPlJOYvOYfhdZotf0 qjbvEfQx+auiYwyFs4M5KkSzNyfSnbbE1zQiek5NyA0jNOC5ZjprH/P3AZUzvenq9jqi o0GWQzozaTiJenB4wkZTgKliu/sTg96ZvLPit3EpFMJA+kuTlbGdUOqeV0oluAClZ9ck K4ZEpTOpouwone5gFOLnQgYZMlofTIBOdGQ8Vn3EO9bvmhGxNAIINGw82FmTKBYp/g4H 0nfQ== X-Forwarded-Encrypted: i=1; AJvYcCWhrx9Czom/krSfm/3uAr/+A96oHkGYwGN/7SFik+/l1eANv/1zKcCAcep1p1ix0U/h0nZrvrbwTcbk5bR/@gnu.org X-Gm-Message-State: AOJu0Yw/Dj568YNXWTLt1aKFjCE0UElVqmRGhjFxqe2wqX2XUt58texP Jl5LajEASzxNab0+7wyN4KrT6sCPeO4x7E70KBtz1n/gdbbcgQs16wgEZSphkhosW15bQBMFxSA 4pzh/MaS9pbp26rSuN/3sl4y8xyP7XOgC X-Google-Smtp-Source: AGHT+IGbm6tqGIexDdF0rJRSlmOdO6CBDMgGZBO+D089K/boUS7kq+T2PjVXktFHtWaCLMvIIl1k5CcMJntqgknxN0w= X-Received: by 2002:a05:6402:2790:b0:5cb:666e:a3bc with SMTP id 4fb4d7f45d1cf-5cd54a83c33mr8259986a12.10.1730449661725; Fri, 01 Nov 2024 01:27:41 -0700 (PDT) MIME-Version: 1.0 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> <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> In-Reply-To: <87jzdo2e4m.fsf@gmail.com> From: =?UTF-8?Q?Tor=2Dbj=C3=B6rn_Claesson?= Date: Fri, 1 Nov 2024 10:27:30 +0200 Message-ID: Subject: Re: Org-cite: Replace basic follow-processor with transient menu? To: Ihor Radchenko Cc: Jonas Bernoulli , emacs-orgmode@gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=tclaesson@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: -0.49 X-Spam-Score: -0.49 X-Migadu-Queue-Id: A00538616F X-Migadu-Scanner: mx12.migadu.com X-TUID: 4F5J+it6oBS4 But that was not good enough - we do not cover the case of specifying a lambda in org-cite-basic-follow-actions, or passing other arguments to the function than citation, prefix or citation key. This updated version fixes this, so the action can be either 1. a suffix (as in transient-define-suffix) 2. a lambda form (as in (lambda (citation prefix) (interactive (transient-scope)) ...)) 3. a function call, which will be wrapped in the ugly dance-lambda and where !citation, !prefix, and !citation-key will be (recursively) substituted but other arguments preserved. (defun org-cite-basic-follow--process-function-arguments (arguments) (cond ((null arguments) '()) ((atom (car arguments)) (cons (pcase (car arguments) ('!citation '(car (transient-scope))) ('!prefix '(cadr (transient-scope))) ('!citation-key '(org-element-property :key (car (transient-scope)))) (argument argument)) (org-cite-basic-follow--process-function-arguments (cdr arguments= )))) (t (cons (org-cite-basic-follow--process-function-arguments (car arguments= )) (org-cite-basic-follow--process-function-arguments (cdr arguments)))))) (defun org-cite-basic-follow--parse-suffix-specification (specification) (pcase specification ((and (pred stringp) label) label) (`(,key ,desc (lambda . ,fn-args) . ,other) (list key desc `(lambda ,@fn-args) ,other)) (`(,key ,desc (,fn . ,fn-args) . ,other) (let ((function-args (org-cite-basic-follow--process-function-arguments fn-args))) `(,key ,desc (lambda () (interactive) (,fn ,@function-args)) ,other))) (`(,key ,desc ,suffix) (list key desc suffix)))) (defun org-cite-basic-follow--setup (_) (transient-parse-suffixes 'org-cite-basic-follow (cl-map 'vector (lambda (group) (cl-map 'vector #'org-cite-basic-follow--parse-suffix-specific= ation group)) org-cite-basic-follow-actions))) Cheers! Tor-bj=C3=B6rn Den tors 31 okt. 2024 kl 22:48 skrev Tor-bj=C3=B6rn Claesson : > > Thanks! > > Here is another take=3D) > > (defcustom org-cite-basic-follow-actions > '[["Open" > ("b" "bibliography entry" (org-cite-basic-goto !citation !prefix))] > ["Copy" > ("d" "DOI" org-cite-basic-follow.copy-doi)] > ["Browse" > ("u" "url" org-cite-basic-follow.browse-url)]] > "Hepp" > :group 'org-cite > :type 'sexp) > > (transient-define-prefix org-cite-basic-follow (citation &optional prefix= ) > [:class transient-columns > :setup-children org-cite-basic-follow--setup > :pad-keys t] > (interactive) > (if (or org-cite-basic-follow-ask > (eq prefix '(-4))) > (transient-setup 'org-cite-basic-follow nil nil > :scope (list citation prefix)) > (org-cite-basic-goto citation prefix))) > > (defun org-cite-basic-follow--parse-suffix-specification (specification) > (pcase specification > ((and (pred stringp) label) > label) > (`(,key ,desc (,fn . ,fn-args) . ,other) > (let ((function-args > (mapcar > (lambda (arg) > (pcase arg > ('!citation > '(car (transient-scope))) > ('!prefix > '(cadr (transient-scope))) > ('!citation-key > '(org-element-property :key (car (transient-scope)))))) > fn-args))) > `(,key ,desc > (lambda () > (interactive) > (,fn ,@function-args)) > ,other))) > (`(,key ,desc ,suffix) > (list key desc suffix)))) > > (defun org-cite-basic-follow--setup (_) > (transient-parse-suffixes > 'org-cite-basic-follow > (cl-map 'vector > (lambda (group) > (cl-map 'vector > #'org-cite-basic-follow--parse-suffix-specification > group)) > org-cite-basic-follow-actions))) > > Cheers, > Tor-bj=C3=B6rn