feat - Added option to set table name
Allows the table to be referenced. Optional string.
This commit is contained in:
parent
1d98c7d07c
commit
0ba63291a3
1 changed files with 6 additions and 1 deletions
|
|
@ -296,13 +296,16 @@ Valid parameters include:
|
|||
:ts-format Optional format string used to format
|
||||
timestamp-based columns.
|
||||
|
||||
:table-name Optional string. If non-nil, add `#+tblname: <name>'
|
||||
before the table. Allowing it to be referenced.
|
||||
|
||||
For example, an org-ql dynamic block header could look like
|
||||
this (must be a single line in the Org buffer):
|
||||
|
||||
#+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 :table-name) 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.
|
||||
|
|
@ -353,6 +356,8 @@ this (must be a single line in the Org buffer):
|
|||
""))
|
||||
" | ")))
|
||||
;; Table header
|
||||
(if table-name
|
||||
(insert (concat "#+tblname: " (format "%s" table-name) "\n")))
|
||||
(insert "| " (string-join (--map (pcase it
|
||||
((pred symbolp) (capitalize (symbol-name it)))
|
||||
(`(,_ ,name) name))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue