Skip to content
Open
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
45 changes: 35 additions & 10 deletions org-ql-search.el
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,37 @@ Valid parameters include:
form.

:columns A list of columns, including `heading', `todo',
`property',`priority',`deadline',`scheduled',`closed'.
Each column may also be specified as a list with the
second element being a header string. For example,
to abbreviate the priority column: (priority \"P\").
For certain columns, like `property', arguments may
be passed by specifying the column type itself as a
list. For example, to display a column showing the
values of a property named \"milestone\", with the
header being abbreviated to \"M\":
`property', `priority', `deadline', `scheduled',
`closed', `custom'. Each column may also be
specified as a list with the second element being a
header string. For example, to abbreviate the
priority column: (priority \"P\"). For certain
columns, like `property', arguments may be passed
by specifying the column type itself as a list. For
example, to display a column showing the values of
a property named \"milestone\", with the header
being abbreviated to \"M\":

((property \"milestone\") \"M\").

For a `custom' column, the first argument is a
function, followed by any arguments to that
function. A header string is required:

((custom my-func \"arg\") \"MyHeading\").

The custom function must return a string.

Note that the first argument passed to the custom
function will be the Org element of the matched
heading. So the function above will run as:

(my-func element \"arg\")

The alist of column lambdas in this function are
useful starting points for writing your own custom
column functions.

:sort One or a list of Org QL sorting methods
(see `org-ql-select').

Expand Down Expand Up @@ -345,7 +364,13 @@ this (must be a single line in the Org buffer):
(--when-let (org-element-property :closed element)
(ts-format ts-format (ts-parse-org-element it)))))
(cons 'property (lambda (element property)
(org-element-property (intern (concat ":" (upcase property))) element)))))
(org-element-property (intern (concat ":" (upcase property))) element)))
(cons 'custom (lambda (element func &rest args)
(let ((result (apply func element args)))
(if (stringp result)
result
(error "org-dblock-write:org-ql: Custom column %s must return a string"
(if (symbolp func) func "lambda"))))))))
(elements (org-ql-query :from (current-buffer)
:where query
:select '(org-ql-view--resolve-element-properties
Expand Down