From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id CLKgNgCKCWBOZgAA0tVLHw (envelope-from ) for ; Thu, 21 Jan 2021 14:04:48 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 8Mp2MgCKCWAQWQAAbx9fmQ (envelope-from ) for ; Thu, 21 Jan 2021 14:04:48 +0000 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 530E294043A for ; Thu, 21 Jan 2021 14:04:48 +0000 (UTC) Received: from localhost ([::1]:46776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2aZq-0003Jg-3N for larch@yhetil.org; Thu, 21 Jan 2021 09:04:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2aX5-0002G7-Dl for emacs-orgmode@gnu.org; Thu, 21 Jan 2021 09:01:56 -0500 Received: from mout-p-202.mailbox.org ([2001:67c:2050::465:202]:55794) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1l2aX0-0000xS-W1 for emacs-orgmode@gnu.org; Thu, 21 Jan 2021 09:01:53 -0500 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4DM3wS5RPRzQlHB; Thu, 21 Jan 2021 15:01:44 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id 9PuIVdKCImEK; Thu, 21 Jan 2021 15:01:38 +0100 (CET) From: Kevin Foley To: Ihor Radchenko , emacs-orgmode@gnu.org Subject: Re: [PATCH] Org Agenda Support Argument Collection for Custom Bulk Functions (was: Custom Bulk Functions With Prompt) In-Reply-To: <87v9bsumpb.fsf@localhost> References: <871rekxgpf.fsf@localhost> <87lfcrvvro.fsf@localhost> <878s8qwrvb.fsf@localhost> <87v9bsumpb.fsf@localhost> Date: Thu, 21 Jan 2021 09:01:35 -0500 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-MBO-SPAM-Probability: X-Rspamd-Score: -5.15 / 15.00 / 15.00 X-Rspamd-Queue-Id: B93581831 X-Rspamd-UID: 04dfa2 Received-SPF: pass client-ip=2001:67c:2050::465:202; envelope-from=kevin@kevinjfoley.me; helo=mout-p-202.mailbox.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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.23 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" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.35 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 530E294043A X-Spam-Score: -2.35 X-Migadu-Scanner: scn1.migadu.com X-TUID: XHldtoIxvfGR --=-=-= Content-Type: text/plain Attached patch should allow user to specify a function to collect arguments when calling a custom bulk function such that those arguments are only collected once and used for each entry. Kevin Foley --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-agenda.el-Support-argument-collection-for-custom.patch >From dfab64f738f227691d84a2fdec5bba2cf4f1e3b0 Mon Sep 17 00:00:00 2001 From: "Kevin J. Foley" Date: Thu, 21 Jan 2021 08:48:52 -0500 Subject: [PATCH] org-agenda.el: Support argument collection for custom bulk functions * lisp/org-agenda.el: (org-agenda-bulk-custom-functions): Add documentation about for collection arguments for custom bulk functions. (org-agenda-bulk-action): Support function to collect arguments for custom bulk functions. --- lisp/org-agenda.el | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index dedf7e5bb..deadacc1e 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2080,7 +2080,20 @@ (defcustom org-agenda-bulk-custom-functions nil With selected entries in an agenda buffer, `B R' will call the custom function `set-category' on the selected entries. -Note that functions in this alist don't need to be quoted." +Note that functions in this alist don't need to be quoted. + +If the custom function accepts arguments which you'd like to +collect once from the user to be used for each call, you can pass +a list with the bulk function, and the function which collects +it's arguments and returns them as a list. For example: + + \\='((?R (set-category get-category)) + (?C bulk-cut)) + +Now, `B R' will call the custom `get-category' which would prompt +the user once for a category. That category is then passed as an +argument to `set-category' for each entry it's called against. +" :type '(alist :key-type character :value-type (group function)) :version "24.1" :group 'org-agenda) @@ -10487,7 +10500,12 @@ (defun org-agenda-bulk-action (&optional arg) (action (pcase (assoc action org-agenda-bulk-custom-functions) - (`(,_ ,f) (setq cmd f) (setq redo-at-end t)) + (`(,_ ,f) + (when (listp f) + (let ((args (funcall (nth 1 f))) + (func (nth 0 f))) + (setq f (apply #'apply-partially func args)))) + (setq cmd f) (setq redo-at-end t)) (_ (user-error "Invalid bulk action: %c" action))))) ;; Sort the markers, to make sure that parents are handled -- 2.28.0 --=-=-=--