:link option and file name options

- `:link t` option gives the user an option whether to make the headings a link or not
- an element with `:file` to be added via `org-ql.el`
- this `:file` will be used here for the file-name with its path
This commit is contained in:
Bala Ramadurai 2021-01-29 08:16:17 +05:30 committed by GitHub
parent 35d305b7f6
commit f15d0dc76b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -268,13 +268,15 @@ Valid parameters include:
positive number) or the end (a negative number) of positive number) or the end (a negative number) of
the results. the results.
:link set this to non-nil for org-links to be there. If you leave this out or to nil, then no links in the headings.
:ts-format Optional format string used to format :ts-format Optional format string used to format
timestamp-based columns. timestamp-based columns.
For example, an org-ql dynamic block header could look like: For example, an org-ql dynamic block header could look like:
#+BEGIN: org-ql :file org-agenda-files :query (todo \"UNDERWAY\") :columns (priority todo heading) :sort (priority date) :ts-format \"%Y-%m-%d %H:%M\"" #+BEGIN: org-ql :file org-agenda-files :query (todo \"UNDERWAY\") :columns (priority todo heading) :sort (priority date) :link t :ts-format \"%Y-%m-%d %H:%M\""
(-let* (((&plist :query :columns :sort :ts-format :take :file) params) (-let* (((&plist :query :columns :sort :ts-format :take :link :file) params)
(query (cl-etypecase query (query (cl-etypecase query
(string (org-ql--query-string-to-sexp 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. (list ;; SAFETY: Query is in sexp form: ask for confirmation, because it could contain arbitrary code.
@ -289,10 +291,12 @@ For example, an org-ql dynamic block header could look like:
(list (cons 'todo (lambda (element) (list (cons 'todo (lambda (element)
(org-element-property :todo-keyword element))) (org-element-property :todo-keyword element)))
(cons 'heading (lambda (element) (cons 'heading (lambda (element)
(--when-let (org-element-property :raw-value element)
(if (not link) it
(let ((search
(org-link-heading-search-string it)))
(org-link-make-string (org-link-make-string
(format "file:%s::%s" (format "file:%s::%s" (org-element-property :file element) search)
(marker-buffer (org-element-property :org-marker element))
(org-element-property :raw-value element))
;; Prune statistics cookies. Replace ;; Prune statistics cookies. Replace
;; links with their description, or ;; links with their description, or
;; a plain link if there is none. ;; a plain link if there is none.
@ -300,11 +304,14 @@ For example, an org-ql dynamic block header could look like:
(org-link-display-format (org-link-display-format
(replace-regexp-in-string (replace-regexp-in-string
"\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]" "" "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]" ""
(org-element-property :raw-value element))))) it))))
)) )))))
(cons 'priority (lambda (element) (cons 'priority (lambda (element)
(--when-let (org-element-property :priority element) (--when-let (org-element-property :priority element)
(char-to-string it)))) (char-to-string it))))
(cons 'closed (lambda (element)
(--when-let (org-element-property :closed element)
(ts-format ts-format (ts-parse-org-element it)))))
(cons 'deadline (lambda (element) (cons 'deadline (lambda (element)
(--when-let (org-element-property :deadline element) (--when-let (org-element-property :deadline element)
(ts-format ts-format (ts-parse-org-element it))))) (ts-format ts-format (ts-parse-org-element it)))))