Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions org-journal.el
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,25 @@ This runs once per date, before `org-journal-after-entry-create-hook'.")

(defvar org-journal--search-buffer "*Org-journal search*")


(defvar org-journal-allow-mark-entries t
"Allows us to prevent marking entries in cases such as org-deadline and org-time-stamp")

;;;###autoload
(add-hook 'calendar-today-visible-hook 'org-journal-mark-entries)
;;;###autoload
(add-hook 'calendar-today-invisible-hook 'org-journal-mark-entries)

(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)
(unwind-protect
(apply orig-fun args)
(setq org-journal-allow-mark-entries t))))

;;;###autoload
(advice-add 'org-read-date :around #'org-journal--org-read-date)

;; Journal mode definition
;;;###autoload
(define-derived-mode org-journal-mode org-mode
Expand Down Expand Up @@ -1330,14 +1343,15 @@ from oldest to newest."
(defun org-journal-mark-entries ()
"Mark days in the calendar for which a journal entry is present."
(interactive)
(when (file-exists-p org-journal-dir)
(let ((current-time (current-time)))
(dolist (journal-entry (org-journal--list-dates))
(if (calendar-date-is-visible-p journal-entry)
(if (time-less-p (org-journal--calendar-date->time journal-entry)
current-time)
(calendar-mark-visible-date journal-entry 'org-journal-calendar-entry-face)
(calendar-mark-visible-date journal-entry 'org-journal-calendar-scheduled-face)))))))
(if org-journal-allow-mark-entries
(when (file-exists-p org-journal-dir)
(let ((current-time (current-time)))
(dolist (journal-entry (org-journal--list-dates))
(if (calendar-date-is-visible-p journal-entry)
(if (time-less-p (org-journal--calendar-date->time journal-entry)
current-time)
(calendar-mark-visible-date journal-entry 'org-journal-calendar-entry-face)
(calendar-mark-visible-date journal-entry 'org-journal-calendar-scheduled-face))))))))

;;;###autoload
(defun org-journal-read-entry (_arg &optional event)
Expand Down