bastibe / org-journal

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

In weekly mode, on Sunday, org-journal thinks it's still Friday #354

Open drewbenn opened 3 years ago

drewbenn commented 3 years ago

I tried to add a new entry on Sunday evening after not using org-journal since Friday afternoon. When I tried to start a new entry with C-c C-j, the entry was added to the end of Friday, instead of getting a new date line added to the file.

C-u C-c C-j, to create the current date without adding a new entry, also jumps to the end of Friday without adding a new entry.

org-journal 2.1.2 installed manually on Debian stable (10) KDE. Applicable lines from my .emacs:

    (load "calendar")
    (setq org-journal-dir "~/journal/")
    (setq org-journal-file-type 'weekly)

    (load "~/.emacs.d/org-journal.el")
    (load "~/.emacs.d/org-journal-tags.el")

Screenshot_20210606_182137

drewbenn commented 3 years ago

I may have found the cause. The last line in my journal file is 3 spaces. When I C-u C-c C-j, the * Sunday, 06/06/2021 is appended to that line (and no :PROPERTIES: drawer is created): because there are 3 spaces before the *, that line isn't recognized as an org-mode heading. If I C-u C-c C-j a second time, * Sunday, 06/06/2021 is appended again, this time to a blank line, and the :PROPERTIES: drawer is created.

hexdump of the file showing the last line, before I do anything:

$ hexdump -C 20210531 | tail -2
0000e5a0  20 20 20 20 20 34 20 7c  0a 20 20 20 0a           |     4 |.   .|
0000e5ad
$ 

So the bug seems to be: org-journal doesn't correctly create a new day in weekly mode if the last line of the file ends in a space.

bastibe commented 3 years ago

How strange. Thank you for your analysis!

superhans2 commented 3 months ago

I also have this bug, what is the fix? issue

superhans2 commented 6 days ago

I solved this using: (defun my-org-mode-setup () "Custom configurations for org-mode." (add-hook 'before-save-hook 'delete-trailing-whitespace nil t)) (add-hook 'org-mode-hook 'my-org-mode-setup))