-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
org-gtd-single-action.el
72 lines (58 loc) · 2.29 KB
/
org-gtd-single-action.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
;;; org-gtd-single-action.el --- Define single action items in org-gtd -*- 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:
;;
;; Single action items have their own logic, defined here
;;
;;; Code:
(defconst org-gtd-action "Actions")
(defconst org-gtd-action-template
(format "* Actions
:PROPERTIES:
:ORG_GTD: %s
:END:
" org-gtd-action))
(defcustom org-gtd-organize-single-action-func
#'org-gtd-single-action--apply
"Function called when item at point is a single next action."
:group 'org-gtd-organize
:type 'function
:package-version '(org-gtd . "3.0.0"))
;;;###autoload
(defun org-gtd-single-action ()
"Organize, decorate and refile item at point as a single action."
(interactive)
(org-gtd-organize--call org-gtd-organize-single-action-func))
(defun org-gtd-single-action--apply ()
"Item at point is a one-off action, ready to be executed."
(interactive)
(org-todo org-gtd-next)
(setq-local org-gtd--organize-type 'single-action)
(org-gtd-organize-apply-hooks)
(org-gtd--refile org-gtd-action org-gtd-action-template))
(defun org-gtd-single-action-create (topic)
"Automatically create a delegated task in the GTD flow.
TOPIC is what you want to see in the agenda view."
(let ((buffer (generate-new-buffer "Org GTD programmatic temp buffer"))
(org-id-overriding-file-name "org-gtd"))
(with-current-buffer buffer
(org-mode)
(insert (format "* %s" topic))
(org-gtd-clarify-item)
(org-gtd-single-action))
(kill-buffer buffer)))
(provide 'org-gtd-single-action)
;;; org-gtd-single-action.el ends here