bastibe / org-journal

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

Ignore unrecognized timestamps and timestamps in subheadings #397

Closed xeruf closed 1 year ago

xeruf commented 1 year ago

Description

I work with Orgzly, and this produces timestamps like:

:PROPERTIES:
:CREATED: [2022-08-23 Tue 10:09]
:END:

While org-journal for me uses:

org-journal-created-property-timestamp-format

Value
"[%Y-%m-%d]"

Expected Results

org-journal ignores:

  1. CREATED entries on subheadings
  2. CREATED entries outside of PROPERTIES drawers (yes I moved it out to test and org-journal did not care)
  3. CREATED entries that do not match its format

No errors, no complaining, just ignore them as if they weren't there :)

Actual Results

user-error: Created property timestamp format "[%Y-%m-%d]" doesn’t match CREATED property value (nil) from entry at line: Line 637
xeruf commented 1 year ago

Now this is really weird, if I call either of org-time-stamp(-inactive) anywhere as soon as org-journal is loaded, I get an error:

user-error: Created property timestamp format "[%Y-%m-%d]" doesn’t match CREATED property value ([2022-08-23 Tue 10:09]) from entry at line: Line 602

Seems like org-journal is hooked in somewhere it shouldn't be?

xeruf commented 1 year ago

See also https://github.com/bastibe/org-journal/issues/383 and https://github.com/bastibe/org-journal/issues/391

xeruf commented 1 year ago

okay, org-journal hooks into the calendar to mark days. I see @jmay @dppdppd you have already created patches, could you assist on this issue as well?

After an hour of debugging I think I found the culprit:

(defun org-journal--file->calendar-dates (file)
  "Return journal dates from FILE."
  (org-journal--with-journal
      file
    (let (dates)
      (save-excursion
        (goto-char (point-min))
        (while (re-search-forward org-journal--created-re nil t)
          (when (= (save-excursion (org-back-to-heading) (org-outline-level)) 1)
            (push (org-journal--entry-date->calendar-date) dates)))
        dates))))

my journal contains #+startup: overview, which means the headings are all folded and org-outline-level always reports 1. Inserting outline-show-all in there did not seem to cut it :/

jmay commented 1 year ago

@xeruf Make sure you restart your emacs and have the latest org-journal changes. Are you still getting errors? I can run org-time-stamp or org-time-stamp-inactive without problems. The calendar-dates function above was definitely where the patch was applied.

xeruf commented 1 year ago

yes, this works with the patch, which I've merged together at https://github.com/toemacs/org-journal

however, org-journal still erroneously checks on timestamps in subheadings.

xeruf commented 1 year ago

I am now getting user-error: Created property timestamp format "[%Y-%m-%d]" doesn’t match CREATED property value (nil) from entry at line: Line 7 and org-journal refuses to create timestamped headings. I can't even find the line the error is about.

Can we somehow prevent all these kinds of errors from impeding basic org-journal functionality?

xeruf commented 1 year ago

Can we somehow prevent all these kinds of errors from impeding basic org-journal functionality?

Fixed by https://github.com/bastibe/org-journal/pull/380