Insert active concurrent DATE entries when inserting checklist
Those DATE entries may be relevant to the item at hand. Caveat: the query to determine active, concurrent DATE entries is not quite right yet, two disjoint time ranges that do not include today but cover the past and the future would also be considered as concurrent active date. This needs to be fixed.
This commit is contained in:
parent
94187697e6
commit
7309cee413
@ -1193,9 +1193,12 @@ CHECKLIST_INSERTED_P with value t to item at point. Checklists
|
|||||||
are not inserted if this property with this value is already
|
are not inserted if this property with this value is already
|
||||||
present, to avoid double insertions of checklists.
|
present, to avoid double insertions of checklists.
|
||||||
|
|
||||||
The checklist consists of a listing of relevant backlinks of the
|
The checklist consists of a listing of concurrent date entries,
|
||||||
current item and its parents (without archives) as well as a
|
relevant backlinks of the current item and its parents (without
|
||||||
template.
|
archives) as well as a template.
|
||||||
|
|
||||||
|
Concurrent date entries are all Org items tagged with DATE and
|
||||||
|
posessing an active time range that encloses today.
|
||||||
|
|
||||||
Relevant backlinks are Org items and are determined as follows:
|
Relevant backlinks are Org items and are determined as follows:
|
||||||
|
|
||||||
@ -1281,6 +1284,21 @@ inserting the checklist."
|
|||||||
(looking-at (rx bol (* space) eol)))
|
(looking-at (rx bol (* space) eol)))
|
||||||
(insert "\n"))
|
(insert "\n"))
|
||||||
|
|
||||||
|
;; Insert links to concurrent DATEs, if any
|
||||||
|
(when-let ((concurrent-dates (org-ql-query :from (org-agenda-files)
|
||||||
|
:select '(cons
|
||||||
|
(org-entry-get (point) "ITEM")
|
||||||
|
(org-id-get-create))
|
||||||
|
:where '(and ; XXX: this is not quite right yet
|
||||||
|
(tags "DATE")
|
||||||
|
(not (done))
|
||||||
|
(ts-active :from today)
|
||||||
|
(ts-active :to today)))))
|
||||||
|
(insert "Concurrent DATEs:\n")
|
||||||
|
(dolist (date concurrent-dates)
|
||||||
|
(insert "- " (org-link-make-string (cdr date) (car date)) "\n"))
|
||||||
|
(insert "\n"))
|
||||||
|
|
||||||
;; Insert relevant backlinks, when available.
|
;; Insert relevant backlinks, when available.
|
||||||
(let ((parent-depth (--when-let (org-entry-get (point) "CHECKLIST_BACKLINK_DEPTH" nil)
|
(let ((parent-depth (--when-let (org-entry-get (point) "CHECKLIST_BACKLINK_DEPTH" nil)
|
||||||
(string-to-number it)))
|
(string-to-number it)))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user