rename scope to buffers-files
This commit is contained in:
parent
020128feae
commit
1134f47f5c
1 changed files with 22 additions and 22 deletions
|
|
@ -242,15 +242,15 @@ automatically from the query."
|
||||||
"Insert content for org-ql dynamic block at point according to PARAMS.
|
"Insert content for org-ql dynamic block at point according to PARAMS.
|
||||||
Valid parameters include:
|
Valid parameters include:
|
||||||
|
|
||||||
:scope The scope to consider for the Org QL query. This can
|
:buffers-files The buffers or files to consider for the Org QL
|
||||||
be one of the following:
|
query. This can be one of the following:
|
||||||
|
|
||||||
`buffer' the current buffer
|
`buffer' the current buffer
|
||||||
`all' all agenda files, and org-mode buffers
|
`all' all 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
|
||||||
`\"path\"' a single file name
|
`\"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.
|
||||||
|
|
@ -281,25 +281,25 @@ Valid parameters include:
|
||||||
For example, an org-ql dynamic block header could look like:
|
For example, an org-ql dynamic block header could look like:
|
||||||
|
|
||||||
#+BEGIN: org-ql :query (todo \"UNDERWAY\") :columns (priority todo heading) :sort (priority date) :ts-format \"%Y-%m-%d %H:%M\""
|
#+BEGIN: org-ql :query (todo \"UNDERWAY\") :columns (priority todo heading) :sort (priority date) :ts-format \"%Y-%m-%d %H:%M\""
|
||||||
(-let* (((&plist :scope :query :columns :sort :ts-format :take) params)
|
(-let* (((&plist :buffers-files :query :columns :sort :ts-format :take) params)
|
||||||
(query (cl-etypecase query
|
(query (cl-etypecase query
|
||||||
(string (org-ql--query-string-to-sexp query))
|
(string (org-ql--query-string-to-sexp query))
|
||||||
(list ;; SAFETY: Query is in sexp form: ask for confirmation, because it could contain arbitrary code.
|
(list ;; SAFETY: Query is in sexp form: ask for confirmation, because it could contain arbitrary code.
|
||||||
(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 (pcase scope
|
(buffers-files (pcase buffers-files
|
||||||
('buffer (current-buffer))
|
('buffer (current-buffer))
|
||||||
('all (--select (equal (buffer-local-value 'major-mode it) 'org-mode)
|
('all (--select (equal (buffer-local-value 'major-mode it) 'org-mode)
|
||||||
(buffer-list)))
|
(buffer-list)))
|
||||||
('org-agenda-files (org-agenda-files))
|
('org-agenda-files (org-agenda-files))
|
||||||
('org-directory (org-ql-search-directories-files))
|
('oorg-directory (org-ql-search-directories-files))
|
||||||
((and (pred listp) (pred seq-every-p #'stringp)) scope)
|
((and (pred listp) (pred seq-every-p #'stringp)) buffers-files)
|
||||||
((pred stringp)
|
((pred stringp)
|
||||||
(if (file-directory-p scope)
|
(if (file-directory-p buffers-files)
|
||||||
(directory-files-recursively scope "\\.org$")
|
(directory-files-recursively buffers-files "\\.org$")
|
||||||
scope))
|
buffers-files))
|
||||||
(_ (user-error "Unknown scope '%s'" scope))))
|
(_ (user-error "Unknown buffers-files '%s'" buffers-files))))
|
||||||
;; 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
|
||||||
|
|
@ -334,7 +334,7 @@ For example, an org-ql dynamic block header could look like:
|
||||||
(ts-format ts-format (ts-parse-org-element it)))))
|
(ts-format ts-format (ts-parse-org-element it)))))
|
||||||
(cons 'property (lambda (element property)
|
(cons 'property (lambda (element property)
|
||||||
(org-element-property (intern (concat ":" (upcase property))) element)))))
|
(org-element-property (intern (concat ":" (upcase property))) element)))))
|
||||||
(elements (org-ql-query :from scope
|
(elements (org-ql-query :from buffers-files
|
||||||
:where query
|
:where query
|
||||||
:select '(org-element-put-property (org-element-headline-parser (line-end-position)) :file (buffer-file-name))
|
:select '(org-element-put-property (org-element-headline-parser (line-end-position)) :file (buffer-file-name))
|
||||||
:order-by sort)))
|
:order-by sort)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue