lang/org: general refactor; split init into hooks
lang/org's initialization process is now split up into hooks on org-load-hook. This approach is cleaner and easier to customize. I also removed the escape binding in org-agenda-mode-map, as the popup system makes it redundant.
This commit is contained in:
parent
b57c2e2264
commit
6853196017
6 changed files with 48 additions and 30 deletions
|
@ -33,16 +33,15 @@
|
|||
;; Bootstrap
|
||||
;;
|
||||
|
||||
(after! org
|
||||
(defvaralias 'org-directory '+org-dir)
|
||||
(add-hook! 'org-load-hook
|
||||
#'(org-crypt-use-before-save-magic
|
||||
+org|setup-ui
|
||||
+org|setup-agenda
|
||||
+org|setup-keybinds
|
||||
+org|setup-hacks))
|
||||
|
||||
(org-crypt-use-before-save-magic)
|
||||
(+org-init-ui)
|
||||
(+org-init-keybinds)
|
||||
(+org-hacks))
|
||||
|
||||
(add-hook! org-mode
|
||||
#'(doom|disable-line-numbers ; no line numbers
|
||||
(add-hook! 'org-mode-hook
|
||||
#'(doom|disable-line-numbers ; org doesn't really need em
|
||||
org-bullets-mode ; "prettier" bullets
|
||||
org-indent-mode ; margin-based indentation
|
||||
toc-org-enable ; auto-table of contents
|
||||
|
@ -55,9 +54,15 @@
|
|||
+org|show-paren-mode-compatibility
|
||||
))
|
||||
|
||||
(after! org
|
||||
(defvaralias 'org-directory '+org-dir))
|
||||
|
||||
(when (featurep 'org)
|
||||
(run-hooks 'org-load-hook))
|
||||
|
||||
|
||||
;;
|
||||
;; Config hooks
|
||||
;; `org-mode' hooks
|
||||
;;
|
||||
|
||||
(defun +org|unfold-to-2nd-level-or-point ()
|
||||
|
@ -106,18 +111,23 @@ unfold to point on startup."
|
|||
|
||||
|
||||
;;
|
||||
(defun +org-init-ui ()
|
||||
"Configures the UI for `org-mode'."
|
||||
;; `org-load' hooks
|
||||
;;
|
||||
|
||||
(defun +org|setup-agenda ()
|
||||
(setq-default
|
||||
org-adapt-indentation nil
|
||||
org-agenda-dim-blocked-tasks nil
|
||||
org-agenda-files (ignore-errors (directory-files +org-dir t "\\.org$" t))
|
||||
org-agenda-inhibit-startup t
|
||||
org-agenda-skip-unavailable-files nil
|
||||
org-agenda-skip-unavailable-files t))
|
||||
|
||||
(defun +org|setup-ui ()
|
||||
"Configures the UI for `org-mode'."
|
||||
(setq-default
|
||||
org-adapt-indentation nil
|
||||
org-cycle-include-plain-lists t
|
||||
org-cycle-separator-lines 1
|
||||
org-entities-user '(("flat" "\\flat" nil "" "" "266D" "♭") ("sharp" "\\sharp" nil "" "" "266F" "♯"))
|
||||
;; org-ellipsis " ... "
|
||||
org-fontify-done-headline t
|
||||
org-fontify-quote-and-verse-blocks t
|
||||
org-fontify-whole-heading-line t
|
||||
|
@ -147,8 +157,8 @@ unfold to point on startup."
|
|||
outline-blank-line t
|
||||
|
||||
;; LaTeX previews are too small and usually render to light backgrounds, so
|
||||
;; this enlargens them and ensures their background (and foreground) match the
|
||||
;; current theme.
|
||||
;; this enlargens them and ensures their background (and foreground) match
|
||||
;; the current theme.
|
||||
org-preview-latex-image-directory (concat doom-cache-dir "org-latex/")
|
||||
org-format-latex-options (plist-put org-format-latex-options :scale 1.5)
|
||||
org-format-latex-options
|
||||
|
@ -167,7 +177,7 @@ unfold to point on startup."
|
|||
'org-link
|
||||
'error))))
|
||||
|
||||
(defun +org-init-keybinds ()
|
||||
(defun +org|setup-keybinds ()
|
||||
"Sets up org-mode and evil keybindings. Tries to fix the idiosyncrasies
|
||||
between the two."
|
||||
(map! :map org-mode-map
|
||||
|
@ -195,6 +205,7 @@ between the two."
|
|||
:ni [M-return] (λ! (+org/insert-item 'below))
|
||||
:ni [S-M-return] (λ! (+org/insert-item 'above))
|
||||
|
||||
;; Fix vim motion keys
|
||||
:m "]]" (λ! (org-forward-heading-same-level nil) (org-beginning-of-line))
|
||||
:m "[[" (λ! (org-backward-heading-same-level nil) (org-beginning-of-line))
|
||||
:m "]l" #'org-next-link
|
||||
|
@ -206,7 +217,6 @@ between the two."
|
|||
:n ">" #'org-metaright
|
||||
:v "<" (λ! (org-metaleft) (evil-visual-restore))
|
||||
:v ">" (λ! (org-metaright) (evil-visual-restore))
|
||||
|
||||
;; Fix code-folding keybindings
|
||||
:n "za" #'+org/toggle-fold
|
||||
:n "zA" #'org-shifttab
|
||||
|
@ -220,18 +230,16 @@ between the two."
|
|||
|
||||
(:after org-agenda
|
||||
(:map org-agenda-mode-map
|
||||
:e "<escape>" #'org-agenda-Quit
|
||||
:e "m" #'org-agenda-month-view
|
||||
:e "C-j" #'org-agenda-next-item
|
||||
:e "C-k" #'org-agenda-previous-item
|
||||
:e "C-n" #'org-agenda-next-item
|
||||
:e "C-p" #'org-agenda-previous-item))))
|
||||
|
||||
;;
|
||||
(defun +org-hacks ()
|
||||
(defun +org|setup-hacks ()
|
||||
"Getting org to behave."
|
||||
;; Don't open separate windows
|
||||
(push '(file . find-file) org-link-frame-setup)
|
||||
(map-put org-link-frame-setup 'file 'find-file)
|
||||
|
||||
;; Let OS decide what to do with files when opened
|
||||
(setq org-file-apps
|
||||
|
@ -252,4 +260,4 @@ between the two."
|
|||
(cl-find (file-truename filename) org-agenda-files
|
||||
:key #'file-truename
|
||||
:test #'equal))
|
||||
(add-to-list 'recentf-exclude #'+org-is-agenda-file)))
|
||||
(push #'+org-is-agenda-file recentf-exclude)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue