featurep! will be renamed modulep! in the future, so it's been deprecated. They have identical interfaces, and can be replaced without issue. featurep! was never quite the right name for this macro. It implied that it had some connection to featurep, which it doesn't (only that it was similar in purpose; still, Doom modules are not features). To undo such implications and be consistent with its namespace (and since we're heading into a storm of breaking changes with the v3 release anyway), now was the best opportunity to begin the transition.
72 lines
3.2 KiB
EmacsLisp
72 lines
3.2 KiB
EmacsLisp
;;; lang/org/contrib/journal.el -*- lexical-binding: t; -*-
|
|
;;;###if (modulep! +journal)
|
|
|
|
(use-package! org-journal
|
|
:defer t
|
|
:init
|
|
;; HACK `org-journal' adds a `magic-mode-alist' entry for detecting journal
|
|
;; files, but this causes us lazy loaders a big problem: an unacceptable
|
|
;; delay on the first file the user opens, because calling the autoloaded
|
|
;; `org-journal-is-journal' pulls all of `org' with it. So, we replace it
|
|
;; with our own, extra layer of heuristics.
|
|
(add-to-list 'magic-mode-alist '(+org-journal-p . org-journal-mode))
|
|
|
|
(defun +org-journal-p ()
|
|
"Wrapper around `org-journal-is-journal' to lazy load `org-journal'."
|
|
(when-let (buffer-file-name (buffer-file-name (buffer-base-buffer)))
|
|
(if (or (featurep 'org-journal)
|
|
(and (file-in-directory-p
|
|
buffer-file-name (expand-file-name org-journal-dir org-directory))
|
|
(require 'org-journal nil t)))
|
|
(org-journal-is-journal))))
|
|
|
|
;; `org-journal-dir' defaults to "~/Documents/journal/", which is an odd
|
|
;; default, so we change it to {org-directory}/journal (we expand it after
|
|
;; org-journal is loaded).
|
|
(setq org-journal-dir "journal/"
|
|
org-journal-cache-file (concat doom-cache-dir "org-journal"))
|
|
|
|
:config
|
|
;; Remove the orginal journal file detector and rely on `+org-journal-p'
|
|
;; instead, to avoid loading org-journal until the last possible moment.
|
|
(setq magic-mode-alist (assq-delete-all 'org-journal-is-journal magic-mode-alist))
|
|
|
|
;; `org-journal' can't deal with symlinks, so resolve them here.
|
|
(setq org-journal-dir (expand-file-name org-journal-dir org-directory)
|
|
;; Doom opts for an "open in a popup or here" strategy as a default.
|
|
;; Open in "other window" is less predictable, and can replace a window
|
|
;; we wanted to keep visible.
|
|
org-journal-find-file #'find-file)
|
|
|
|
;; Setup carryover to include all configured TODO states. We cannot carry over
|
|
;; [ ] keywords because `org-journal-carryover-items's syntax cannot correctly
|
|
;; interpret it as anything other than a date.
|
|
(setq org-journal-carryover-items "TODO=\"TODO\"|TODO=\"PROJ\"|TODO=\"STRT\"|TODO=\"WAIT\"|TODO=\"HOLD\"")
|
|
|
|
(set-company-backend! 'org-journal-mode 'company-capf 'company-dabbrev)
|
|
|
|
(map! (:map org-journal-mode-map
|
|
:n "]f" #'org-journal-next-entry
|
|
:n "[f" #'org-journal-previous-entry
|
|
:n "C-n" #'org-journal-next-entry
|
|
:n "C-p" #'org-journal-previous-entry)
|
|
(:map org-journal-search-mode-map
|
|
"C-n" #'org-journal-search-next
|
|
"C-p" #'org-journal-search-previous)
|
|
:localleader
|
|
(:map org-journal-mode-map
|
|
(:prefix "j"
|
|
"c" #'org-journal-new-entry
|
|
"d" #'org-journal-new-date-entry
|
|
"n" #'org-journal-next-entry
|
|
"p" #'org-journal-previous-entry)
|
|
(:prefix "s"
|
|
"s" #'org-journal-search
|
|
"f" #'org-journal-search-forever
|
|
"F" #'org-journal-search-future
|
|
"w" #'org-journal-search-calendar-week
|
|
"m" #'org-journal-search-calendar-month
|
|
"y" #'org-journal-search-calendar-year))
|
|
(:map org-journal-search-mode-map
|
|
"n" #'org-journal-search-next
|
|
"p" #'org-journal-search-prev)))
|