accept a single file name in :scope

This commit is contained in:
bhuztez 2022-08-22 21:22:37 +08:00
parent 03349193da
commit 020128feae

View file

@ -246,10 +246,11 @@ Valid parameters include:
be one of the following: be one of the following:
`buffer' the current buffer `buffer' the current buffer
`all' all agenda files, and org-mode buffers
`org-agenda-files' all agenda files `org-agenda-files' all agenda files
`org-directory' all org files `org-directory' all org files
`(\"path\" ...)' list of buffer names or file paths `(\"path\" ...)' list of buffer names or file paths
`all' all agenda files, and org-mode buffers `\"path\"' a single file name
:query An Org QL query expression in either sexp or string :query An Org QL query expression in either sexp or string
form. form.
@ -287,11 +288,18 @@ For example, an org-ql dynamic block header could look like:
(org-ql--ask-unsafe-query query) (org-ql--ask-unsafe-query query)
query))) query)))
(columns (or columns '(heading todo (priority "P")))) (columns (or columns '(heading todo (priority "P"))))
(scope (cond ((and (listp scope) (seq-every-p #'stringp scope)) scope) (scope (pcase scope
((string-equal scope "org-agenda-files") (org-agenda-files)) ('buffer (current-buffer))
((or (not scope) (string-equal scope "buffer")) (current-buffer)) ('all (--select (equal (buffer-local-value 'major-mode it) 'org-mode)
((string-equal scope "org-directory") (org-ql-search-directories-files)) (buffer-list)))
(t (user-error "Unknown scope '%s'" scope)))) ('org-agenda-files (org-agenda-files))
('org-directory (org-ql-search-directories-files))
((and (pred listp) (pred seq-every-p #'stringp)) scope)
((pred stringp)
(if (file-directory-p scope)
(directory-files-recursively scope "\\.org$")
scope))
(_ (user-error "Unknown scope '%s'" scope))))
;; MAYBE: Custom column functions. ;; MAYBE: Custom column functions.
(format-fns (format-fns
;; NOTE: Backquoting this alist prevents the lambdas from seeing ;; NOTE: Backquoting this alist prevents the lambdas from seeing