Skip to content

Commit

Permalink
wip - upgrading processing code
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevoke committed Mar 24, 2023
1 parent 196be5e commit f0d7f1b
Showing 6 changed files with 83 additions and 64 deletions.
17 changes: 17 additions & 0 deletions org-gtd-core.el
Original file line number Diff line number Diff line change
@@ -28,6 +28,23 @@
(require 'org-agenda-property)
(require 'org-capture)

(defgroup org-gtd nil
"Customize the org-gtd package."
:link '(url-link "https://github.com/Trevoke/org-gtd.el")
:package-version '(org-gtd . "0.1")
:group 'org)

(defcustom org-gtd-directory "~/gtd/"
"Directory for org-gtd.
The package will use this directory for all its functionality, whether it is
building the agenda or refiling items. This is the directory where you will
find the default org-gtd file, and it is the directory where you should place
your own files if you want multiple refile targets (projects, etc.)."
:group 'org-gtd
:package-version '(org-gtd . "0.1")
:type 'directory)

(defconst org-gtd-inbox "inbox")
(defconst org-gtd-incubated "incubated")
(defconst org-gtd-projects "projects")
80 changes: 45 additions & 35 deletions org-gtd-organize.el
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
;;
;;; Code:

(require 'transient)
(require 'org-gtd-core)
(require 'org-gtd-agenda)
(require 'org-gtd-projects)
@@ -42,62 +43,78 @@ point as an action that you started and finished just now."
:type 'function
:package-version '(org-gtd . "3.0.0"))

(defcustom org-gtd-organize-foo
#'org-gtd-organize-foo
"Can be an atom or a sexp. Function called when org-gtd..."
(defcustom org-gtd-organize-single-action-func
#'org-gtd-organize-task-at-point-as-single-action
"Can be an atom or a sexp. Function called when org-gtd organizes the item at
point as a single next action."
:group 'org-gtd-organize
:type 'function
:package-version '(org-gtd . "3.0.0"))

(defcustom org-gtd-organize-foo
#'org-gtd-organize-foo
"Can be an atom or a sexp. Function called when org-gtd..."
(defcustom org-gtd-organize-archive-func
#'org-gtd-organize-task-at-point-as-archived-knowledge
"Can be an atom or a sexp. Function called when org-gtd organizes the item at
point as knowledge to be stored. Note that this function is used inside loops,
for instance to process the inbox, so if you have manual steps you need to take
when storing a heading as knowledge, take them before calling this function
(for instance, during inbox processing, take the manual steps during the clarify
step, before you call `org-gtd-organize')."
:group 'org-gtd-organize
:type 'function
:package-version '(org-gtd . "3.0.0"))

(defcustom org-gtd-organize-foo
#'org-gtd-organize-foo
"Can be an atom or a sexp. Function called when org-gtd..."
(defcustom org-gtd-organize-project-func
#'org-gtd-organize-task-at-point-as-new-project
"Can be an atom or a sexp. Function called when org-gtd organizes the item at
point as a project. You *probably* should not change this from the default, as a
lot of fiddly bits depend on the way org-gtd structures and organizes the
projects, but who's gonna stop you?"
:group 'org-gtd-organize
:type 'function
:package-version '(org-gtd . "3.0.0"))

(defcustom org-gtd-organize-foo
#'org-gtd-organize-foo
"Can be an atom or a sexp. Function called when org-gtd..."
(defcustom org-gtd-organize-add-to-project-func
#'org-gtd-organize-task-at-point-add-to-existing-project
"Can be an atom or a sexp. Function called when org-gtd organizes the item at
point as a new task in an existing project"
:group 'org-gtd-organize
:type 'function
:package-version '(org-gtd . "3.0.0"))

(defcustom org-gtd-organize-foo
#'org-gtd-organize-foo
"Can be an atom or a sexp. Function called when org-gtd..."
(defcustom org-gtd-organize-appointment-func
#'org-gtd-organize-task-at-point-as-appointment
"Can be an atom or a sexp. Function called when org-gtd organizes the item at
point as a task that must happen on a given day. Keep this clean and don't load
your calendar with things that aren't actually appointments or deadlines."
:group 'org-gtd-organize
:type 'function
:package-version '(org-gtd . "3.0.0"))

(defcustom org-gtd-organize-foo
#'org-gtd-organize-foo
"Can be an atom or a sexp. Function called when org-gtd..."
(defcustom org-gtd-organize-delegate-func
#'org-gtd-organize-task-at-point-as-delegated
"Can be an atom or a sexp. Function called when org-gtd organizes the item at
point as an action delegated to someone else."
:group 'org-gtd-organize
:type 'function
:package-version '(org-gtd . "3.0.0"))

(defcustom org-gtd-organize-foo
#'org-gtd-organize-foo
"Can be an atom or a sexp. Function called when org-gtd..."
(defcustom org-gtd-organize-incubate-func
#'org-gtd-organize-task-at-point-as-incubated
"Can be an atom or a sexp. Function called when org-gtd organizes the item at
point as incubated."
:group 'org-gtd-organize
:type 'function
:package-version '(org-gtd . "3.0.0"))

(defcustom org-gtd-organize-foo
#'org-gtd-organize-foo
"Can be an atom or a sexp. Function called when org-gtd..."
(defcustom org-gtd-organize-trash-func
#'org-gtd-organize-task-at-point-as-trash
"Can be an atom or a sexp. Function called when org-gtd organizes the item at
point as something to be discarded."
:group 'org-gtd-organize
:type 'function
:package-version '(org-gtd . "3.0.0"))

;;;###autoload
(transient-define-prefix org-gtd-organize ()
"Choose how to categorize the current item.
@@ -128,7 +145,7 @@ undefined state."
#'org-gtd-organize
"2.3.0")

(defun org-gtd-organize-next-action ()
(defun org-gtd-organize-task-at-point-as-single-action ()
"Item at point is a one-off NEXT action."
(interactive)
(let ((org-todo-keywords '((sequence "NEXT" "TODO" "WAIT" "|" "DONE" "CNCL" "TRASH")))
@@ -180,7 +197,7 @@ the inbox. Refile to `org-gtd-actionable-file-basename'."
(org-update-statistics-cookies t)
(org-gtd--refile org-gtd-projects)))

(defun org-gtd-organize-add-task-at-point-to-existing-project ()
(defun org-gtd-organize-task-at-point-add-to-existing-project ()
"Refile the org heading at point under a chosen heading in the agenda files."
(interactive)
(with-org-gtd-context
@@ -207,27 +224,20 @@ the inbox. Refile to `org-gtd-actionable-file-basename'."
(org-schedule 0)
(org-gtd--refile org-gtd-calendar))

(defun org-gtd-organize-delegate-task-at-point ()
(defun org-gtd-organize-task-at-point-as-delegated ()
"Delegate this item and file it in the org-gtd system."
(interactive)
(org-gtd-organize-decorate-item)
(org-gtd-delegate)
(org-gtd--refile org-gtd-actions))

(defun org-gtd-organize-incubate-task-at-point ()
(defun org-gtd-organize-task-at-point-as-incubated ()
"Incubate this item through org-gtd."
(interactive)
(org-gtd-organize-decorate-item)
(org-schedule 0)
(org-gtd--refile org-gtd-incubated))

(defun org-gtd-organize-task-at-point-as-single-action ()
"Process GTD inbox item as a single action."
(interactive)
(org-gtd-organize-decorate-item)
(org-todo "NEXT")
(org-gtd--refile org-gtd-actions))

(defun org-gtd-organize-task-at-point-as-trash ()
"Mark GTD inbox item as cancelled and move it to the org-gtd task archives."
(interactive)
11 changes: 3 additions & 8 deletions org-gtd-process.el
Original file line number Diff line number Diff line change
@@ -105,12 +105,7 @@ the inbox. Refile to `org-gtd-actionable-file-basename'."
(org-gtd-process-action
org-gtd--modify-project
"Refile the org heading at point under a chosen heading in the agenda files."
(org-gtd-organize-add-task-at-point-to-existing-project))

(org-gtd-process-action
org-gtd--modify-project
"Refile the org heading at point under a chosen heading in the agenda files."
(org-gtd-organize-add-task-at-point-to-existing-project))
(org-gtd-organize-task-at-point-add-to-existing-project))

(org-gtd-process-action
org-gtd--calendar
@@ -120,15 +115,15 @@ the inbox. Refile to `org-gtd-actionable-file-basename'."
(org-gtd-process-action
org-gtd--delegate
"Process GTD inbox item by delegating it."
(org-gtd-organize-delegate-task-at-point))
(org-gtd-organize-task-at-point-as-delegated))

(org-gtd-process-action
org-gtd--incubate
"Process GTD inbox item by incubating it.
Allow the user apply user-defined tags from
`org-tag-persistent-alist', `org-tag-alist' or file-local tags in
the inbox. Refile to any org-gtd incubate target (see manual)."
(org-gtd-organize-incubate-task-at-point))
(org-gtd-organize-task-at-point-as-incubated))

(org-gtd-process-action
org-gtd--quick-action
17 changes: 0 additions & 17 deletions org-gtd.el
Original file line number Diff line number Diff line change
@@ -50,23 +50,6 @@
(require 'org-agenda-property)
(require 'org-edna)

(defgroup org-gtd nil
"Customize the org-gtd package."
:link '(url-link "https://github.com/Trevoke/org-gtd.el")
:package-version '(org-gtd . "0.1")
:group 'org)

(defcustom org-gtd-directory "~/gtd/"
"Directory for org-gtd.
The package will use this directory for all its functionality, whether it is
building the agenda or refiling items. This is the directory where you will
find the default org-gtd file, and it is the directory where you should place
your own files if you want multiple refile targets (projects, etc.)."
:group 'org-gtd
:package-version '(org-gtd . "0.1")
:type 'directory)

(require 'org-gtd-core)
(require 'org-gtd-id)
(require 'org-gtd-wip)
6 changes: 3 additions & 3 deletions test/organizing-test.el
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
(set-buffer source-buffer)
(org-gtd-clarify-item)
(setq window-config org-gtd--window-config)
(org-gtd-organize-next-action)
(org-gtd-organize-task-at-point-as-single-action)

(expect (compare-window-configurations (current-window-configuration) window-config)
:to-be t)))
@@ -27,13 +27,13 @@
(org-gtd-refile-to-any-target t))
(set-buffer source-buffer)
(org-gtd-clarify-item)
(org-gtd-organize-next-action)
(org-gtd-organize-task-at-point-as-single-action)
(expect (org-gtd-wip--get-buffers) :to-be nil)))

(it "deletes the source heading"
(let ((source-buffer (ogt--temp-org-file-buffer "taskfile" "* This is the heading to clarify"))
(org-gtd-refile-to-any-target t))
(set-buffer source-buffer)
(org-gtd-clarify-item)
(org-gtd-organize-next-action)
(org-gtd-organize-task-at-point-as-single-action)
(expect (buffer-size) :to-equal 0))))
16 changes: 15 additions & 1 deletion test/wip-buffer-test.el
Original file line number Diff line number Diff line change
@@ -4,6 +4,20 @@
(require 'buttercup)
(require 'with-simulated-input)

(defun ogt-manage-active-minor-modes ()
"Get a list of which minor modes are enabled in the current buffer. Taken from
https://emacs.stackexchange.com/a/62414/61
because I need to run this on older emacsen than 28.1 which has
`local-minor-modes'."
(let ($list)
(mapc (lambda ($mode)
(condition-case nil
(if (and (symbolp $mode) (symbol-value $mode))
(setq $list (cons $mode $list)))
(error nil)))
minor-mode-list)
(sort $list 'string<)))

(describe
"WIP state for tasks"

@@ -28,4 +42,4 @@

(let ((wip-buffer (car (org-gtd-wip--get-buffers))))
(with-current-buffer wip-buffer
(expect local-minor-modes :to-contain 'org-gtd-process-mode))))))
(expect (ogt-manage-active-minor-modes) :to-contain 'org-gtd-process-mode))))))

0 comments on commit f0d7f1b

Please sign in to comment.