2019-09-18 13:29:06 +09:00
|
|
|
;;; lang/org/contrib/journal.el -*- lexical-binding: t; -*-
|
2019-09-18 13:30:26 +09:00
|
|
|
;;;###if (featurep! +journal)
|
2019-09-18 13:29:06 +09:00
|
|
|
|
2020-04-12 03:41:42 -04:00
|
|
|
(use-package! org-journal
|
2020-05-08 05:46:19 -04:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(remove-hook 'org-mode-hook #'org-journal-update-auto-mode-alist)
|
|
|
|
|
2020-05-07 00:23:29 -04:00
|
|
|
;; Not using the .org file extension causes needless headache with file
|
|
|
|
;; 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.
|
|
|
|
(defvar org-journal-file-format "%Y%m%d.org")
|
2020-04-17 05:07:55 -04:00
|
|
|
|
2020-05-07 00:23:29 -04:00
|
|
|
;; HACK `org-journal-dir' is surrounded with setters and `auto-mode-alist'
|
|
|
|
;; magic which makes it difficult to create an better default for Doom
|
|
|
|
;; users. We set this here so we can detect user-changes to it later.
|
|
|
|
(setq org-journal-dir "journal/"
|
2020-04-17 05:07:55 -04:00
|
|
|
org-journal-cache-file (concat doom-cache-dir "org-journal")
|
|
|
|
;; Doom opts for an "open in a popup or here" strategy as a default.
|
2020-05-07 00:23:29 -04:00
|
|
|
;; Open in "other window" is less predictable, and can replace a window
|
|
|
|
;; we wanted to keep visible.
|
2020-04-17 05:07:55 -04:00
|
|
|
org-journal-find-file #'find-file)
|
|
|
|
|
2020-05-08 05:46:19 -04:00
|
|
|
;; HACK `org-journal' does some file-path magic at load time that creates
|
|
|
|
;; duplicate entries in `auto-mode-alist'. We load org-journal in such a
|
|
|
|
;; way that we can generate a final entry after the user could possibly
|
|
|
|
;; customize `org-journal-dir'.
|
|
|
|
(after! org
|
|
|
|
(require 'org-journal)
|
|
|
|
;; Delete duplicate entries in `auto-mode-alist'
|
|
|
|
(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.'
|
2020-05-07 00:23:29 -04:00
|
|
|
(setq! org-journal-dir (expand-file-name org-journal-dir org-directory)))
|
2019-10-31 23:09:43 -04:00
|
|
|
|
2020-05-08 05:46:19 -04:00
|
|
|
:config
|
2020-05-07 00:23:46 -04:00
|
|
|
(set-popup-rule! "^\\*Org-journal search" :select t :quit t)
|
|
|
|
|
2020-01-18 20:34:37 -05:00
|
|
|
(map! (:map org-journal-mode-map
|
2020-05-07 00:23:29 -04:00
|
|
|
:n "]f" #'org-journal-open-next-entry
|
|
|
|
:n "[f" #'org-journal-open-previous-entry
|
|
|
|
:n "C-n" #'org-journal-open-next-entry
|
|
|
|
:n "C-p" #'org-journal-open-previous-entry)
|
2019-10-31 23:09:43 -04:00
|
|
|
(:map org-journal-search-mode-map
|
2020-05-07 00:23:29 -04:00
|
|
|
"C-n" #'org-journal-search-next
|
|
|
|
"C-p" #'org-journal-search-previous)
|
2020-01-18 20:34:37 -05:00
|
|
|
:localleader
|
2019-10-31 23:09:43 -04:00
|
|
|
(:map org-journal-mode-map
|
2020-05-07 00:23:29 -04:00
|
|
|
"c" #'org-journal-new-entry
|
|
|
|
"d" #'org-journal-new-date-entry
|
|
|
|
"n" #'org-journal-open-next-entry
|
|
|
|
"p" #'org-journal-open-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))
|
2020-01-18 20:34:37 -05:00
|
|
|
(:map org-journal-search-mode-map
|
2020-05-07 00:23:29 -04:00
|
|
|
"n" #'org-journal-search-next
|
|
|
|
"p" #'org-journal-search-prev)))
|