bastibe / org-journal

A simple org-mode based journaling mode
BSD 3-Clause "New" or "Revised" License
1.24k stars 124 forks source link

Do not delete old carryover elements if they have a LOGBOOK drawer #363

Open jmburgos opened 3 years ago

jmburgos commented 3 years ago

Hello everyone,

I am trying to mody the org-journal-delete-old-carryover function so it will not delete entries that have a LOGBOOK drawer. It should be pretty straightforward, just adding an new conditional clause, but I guess my elisp is not up to the task. Could anyone give me a hand?

(defun org-journal-delete-old-carryover (old_entries)
  "Delete all carryover entries from the previous day's journal.

If the parent heading has no more content, delete it as well."
  (mapc (lambda (x)
          (unless (save-excursion
                    (goto-char (1- (cadr x)))
                    (org-goto-first-child))

                 (kill-region (car x) (cadr x))

        )
      )
        (reverse old_entries)))

(setq org-journal-handle-old-carryover 'org-journal-delete-old-carryover)
jmburgos commented 3 years ago

This is my attempt which did not worked:


(defun org-journal-delete-old-carryover-except-logbook (old_entries)
  "Delete all carryover entries from the previous day's journal, except those with a LOGBOOK drawer. If the parent heading has no more content, delete it as well."
  (require 'cl-seq)
  (mapc (lambda (x)
      (unless (cl-member "LOGBOOK" x :test #'string-match)
          (unless (save-excursion
                    (goto-char (1- (cadr x)))
                    (org-goto-first-child))
                 (kill-region (car x) (cadr x)))
      ))
        (reverse old_entries)))
bastibe commented 3 years ago

Is this perhaps something you could solve with a custom org-journal-carryover-items? It currently selects for TODO items, but the search patterns are quite powerful, and do allow filtering by properties etc.