-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
833 additions
and
1,214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
(setq action | ||
'((keyword . "NEXT") | ||
(properties . ((ORG_GTD . ((value . "Actions") | ||
(selectable . nil))) | ||
(id . ((value . org-gtd-id-get-create) | ||
(selectable . nil))))))) | ||
|
||
(setq calendared-draft-one | ||
'((properties . ((id . ((value . org-gtd-id-get-create) | ||
(selectable . nil))) | ||
(ORG_GTD . ((value . "Calendar") | ||
(selectable . nil))) | ||
(ORG_GTD_TIMESTAMP . ((type . 'active-timestamp) | ||
(prompt . "Timestamp: ") | ||
(selectable . t))))))) | ||
|
||
|
||
(setq calendared | ||
'((metadata . ((id . org-gtd-id-get-create) | ||
(ORG_GTD . "Calendar"))) | ||
(definition . (properties . ((ORG_GTD_TIMESTAMP . ((type . 'active-timestamp) | ||
(prompt . "Timestamp: ")))))) | ||
(views . (engage . ((ORG_GTD_TIMESTAMP . :today)))))) | ||
|
||
(setq habits | ||
'((keyword . "SCHEDULED") | ||
(properties . ((id . ((value . org-gtd-id-get-create) | ||
(selectable . nil))) | ||
(ORG_GTD . ((value . "Habits") | ||
(selectable . nil))) | ||
(style . ((value . "habit") | ||
(selectable . nil))))))) | ||
|
||
(setq incubated | ||
'((properties . ((id . ((value . org-gtd-id-get-create) | ||
(selectable . nil))) | ||
(ORG_GTD . ((value . "incubated") | ||
(selectable . nil))) | ||
(ORG_GTD_TIMESTAMP . ((type . 'active-timestamp) | ||
(prompt . "Timestamp: ") | ||
(selectable . t))))))) | ||
|
||
(setq project | ||
'((properties . ((id . ((value . org-gtd-id-get-create) | ||
(selectable . nil))) | ||
(ORG_GTD . ((value . "project") | ||
(selectable . nil))) | ||
(trigger . ((value . "org-gtd-next-project-action org-gtd-update-project-task!") | ||
(selectable . nil))) | ||
(first_action . ((type . 'string) | ||
(value . org-gtd-id-get-create) | ||
(selectable . t))))))) | ||
|
||
(setq project-action | ||
'((keyword . "TODO") | ||
(properties . ((ORG_GTD . ((value . "actions") | ||
(selectable . nil))) | ||
(id . ((value . org-gtd-id-get-create) | ||
(selectable . nil))) | ||
(parent_id . ((type . 'string) | ||
(value . org-gtd-id-get-create) | ||
(selectable . t))) | ||
(following-action . ((type . 'string) | ||
(value . "") | ||
(selectable . t))))))) | ||
|
||
(setq delegated | ||
'((keyword . "WAIT") | ||
(properties . ((id . ((value . org-gtd-id-get-create) | ||
(selectable . nil))) | ||
(ORG_GTD_TIMESTAMP . ((type . 'active-timestamp) | ||
(prompt . "When to check in on this? ") | ||
(selectable . t))) | ||
(ORG_GTD . ((value . "actions") | ||
(selectable . nil))))))) | ||
|
||
(defun prompt-for-property (property-data) | ||
"Prompt the user for a value based on PROPERTY-DATA if it is selectable." | ||
(interactive) | ||
(let ((type (cdr (assoc 'type property-data))) | ||
(prompt (cdr (assoc 'prompt property-data))) | ||
(selectable (cdr (assoc 'selectable property-data))) | ||
(value (cdr (assoc 'value property-data)))) | ||
(if selectable | ||
(pcase type | ||
('string (read-string (format "%s: " prompt))) | ||
('active-timestamp (prompt-for-active-date prompt)) | ||
('active-timestamp-with-repeater (prompt-for-date-with-repeater)) | ||
(_ (read-string (format "%s: " prompt)))) | ||
(if (functionp value) | ||
(funcall value) | ||
value)))) | ||
|
||
(defun prompt-for-date-with-repeater () | ||
(interactive) | ||
(let ((start-date (org-read-date nil nil nil "When do you want this repeating event to start?")) | ||
(repeater (read-from-minibuffer "How do you want this to repeat? "))) | ||
(format "<%s %s>" today repeater))) | ||
|
||
(defun prompt-for-active-date (prompt) | ||
(interactive) | ||
(let ((date (org-read-date nil nil nil prompt))) | ||
(format "<%s>" date))) | ||
|
||
(defun make-new-heading (action-alist &optional epom) | ||
"Create a new org heading with the information from ACTION-ALIST at EPOM." | ||
(interactive) | ||
(let ((epom (or epom (org-element-at-point))) | ||
(properties (cdr (assoc 'properties action-alist))) | ||
(keyword (cdr (assoc 'keyword action-alist)))) | ||
;; Navigate to EPOM | ||
(goto-char (org-element-property :begin epom)) | ||
|
||
;; Iterate over properties and set them | ||
(dolist (property properties) | ||
(let ((property-name (symbol-name (car property))) | ||
(property-data (cdr property))) | ||
(org-set-property property-name (prompt-for-property property-data)))) | ||
;; Set keyword if present | ||
(when keyword | ||
(org-todo keyword)))) | ||
|
||
|
||
(defun generate-org-ql-query (alist) | ||
"Generate an org-ql query from the provided ALIST, focusing on ORG_GTD, ORG_GTD_TIMESTAMP, and style." | ||
(let ((keyword (cdr (assoc 'keyword alist))) | ||
(properties (cdr (assoc 'properties alist)))) | ||
(delq nil | ||
(append | ||
'(and) | ||
(when keyword | ||
`((todo ,keyword))) | ||
(mapcar (lambda (property) | ||
(let ((name (symbol-name (car property))) | ||
(value (cdr (assoc 'value (cdr property))))) | ||
(when (and value (member name '("ORG_GTD" "ORG_GTD_TIMESTAMP" "style"))) | ||
`(property ,name ,value t)))) | ||
properties))))) | ||
|
||
|
||
(org-ql-search (org-agenda-files) (generate-org-ql-query action)) | ||
(org-ql-search (org-agenda-files) '(todo "NEXT")) | ||
(org-ql-search (org-agenda-files) '(and (property "ORG_GTD" "Calendar" t))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
;;; org-gtd-calendar.el --- Define calendar 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: | ||
;; | ||
;; Calendar items have their own state and logic, defined here. | ||
;; | ||
;;; Code: | ||
|
||
;;;; Requirements | ||
|
||
(require 'org-gtd-clarify) | ||
|
||
(declare-function 'org-gtd-organize--call 'org-gtd-organize) | ||
(declare-function 'org-gtd-organize-apply-hooks 'org-gtd-organize) | ||
|
||
;;;; Constants | ||
|
||
(defconst org-gtd-calendar "Calendar") | ||
|
||
(defconst org-gtd-calendar-func #'org-gtd-calendar--apply | ||
"Function called when item at point is 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.") | ||
|
||
(defconst org-gtd-calendar-template | ||
(format "* Calendar | ||
:PROPERTIES: | ||
:ORG_GTD: %s | ||
:END: | ||
" org-gtd-calendar)) | ||
|
||
;;;; Commands | ||
|
||
(defun org-gtd-calendar (&optional appointment-date) | ||
"Decorate and refile item at point as a calendar item. | ||
You can pass APPOINTMENT-DATE as a YYYY-MM-DD string if you want to use this | ||
non-interactively." | ||
(interactive) | ||
(org-gtd-organize--call | ||
(apply-partially org-gtd-calendar-func | ||
appointment-date))) | ||
|
||
;;;; Functions | ||
|
||
;;;;; Public | ||
|
||
(defun org-gtd-calendar-create (topic appointment-date) | ||
"Automatically create a calendar task in the GTD flow. | ||
Takes TOPIC as the string from which to make the heading to add to `org-gtd' and | ||
APPOINTMENT-DATE as a YYYY-MM-DD string." | ||
(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-calendar appointment-date)) | ||
(kill-buffer buffer))) | ||
|
||
;;;;; Private | ||
|
||
(defun org-gtd-calendar--apply (&optional appointment-date rfloc) | ||
"Add a date/time to this item and store in org gtd. | ||
You can pass APPOINTMENT-DATE as a YYYY-MM-DD string if you want to use this | ||
non-interactively." | ||
(let ((date (or appointment-date | ||
(org-read-date t nil nil "When is this going to happen? ")))) | ||
(org-entry-put (point) org-gtd-timestamp (format "<%s>" date)) | ||
(save-excursion | ||
(org-end-of-meta-data t) | ||
(open-line 1) | ||
(insert (format "<%s>" date)))) | ||
(setq-local org-gtd--organize-type 'calendar) | ||
(org-gtd-organize-apply-hooks) | ||
(org-refile nil nil rfloc)) | ||
|
||
;;;; Footer | ||
|
||
(provide 'org-gtd-calendar) | ||
|
||
;;; org-gtd-calendar.el ends here |
Oops, something went wrong.