Fix journal org files not opening in org-journal

Should also fix any lingering "No year zero" errors.
This commit is contained in:
Henrik Lissner 2020-05-08 05:46:19 -04:00
parent 2db423897c
commit 9a7f46fff3
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -2,11 +2,10 @@
;;;###if (featurep! +journal) ;;;###if (featurep! +journal)
(use-package! org-journal (use-package! org-journal
:hook (org-load . org-journal-update-auto-mode-alist) :defer t
;; This is necessary if the user decides opens a journal file directly, via :init
;; `find-file' or something, and not through org-journal's commands. (remove-hook 'org-mode-hook #'org-journal-update-auto-mode-alist)
:mode ("/[0-9]\\{8\\}\\.org\\(?:\\.gpg\\)?\\'" . org-journal-mode)
:preface
;; Not using the .org file extension causes needless headache with file ;; Not using the .org file extension causes needless headache with file
;; detection for no compelling reason, so we make it the default, so ;; detection for no compelling reason, so we make it the default, so
;; `org-journal' doesn't have to do all its `auto-mode-alist' magic. ;; `org-journal' doesn't have to do all its `auto-mode-alist' magic.
@ -22,16 +21,20 @@
;; we wanted to keep visible. ;; we wanted to keep visible.
org-journal-find-file #'find-file) org-journal-find-file #'find-file)
:config ;; HACK `org-journal' does some file-path magic at load time that creates
(when (or (equal org-journal-dir "journal/") ;; duplicate entries in `auto-mode-alist'. We load org-journal in such a
(not (equal org-journal-file-format "%Y%m%d.org"))) ;; way that we can generate a final entry after the user could possibly
;; HACK `org-journal' does some file-path magic at load time that creates ;; customize `org-journal-dir'.
;; several, duplicate and hard-coded `auto-mode-alist' entries, so get (after! org
;; rid of them all here so we can create a one-true-entry right after. (require 'org-journal)
(setq auto-mode-alist (rassq-delete-all 'org-journal-mode auto-mode-alist)) ;; Delete duplicate entries in `auto-mode-alist'
;; ...By exploiting `org-journal-dir''s setter (rassq-delete-all 'org-journal-mode auto-mode-alist)
;; ...and exploit `org-journal-dir''s setter to set up
;; `org-journal-file-pattern' and call `org-journal-update-auto-mode-alist'
;; for us, to create the one-true-entry in `auto-mode-alist.'
(setq! org-journal-dir (expand-file-name org-journal-dir org-directory))) (setq! org-journal-dir (expand-file-name org-journal-dir org-directory)))
:config
(set-popup-rule! "^\\*Org-journal search" :select t :quit t) (set-popup-rule! "^\\*Org-journal search" :select t :quit t)
(map! (:map org-journal-mode-map (map! (:map org-journal-mode-map