From 3fccdb1058b7f48b4073be5df07bd73cd7e0cf79 Mon Sep 17 00:00:00 2001 From: Daniel Nicolai Date: Wed, 24 Feb 2021 14:39:32 +0100 Subject: [PATCH] Improve new-scheduled-entry command Currently the command inserts the time preceding the TODO. This PR implements fixes (non-desctructively), but it assumes that #335 and #337 get merged first. --- org-journal.el | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/org-journal.el b/org-journal.el index 06b98f3..8b46c58 100644 --- a/org-journal.el +++ b/org-journal.el @@ -632,7 +632,7 @@ This allows the use of `org-journal-tag-alist' and (when (re-search-backward "^#\\+" nil t) (org-ctrl-c-ctrl-c))))) -(defun org-journal--insert-entry-header (time &optional insert-at-point) +(defun org-journal--insert-entry-header (time &optional todo insert-at-point) "Create new journal entry if there isn't one." (let ((entry-header (if (functionp org-journal-date-format) @@ -694,9 +694,9 @@ This allows the use of `org-journal-tag-alist' and (defun org-journal-insert-header-at-point () "Create journal style headline at point." (interactive) - (org-journal--insert-entry-header (current-time) t)) + (org-journal--insert-entry-header (current-time) nil t)) -(defun org-journal--insert-entry (time org-extend-today-until-active-p) +(defun org-journal--insert-entry (time org-extend-today-until-active-p &optional todo) "Insert a new entry." (unless (eq (current-column) 0) (insert "\n")) (let* ((day-discrepancy (- (time-to-days (current-time)) (time-to-days time))) @@ -712,11 +712,11 @@ This allows the use of `org-journal-tag-alist' and (format-time-string org-journal-time-format))) ;; “time” is on some other day, use blank timestamp (t "")))) - (insert org-journal-time-prefix timestamp)) + (insert (concat org-journal-time-prefix (when todo "TODO ") timestamp))) (run-hooks 'org-journal-after-entry-create-hook)) ;;;###autoload -(defun org-journal-new-entry (prefix &optional time) +(defun org-journal-new-entry (prefix &optional time todo) "Open today's journal file and start a new entry. With a PREFIX arg, open the today's file, create a heading if it doesn't exist yet, @@ -756,7 +756,7 @@ hook is run." (view-mode -1) (org-journal--insert-header time) - (org-journal--insert-entry-header time) + (org-journal--insert-entry-header time todo) (org-journal--decrypt) ;; Move TODOs from previous day to new entry @@ -770,7 +770,7 @@ hook is run." (goto-char (point-max))) (when should-add-entry-p - (org-journal--insert-entry time org-extend-today-until-active-p)) + (org-journal--insert-entry time org-extend-today-until-active-p todo)) (if (and org-journal-hide-entries-p (org-journal--time-entry-level)) (outline-hide-sublevels (org-journal--time-entry-level)) @@ -1068,12 +1068,12 @@ With non-nil prefix argument create a regular entry instead of a TODO entry." org-journal-carryover-items) (when (time-less-p time (current-time)) (user-error "Scheduled time needs to be in the future")) - (org-journal-new-entry nil time) - (unless prefix - (insert "TODO ")) + (org-journal-new-entry nil time (not prefix)) (save-excursion (insert "\n") - (org-insert-time-stamp time)))) + (insert "SCHEDULED: ") + (org-insert-time-stamp time t) + (org-cycle)))) ;;;###autoload (defun org-journal-reschedule-scheduled-entry (&optional time)