Move lang/org => org/*
Since lang/org has grown (and is expected to grow much, much more), it has been given its own module category. Concerns #129, #138
This commit is contained in:
parent
576a91b66c
commit
d2d4166b42
31 changed files with 774 additions and 721 deletions
33
modules/org/org-attach/autoload/evil.el
Normal file
33
modules/org/org-attach/autoload/evil.el
Normal file
|
@ -0,0 +1,33 @@
|
|||
;;; org/org-attach/autoload/evil.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload (autoload '+org-attach:dwim "org/org-attach/autoload/evil" nil t)
|
||||
(evil-define-command +org-attach:dwim (&optional uri)
|
||||
"An evil ex interface to `+org-attach/dwim'."
|
||||
(interactive "<a>")
|
||||
(unless (eq major-mode 'org-mode)
|
||||
(user-error "Not in an org-mode buffer"))
|
||||
(if uri
|
||||
(let* ((rel-path (org-download--fullname uri))
|
||||
(new-path (expand-file-name rel-path))
|
||||
(image-p (image-type-from-file-name uri)))
|
||||
(cond ((string-match-p (concat "^" (regexp-opt '("http" "https" "nfs" "ftp" "file")) ":/") uri)
|
||||
(url-copy-file uri new-path))
|
||||
(t (copy-file uri new-path)))
|
||||
(unless new-path
|
||||
(user-error "No file was provided"))
|
||||
(if (evil-visual-state-p)
|
||||
(org-insert-link nil (format "./%s" rel-path)
|
||||
(concat (buffer-substring-no-properties (region-beginning) (region-end))
|
||||
" " (org-attach--icon rel-path)))
|
||||
|
||||
(insert (if image-p
|
||||
(format "[[./%s]] " rel-path)
|
||||
(format "%s [[./%s][%s]] "
|
||||
(org-attach--icon rel-path)
|
||||
rel-path (file-name-nondirectory (directory-file-name rel-path))))))
|
||||
(when (string-match-p (regexp-opt '("jpg" "jpeg" "gif" "png")) (file-name-extension rel-path))
|
||||
(org-redisplay-inline-images)))
|
||||
(let ((default-directory ".attach/"))
|
||||
(if (file-exists-p default-directory)
|
||||
(call-interactively 'find-file)
|
||||
(user-error "No attachments")))))
|
55
modules/org/org-attach/autoload/org-attach.el
Normal file
55
modules/org/org-attach/autoload/org-attach.el
Normal file
|
@ -0,0 +1,55 @@
|
|||
;;; org/org-attach/autoload/org-attach.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defun +org-attach--icon (path)
|
||||
(char-to-string
|
||||
(pcase (downcase (file-name-extension path))
|
||||
((or "jpg" "jpeg" "png" "gif") ?)
|
||||
("pdf" ?)
|
||||
((or "ppt" "pptx") ?)
|
||||
((or "xls" "xlsx") ?)
|
||||
((or "doc" "docx") ?)
|
||||
((or "ogg" "mp3" "wav" "aiff" "flac") ?)
|
||||
((or "mp4" "mov" "avi") ?)
|
||||
((or "zip" "gz" "tar" "7z" "rar") ?)
|
||||
(_ ?))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-attach-cleanup ()
|
||||
;; "Deletes any attachments that are no longer present in the org-mode buffer."
|
||||
(let* ((attachments-local (+org-attachments))
|
||||
(attachments (directory-files org-attach-directory t "^[^.]" t))
|
||||
(to-delete (cl-set-difference attachments-local attachments)))
|
||||
;; TODO
|
||||
to-delete))
|
||||
|
||||
(defun +org-attachments ()
|
||||
"List all attachments in the current buffer."
|
||||
(unless (eq major-mode 'org-mode)
|
||||
(user-error "Not an org buffer"))
|
||||
(org-save-outline-visibility nil
|
||||
(let ((attachments '())
|
||||
element)
|
||||
(when (and (file-directory-p org-attach-directory)
|
||||
(> (length (file-expand-wildcards (expand-file-name "*" org-attach-directory))) 0))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (progn (org-next-link) (not org-link-search-failed))
|
||||
(setq element (org-element-context))
|
||||
(when-let (file (and (eq (org-element-type element) 'link)
|
||||
(expand-file-name (org-element-property :path element))))
|
||||
(when (and (string= (org-element-property :type element) "file")
|
||||
(string= (concat (file-name-base (directory-file-name (file-name-directory file))) "/")
|
||||
org-attach-directory)
|
||||
(file-exists-p file))
|
||||
(push file attachments))))))
|
||||
(cl-remove-duplicates attachments))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-attach-download-dnd (uri action)
|
||||
(if (eq major-mode 'org-mode)
|
||||
(doom:org-attach uri) ;; FIXME
|
||||
(let ((dnd-protocol-alist
|
||||
(rassq-delete-all '+org-attach-download-dnd
|
||||
(copy-alist dnd-protocol-alist))))
|
||||
(dnd-handle-one-url nil action uri))))
|
||||
|
49
modules/org/org-attach/config.el
Normal file
49
modules/org/org-attach/config.el
Normal file
|
@ -0,0 +1,49 @@
|
|||
;;; org/org-attach/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +org-attach-dir (expand-file-name ".attach/" +org-dir)
|
||||
"Where to store attachments (relative to current org file).")
|
||||
|
||||
|
||||
(add-hook '+org-init-hook #'+org|init-attach t)
|
||||
|
||||
;; FIXME This module is broken and needs to be rewritten.
|
||||
;;
|
||||
;; I believe Org's native attachment system is over-complicated and litters
|
||||
;; files with metadata I don't want.
|
||||
;;
|
||||
;; This installs my own attachment system. It:
|
||||
;;
|
||||
;; + Centralizes attachment in a global location,
|
||||
;; + Adds drag-and-drop file support
|
||||
;; + TODO ...with attachment icons, and
|
||||
;; + TODO Offers an attachment management system.
|
||||
|
||||
(def-package! org-download
|
||||
:config
|
||||
(setq-default org-download-image-dir +org-attach-dir
|
||||
org-download-heading-lvl nil
|
||||
org-download-timestamp "_%Y%m%d_%H%M%S")
|
||||
(setq org-download-screenshot-method
|
||||
(cond (IS-MAC "screencapture -i %s")
|
||||
(IS-LINUX "maim --opengl -s %s")))
|
||||
|
||||
;; Write download paths relative to current file
|
||||
(defun +org-attach*download-fullname (path)
|
||||
(file-relative-name path (file-name-directory (buffer-file-name))))
|
||||
(advice-add #'org-download--dir-2 :override #'ignore)
|
||||
(advice-add #'org-download--fullname
|
||||
:filter-return #'+org-attach*download-fullname))
|
||||
|
||||
;;
|
||||
(defun +org-attach|init ()
|
||||
(setq org-attach-directory +org-attach-directory)
|
||||
|
||||
(push ".attach" projectile-globally-ignored-file-suffixes)
|
||||
(after! recentf
|
||||
(push (format "/%s.+$" (regexp-quote +org-attach-dir))
|
||||
recentf-exclude))
|
||||
|
||||
(require 'org-download)
|
||||
|
||||
;; Add another drag-and-drop handler that will handle anything but image files
|
||||
(push '("^\\(https?\\|ftp\\|file\\|nfs\\):\\(//\\)?" . +org-attach-download-dnd) dnd-protocol-alist))
|
4
modules/org/org-attach/packages.el
Normal file
4
modules/org/org-attach/packages.el
Normal file
|
@ -0,0 +1,4 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; org/org-attach/packages.el
|
||||
|
||||
(package! org-download)
|
12
modules/org/org-babel/autoload.el
Normal file
12
modules/org/org-babel/autoload.el
Normal file
|
@ -0,0 +1,12 @@
|
|||
;;; org/org-babel/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-babel/edit (arg)
|
||||
"Edit the source block at point in a popup.
|
||||
|
||||
If ARG is non-nil (universal argument), use the current window."
|
||||
(interactive "P")
|
||||
(if arg
|
||||
(call-interactively #'org-edit-special)
|
||||
(with-popup-rules! (("^\\*Org Src" :regexp t :select t :noesc t :same t))
|
||||
(call-interactively #'org-edit-special))))
|
52
modules/org/org-babel/config.el
Normal file
52
modules/org/org-babel/config.el
Normal file
|
@ -0,0 +1,52 @@
|
|||
;;; org/org-babel/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(add-hook 'org-load-hook #'+org-babel|init t)
|
||||
|
||||
(defun +org-babel|init ()
|
||||
(setq org-src-fontify-natively t ; make code pretty
|
||||
org-src-preserve-indentation t ; use native major-mode indentation
|
||||
org-src-tab-acts-natively t
|
||||
org-src-window-setup 'current-window
|
||||
org-confirm-babel-evaluate nil) ; you don't need my permission
|
||||
|
||||
(org-babel-do-load-languages
|
||||
'org-babel-load-languages
|
||||
(mapcar (lambda (sym) (cons sym t))
|
||||
'(calc
|
||||
css
|
||||
emacs-lisp
|
||||
haskell
|
||||
js
|
||||
latex
|
||||
ledger
|
||||
lilypond
|
||||
lisp
|
||||
matlab
|
||||
plantuml
|
||||
python
|
||||
restclient ; ob-restclient
|
||||
ruby
|
||||
rust ; ob-rust
|
||||
sh
|
||||
sqlite
|
||||
sql-mode ; ob-sql-mode
|
||||
translate ; ob-translate
|
||||
)))
|
||||
|
||||
;; In a recent update, `org-babel-get-header' was removed from org-mode, which
|
||||
;; is something a fair number of babel plugins use. So until those plugins
|
||||
;; update, this polyfill will do:
|
||||
(defun org-babel-get-header (params key &optional others)
|
||||
(cl-loop with fn = (if others #'not #'identity)
|
||||
for p in params
|
||||
if (funcall fn (eq (car p) key))
|
||||
collect p))
|
||||
|
||||
;; I prefer C-c C-c for confirming over the default C-c '
|
||||
(map! :map org-src-mode-map "C-c C-c" #'org-edit-src-exit)
|
||||
|
||||
(defun +org|src-mode-remove-header ()
|
||||
"Remove header-line with keybinding help; I know the keybinds."
|
||||
(when header-line-format
|
||||
(setq header-line-format nil)))
|
||||
(add-hook 'org-src-mode-hook #'+org|src-mode-remove-header))
|
10
modules/org/org-babel/packages.el
Normal file
10
modules/org/org-babel/packages.el
Normal file
|
@ -0,0 +1,10 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; org/org-babel/packages.el
|
||||
|
||||
(package! ob-go)
|
||||
(package! ob-mongo)
|
||||
(package! ob-redis)
|
||||
(package! ob-restclient)
|
||||
(package! ob-rust :recipe (:fetcher github :repo "zweifisch/ob-rust"))
|
||||
(package! ob-sql-mode)
|
||||
(package! ob-translate)
|
10
modules/org/org-capture/autoload/evil.el
Normal file
10
modules/org/org-capture/autoload/evil.el
Normal file
|
@ -0,0 +1,10 @@
|
|||
;;; org/org-capture/autoload/evil.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload (autoload '+org-capture:dwim "org/org-capture/autoload/evil" nil t)
|
||||
(evil-define-operator +org-capture:dwim (&optional beg end)
|
||||
"Evil ex interface to `+org-capture/dwim'."
|
||||
:move-point nil :type inclusive
|
||||
(interactive "<r>")
|
||||
(+org-capture/dwim
|
||||
(unless (or (evil-normal-state-p) (evil-insert-state-p))
|
||||
(buffer-substring beg end))))
|
17
modules/org/org-capture/autoload/org-capture.el
Normal file
17
modules/org/org-capture/autoload/org-capture.el
Normal file
|
@ -0,0 +1,17 @@
|
|||
;;; org/org-capture/autoload/org-capture.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-capture/dwim (&optional string key)
|
||||
"Sends STRING, the current selection or prompted input to `org-capture'.
|
||||
|
||||
Uses the capture template specified by KEY. Otherwise, prompts you for one."
|
||||
(interactive)
|
||||
(let ((key (or key "n")))
|
||||
(if-let (string (cond ((not (equal string ""))
|
||||
string)
|
||||
((region-active-p)
|
||||
(buffer-substring-no-properties
|
||||
(region-beginning)
|
||||
(region-end)))))
|
||||
(org-capture-string string key)
|
||||
(org-capture nil key))))
|
61
modules/org/org-capture/config.el
Normal file
61
modules/org/org-capture/config.el
Normal file
|
@ -0,0 +1,61 @@
|
|||
;;; org/org-capture/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(add-hook 'org-load-hook #'+org-capture|init t)
|
||||
|
||||
;; Sets up two `org-capture' workflows that I like:
|
||||
;;
|
||||
;; 1. The traditional way: invoking `org-capture' directly (or through a
|
||||
;; command, like :org).
|
||||
;;
|
||||
;; 2. Through a org-capture popup frame that is invoked from outside Emacs (the
|
||||
;; script is in ~/.emacs.d/bin). This lets me open an org-capture box
|
||||
;; anywhere I can call org-capture (whether or not Emacs is open/running),
|
||||
;; like, say, from qutebrowser, vimperator, dmenu or a global keybinding.
|
||||
|
||||
(defun +org-capture|init ()
|
||||
"Set up a sane `org-capture' workflow."
|
||||
(setq org-default-notes-file (concat +org-dir "notes.org")
|
||||
;; FIXME This is incomplete!
|
||||
org-capture-templates
|
||||
'(;; TODO: New Task (todo)
|
||||
;; TODO: New vocabulary word
|
||||
|
||||
("c" "Changelog" entry
|
||||
(file+headline (expand-file-name "CHANGELOG.org" (doom/project-root)) "Unreleased")
|
||||
"* %?")
|
||||
|
||||
;; ("p" "Project Notes" entry
|
||||
;; (file+headline org-default-notes-file "Inbox")
|
||||
;; "* %u %?\n%i" :prepend t)
|
||||
|
||||
;; ("m" "Major-mode Notes" entry
|
||||
;; (file+headline org-default-notes-file "Inbox")
|
||||
;; "* %u %?\n%i" :prepend t)
|
||||
|
||||
("n" "Notes" entry
|
||||
(file+headline (concat +org-dir "notes.org") "Inbox")
|
||||
"* %u %?\n%i" :prepend t)
|
||||
|
||||
;; ("v" "Vocab" entry
|
||||
;; (file+headline (concat org-directory "topics/vocab.org") "Unsorted")
|
||||
;; "** %i%?\n")
|
||||
))
|
||||
|
||||
;; Allows the Emacs mini-frame (opened from an external shell script to run
|
||||
;; and clean up properly) if the frame is named "org-capture".
|
||||
(require 'org-capture)
|
||||
(require 'org-protocol)
|
||||
(defun +org-capture*init (&rest _)
|
||||
"Makes sure the org-capture window is the only window in the frame."
|
||||
(when (equal "org-capture" (frame-parameter nil 'name))
|
||||
(setq mode-line-format nil)
|
||||
(delete-other-windows)))
|
||||
(advice-add #'org-capture :after #'+org-capture*init)
|
||||
|
||||
(defun +org-capture|finalize ()
|
||||
"Closes the frame once org-capture is done."
|
||||
(when (equal "org-capture" (frame-parameter nil 'name))
|
||||
(when (and (featurep 'persp-mode) persp-mode)
|
||||
(+workspace/delete (+workspace-current-name)))
|
||||
(delete-frame)))
|
||||
(add-hook 'org-capture-after-finalize-hook #'+org-capture|finalize))
|
35
modules/org/org-export/config.el
Normal file
35
modules/org/org-export/config.el
Normal file
|
@ -0,0 +1,35 @@
|
|||
;;; org/org-export/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(add-hook 'org-load-hook #'+org-export|init t)
|
||||
|
||||
;; I don't have any beef with org's built-in export system, but I do wish it
|
||||
;; would export to a central directory, rather than `default-directory'. This is
|
||||
;; because all my org files are usually in one place, and I want to be able to
|
||||
;; refer back to old exports if needed.
|
||||
|
||||
(def-package! ox-pandoc
|
||||
:config
|
||||
(unless (executable-find "pandoc")
|
||||
(warn "org-export: couldn't find pandoc, disabling pandoc export"))
|
||||
(setq org-pandoc-options
|
||||
'((standalone . t)
|
||||
(mathjax . t)
|
||||
(parse-raw . t))))
|
||||
|
||||
;;
|
||||
(defun +org-export|init ()
|
||||
(setq org-export-directory (expand-file-name ".export" +org-dir)
|
||||
org-export-backends '(ascii html latex md)
|
||||
org-export-with-toc t
|
||||
org-export-with-author t)
|
||||
|
||||
;; Always export to a central location
|
||||
(unless (file-directory-p org-export-directory)
|
||||
(make-directory org-export-directory t))
|
||||
(defun +org*export-output-file-name (args)
|
||||
"Return a centralized export location."
|
||||
(unless (nth 2 args)
|
||||
(setq args (append args (list org-export-directory))))
|
||||
args)
|
||||
(advice-add #'org-export-output-file-name
|
||||
:filter-args #'+org*export-output-file-name))
|
4
modules/org/org-export/packages.el
Normal file
4
modules/org/org-export/packages.el
Normal file
|
@ -0,0 +1,4 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; org/org-export/packages.el
|
||||
|
||||
(package! ox-pandoc)
|
36
modules/org/org-notebook/autoload.el
Normal file
36
modules/org/org-notebook/autoload.el
Normal file
|
@ -0,0 +1,36 @@
|
|||
;;; org/org-notebook/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defun +org-notebook--explore-notes (dir)
|
||||
(unless (file-directory-p dir)
|
||||
(error "Directory doesn't exist: %s" dir))
|
||||
(if (fboundp '+evil/neotree)
|
||||
(neotree-dir dir)
|
||||
(let ((default-directory dir))
|
||||
(call-interactively (command-remapping 'find-file)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-notebook/find-major-mode-notes ()
|
||||
"Browse org notes in `+org-notebook-code-dir' in neotree, ido, ivy or helm --
|
||||
whichever is available."
|
||||
(interactive)
|
||||
(let ((dir (expand-file-name
|
||||
(concat (or (cdr (assq major-mode +org-notebook-code-alist))
|
||||
(replace-regexp-in-string
|
||||
"+" "p"
|
||||
(string-remove-suffix "-mode" (symbol-name major-mode))
|
||||
nil t))
|
||||
"/")
|
||||
+org-notebook-code-dir)))
|
||||
(unless (file-in-directory-p dir +org-notebook-code-dir)
|
||||
(error "Invalid location for %s notes: %s"
|
||||
major-mode (abbreviate-file-name dir)))
|
||||
(unless (file-directory-p dir)
|
||||
(make-directory dir t))
|
||||
(+org-notebook--explore-notes dir)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-notebook/find-project-notes ()
|
||||
"Browse org notes in `+org-notebook-project-dir' in neotree, ido, ivy or helm --
|
||||
whichever is available."
|
||||
(interactive)
|
||||
(+org-notebook--explore-notes +org-notebook-project-dir))
|
27
modules/org/org-notebook/config.el
Normal file
27
modules/org/org-notebook/config.el
Normal file
|
@ -0,0 +1,27 @@
|
|||
;;; org/org-notebook/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; (add-hook 'org-load-hook '+org|init-notebook t)
|
||||
|
||||
;; While I program, write or plan, I want easy access to notes of various kinds,
|
||||
;; such as major-mode/language specific notes, or project-specific notes. They
|
||||
;; can be accessed via `+org-notebook/find-major-mode-notes' and
|
||||
;; `+org-notebook/find-project-notes'.
|
||||
|
||||
(defvar +org-notebook-dir (concat +org-dir "notes/")
|
||||
"The directory where the notes are kept.")
|
||||
|
||||
(defvar +org-notebook-code-dir (concat +org-notebook-dir "code/")
|
||||
"The directory where programming notes and snippets are kept.")
|
||||
|
||||
(defvar +org-notebook-project-dir (concat +org-notebook-dir "projects/")
|
||||
"The directory where project notes are kept.")
|
||||
|
||||
|
||||
(defvar +org-notebook-code-alist
|
||||
'((js2-mode . "javascript"))
|
||||
"An alist mapping certain modes (symbols) to their org notes directory name.
|
||||
If a mode isn't here, it's guessed by stripping out the -mode suffix and
|
||||
replacing '+' characters with 'p's.")
|
||||
|
||||
|
||||
;; (defun +org|init-notebook ())
|
88
modules/org/org-present/autoload.el
Normal file
88
modules/org/org-present/autoload.el
Normal file
|
@ -0,0 +1,88 @@
|
|||
;;; org/org-present/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +doom-present*org-tree-slide-narrow-exclude-header (orig-fn &rest args)
|
||||
"TODO"
|
||||
(cl-letf (((symbol-function 'org-narrow-to-subtree)
|
||||
(lambda () (save-excursion
|
||||
(save-match-data
|
||||
(org-with-limited-levels
|
||||
(narrow-to-region
|
||||
(progn (org-back-to-heading t)
|
||||
(forward-line 1)
|
||||
(point))
|
||||
(progn (org-end-of-subtree t t)
|
||||
(when (and (org-at-heading-p) (not (eobp))) (backward-char 1))
|
||||
(point)))))))))
|
||||
(apply orig-fn args)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-present|org-tree-prepare-window ()
|
||||
"TODO"
|
||||
(doom/window-zoom)
|
||||
(let ((arg (if org-tree-slide-mode +1 -1)))
|
||||
(when (fboundp 'centered-window-mode)
|
||||
(centered-window-mode arg))
|
||||
(window-divider-mode (* arg -1))
|
||||
(doom-hide-modeline-mode arg)
|
||||
(+org-pretty-mode arg)
|
||||
(cond (org-tree-slide-mode
|
||||
(org-indent-mode -1)
|
||||
(text-scale-set +org-present-text-scale)
|
||||
(ignore-errors (org-toggle-latex-fragment '(4)))
|
||||
(set-face-attribute 'org-level-2 nil :height 1.4))
|
||||
(t
|
||||
(org-indent-mode +1)
|
||||
(text-scale-set 0)
|
||||
(org-remove-latex-fragment-image-overlays)
|
||||
(set-face-attribute 'org-level-2 nil :height 1.0)
|
||||
(+org-present|remove-overlays)
|
||||
(org-remove-inline-images)))))
|
||||
|
||||
(defvar +org-present--overlays nil)
|
||||
;;;###autoload
|
||||
(defun +org-present/org-tree-slides ()
|
||||
(interactive)
|
||||
(unless (derived-mode-p 'org-mode)
|
||||
(error "Not in an org buffer"))
|
||||
(call-interactively 'org-tree-slide-mode)
|
||||
(add-hook 'kill-buffer-hook '+org-present--cleanup-org-tree-slides-mode))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-present|add-overlays ()
|
||||
(add-to-invisibility-spec '(+org-present))
|
||||
(save-excursion
|
||||
;; hide org-mode options starting with #+
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^[[:space:]]*\\(#\\+\\)\\(\\(?:BEGIN\\|END\\|ATTR\\)[^[:space:]]+\\).*" nil t)
|
||||
(+org-present--make-invisible
|
||||
(match-beginning 1)
|
||||
(match-end 0)))
|
||||
;; hide stars in headings
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^\\(\\*+\\s-\\)" nil t)
|
||||
(+org-present--make-invisible (match-beginning 1) (match-end 1)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-present|remove-overlays ()
|
||||
(mapc #'delete-overlay +org-present--overlays)
|
||||
(remove-from-invisibility-spec '(+org-present)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-present|detect-slide ()
|
||||
(outline-show-all)
|
||||
(if (member "title" (org-get-tags-at))
|
||||
(text-scale-set 10)
|
||||
(text-scale-set +org-present-text-scale)))
|
||||
|
||||
(defun +org-present--cleanup-org-tree-slides-mode ()
|
||||
(unless (cl-loop for buf in (doom-buffers-in-mode 'org-mode)
|
||||
if (buffer-local-value 'org-tree-slide-mode buf)
|
||||
return t)
|
||||
(org-tree-slide-mode -1)
|
||||
(remove-hook 'kill-buffer-hook #'+org-present--cleanup-org-tree-slides-mode)))
|
||||
|
||||
(defun +org-present--make-invisible (beg end)
|
||||
(let ((overlay (make-overlay beg end)))
|
||||
(push overlay +org-present--overlays)
|
||||
(overlay-put overlay 'invisible '+org-present)))
|
59
modules/org/org-present/config.el
Normal file
59
modules/org/org-present/config.el
Normal file
|
@ -0,0 +1,59 @@
|
|||
;;; org/org-present/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +org-present-text-scale 7
|
||||
"The `text-scale-amount' for `org-tree-slide-mode'.")
|
||||
|
||||
(add-hook 'org-load-hook #'+org-present|init t)
|
||||
|
||||
|
||||
;;
|
||||
;; Plugins
|
||||
;;
|
||||
|
||||
(def-package! ox-reveal
|
||||
:config
|
||||
(setq org-reveal-root "http://cdn.jsdelivr.net/reveal.js/3.0.0/"
|
||||
org-reveal-mathjax t))
|
||||
|
||||
|
||||
(def-package! org-tree-slide
|
||||
:commands org-tree-slide-mode
|
||||
:config
|
||||
(org-tree-slide-simple-profile)
|
||||
(setq org-tree-slide-skip-outline-level 2
|
||||
org-tree-slide-activate-message " "
|
||||
org-tree-slide-deactivate-message " "
|
||||
org-tree-slide-modeline-display nil)
|
||||
|
||||
(map! :map org-tree-slide-mode-map
|
||||
[right] #'org-tree-slide-move-next-tree
|
||||
[left] #'org-tree-slide-move-previous-tree)
|
||||
|
||||
(add-hook! 'org-tree-slide-mode-after-narrow-hook
|
||||
#'(+org-present|detect-slide +org-present|add-overlays org-display-inline-images))
|
||||
|
||||
(add-hook 'org-tree-slide-mode-hook #'+org-present|org-tree-prepare-window)
|
||||
(advice-add #'org-tree-slide--display-tree-with-narrow
|
||||
:around #'+doom-present*org-tree-slide-narrow-exclude-header))
|
||||
|
||||
|
||||
(def-package! centered-window-mode
|
||||
:commands centered-window-mode
|
||||
:config
|
||||
(setq cwm-use-vertical-padding t
|
||||
cwm-frame-internal-border 110
|
||||
cwm-left-fringe-ratio -10
|
||||
cwm-centered-window-width 240))
|
||||
|
||||
|
||||
;;
|
||||
;; Bootstrap
|
||||
;;
|
||||
|
||||
(defun +org-present|init ()
|
||||
(require 'ox-reveal)
|
||||
|
||||
(map! :map org-mode-map
|
||||
"<f8>" #'+org-present/org-tree-slides
|
||||
"<f7>" #'+org-present/next))
|
||||
|
6
modules/org/org-present/packages.el
Normal file
6
modules/org/org-present/packages.el
Normal file
|
@ -0,0 +1,6 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; org/org-present/packages.el
|
||||
|
||||
(package! centered-window-mode)
|
||||
(package! org-tree-slide)
|
||||
(package! ox-reveal)
|
248
modules/org/org/autoload/org.el
Normal file
248
modules/org/org/autoload/org.el
Normal file
|
@ -0,0 +1,248 @@
|
|||
;;; org/org/autoload/org.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode +org-pretty-mode
|
||||
"TODO"
|
||||
:init-value nil
|
||||
:lighter " *"
|
||||
:group 'evil-org
|
||||
(setq org-hide-emphasis-markers +org-pretty-mode)
|
||||
(org-toggle-pretty-entities)
|
||||
;; In case the above un-align tables
|
||||
(org-table-map-tables 'org-table-align t))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org|realign-table-maybe ()
|
||||
"Auto-align table under cursor."
|
||||
(when (org-at-table-p)
|
||||
(save-excursion
|
||||
(org-table-align))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org|update-cookies ()
|
||||
"Update counts in headlines (aka \"cookies\")."
|
||||
(when (and buffer-file-name (file-exists-p buffer-file-name))
|
||||
(org-update-statistics-cookies t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/dwim-at-point ()
|
||||
"Do-what-I-mean at point. This includes following timestamp links, aligning
|
||||
tables, toggling checkboxes/todos, executing babel blocks, previewing latex
|
||||
fragments, opening links, or refreshing images."
|
||||
(interactive)
|
||||
(let* ((scroll-pt (window-start))
|
||||
(context (org-element-context))
|
||||
(type (org-element-type context)))
|
||||
(cond
|
||||
((memq type '(planning timestamp))
|
||||
(org-follow-timestamp-link))
|
||||
|
||||
((memq type '(table table-row))
|
||||
(if (org-element-property :tblfm (org-element-property :parent context))
|
||||
(org-table-recalculate t)
|
||||
(org-table-align)))
|
||||
|
||||
((org-element-property :checkbox (org-element-lineage context '(item) t))
|
||||
(let ((match (and (org-at-item-checkbox-p) (match-string 1))))
|
||||
(org-toggle-checkbox (if (equal match "[ ]") '(16)))))
|
||||
|
||||
((and (eq type 'headline)
|
||||
(org-element-property :todo-type context))
|
||||
(org-todo
|
||||
(if (eq (org-element-property :todo-type context) 'done) 'todo 'done)))
|
||||
|
||||
((and (eq type 'headline)
|
||||
(string= "ARCHIVE" (car-safe (org-get-tags))))
|
||||
(org-force-cycle-archived))
|
||||
|
||||
((eq type 'headline)
|
||||
(org-remove-latex-fragment-image-overlays)
|
||||
(org-toggle-latex-fragment '(4)))
|
||||
|
||||
((eq type 'babel-call)
|
||||
(org-babel-lob-execute-maybe))
|
||||
|
||||
((memq type '(src-block inline-src-block))
|
||||
(org-babel-execute-src-block))
|
||||
|
||||
((memq type '(latex-fragment latex-environment))
|
||||
(org-toggle-latex-fragment))
|
||||
|
||||
((eq type 'link)
|
||||
(let ((path (org-element-property :path (org-element-lineage context '(link) t))))
|
||||
(if (and path (image-type-from-file-name path))
|
||||
(+org/refresh-inline-images)
|
||||
(org-open-at-point))))
|
||||
|
||||
(t (+org/refresh-inline-images)))
|
||||
(set-window-start nil scroll-pt)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/indent ()
|
||||
"Indent the current item (header or item). Otherwise, forward to
|
||||
`self-insert-command'."
|
||||
(interactive)
|
||||
(cond ((org-at-item-p)
|
||||
(org-indent-item-tree))
|
||||
((org-at-heading-p)
|
||||
(ignore-errors (org-demote)))
|
||||
((org-in-src-block-p t)
|
||||
(doom/dumb-indent))
|
||||
(t
|
||||
(call-interactively #'self-insert-command))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/indent-or-next-field-or-yas-expand ()
|
||||
"Depending on the context either a) indent the current line, b) go the next
|
||||
table field or c) run `yas-expand'."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(cond ((and (bound-and-true-p yas-minor-mode)
|
||||
(yas--templates-for-key-at-point))
|
||||
#'yas-expand)
|
||||
((org-at-table-p)
|
||||
#'org-table-next-field)
|
||||
(t
|
||||
#'+org/indent))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/dedent ()
|
||||
"Dedent the current item (header or item). Otherwise, forward to
|
||||
`self-insert-command'."
|
||||
(interactive)
|
||||
(cond ((org-at-item-p)
|
||||
(org-list-indent-item-generic
|
||||
-1 nil
|
||||
(save-excursion
|
||||
(when (org-region-active-p)
|
||||
(goto-char (region-beginning)))
|
||||
(org-list-struct))))
|
||||
((org-at-heading-p)
|
||||
(ignore-errors (org-promote)))
|
||||
(t
|
||||
(call-interactively #'self-insert-command))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/dedent-or-prev-field ()
|
||||
"Depending on the context either dedent the current item or go the previous
|
||||
table field."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(if (org-at-table-p)
|
||||
#'org-table-previous-field
|
||||
#'+org/dedent)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/insert-item (direction)
|
||||
"Inserts a new heading, table cell or item, depending on the context.
|
||||
DIRECTION can be 'above or 'below.
|
||||
|
||||
I use this instead of `org-insert-item' or `org-insert-heading' which are too
|
||||
opinionated and perform this simple task incorrectly (e.g. whitespace in the
|
||||
wrong places)."
|
||||
(interactive)
|
||||
(let* ((context (org-element-lineage
|
||||
(org-element-context)
|
||||
'(table table-row headline inlinetask item plain-list)
|
||||
t))
|
||||
(type (org-element-type context)))
|
||||
(cond ((eq type 'item)
|
||||
(let ((marker (org-element-property :bullet context))
|
||||
(pad (save-excursion
|
||||
(back-to-indentation)
|
||||
(- (point) (line-beginning-position)))))
|
||||
(pcase direction
|
||||
('below
|
||||
(goto-char (line-end-position))
|
||||
(insert (concat "\n" (make-string pad ? ) marker)))
|
||||
('above
|
||||
(goto-char (line-beginning-position))
|
||||
(insert (make-string pad ? ) marker)
|
||||
(save-excursion (insert "\n")))))
|
||||
(when (org-element-property :checkbox context)
|
||||
(insert "[ ] ")))
|
||||
|
||||
((memq type '(table table-row))
|
||||
(pcase direction
|
||||
('below (org-table-insert-row t))
|
||||
('above (+org/table-prepend-row-or-shift-up))))
|
||||
|
||||
((memq type '(headline inlinetask plain-list))
|
||||
(let* ((subcontext (org-element-context))
|
||||
(level (save-excursion
|
||||
(org-back-to-heading)
|
||||
(org-element-property
|
||||
:level
|
||||
(if (eq (org-element-type subcontext) 'headline)
|
||||
subcontext
|
||||
1)))))
|
||||
(pcase direction
|
||||
('below
|
||||
(let ((at-eol (= (point) (1- (line-end-position)))))
|
||||
(goto-char (line-end-position))
|
||||
(org-end-of-subtree)
|
||||
(insert (concat "\n"
|
||||
(when (= level 1)
|
||||
(if at-eol
|
||||
(ignore (cl-incf level))
|
||||
"\n"))
|
||||
(make-string level ?*)
|
||||
" "))))
|
||||
('above
|
||||
(org-back-to-heading)
|
||||
(org-insert-heading)
|
||||
(when (= level 1)
|
||||
(save-excursion (evil-open-above 1))
|
||||
(save-excursion (insert "\n")))))
|
||||
(when (org-element-property :todo-type context)
|
||||
(org-todo 'todo))))
|
||||
|
||||
(t (user-error "Not a valid list, heading or table")))
|
||||
|
||||
(when (bound-and-true-p evil-mode)
|
||||
(evil-append-line 1))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-get-property (name &optional _file) ; TODO Add FILE
|
||||
"Get a propery from an org file."
|
||||
(save-excursion
|
||||
(goto-char 1)
|
||||
(re-search-forward (format "^#\\+%s:[ \t]*\\([^\n]+\\)" (upcase name)) nil t)
|
||||
(buffer-substring-no-properties (match-beginning 1) (match-end 1))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/refresh-inline-images ()
|
||||
"Refresh image previews in the current heading/tree."
|
||||
(interactive)
|
||||
(if (> (length org-inline-image-overlays) 0)
|
||||
(org-remove-inline-images)
|
||||
(org-display-inline-images
|
||||
t t
|
||||
(if (org-before-first-heading-p)
|
||||
(line-beginning-position)
|
||||
(save-excursion (org-back-to-heading) (point)))
|
||||
(if (org-before-first-heading-p)
|
||||
(line-end-position)
|
||||
(save-excursion (org-end-of-subtree) (point))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/toggle-checkbox ()
|
||||
"Toggle the presence of a checkbox in the current item."
|
||||
(interactive)
|
||||
(org-toggle-checkbox '(4)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/toggle-fold ()
|
||||
"Toggle the local fold at the point (as opposed to cycling through all levels
|
||||
with `org-cycle'). Also removes babel result blocks, if run from a code block."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(org-beginning-of-line)
|
||||
(cond ((org-in-src-block-p)
|
||||
(org-babel-remove-result))
|
||||
((org-at-heading-p)
|
||||
(outline-toggle-children))
|
||||
((org-at-item-p)
|
||||
(let ((window-beg (window-start)))
|
||||
(org-cycle)
|
||||
(set-window-start nil window-beg))))))
|
66
modules/org/org/autoload/tables.el
Normal file
66
modules/org/org/autoload/tables.el
Normal file
|
@ -0,0 +1,66 @@
|
|||
;;; org/org/autoload/tables.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/table-next-row ()
|
||||
"Go to the next row (same column) in the current table."
|
||||
(interactive)
|
||||
(if (org-at-table-p)
|
||||
(org-table-next-row)
|
||||
(org-down-element)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/table-previous-row ()
|
||||
"Go to the previous row (same column) in the current table. Before doing so,
|
||||
re-align the table if necessary. (Necessary because org-mode has a
|
||||
`org-table-next-row', but not `org-table-previous-row')"
|
||||
(interactive)
|
||||
(if (org-at-table-p)
|
||||
(progn
|
||||
(org-table-maybe-eval-formula)
|
||||
(org-table-maybe-recalculate-line)
|
||||
(if (and org-table-automatic-realign
|
||||
org-table-may-need-update)
|
||||
(org-table-align))
|
||||
(let ((col (org-table-current-column)))
|
||||
(beginning-of-line 0)
|
||||
(when (or (not (org-at-table-p)) (org-at-table-hline-p))
|
||||
(beginning-of-line))
|
||||
(org-table-goto-column col)
|
||||
(skip-chars-backward "^|\n\r")
|
||||
(when (org-looking-at-p " ") (forward-char))))
|
||||
(org-up-element)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/table-next-field ()
|
||||
(interactive)
|
||||
(if (org-at-table-p) (org-table-next-field) (org-end-of-line)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/table-previous-field ()
|
||||
(interactive)
|
||||
(if (org-at-table-p) (org-table-previous-field) (org-beginning-of-line)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/table-append-field-or-shift-right ()
|
||||
(interactive)
|
||||
(org-shiftmetaright)
|
||||
(when (org-at-table-p) (org-metaright)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/table-prepend-field-or-shift-left ()
|
||||
(interactive)
|
||||
(if (org-at-table-p) (org-shiftmetaright) (org-shiftmetaleft)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/table-append-row-or-shift-down ()
|
||||
(interactive)
|
||||
(org-shiftmetadown)
|
||||
(when (org-at-table-p) (org-metadown)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/table-prepend-row-or-shift-up ()
|
||||
(interactive)
|
||||
(if (org-at-table-p)
|
||||
(org-shiftmetadown)
|
||||
(org-shiftmetaup)))
|
||||
|
259
modules/org/org/config.el
Normal file
259
modules/org/org/config.el
Normal file
|
@ -0,0 +1,259 @@
|
|||
;;; org/org/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
;; Ensure ELPA org is prioritized above built-in org.
|
||||
(when-let (path (locate-library "org" nil doom--package-load-path))
|
||||
(cl-pushnew (file-name-directory path) load-path :test #'equal))
|
||||
|
||||
;; Custom variables
|
||||
(defvar +org-dir (expand-file-name "~/work/org/")
|
||||
"The directory where org files are kept.")
|
||||
(defvaralias 'org-directory '+org-dir)
|
||||
|
||||
(add-hook 'org-load-hook #'+org|init)
|
||||
(add-hook 'org-mode-hook #'+org|hook)
|
||||
|
||||
|
||||
;;
|
||||
;; Plugins
|
||||
;;
|
||||
|
||||
(def-package! toc-org
|
||||
:commands toc-org-enable
|
||||
:init (add-hook 'org-mode-hook #'toc-org-enable))
|
||||
|
||||
(def-package! org-crypt ; built-in
|
||||
:commands org-crypt-use-before-save-magic
|
||||
:init (add-hook 'org-load-hook #'org-crypt-use-before-save-magic)
|
||||
:config
|
||||
(setq org-tags-exclude-from-inheritance '("crypt")
|
||||
org-crypt-key user-mail-address
|
||||
epa-file-encrypt-to user-mail-address))
|
||||
|
||||
;; The standard unicode characters are usually misaligned depending on the font.
|
||||
;; This bugs me. Personally, markdown #-marks for headlines are more elegant, so
|
||||
;; we use those.
|
||||
(def-package! org-bullets
|
||||
:commands org-bullets-mode
|
||||
:init (add-hook 'org-mode-hook #'org-bullets-mode)
|
||||
:config (setq org-bullets-bullet-list '("#")))
|
||||
|
||||
|
||||
;;
|
||||
;; Hooks & bootstraps
|
||||
;;
|
||||
|
||||
(defun +org|hook ()
|
||||
"Run everytime `org-mode' is enabled."
|
||||
(setq line-spacing 1)
|
||||
|
||||
;; show-paren-mode causes problems for org-indent-mode
|
||||
(make-local-variable 'show-paren-mode)
|
||||
(setq show-paren-mode nil)
|
||||
|
||||
(unless org-agenda-inhibit-startup
|
||||
;; My version of the 'overview' #+STARTUP option: expand first-level
|
||||
;; headings.
|
||||
(when (eq org-startup-folded t)
|
||||
(outline-hide-sublevels 2))
|
||||
|
||||
;; If saveplace places the point in a folded position, unfold it on load
|
||||
(when (outline-invisible-p)
|
||||
(ignore-errors
|
||||
(save-excursion
|
||||
(outline-previous-visible-heading 1)
|
||||
(org-show-subtree))))))
|
||||
|
||||
(defun +org|init ()
|
||||
"Run once, when org is first loaded."
|
||||
(define-minor-mode +org-evil-mode
|
||||
"Evil-mode bindings for org-mode."
|
||||
:init-value nil
|
||||
:lighter " !"
|
||||
:keymap (make-sparse-keymap)
|
||||
:group 'evil-org)
|
||||
|
||||
(add-hook 'org-mode-hook #'visual-line-mode)
|
||||
(when (featurep! :feature evil)
|
||||
(add-hook 'org-mode-hook #'+org-evil-mode))
|
||||
|
||||
(add-hook 'evil-insert-state-exit-hook #'+org|realign-table-maybe nil t)
|
||||
(add-hook 'evil-insert-state-exit-hook #'+org|update-cookies nil t)
|
||||
(add-hook 'before-save-hook #'+org|update-cookies nil t)
|
||||
|
||||
(+org-init-ui)
|
||||
(+org-init-keybinds)
|
||||
(+org-hacks))
|
||||
|
||||
;;
|
||||
(defun +org-init-ui ()
|
||||
"Configures the UI for `org-mode'."
|
||||
(setq-default
|
||||
org-adapt-indentation nil
|
||||
org-agenda-dim-blocked-tasks nil
|
||||
org-agenda-files (directory-files +org-dir t "\\.org$" t)
|
||||
org-agenda-inhibit-startup t
|
||||
org-agenda-skip-unavailable-files nil
|
||||
org-cycle-include-plain-lists t
|
||||
org-cycle-separator-lines 1
|
||||
;; org-ellipsis " "
|
||||
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-hidden-keywords nil
|
||||
org-hide-emphasis-markers nil
|
||||
org-hide-leading-stars t
|
||||
org-hide-leading-stars-before-indent-mode t
|
||||
org-image-actual-width nil
|
||||
org-indent-indentation-per-level 2
|
||||
org-indent-mode-turns-on-hiding-stars t
|
||||
org-pretty-entities nil
|
||||
org-pretty-entities-include-sub-superscripts t
|
||||
org-startup-folded t
|
||||
org-startup-indented t
|
||||
org-startup-with-inline-images nil
|
||||
org-tags-column 0
|
||||
org-use-sub-superscripts '{}
|
||||
outline-blank-line t
|
||||
|
||||
;; LaTeX previews are too small and usually render to light backgrounds, so
|
||||
;; this enlargens them and ensures their background (and foreground) match the
|
||||
;; current theme.
|
||||
org-format-latex-options (plist-put org-format-latex-options :scale 1.5)
|
||||
org-format-latex-options
|
||||
(plist-put org-format-latex-options
|
||||
:background (face-attribute (or (cadr (assq 'default face-remapping-alist))
|
||||
'default)
|
||||
:background nil t)))
|
||||
|
||||
;; Use ivy/helm if either is available
|
||||
(when (or (featurep! :completion ivy)
|
||||
(featurep! :completion helm))
|
||||
(setq-default org-completion-use-ido nil
|
||||
org-outline-path-complete-in-steps nil))
|
||||
|
||||
;; Custom fontification
|
||||
(defsubst +org--tag-face (n)
|
||||
(let ((kwd (match-string n)))
|
||||
(or (and (equal kwd "#") 'org-tag)
|
||||
(and (equal kwd "@") 'org-special-keyword))))
|
||||
|
||||
(defun +org|init-custom-fontification ()
|
||||
"Correct (and improve) org-mode's font-lock keywords.
|
||||
|
||||
1. Re-set `org-todo' & `org-headline-done' faces, to make them respect
|
||||
underlying faces.
|
||||
2. Fontify item bullets
|
||||
3. Fontify item checkboxes (and when they're marked done)
|
||||
4. Fontify dividers/separators (5+ dashes)
|
||||
5. Fontify #hashtags and @at-tags, for personal convenience"
|
||||
(let ((org-todo (format org-heading-keyword-regexp-format
|
||||
org-todo-regexp))
|
||||
(org-done (format org-heading-keyword-regexp-format
|
||||
(concat "\\(?:" (mapconcat #'regexp-quote org-done-keywords "\\|") "\\)"))))
|
||||
(setq
|
||||
org-font-lock-extra-keywords
|
||||
(append (org-delete-all
|
||||
`(("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
|
||||
(0 (org-get-checkbox-statistics-face) t))
|
||||
(,org-todo (2 (org-get-todo-face 2) t))
|
||||
(,org-done (2 'org-headline-done t)))
|
||||
org-font-lock-extra-keywords)
|
||||
`((,org-todo (2 (org-get-todo-face 2) prepend))
|
||||
(,org-done (2 'org-headline-done prepend))
|
||||
;; Make checkbox statistic cookies respect underlying faces
|
||||
("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
|
||||
(0 (org-get-checkbox-statistics-face) prepend))
|
||||
;; I like how org-mode fontifies checked TODOs and want this to extend to
|
||||
;; checked checkbox items:
|
||||
("^[ \t]*\\(?:[-+*]\\|[0-9]+[).]\\)[ \t]+\\(\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\(?:X\\|\\([0-9]+\\)/\\2\\)\\][^\n]*\n\\)"
|
||||
1 'org-headline-done prepend)
|
||||
;; make plain list bullets stand out
|
||||
("^ *\\([-+]\\|[0-9]+[).]\\) " 1 'org-list-dt append)
|
||||
;; and separators/dividers
|
||||
("^ *\\(-----+\\)$" 1 'org-meta-line)
|
||||
;; custom #hashtags & @at-tags for another level of organization
|
||||
("\\s-\\(\\([#@]\\)[^ \n.,]+\\)" 1 (+org--tag-face 2)))))))
|
||||
(add-hook 'org-font-lock-set-keywords-hook #'+org|init-custom-fontification))
|
||||
|
||||
(defun +org-init-keybinds ()
|
||||
"Sets up org-mode and evil keybindings. Tries to fix the idiosyncrasies
|
||||
between the two."
|
||||
(map! (:map org-mode-map "RET" #'org-return-indent)
|
||||
|
||||
(:map +org-evil-mode-map
|
||||
:n "RET" #'+org/dwim-at-point
|
||||
|
||||
;; Navigate table cells (from insert-mode)
|
||||
:i "C-L" #'+org/table-next-field
|
||||
:i "C-H" #'+org/table-previous-field
|
||||
:i "C-K" #'+org/table-previous-row
|
||||
:i "C-J" #'+org/table-next-row
|
||||
|
||||
:n [tab] #'+org/toggle-fold
|
||||
:i [tab] #'+org/indent-or-next-field-or-yas-expand
|
||||
:i [backtab] #'+org/dedent-or-prev-field
|
||||
|
||||
:ni [M-return] (λ! (+org/insert-item 'below))
|
||||
:ni [S-M-return] (λ! (+org/insert-item 'above))
|
||||
|
||||
:m "]]" (λ! (org-forward-heading-same-level nil) (org-beginning-of-line))
|
||||
:m "[[" (λ! (org-backward-heading-same-level nil) (org-beginning-of-line))
|
||||
:m "]l" #'org-next-link
|
||||
:m "[l" #'org-previous-link
|
||||
:m "$" #'org-end-of-line
|
||||
:m "^" #'org-beginning-of-line
|
||||
:n "gQ" #'org-fill-paragraph
|
||||
:n "<" #'org-metaleft
|
||||
:n ">" #'org-metaright
|
||||
:v "<" (λ! (org-metaleft) (evil-visual-restore))
|
||||
:v ">" (λ! (org-metaright) (evil-visual-restore))
|
||||
:m "<tab>" #'org-cycle
|
||||
|
||||
;; Fix code-folding keybindings
|
||||
:n "za" #'+org/toggle-fold
|
||||
:n "zA" #'org-shifttab
|
||||
:n "zc" #'outline-hide-subtree
|
||||
:n "zC" (λ! (outline-hide-sublevels 1))
|
||||
:n "zd" (lambda (&optional arg) (interactive "p") (outline-hide-sublevels (or arg 3)))
|
||||
:n "zm" (λ! (outline-hide-sublevels 1))
|
||||
:n "zo" #'outline-show-subtree
|
||||
:n "zO" #'outline-show-all
|
||||
:n "zr" #'outline-show-all)
|
||||
|
||||
(:after org-agenda
|
||||
(:map org-agenda-mode-map
|
||||
:e "<escape>" #'org-agenda-Quit
|
||||
:e "m" #'org-agenda-month-view
|
||||
:e "C-j" #'org-agenda-next-item
|
||||
:e "C-k" #'org-agenda-previous-item
|
||||
:e "C-n" #'org-agenda-next-item
|
||||
:e "C-p" #'org-agenda-previous-item))))
|
||||
|
||||
;;
|
||||
(defun +org-hacks ()
|
||||
"Getting org to behave."
|
||||
;; Don't open separate windows
|
||||
(cl-pushnew '(file . find-file) org-link-frame-setup)
|
||||
|
||||
;; Let OS decide what to do with files when opened
|
||||
(setq org-file-apps
|
||||
`(("\\.org$" . emacs)
|
||||
(t . ,(cond (IS-MAC "open -R \"%s\"")
|
||||
(IS-LINUX "xdg-open \"%s\"")))))
|
||||
|
||||
;; Remove highlights on ESC
|
||||
(defun +org|remove-occur-highlights ()
|
||||
(when (derived-mode-p 'org-mode)
|
||||
(org-remove-occur-highlights)
|
||||
t))
|
||||
(add-hook '+evil-esc-hook #'+org|remove-occur-highlights)
|
||||
|
||||
(after! recentf
|
||||
;; Don't clobber recentf with agenda files
|
||||
(defun +org-is-agenda-file (filename)
|
||||
(cl-find (file-truename filename) org-agenda-files
|
||||
:key #'file-truename
|
||||
:test #'equal))
|
||||
(add-to-list 'recentf-exclude #'+org-is-agenda-file)))
|
11
modules/org/org/packages.el
Normal file
11
modules/org/org/packages.el
Normal file
|
@ -0,0 +1,11 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; org/org/packages.el
|
||||
|
||||
;; NOTE This is an insecure source, but unavoidable if we want org 9.0+.
|
||||
;; orgmode.org offers no secure access to this repo. If this bothers you,
|
||||
;; comment out this `package!' block and download org-plus-contrib from
|
||||
;; orgmode.org.
|
||||
(package! org-plus-contrib :recipe (:fetcher git :url "http://orgmode.org/org-mode.git"))
|
||||
|
||||
(package! org-bullets :recipe (:fetcher github :repo "hlissner/org-bullets"))
|
||||
(package! toc-org)
|
Loading…
Add table
Add a link
Reference in a new issue