Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Before first heading" error in heading-free files #440

Open
meedstrom opened this issue Aug 9, 2024 · 4 comments
Open

"Before first heading" error in heading-free files #440

meedstrom opened this issue Aug 9, 2024 · 4 comments

Comments

@meedstrom
Copy link

meedstrom commented Aug 9, 2024

Describe the bug
I get a "Before first heading" error message when I call org-journal-new-entry.

To Reproduce

Set these settings:

(progn
  (setq org-journal-file-type 'daily)
  (setq org-journal-file-format "%F.org")
  (setq org-journal-date-prefix "#+title: ")
  (setq org-journal-date-format "%F")
  (setq org-journal-time-prefix "")
  (setq org-journal-time-format ""))

Now do M-x org-journal-new-entry.

Desktop (please complete the following information):

  • OS: Debian sid
  • Emacs Version 29.4
@meedstrom
Copy link
Author

meedstrom commented Aug 9, 2024

It is because org-journal-new-entry calls outline-show-entry at the end.

Simple workaround may be to add Beginning-of-String "\\`" to the outline-regexp in org-journal buffers.

Like

(add-hook 'org-journal-mode-hook
            (lambda ()
              (setq outline-regexp (rx (or bos (seq (+ "*") " "))))))

@bastibe
Copy link
Owner

bastibe commented Aug 12, 2024

Is this caused by your customizations, or always a problem?

@meedstrom
Copy link
Author

meedstrom commented Aug 12, 2024

It wasn't a problem when I went with a non-blank time prefix:

(setq org-journal-time-prefix "* ")

so I inferred that it has to do with some Org code not behaving as expected when point is before the first heading (a common problem).

I'm actually gonna use a homegrown system rather than org-journal, so it's not important to me to fix this, but let me know if you don't get the error with the reproduction steps suggested in OP. I will be surprised (is your value of outline-regexp the default?), but then I might try to track down the real issue with emacs -Q.

@bastibe
Copy link
Owner

bastibe commented Aug 13, 2024

I guess this is expected behavior, in some sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants