Skip to content

Commit

Permalink
Allow :file parameter in org-ql dynamic blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
yantar92 committed Aug 8, 2021
1 parent 94f9e6f commit fb9591e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions org-ql-search.el
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,14 @@ 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) params)
(-let* (((&plist :query :columns :sort :ts-format :take :file) 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)))
;; MAYBE: Custom column functions.
(format-fns
;; NOTE: Backquoting this alist prevents the lambdas from seeing
Expand All @@ -299,7 +300,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 (current-buffer)
(elements (org-ql-query :from file
:where query
:select '(org-element-headline-parser (line-end-position))
:order-by sort)))
Expand Down

0 comments on commit fb9591e

Please sign in to comment.