Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add table name #349

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion org-ql-search.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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))
Expand Down