From ecdaef98607bd4e85b8821f16db0852339ccd5cc Mon Sep 17 00:00:00 2001 From: Benson Chu Date: Thu, 19 Dec 2019 17:40:26 -0600 Subject: [PATCH] Implemented custom delay --- config-org-new.org | 3 +- lisp/libs.el | 1 + lisp/org-delay.el | 66 ++++++++++++++++++++++++++++++++ lisp/org-project/opr-projects.el | 11 +++--- lisp/org-project/opr-tasks.el | 6 +-- lisp/org-project/org-project.el | 14 ++++--- 6 files changed, 85 insertions(+), 16 deletions(-) create mode 100644 lisp/org-delay.el diff --git a/config-org-new.org b/config-org-new.org index b43f93b..aea33b7 100644 --- a/config-org-new.org +++ b/config-org-new.org @@ -604,8 +604,7 @@ (todo "NEXT")) ((org-ql-block-header "Things to do"))) (agenda "" - ((org-agenda-skip-function 'my/agenda-custom-skip) - (org-agenda-span 'day) + ((org-agenda-span 'day) (org-agenda-tag-filter-preset (quote (,dev-tag))) (org-agenda-skip-deadline-if-done t) (org-agenda-skip-scheduled-if-done t) diff --git a/lisp/libs.el b/lisp/libs.el index e7af134..0514583 100644 --- a/lisp/libs.el +++ b/lisp/libs.el @@ -9,6 +9,7 @@ (require 'org-loop) (require 'org-project) +(require 'org-delay) ;; New stuff, may not stick around (require 'org-ql-custom-stuck-projects) diff --git a/lisp/org-delay.el b/lisp/org-delay.el new file mode 100644 index 0000000..bcf24c6 --- /dev/null +++ b/lisp/org-delay.el @@ -0,0 +1,66 @@ +;;; org-delay.el --- -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Benson Chu + +;; Author: Benson Chu +;; Created: [2019-12-19 16:52] + +;; This file is not part of GNU Emacs + +;; This program 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 of the License, or +;; (at your option) any later version. + +;; This program 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 program. If not, see . + +;;; Commentary: + +;;; Code: + +(defun org-delay (arg &optional time) + (interactive "P") + (if (and (org-region-active-p) org-loop-over-headlines-in-active-region) + (error "Not supported yet") + (pcase arg + ('(4) + (org-entry-delete (point) "DELAYED")) + (_ + (let ((new-time + (or time + (format "<%s>" + (org-read-date + nil nil nil + "Delay until when?"))))) + (org-entry-put (point) "DELAYED" new-time)))))) + +(define-key org-mode-map (kbd "C-c ") #'org-delay) + +(defun org-agenda-delay (arg &optional time) + (interactive "P") + (org-agenda-check-type t 'agenda 'todo 'tags 'search) + (org-agenda-check-no-diary) + (let* ((marker (or (org-get-at-bol 'org-marker) + (org-agenda-error))) + (buffer (marker-buffer marker)) + (pos (marker-position marker)) + ts) + (org-with-remote-undo buffer + (with-current-buffer buffer + (widen) + (goto-char pos) + (setq ts (org-delay arg time))) + (org-agenda-show-new-time marker ts " D")) + (message "%s" ts))) + +(define-key org-agenda-mode-map (kbd "C-c ") #'org-agenda-delay) + + +(provide 'org-delay) +;;; org-delay.el ends here diff --git a/lisp/org-project/opr-projects.el b/lisp/org-project/opr-projects.el index e499819..5b1c933 100644 --- a/lisp/org-project/opr-projects.el +++ b/lisp/org-project/opr-projects.el @@ -1,4 +1,4 @@ -;;; org-project-projects.el --- -*- lexical-binding: t -*- +;;; opr-projects.el --- -*- lexical-binding: t -*- ;; Copyright (C) 2019Benson Chu @@ -24,7 +24,7 @@ ;;; Code: -(require 'org-project-util) +(require 'opr-util) ;; Context sensitive (define-todo-keyword "META" 'project :color "white" :key ?m) @@ -80,9 +80,8 @@ ("ETERNAL" 'active) (t (when (or (not (member state opr/ambiguous)) (eq 'project (opr/ambiguous-task-or-project))) - (if (and (member state opr/strict-projects) - (org-time> (org-entry-get (point) "SCHEDULED") - (org-matcher-time ""))) + (if (org-time> (org-entry-get (point) "DELAYED") + (org-matcher-time "")) 'invis (pcase state ("EMPTY" (empty-status?)) @@ -95,4 +94,4 @@ (meta1-status?)))))))))) (provide 'opr-projects) -;;; org-project-projects.el ends here +;;; opr-projects.el ends here diff --git a/lisp/org-project/opr-tasks.el b/lisp/org-project/opr-tasks.el index df596b9..80ffe16 100644 --- a/lisp/org-project/opr-tasks.el +++ b/lisp/org-project/opr-tasks.el @@ -1,4 +1,4 @@ -;;; org-project-tasks.el --- -*- lexical-binding: t -*- +;;; opr-tasks.el --- -*- lexical-binding: t -*- ;; Copyright (C) 2019Benson Chu @@ -24,7 +24,7 @@ ;;; Code: -(require 'org-project-util) +(require 'opr-util) (define-todo-keyword "STUFF" 'task :color "goldenrod" :key ?s) @@ -74,4 +74,4 @@ 'stuck)))))) (provide 'opr-tasks) -;;; org-project-tasks.el ends here +;;; opr-tasks.el ends here diff --git a/lisp/org-project/org-project.el b/lisp/org-project/org-project.el index fcd4d94..78770bb 100644 --- a/lisp/org-project/org-project.el +++ b/lisp/org-project/org-project.el @@ -26,11 +26,12 @@ (require 'org) (require 'org-loop) -(require 'org-project-legacy) (require 'pcase) +(require 'org-delay) +(require 'org-project-legacy) ;; Import init function, opr/strict-projects, opr/ambiguous, and opr/strict-task -(load-file "./opr-util.el") +(require 'opr-util) (opr/init) @@ -94,7 +95,7 @@ 'task type))) - (defun opr/get-type-and-state () +(defun opr/get-type-and-state () (let* ((state (org-get-todo-state)) (type (cond ((member state opr/strict-projects) 'project) @@ -103,7 +104,7 @@ ((member state opr/ambiguous) (opr/ambiguous-task-or-project)) (t 'legacy)))) - (list (if (eq 'legacy type) + (cons (if (eq 'legacy type) 'task type) (pcase type @@ -113,7 +114,10 @@ (defun opr/print-type-and-state () (interactive) - (message "Headline has todo keyword \"%s\" and is \"%s\"" (opr/get-type))) + (let ((ts (opr/get-type-and-state))) + (message "Headline has todo keyword \"%s\" and is \"%s\"" + (car ts) + (cdr ts)))) (provide 'org-project) ;;; org-project.el ends here