Kevin Foley writes: > Kyle Meyer <k...@kyleam.com> writes: > >> (setq org-agenda-bulk-custom-functions >> '((?D my/bulk-action) >> (?E (my/bulk-action)) >> (?F (my/bulk-action my/args)))) >> However, customize doesn't render the above value properly [...] > Side note I'm not sure your example would render properly regardless > since `my/bulk-action' and `my/args' aren't functions.
I'm confused by this. They were defined just above the text you quoted: (defun my/bulk-action (&rest args) args) (defun my/args () (list 1 2 3)) (setq org-agenda-bulk-custom-functions [...] Either way, your latest defcustom type as well as the rest of the update, aside from the issue I note below, looks good to me. Thanks. > @@ -10486,10 +10502,14 @@ (defun org-agenda-bulk-action (&optional arg) > (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))))) > - > + (pcase-let (`(,_ ,fn ,arg-fn) > + (assoc action org-agenda-bulk-custom-functions)) > + (if (not fn) > + (user-error "Invalid bulk action: %c" action) > + (when (functionp arg-fn) > + (setq fn (apply #'apply-partially fn (funcall arg-fn)))) > + (setq cmd fn) > + (setq redo-at-end t))))) Aren't the pcase-let bindings missing a set of parentheses? (pcase-let (`(,_ ,fn ,arg-fn) (list 1 2 3)) (list fn arg-fn)) ; let: Invalid function: (\, _) (pcase-let ((`(,_ ,fn ,arg-fn) (list 1 2 3))) (list fn arg-fn)) ; => (2 3) However, I don't see using pcase-let here as an improvement. Admittedly it's mostly subjective, but I think it's unhelpfully permissive for this use case: (pcase-let ((`(,a ,b) (list 1 2 3 4))) (list a b)) ; => (1 2) Fwiw, here's a relevant emacs.devel thread: https://lists.gnu.org/archive/html/emacs-devel/2015-07/msg00103.html (message ID: <jwvegkfoniv.fsf-monnier+em...@gnu.org>) My pcase-based suggestion, on top of your patch, is below. If that looks okay to you, there's no need to resend; I can squash it in. diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 42d127232..d6499e6b0 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -10502,14 +10502,15 @@ (defun org-agenda-bulk-action (&optional arg) (completing-read "Function: " obarray #'fboundp t nil nil)))) (action - (pcase-let (`(,_ ,fn ,arg-fn) - (assoc action org-agenda-bulk-custom-functions)) - (if (not fn) - (user-error "Invalid bulk action: %c" action) - (when (functionp arg-fn) - (setq fn (apply #'apply-partially fn (funcall arg-fn)))) - (setq cmd fn) - (setq redo-at-end t))))) + (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