summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin J. Foley <kevin@kevinjfoley.me>2021-02-13 12:04:38 -0500
committerKyle Meyer <kyle@kyleam.com>2021-02-14 21:53:14 -0500
commit885ee086dde4ec2a9e303ff101e55d55c4b2363f (patch)
treefe4c68921881afa70a8db899eac9b67a257a1323
parente0fb2339f41fdf971915121faffbad9b4667a91b (diff)
downloadorg-mode-885ee086dde4ec2a9e303ff101e55d55c4b2363f.tar.gz
org-agenda.el: Support argument collection for custom bulk functions
* lisp/org-agenda.el (org-agenda-bulk-custom-functions): Add documentation about argument collection for custom bulk functions. (org-agenda-bulk-action): Support function to collect arguments for custom bulk functions. * etc/ORG-NEWS (Option ~org-agenda-bulk-custom-functions~ now supports collecting bulk arguments): Add entry to NEWS.
-rw-r--r--etc/ORG-NEWS6
-rw-r--r--lisp/org-agenda.el35
2 files changed, 34 insertions, 7 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 02bd42b..f95a568 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -88,6 +88,12 @@ New variable ~org-html-meta-tags~ makes it possible to customize the
values, or a function that generates such a list (see
~org-html-meta-tags-default~ as an example of the latter).
+*** Option ~org-agenda-bulk-custom-functions~ now supports collecting bulk arguments
+
+When specifying a custom agenda bulk option, you can now also specify
+a function which collects the arguments to be used with each call to
+the custom function.
+
** New features
*** =ob-python= improvements to =:return= header argument
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index b9799d2..3a6e4f6 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2080,9 +2080,25 @@ For example, this value makes those two functions available:
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."
- :type '(alist :key-type character :value-type (group function))
- :version "24.1"
+Note that functions in this alist don't need to be quoted.
+
+You can also specify a function which collects arguments to be
+used for each call to your bulk custom function. The argument
+collecting function will be run once and should return a list of
+arguments to pass to the bulk function. For example:
+
+ \\='((?R set-category get-category))
+
+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 :tag "Bulk Custom Function")
+ (choice (function :tag "Bulk Custom Argument Function")
+ (const :tag "No Bulk Custom Argument Function" nil))))
+ :package-version '(Org . "9.5")
:group 'org-agenda)
(defmacro org-agenda-with-point-at-orig-entry (string &rest body)
@@ -10487,10 +10503,15 @@ The prefix arg is passed through to the command if possible."
(completing-read "Function: " obarray #'fboundp t nil nil))))
(action
- (pcase (assoc action org-agenda-bulk-custom-functions)
- (`(,_ ,f) (setq cmd f) (setq redo-at-end t))
- (_ (user-error "Invalid bulk action: %c" action)))))
-
+ (setq cmd
+ (pcase (assoc action org-agenda-bulk-custom-functions)
+ (`(,_ ,fn)
+ fn)
+ (`(,_ ,fn ,arg-fn)
+ (apply #'apply-partially fn (funcall arg-fn)))
+ (_
+ (user-error "Invalid bulk action: %c" action))))
+ (setq redo-at-end t)))
;; Sort the markers, to make sure that parents are handled
;; before children.
(setq entries (sort entries