bastibe / org-journal

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

create-entry is brittle on unexpected contents in PROPERTIES blocks #425

Closed jmay closed 5 months ago

jmay commented 7 months ago

Describe the bug org-journal-new-entry does not know how to deal with unexpected contents inside PROPERTIES drawers. Should be more forgiving of bad input, maybe with warnings but not aborting.

Might be related to other issues with treatment of timestamps found in unexpected formats.

To Reproduce I've experienced this with per-year journal files.

Steps to reproduce the behavior:

  1. Open a current journal file. In any PROPERTIES drawer, insert a blank line above or below the CREATED timestamp line, save file.
  2. Invoke org-journal-new-entry
  3. Witness error behavior: fails to create new entry, shows error message in minibuffer "user-error: Created property timestamp format "%Y-%m-%d" doesn’t match CREATED property value (nil) from entry at line: Line NNNN"
  4. Delete the blank line, save file, try again, should work correctly.

Expected behavior Should create a new journal entry in the expected place.

Optional behavior: Log some warnings to an appropriate place (*Messages* or *Warnings* or an org-journal-specific buffer) and possible print a notification in the minibuffer.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Your Emacs Configuration The part relevant to org-journal.

casch-at commented 6 months ago

This is valid for those examples too.

* Monday, 22 January 2024

:PROPERTIES:
:CREATED:  [2024-01-22 Mon]
:END:
* Monday, 22 January 2024
:PROPERTIES:
:CREATED:  [2024-01-22 Mon]

:END:

* Monday, 22 January 2024
:PROPERTIES:

:CREATED:  [2024-01-22 Mon]
:END:

Hmm, is more an org-mode bug IMHO.

casch-at commented 6 months ago

(org-entry-get (point) "CREATED") on the CREATED property returns nil in all three cases.

jmay commented 5 months ago

Verified. This is definitely an org-mode bug. I don't see a strong reason to address this specifically for org-journal. I'll wait a few days for other comments, otherwise I'll close this.

jmay commented 5 months ago

I've learned about org-lint. Perhaps we could incorporate this into the org-journal process somewhere. Instead of a confusing "user-error" message in the minibuffer we could open the *Org Lint* buffer in these cases which might be a better guide to resolving such problems.

casch-at commented 5 months ago

@jmay Good point! Hmm, should we report this behavior to org? Can you create a new issue for org-lint and close this, thank you ❤️

jmay commented 5 months ago

I got a response from the org team. Unlikely that they will fix this.

My plan is to add something to org-journal that detects this condition and delivers a more useful error message: instead of "user-error blah blah properties etc" it should say "There's something wrong with the PROPERTIES in file xxxx.org. Please run org-lint to resolve."

Closing this issue. I'll submit a PR later with details.