forked from Trevoke/org-gtd.el
-
Notifications
You must be signed in to change notification settings - Fork 0
/
org-gtd-capture.el
106 lines (80 loc) · 2.86 KB
/
org-gtd-capture.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
;;; org-gtd-capture.el --- capturing items to the inbox -*- lexical-binding: t; coding: utf-8 -*-
;;
;; Copyright © 2019-2023 Aldric Giacomoni
;; Author: Aldric Giacomoni <[email protected]>
;; This file is not part of GNU Emacs.
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this file. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; capturing items to the inbox for org-gtd.
;;
;;; Code:
;;;; Requirements
(require 'org-capture)
(require 'org-gtd-files)
;;;; Customization
(defgroup org-gtd-capture nil
"Manage the functions for organizing the GTD actions."
:group 'org-gtd
:package-version '(org-gtd . "3.0.0"))
(defcustom org-gtd-capture-templates
`(("i" "Inbox"
entry (file ,#'org-gtd-inbox-path)
"* %?\n%U\n\n %i"
:kill-buffer t)
("l" "Inbox with link"
entry (file ,#'org-gtd-inbox-path)
"* %?\n%U\n\n %i\n %a"
:kill-buffer t))
"Capture templates to be used when adding something to the inbox.
See `org-capture-templates' for the format of each capture template.
Make the sure the template string starts with a single asterisk to denote a
top level heading, or the behavior of org-gtd will be undefined."
:group 'org-gtd-capture
:package-version '(org-gtd . "2.0.0")
:type 'sexp)
;;;; Constants
(defconst org-gtd-inbox "inbox")
(defconst org-gtd-inbox-template
"#+begin_comment
This is the inbox. Everything goes in here when you capture it.
#+end_comment
"
"Template for the GTD inbox.")
;;;; Macros
(defmacro with-org-gtd-capture (&rest body)
"Wrap BODY... with let-bound `org-gtd' variables for capture purposes."
(declare (debug t) (indent 2))
`(let ((org-capture-templates org-gtd-capture-templates))
(unwind-protect
(progn ,@body))))
;;;; Commands
;;;###autoload
(defun org-gtd-capture (&optional goto keys)
"Capture something into the GTD inbox.
Wraps the function `org-capture' to ensure the inbox exists.
For GOTO and KEYS, see `org-capture' documentation for the variables of the
same name."
(interactive)
(with-org-gtd-capture
(org-capture goto keys)))
;;;; Functions
;;;; Public
;;;###autoload
(defun org-gtd-inbox-path ()
"Return the full path to the inbox file."
(let ((path (org-gtd--path org-gtd-inbox)))
(org-gtd--ensure-file-exists path org-gtd-inbox-template)
path))
;;;; Footer
(provide 'org-gtd-capture)
;;; org-gtd-capture.el ends here