Skip to content

Commit

Permalink
Add sort to dynamic block
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-shariff committed Oct 10, 2023
1 parent 7a03ef0 commit eab43b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ There are two ways to add a new predicate to org-roam-ql:
Similar to ~org-ql~, ~org-roam-ql~ also provides a dynamic block. The header parameters are as follows:
- ~:query~ - A valid [[#valid-values-for-source-or-query][ ~SOURCE-OR-QUERY~ ]]
- ~:columns~ - A list of columns to display. Each column name is a slot name of ~org-roam-nodes~. For any function/accessor with a name of the form ~org-roam-node-<name>~, which takes an org-roam-node as a parameter, ~<name>~ can also be used column name. For example, if there is a function named ~org-roam-node-short-title~, ~short-title~ can be used as a column name, this will result in a column with the title ~short-title~ where the content of each row is the result of calling the respective function.
- ~:sort~ - Name of a registered sort functions. See [[#commandsfunctions][ ~org-roam-ql-search~ ]] for more info on the values for sort functions.
- ~:take~ (optional) - If a positive integer N, take the first N elements, if a negative -N, take the last N nodes.
- ~:no-link~ (optional) - If a non-nil value is set, the first column containing the links will be dropped.

Expand Down
3 changes: 2 additions & 1 deletion org-roam-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -913,10 +913,11 @@ If there are entries that do not have an ID, it will signal an error"
"Write org block for org-roam-ql with PARAMS."
(let ((query (plist-get params :query))
(columns (plist-get params :columns))
(sort (plist-get params :sort))
(take (plist-get params :take))
(no-link (plist-get params :no-link)))
(if (and query columns)
(-if-let (nodes (org-roam-ql-nodes query))
(-if-let (nodes (org-roam-ql-nodes query sort))
(progn
(when take
(setq nodes (cl-etypecase take
Expand Down

0 comments on commit eab43b3

Please sign in to comment.