From eab43b342ee1e63e07e5d6bee5efa8180747f975 Mon Sep 17 00:00:00 2001 From: Shariff Faleel Date: Tue, 10 Oct 2023 15:23:26 -0700 Subject: [PATCH] Add sort to dynamic block --- README.org | 1 + org-roam-ql.el | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 32cdcf1..7e9256d 100644 --- a/README.org +++ b/README.org @@ -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-~, which takes an org-roam-node as a parameter, ~~ 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. diff --git a/org-roam-ql.el b/org-roam-ql.el index 6dce686..06c1913 100644 --- a/org-roam-ql.el +++ b/org-roam-ql.el @@ -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