create-entry is brittle on unexpected contents in PROPERTIES blocks
Closed this issue · 6 comments
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:
- Open a current journal file. In any
PROPERTIES
drawer, insert a blank line above or below theCREATED
timestamp line, save file. - Invoke
org-journal-new-entry
- 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"
- 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):
- OS: macOS Sonoma 14.1
- Emacs Version: 29.1
Your Emacs Configuration
The part relevant to org-journal.
- org-mode version 9.7-pre
- org-journal commits
46146e7
anda306f76
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.
(org-entry-get (point) "CREATED")
on the CREATED
property returns nil
in all three cases.
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.
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.
@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 ❤️
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.