org-journal icon indicating copy to clipboard operation
org-journal copied to clipboard

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

Open jmburgos opened this issue 2 years ago • 2 comments

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 avatar Aug 28 '21 14:08 jmburgos

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)))

jmburgos avatar Aug 29 '21 12:08 jmburgos

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.

bastibe avatar Sep 08 '21 09:09 bastibe