diff options
| author | Thanos Apollo <public@thanosapollo.org> | 2026-02-20 20:04:53 +0200 |
|---|---|---|
| committer | Thanos Apollo <public@thanosapollo.org> | 2026-02-20 20:04:53 +0200 |
| commit | ba3cd3f9b0c3c800f781b3da8db3c4a33bff0aa5 (patch) | |
| tree | d8c4f7770ffc7fba4c74283831a90253e78df28d | |
| parent | 1b0e6a5131eaf9be99f4a66fa7539666d1c23294 (diff) | |
journal: todos: Only get checkboxes for todays todos.
| -rw-r--r-- | org-gnosis.el | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/org-gnosis.el b/org-gnosis.el index c26217f..d140634 100644 --- a/org-gnosis.el +++ b/org-gnosis.el @@ -415,7 +415,22 @@ Removes all contents of FILE in database, adding them anew." (org-gnosis--update-file file journal-p) ;; Update todos (when (and journal-p file) - (let ((done-todos (org-gnosis-get-checked-items (org-element-parse-buffer)))) + (let* ((today (format-time-string "%Y-%m-%d")) + (parsed-buffer (org-element-parse-buffer)) + (done-todos (if (and org-gnosis-journal-file + (string= file (file-name-nondirectory org-gnosis-journal-file))) + ;; For single journal file, only get items from today's heading + (let ((today-heading + (org-element-map parsed-buffer 'headline + (lambda (headline) + (when (string= (org-element-property :raw-value headline) today) + headline)) + nil t))) + (if today-heading + (org-gnosis-get-checked-items today-heading) + nil)) + ;; For separate journal files, get all items + (org-gnosis-get-checked-items parsed-buffer)))) (cl-loop for done-todo in done-todos do (org-gnosis-mark-todo-as-done done-todo)))))) @@ -765,11 +780,11 @@ ELEMENT should be the output of `org-element-parse-buffer'." (lambda (item) (when (eq (org-element-property :checkbox item) 'on) (push (car (split-string - (substring-no-properties - (string-trim - (org-element-interpret-data - (org-element-contents item)))) - "\n")) + (substring-no-properties + (string-trim + (org-element-interpret-data + (org-element-contents item)))) + "\n")) checked-items)))) (nreverse checked-items))) |
