Fix org-journal-mode not loading on journal files

This commit is contained in:
Henrik Lissner 2020-04-12 03:41:42 -04:00
parent 42084af680
commit 9ba14f0ba4
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -1,18 +1,24 @@
;;; lang/org/contrib/journal.el -*- lexical-binding: t; -*- ;;; lang/org/contrib/journal.el -*- lexical-binding: t; -*-
;;;###if (featurep! +journal) ;;;###if (featurep! +journal)
;; HACK org-journal does some file-path magic at load time that creates (use-package! org-journal
;; duplicate `auto-mode-alist' entries, so we suppress it for now, so we :mode ("/\\(?1:[0-9]\\{4\\}\\)\\(?2:[0-9][0-9]\\)\\(?3:[0-9][0-9]\\)\\(\\.gpg\\)?\\'"
;; can do it properly later. . org-journal-mode)
(advice-add #'org-journal-update-auto-mode-alist :override #'ignore) :preface
;; HACK org-journal does some file-path magic at load time that creates
(after! org-journal ;; duplicate and hard-coded `auto-mode-alist' entries, so we suppress it
(setq org-journal-dir (expand-file-name "journal/" org-directory) ;; and use the more generalize regexp (above).
org-journal-cache-file (concat doom-cache-dir "org-journal") (advice-add #'org-journal-update-auto-mode-alist :override #'ignore)
org-journal-file-pattern (org-journal-dir-and-format->regex ;; HACK `org-journal-dir' has is surrounded by setter and `auto-mode-alist'
org-journal-dir org-journal-file-format)) ;; magic which makes its needlessly difficult to create an "overrideable"
;; default for Doom users, so we set this to an empty string (anything
(add-to-list 'auto-mode-alist (cons org-journal-file-pattern 'org-journal-mode)) ;; else will throw an error) so we can detect it being changed later.
(setq org-journal-dir ""
org-journal-cache-file (concat doom-cache-dir "org-journal"))
:config
(when (string-empty-p org-journal-dir)
(setq! org-journal-dir (expand-file-name "journal/" org-directory)))
(setq org-journal-find-file #'find-file)
(map! (:map org-journal-mode-map (map! (:map org-journal-mode-map
:n "]f" #'org-journal-open-next-entry :n "]f" #'org-journal-open-next-entry