2017-12-08 22:59:42 -05:00
|
|
|
;;; lang/org/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
2021-07-28 15:00:35 -04:00
|
|
|
(defvar +org-babel-native-async-langs '(python)
|
|
|
|
"Languages that will use `ob-comint' instead of `ob-async' for `:async'.")
|
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
(defvar +org-babel-mode-alist
|
2021-04-17 00:08:29 -04:00
|
|
|
'((c . C)
|
|
|
|
(cpp . C)
|
2019-10-25 20:00:06 -04:00
|
|
|
(C++ . C)
|
|
|
|
(D . C)
|
2020-05-06 02:49:00 -04:00
|
|
|
(elisp . emacs-lisp)
|
2019-10-25 20:00:06 -04:00
|
|
|
(sh . shell)
|
|
|
|
(bash . shell)
|
2020-02-16 00:49:01 -05:00
|
|
|
(matlab . octave)
|
2020-05-17 21:28:31 +02:00
|
|
|
(rust . rustic-babel)
|
2020-02-16 00:49:01 -05:00
|
|
|
(amm . ammonite))
|
2019-10-25 20:00:06 -04:00
|
|
|
"An alist mapping languages to babel libraries. This is necessary for babel
|
|
|
|
libraries (ob-*.el) that don't match the name of the language.
|
|
|
|
|
2021-10-18 11:43:44 +02:00
|
|
|
For example, (fish . shell) will cause #+begin_src fish blocks to load
|
2020-04-08 15:29:29 -04:00
|
|
|
ob-shell.el when executed.")
|
2019-10-25 20:00:06 -04:00
|
|
|
|
|
|
|
(defvar +org-babel-load-functions ()
|
|
|
|
"A list of functions executed to load the current executing src block. They
|
|
|
|
take one argument (the language specified in the src block, as a string). Stops
|
|
|
|
at the first function to return non-nil.")
|
|
|
|
|
|
|
|
(defvar +org-capture-todo-file "todo.org"
|
|
|
|
"Default target for todo entries.
|
|
|
|
|
|
|
|
Is relative to `org-directory', unless it is absolute. Is used in Doom's default
|
|
|
|
`org-capture-templates'.")
|
|
|
|
|
|
|
|
(defvar +org-capture-changelog-file "changelog.org"
|
|
|
|
"Default target for changelog entries.
|
|
|
|
|
|
|
|
Is relative to `org-directory' unless it is absolute. Is used in Doom's default
|
|
|
|
`org-capture-templates'.")
|
|
|
|
|
|
|
|
(defvar +org-capture-notes-file "notes.org"
|
|
|
|
"Default target for storing notes.
|
|
|
|
|
|
|
|
Used as a fall back file for org-capture.el, for templates that do not specify a
|
|
|
|
target file.
|
|
|
|
|
|
|
|
Is relative to `org-directory', unless it is absolute. Is used in Doom's default
|
|
|
|
`org-capture-templates'.")
|
|
|
|
|
2019-10-31 23:09:26 -04:00
|
|
|
(defvar +org-capture-journal-file "journal.org"
|
|
|
|
"Default target for storing timestamped journal entries.
|
|
|
|
|
|
|
|
Is relative to `org-directory', unless it is absolute. Is used in Doom's default
|
|
|
|
`org-capture-templates'.")
|
|
|
|
|
2019-10-31 22:45:59 -04:00
|
|
|
(defvar +org-capture-projects-file "projects.org"
|
|
|
|
"Default, centralized target for org-capture templates.")
|
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
(defvar +org-habit-graph-padding 2
|
|
|
|
"The padding added to the end of the consistency graph")
|
|
|
|
|
|
|
|
(defvar +org-habit-min-width 30
|
|
|
|
"Hides the consistency graph if the `org-habit-graph-column' is less than this value")
|
|
|
|
|
|
|
|
(defvar +org-habit-graph-window-ratio 0.3
|
|
|
|
"The ratio of the consistency graphs relative to the window width")
|
|
|
|
|
2021-07-31 02:01:37 -04:00
|
|
|
(defvar +org-startup-with-animated-gifs nil
|
|
|
|
"If non-nil, and the cursor is over a gif inline-image preview, animate it!")
|
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
|
2017-07-05 02:33:41 +02:00
|
|
|
;;
|
2019-03-07 00:15:15 -05:00
|
|
|
;;; `org-load' hooks
|
2018-01-08 20:38:46 -05:00
|
|
|
|
2020-04-25 15:40:24 -04:00
|
|
|
(defun +org-init-org-directory-h ()
|
|
|
|
(unless org-directory
|
2020-11-03 22:00:15 -05:00
|
|
|
(setq-default org-directory "~/org"))
|
2021-02-07 13:16:06 +01:00
|
|
|
(unless org-id-locations-file
|
|
|
|
(setq org-id-locations-file (expand-file-name ".orgids" org-directory))))
|
2020-04-25 15:40:24 -04:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-agenda-h ()
|
2018-09-30 15:14:01 -04:00
|
|
|
(unless org-agenda-files
|
2020-11-03 22:00:15 -05:00
|
|
|
(setq-default org-agenda-files (list org-directory)))
|
2017-07-05 02:33:41 +02:00
|
|
|
(setq-default
|
2020-08-05 18:17:13 -04:00
|
|
|
;; Different colors for different priority levels
|
2020-07-31 01:31:03 -04:00
|
|
|
org-agenda-deadline-faces
|
|
|
|
'((1.001 . error)
|
|
|
|
(1.0 . org-warning)
|
|
|
|
(0.5 . org-upcoming-deadline)
|
|
|
|
(0.0 . org-upcoming-distant-deadline))
|
2019-09-10 14:54:13 -04:00
|
|
|
;; Don't monopolize the whole frame just for the agenda
|
|
|
|
org-agenda-window-setup 'current-window
|
2018-06-10 01:32:19 +02:00
|
|
|
org-agenda-skip-unavailable-files t
|
2020-08-05 18:17:13 -04:00
|
|
|
;; Shift the agenda to show the previous 3 days and the next 7 days for
|
|
|
|
;; better context on your week. The past is less important than the future.
|
2018-06-10 01:32:19 +02:00
|
|
|
org-agenda-span 10
|
|
|
|
org-agenda-start-on-weekday nil
|
2020-07-31 01:33:16 -04:00
|
|
|
org-agenda-start-day "-3d"
|
|
|
|
;; Optimize `org-agenda' by inhibiting extra work while opening agenda
|
|
|
|
;; buffers in the background. They'll be "restarted" if the user switches to
|
|
|
|
;; them anyway (see `+org-exclude-agenda-buffers-from-workspace-h')
|
|
|
|
org-agenda-inhibit-startup t))
|
2018-01-08 20:38:46 -05:00
|
|
|
|
2019-03-07 00:15:15 -05:00
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-appearance-h ()
|
2018-01-08 20:38:46 -05:00
|
|
|
"Configures the UI for `org-mode'."
|
2019-10-28 02:02:45 -04:00
|
|
|
(setq org-indirect-buffer-display 'current-window
|
|
|
|
org-eldoc-breadcrumb-separator " → "
|
|
|
|
org-enforce-todo-dependencies t
|
|
|
|
org-entities-user
|
|
|
|
'(("flat" "\\flat" nil "" "" "266D" "♭")
|
|
|
|
("sharp" "\\sharp" nil "" "" "266F" "♯"))
|
2020-07-31 01:31:03 -04:00
|
|
|
org-fontify-done-headline t
|
2019-10-28 02:02:45 -04:00
|
|
|
org-fontify-quote-and-verse-blocks t
|
|
|
|
org-fontify-whole-heading-line t
|
|
|
|
org-hide-leading-stars t
|
|
|
|
org-image-actual-width nil
|
2021-09-25 00:54:13 +02:00
|
|
|
org-imenu-depth 6
|
2019-10-28 02:02:45 -04:00
|
|
|
org-priority-faces
|
|
|
|
'((?A . error)
|
|
|
|
(?B . warning)
|
|
|
|
(?C . success))
|
|
|
|
org-startup-indented t
|
2019-11-29 21:55:18 -05:00
|
|
|
org-tags-column 0
|
2021-09-25 00:56:31 +02:00
|
|
|
org-use-sub-superscripts '{}
|
|
|
|
;; `showeverything' is org's default, but it doesn't respect
|
|
|
|
;; `org-hide-block-startup' (#+startup: hideblocks), archive trees,
|
|
|
|
;; hidden drawers, or VISIBILITY properties. `nil' is equivalent, but
|
|
|
|
;; respects these settings.
|
|
|
|
org-startup-folded nil)
|
2019-10-27 17:23:22 -04:00
|
|
|
|
2019-10-28 00:49:10 -04:00
|
|
|
(setq org-refile-targets
|
|
|
|
'((nil :maxlevel . 3)
|
|
|
|
(org-agenda-files :maxlevel . 3))
|
|
|
|
;; Without this, completers like ivy/helm are only given the first level of
|
|
|
|
;; each outline candidates. i.e. all the candidates under the "Tasks" heading
|
|
|
|
;; are just "Tasks/". This is unhelpful. We want the full path to each refile
|
2019-10-31 14:35:07 -04:00
|
|
|
;; target! e.g. FILE/Tasks/heading/subheading
|
2019-10-28 00:49:10 -04:00
|
|
|
org-refile-use-outline-path 'file
|
|
|
|
org-outline-path-complete-in-steps nil)
|
|
|
|
|
2020-04-14 15:34:20 -04:00
|
|
|
(plist-put org-format-latex-options :scale 1.5) ; larger previews
|
2019-10-25 20:00:06 -04:00
|
|
|
|
2019-10-27 14:05:31 -04:00
|
|
|
;; HACK Face specs fed directly to `org-todo-keyword-faces' don't respect
|
|
|
|
;; underlying faces like the `org-todo' face does, so we define our own
|
|
|
|
;; intermediary faces that extend from org-todo.
|
2019-11-23 00:52:36 -05:00
|
|
|
(with-no-warnings
|
2020-03-27 01:25:30 -04:00
|
|
|
(custom-declare-face '+org-todo-active '((t (:inherit (bold font-lock-constant-face org-todo)))) "")
|
2019-11-23 00:52:36 -05:00
|
|
|
(custom-declare-face '+org-todo-project '((t (:inherit (bold font-lock-doc-face org-todo)))) "")
|
2021-02-26 21:27:17 -05:00
|
|
|
(custom-declare-face '+org-todo-onhold '((t (:inherit (bold warning org-todo)))) "")
|
|
|
|
(custom-declare-face '+org-todo-cancel '((t (:inherit (bold error org-todo)))) ""))
|
2019-10-27 14:05:31 -04:00
|
|
|
(setq org-todo-keywords
|
|
|
|
'((sequence
|
|
|
|
"TODO(t)" ; A task that needs doing & is ready to do
|
2020-04-17 14:49:58 -04:00
|
|
|
"PROJ(p)" ; A project, which usually contains other tasks
|
2021-02-26 21:27:17 -05:00
|
|
|
"LOOP(r)" ; A recurring task
|
2019-10-29 11:36:22 -04:00
|
|
|
"STRT(s)" ; A task that is in progress
|
2020-04-17 14:49:58 -04:00
|
|
|
"WAIT(w)" ; Something external is holding up this task
|
|
|
|
"HOLD(h)" ; This task is paused/on hold because of me
|
2021-02-26 21:27:17 -05:00
|
|
|
"IDEA(i)" ; An unconfirmed and unapproved task or notion
|
2019-10-27 14:05:31 -04:00
|
|
|
"|"
|
2019-10-28 12:57:11 -04:00
|
|
|
"DONE(d)" ; Task successfully completed
|
2019-10-27 14:05:31 -04:00
|
|
|
"KILL(k)") ; Task was cancelled, aborted or is no longer applicable
|
|
|
|
(sequence
|
|
|
|
"[ ](T)" ; A task that needs doing
|
2019-10-28 12:57:11 -04:00
|
|
|
"[-](S)" ; Task is in progress
|
2019-10-27 14:05:31 -04:00
|
|
|
"[?](W)" ; Task is being held up or paused
|
|
|
|
"|"
|
2021-02-26 21:27:17 -05:00
|
|
|
"[X](D)") ; Task was completed
|
|
|
|
(sequence
|
|
|
|
"|"
|
|
|
|
"OKAY(o)"
|
|
|
|
"YES(y)"
|
|
|
|
"NO(n)"))
|
2019-10-27 14:05:31 -04:00
|
|
|
org-todo-keyword-faces
|
|
|
|
'(("[-]" . +org-todo-active)
|
2019-10-28 12:57:11 -04:00
|
|
|
("STRT" . +org-todo-active)
|
2019-10-27 14:05:31 -04:00
|
|
|
("[?]" . +org-todo-onhold)
|
|
|
|
("WAIT" . +org-todo-onhold)
|
2020-04-17 14:49:58 -04:00
|
|
|
("HOLD" . +org-todo-onhold)
|
2021-02-26 21:27:17 -05:00
|
|
|
("PROJ" . +org-todo-project)
|
|
|
|
("NO" . +org-todo-cancel)
|
|
|
|
("KILL" . +org-todo-cancel)))
|
2019-10-27 14:05:31 -04:00
|
|
|
|
2020-05-15 01:44:53 -04:00
|
|
|
(defadvice! +org-display-link-in-eldoc-a (&rest _)
|
2019-10-25 20:00:06 -04:00
|
|
|
"Display full link in minibuffer when cursor/mouse is over it."
|
2020-04-27 17:43:29 -04:00
|
|
|
:before-until #'org-eldoc-documentation-function
|
2021-07-31 12:29:30 -04:00
|
|
|
(when-let* ((context (org-element-context))
|
|
|
|
(path (org-element-property :path context)))
|
|
|
|
(pcase (org-element-property :type context)
|
|
|
|
("kbd"
|
|
|
|
(format "%s %s"
|
|
|
|
(propertize "Key sequence:" 'face 'bold)
|
|
|
|
(propertize (+org-read-kbd-at-point path context)
|
|
|
|
'face 'help-key-binding)))
|
|
|
|
("doom-module"
|
|
|
|
(format "%s %s"
|
|
|
|
(propertize "Doom module:" 'face 'bold)
|
|
|
|
(propertize (+org-read-link-description-at-point path)
|
|
|
|
'face 'org-priority)))
|
|
|
|
("doom-package"
|
|
|
|
(format "%s %s"
|
|
|
|
(propertize "Doom package:" 'face 'bold)
|
|
|
|
(propertize (+org-read-link-description-at-point path)
|
|
|
|
'face 'org-priority)))
|
|
|
|
(type (format "Link: %s" (org-element-property :raw-link context))))))
|
2019-02-22 02:07:44 -05:00
|
|
|
|
2019-10-31 14:35:07 -04:00
|
|
|
;; Automatic indent detection in org files is meaningless
|
2020-03-27 01:25:30 -04:00
|
|
|
(add-to-list 'doom-detect-indentation-excluded-modes 'org-mode)
|
2018-07-29 02:54:19 +02:00
|
|
|
|
2020-08-12 18:52:14 -04:00
|
|
|
(set-ligatures! 'org-mode
|
2019-06-28 16:53:26 +02:00
|
|
|
:name "#+NAME:"
|
2020-04-03 12:01:34 +02:00
|
|
|
:name "#+name:"
|
2019-06-28 16:53:26 +02:00
|
|
|
:src_block "#+BEGIN_SRC"
|
2020-04-03 12:01:34 +02:00
|
|
|
:src_block "#+begin_src"
|
|
|
|
:src_block_end "#+END_SRC"
|
|
|
|
:src_block_end "#+end_src"
|
|
|
|
:quote "#+BEGIN_QUOTE"
|
|
|
|
:quote "#+begin_quote"
|
|
|
|
:quote_end "#+END_QUOTE"
|
|
|
|
:quote_end "#+end_quote"))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-babel-h ()
|
2019-09-05 13:12:44 -04:00
|
|
|
(setq org-src-preserve-indentation t ; use native major-mode indentation
|
2020-01-01 20:59:58 -05:00
|
|
|
org-src-tab-acts-natively t ; we do this ourselves
|
2019-10-31 23:13:03 -04:00
|
|
|
;; You don't need my permission (just be careful, mkay?)
|
|
|
|
org-confirm-babel-evaluate nil
|
|
|
|
org-link-elisp-confirm-function nil
|
2019-09-10 14:54:13 -04:00
|
|
|
;; Show src buffer in popup, and don't monopolize the frame
|
2019-12-02 19:55:05 -05:00
|
|
|
org-src-window-setup 'other-window
|
|
|
|
;; Our :lang common-lisp module uses sly, so...
|
|
|
|
org-babel-lisp-eval-fn #'sly-eval)
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
;; I prefer C-c C-c over C-c ' (more consistent)
|
|
|
|
(define-key org-src-mode-map (kbd "C-c C-c") #'org-edit-src-exit)
|
|
|
|
|
2021-02-25 13:16:21 -05:00
|
|
|
;; Don't process babel results asynchronously when exporting org, as they
|
|
|
|
;; won't likely complete in time, and will instead output an ob-async hash
|
|
|
|
;; instead of the wanted evaluation results.
|
|
|
|
(after! ob
|
2021-03-01 10:54:27 -05:00
|
|
|
(add-to-list 'org-babel-default-lob-header-args '(:sync)))
|
|
|
|
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +org-babel-disable-async-maybe-a (fn &optional orig-fn arg info params)
|
2021-07-28 15:00:35 -04:00
|
|
|
"Use ob-comint where supported, disable async altogether where it isn't.
|
|
|
|
|
|
|
|
We have access to two async backends: ob-comint or ob-async, which have
|
|
|
|
different requirements. This advice tries to pick the best option between them,
|
|
|
|
falling back to synchronous execution otherwise. Without this advice, they die
|
|
|
|
with an error; terrible UX!
|
2021-03-01 10:54:27 -05:00
|
|
|
|
2021-07-28 15:00:35 -04:00
|
|
|
Note: ob-comint support will only kick in for languages listed in
|
|
|
|
`+org-babel-native-async-langs'.
|
2021-03-01 10:54:27 -05:00
|
|
|
|
|
|
|
Also adds support for a `:sync' parameter to override `:async'."
|
2021-02-25 13:16:21 -05:00
|
|
|
:around #'ob-async-org-babel-execute-src-block
|
2021-08-04 01:18:06 -04:00
|
|
|
(if (null orig-fn)
|
|
|
|
(funcall fn orig-fn arg info params)
|
2021-03-01 10:54:27 -05:00
|
|
|
(let* ((info (or info (org-babel-get-src-block-info)))
|
|
|
|
(params (org-babel-merge-params (nth 2 info) params)))
|
2021-07-28 15:00:35 -04:00
|
|
|
(if (or (assq :sync params)
|
|
|
|
(not (assq :async params))
|
|
|
|
(member (car info) ob-async-no-async-languages-alist)
|
|
|
|
;; ob-comint requires a :session, ob-async does not, so fall
|
|
|
|
;; back to ob-async if no :session is provided.
|
|
|
|
(unless (member (alist-get :session params) '("none" nil))
|
|
|
|
(unless (memq (let* ((lang (nth 0 info))
|
|
|
|
(lang (cond ((symbolp lang) lang)
|
|
|
|
((stringp lang) (intern lang)))))
|
|
|
|
(or (alist-get lang +org-babel-mode-alist)
|
|
|
|
lang))
|
|
|
|
+org-babel-native-async-langs)
|
|
|
|
(message "Org babel: %s :session is incompatible with :async. Executing synchronously!"
|
|
|
|
(car info))
|
|
|
|
(sleep-for 0.2))
|
|
|
|
t))
|
2021-08-04 01:18:06 -04:00
|
|
|
(funcall orig-fn arg info params)
|
|
|
|
(funcall fn orig-fn arg info params)))))
|
2021-02-25 13:16:21 -05:00
|
|
|
|
2022-02-10 21:28:55 +01:00
|
|
|
;; HACK Fix #6061. Seems `org-babel-do-in-edit-buffer' has the side effect of
|
|
|
|
;; deleting side windows. Should be reported upstream! This advice
|
|
|
|
;; suppresses this behavior wherever it is known to be used.
|
|
|
|
(defadvice! +org-fix-window-excursions-a (fn &rest args)
|
|
|
|
"Suppress changes to the window config anywhere
|
|
|
|
`org-babel-do-in-edit-buffer' is used."
|
|
|
|
:around #'evil-org-open-below
|
|
|
|
:around #'evil-org-open-above
|
|
|
|
:around #'org-indent-region
|
|
|
|
:around #'org-indent-line
|
|
|
|
(save-window-excursion (apply fn args)))
|
|
|
|
|
2020-05-15 01:44:53 -04:00
|
|
|
(defadvice! +org-fix-newline-and-indent-in-src-blocks-a (&optional indent _arg _interactive)
|
2019-10-25 20:00:06 -04:00
|
|
|
"Mimic `newline-and-indent' in src blocks w/ lang-appropriate indentation."
|
2020-05-15 01:44:53 -04:00
|
|
|
:after #'org-return
|
2020-07-31 15:41:34 -04:00
|
|
|
(when (and indent
|
|
|
|
org-src-tab-acts-natively
|
|
|
|
(org-in-src-block-p t))
|
2022-02-10 21:28:55 +01:00
|
|
|
(save-window-excursion
|
|
|
|
(org-babel-do-in-edit-buffer
|
|
|
|
(call-interactively #'indent-for-tab-command)))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +org-inhibit-mode-hooks-a (fn datum name &optional initialize &rest args)
|
2020-07-31 15:41:34 -04:00
|
|
|
"Prevent potentially expensive mode hooks in `org-babel-do-in-edit-buffer' ops."
|
|
|
|
:around #'org-src--edit-element
|
2021-08-04 01:18:06 -04:00
|
|
|
(apply fn datum name
|
2020-07-31 15:41:34 -04:00
|
|
|
(if (and (eq org-src-window-setup 'switch-invisibly)
|
|
|
|
(functionp initialize))
|
|
|
|
;; org-babel-do-in-edit-buffer is used to execute quick, one-off
|
2020-08-20 01:48:49 -04:00
|
|
|
;; logic in the context of another major mode, but initializing a
|
|
|
|
;; major mode with expensive hooks can be terribly expensive.
|
|
|
|
;; Since Doom adds its most expensive hooks to
|
|
|
|
;; MAJOR-MODE-local-vars-hook, we can savely inhibit those.
|
2020-07-31 15:41:34 -04:00
|
|
|
(lambda ()
|
2020-08-20 01:48:49 -04:00
|
|
|
(let ((doom-inhibit-local-var-hooks t))
|
|
|
|
(funcall initialize)))
|
2020-07-31 15:41:34 -04:00
|
|
|
initialize)
|
|
|
|
args))
|
|
|
|
|
2019-10-22 17:58:30 -04:00
|
|
|
;; Refresh inline images after executing src blocks (useful for plantuml or
|
|
|
|
;; ipython, where the result could be an image)
|
2022-01-27 01:18:02 +01:00
|
|
|
(add-hook! 'org-babel-after-execute-hook
|
|
|
|
(defun +org-redisplay-inline-images-in-babel-result-h ()
|
|
|
|
(unless (or
|
|
|
|
;; ...but not while Emacs is exporting an org buffer (where
|
|
|
|
;; `org-display-inline-images' can be awfully slow).
|
|
|
|
(bound-and-true-p org-export-current-backend)
|
|
|
|
;; ...and not while tangling org buffers (which happens in a temp
|
|
|
|
;; buffer where `buffer-file-name' is nil).
|
|
|
|
(string-match-p "^ \\*temp" (buffer-name)))
|
2022-01-29 18:42:20 +01:00
|
|
|
(save-excursion
|
|
|
|
(when-let ((beg (org-babel-where-is-src-block-result))
|
2022-01-30 01:27:17 +01:00
|
|
|
(end (progn (goto-char beg) (forward-line) (org-babel-result-end))))
|
|
|
|
(org-display-inline-images nil nil (min beg end) (max beg end)))))))
|
2019-10-22 17:58:30 -04:00
|
|
|
|
2020-02-28 18:52:50 +01:00
|
|
|
(after! python
|
2021-10-03 20:38:27 +02:00
|
|
|
(unless org-babel-python-command
|
|
|
|
(setq org-babel-python-command
|
2021-11-28 21:59:52 +01:00
|
|
|
(string-trim
|
|
|
|
(concat python-shell-interpreter " "
|
|
|
|
(if (string-match-p "\\<i?python[23]?$" python-shell-interpreter)
|
|
|
|
(replace-regexp-in-string
|
|
|
|
"\\(^\\| \\)-i\\( \\|$\\)" " " python-shell-interpreter-args)
|
|
|
|
python-shell-interpreter-args))))))
|
2020-11-09 02:25:59 -05:00
|
|
|
|
2021-04-21 19:21:54 -04:00
|
|
|
(after! ob-ditaa
|
|
|
|
;; TODO Should be fixed upstream
|
|
|
|
(let ((default-directory (org-find-library-dir "org-contribdir")))
|
|
|
|
(setq org-ditaa-jar-path (expand-file-name "scripts/ditaa.jar")
|
Drop Emacs 26.x support
Emacs 27.x has been the stable version of Emacs for nearly a year, and
introduces a litany of bugfixes, performance, and quality-of-life
improvements that significantly reduce Doom's maintenance burden (like
XDG support, early-init.el, image manipulation without imagemagick, a
native JSON library, harfbuzz support, pdumper, and others).
With so many big changes on Doom's horizon, I like having one less (big)
thing to worry about.
Also reverts bb677cf7a (#5232) as it is no longer needed.
2021-07-06 01:54:32 -04:00
|
|
|
org-ditaa-eps-jar-path (expand-file-name "scripts/DitaaEps.jar")))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-babel-lazy-loader-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
"Load babel libraries lazily when babel blocks are executed."
|
2020-04-13 15:23:16 -04:00
|
|
|
(defun +org--babel-lazy-load (lang &optional async)
|
|
|
|
(cl-check-type lang (or symbol null))
|
|
|
|
(unless (cdr (assq lang org-babel-load-languages))
|
|
|
|
(when async
|
|
|
|
;; ob-async has its own agenda for lazy loading packages (in the child
|
|
|
|
;; process), so we only need to make sure it's loaded.
|
|
|
|
(require 'ob-async nil t))
|
|
|
|
(prog1 (or (run-hook-with-args-until-success '+org-babel-load-functions lang)
|
|
|
|
(require (intern (format "ob-%s" lang)) nil t)
|
|
|
|
(require lang nil t))
|
|
|
|
(add-to-list 'org-babel-load-languages (cons lang t)))))
|
|
|
|
|
2020-04-14 01:29:27 -04:00
|
|
|
(defadvice! +org--export-lazy-load-library-h ()
|
2020-04-14 15:37:00 -04:00
|
|
|
"Lazy load a babel package when a block is executed during exporting."
|
2020-04-14 01:29:27 -04:00
|
|
|
:before #'org-babel-exp-src-block
|
|
|
|
(+org--babel-lazy-load-library-a (org-babel-get-src-block-info)))
|
2019-12-18 10:18:58 -05:00
|
|
|
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +org--src-lazy-load-library-a (lang)
|
2019-07-10 19:30:56 +02:00
|
|
|
"Lazy load a babel package to ensure syntax highlighting."
|
2019-07-21 02:38:42 +02:00
|
|
|
:before #'org-src--get-lang-mode
|
2019-07-10 19:30:56 +02:00
|
|
|
(or (cdr (assoc lang org-src-lang-modes))
|
2019-12-18 10:18:58 -05:00
|
|
|
(+org--babel-lazy-load lang)))
|
2019-07-10 19:30:56 +02:00
|
|
|
|
2020-04-13 15:23:16 -04:00
|
|
|
;; This also works for tangling
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +org--babel-lazy-load-library-a (info)
|
2019-06-28 16:53:26 +02:00
|
|
|
"Load babel libraries lazily when babel blocks are executed."
|
2019-07-21 02:38:42 +02:00
|
|
|
:after-while #'org-babel-confirm-evaluate
|
2019-06-28 16:53:26 +02:00
|
|
|
(let* ((lang (nth 0 info))
|
2019-09-08 20:55:21 -04:00
|
|
|
(lang (cond ((symbolp lang) lang)
|
|
|
|
((stringp lang) (intern lang))))
|
2019-06-28 16:53:26 +02:00
|
|
|
(lang (or (cdr (assq lang +org-babel-mode-alist))
|
|
|
|
lang)))
|
2021-03-01 10:54:27 -05:00
|
|
|
(+org--babel-lazy-load
|
|
|
|
lang (and (not (assq :sync (nth 2 info)))
|
|
|
|
(assq :async (nth 2 info))))
|
2019-12-16 16:48:02 -05:00
|
|
|
t))
|
|
|
|
|
2020-03-27 18:06:31 -04:00
|
|
|
(advice-add #'org-babel-do-load-languages :override #'ignore))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-capture-defaults-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
"Sets up some reasonable defaults, as well as two `org-capture' workflows that
|
|
|
|
I like:
|
|
|
|
|
|
|
|
1. The traditional way: invoking `org-capture' directly, via SPC X, or through
|
|
|
|
the :cap ex command.
|
|
|
|
2. Through a org-capture popup frame that is invoked from outside Emacs (the
|
|
|
|
~/.emacs.d/bin/org-capture script). This can be invoked from qutebrowser,
|
|
|
|
vimperator, dmenu or a global keybinding."
|
|
|
|
(setq org-default-notes-file
|
|
|
|
(expand-file-name +org-capture-notes-file org-directory)
|
2020-01-12 15:03:24 +00:00
|
|
|
+org-capture-journal-file
|
|
|
|
(expand-file-name +org-capture-journal-file org-directory)
|
2019-06-28 16:53:26 +02:00
|
|
|
org-capture-templates
|
|
|
|
'(("t" "Personal todo" entry
|
|
|
|
(file+headline +org-capture-todo-file "Inbox")
|
2019-10-31 23:12:02 -04:00
|
|
|
"* [ ] %?\n%i\n%a" :prepend t)
|
2019-06-28 16:53:26 +02:00
|
|
|
("n" "Personal notes" entry
|
|
|
|
(file+headline +org-capture-notes-file "Inbox")
|
2019-10-31 22:45:59 -04:00
|
|
|
"* %u %?\n%i\n%a" :prepend t)
|
2019-10-31 23:09:26 -04:00
|
|
|
("j" "Journal" entry
|
2020-01-25 17:07:31 -05:00
|
|
|
(file+olp+datetree +org-capture-journal-file)
|
2019-10-31 23:09:26 -04:00
|
|
|
"* %U %?\n%i\n%a" :prepend t)
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
;; Will use {project-root}/{todo,notes,changelog}.org, unless a
|
|
|
|
;; {todo,notes,changelog}.org file is found in a parent directory.
|
|
|
|
;; Uses the basename from `+org-capture-todo-file',
|
|
|
|
;; `+org-capture-changelog-file' and `+org-capture-notes-file'.
|
|
|
|
("p" "Templates for projects")
|
2019-10-31 22:45:59 -04:00
|
|
|
("pt" "Project-local todo" entry ; {project-root}/todo.org
|
2019-06-28 16:53:26 +02:00
|
|
|
(file+headline +org-capture-project-todo-file "Inbox")
|
2019-10-31 22:45:59 -04:00
|
|
|
"* TODO %?\n%i\n%a" :prepend t)
|
|
|
|
("pn" "Project-local notes" entry ; {project-root}/notes.org
|
2019-06-28 16:53:26 +02:00
|
|
|
(file+headline +org-capture-project-notes-file "Inbox")
|
2019-10-31 23:12:35 -04:00
|
|
|
"* %U %?\n%i\n%a" :prepend t)
|
2019-10-31 22:45:59 -04:00
|
|
|
("pc" "Project-local changelog" entry ; {project-root}/changelog.org
|
2019-10-29 12:18:19 -04:00
|
|
|
(file+headline +org-capture-project-changelog-file "Unreleased")
|
2019-10-31 23:12:35 -04:00
|
|
|
"* %U %?\n%i\n%a" :prepend t)
|
2019-10-31 22:45:59 -04:00
|
|
|
|
|
|
|
;; Will use {org-directory}/{+org-capture-projects-file} and store
|
|
|
|
;; these under {ProjectName}/{Tasks,Notes,Changelog} headings. They
|
|
|
|
;; support `:parents' to specify what headings to put them under, e.g.
|
|
|
|
;; :parents ("Projects")
|
|
|
|
("o" "Centralized templates for projects")
|
|
|
|
("ot" "Project todo" entry
|
|
|
|
(function +org-capture-central-project-todo-file)
|
|
|
|
"* TODO %?\n %i\n %a"
|
|
|
|
:heading "Tasks"
|
|
|
|
:prepend nil)
|
|
|
|
("on" "Project notes" entry
|
|
|
|
(function +org-capture-central-project-notes-file)
|
2019-10-31 23:12:35 -04:00
|
|
|
"* %U %?\n %i\n %a"
|
2019-10-31 22:45:59 -04:00
|
|
|
:heading "Notes"
|
|
|
|
:prepend t)
|
|
|
|
("oc" "Project changelog" entry
|
|
|
|
(function +org-capture-central-project-changelog-file)
|
2019-10-31 23:12:35 -04:00
|
|
|
"* %U %?\n %i\n %a"
|
2019-10-31 22:45:59 -04:00
|
|
|
:heading "Changelog"
|
|
|
|
:prepend t)))
|
|
|
|
|
|
|
|
;; Kill capture buffers by default (unless they've been visited)
|
|
|
|
(after! org-capture
|
|
|
|
(org-capture-put :kill-buffer t))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2020-05-11 03:08:37 -04:00
|
|
|
;; Fix #462: when refiling from org-capture, Emacs prompts to kill the
|
|
|
|
;; underlying, modified buffer. This fixes that.
|
|
|
|
(add-hook 'org-after-refile-insert-hook #'save-buffer)
|
|
|
|
|
2020-02-27 00:47:30 -05:00
|
|
|
;; HACK Doom doesn't support `customize'. Best not to advertise it as an
|
|
|
|
;; option in `org-capture's menu.
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +org--remove-customize-option-a (fn table title &optional prompt specials)
|
2020-02-27 00:47:30 -05:00
|
|
|
:around #'org-mks
|
2021-08-04 01:18:06 -04:00
|
|
|
(funcall fn table title prompt
|
2020-05-11 03:08:37 -04:00
|
|
|
(remove '("C" "Customize org-capture-templates")
|
|
|
|
specials)))
|
2020-02-27 00:47:30 -05:00
|
|
|
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +org--capture-expand-variable-file-a (file)
|
2019-06-28 16:53:26 +02:00
|
|
|
"If a variable is used for a file path in `org-capture-template', it is used
|
|
|
|
as is, and expanded relative to `default-directory'. This changes it to be
|
|
|
|
relative to `org-directory', unless it is an absolute path."
|
2019-07-21 02:38:42 +02:00
|
|
|
:filter-args #'org-capture-expand-file
|
2019-06-28 16:53:26 +02:00
|
|
|
(if (and (symbolp file) (boundp file))
|
|
|
|
(expand-file-name (symbol-value file) org-directory)
|
|
|
|
file))
|
|
|
|
|
2019-07-26 22:46:05 +02:00
|
|
|
(add-hook! 'org-capture-mode-hook
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-show-target-in-capture-header-h ()
|
|
|
|
(setq header-line-format
|
|
|
|
(format "%s%s%s"
|
|
|
|
(propertize (abbreviate-file-name (buffer-file-name (buffer-base-buffer)))
|
|
|
|
'face 'font-lock-string-face)
|
|
|
|
org-eldoc-breadcrumb-separator
|
2020-08-05 18:17:13 -04:00
|
|
|
header-line-format)))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-capture-frame-h ()
|
|
|
|
(add-hook 'org-capture-after-finalize-hook #'+org-capture-cleanup-frame-h)
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2020-06-04 20:02:46 -04:00
|
|
|
(defadvice! +org-capture-refile-cleanup-frame-a (&rest _)
|
2020-05-24 23:29:35 +07:00
|
|
|
:after #'org-capture-refile
|
|
|
|
(+org-capture-cleanup-frame-h))
|
|
|
|
|
2019-06-28 16:53:26 +02:00
|
|
|
(when (featurep! :ui doom-dashboard)
|
|
|
|
(add-hook '+doom-dashboard-inhibit-functions #'+org-capture-frame-p)))
|
|
|
|
|
|
|
|
|
2019-12-29 16:31:25 -05:00
|
|
|
(defun +org-init-attachments-h ()
|
|
|
|
"Sets up org's attachment system."
|
2020-04-25 15:40:24 -04:00
|
|
|
(setq org-attach-store-link-p t ; store link after attaching files
|
|
|
|
org-attach-use-inheritance t) ; inherit properties from parent nodes
|
|
|
|
|
2020-05-20 01:07:18 -04:00
|
|
|
;; Autoload all these commands that org-attach doesn't autoload itself
|
|
|
|
(use-package! org-attach
|
|
|
|
:commands (org-attach-new
|
|
|
|
org-attach-open
|
|
|
|
org-attach-open-in-emacs
|
|
|
|
org-attach-reveal-in-emacs
|
|
|
|
org-attach-url
|
|
|
|
org-attach-set-directory
|
|
|
|
org-attach-sync)
|
|
|
|
:config
|
2020-04-25 15:40:24 -04:00
|
|
|
(unless org-attach-id-dir
|
2020-05-20 01:07:18 -04:00
|
|
|
;; Centralized attachments directory by default
|
2020-11-03 22:00:15 -05:00
|
|
|
(setq-default org-attach-id-dir (expand-file-name ".attach/" org-directory)))
|
2020-04-25 15:40:24 -04:00
|
|
|
(after! projectile
|
2020-05-07 00:54:41 -04:00
|
|
|
(add-to-list 'projectile-globally-ignored-directories org-attach-id-dir)))
|
|
|
|
|
|
|
|
;; Add inline image previews for attachment links
|
|
|
|
(org-link-set-parameters "attachment" :image-data-fun #'+org-inline-image-data-fn))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-custom-links-h ()
|
2021-07-31 12:29:30 -04:00
|
|
|
;; Modify default file: links to colorize broken file links red
|
2019-06-28 16:53:26 +02:00
|
|
|
(org-link-set-parameters
|
|
|
|
"file"
|
|
|
|
:face (lambda (path)
|
|
|
|
(if (or (file-remote-p path)
|
2020-11-04 14:40:44 -05:00
|
|
|
;; filter out network shares on windows (slow)
|
2020-11-06 02:32:09 -05:00
|
|
|
(and IS-WINDOWS (string-prefix-p "\\\\" path))
|
2019-06-28 16:53:26 +02:00
|
|
|
(file-exists-p path))
|
|
|
|
'org-link
|
2021-06-01 21:24:32 -04:00
|
|
|
'(warning org-link))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2021-07-31 12:29:30 -04:00
|
|
|
;; Additional custom links for convenience
|
2019-07-23 18:05:28 +02:00
|
|
|
(pushnew! org-link-abbrev-alist
|
|
|
|
'("github" . "https://github.com/%s")
|
|
|
|
'("youtube" . "https://youtube.com/watch?v=%s")
|
|
|
|
'("google" . "https://google.com/search?q=")
|
|
|
|
'("gimages" . "https://google.com/images?q=%s")
|
|
|
|
'("gmap" . "https://maps.google.com/maps?q=%s")
|
|
|
|
'("duckduckgo" . "https://duckduckgo.com/?q=%s")
|
2020-06-12 20:08:24 +05:30
|
|
|
'("wikipedia" . "https://en.wikipedia.org/wiki/%s")
|
2019-07-23 18:05:28 +02:00
|
|
|
'("wolfram" . "https://wolframalpha.com/input/?i=%s")
|
|
|
|
'("doom-repo" . "https://github.com/hlissner/doom-emacs/%s"))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2020-04-24 20:41:56 -04:00
|
|
|
(+org-define-basic-link "org" 'org-directory)
|
|
|
|
(+org-define-basic-link "doom" 'doom-emacs-dir)
|
|
|
|
(+org-define-basic-link "doom-docs" 'doom-docs-dir)
|
|
|
|
(+org-define-basic-link "doom-modules" 'doom-modules-dir)
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2022-02-23 22:14:57 +01:00
|
|
|
;; TODO PR this upstream
|
|
|
|
(defadvice! +org--follow-search-string-a (fn link arg)
|
|
|
|
"Support ::SEARCH syntax for id: links."
|
|
|
|
:around #'org-id-open
|
|
|
|
:around #'org-roam-id-open
|
|
|
|
(save-match-data
|
|
|
|
(cl-destructuring-bind (id &optional search)
|
|
|
|
(split-string link "::")
|
|
|
|
(prog1 (funcall fn id arg)
|
|
|
|
(cond ((null search))
|
|
|
|
((string-match-p "\\`[0-9]+\\'" search)
|
|
|
|
;; Move N lines after the ID (in case it's a heading), instead
|
|
|
|
;; of the start of the buffer.
|
|
|
|
(forward-line (string-to-number option)))
|
|
|
|
((string-match "^/\\([^/]+\\)/$" search)
|
|
|
|
(let ((match (match-string 1 search)))
|
|
|
|
(save-excursion (org-link-search search))
|
|
|
|
;; `org-link-search' only reveals matches. Moving the point
|
|
|
|
;; to the first match after point is a sensible change.
|
|
|
|
(when (re-search-forward match)
|
|
|
|
(goto-char (match-beginning 0)))))
|
|
|
|
((org-link-search search)))))))
|
|
|
|
|
2021-07-31 12:29:30 -04:00
|
|
|
;; Add "lookup" links for packages and keystrings; useful for Emacs
|
|
|
|
;; documentation -- especially Doom's!
|
|
|
|
(org-link-set-parameters
|
|
|
|
"kbd"
|
|
|
|
:follow (lambda (_) (minibuffer-message "%s" (+org-display-link-in-eldoc-a)))
|
|
|
|
:help-echo #'+org-read-kbd-at-point
|
|
|
|
:face 'help-key-binding)
|
|
|
|
(org-link-set-parameters
|
|
|
|
"doom-package"
|
|
|
|
:follow #'+org-link--doom-package-follow-fn
|
|
|
|
:face (lambda (_) '(:inherit org-priority :slant italic)))
|
|
|
|
(org-link-set-parameters
|
|
|
|
"doom-module"
|
|
|
|
:follow #'+org-link--doom-module-follow-fn
|
|
|
|
:face #'+org-link--doom-module-face-fn)
|
|
|
|
|
2020-06-28 01:02:55 -04:00
|
|
|
;; Allow inline image previews of http(s)? urls or data uris.
|
|
|
|
;; `+org-http-image-data-fn' will respect `org-display-remote-inline-images'.
|
|
|
|
(setq org-display-remote-inline-images 'download) ; TRAMP urls
|
2020-04-24 20:41:56 -04:00
|
|
|
(org-link-set-parameters "http" :image-data-fun #'+org-http-image-data-fn)
|
|
|
|
(org-link-set-parameters "https" :image-data-fun #'+org-http-image-data-fn)
|
|
|
|
(org-link-set-parameters "img" :image-data-fun #'+org-inline-image-data-fn)
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
;; Add support for youtube links + previews
|
2020-06-28 01:17:53 -04:00
|
|
|
(require 'org-yt nil t)
|
2020-07-23 01:04:04 -04:00
|
|
|
|
2020-06-28 01:17:53 -04:00
|
|
|
(defadvice! +org-dont-preview-if-disabled-a (&rest _)
|
|
|
|
"Make `org-yt' respect `org-display-remote-inline-images'."
|
|
|
|
:before-while #'org-yt-image-data-fun
|
|
|
|
(not (eq org-display-remote-inline-images 'skip))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-export-h ()
|
2019-10-25 20:00:06 -04:00
|
|
|
"TODO"
|
2019-10-20 12:28:38 -04:00
|
|
|
(setq org-export-with-smart-quotes t
|
2020-07-31 15:57:53 -04:00
|
|
|
org-html-validation-link nil
|
|
|
|
org-latex-prefer-user-labels t)
|
2019-07-28 22:55:40 +02:00
|
|
|
|
2019-06-28 16:53:26 +02:00
|
|
|
(when (featurep! :lang markdown)
|
|
|
|
(add-to-list 'org-export-backends 'md))
|
|
|
|
|
2019-10-11 15:04:51 -04:00
|
|
|
(use-package! ox-hugo
|
|
|
|
:when (featurep! +hugo)
|
|
|
|
:after ox)
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! ox-pandoc
|
2019-09-15 19:23:06 -04:00
|
|
|
:when (featurep! +pandoc)
|
|
|
|
:when (executable-find "pandoc")
|
2019-06-28 16:53:26 +02:00
|
|
|
:after ox
|
|
|
|
:init
|
|
|
|
(add-to-list 'org-export-backends 'pandoc)
|
|
|
|
(setq org-pandoc-options
|
|
|
|
'((standalone . t)
|
|
|
|
(mathjax . t)
|
Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.
Fixes #2802, #2737, #2386
The big highlights are:
- Fix #2802: We now update recipe repos *before* updating/installing any
new packages. No more "Could not find package X in recipe repositories".
- Fix #2737: An edge case where straight couldn't reach a pinned
commit (particularly with agda).
- Doom is now smarter about what option it recommends when straight
prompts you to make a choice.
- Introduces a new init path for Doom. The old way:
- Launch in "minimal" CLI mode in non-interactive sessions
- Launch a "full" interactive mode otherwise.
The new way
- Launch in "minimal" CLI mode *only* for bin/doom
- Launch is a simple mode for non-interactive sessions that still need
access to your interactive config (like async org export/babel).
- Launch a "full" interactive mode otherwise.
This should fix compatibility issues with plugins that use the
async.el library or spawn child Emacs processes to fake
parallelization (like org's async export and babel functionality).
- Your private init.el is now loaded more reliably when running any
bin/doom command. This gives you an opportunity to configure its
settings.
- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
deferred activation of a number of packages. Users can remove these
modes from these hooks; altogether preventing them from loading,
rather than waiting for them to load to then disable them,
e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
'doom-first-buffer #'smartparens-global-mode)
Hooks added to doom-first-*-hook variables will be removed once they
run.
This should also indirectly fix #2386, by preventing interactive modes
from running in non-interactive session.
- Added `doom/bump-*` commands to make bumping modules and packages
easier, and `doom/bumpify-*` commands for converting package!
statements into user/repo@sha1hash format for bump commits.
- straight.el is now commit-pinned, like all other packages. We also
more reliably install straight.el by cloning it ourselves, rather than
relying on its bootstrap.el.
This should prevent infinite "straight has diverged from master"
prompts whenever we change branches (though, you might have to put up
with it one more after this update -- see #2937 for workaround).
All the other minor changes:
- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
1. Child instances will no longer inherit the process environment of
the host instance,
2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-14 15:00:23 -04:00
|
|
|
(variable . "revealjs-url=https://revealjs.com"))))
|
|
|
|
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +org--dont-trigger-save-hooks-a (fn &rest args)
|
2021-03-10 12:58:04 -05:00
|
|
|
"Exporting and tangling trigger save hooks; inadvertantly triggering
|
|
|
|
mutating hooks on exported output, like formatters."
|
|
|
|
:around '(org-export-to-file org-babel-tangle)
|
2020-06-04 23:48:16 -04:00
|
|
|
(let (before-save-hook after-save-hook)
|
2021-08-04 01:18:06 -04:00
|
|
|
(apply fn args)))
|
2020-06-04 23:48:16 -04:00
|
|
|
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +org--fix-async-export-a (fn &rest args)
|
2020-11-14 13:52:11 -05:00
|
|
|
:around '(org-export-to-file org-export-as)
|
|
|
|
(let ((old-async-init-file org-export-async-init-file)
|
|
|
|
(org-export-async-init-file (make-temp-file "doom-org-async-export")))
|
|
|
|
(with-temp-file org-export-async-init-file
|
|
|
|
(prin1 `(progn (setq org-export-async-debug
|
|
|
|
,(or org-export-async-debug
|
|
|
|
debug-on-error)
|
|
|
|
load-path ',load-path)
|
2021-03-10 12:53:54 -05:00
|
|
|
(unwind-protect
|
|
|
|
(load ,(or old-async-init-file user-init-file)
|
|
|
|
nil t)
|
|
|
|
(delete-file load-file-name)))
|
2020-11-14 13:52:11 -05:00
|
|
|
(current-buffer)))
|
2021-08-04 01:18:06 -04:00
|
|
|
(apply fn args))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2020-05-12 05:15:55 -04:00
|
|
|
(defun +org-init-habit-h ()
|
|
|
|
(add-hook! 'org-agenda-mode-hook
|
|
|
|
(defun +org-habit-resize-graph-h ()
|
|
|
|
"Right align and resize the consistency graphs based on
|
|
|
|
`+org-habit-graph-window-ratio'"
|
|
|
|
(when (featurep 'org-habit)
|
|
|
|
(let* ((total-days (float (+ org-habit-preceding-days org-habit-following-days)))
|
|
|
|
(preceding-days-ratio (/ org-habit-preceding-days total-days))
|
|
|
|
(graph-width (floor (* (window-width) +org-habit-graph-window-ratio)))
|
|
|
|
(preceding-days (floor (* graph-width preceding-days-ratio)))
|
|
|
|
(following-days (- graph-width preceding-days))
|
|
|
|
(graph-column (- (window-width) (+ preceding-days following-days)))
|
|
|
|
(graph-column-adjusted (if (> graph-column +org-habit-min-width)
|
|
|
|
(- graph-column +org-habit-graph-padding)
|
|
|
|
nil)))
|
|
|
|
(setq-local org-habit-preceding-days preceding-days)
|
|
|
|
(setq-local org-habit-following-days following-days)
|
|
|
|
(setq-local org-habit-graph-column graph-column-adjusted))))))
|
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-hacks-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
"Getting org to behave."
|
2020-04-25 15:40:24 -04:00
|
|
|
;; Open file links in current window, rather than new ones
|
2019-06-28 16:53:26 +02:00
|
|
|
(setf (alist-get 'file org-link-frame-setup) #'find-file)
|
2020-04-25 15:40:24 -04:00
|
|
|
;; Open directory links in dired
|
2019-06-28 16:53:26 +02:00
|
|
|
(add-to-list 'org-file-apps '(directory . emacs))
|
2021-02-26 21:26:24 -05:00
|
|
|
(add-to-list 'org-file-apps '(remote . emacs))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2021-07-31 02:07:05 -04:00
|
|
|
;; Open help:* links with helpful-* instead of describe-*
|
|
|
|
(advice-add #'org-link--open-help :around #'doom-use-helpful-a)
|
|
|
|
|
2021-07-28 15:02:14 -04:00
|
|
|
(defadvice! +org--show-parents-a (&optional arg)
|
|
|
|
"Show all headlines in the buffer, like a table of contents.
|
|
|
|
With numerical argument N, show content up to level N."
|
|
|
|
:override #'org-content
|
|
|
|
(interactive "p")
|
|
|
|
(org-show-all '(headings drawers))
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-max))
|
|
|
|
(let ((regexp (if (and (wholenump arg) (> arg 0))
|
|
|
|
(format "^\\*\\{%d,%d\\} " (1- arg) arg)
|
|
|
|
"^\\*+ "))
|
|
|
|
(last (point)))
|
|
|
|
(while (re-search-backward regexp nil t)
|
|
|
|
(when (or (not (wholenump arg))
|
|
|
|
(= (org-current-level) arg))
|
|
|
|
(org-flag-region (line-end-position) last t 'outline))
|
|
|
|
(setq last (line-end-position 0))))))
|
|
|
|
|
2020-10-14 01:02:25 -04:00
|
|
|
;; Some uses of `org-fix-tags-on-the-fly' occur without a check on
|
|
|
|
;; `org-auto-align-tags', such as in `org-self-insert-command' and
|
|
|
|
;; `org-delete-backward-char'.
|
|
|
|
;; TODO Should be reported/PR'ed upstream
|
|
|
|
(defadvice! +org--respect-org-auto-align-tags-a (&rest _)
|
|
|
|
:before-while #'org-fix-tags-on-the-fly
|
|
|
|
org-auto-align-tags)
|
|
|
|
|
2020-06-05 03:20:51 -04:00
|
|
|
(defadvice! +org--recenter-after-follow-link-a (&rest _args)
|
|
|
|
"Recenter after following a link, but only internal or file links."
|
|
|
|
:after '(org-footnote-action
|
|
|
|
org-follow-timestamp-link
|
|
|
|
org-link-open-as-file
|
|
|
|
org-link-search)
|
2020-06-06 00:56:46 -04:00
|
|
|
(when (get-buffer-window)
|
|
|
|
(recenter)))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +org--strip-properties-from-outline-a (fn &rest args)
|
2021-01-03 22:37:51 -05:00
|
|
|
"Fix variable height faces in eldoc breadcrumbs."
|
2019-07-21 02:38:42 +02:00
|
|
|
:around #'org-format-outline-path
|
2021-01-03 22:37:51 -05:00
|
|
|
(let ((org-level-faces
|
|
|
|
(cl-loop for face in org-level-faces
|
|
|
|
collect `(:foreground ,(face-foreground face nil t)
|
|
|
|
:weight bold))))
|
2021-08-04 01:18:06 -04:00
|
|
|
(apply fn args)))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2020-04-28 18:43:15 -04:00
|
|
|
(after! org-eldoc
|
|
|
|
;; HACK Fix #2972: infinite recursion when eldoc kicks in in 'org' or
|
|
|
|
;; 'python' src blocks.
|
|
|
|
;; TODO Should be reported upstream!
|
|
|
|
(puthash "org" #'ignore org-eldoc-local-functions-cache)
|
2020-08-26 13:55:09 -04:00
|
|
|
(puthash "plantuml" #'ignore org-eldoc-local-functions-cache)
|
2020-04-28 18:43:15 -04:00
|
|
|
(puthash "python" #'python-eldoc-function org-eldoc-local-functions-cache))
|
|
|
|
|
2019-10-07 23:20:23 -04:00
|
|
|
(defun +org--restart-mode-h ()
|
|
|
|
"Restart `org-mode', but only once."
|
2021-04-24 10:53:29 +09:00
|
|
|
(quiet! (org-mode-restart))
|
|
|
|
(delq! (current-buffer) org-agenda-new-buffers)
|
2019-10-07 23:20:23 -04:00
|
|
|
(remove-hook 'doom-switch-buffer-hook #'+org--restart-mode-h
|
2021-03-10 20:30:10 -05:00
|
|
|
'local)
|
2021-04-24 10:53:29 +09:00
|
|
|
(run-hooks 'find-file-hook))
|
2019-10-07 23:20:23 -04:00
|
|
|
|
2019-07-26 22:46:05 +02:00
|
|
|
(add-hook! 'org-agenda-finalize-hook
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-exclude-agenda-buffers-from-workspace-h ()
|
2020-12-18 16:10:06 -05:00
|
|
|
"Don't associate temporary agenda buffers with current workspace."
|
2020-07-31 15:56:02 -04:00
|
|
|
(when (and org-agenda-new-buffers
|
|
|
|
(bound-and-true-p persp-mode)
|
|
|
|
(not org-agenda-sticky))
|
|
|
|
(let (persp-autokill-buffer-on-remove)
|
|
|
|
(persp-remove-buffer org-agenda-new-buffers
|
|
|
|
(get-current-persp)
|
|
|
|
nil))))
|
|
|
|
(defun +org-defer-mode-in-agenda-buffers-h ()
|
2020-12-18 16:10:06 -05:00
|
|
|
"`org-agenda' opens temporary, incomplete org-mode buffers.
|
|
|
|
I've disabled a lot of org-mode's startup processes for these invisible buffers
|
|
|
|
to speed them up (in `+org--exclude-agenda-buffers-from-recentf-a'). However, if
|
|
|
|
the user tries to visit one of these buffers they'll see a gimped, half-broken
|
|
|
|
org buffer. To avoid that, restart `org-mode' when they're switched to so they
|
|
|
|
can grow up to be fully-fledged org-mode buffers."
|
2020-07-31 15:56:02 -04:00
|
|
|
(dolist (buffer org-agenda-new-buffers)
|
2021-08-06 00:18:47 -07:00
|
|
|
(when (buffer-live-p buffer) ; Ensure buffer is not killed
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(add-hook 'doom-switch-buffer-hook #'+org--restart-mode-h
|
|
|
|
nil 'local))))))
|
2019-07-21 02:38:42 +02:00
|
|
|
|
2021-03-07 13:04:24 -05:00
|
|
|
(defvar recentf-exclude)
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +org--optimize-backgrounded-agenda-buffers-a (fn file)
|
2019-06-28 16:53:26 +02:00
|
|
|
"Prevent temporarily opened agenda buffers from polluting recentf."
|
2019-07-21 02:38:42 +02:00
|
|
|
:around #'org-get-agenda-file-buffer
|
2020-08-21 19:08:46 -04:00
|
|
|
(let ((recentf-exclude (list (lambda (_file) t)))
|
2020-12-18 16:08:58 -05:00
|
|
|
(doom-inhibit-large-file-detection t)
|
2021-05-16 21:18:26 -04:00
|
|
|
org-startup-indented
|
|
|
|
org-startup-folded
|
|
|
|
vc-handled-backends
|
2021-03-10 20:30:10 -05:00
|
|
|
org-mode-hook
|
|
|
|
find-file-hook)
|
2021-08-04 01:18:06 -04:00
|
|
|
(funcall fn file)))
|
2019-09-26 15:29:09 -04:00
|
|
|
|
|
|
|
;; HACK With https://code.orgmode.org/bzg/org-mode/commit/48da60f4, inline
|
2019-10-20 13:29:29 -04:00
|
|
|
;; image previews broke for users with imagemagick support built in. This
|
|
|
|
;; reverses the problem, but should be removed once it is addressed
|
|
|
|
;; upstream (if ever).
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +org--fix-inline-images-for-imagemagick-users-a (fn &rest args)
|
2019-09-26 15:29:09 -04:00
|
|
|
:around #'org-display-inline-images
|
2020-04-29 21:08:17 -04:00
|
|
|
(letf! (defun create-image (file-or-data &optional type data-p &rest props)
|
|
|
|
(let ((type (if (plist-get props :width) type)))
|
|
|
|
(apply create-image file-or-data type data-p props)))
|
2021-08-04 01:18:06 -04:00
|
|
|
(apply fn args)))
|
2020-03-31 12:33:16 +01:00
|
|
|
|
2020-04-07 10:22:05 +01:00
|
|
|
(defadvice! +org--fix-inconsistent-uuidgen-case-a (uuid)
|
2020-03-31 12:33:16 +01:00
|
|
|
"Ensure uuidgen always produces lowercase output regardless of system."
|
2020-04-07 10:22:05 +01:00
|
|
|
:filter-return #'org-id-new
|
|
|
|
(if (eq org-id-method 'uuid)
|
|
|
|
(downcase uuid)
|
|
|
|
uuid)))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-keybinds-h ()
|
2017-07-05 02:33:41 +02:00
|
|
|
"Sets up org-mode and evil keybindings. Tries to fix the idiosyncrasies
|
|
|
|
between the two."
|
2019-07-21 02:38:42 +02:00
|
|
|
(add-hook 'doom-escape-hook #'+org-remove-occur-highlights-h)
|
2018-07-09 15:33:31 +02:00
|
|
|
|
2018-02-18 00:26:27 -05:00
|
|
|
;; C-a & C-e act like `doom/backward-to-bol-or-indent' and
|
|
|
|
;; `doom/forward-to-last-non-comment-or-eol', but with more org awareness.
|
|
|
|
(setq org-special-ctrl-a/e t)
|
2018-07-09 15:33:31 +02:00
|
|
|
|
2018-07-04 13:16:11 +02:00
|
|
|
(setq org-M-RET-may-split-line nil
|
|
|
|
;; insert new headings after current subtree rather than inside it
|
|
|
|
org-insert-heading-respect-content t)
|
2018-07-09 15:33:31 +02:00
|
|
|
|
2019-07-26 19:57:13 +02:00
|
|
|
(add-hook! 'org-tab-first-hook
|
2020-01-01 20:59:58 -05:00
|
|
|
#'+org-yas-expand-maybe-h
|
|
|
|
#'+org-indent-maybe-h)
|
2019-07-26 19:57:13 +02:00
|
|
|
|
|
|
|
(add-hook 'doom-delete-backward-functions
|
|
|
|
#'+org-delete-backward-char-and-realign-table-maybe-h)
|
2018-07-09 15:33:31 +02:00
|
|
|
|
2019-01-22 18:51:45 -05:00
|
|
|
(map! :map org-mode-map
|
2021-07-23 22:10:43 -04:00
|
|
|
;; Recently, a [tab] keybind in `outline-mode-cycle-map' has begun
|
|
|
|
;; overriding org's [tab] keybind in GUI Emacs. This is needed to undo
|
|
|
|
;; that, and should probably be PRed to org.
|
|
|
|
[tab] #'org-cycle
|
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
"C-c C-S-l" #'+org/remove-link
|
|
|
|
"C-c C-i" #'org-toggle-inline-images
|
2019-01-22 18:51:45 -05:00
|
|
|
;; textmate-esque newline insertion
|
2020-08-05 18:02:40 -04:00
|
|
|
"S-RET" #'+org/shift-return
|
2020-04-27 17:30:23 -04:00
|
|
|
"C-RET" #'+org/insert-item-below
|
|
|
|
"C-S-RET" #'+org/insert-item-above
|
|
|
|
"C-M-RET" #'org-insert-subheading
|
2019-06-28 16:53:26 +02:00
|
|
|
[C-return] #'+org/insert-item-below
|
|
|
|
[C-S-return] #'+org/insert-item-above
|
2020-01-06 16:21:22 -05:00
|
|
|
[C-M-return] #'org-insert-subheading
|
2020-01-10 05:00:08 -05:00
|
|
|
(:when IS-MAC
|
2020-05-24 21:54:37 -05:00
|
|
|
[s-return] #'+org/insert-item-below
|
|
|
|
[s-S-return] #'+org/insert-item-above
|
|
|
|
[s-M-return] #'org-insert-subheading)
|
2019-10-25 20:00:06 -04:00
|
|
|
;; Org-aware C-a/C-e
|
2019-01-22 18:51:45 -05:00
|
|
|
[remap doom/backward-to-bol-or-indent] #'org-beginning-of-line
|
2019-04-04 18:47:40 -04:00
|
|
|
[remap doom/forward-to-last-non-comment-or-eol] #'org-end-of-line
|
|
|
|
|
|
|
|
:localleader
|
2020-04-24 02:08:09 -04:00
|
|
|
"#" #'org-update-statistics-cookies
|
2019-05-12 01:46:29 -04:00
|
|
|
"'" #'org-edit-special
|
2020-04-24 02:08:09 -04:00
|
|
|
"*" #'org-ctrl-c-star
|
|
|
|
"+" #'org-ctrl-c-minus
|
2019-04-05 04:12:56 -04:00
|
|
|
"," #'org-switchb
|
2019-04-05 04:33:26 -04:00
|
|
|
"." #'org-goto
|
2021-11-22 14:21:19 +01:00
|
|
|
"@" #'org-cite-insert
|
2019-04-05 04:33:26 -04:00
|
|
|
(:when (featurep! :completion ivy)
|
2020-05-24 21:54:37 -05:00
|
|
|
"." #'counsel-org-goto
|
|
|
|
"/" #'counsel-org-goto-all)
|
2019-04-05 04:33:26 -04:00
|
|
|
(:when (featurep! :completion helm)
|
2020-05-24 21:54:37 -05:00
|
|
|
"." #'helm-org-in-buffer-headings
|
|
|
|
"/" #'helm-org-agenda-files-headings)
|
2021-07-09 20:16:11 +03:00
|
|
|
(:when (featurep! :completion vertico)
|
2021-05-08 16:48:48 +03:00
|
|
|
"." #'consult-org-heading
|
|
|
|
"/" #'consult-org-agenda)
|
2019-11-04 10:48:06 +00:00
|
|
|
"A" #'org-archive-subtree
|
2019-10-11 14:49:21 -04:00
|
|
|
"e" #'org-export-dispatch
|
2021-08-12 18:56:47 +02:00
|
|
|
"f" #'org-footnote-action
|
2019-05-12 01:46:29 -04:00
|
|
|
"h" #'org-toggle-heading
|
|
|
|
"i" #'org-toggle-item
|
2021-07-19 00:53:07 +03:00
|
|
|
"I" #'org-id-get-create
|
2022-03-19 15:19:54 +00:00
|
|
|
"k" #'org-babel-remove-result
|
|
|
|
"K" #'+org/remove-result-blocks
|
2019-10-25 20:00:06 -04:00
|
|
|
"n" #'org-store-link
|
|
|
|
"o" #'org-set-property
|
2019-05-13 10:40:43 +02:00
|
|
|
"q" #'org-set-tags-command
|
2019-05-12 01:46:29 -04:00
|
|
|
"t" #'org-todo
|
|
|
|
"T" #'org-todo-list
|
2020-08-19 17:42:11 +05:30
|
|
|
"x" #'org-toggle-checkbox
|
2019-10-25 20:00:06 -04:00
|
|
|
(:prefix ("a" . "attachments")
|
2020-05-24 21:54:37 -05:00
|
|
|
"a" #'org-attach
|
|
|
|
"d" #'org-attach-delete-one
|
|
|
|
"D" #'org-attach-delete-all
|
|
|
|
"f" #'+org/find-file-in-attachments
|
|
|
|
"l" #'+org/attach-file-and-insert-link
|
|
|
|
"n" #'org-attach-new
|
|
|
|
"o" #'org-attach-open
|
|
|
|
"O" #'org-attach-open-in-emacs
|
|
|
|
"r" #'org-attach-reveal
|
|
|
|
"R" #'org-attach-reveal-in-emacs
|
|
|
|
"u" #'org-attach-url
|
|
|
|
"s" #'org-attach-set-directory
|
|
|
|
"S" #'org-attach-sync
|
|
|
|
(:when (featurep! +dragndrop)
|
|
|
|
"c" #'org-download-screenshot
|
2020-08-25 05:48:09 -04:00
|
|
|
"p" #'org-download-clipboard
|
|
|
|
"P" #'org-download-yank))
|
2019-11-11 00:19:55 -05:00
|
|
|
(:prefix ("b" . "tables")
|
2020-05-24 21:54:37 -05:00
|
|
|
"-" #'org-table-insert-hline
|
|
|
|
"a" #'org-table-align
|
|
|
|
"b" #'org-table-blank-field
|
|
|
|
"c" #'org-table-create-or-convert-from-region
|
|
|
|
"e" #'org-table-edit-field
|
|
|
|
"f" #'org-table-edit-formulas
|
|
|
|
"h" #'org-table-field-info
|
|
|
|
"s" #'org-table-sort-lines
|
|
|
|
"r" #'org-table-recalculate
|
|
|
|
"R" #'org-table-recalculate-buffer-tables
|
|
|
|
(:prefix ("d" . "delete")
|
|
|
|
"c" #'org-table-delete-column
|
|
|
|
"r" #'org-table-kill-row)
|
|
|
|
(:prefix ("i" . "insert")
|
|
|
|
"c" #'org-table-insert-column
|
|
|
|
"h" #'org-table-insert-hline
|
|
|
|
"r" #'org-table-insert-row
|
|
|
|
"H" #'org-table-hline-and-move)
|
|
|
|
(:prefix ("t" . "toggle")
|
|
|
|
"f" #'org-table-toggle-formula-debugger
|
|
|
|
"o" #'org-table-toggle-coordinate-overlays)
|
|
|
|
(:when (featurep! +gnuplot)
|
|
|
|
"p" #'org-plot/gnuplot))
|
2019-04-04 18:47:40 -04:00
|
|
|
(:prefix ("c" . "clock")
|
2020-05-24 21:54:37 -05:00
|
|
|
"c" #'org-clock-cancel
|
|
|
|
"d" #'org-clock-mark-default-task
|
|
|
|
"e" #'org-clock-modify-effort-estimate
|
|
|
|
"E" #'org-set-effort
|
|
|
|
"g" #'org-clock-goto
|
2020-07-26 15:55:11 -04:00
|
|
|
"G" (cmd! (org-clock-goto 'select))
|
|
|
|
"l" #'+org/toggle-last-clock
|
2020-05-24 21:54:37 -05:00
|
|
|
"i" #'org-clock-in
|
|
|
|
"I" #'org-clock-in-last
|
|
|
|
"o" #'org-clock-out
|
|
|
|
"r" #'org-resolve-clocks
|
|
|
|
"R" #'org-clock-report
|
|
|
|
"t" #'org-evaluate-time-range
|
|
|
|
"=" #'org-clock-timestamps-up
|
|
|
|
"-" #'org-clock-timestamps-down)
|
2020-04-24 02:05:35 -04:00
|
|
|
(:prefix ("d" . "date/deadline")
|
2020-05-24 21:54:37 -05:00
|
|
|
"d" #'org-deadline
|
|
|
|
"s" #'org-schedule
|
|
|
|
"t" #'org-time-stamp
|
|
|
|
"T" #'org-time-stamp-inactive)
|
2019-04-05 04:12:56 -04:00
|
|
|
(:prefix ("g" . "goto")
|
2020-05-24 21:54:37 -05:00
|
|
|
"g" #'org-goto
|
|
|
|
(:when (featurep! :completion ivy)
|
|
|
|
"g" #'counsel-org-goto
|
|
|
|
"G" #'counsel-org-goto-all)
|
|
|
|
(:when (featurep! :completion helm)
|
|
|
|
"g" #'helm-org-in-buffer-headings
|
|
|
|
"G" #'helm-org-agenda-files-headings)
|
2021-07-09 20:16:11 +03:00
|
|
|
(:when (featurep! :completion vertico)
|
2021-05-08 16:48:48 +03:00
|
|
|
"g" #'consult-org-heading
|
|
|
|
"G" #'consult-org-agenda)
|
2020-05-24 21:54:37 -05:00
|
|
|
"c" #'org-clock-goto
|
2020-07-26 15:56:51 -04:00
|
|
|
"C" (cmd! (org-clock-goto 'select))
|
2020-05-24 21:54:37 -05:00
|
|
|
"i" #'org-id-goto
|
|
|
|
"r" #'org-refile-goto-last-stored
|
|
|
|
"v" #'+org/goto-visible
|
|
|
|
"x" #'org-capture-goto-last-stored)
|
2019-11-21 17:13:21 -05:00
|
|
|
(:prefix ("l" . "links")
|
2020-05-24 21:54:37 -05:00
|
|
|
"c" #'org-cliplink
|
|
|
|
"d" #'+org/remove-link
|
|
|
|
"i" #'org-id-store-link
|
|
|
|
"l" #'org-insert-link
|
|
|
|
"L" #'org-insert-all-links
|
|
|
|
"s" #'org-store-link
|
|
|
|
"S" #'org-insert-last-stored-link
|
|
|
|
"t" #'org-toggle-link-display)
|
2020-07-20 09:13:27 -05:00
|
|
|
(:prefix ("P" . "publish")
|
|
|
|
"a" #'org-publish-all
|
|
|
|
"f" #'org-publish-current-file
|
|
|
|
"p" #'org-publish
|
|
|
|
"P" #'org-publish-current-project
|
|
|
|
"s" #'org-publish-sitemap)
|
2019-11-11 00:19:55 -05:00
|
|
|
(:prefix ("r" . "refile")
|
2020-05-24 21:54:37 -05:00
|
|
|
"." #'+org/refile-to-current-file
|
|
|
|
"c" #'+org/refile-to-running-clock
|
|
|
|
"l" #'+org/refile-to-last-location
|
|
|
|
"f" #'+org/refile-to-file
|
|
|
|
"o" #'+org/refile-to-other-window
|
|
|
|
"O" #'+org/refile-to-other-buffer
|
|
|
|
"v" #'+org/refile-to-visible
|
|
|
|
"r" #'org-refile) ; to all `org-refile-targets'
|
2021-03-01 20:04:41 -08:00
|
|
|
(:prefix ("s" . "tree/subtree")
|
2020-05-24 21:54:37 -05:00
|
|
|
"a" #'org-toggle-archive-tag
|
|
|
|
"b" #'org-tree-to-indirect-buffer
|
2021-10-03 13:55:18 -04:00
|
|
|
"c" #'org-clone-subtree-with-time-shift
|
2020-05-24 21:54:37 -05:00
|
|
|
"d" #'org-cut-subtree
|
|
|
|
"h" #'org-promote-subtree
|
|
|
|
"j" #'org-move-subtree-down
|
|
|
|
"k" #'org-move-subtree-up
|
|
|
|
"l" #'org-demote-subtree
|
|
|
|
"n" #'org-narrow-to-subtree
|
|
|
|
"r" #'org-refile
|
|
|
|
"s" #'org-sparse-tree
|
|
|
|
"A" #'org-archive-subtree
|
|
|
|
"N" #'widen
|
2021-03-01 20:04:41 -08:00
|
|
|
"S" #'org-sort)
|
|
|
|
(:prefix ("p" . "priority")
|
|
|
|
"d" #'org-priority-down
|
|
|
|
"p" #'org-priority
|
|
|
|
"u" #'org-priority-up))
|
2020-05-24 21:54:37 -05:00
|
|
|
|
2019-10-23 17:36:30 -04:00
|
|
|
(map! :after org-agenda
|
2019-11-30 14:45:41 -05:00
|
|
|
:map org-agenda-mode-map
|
2019-12-03 11:33:18 -05:00
|
|
|
:m "C-SPC" #'org-agenda-show-and-scroll-up
|
2019-05-10 08:16:09 +02:00
|
|
|
:localleader
|
2020-05-26 22:11:58 +02:00
|
|
|
(:prefix ("d" . "date/deadline")
|
|
|
|
"d" #'org-agenda-deadline
|
|
|
|
"s" #'org-agenda-schedule)
|
2019-11-10 19:10:49 +09:00
|
|
|
(:prefix ("c" . "clock")
|
2020-05-26 22:08:11 +02:00
|
|
|
"c" #'org-agenda-clock-cancel
|
2020-05-24 21:54:37 -05:00
|
|
|
"g" #'org-agenda-clock-goto
|
2020-05-26 22:08:11 +02:00
|
|
|
"i" #'org-agenda-clock-in
|
|
|
|
"o" #'org-agenda-clock-out
|
2020-05-24 21:54:37 -05:00
|
|
|
"r" #'org-agenda-clockreport-mode
|
2020-05-26 22:08:11 +02:00
|
|
|
"s" #'org-agenda-show-clocking-issues)
|
2021-03-01 20:04:41 -08:00
|
|
|
(:prefix ("p" . "priority")
|
|
|
|
"d" #'org-agenda-priority-down
|
|
|
|
"p" #'org-agenda-priority
|
|
|
|
"u" #'org-agenda-priority-up)
|
2019-05-10 15:03:29 +02:00
|
|
|
"q" #'org-agenda-set-tags
|
2019-05-10 08:16:09 +02:00
|
|
|
"r" #'org-agenda-refile
|
|
|
|
"t" #'org-agenda-todo))
|
2019-03-07 00:15:15 -05:00
|
|
|
|
2018-07-09 15:33:31 +02:00
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-popup-rules-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
(set-popup-rules!
|
|
|
|
'(("^\\*Org Links" :slot -1 :vslot -1 :size 2 :ttl 0)
|
2020-02-29 00:33:58 -05:00
|
|
|
("^ ?\\*\\(?:Agenda Com\\|Calendar\\|Org Export Dispatcher\\)"
|
2019-06-28 16:53:26 +02:00
|
|
|
:slot -1 :vslot -1 :size #'+popup-shrink-to-fit :ttl 0)
|
2020-02-29 00:33:58 -05:00
|
|
|
("^\\*Org \\(?:Select\\|Attach\\)" :slot -1 :vslot -2 :ttl 0 :size 0.25)
|
2020-04-13 14:18:11 -04:00
|
|
|
("^\\*Org Agenda" :ignore t)
|
2022-02-06 02:38:21 +01:00
|
|
|
("^\\*Org Src" :size 0.42 :quit nil :select t :autosave t :modeline t :ttl nil)
|
2020-04-13 14:18:11 -04:00
|
|
|
("^\\*Org-Babel")
|
2022-02-06 02:38:21 +01:00
|
|
|
("^\\*Capture\\*$\\|CAPTURE-.*$" :size 0.42 :quit nil :select t :autosave ignore))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-protocol-lazy-loader-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
"Brings lazy-loaded support for org-protocol, so external programs (like
|
|
|
|
browsers) can invoke specialized behavior from Emacs. Normally you'd simply
|
|
|
|
require `org-protocol' and use it, but the package loads all of org for no
|
|
|
|
compelling reason, so..."
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +org--server-visit-files-a (args)
|
2019-06-28 16:53:26 +02:00
|
|
|
"Advise `server-visit-flist' to invoke `org-protocol' lazily."
|
2019-07-21 02:38:42 +02:00
|
|
|
:filter-args #'server-visit-files
|
2019-06-28 16:53:26 +02:00
|
|
|
(cl-destructuring-bind (files proc &optional nowait) args
|
|
|
|
(catch 'greedy
|
|
|
|
(let ((flist (reverse files)))
|
|
|
|
(dolist (var flist)
|
|
|
|
(when (string-match-p ":/+" (car var))
|
|
|
|
(require 'server)
|
|
|
|
(require 'org-protocol)
|
|
|
|
;; `\' to `/' on windows
|
|
|
|
(let ((fname (org-protocol-check-filename-for-protocol
|
|
|
|
(expand-file-name (car var))
|
|
|
|
(member var flist)
|
|
|
|
proc)))
|
|
|
|
(cond ((eq fname t) ; greedy? We need the t return value.
|
|
|
|
(setq files nil)
|
|
|
|
(throw 'greedy t))
|
|
|
|
((stringp fname) ; probably filename
|
|
|
|
(setcar var fname))
|
|
|
|
((setq files (delq var files)))))))))
|
|
|
|
(list files proc nowait)))
|
|
|
|
|
|
|
|
;; Disable built-in, clumsy advice
|
|
|
|
(after! org-protocol
|
|
|
|
(ad-disable-advice 'server-visit-files 'before 'org-protocol-detect-protocol-server)))
|
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-protocol-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
;; TODO org-board or better link grabbing support
|
|
|
|
;; TODO org-capture + org-protocol instead of bin/org-capture
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-05-13 22:48:42 -04:00
|
|
|
(defun +org-init-smartparens-h ()
|
|
|
|
;; Disable the slow defaults
|
|
|
|
(provide 'smartparens-org))
|
|
|
|
|
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
;;
|
|
|
|
;;; Packages
|
|
|
|
|
|
|
|
(use-package! toc-org ; auto-table of contents
|
|
|
|
:hook (org-mode . toc-org-enable)
|
2020-04-04 00:30:14 -04:00
|
|
|
:config
|
|
|
|
(setq toc-org-hrefify-default "gh")
|
|
|
|
|
2021-08-04 01:18:06 -04:00
|
|
|
(defadvice! +org-inhibit-scrolling-a (fn &rest args)
|
2020-04-04 00:30:14 -04:00
|
|
|
"Prevent the jarring scrolling that occurs when the-ToC is regenerated."
|
|
|
|
:around #'toc-org-insert-toc
|
|
|
|
(let ((p (set-marker (make-marker) (point)))
|
|
|
|
(s (window-start)))
|
2021-08-04 01:18:06 -04:00
|
|
|
(prog1 (apply fn args)
|
2020-04-04 00:30:14 -04:00
|
|
|
(goto-char p)
|
|
|
|
(set-window-start nil s t)
|
|
|
|
(set-marker p nil)))))
|
2019-10-25 20:00:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
(use-package! org-crypt ; built-in
|
2020-04-17 12:08:08 +02:00
|
|
|
:commands org-encrypt-entries org-encrypt-entry org-decrypt-entries org-decrypt-entry
|
2019-10-25 20:00:06 -04:00
|
|
|
:hook (org-reveal-start . org-decrypt-entry)
|
2020-04-30 14:37:06 -04:00
|
|
|
:preface
|
|
|
|
;; org-crypt falls back to CRYPTKEY property then `epa-file-encrypt-to', which
|
|
|
|
;; is a better default than the empty string `org-crypt-key' defaults to.
|
|
|
|
(defvar org-crypt-key nil)
|
2020-05-02 17:52:22 -04:00
|
|
|
(after! org
|
|
|
|
(add-to-list 'org-tags-exclude-from-inheritance "crypt")
|
|
|
|
(add-hook! 'org-mode-hook
|
2020-05-16 05:13:46 -04:00
|
|
|
(add-hook 'before-save-hook 'org-encrypt-entries nil t))))
|
2019-10-25 20:00:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
(use-package! org-clock ; built-in
|
|
|
|
:commands org-clock-save
|
|
|
|
:init
|
|
|
|
(setq org-clock-persist-file (concat doom-etc-dir "org-clock-save.el"))
|
|
|
|
(defadvice! +org--clock-load-a (&rest _)
|
|
|
|
"Lazy load org-clock until its commands are used."
|
|
|
|
:before '(org-clock-in
|
|
|
|
org-clock-out
|
|
|
|
org-clock-in-last
|
|
|
|
org-clock-goto
|
|
|
|
org-clock-cancel)
|
|
|
|
(org-clock-load))
|
|
|
|
:config
|
2019-11-01 14:45:14 -04:00
|
|
|
(setq org-clock-persist 'history
|
2019-10-25 20:00:06 -04:00
|
|
|
;; Resume when clocking into task with open clock
|
2021-06-04 11:52:59 -04:00
|
|
|
org-clock-in-resume t
|
|
|
|
;; Remove log if task was clocked for 0:00 (accidental clocking)
|
2021-09-28 22:42:29 +02:00
|
|
|
org-clock-out-remove-zero-time-clocks t
|
|
|
|
;; The default value (5) is too conservative.
|
|
|
|
org-clock-history-length 20)
|
2019-10-25 20:00:06 -04:00
|
|
|
(add-hook 'kill-emacs-hook #'org-clock-save))
|
|
|
|
|
|
|
|
|
2020-04-14 15:31:39 -04:00
|
|
|
(use-package! org-pdftools
|
2019-10-25 20:00:06 -04:00
|
|
|
:when (featurep! :tools pdf)
|
2020-04-14 15:31:39 -04:00
|
|
|
:commands org-pdftools-export
|
2019-10-25 20:00:06 -04:00
|
|
|
:init
|
|
|
|
(after! org
|
2021-08-22 01:41:26 -04:00
|
|
|
;; HACK Fixes an issue where org-pdftools link handlers will throw a
|
|
|
|
;; 'pdf-info-epdfinfo-program is not executable' error whenever any
|
|
|
|
;; link is stored or exported (whether or not they're a pdf link). This
|
|
|
|
;; error gimps org until `pdf-tools-install' is run, but this is poor
|
|
|
|
;; UX, so we suppress it.
|
|
|
|
(defun +org--pdftools-link-handler (fn &rest args)
|
|
|
|
"Produces a link handler for org-pdftools that suppresses missing-epdfinfo errors whenever storing or exporting links."
|
|
|
|
(lambda (&rest args)
|
|
|
|
(and (ignore-errors (require 'org-pdftools nil t))
|
|
|
|
(file-executable-p pdf-info-epdfinfo-program)
|
|
|
|
(apply fn args))))
|
2020-04-17 14:05:15 -04:00
|
|
|
(org-link-set-parameters (or (bound-and-true-p org-pdftools-link-prefix) "pdf")
|
2021-08-22 01:41:26 -04:00
|
|
|
:follow (+org--pdftools-link-handler #'org-pdftools-open)
|
|
|
|
:complete (+org--pdftools-link-handler #'org-pdftools-complete-link)
|
|
|
|
:store (+org--pdftools-link-handler #'org-pdftools-store-link)
|
|
|
|
:export (+org--pdftools-link-handler #'org-pdftools-export))
|
2020-04-15 23:46:58 -04:00
|
|
|
(add-hook! 'org-open-link-functions
|
2020-04-17 22:45:16 -04:00
|
|
|
(defun +org-open-legacy-pdf-links-fn (link)
|
|
|
|
"Open pdftools:* and pdfviews:* links as if they were pdf:* links."
|
2020-04-16 19:10:28 -04:00
|
|
|
(let ((regexp "^pdf\\(?:tools\\|view\\):"))
|
2020-04-16 14:51:26 -04:00
|
|
|
(when (string-match-p regexp link)
|
2020-04-16 19:10:28 -04:00
|
|
|
(org-pdftools-open (replace-regexp-in-string regexp "" link))
|
2020-04-17 14:05:15 -04:00
|
|
|
t))))))
|
2019-10-25 20:00:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
(use-package! evil-org
|
|
|
|
:when (featurep! :editor evil +everywhere)
|
|
|
|
:hook (org-mode . evil-org-mode)
|
2020-08-05 18:17:13 -04:00
|
|
|
:hook (org-capture-mode . evil-insert-state)
|
2019-10-25 20:00:06 -04:00
|
|
|
:init
|
|
|
|
(defvar evil-org-retain-visual-state-on-shift t)
|
|
|
|
(defvar evil-org-special-o/O '(table-row))
|
|
|
|
(defvar evil-org-use-additional-insert t)
|
|
|
|
:config
|
2020-08-14 13:25:36 -04:00
|
|
|
(add-hook 'evil-org-mode-hook #'evil-normalize-keymaps)
|
2019-10-25 20:00:06 -04:00
|
|
|
(evil-org-set-key-theme)
|
2019-12-30 00:07:19 -05:00
|
|
|
(add-hook! 'org-tab-first-hook :append
|
|
|
|
;; Only fold the current tree, rather than recursively
|
|
|
|
#'+org-cycle-only-current-subtree-h
|
|
|
|
;; Clear babel results if point is inside a src block
|
|
|
|
#'+org-clear-babel-results-h)
|
2020-12-10 01:21:25 +01:00
|
|
|
(let-alist evil-org-movement-bindings
|
2021-02-27 19:46:33 -05:00
|
|
|
(let ((Cright (concat "C-" .right))
|
|
|
|
(Cleft (concat "C-" .left))
|
|
|
|
(Cup (concat "C-" .up))
|
|
|
|
(Cdown (concat "C-" .down))
|
2021-02-27 12:07:31 +09:00
|
|
|
(CSright (concat "C-S-" .right))
|
2021-02-27 19:46:33 -05:00
|
|
|
(CSleft (concat "C-S-" .left))
|
|
|
|
(CSup (concat "C-S-" .up))
|
|
|
|
(CSdown (concat "C-S-" .down)))
|
2020-12-10 01:21:25 +01:00
|
|
|
(map! :map evil-org-mode-map
|
|
|
|
:ni [C-return] #'+org/insert-item-below
|
|
|
|
:ni [C-S-return] #'+org/insert-item-above
|
|
|
|
;; navigate table cells (from insert-mode)
|
|
|
|
:i Cright (cmds! (org-at-table-p) #'org-table-next-field
|
2020-08-05 18:17:13 -04:00
|
|
|
#'org-end-of-line)
|
2020-12-10 01:21:25 +01:00
|
|
|
:i Cleft (cmds! (org-at-table-p) #'org-table-previous-field
|
2020-08-05 18:17:13 -04:00
|
|
|
#'org-beginning-of-line)
|
2020-12-10 01:21:25 +01:00
|
|
|
:i Cup (cmds! (org-at-table-p) #'+org/table-previous-row
|
2020-08-05 18:17:13 -04:00
|
|
|
#'org-up-element)
|
2020-12-10 01:21:25 +01:00
|
|
|
:i Cdown (cmds! (org-at-table-p) #'org-table-next-row
|
2020-08-05 18:17:13 -04:00
|
|
|
#'org-down-element)
|
2020-12-10 01:21:25 +01:00
|
|
|
:ni CSright #'org-shiftright
|
|
|
|
:ni CSleft #'org-shiftleft
|
|
|
|
:ni CSup #'org-shiftup
|
|
|
|
:ni CSdown #'org-shiftdown
|
|
|
|
;; more intuitive RET keybinds
|
|
|
|
:n [return] #'+org/dwim-at-point
|
|
|
|
:n "RET" #'+org/dwim-at-point
|
2022-02-10 20:21:04 +01:00
|
|
|
:i [return] #'+org/return
|
|
|
|
:i "RET" #'+org/return
|
2020-12-10 01:21:25 +01:00
|
|
|
:i [S-return] #'+org/shift-return
|
|
|
|
:i "S-RET" #'+org/shift-return
|
|
|
|
;; more vim-esque org motion keys (not covered by evil-org-mode)
|
|
|
|
:m "]h" #'org-forward-heading-same-level
|
|
|
|
:m "[h" #'org-backward-heading-same-level
|
|
|
|
:m "]l" #'org-next-link
|
|
|
|
:m "[l" #'org-previous-link
|
|
|
|
:m "]c" #'org-babel-next-src-block
|
|
|
|
:m "[c" #'org-babel-previous-src-block
|
|
|
|
:n "gQ" #'org-fill-paragraph
|
|
|
|
;; sensible vim-esque folding keybinds
|
|
|
|
:n "za" #'+org/toggle-fold
|
|
|
|
:n "zA" #'org-shifttab
|
|
|
|
:n "zc" #'+org/close-fold
|
|
|
|
:n "zC" #'outline-hide-subtree
|
|
|
|
:n "zm" #'+org/hide-next-fold-level
|
|
|
|
:n "zM" #'+org/close-all-folds
|
|
|
|
:n "zn" #'org-tree-to-indirect-buffer
|
|
|
|
:n "zo" #'+org/open-fold
|
|
|
|
:n "zO" #'outline-show-subtree
|
|
|
|
:n "zr" #'+org/show-next-fold-level
|
|
|
|
:n "zR" #'+org/open-all-folds
|
|
|
|
:n "zi" #'org-toggle-inline-images
|
|
|
|
|
|
|
|
:map org-read-date-minibuffer-local-map
|
2021-02-27 19:46:33 -05:00
|
|
|
Cleft (cmd! (org-eval-in-calendar '(calendar-backward-day 1)))
|
2020-12-10 01:21:25 +01:00
|
|
|
Cright (cmd! (org-eval-in-calendar '(calendar-forward-day 1)))
|
2021-02-27 19:46:33 -05:00
|
|
|
Cup (cmd! (org-eval-in-calendar '(calendar-backward-week 1)))
|
2020-12-10 01:21:25 +01:00
|
|
|
Cdown (cmd! (org-eval-in-calendar '(calendar-forward-week 1)))
|
|
|
|
CSleft (cmd! (org-eval-in-calendar '(calendar-backward-month 1)))
|
|
|
|
CSright (cmd! (org-eval-in-calendar '(calendar-forward-month 1)))
|
|
|
|
CSup (cmd! (org-eval-in-calendar '(calendar-backward-year 1)))
|
|
|
|
CSdown (cmd! (org-eval-in-calendar '(calendar-forward-year 1)))))))
|
2019-10-25 20:00:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
(use-package! evil-org-agenda
|
|
|
|
:when (featurep! :editor evil +everywhere)
|
|
|
|
:hook (org-agenda-mode . evil-org-agenda-mode)
|
|
|
|
:config
|
|
|
|
(evil-org-agenda-set-keys)
|
|
|
|
(evil-define-key* 'motion evil-org-agenda-mode-map
|
|
|
|
(kbd doom-leader-key) nil))
|
|
|
|
|
|
|
|
|
2018-05-18 01:43:37 +02:00
|
|
|
;;
|
2019-04-10 18:47:21 -04:00
|
|
|
;;; Bootstrap
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! org
|
2019-04-10 18:47:21 -04:00
|
|
|
:defer-incrementally
|
2019-06-28 16:53:26 +02:00
|
|
|
calendar find-func format-spec org-macs org-compat org-faces org-entities
|
|
|
|
org-list org-pcomplete org-src org-footnote org-macro ob org org-agenda
|
|
|
|
org-capture
|
|
|
|
:preface
|
2020-08-05 18:17:13 -04:00
|
|
|
;; Set to nil so we can detect user changes to them later (and fall back on
|
|
|
|
;; defaults otherwise).
|
2020-04-25 15:40:24 -04:00
|
|
|
(defvar org-directory nil)
|
2021-02-07 13:16:06 +01:00
|
|
|
(defvar org-id-locations-file nil)
|
2020-04-25 15:40:24 -04:00
|
|
|
(defvar org-attach-id-dir nil)
|
2021-10-03 20:38:27 +02:00
|
|
|
(defvar org-babel-python-command nil)
|
2020-04-25 15:40:24 -04:00
|
|
|
|
2020-04-25 01:27:25 -04:00
|
|
|
(setq org-publish-timestamp-directory (concat doom-cache-dir "org-timestamps/")
|
2020-07-26 16:13:29 -04:00
|
|
|
org-preview-latex-image-directory (concat doom-cache-dir "org-latex/")
|
2022-02-18 20:16:06 +01:00
|
|
|
org-persist-directory (concat doom-cache-dir "org-persist/")
|
2020-07-26 16:13:29 -04:00
|
|
|
;; Recognize a), A), a., A., etc -- must be set before org is loaded.
|
|
|
|
org-list-allow-alphabetical t)
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2020-08-05 18:17:13 -04:00
|
|
|
;; Make most of the default modules opt-in to lighten its first-time load
|
|
|
|
;; delay. I sincerely doubt most users use them all.
|
2019-06-28 16:53:26 +02:00
|
|
|
(defvar org-modules
|
2019-08-15 21:02:43 -04:00
|
|
|
'(;; ol-w3m
|
|
|
|
;; ol-bbdb
|
|
|
|
ol-bibtex
|
|
|
|
;; ol-docview
|
|
|
|
;; ol-gnus
|
|
|
|
;; ol-info
|
|
|
|
;; ol-irc
|
|
|
|
;; ol-mhe
|
|
|
|
;; ol-rmail
|
|
|
|
;; ol-eww
|
2019-06-28 16:53:26 +02:00
|
|
|
))
|
|
|
|
|
2020-04-08 15:17:56 -04:00
|
|
|
;;; Custom org modules
|
2020-05-11 02:53:18 -04:00
|
|
|
(dolist (flag doom--current-flags)
|
2020-05-11 04:53:39 -04:00
|
|
|
(load! (concat "contrib/" (substring (symbol-name flag) 1)) nil t))
|
2019-10-29 00:50:35 -04:00
|
|
|
|
2020-04-08 15:17:56 -04:00
|
|
|
;; Add our general hooks after the submodules, so that any hooks the
|
|
|
|
;; submodules add run after them, and can overwrite any defaults if necessary.
|
2019-04-10 18:47:21 -04:00
|
|
|
(add-hook! 'org-mode-hook
|
2019-10-25 20:00:06 -04:00
|
|
|
;; `show-paren-mode' causes flickering with indent overlays made by
|
2019-07-26 19:57:13 +02:00
|
|
|
;; `org-indent-mode', so we turn off show-paren-mode altogether
|
|
|
|
#'doom-disable-show-paren-mode-h
|
2019-10-25 20:00:06 -04:00
|
|
|
;; disable `show-trailing-whitespace'; shows a lot of false positives
|
2019-07-26 19:57:13 +02:00
|
|
|
#'doom-disable-show-trailing-whitespace-h
|
|
|
|
#'+org-enable-auto-reformat-tables-h
|
|
|
|
#'+org-enable-auto-update-cookies-h
|
2020-05-11 02:50:45 -04:00
|
|
|
#'+org-make-last-point-visible-h)
|
2019-04-10 18:47:21 -04:00
|
|
|
|
2019-06-28 16:53:26 +02:00
|
|
|
(add-hook! 'org-load-hook
|
2020-04-25 15:40:24 -04:00
|
|
|
#'+org-init-org-directory-h
|
2019-07-26 19:57:13 +02:00
|
|
|
#'+org-init-appearance-h
|
|
|
|
#'+org-init-agenda-h
|
2019-12-29 16:31:25 -05:00
|
|
|
#'+org-init-attachments-h
|
2019-07-26 19:57:13 +02:00
|
|
|
#'+org-init-babel-h
|
|
|
|
#'+org-init-babel-lazy-loader-h
|
|
|
|
#'+org-init-capture-defaults-h
|
|
|
|
#'+org-init-capture-frame-h
|
|
|
|
#'+org-init-custom-links-h
|
|
|
|
#'+org-init-export-h
|
2020-05-12 05:15:55 -04:00
|
|
|
#'+org-init-habit-h
|
2019-07-26 19:57:13 +02:00
|
|
|
#'+org-init-hacks-h
|
|
|
|
#'+org-init-keybinds-h
|
|
|
|
#'+org-init-popup-rules-h
|
|
|
|
#'+org-init-protocol-h
|
2020-05-13 22:48:42 -04:00
|
|
|
#'+org-init-protocol-lazy-loader-h
|
|
|
|
#'+org-init-smartparens-h)
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2020-04-08 15:17:56 -04:00
|
|
|
;; (Re)activate eldoc-mode in org-mode a little later, because it disables
|
|
|
|
;; itself if started too soon (which is the case with `global-eldoc-mode').
|
|
|
|
(add-hook 'org-mode-local-vars-hook #'eldoc-mode)
|
2019-10-25 20:00:06 -04:00
|
|
|
|
2019-06-28 16:53:26 +02:00
|
|
|
;; In case the user has eagerly loaded org from their configs
|
2019-08-28 14:15:13 -04:00
|
|
|
(when (and (featurep 'org)
|
2019-09-20 23:10:53 -04:00
|
|
|
(not byte-compile-current-file))
|
2020-05-20 01:07:32 -04:00
|
|
|
(unless doom-reloading-p
|
|
|
|
(message "`org' was already loaded by the time lang/org loaded, this may cause issues"))
|
2019-06-28 16:53:26 +02:00
|
|
|
(run-hooks 'org-load-hook))
|
2019-04-10 18:47:21 -04:00
|
|
|
|
2019-07-08 22:07:52 +02:00
|
|
|
:config
|
2020-12-12 15:38:29 -05:00
|
|
|
(add-to-list 'doom-debug-variables 'org-export-async-debug)
|
|
|
|
|
2020-12-25 09:44:18 +03:00
|
|
|
(set-company-backend! 'org-mode 'company-capf)
|
2020-08-05 23:52:56 -04:00
|
|
|
(set-eval-handler! 'org-mode #'+org-eval-handler)
|
2020-08-06 00:19:56 -04:00
|
|
|
(set-lookup-handlers! 'org-mode
|
|
|
|
:definition #'+org-lookup-definition-handler
|
|
|
|
:references #'+org-lookup-references-handler
|
|
|
|
:documentation #'+org-lookup-documentation-handler)
|
2020-08-05 23:52:56 -04:00
|
|
|
|
|
|
|
;; Save target buffer after archiving a node.
|
|
|
|
(setq org-archive-subtree-save-file-p t)
|
2020-03-10 22:15:49 -04:00
|
|
|
|
2021-07-28 14:06:35 -04:00
|
|
|
;; Don't number headings with these tags
|
|
|
|
(setq org-num-face '(:inherit org-special-keyword :underline nil :weight bold)
|
|
|
|
org-num-skip-tags '("noexport" "nonum"))
|
|
|
|
|
2020-07-26 16:13:13 -04:00
|
|
|
;; Prevent modifications made in invisible sections of an org document, as
|
|
|
|
;; unintended changes can easily go unseen otherwise.
|
|
|
|
(setq org-catch-invisible-edits 'smart)
|
|
|
|
|
2020-01-02 00:31:20 -05:00
|
|
|
;; Global ID state means we can have ID links anywhere. This is required for
|
|
|
|
;; `org-brain', however.
|
2020-05-20 01:07:52 -04:00
|
|
|
(setq org-id-locations-file-relative t)
|
2020-01-02 00:31:20 -05:00
|
|
|
|
2020-02-06 22:26:06 -05:00
|
|
|
;; HACK `org-id' doesn't check if `org-id-locations-file' exists or is
|
|
|
|
;; writeable before trying to read/write to it.
|
|
|
|
(defadvice! +org--fail-gracefully-a (&rest _)
|
|
|
|
:before-while '(org-id-locations-save org-id-locations-load)
|
2020-03-01 23:35:59 -05:00
|
|
|
(file-writable-p org-id-locations-file))
|
2020-02-06 22:26:06 -05:00
|
|
|
|
2021-07-31 02:01:37 -04:00
|
|
|
(add-hook 'org-open-at-point-functions #'doom-set-jump-h)
|
2022-02-09 14:33:43 +01:00
|
|
|
;; HACK For functions that dodge `org-open-at-point-functions', like
|
|
|
|
;; `org-id-open', `org-goto', or roam: links.
|
|
|
|
(advice-add #'org-mark-ring-push :around #'doom-set-jump-a)
|
2021-07-31 02:01:37 -04:00
|
|
|
|
|
|
|
;; Add the ability to play gifs, at point or throughout the buffer. However,
|
|
|
|
;; 'playgifs' is stupid slow and there's not much I can do to fix it; use at
|
|
|
|
;; your own risk.
|
|
|
|
(add-to-list 'org-startup-options '("inlinegifs" +org-startup-with-animated-gifs at-point))
|
|
|
|
(add-to-list 'org-startup-options '("playgifs" +org-startup-with-animated-gifs t))
|
|
|
|
(add-hook! 'org-mode-local-vars-hook
|
|
|
|
(defun +org-init-gifs-h ()
|
|
|
|
(remove-hook 'post-command-hook #'+org-play-gif-at-point-h t)
|
|
|
|
(remove-hook 'post-command-hook #'+org-play-all-gifs-h t)
|
|
|
|
(pcase +org-startup-with-animated-gifs
|
|
|
|
(`at-point (add-hook 'post-command-hook #'+org-play-gif-at-point-h nil t))
|
|
|
|
(`t (add-hook 'post-command-hook #'+org-play-all-gifs-h nil t))))))
|