2017-07-05 02:33:41 +02:00
|
|
|
;;; org/org-capture/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
(add-hook 'org-load-hook #'+org-capture|init t)
|
2017-02-19 19:01:47 -05:00
|
|
|
|
2017-02-24 20:00:59 -05:00
|
|
|
;; Sets up two `org-capture' workflows that I like:
|
2017-02-19 19:01:47 -05:00
|
|
|
;;
|
2017-02-24 20:00:59 -05:00
|
|
|
;; 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
|
2017-04-22 01:51:52 -04:00
|
|
|
;; script is in ~/.emacs.d/bin). This lets me open an org-capture box
|
2017-07-05 02:33:41 +02:00
|
|
|
;; anywhere I can call org-capture (whether or not Emacs is open/running),
|
|
|
|
;; like, say, from qutebrowser, vimperator, dmenu or a global keybinding.
|
2017-02-19 19:01:47 -05:00
|
|
|
|
2017-07-05 02:33:41 +02:00
|
|
|
(defun +org-capture|init ()
|
2017-02-19 19:01:47 -05:00
|
|
|
"Set up a sane `org-capture' workflow."
|
2017-07-05 02:33:41 +02:00
|
|
|
(setq org-default-notes-file (concat +org-dir "notes.org")
|
|
|
|
;; FIXME This is incomplete!
|
|
|
|
org-capture-templates
|
2017-02-19 19:01:47 -05:00
|
|
|
'(;; 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
|
2017-02-24 20:00:59 -05:00
|
|
|
(file+headline (concat +org-dir "notes.org") "Inbox")
|
2017-02-19 19:01:47 -05:00
|
|
|
"* %u %?\n%i" :prepend t)
|
|
|
|
|
|
|
|
;; ("v" "Vocab" entry
|
|
|
|
;; (file+headline (concat org-directory "topics/vocab.org") "Unsorted")
|
|
|
|
;; "** %i%?\n")
|
2017-02-24 20:00:59 -05:00
|
|
|
))
|
|
|
|
|
2017-07-05 03:09:43 +02:00
|
|
|
(when (featurep! :feature evil)
|
|
|
|
(add-hook 'org-capture-mode-hook #'evil-insert-state))
|
|
|
|
|
2017-02-24 20:00:59 -05:00
|
|
|
;; 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)
|
2017-07-05 02:33:41 +02:00
|
|
|
(defun +org-capture*init (&rest _)
|
2017-02-24 20:00:59 -05:00
|
|
|
"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)))
|
2017-07-05 02:33:41 +02:00
|
|
|
(advice-add #'org-capture :after #'+org-capture*init)
|
2017-02-24 20:00:59 -05:00
|
|
|
|
2017-07-05 02:33:41 +02:00
|
|
|
(defun +org-capture|finalize ()
|
2017-02-24 20:00:59 -05:00
|
|
|
"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)))
|
2017-07-05 02:33:41 +02:00
|
|
|
(add-hook 'org-capture-after-finalize-hook #'+org-capture|finalize))
|