From 3c7f81a3d94d07e1c6e705ecdbf17ca3b5a9cce0 Mon Sep 17 00:00:00 2001 From: Ido Magal <1166577+IdoMagal@users.noreply.github.com> Date: Mon, 24 Jan 2022 00:07:43 -0800 Subject: [PATCH 1/3] Skip marking calendar entries when calendar is just for input #375 --- org-journal.el | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/org-journal.el b/org-journal.el index 5f22d53..4f21e4a 100644 --- a/org-journal.el +++ b/org-journal.el @@ -403,12 +403,24 @@ This runs once per date, before `org-journal-after-entry-create-hook'.") (defvar org-journal--search-buffer "*Org-journal search*") - +(defvar org-journal-dont-mark-entries nil) + ;;;###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-dont-mark-entries t) + (unwind-protect + (apply orig-fun args) + (setq org-journal-dont-mark-entries nil)))) + +;;;###autoload +(advice-add 'org-read-date :around #'org-journal--org-read-date) + ;; Journal mode definition ;;;###autoload (define-derived-mode org-journal-mode org-mode @@ -1330,14 +1342,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))))))) + (unless org-journal-dont-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) From d5d1ac7885a053ad26e0274993358d18b6e4ef12 Mon Sep 17 00:00:00 2001 From: Ido Magal <1166577+dppdppd@users.noreply.github.com> Date: Mon, 24 Jan 2022 13:02:39 -0800 Subject: [PATCH 2/3] flipped logic on control variable --- org-journal.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/org-journal.el b/org-journal.el index 4f21e4a..5935970 100644 --- a/org-journal.el +++ b/org-journal.el @@ -403,7 +403,8 @@ This runs once per date, before `org-journal-after-entry-create-hook'.") (defvar org-journal--search-buffer "*Org-journal search*") -(defvar org-journal-dont-mark-entries nil) +(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) @@ -413,10 +414,10 @@ This runs once per date, before `org-journal-after-entry-create-hook'.") (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-dont-mark-entries t) + (setq org-journal-allow-mark-entries nil) (unwind-protect (apply orig-fun args) - (setq org-journal-dont-mark-entries nil)))) + (setq org-journal-allow-mark-entries t)))) ;;;###autoload (advice-add 'org-read-date :around #'org-journal--org-read-date) @@ -1342,7 +1343,7 @@ from oldest to newest." (defun org-journal-mark-entries () "Mark days in the calendar for which a journal entry is present." (interactive) - (unless org-journal-dont-mark-entries + (unless org-journal-allow-mark-entries (when (file-exists-p org-journal-dir) (let ((current-time (current-time))) (dolist (journal-entry (org-journal--list-dates)) From 3bb573fd24e449304774dc825f1cecca70104308 Mon Sep 17 00:00:00 2001 From: Ido Magal <1166577+dppdppd@users.noreply.github.com> Date: Mon, 24 Jan 2022 13:11:49 -0800 Subject: [PATCH 3/3] fixed logic with flipped logic --- org-journal.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/org-journal.el b/org-journal.el index 5935970..ba6bfc1 100644 --- a/org-journal.el +++ b/org-journal.el @@ -1343,15 +1343,15 @@ from oldest to newest." (defun org-journal-mark-entries () "Mark days in the calendar for which a journal entry is present." (interactive) - (unless 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)))))))) + (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)