ENH dynamical scope files list on each series call

This commit is contained in:
Nathan Dwarshuis 2021-12-28 16:35:48 -05:00
parent 11f8d3a48a
commit 0e61accb0a
1 changed files with 14 additions and 4 deletions

View File

@ -2940,18 +2940,28 @@ original function being advised and ARGS are the arguments."
(:active . 3) (:active . 3)
(:inert . 4))) (:inert . 4)))
(defun org-x-agenda-run-series-advice (fun name settings)
(-if-let (org-agenda-files (->> (nth 1 settings)
(alist-get 'org-agenda-files)
(car)
(eval)))
(funcall fun name settings)
(funcall fun name settings)))
(advice-add #'org-agenda-run-series :around #'org-x-agenda-run-series-advice)
(defun nd/org-agenda-call (name type match files settings) (defun nd/org-agenda-call (name type match files settings)
(declare (indent 4)) (declare (indent 4))
(-let* (((bname hname) (pcase name (-let* (((bname hname) (pcase name
(`(,b ,h) (list b h)) (`(,b ,h) (list b h))
((and s (pred stringp)) (list s s)) ((and s (pred stringp)) (list s s))
(e (error "Invalid agenda name spec: %s" e)))) (e (error "Invalid agenda name spec: %s" e))))
(s `((org-agenda-files ',files) (s `((org-agenda-overriding-header ,hname)
(org-agenda-overriding-header ,hname)
,@settings))) ,@settings)))
(catch 'exit (catch 'exit
(let ((org-agenda-buffer-name (format "*Agenda: %s" bname))) (let ((org-agenda-buffer-name (format "*Agenda: %s*" bname)))
(org-agenda-run-series name `(((,type ,match ,s)))))))) (org-agenda-run-series name `(((,type ,match ,s))
((org-agenda-files ',files))))))))
(defun nd/org-agenda-call-agenda (name files settings) (defun nd/org-agenda-call-agenda (name files settings)
(declare (indent 2)) (declare (indent 2))