branch: externals/denote commit 1d68f350211b5928798a12dda37700fdbd8865a1 Author: Jean-Philippe Gagné Guay <jeanphilippe...@gmail.com> Commit: Jean-Philippe Gagné Guay <jeanphilippe...@gmail.com>
Rework denote--date-prompt When org-read-date is used and the seconds are 00, add the current seconds to the time returned by org-read-date. --- denote.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/denote.el b/denote.el index 6cf7c3d532..4d0af88729 100644 --- a/denote.el +++ b/denote.el @@ -1131,10 +1131,13 @@ here for clarity." (defun denote--date-prompt () "Prompt for date." (if denote-date-prompt-use-org-read-date - (let* ((org-time (org-read-date nil t)) - (current-seconds (string-to-number - (format-time-string "%S" (current-time)))) - (time (time-add org-time current-seconds))) + (let* ((time (org-read-date nil t)) + (org-time-seconds (format-time-string "%S" time)) + (cur-time-seconds (format-time-string "%S" (current-time)))) + ;; When the user does not input a time, org-read-date defaults to 00 for seconds. + ;; When the seconds are 00, we add the current seconds to avoid identifier collisions. + (when (string-equal "00" org-time-seconds) + (setq time (time-add time (string-to-number cur-time-seconds)))) (format-time-string "%Y-%m-%d %H:%M:%S" time)) (read-string "DATE and TIME for note (e.g. 2022-06-16 14:30): "