1
0
Fork 0

Move org-capture settings to their own section

This commit is contained in:
Tom Willemse 2020-09-21 18:26:43 -07:00
parent 2eb1766496
commit 721fccc2ca

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2020.0921.182344
;; Version: 2020.0921.182555
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org-plus-contrib org-bullets org-edna diminish all-the-icons)
;; This program is free software; you can redistribute it and/or modify
@ -33,7 +33,6 @@
(require 'ob)
(require 'ol-man)
(require 'org)
(require 'org-capture)
(require 'org-clock)
(require 'org-edna)
(require 'org-element)
@ -77,22 +76,6 @@ installs it will always be ~."
(add-to-list 'yas-snippet-dirs oni-org-snippets-dir t))
(yas-load-directory oni-org-snippets-dir))
(defun oni-org-delete-frame-once ()
"Run `delete-frame'.
After running it once remove it from `org-capture-after-finalize-hook'."
(delete-frame)
(remove-hook 'org-capture-after-finalize-hook 'oni-org-delete-frame-once))
(defun oni-org-run-capture-in-dedicated-frame ()
"Run `org-capture' in a dedicated frame."
(with-selected-frame (make-frame '((minibuffer)))
(org-capture nil "t")
(delete-other-windows)
(setf (frame-width) 80)
(setf (frame-height) 24)
(add-hook 'org-capture-after-finalize-hook 'oni-org-delete-frame-once)))
(defun oni-org-maybe-change-todo-state (current-state)
"Change the state of the current task to in-progress CURRENT-STATE is todo."
(if (string= current-state "TODO")
@ -257,51 +240,6 @@ also move point to the start of the heading."
(oni-org-create-chapter-heading book-name chapter-name notes-file))
(oni-org-create-chapter-section chapter-name notes-file))))
(setq org-capture-templates-contexts
'(("n" ((in-mode . "nov-mode")))))
(setq org-capture-templates
`(("i" "Inbox" entry (file "")
"* %?\n:PROPERTIES:\n:CREATED: %U\n:ORIGIN: %a\n:END:\n\n")
("I" "Inbox (add selection)" entry (file "")
"* %?\n:PROPERTIES:\n:CREATED: %U\n:ORIGIN: %a\n:END:\n\n#+begin_quote\n%i\n#+end_quote")
("t" "Task" entry (file "")
"* TODO %i%?\n :PROPERTIES:\n :CREATED: %U\n :END:")
("a" "Appointment" entry (file "")
"* TODO %i%?\n %U")
("j" "Journal entry" entry
(file+olp+datetree
,(oni-org-expand-to-home "documents/gtd/journal.org"))
"* %<%H:%M:%S>\n %?")
("n" "Reading note" item (function oni-org-reading-note)
"%?\n\n#+begin_quote\n%i\n#+end_quote"
:empty-lines 1)
("c" "Add to currently clocked item")
("ca" "Note" plain
(clock)
" %U\n\n %?" :empty-lines 1)
("ci" "Item to current clocked task" item
(clock)
" %i%?" :empty-lines 1)
("cc" "Marked code example with notes" plain
(clock)
" %U
- File: [[file:%F::%(number-to-string (with-current-buffer (get-buffer (find-file-noselect \"%F\")) (line-number-at-pos (region-beginning))))][%f]]
%?
#+BEGIN_SRC %(string-remove-suffix \"-mode\" (symbol-name (with-current-buffer (get-buffer (find-file-noselect \"%F\")) major-mode)))
%i
#+END_SRC"
:empty-lines 1)
("cC" "Marked code example" plain
(clock)
" #+BEGIN_EXAMPLE\n %i\n #+END_EXAMPLE"
:immediate-finish t :empty-lines 1)
("ck" "Kill-ring contents" plain
(clock)
" %c" :immediate-finish t :empty-lines 1)))
(setq org-todo-keywords
'((sequence "TODO(t)" "NEXT(n)" "BLOCKED(b@)" "IN-PROGRESS(p)"
"|" "DONE(d!)" "CANCELLED(c@)")))
@ -386,5 +324,70 @@ also move point to the start of the heading."
(add-hook 'org-mode-hook #'oni-org-initialize-agenda-category-icons)
;;;; Capture
(require 'org-capture)
(defun oni-org-delete-frame-once ()
"Run `delete-frame'.
After running it once remove it from `org-capture-after-finalize-hook'."
(delete-frame)
(remove-hook 'org-capture-after-finalize-hook 'oni-org-delete-frame-once))
(defun oni-org-run-capture-in-dedicated-frame ()
"Run `org-capture' in a dedicated frame."
(with-selected-frame (make-frame '((minibuffer)))
(org-capture nil "t")
(delete-other-windows)
(setf (frame-width) 80)
(setf (frame-height) 24)
(add-hook 'org-capture-after-finalize-hook 'oni-org-delete-frame-once)))
(setq org-capture-templates
`(("i" "Inbox" entry (file "")
"* %?\n:PROPERTIES:\n:CREATED: %U\n:ORIGIN: %a\n:END:\n\n")
("I" "Inbox (add selection)" entry (file "")
"* %?\n:PROPERTIES:\n:CREATED: %U\n:ORIGIN: %a\n:END:\n\n#+begin_quote\n%i\n#+end_quote")
("t" "Task" entry (file "")
"* TODO %i%?\n :PROPERTIES:\n :CREATED: %U\n :END:")
("a" "Appointment" entry (file "")
"* TODO %i%?\n %U")
("j" "Journal entry" entry
(file+olp+datetree
,(oni-org-expand-to-home "documents/gtd/journal.org"))
"* %<%H:%M:%S>\n %?")
("n" "Reading note" item (function oni-org-reading-note)
"%?\n\n#+begin_quote\n%i\n#+end_quote"
:empty-lines 1)
("c" "Add to currently clocked item")
("ca" "Note" plain
(clock)
" %U\n\n %?" :empty-lines 1)
("ci" "Item to current clocked task" item
(clock)
" %i%?" :empty-lines 1)
("cc" "Marked code example with notes" plain
(clock)
" %U
- File: [[file:%F::%(number-to-string (with-current-buffer (get-buffer (find-file-noselect \"%F\")) (line-number-at-pos (region-beginning))))][%f]]
%?
#+BEGIN_SRC %(string-remove-suffix \"-mode\" (symbol-name (with-current-buffer (get-buffer (find-file-noselect \"%F\")) major-mode)))
%i
#+END_SRC"
:empty-lines 1)
("cC" "Marked code example" plain
(clock)
" #+BEGIN_EXAMPLE\n %i\n #+END_EXAMPLE"
:immediate-finish t :empty-lines 1)
("ck" "Kill-ring contents" plain
(clock)
" %c" :immediate-finish t :empty-lines 1)))
(setq org-capture-templates-contexts
'(("n" ((in-mode . "nov-mode")))))
(provide 'oni-org)
;;; oni-org.el ends here