From 4e1d8f458d152a0ecf012e51e9720b89b0661d5f Mon Sep 17 00:00:00 2001 From: OZoneGuy Date: Wed, 19 Apr 2023 04:57:30 -0400 Subject: [PATCH 1/4] feat - Added an option to not format headings as links For the dynamic block --- org-ql-search.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index b029544d..91e6e404 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -229,10 +229,10 @@ automatically from the query." ('nil (org-agenda-files nil 'ifmode)) (_ (prog1 org-agenda-restrict (with-current-buffer org-agenda-restrict - ;; Narrow the buffer; remember to widen it later. - (setf old-beg (point-min) old-end (point-max) + ;; Narrow the buffer; remember to widen it later. + (setf old-beg (point-min) old-end (point-max) narrow-p t) - (narrow-to-region org-agenda-restrict-begin org-agenda-restrict-end)))))) + (narrow-to-region org-agenda-restrict-begin org-agenda-restrict-end)))))) (items (org-ql-select from query :action 'element-with-markers :narrow narrow-p))) @@ -296,13 +296,16 @@ Valid parameters include: :ts-format Optional format string used to format timestamp-based columns. + :not-links Optional boolean. If non-nil, don't make headings + into links. + 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 :not-links) 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. @@ -318,7 +321,9 @@ this (must be a single line in the Org buffer): (cons 'heading (lambda (element) (let ((normalized-heading (org-ql-search--link-heading-search-string (org-element-property :raw-value element)))) - (org-ql-search--org-make-link-string normalized-heading (org-link-display-format normalized-heading))))) + (if not-links + normalized-heading + (org-ql-search--org-make-link-string normalized-heading (org-link-display-format normalized-heading)))))) (cons 'priority (lambda (element) (--when-let (org-element-property :priority element) (char-to-string it)))) From 59e4a831c066a808fe6dd8541a1b3f34070925a1 Mon Sep 17 00:00:00 2001 From: OZoneGuy Date: Wed, 19 Apr 2023 05:03:33 -0400 Subject: [PATCH 2/4] docs - Added option to the example query --- org-ql-search.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-ql-search.el b/org-ql-search.el index 91e6e404..be7ff22c 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -304,7 +304,7 @@ 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\"" +:ts-format \"%Y-%m-%d %H:%M\" :not-links t" (-let* (((&plist :query :columns :sort :ts-format :take :not-links) params) (query (cl-etypecase query (string (org-ql--query-string-to-sexp query)) From c63250072713474f1c280fce6fa4708019a31142 Mon Sep 17 00:00:00 2001 From: OZoneGuy Date: Sun, 7 Jan 2024 18:11:14 -0500 Subject: [PATCH 3/4] chore: undo white space changes --- org-ql-search.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index be7ff22c..a63779c3 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -229,10 +229,10 @@ automatically from the query." ('nil (org-agenda-files nil 'ifmode)) (_ (prog1 org-agenda-restrict (with-current-buffer org-agenda-restrict - ;; Narrow the buffer; remember to widen it later. - (setf old-beg (point-min) old-end (point-max) + ;; Narrow the buffer; remember to widen it later. + (setf old-beg (point-min) old-end (point-max) narrow-p t) - (narrow-to-region org-agenda-restrict-begin org-agenda-restrict-end)))))) + (narrow-to-region org-agenda-restrict-begin org-agenda-restrict-end)))))) (items (org-ql-select from query :action 'element-with-markers :narrow narrow-p))) From 1e1469b8b35fb3988e05e997e5991d4e55cc848e Mon Sep 17 00:00:00 2001 From: OZoneGuy Date: Mon, 8 Jan 2024 18:30:17 -0500 Subject: [PATCH 4/4] refact: renamed property to `link` --- org-ql-search.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/org-ql-search.el b/org-ql-search.el index a63779c3..79986776 100644 --- a/org-ql-search.el +++ b/org-ql-search.el @@ -296,16 +296,17 @@ Valid parameters include: :ts-format Optional format string used to format timestamp-based columns. - :not-links Optional boolean. If non-nil, don't make headings - into links. + :link Optional flag. Defaults to `t`. When non-nil, links + are displayed as links, otherwise they are displayed + as plain text. 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\" :not-links t" - (-let* (((&plist :query :columns :sort :ts-format :take :not-links) params) +:ts-format \"%Y-%m-%d %H:%M\" :link t" + (-let* (((&plist :query :columns :sort :ts-format :take :link) 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. @@ -321,9 +322,9 @@ this (must be a single line in the Org buffer): (cons 'heading (lambda (element) (let ((normalized-heading (org-ql-search--link-heading-search-string (org-element-property :raw-value element)))) - (if not-links - normalized-heading - (org-ql-search--org-make-link-string normalized-heading (org-link-display-format normalized-heading)))))) + (pcase links + (t (org-ql-search--org-make-link-string normalized-heading (org-link-display-format normalized-heading))) + (nil normalized-heading))))) (cons 'priority (lambda (element) (--when-let (org-element-property :priority element) (char-to-string it))))