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)
|
|
|
|
(sh . shell)
|
|
|
|
(bash . shell)
|
|
|
|
(matlab . octave))
|
|
|
|
"An alist mapping languages to babel libraries. This is necessary for babel
|
|
|
|
libraries (ob-*.el) that don't match the name of the language.
|
|
|
|
|
|
|
|
For example, with (fish . shell) will cause #+BEGIN_SRC fish to load ob-shell.el
|
|
|
|
when executed.")
|
|
|
|
|
|
|
|
(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'.")
|
|
|
|
|
|
|
|
(defvar +org-initial-fold-level 2
|
|
|
|
"The initial fold level of org files when no #+STARTUP options for it.")
|
|
|
|
|
|
|
|
(defvar +org-enable-centralized-exports t
|
|
|
|
"If non-nil, files exported from files in `org-directory' will be stored in
|
|
|
|
`+org-export-directory', rather than the same directory has the input file(s).")
|
|
|
|
|
|
|
|
(defvar +org-export-directory ".export/"
|
|
|
|
"Where to store exported files relative to `org-directory'. Can be an absolute
|
|
|
|
path too.")
|
|
|
|
|
|
|
|
(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
|
|
|
|
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
|
|
|
|
(setq org-agenda-files (list org-directory)))
|
2017-07-05 02:33:41 +02:00
|
|
|
(setq-default
|
2019-09-10 14:54:13 -04:00
|
|
|
;; Don't monopolize the whole frame just for the agenda
|
|
|
|
org-agenda-window-setup 'current-window
|
2019-07-22 00:36:02 +02:00
|
|
|
;; Hide blocked tasks in the agenda view.
|
|
|
|
org-agenda-dim-blocked-tasks 'invisible
|
2017-07-05 02:33:41 +02:00
|
|
|
org-agenda-inhibit-startup t
|
2018-06-10 01:32:19 +02:00
|
|
|
org-agenda-skip-unavailable-files t
|
|
|
|
;; Move the agenda to show the previous 3 days and the next 7 days for a bit
|
|
|
|
;; better context instead of just the current week which is a bit confusing
|
|
|
|
;; on, for example, a sunday
|
|
|
|
org-agenda-span 10
|
|
|
|
org-agenda-start-on-weekday nil
|
|
|
|
org-agenda-start-day "-3d"))
|
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" "♯"))
|
|
|
|
org-fontify-done-headline t
|
|
|
|
org-fontify-quote-and-verse-blocks t
|
|
|
|
org-fontify-whole-heading-line t
|
|
|
|
org-footnote-auto-label 'plain
|
|
|
|
org-hide-leading-stars t
|
|
|
|
org-hide-leading-stars-before-indent-mode t
|
|
|
|
org-image-actual-width nil
|
|
|
|
org-list-description-max-indent 4
|
|
|
|
org-priority-faces
|
|
|
|
'((?A . error)
|
|
|
|
(?B . warning)
|
|
|
|
(?C . success))
|
|
|
|
org-startup-indented t
|
|
|
|
org-tags-column -80
|
|
|
|
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
|
|
|
|
;; target! e.g. FILE/Task/heading/subheading
|
|
|
|
org-refile-use-outline-path 'file
|
|
|
|
org-outline-path-complete-in-steps nil)
|
|
|
|
|
2019-10-28 02:02:45 -04:00
|
|
|
;; Scale up LaTeX previews a bit (default is too small)
|
|
|
|
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5))
|
|
|
|
;; ...and fix their background w/ themes
|
2019-10-27 17:23:22 -04:00
|
|
|
(add-hook! 'doom-load-theme-hook
|
|
|
|
(defun +org-refresh-latex-background ()
|
|
|
|
"Previews are usually rendered with light backgrounds, so ensure their
|
|
|
|
background (and foreground) match the current theme."
|
|
|
|
(setq org-format-latex-options
|
|
|
|
(plist-put org-format-latex-options
|
|
|
|
:background
|
|
|
|
(face-attribute (or (cadr (assq 'default face-remapping-alist))
|
|
|
|
'default)
|
|
|
|
:background nil t)))))
|
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.
|
|
|
|
(custom-declare-face '+org-todo-active '((t (:inherit (bold font-lock-constant-face org-todo)))) "")
|
|
|
|
(custom-declare-face '+org-todo-project '((t (:inherit (bold font-lock-doc-face org-todo)))) "")
|
|
|
|
(custom-declare-face '+org-todo-onhold '((t (:inherit (bold warning org-todo)))) "")
|
|
|
|
(setq org-todo-keywords
|
|
|
|
'((sequence
|
|
|
|
"TODO(t)" ; A task that needs doing & is ready to do
|
|
|
|
"PROJ(p)" ; An ongoing project that cannot be completed in one step
|
2019-10-29 11:36:22 -04:00
|
|
|
"STRT(s)" ; A task that is in progress
|
2019-10-27 14:05:31 -04:00
|
|
|
"WAIT(w)" ; Something is holding up this task; or it is paused
|
|
|
|
"|"
|
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
|
|
|
|
"|"
|
2019-10-28 12:57:11 -04:00
|
|
|
"[X](D)")) ; Task was completed
|
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)
|
|
|
|
("PROJ" . +org-todo-project)))
|
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
(defadvice! +org-display-link-in-eldoc-a (orig-fn &rest args)
|
|
|
|
"Display full link in minibuffer when cursor/mouse is over it."
|
|
|
|
:around #'org-eldoc-documentation-function
|
|
|
|
(or (when-let (link (org-element-property :raw-link (org-element-context)))
|
|
|
|
(format "Link: %s" link))
|
|
|
|
(apply orig-fn args)))
|
2019-02-22 02:07:44 -05:00
|
|
|
|
2018-07-29 02:54:19 +02:00
|
|
|
;; Don't do automatic indent detection in org files
|
2019-10-27 17:23:22 -04:00
|
|
|
(cl-pushnew 'org-mode doom-detect-indentation-excluded-modes :test #'eq)
|
2018-07-29 02:54:19 +02:00
|
|
|
|
2019-06-28 16:53:26 +02:00
|
|
|
(set-pretty-symbols! 'org-mode
|
|
|
|
:name "#+NAME:"
|
|
|
|
:src_block "#+BEGIN_SRC"
|
2019-10-27 17:23:22 -04:00
|
|
|
:src_block_end "#+END_SRC"))
|
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
|
2019-06-28 16:53:26 +02:00
|
|
|
org-src-tab-acts-natively t
|
2019-09-10 14:54:13 -04:00
|
|
|
org-confirm-babel-evaluate nil ; you don't need my permission
|
|
|
|
;; Show src buffer in popup, and don't monopolize the frame
|
|
|
|
org-src-window-setup 'other-window)
|
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)
|
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
(defadvice! +org-fix-newline-and-indent-in-src-blocks-a ()
|
|
|
|
"Mimic `newline-and-indent' in src blocks w/ lang-appropriate indentation."
|
|
|
|
:after #'org-return-indent
|
|
|
|
(when (org-in-src-block-p t)
|
|
|
|
(org-babel-do-in-edit-buffer
|
|
|
|
(call-interactively #'indent-for-tab-command))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
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)
|
|
|
|
|
2019-10-23 18:05:15 -04:00
|
|
|
;; Fix 'require(...).print is not a function' error from `ob-js' when
|
|
|
|
;; executing JS src blocks
|
2019-06-30 02:27:07 +02:00
|
|
|
(setq org-babel-js-function-wrapper "console.log(require('util').inspect(function(){\n%s\n}()));"))
|
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."
|
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))
|
|
|
|
(fboundp (intern-soft (format "%s-mode" lang)))
|
|
|
|
(require (intern-soft (format "ob-%s" lang)) nil t)))
|
|
|
|
|
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)))
|
2019-09-08 20:55:21 -04:00
|
|
|
(when (and lang
|
|
|
|
(not (cdr (assq lang org-babel-load-languages)))
|
2019-06-28 16:53:26 +02:00
|
|
|
(or (run-hook-with-args-until-success '+org-babel-load-functions lang)
|
|
|
|
(require (intern (format "ob-%s" lang)) nil t)))
|
|
|
|
(when (assq :async (nth 2 info))
|
|
|
|
;; 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))
|
|
|
|
(add-to-list 'org-babel-load-languages (cons lang t)))
|
2019-07-21 02:38:42 +02:00
|
|
|
t)))
|
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)
|
|
|
|
org-capture-templates
|
|
|
|
'(("t" "Personal todo" entry
|
|
|
|
(file+headline +org-capture-todo-file "Inbox")
|
|
|
|
"* TODO %?\n%i\n%a" :prepend t :kill-buffer t)
|
|
|
|
("n" "Personal notes" entry
|
|
|
|
(file+headline +org-capture-notes-file "Inbox")
|
|
|
|
"* %u %?\n%i\n%a" :prepend t :kill-buffer t)
|
|
|
|
|
|
|
|
;; 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")
|
|
|
|
("pt" "Project todo" entry ; {project-root}/todo.org
|
|
|
|
(file+headline +org-capture-project-todo-file "Inbox")
|
|
|
|
"* TODO %?\n%i\n%a" :prepend t :kill-buffer t)
|
|
|
|
("pn" "Project notes" entry ; {project-root}/notes.org
|
|
|
|
(file+headline +org-capture-project-notes-file "Inbox")
|
|
|
|
"* TODO %?\n%i\n%a" :prepend t :kill-buffer t)
|
|
|
|
("pc" "Project changelog" entry ; {project-root}/changelog.org
|
|
|
|
(file+headline +org-capture-project-notes-file "Unreleased")
|
|
|
|
"* TODO %?\n%i\n%a" :prepend t :kill-buffer t)))
|
|
|
|
|
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-23 17:24:56 +02:00
|
|
|
(defadvice! +org--prevent-save-prompts-when-refiling-a (&rest _)
|
2019-06-28 16:53:26 +02:00
|
|
|
"Fix #462: when refiling from org-capture, Emacs prompts to kill the
|
|
|
|
underlying, modified buffer. This fixes that."
|
2019-07-21 02:38:42 +02:00
|
|
|
:after 'org-refile
|
2019-06-28 16:53:26 +02:00
|
|
|
(when (bound-and-true-p org-capture-is-refiling)
|
|
|
|
(org-save-all-org-buffers)))
|
|
|
|
|
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
|
|
|
|
header-line-format))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
(when (featurep! :editor evil)
|
|
|
|
(add-hook 'org-capture-mode-hook #'evil-insert-state)))
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
(when (featurep! :ui doom-dashboard)
|
|
|
|
(add-hook '+doom-dashboard-inhibit-functions #'+org-capture-frame-p)))
|
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-centralized-attachments-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
"I believe Org's native attachment system is over-complicated and litters
|
|
|
|
files with metadata I don't want. So I wrote my own, which:
|
|
|
|
|
2019-09-20 23:10:53 -04:00
|
|
|
+ Places attachments in a centralized location (`org-attach-id-dir' in
|
2019-06-28 16:53:26 +02:00
|
|
|
`org-directory').
|
|
|
|
+ Adds attach:* link abbreviation for quick links to these files from anywhere.
|
|
|
|
+ Use `+org-attach/sync' to index all attachments in `org-directory' that use
|
|
|
|
the attach:* abbreviation and delete orphaned ones that are no longer
|
|
|
|
referenced.
|
|
|
|
+ This compliments the +dragndrop flag which provides drag'n'drop support for
|
|
|
|
images (with preview) and media files.
|
|
|
|
|
|
|
|
Some commands of interest:
|
|
|
|
+ `org-download-screenshot'
|
|
|
|
+ `+org-attach/file'
|
|
|
|
+ `+org-attach/url'
|
|
|
|
+ `+org-attach/sync'"
|
2019-09-20 23:10:53 -04:00
|
|
|
(setq org-attach-id-dir (doom-path org-directory org-attach-id-dir))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2019-07-18 15:10:36 +02:00
|
|
|
;; A shorter link to attachments
|
2019-07-21 23:31:42 +02:00
|
|
|
(add-to-list 'org-link-abbrev-alist
|
|
|
|
(cons "attach"
|
2019-09-20 23:10:53 -04:00
|
|
|
(abbreviate-file-name org-attach-id-dir)))
|
2019-07-18 15:10:36 +02:00
|
|
|
|
2019-06-28 16:53:26 +02:00
|
|
|
(org-link-set-parameters
|
|
|
|
"attach"
|
2019-09-20 23:10:53 -04:00
|
|
|
:follow (lambda (link) (find-file (doom-path org-attach-id-dir link)))
|
2019-06-28 16:53:26 +02:00
|
|
|
:complete (lambda (&optional _arg)
|
2019-09-20 23:10:53 -04:00
|
|
|
(+org--relpath (+org-link-read-file "attach" org-attach-id-dir)
|
|
|
|
org-attach-id-dir))
|
2019-06-28 16:53:26 +02:00
|
|
|
:face (lambda (link)
|
2019-09-20 23:10:53 -04:00
|
|
|
(if (file-exists-p (expand-file-name link org-attach-id-dir))
|
2019-06-28 16:53:26 +02:00
|
|
|
'org-link
|
|
|
|
'error)))
|
|
|
|
|
|
|
|
(after! projectile
|
2019-09-20 23:10:53 -04:00
|
|
|
(add-to-list 'projectile-globally-ignored-directories org-attach-id-dir))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
(after! recentf
|
|
|
|
(add-to-list 'recentf-exclude
|
2019-09-20 23:10:53 -04:00
|
|
|
(lambda (file) (file-in-directory-p file org-attach-id-dir)))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-centralized-exports-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
"TODO"
|
|
|
|
;; I don't have any beef with org's built-in export system, but I do wish it
|
|
|
|
;; would export to a central directory (by default), rather than
|
|
|
|
;; `default-directory'. This is because all my org files are usually in one
|
|
|
|
;; place, and I want to be able to refer back to old exports if needed.
|
|
|
|
(setq +org-export-directory (expand-file-name +org-export-directory org-directory))
|
|
|
|
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +org--export-output-file-name-a (args)
|
2019-06-28 16:53:26 +02:00
|
|
|
"Return a centralized export location unless one is provided or the current
|
|
|
|
file isn't in `org-directory'."
|
2019-07-21 02:38:42 +02:00
|
|
|
:filter-args #'org-export-output-file-name
|
2019-06-28 16:53:26 +02:00
|
|
|
(when (and +org-enable-centralized-exports
|
|
|
|
(not (nth 2 args))
|
|
|
|
buffer-file-name
|
|
|
|
(file-in-directory-p buffer-file-name org-directory))
|
|
|
|
(cl-destructuring-bind (extension &optional subtreep _pubdir) args
|
|
|
|
(let ((dir (expand-file-name +org-export-directory org-directory)))
|
|
|
|
(unless (file-directory-p dir)
|
|
|
|
(make-directory dir t))
|
|
|
|
(setq args (list extension subtreep dir)))))
|
2019-07-21 02:38:42 +02:00
|
|
|
args))
|
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
|
|
|
(defun +org--relpath (path root)
|
|
|
|
(if (and buffer-file-name (file-in-directory-p buffer-file-name root))
|
|
|
|
(file-relative-name path)
|
|
|
|
path))
|
|
|
|
|
|
|
|
(defun +org-def-link (key dir)
|
|
|
|
(org-link-set-parameters
|
|
|
|
key
|
|
|
|
:complete (lambda () (+org--relpath (+org-link-read-file key dir) dir))
|
|
|
|
:follow (lambda (link) (find-file (expand-file-name link dir)))
|
|
|
|
:face (lambda (link)
|
|
|
|
(if (file-exists-p (expand-file-name link dir))
|
|
|
|
'org-link
|
|
|
|
'error))))
|
2019-03-07 00:15:15 -05:00
|
|
|
|
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)
|
|
|
|
(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")
|
|
|
|
'("wolfram" . "https://wolframalpha.com/input/?i=%s")
|
|
|
|
'("doom-repo" . "https://github.com/hlissner/doom-emacs/%s"))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
(+org-def-link "org" org-directory)
|
|
|
|
(+org-def-link "doom" doom-emacs-dir)
|
|
|
|
(+org-def-link "doom-docs" doom-docs-dir)
|
|
|
|
(+org-def-link "doom-modules" doom-modules-dir)
|
|
|
|
|
|
|
|
;; Allow inline image previews of http(s)? urls or data uris
|
|
|
|
(org-link-set-parameters "http" :image-data-fun #'+org-image-link)
|
|
|
|
(org-link-set-parameters "https" :image-data-fun #'+org-image-link)
|
|
|
|
(org-link-set-parameters "img" :image-data-fun #'+org-inline-data-image)
|
|
|
|
|
|
|
|
;; Add support for youtube links + previews
|
2019-10-25 20:00:06 -04:00
|
|
|
(require 'org-yt nil t))
|
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
|
|
|
|
org-html-validation-link nil)
|
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)
|
2019-08-29 16:26:06 +02:00
|
|
|
(variable . "revealjs-url=https://cdn.jsdelivr.net/npm/reveal.js@3/")))))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-habit-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
"TODO"
|
2019-07-26 22:46:05 +02:00
|
|
|
(add-hook! 'org-agenda-mode-hook
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-habit-resize-graph-h ()
|
|
|
|
"Right align and resize the consistency graphs based on
|
2019-06-28 16:53:26 +02:00
|
|
|
`+org-habit-graph-window-ratio'"
|
2019-07-21 02:38:42 +02:00
|
|
|
(require '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)))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun +org-init-hacks-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
"Getting org to behave."
|
|
|
|
;; Don't open separate windows
|
|
|
|
(setf (alist-get 'file org-link-frame-setup) #'find-file)
|
|
|
|
;; Open directory links in Emacs
|
|
|
|
(add-to-list 'org-file-apps '(directory . emacs))
|
|
|
|
|
2019-07-22 00:36:17 +02:00
|
|
|
;; When you create a sparse tree and `org-indent-mode' is enabled, the
|
|
|
|
;; highlighting destroys the invisibility added by `org-indent-mode'.
|
|
|
|
;; Therefore, don't highlight when creating a sparse tree.
|
|
|
|
(setq org-highlight-sparse-tree-matches nil)
|
|
|
|
|
2019-07-26 22:46:05 +02:00
|
|
|
(add-hook! 'org-follow-link-hook
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-delayed-recenter-h ()
|
|
|
|
"`recenter', but after a tiny delay. Necessary to prevent certain race
|
2019-06-28 16:53:26 +02:00
|
|
|
conditions where a window's buffer hasn't changed at the time this hook is run."
|
2019-07-21 02:38:42 +02:00
|
|
|
(run-at-time 0.1 nil #'recenter)))
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +org--strip-properties-from-outline-a (orig-fn path &optional width prefix separator)
|
2019-06-28 16:53:26 +02:00
|
|
|
"Remove link syntax and fix variable height text (e.g. org headings) in the
|
|
|
|
eldoc string."
|
2019-07-21 02:38:42 +02:00
|
|
|
:around #'org-format-outline-path
|
2019-06-28 16:53:26 +02:00
|
|
|
(let ((result (funcall orig-fn path width prefix separator))
|
|
|
|
(separator (or separator "/")))
|
|
|
|
(string-join
|
|
|
|
(cl-loop for part
|
2019-10-21 14:45:43 -04:00
|
|
|
in (cdr (split-string (substring-no-properties result) separator))
|
2019-06-28 16:53:26 +02:00
|
|
|
for n from 0
|
|
|
|
for face = (nth (% n org-n-level-faces) org-level-faces)
|
|
|
|
collect
|
2019-09-20 23:10:53 -04:00
|
|
|
(org-add-props (replace-regexp-in-string org-link-any-re "\\4" part)
|
2019-06-28 16:53:26 +02:00
|
|
|
nil 'face `(:foreground ,(face-foreground face nil t) :weight bold)))
|
|
|
|
separator)))
|
|
|
|
|
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 ()
|
2019-08-27 00:13:04 -04:00
|
|
|
"Prevent temporarily-opened agenda buffers from being associated with the
|
2019-10-04 13:57:20 -04:00
|
|
|
current workspace (and clean them up)."
|
2019-07-21 02:38:42 +02:00
|
|
|
(when (and org-agenda-new-buffers (bound-and-true-p persp-mode))
|
2019-10-07 12:52:10 -04:00
|
|
|
(let (persp-autokill-buffer-on-remove)
|
2019-07-21 02:38:42 +02:00
|
|
|
(persp-remove-buffer org-agenda-new-buffers
|
|
|
|
(get-current-persp)
|
2019-10-07 23:20:23 -04:00
|
|
|
nil))
|
|
|
|
(dolist (buffer org-agenda-new-buffers)
|
|
|
|
(with-current-buffer buffer
|
|
|
|
;; HACK Org agenda opens temporary agenda incomplete org-mode
|
2019-10-20 13:29:29 -04:00
|
|
|
;; buffers. These are great for extracting agenda information
|
|
|
|
;; from, but what if the user tries to visit one of these
|
|
|
|
;; buffers? Then we remove it from the to-be-cleaned queue and
|
|
|
|
;; restart `org-mode' so they can grow up to be full-fledged
|
|
|
|
;; org-mode buffers.
|
2019-10-07 23:20:23 -04:00
|
|
|
(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
|
2019-06-28 16:53:26 +02:00
|
|
|
(let ((recentf-exclude (list (lambda (_file) t))))
|
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
|
|
|
|
(cl-letf* ((old-create-image (symbol-function #'create-image))
|
|
|
|
((symbol-function #'create-image)
|
|
|
|
(lambda (file-or-data &optional type data-p &rest props)
|
|
|
|
(let ((type (if (plist-get props :width) type)))
|
|
|
|
(apply old-create-image file-or-data type data-p props)))))
|
|
|
|
(apply orig-fn args))))
|
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
|
|
|
|
#'+org-indent-maybe-h
|
|
|
|
#'+org-yas-expand-maybe-h)
|
|
|
|
|
|
|
|
(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
|
2019-06-28 16:53:26 +02:00
|
|
|
[C-return] #'+org/insert-item-below
|
|
|
|
[C-S-return] #'+org/insert-item-above
|
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
|
2019-05-12 01:46:29 -04:00
|
|
|
"'" #'org-edit-special
|
2019-04-05 04:12:56 -04:00
|
|
|
"," #'org-switchb
|
2019-04-05 04:33:26 -04:00
|
|
|
"." #'org-goto
|
|
|
|
(:when (featurep! :completion ivy)
|
|
|
|
"." #'counsel-org-goto
|
|
|
|
"/" #'counsel-org-goto-all)
|
|
|
|
(:when (featurep! :completion helm)
|
|
|
|
"." #'helm-org-in-buffer-headings
|
|
|
|
"/" #'helm-org-agenda-files-headings)
|
2019-04-04 18:47:40 -04:00
|
|
|
"d" #'org-deadline
|
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-04-04 18:47:40 -04:00
|
|
|
"l" #'org-insert-link
|
2019-10-25 20:00:06 -04:00
|
|
|
"L" #'+org/remove-link
|
|
|
|
"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-04-05 04:12:56 -04:00
|
|
|
"s" #'org-schedule
|
2019-05-12 01:46:29 -04:00
|
|
|
"t" #'org-todo
|
|
|
|
"T" #'org-todo-list
|
2019-10-28 02:02:18 -04:00
|
|
|
(:prefix ("r" . "refile")
|
|
|
|
"." #'+org/refile-to-current-file
|
|
|
|
"c" #'+org/refile-to-running-clock
|
|
|
|
"l" #'+org/refile-to-last-location
|
|
|
|
"o" #'+org/refile-to-other-window
|
|
|
|
"O" #'+org/refile-to-other-buffers
|
|
|
|
"r" #'org-refile) ; to all `org-refile-targets'
|
2019-10-25 20:00:06 -04:00
|
|
|
(:prefix ("a" . "attachments")
|
|
|
|
"a" #'org-attach/file
|
|
|
|
"u" #'org-attach/uri
|
|
|
|
"f" #'org-attach/find-file
|
|
|
|
"s" #'org-attach/sync)
|
2019-04-04 18:47:40 -04:00
|
|
|
(:prefix ("c" . "clock")
|
|
|
|
"c" #'org-clock-in
|
|
|
|
"C" #'org-clock-out
|
2019-04-05 04:12:56 -04:00
|
|
|
"d" #'org-clock-mark-default-task
|
|
|
|
"e" #'org-clock-modify-effort-estimate
|
|
|
|
"l" #'org-clock-in-last
|
2019-04-04 18:47:40 -04:00
|
|
|
"g" #'org-clock-goto
|
|
|
|
"G" (λ! (org-clock-goto 'select))
|
2019-04-05 04:12:56 -04:00
|
|
|
"x" #'org-clock-cancel
|
|
|
|
"=" #'org-clock-timestamps-up
|
|
|
|
"-" #'org-clock-timestamps-down)
|
|
|
|
(:prefix ("g" . "goto")
|
|
|
|
"g" #'org-goto
|
|
|
|
(:when (featurep! :completion ivy)
|
|
|
|
"g" #'counsel-org-goto
|
|
|
|
"G" #'counsel-org-goto-all)
|
|
|
|
"a" #'org-agenda-goto
|
|
|
|
"A" #'org-agenda-clock-goto
|
|
|
|
"c" #'org-clock-goto
|
|
|
|
"C" (λ! (org-clock-goto 'select))
|
|
|
|
"i" #'org-id-goto
|
|
|
|
"r" #'org-refile-goto-last-stored
|
|
|
|
"x" #'org-capture-goto-last-stored)
|
|
|
|
(:prefix ("b" . "tables")
|
2019-10-22 18:51:47 -04:00
|
|
|
"-" #'org-table-insert-hline
|
2019-04-04 18:47:40 -04:00
|
|
|
"a" #'org-table-align
|
2019-10-22 18:51:47 -04:00
|
|
|
"c" #'org-table-create-or-convert-from-region
|
2019-04-04 18:47:40 -04:00
|
|
|
"e" #'org-table-edit-field
|
|
|
|
"h" #'org-table-field-info
|
2019-06-28 16:53:26 +02:00
|
|
|
(:when (featurep! +gnuplot)
|
2019-10-22 18:51:47 -04:00
|
|
|
"p" #'org-plot/gnuplot)))
|
2019-05-10 08:16:09 +02:00
|
|
|
|
2019-10-23 17:36:30 -04:00
|
|
|
(map! :after org-agenda
|
|
|
|
:map org-agenda-mode-map
|
2019-10-07 12:52:10 -04:00
|
|
|
;; Always clean up after itself
|
|
|
|
[remap org-agenda-quit] #'org-agenda-exit
|
|
|
|
[remap org-agenda-Quit] #'org-agenda-exit
|
2019-05-10 08:16:09 +02:00
|
|
|
:localleader
|
|
|
|
"d" #'org-agenda-deadline
|
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
|
|
|
|
"s" #'org-agenda-schedule
|
|
|
|
"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)
|
|
|
|
("^\\*\\(?:Agenda Com\\|Calendar\\|Org \\(?:Export Dispatcher\\|Select\\)\\)"
|
|
|
|
:slot -1 :vslot -1 :size #'+popup-shrink-to-fit :ttl 0)
|
2019-09-10 14:54:13 -04:00
|
|
|
("^\\*Org Agenda" :ignore t)
|
|
|
|
("^\\*Org Src" :size 0.4 :quit nil :select t :autosave t :modeline t :ttl nil)
|
2019-06-28 16:53:26 +02:00
|
|
|
("^CAPTURE.*\\.org$" :size 0.2 :quit nil :select t :autosave t))))
|
|
|
|
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-07-21 02:38:42 +02:00
|
|
|
(defun +org-init-smartparens-h ()
|
2019-06-28 16:53:26 +02:00
|
|
|
"TODO"
|
|
|
|
(after! smartparens
|
|
|
|
(defun +org-sp-point-in-checkbox-p (_id action _context)
|
|
|
|
(and (eq action 'insert)
|
|
|
|
(sp--looking-at-p "\\s-*]")))
|
2018-07-09 15:33:31 +02:00
|
|
|
|
2019-06-28 16:53:26 +02:00
|
|
|
(defun +org-sp-point-at-bol-p (_id action _context)
|
|
|
|
(and (eq action 'insert)
|
2019-08-07 17:03:16 -04:00
|
|
|
(save-excursion
|
|
|
|
(skip-chars-backward "*")
|
|
|
|
(bolp))))
|
2018-05-11 20:16:19 +02:00
|
|
|
|
2019-08-29 15:43:53 +02:00
|
|
|
(defun +org-sp-in-src-block-p (_id action _context)
|
|
|
|
(and (eq action 'insert)
|
|
|
|
(org-in-src-block-p)))
|
|
|
|
|
2019-06-28 16:53:26 +02:00
|
|
|
;; make delimiter auto-closing a little more conservative
|
|
|
|
(sp-with-modes 'org-mode
|
2019-08-29 15:43:53 +02:00
|
|
|
(sp-local-pair "*" "*" :unless '(:add sp-point-before-word-p sp-in-math-p +org-sp-point-at-bol-p +org-sp-in-src-block-p))
|
|
|
|
(sp-local-pair "_" "_" :unless '(:add sp-point-before-word-p sp-in-math-p +org-sp-in-src-block-p))
|
|
|
|
(sp-local-pair "/" "/" :unless '(:add sp-point-before-word-p sp-in-math-p +org-sp-point-in-checkbox-p +org-sp-in-src-block-p))
|
|
|
|
(sp-local-pair "~" "~" :unless '(:add sp-point-before-word-p +org-sp-in-src-block-p))
|
|
|
|
(sp-local-pair "=" "=" :unless '(:add sp-point-before-word-p sp-in-math-p +org-sp-in-src-block-p)))))
|
2018-05-14 20:49:43 +02:00
|
|
|
|
2018-05-18 01:43:37 +02:00
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
;;
|
|
|
|
;;; Packages
|
|
|
|
|
|
|
|
(use-package! toc-org ; auto-table of contents
|
|
|
|
:hook (org-mode . toc-org-enable)
|
|
|
|
:config (setq toc-org-hrefify-default "gh"))
|
|
|
|
|
|
|
|
|
|
|
|
(use-package! org-bullets ; "prettier" bullets
|
|
|
|
:hook (org-mode . org-bullets-mode))
|
|
|
|
|
|
|
|
|
|
|
|
(use-package! org-fancy-priorities ; priority icons
|
|
|
|
:hook (org-mode . org-fancy-priorities-mode)
|
|
|
|
:config (setq org-fancy-priorities-list '("■" "■" "■")))
|
|
|
|
|
|
|
|
|
|
|
|
(use-package! org-crypt ; built-in
|
|
|
|
:commands org-encrypt-entries
|
|
|
|
:hook (org-reveal-start . org-decrypt-entry)
|
|
|
|
:config
|
|
|
|
(add-hook! 'org-mode-hook
|
|
|
|
(add-hook 'before-save-hook 'org-encrypt-entries nil t))
|
|
|
|
(add-to-list 'org-tags-exclude-from-inheritance "crypt")
|
|
|
|
(setq org-crypt-key user-mail-address))
|
|
|
|
|
|
|
|
|
|
|
|
(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
|
|
|
|
(setq org-clock-persist t
|
|
|
|
;; Resume when clocking into task with open clock
|
|
|
|
org-clock-in-resume t)
|
|
|
|
(add-hook 'kill-emacs-hook #'org-clock-save))
|
|
|
|
|
|
|
|
|
|
|
|
(use-package! org-pdfview
|
|
|
|
:when (featurep! :tools pdf)
|
|
|
|
:commands org-pdfview-open
|
|
|
|
:init
|
|
|
|
(after! org
|
|
|
|
(delete '("\\.pdf\\'" . default) org-file-apps)
|
|
|
|
;; org links to pdf files are opened in pdf-view-mode
|
|
|
|
(add-to-list 'org-file-apps '("\\.pdf\\'" . (lambda (_file link) (org-pdfview-open link))))
|
|
|
|
;; support for links to specific pages
|
|
|
|
(add-to-list 'org-file-apps '("\\.pdf::\\([[:digit:]]+\\)\\'" . (lambda (_file link) (org-pdfview-open link))))))
|
|
|
|
|
|
|
|
|
|
|
|
(use-package! evil-org
|
|
|
|
:when (featurep! :editor evil +everywhere)
|
|
|
|
:hook (org-mode . evil-org-mode)
|
|
|
|
: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
|
|
|
|
(evil-org-set-key-theme)
|
|
|
|
;; Only fold the current tree, rather than recursively
|
|
|
|
(add-hook 'org-tab-first-hook #'+org-cycle-only-current-subtree-h 'append)
|
|
|
|
(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 "C-l" (general-predicate-dispatch 'org-end-of-line
|
|
|
|
(org-at-table-p) 'org-table-next-field)
|
|
|
|
:i "C-h" (general-predicate-dispatch 'org-beginning-of-line
|
|
|
|
(org-at-table-p) 'org-table-previous-field)
|
|
|
|
:i "C-k" (general-predicate-dispatch 'org-up-element
|
|
|
|
(org-at-table-p) '+org/table-previous-row)
|
|
|
|
:i "C-j" (general-predicate-dispatch 'org-down-element
|
|
|
|
(org-at-table-p) 'org-table-next-row)
|
|
|
|
;; moving/(de|pro)moting subtress & expanding tables (prepend/append columns/rows)
|
|
|
|
:ni "C-S-l" #'org-shiftright
|
|
|
|
:ni "C-S-h" #'org-shiftleft
|
|
|
|
:ni "C-S-k" #'org-shiftup
|
|
|
|
:ni "C-S-j" #'org-shiftdown
|
|
|
|
;; more intuitive RET keybinds
|
|
|
|
:i [return] #'org-return-indent
|
|
|
|
:i "RET" #'org-return-indent
|
|
|
|
:n [return] #'+org/dwim-at-point
|
|
|
|
:n "RET" #'+org/dwim-at-point
|
|
|
|
;; 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
|
|
|
|
:n "gr" #'org-ctrl-c-ctrl-c
|
|
|
|
:n "gR" #'org-babel-execute-buffer
|
|
|
|
;; 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 "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" #'outline-show-all
|
|
|
|
:n "zi" #'org-toggle-inline-images
|
|
|
|
|
|
|
|
:map org-read-date-minibuffer-local-map
|
|
|
|
"C-h" (λ! (org-eval-in-calendar '(calendar-backward-day 1)))
|
|
|
|
"C-l" (λ! (org-eval-in-calendar '(calendar-forward-day 1)))
|
|
|
|
"C-k" (λ! (org-eval-in-calendar '(calendar-backward-week 1)))
|
|
|
|
"C-j" (λ! (org-eval-in-calendar '(calendar-forward-week 1)))
|
|
|
|
"C-S-h" (λ! (org-eval-in-calendar '(calendar-backward-month 1)))
|
|
|
|
"C-S-l" (λ! (org-eval-in-calendar '(calendar-forward-month 1)))
|
|
|
|
"C-S-k" (λ! (org-eval-in-calendar '(calendar-backward-year 1)))
|
|
|
|
"C-S-j" (λ! (org-eval-in-calendar '(calendar-forward-year 1)))))
|
|
|
|
|
|
|
|
|
|
|
|
(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
|
|
|
|
;; Change org defaults (should be set before org loads)
|
|
|
|
(defvar org-directory "~/org/")
|
2019-09-20 23:10:53 -04:00
|
|
|
(defvar org-attach-id-dir ".attach/")
|
2019-08-28 12:06:49 -04:00
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
(setq org-publish-timestamp-directory (concat doom-cache-dir "org-timestamps/")
|
2019-08-28 12:06:49 -04:00
|
|
|
org-preview-latex-image-directory (concat doom-cache-dir "org-latex/"))
|
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
|
|
|
))
|
|
|
|
|
2019-10-29 00:50:35 -04:00
|
|
|
(add-hook 'org-mode-local-vars-hook #'eldoc-mode)
|
|
|
|
|
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
|
|
|
|
#'+org-unfold-to-2nd-level-or-point-h)
|
2019-04-10 18:47:21 -04:00
|
|
|
|
2019-06-28 16:53:26 +02:00
|
|
|
(add-hook! 'org-load-hook
|
2019-07-26 19:57:13 +02:00
|
|
|
#'+org-init-appearance-h
|
|
|
|
#'+org-init-agenda-h
|
|
|
|
#'+org-init-babel-h
|
|
|
|
#'+org-init-babel-lazy-loader-h
|
|
|
|
#'+org-init-capture-defaults-h
|
|
|
|
#'+org-init-capture-frame-h
|
|
|
|
#'+org-init-centralized-attachments-h
|
|
|
|
#'+org-init-centralized-exports-h
|
|
|
|
#'+org-init-custom-links-h
|
|
|
|
#'+org-init-export-h
|
|
|
|
#'+org-init-habit-h
|
|
|
|
#'+org-init-hacks-h
|
|
|
|
#'+org-init-keybinds-h
|
|
|
|
#'+org-init-popup-rules-h
|
|
|
|
#'+org-init-protocol-h
|
|
|
|
#'+org-init-protocol-lazy-loader-h
|
|
|
|
#'+org-init-smartparens-h)
|
2019-06-28 16:53:26 +02:00
|
|
|
|
2019-10-25 20:00:06 -04:00
|
|
|
;;; Custom org modules
|
|
|
|
(if (featurep! +dragndrop) (load! "contrib/dragndrop"))
|
|
|
|
(if (featurep! +ipython) (load! "contrib/ipython"))
|
|
|
|
(if (featurep! +pomodoro) (load! "contrib/pomodoro"))
|
|
|
|
(if (featurep! +present) (load! "contrib/present"))
|
|
|
|
|
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 doom-reloading-p)
|
|
|
|
(not byte-compile-current-file))
|
2019-06-28 16:53:26 +02:00
|
|
|
(message "`org' was already loaded by the time lang/org loaded, this may cause issues")
|
|
|
|
(run-hooks 'org-load-hook))
|
2019-04-10 18:47:21 -04:00
|
|
|
|
2019-07-08 22:07:52 +02:00
|
|
|
:config
|
2019-10-25 20:00:06 -04:00
|
|
|
(add-hook 'org-open-at-point-functions #'doom-set-jump-h))
|