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
|
@ -1,5 +1,7 @@
|
|||
;;; lang/org/+attach.el -*- lexical-binding: t; -*-
|
||||
|
||||
(add-hook 'org-load-hook #'+org|init-attach)
|
||||
|
||||
;; I believe Org's native attachment system is over-complicated and litters
|
||||
;; files with metadata I don't want. So I wrote my own, which:
|
||||
;;
|
||||
|
@ -60,7 +62,7 @@
|
|||
:filter-return #'+org-attach*download-fullname))
|
||||
|
||||
;;
|
||||
(after! org
|
||||
(defun +org|init-attach ()
|
||||
(setq org-attach-directory (expand-file-name +org-attach-dir +org-dir))
|
||||
|
||||
(push (car (last (split-string +org-attach-dir "/" t)))
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
;;; lang/org/+babel.el -*- lexical-binding: t; -*-
|
||||
|
||||
(add-hook 'org-load-hook #'+org|init-babel)
|
||||
|
||||
(defvar +org-babel-languages
|
||||
'(calc
|
||||
css
|
||||
|
@ -23,7 +25,7 @@
|
|||
"A list of org-babel languages to load.")
|
||||
|
||||
|
||||
(after! org
|
||||
(defun +org|init-babel ()
|
||||
(setq org-src-fontify-natively t ; make code pretty
|
||||
org-src-preserve-indentation t ; use native major-mode indentation
|
||||
org-src-tab-acts-natively t
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
;;; lang/org/+capture.el -*- lexical-binding: t; -*-
|
||||
|
||||
(add-hook 'org-load-hook #'+org|init-capture)
|
||||
|
||||
;; Sets up two `org-capture' workflows that I like:
|
||||
;;
|
||||
;; 1. The traditional way: invoking `org-capture' directly (or through a
|
||||
|
@ -26,11 +28,11 @@
|
|||
"* %u %?\n%i" :prepend t :kill-buffer t)))
|
||||
|
||||
|
||||
(after! org
|
||||
(defun +org|init-capture ()
|
||||
(defvaralias 'org-default-notes-file '+org-default-notes-file)
|
||||
|
||||
(setq org-default-notes-file (expand-file-name +org-default-notes-file +org-dir)
|
||||
+org-default-todo-file (expand-file-name +org-default-todo-file +org-dir))
|
||||
+org-default-todo-file (expand-file-name +org-default-todo-file +org-dir))
|
||||
|
||||
(add-hook 'org-capture-after-finalize-hook #'+org-capture|cleanup-frame)
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
;;; lang/org/+export.el -*- lexical-binding: t; -*-
|
||||
|
||||
(add-hook 'org-load-hook #'+org|init-export)
|
||||
|
||||
;; I don't have any beef with org's built-in export system, but I do wish it
|
||||
;; would export to a central directory, rather than `default-directory'. This is
|
||||
;; because all my org files are usually in one place, and I want to be able to
|
||||
|
@ -16,7 +18,7 @@
|
|||
(parse-raw . t))))
|
||||
|
||||
;;
|
||||
(after! org
|
||||
(defun +org|init-export ()
|
||||
(add-transient-hook! #'org-export-dispatch (require 'ox-pandoc))
|
||||
|
||||
(setq org-export-directory (expand-file-name ".export" +org-dir)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
;;; lang/org/+present.el -*- lexical-binding: t; -*-
|
||||
|
||||
(add-hook 'org-load-hook #'+org|init-present)
|
||||
|
||||
(defvar +org-present-text-scale 7
|
||||
"The `text-scale-amount' for `org-tree-slide-mode'.")
|
||||
|
||||
|
@ -43,7 +45,7 @@
|
|||
;; Bootstrap
|
||||
;;
|
||||
|
||||
(after! org
|
||||
(defun +org|init-present ()
|
||||
(require 'ox-reveal)
|
||||
(map! :map org-mode-map "<f8>" #'+org-present/start))
|
||||
|
||||
|
|
|
@ -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