Merge commit 'pullreqs/212' into feature/file-dynamic-blocks
This commit is contained in:
commit
773fd9c01e
1 changed files with 16 additions and 3 deletions
|
|
@ -242,6 +242,15 @@ automatically from the query."
|
|||
"Insert content for org-ql dynamic block at point according to PARAMS.
|
||||
Valid parameters include:
|
||||
|
||||
:scope The scope to consider for the Org QL query. This can
|
||||
be one of the following:
|
||||
|
||||
`buffer' the current buffer
|
||||
`org-agenda-files' all agenda files
|
||||
`org-directory' all org files
|
||||
`(list-of-files ...)' a list of org files
|
||||
`all' all agenda files, and org-mode buffers
|
||||
|
||||
:query An Org QL query expression in either sexp or string
|
||||
form.
|
||||
|
||||
|
|
@ -271,14 +280,18 @@ Valid parameters include:
|
|||
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\""
|
||||
(-let* (((&plist :query :columns :sort :ts-format :take :file) params)
|
||||
(-let* (((&plist :scope :query :columns :sort :ts-format :take) params)
|
||||
(query (cl-etypecase 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.
|
||||
(org-ql--ask-unsafe-query query)
|
||||
query)))
|
||||
(columns (or columns '(heading todo (priority "P"))))
|
||||
(file (or file (current-buffer)))
|
||||
(scope (cond ((listp scope) scope)
|
||||
((string-equal scope "org-agenda-files") (org-agenda-files))
|
||||
((or (not scope) (string-equal scope "buffer")) (current-buffer))
|
||||
((string-equal scope "org-directory") (org-ql-search-directories-files))
|
||||
(t (user-error "Unknown scope '%s'" scope))))
|
||||
;; MAYBE: Custom column functions.
|
||||
(format-fns
|
||||
;; NOTE: Backquoting this alist prevents the lambdas from seeing
|
||||
|
|
@ -303,7 +316,7 @@ For example, an org-ql dynamic block header could look like:
|
|||
(ts-format ts-format (ts-parse-org-element it)))))
|
||||
(cons 'property (lambda (element property)
|
||||
(org-element-property (intern (concat ":" (upcase property))) element)))))
|
||||
(elements (org-ql-query :from file
|
||||
(elements (org-ql-query :from scope
|
||||
:where query
|
||||
:select '(org-element-headline-parser (line-end-position))
|
||||
:order-by sort)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue