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

Added an option to not format headings as links #348

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
17 changes: 11 additions & 6 deletions org-ql-search.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))))))
OZoneGuy marked this conversation as resolved.
Show resolved Hide resolved
(items (org-ql-select from query
:action 'element-with-markers
:narrow narrow-p)))
Expand Down Expand Up @@ -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.

OZoneGuy marked this conversation as resolved.
Show resolved Hide resolved
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)
: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))
(list ;; SAFETY: Query is in sexp form: ask for confirmation, because it could contain arbitrary code.
Expand All @@ -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))))))
OZoneGuy marked this conversation as resolved.
Show resolved Hide resolved
(cons 'priority (lambda (element)
(--when-let (org-element-property :priority element)
(char-to-string it))))
Expand Down