Closed zhyzky closed 9 months ago
By the way, I set org-journal-file-type to 'weekly
I finally got that the issue is with macro org-journal--with-journal, within which (generate-new-buffer *) was called and in this buffer, its major mode is fundamental. That's why it raised the error with non-org mode.
After re-write the macro:
(defmacro org-journal--with-journal (file &rest body)
"Opens JOURNAL-FILE in fundamental mode, or switches to the
buffer which is visiting JOURNAL-FILE.
Returns the last value from BODY. If the buffer didn't exist
before it will be deposed."
;; Use find-file... instead of view-file... since
;; view-file does not respect auto-mode-alist
(declare (indent 1))
`(let* ((buffer-exists (get-buffer (file-name-nondirectory ,file)))
(buf (if buffer-exists buffer-exists
(find-file ,file)))
result)
(with-current-buffer buf
(setq result (progn ,@body)))
(unless buffer-exists
(kill-buffer buf))
result))
where there's no temp buffer exists, and the issue seemes fixed.
Update, much less code:
(defmacro org-journal--with-journal (file &rest body)
"Opens JOURNAL-FILE in fundamental mode, or switches to the
buffer which is visiting JOURNAL-FILE.
Returns the last value from BODY. If the buffer didn't exist
before it will be deposed."
;; Use find-file... instead of view-file... since
;; view-file does not respect auto-mode-alist
;; with-temp-buffer and with explicit declare org-mode seems
;; to be a recommend way
(declare (indent 1))
`(let ((buffer-exists (get-buffer (file-name-nondirectory ,file))))
(if buffer-exists
(with-current-buffer buffer-exists (progn ,@body))
(with-temp-buffer
;; (unless buffer-exists
;; (insert-file-contents ,file))
(insert-file-contents ,file)
((let ((major-mode 'org-mode))
(progn ,@body))))))
Since commit has been merged. Closed.
Describe the bug An error with "cannot be used in non-org buffer" raised with the org commit https://github.com/emacs-straight/org-mode/commit/f1359546ad7dee9698b75ca25ad453e6f054bd06 the issue is clear, so maybe need an update of the code
To Reproduce Just invoke org-journal-prev-entry or anything else
Expected behavior org-journal just work well
Desktop (please complete the following information):
Your Emacs Configuration has nothing todo with this