2017-12-08 22:59:42 -05:00
|
|
|
;;; lang/org/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
(defvar +org-babel-mode-alist
|
|
|
|
'((cpp . C)
|
|
|
|
(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.
|
|
|
|
|
2020-04-08 15:29:29 -04:00
|
|
|
For example, (fish . shell) will cause #+BEGIN_SRC fish blocks to load
|
|
|
|
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")
|
|
|
|
|
|
|
|
|
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-footnote-auto-label 'plain
|
|
|
|
org-hide-leading-stars t
|
|
|
|
org-image-actual-width nil
|
2020-07-31 01:31:03 -04:00
|
|
|
org-imenu-depth 8
|
2020-08-08 23:25:39 -04:00
|
|
|
;; Sub-lists should have different bullets
|
|
|
|
org-list-demote-modify-bullet '(("+" . "-") ("-" . "+") ("*" . "+") ("1." . "a."))
|
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-02-17 11:11:38 +01:00
|
|
|
org-use-sub-superscripts '{})
|
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-10-04 23:06:11 -04:00
|
|
|
;; Previews are rendered with the incorrect background
|
2020-04-14 15:34:20 -04:00
|
|
|
(plist-put org-format-latex-options :scale 1.5) ; larger previews
|
2020-10-11 16:33:25 -04:00
|
|
|
(plist-put org-format-latex-options :background 'default) ; match the background
|
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
|
|
|
|
(when-let (link (org-element-property :raw-link (org-element-context)))
|
|
|
|
(format "Link: %s" link)))
|
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
|
|
|
|
(add-to-list 'org-babel-default-lob-header-args '(:async . nil)))
|
|
|
|
|
|
|
|
(defadvice! +org-inhibit-async-babel-blocks-on-export-a (orig-fn &optional fn arg info params)
|
|
|
|
"Exporting org documents with async blocks will sometimes substitute
|
|
|
|
evaluation output with hashes in the exported document. This is because the
|
|
|
|
block is executed asynchronously, but the exporter doesn't wait for it to
|
|
|
|
finish. This advice forces babel blocks to not execute asychronously when being
|
|
|
|
exported."
|
|
|
|
:around #'ob-async-org-babel-execute-src-block
|
|
|
|
(let ((async (or (assoc :async params)
|
|
|
|
(assoc :async (nth 2 (or info (org-babel-get-src-block-info)))))))
|
|
|
|
(if (and async (null (cdr async)))
|
|
|
|
(funcall fn arg info params)
|
|
|
|
(funcall orig-fn fn arg info params))))
|
|
|
|
|
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))
|
2019-10-25 20:00:06 -04:00
|
|
|
(org-babel-do-in-edit-buffer
|
|
|
|
(call-interactively #'indent-for-tab-command))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2020-07-31 15:41:34 -04:00
|
|
|
(defadvice! +org-inhibit-mode-hooks-a (orig-fn datum name &optional initialize &rest args)
|
|
|
|
"Prevent potentially expensive mode hooks in `org-babel-do-in-edit-buffer' ops."
|
|
|
|
:around #'org-src--edit-element
|
|
|
|
(apply orig-fn datum name
|
|
|
|
(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)
|
|
|
|
(add-hook 'org-babel-after-execute-hook #'org-redisplay-inline-images)
|
|
|
|
|
2020-02-28 18:52:50 +01:00
|
|
|
(after! python
|
2020-11-09 02:25:59 -05:00
|
|
|
(setq org-babel-python-command python-shell-interpreter))
|
|
|
|
|
|
|
|
;; NOTE Backported from Emacs 27.1
|
|
|
|
;; DEPRECATED Remove when 26.x support is dropped
|
|
|
|
(unless EMACS27+
|
|
|
|
(defadvice! +org--dont-suppress-window-changes-a (orig-fn &rest args)
|
|
|
|
:around #'org-babel-execute:emacs-lisp
|
|
|
|
(letf! ((#'current-window-configuration #'ignore)
|
|
|
|
(#'set-window-configuration #'ignore))
|
|
|
|
(apply orig-fn args)))))
|
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)))
|
2020-04-13 15:23:16 -04:00
|
|
|
(+org--babel-lazy-load lang (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.
|
|
|
|
(defadvice! +org--remove-customize-option-a (orig-fn table title &optional prompt specials)
|
|
|
|
:around #'org-mks
|
2020-05-11 03:08:37 -04:00
|
|
|
(funcall orig-fn table title prompt
|
|
|
|
(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 ()
|
2019-06-28 16:53:26 +02:00
|
|
|
;; Highlight broken file links
|
|
|
|
(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
|
|
|
|
'error)))
|
|
|
|
|
|
|
|
;; Add custom link types
|
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
|
|
|
|
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"))))
|
|
|
|
|
2020-06-04 23:48:16 -04:00
|
|
|
(defadvice! +org--dont-trigger-save-hooks-on-export-a (orig-fn &rest args)
|
|
|
|
"`org-export-to-file' triggers save hooks, which may inadvertantly change
|
|
|
|
the exported output (i.e. formatters)."
|
|
|
|
:around #'org-export-to-file
|
|
|
|
(let (before-save-hook after-save-hook)
|
|
|
|
(apply orig-fn args)))
|
|
|
|
|
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
|
|
|
(defadvice! +org--fix-async-export-a (orig-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)
|
|
|
|
(load ,(or old-async-init-file user-init-file)
|
|
|
|
nil t)
|
|
|
|
(delete-file ,org-export-async-init-file))
|
|
|
|
(current-buffer)))
|
|
|
|
(apply orig-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
|
|
|
|
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-01-03 22:37:51 -05:00
|
|
|
(defadvice! +org--strip-properties-from-outline-a (orig-fn &rest args)
|
|
|
|
"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))))
|
|
|
|
(apply orig-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."
|
|
|
|
(quiet! (org-mode-restart))
|
|
|
|
(delq! (current-buffer) org-agenda-new-buffers)
|
|
|
|
(remove-hook 'doom-switch-buffer-hook #'+org--restart-mode-h
|
|
|
|
'local))
|
|
|
|
|
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)
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(add-hook 'doom-switch-buffer-hook #'+org--restart-mode-h
|
|
|
|
nil 'local)))))
|
2019-07-21 02:38:42 +02:00
|
|
|
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +org--exclude-agenda-buffers-from-recentf-a (orig-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)
|
2020-08-21 19:16:56 -04:00
|
|
|
find-file-hook
|
|
|
|
org-mode-hook)
|
2019-09-26 15:29:09 -04:00
|
|
|
(funcall orig-fn file)))
|
|
|
|
|
|
|
|
;; 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).
|
2019-09-26 15:29:09 -04:00
|
|
|
(defadvice! +org--fix-inline-images-for-imagemagick-users-a (orig-fn &rest args)
|
|
|
|
: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)))
|
2020-03-31 12:33:16 +01:00
|
|
|
(apply orig-fn args)))
|
|
|
|
|
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
|
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
|
|
|
|
(: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)
|
2019-11-04 10:48:06 +00:00
|
|
|
"A" #'org-archive-subtree
|
2019-10-11 14:49:21 -04:00
|
|
|
"e" #'org-export-dispatch
|
2019-04-04 18:47:40 -04:00
|
|
|
"f" #'org-footnote-new
|
2019-05-12 01:46:29 -04:00
|
|
|
"h" #'org-toggle-heading
|
|
|
|
"i" #'org-toggle-item
|
|
|
|
"I" #'org-toggle-inline-images
|
2019-10-25 20:00:06 -04:00
|
|
|
"n" #'org-store-link
|
|
|
|
"o" #'org-set-property
|
|
|
|
"p" #'org-priority
|
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)
|
|
|
|
"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'
|
|
|
|
(:prefix ("s" . "Tree/Subtree")
|
|
|
|
"a" #'org-toggle-archive-tag
|
|
|
|
"b" #'org-tree-to-indirect-buffer
|
|
|
|
"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
|
|
|
|
"S" #'org-sort
|
|
|
|
(:prefix ("p" . "Org Priority")
|
|
|
|
"d" #'org-priority-down
|
|
|
|
"p" #'org-priority
|
|
|
|
"u" #'org-priority-up)))
|
|
|
|
|
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)
|
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)
|
|
|
|
("^\\*Org Src" :size 0.4 :quit nil :select t :autosave t :modeline t :ttl nil)
|
|
|
|
("^\\*Org-Babel")
|
2020-02-27 20:10:48 +01:00
|
|
|
("^CAPTURE-.*\\.org$" :size 0.25 :quit nil :select t :autosave t))))
|
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")
|
|
|
|
|
|
|
|
(defadvice! +org-inhibit-scrolling-a (orig-fn &rest args)
|
|
|
|
"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)))
|
|
|
|
(prog1 (apply orig-fn args)
|
|
|
|
(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
|
|
|
|
org-clock-in-resume t)
|
|
|
|
(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
|
2020-04-17 14:05:15 -04:00
|
|
|
(org-link-set-parameters (or (bound-and-true-p org-pdftools-link-prefix) "pdf")
|
2020-04-14 15:31:39 -04:00
|
|
|
:follow #'org-pdftools-open
|
|
|
|
:complete #'org-pdftools-complete-link
|
|
|
|
:store #'org-pdftools-store-link
|
|
|
|
:export #'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
|
|
|
|
(let ((Cright (concat "C-" .right))
|
|
|
|
(Cleft (concat "C-" .left))
|
|
|
|
(Cup (concat "C-" .up))
|
|
|
|
(Cdown (concat "C-" .down))
|
|
|
|
(CSright (concat "C-" (capitalize .right)))
|
|
|
|
(CSleft (concat "C-" (capitalize .left)))
|
|
|
|
(CSup (concat "C-" (capitalize .up)))
|
|
|
|
(CSdown (concat "C-" (capitalize .down))))
|
|
|
|
(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
|
|
|
|
:i [return] (cmd! (org-return electric-indent-mode))
|
|
|
|
:i "RET" (cmd! (org-return electric-indent-mode))
|
|
|
|
: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
|
|
|
|
Cleft (cmd! (org-eval-in-calendar '(calendar-backward-day 1)))
|
|
|
|
Cright (cmd! (org-eval-in-calendar '(calendar-forward-day 1)))
|
|
|
|
Cup (cmd! (org-eval-in-calendar '(calendar-backward-week 1)))
|
|
|
|
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)
|
|
|
|
|
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/")
|
|
|
|
;; 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
|
|
|
|
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
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
(add-hook 'org-open-at-point-functions #'doom-set-jump-h))
|