bastibe / org-journal

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

Skip marking calendar entries for date input #380

Open dppdppd opened 2 years ago

dppdppd commented 2 years ago

(ugh. renaming the branch reset the PR. never again...)

I flipped the logic so it might be clearer now.

We always mark entries, unless we call org-read-date.

(defun org-journal--org-read-date (orig-fun &rest args)
  "In the case where the calendar is opened to input a timestamp, don't mark entries."
  (progn
    (setq org-journal-allow-mark-entries nil) <----- turn it off temporarily
    (unwind-protect
        (apply orig-fun args)               <------- (calendar) gets called in here, and therefore org-journal-mark-entries
      (setq org-journal-allow-mark-entries t)))) <---- turn it back on
bastibe commented 2 years ago

This looks reasonable. I still don't quite understand why we have to disable marking explicitly for org-read-date, since the function that does the marking is disabled anyway. But if you say it's necessary, I'll trust your assessment.

But since the variable is supposed to be configured by the user, it should be a defcustom, not a defvar.

xeruf commented 1 year ago

@dppdppd can you make the suggested correction so we can merge? Then I would squash this with the title "Skip marking calendar entries for date input"