emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add new '[not]todo-unblocked tests to org-agenda-skip-if
@ 2012-02-12 21:18 Toby Cubitt
  2012-04-20 11:59 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Toby Cubitt @ 2012-02-12 21:18 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 877 bytes --]

This patch adds two new tests to `org-agenda-skip-if': 'todo-unblocked
and 'nottodo-unblocked. These match like 'todo and 'nottodo, but only on
unblocked todo items. This type of test is useful when compiling custom
agenda views containing lists of currently actionable todo items.

Whilst it's possible to code such tests in `org-agenda-custom-commands'
directly (well, Elisp is Turing-complete: you can in principle code
anything!), it's far less convenient than a simple `org-agenda-skip-if'
test which can reuse much of the existing machinery.

Note that the attached patch applies on top of my other "Fix
org-agenda-skip-if bug" patch, though this new feature is independent of
that bug-fix.

Toby
-- 
Dr T. S. Cubitt
Mathematics and Quantum Information group
Department of Mathematics
Complutense University
Madrid, Spain

email: tsc25@cantab.net
web:   www.dr-qubit.org

[-- Attachment #2: 0002-Agenda-Add-new-todo-unblocked-and-nottodo-unblocked-.patch --]
[-- Type: text/x-patch, Size: 2468 bytes --]

From 4e52c8c724f57c981206dbffff18c95f9fe285af Mon Sep 17 00:00:00 2001
From: Toby S. Cubitt <tsc25@cantab.net>
Date: Sat, 28 Jan 2012 18:26:21 +0100
Subject: [PATCH 2/2] Agenda: Add new todo-unblocked and nottodo-unblocked skip conditions

* lisp/org-agenda.el (org-agenda-skip-if, org-agenda-skip-if-todo):
Add new todo-unblocked and nottodo-unblocked skip conditions. These
match as for todo and nottodo, but only for unblocked todo items.
---
 lisp/org-agenda.el |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index ad706eb..d411732 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4286,15 +4286,18 @@ that can be put into `org-agenda-skip-function' for the duration of a command."
 	   (not (re-search-forward (nth 1 m) end t)))
       (and (or
 	    (setq m (memq 'nottodo conditions))
+	    (setq m (memq 'todo-unblocked conditions))
+	    (setq m (memq 'nottodo-unblocked conditions))
 	    (setq m (memq 'todo conditions)))
 	   (org-agenda-skip-if-todo m end)))
      end)))
 
 (defun org-agenda-skip-if-todo (args end)
   "Helper function for `org-agenda-skip-if', do not use it directly.
-ARGS is a list with first element either `todo' or `nottodo'.
-The remainder is either a list of TODO keywords, or a state symbol
-`todo' or `done' or `any'."
+ARGS is a list with first element either `todo', `nottodo',
+`todo-unblocked' or `nottodo-unblocked'. The remainder is either
+a list of TODO keywords, or a state symbol `todo' or `done' or
+`any'."
   (let ((kw (car args))
 	(arg (cadr args))
 	todo-wds todo-re)
@@ -4318,9 +4321,20 @@ The remainder is either a list of TODO keywords, or a state symbol
 	  (concat "^\\*+[ \t]+\\<\\("
 		  (mapconcat 'identity todo-wds  "\\|")
 		  "\\)\\>"))
-    (if (eq kw 'todo)
-	(re-search-forward todo-re end t)
-      (not (re-search-forward todo-re end t)))))
+    (cond
+     ((eq kw 'todo) (re-search-forward todo-re end t))
+     ((eq kw 'nottodo) (not (re-search-forward todo-re end t)))
+     ((eq kw 'todo-unblocked)
+      (catch 'unblocked
+	(while (re-search-forward todo-re end t)
+	  (or (org-entry-blocked-p) (throw 'unblocked t)))
+	nil))
+     ((eq kw 'nottodo-unblocked)
+      (catch 'unblocked
+	(while (re-search-forward todo-re end t)
+	  (or (org-entry-blocked-p) (throw 'unblocked nil)))
+	t))
+     )))
 
 ;;;###autoload
 (defun org-agenda-list-stuck-projects (&rest ignore)
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add new '[not]todo-unblocked tests to org-agenda-skip-if
  2012-02-12 21:18 [PATCH] Add new '[not]todo-unblocked tests to org-agenda-skip-if Toby Cubitt
@ 2012-04-20 11:59 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2012-04-20 11:59 UTC (permalink / raw)
  To: emacs-orgmode

Toby Cubitt <tsc25@cantab.net> writes:

> This patch adds two new tests to `org-agenda-skip-if': 'todo-unblocked
> and 'nottodo-unblocked. These match like 'todo and 'nottodo, but only on
> unblocked todo items. This type of test is useful when compiling custom
> agenda views containing lists of currently actionable todo items.

Applied, thanks!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-20 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-12 21:18 [PATCH] Add new '[not]todo-unblocked tests to org-agenda-skip-if Toby Cubitt
2012-04-20 11:59 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).