Browse Source

Agenda: A tags-todo search can now ignore timestamped items

The variables =org-agenda-todo-ignore-with-date=,
=org-agenda-todo-ignore-with-date=, and
=org-agenda-todo-ignore-with-date= make it possible to
exclude TODO entries which have this kind of planning info
associated with them.  This is most useful for people who
schedule everything, and who use the TODO list mainly to find
things that are not yet scheduled.  Thomas Morgan pointed out
that also the tags-todo search may serve exactly this
purpose, and that it might be good to have a way to make
these variables also apply to the tags-todo search.  I can
see than, but could not convince myself to make this the
default.  A new variable must be set to make this happen:
=org-agenda-tags-todo-honor-ignore-options=.
Carsten Dominik 16 years ago
parent
commit
3fed83614e
4 changed files with 90 additions and 20 deletions
  1. 15 0
      ORGWEBPAGE/Changes.org
  2. 13 0
      lisp/ChangeLog
  3. 53 18
      lisp/org-agenda.el
  4. 9 2
      lisp/org.el

+ 15 - 0
ORGWEBPAGE/Changes.org

@@ -65,6 +65,21 @@ table.  Note that since there is no "current filed" for the
 cursor, all row and column references must be absolute, not
 cursor, all row and column references must be absolute, not
 relative.
 relative.
 
 
+*** A tags-todo search can now ignore timestamped items
+    The variables =org-agenda-todo-ignore-with-date=,
+    =org-agenda-todo-ignore-with-date=, and
+    =org-agenda-todo-ignore-with-date= make it possible to
+    exclude TODO entries which have this kind of planning info
+    associated with them.  This is most useful for people who
+    schedule everything, and who use the TODO list mainly to find
+    things that are not yet scheduled.  Thomas Morgan pointed out
+    that also the tags-todo search may serve exactly this
+    purpose, and that it might be good to have a way to make
+    these variables also apply to the tags-todo search.  I can
+    see than, but could not convince myself to make this the
+    default.  A new variable must be set to make this happen:
+    =org-agenda-tags-todo-honor-ignore-options=.
+
 * Version 6.18
 * Version 6.18
 ** Incompatible changes
 ** Incompatible changes
 
 

+ 13 - 0
lisp/ChangeLog

@@ -1,3 +1,16 @@
+2009-01-25  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-scan-tags): Call
+	`org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item'.
+
+	* org-agenda.el (org-agenda-todo-list, org-agenda-match-view): New
+	customization groups.
+	(org-agenda-tags-todo-honor-ignore-options): New option.
+	(org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item):
+	New function.
+	(org-agenda-get-todos): Use
+	`org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item'.
+
 2009-01-24  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-01-24  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org-exp.el (org-export-format-source-code-or-example): Escape
 	* org-exp.el (org-export-format-source-code-or-example): Escape

+ 53 - 18
lisp/org-agenda.el

@@ -409,6 +409,18 @@ this one will be used."
  "Options concerning skipping parts of agenda files."
  "Options concerning skipping parts of agenda files."
  :tag "Org Agenda Skip"
  :tag "Org Agenda Skip"
  :group 'org-agenda)
  :group 'org-agenda)
+(defgroup org-agenda-daily/weekly nil
+  "Options concerning the daily/weekly agenda."
+  :tag "Org Agenda Daily/Weekly"
+  :group 'org-agenda)
+(defgroup org-agenda-todo-list nil
+  "Options concerning the global todo list agenda view."
+  :tag "Org Agenda Todo List"
+  :group 'org-agenda)
+(defgroup org-agenda-match-view nil
+  "Options concerning the general tags/property/todo match agenda view."
+  :tag "Org Agenda Match View"
+  :group 'org-agenda)
 
 
 (defvar org-agenda-archives-mode nil
 (defvar org-agenda-archives-mode nil
   "Non-nil means, the agenda will include archived items.
   "Non-nil means, the agenda will include archived items.
@@ -428,7 +440,7 @@ When nil, these trees are also scanned by agenda commands."
 When nil, the sublevels of a TODO entry are not checked, resulting in
 When nil, the sublevels of a TODO entry are not checked, resulting in
 potentially much shorter TODO lists."
 potentially much shorter TODO lists."
   :group 'org-agenda-skip
   :group 'org-agenda-skip
-  :group 'org-todo
+  :group 'org-agenda-todo-list
   :type 'boolean)
   :type 'boolean)
 
 
 (defcustom org-agenda-todo-ignore-with-date nil
 (defcustom org-agenda-todo-ignore-with-date nil
@@ -439,7 +451,7 @@ When this is set, it also covers deadlines and scheduled items, the settings
 of `org-agenda-todo-ignore-scheduled' and `org-agenda-todo-ignore-deadlines'
 of `org-agenda-todo-ignore-scheduled' and `org-agenda-todo-ignore-deadlines'
 will be ignored."
 will be ignored."
   :group 'org-agenda-skip
   :group 'org-agenda-skip
-  :group 'org-todo
+  :group 'org-agenda-todo-list
   :type 'boolean)
   :type 'boolean)
 
 
 (defcustom org-agenda-todo-ignore-scheduled nil
 (defcustom org-agenda-todo-ignore-scheduled nil
@@ -448,7 +460,7 @@ The idea behind this is that by scheduling it, you have already taken care
 of this item.
 of this item.
 See also `org-agenda-todo-ignore-with-date'."
 See also `org-agenda-todo-ignore-with-date'."
   :group 'org-agenda-skip
   :group 'org-agenda-skip
-  :group 'org-todo
+  :group 'org-agenda-todo-list
   :type 'boolean)
   :type 'boolean)
 
 
 (defcustom org-agenda-todo-ignore-deadlines nil
 (defcustom org-agenda-todo-ignore-deadlines nil
@@ -457,7 +469,22 @@ Near means closer than `org-deadline-warning-days' days.
 The idea behind this is that such items will appear in the agenda anyway.
 The idea behind this is that such items will appear in the agenda anyway.
 See also `org-agenda-todo-ignore-with-date'."
 See also `org-agenda-todo-ignore-with-date'."
   :group 'org-agenda-skip
   :group 'org-agenda-skip
-  :group 'org-todo
+  :group 'org-agenda-todo-list
+  :type 'boolean)
+
+(defcustom org-agenda-tags-todo-honor-ignore-options nil
+  "Non-nil means, honor todo-list ...ignore options also in tags-todo search.
+The variables
+   `org-agenda-todo-ignore-with-date',
+   `org-agenda-todo-ignore-scheduled' 
+   `org-agenda-todo-ignore-deadlines'
+make the global TODO list skip entries that have time stamps of certain
+kinds.  If this option is set, the same options will also apply for the
+tags-todo search, which is the general tags/property matcher
+restricted to unfinished TODO entries only."
+  :group 'org-agenda-skip
+  :group 'org-agenda-todo-list
+  :group 'org-agenda-match-view
   :type 'boolean)
   :type 'boolean)
 
 
 (defcustom org-agenda-skip-scheduled-if-done nil
 (defcustom org-agenda-skip-scheduled-if-done nil
@@ -467,6 +494,7 @@ it applies only to the actual date of the scheduling.  Warnings about
 an item with a past scheduling dates are always turned off when the item
 an item with a past scheduling dates are always turned off when the item
 is DONE."
 is DONE."
   :group 'org-agenda-skip
   :group 'org-agenda-skip
+  :group 'org-agenda-daily/weekly
   :type 'boolean)
   :type 'boolean)
 
 
 (defcustom org-agenda-skip-deadline-if-done nil
 (defcustom org-agenda-skip-deadline-if-done nil
@@ -476,11 +504,13 @@ This is relevant for the daily/weekly agenda.  And it applied only to the
 actually date of the deadline.  Warnings about approaching and past-due
 actually date of the deadline.  Warnings about approaching and past-due
 deadlines are always turned off when the item is DONE."
 deadlines are always turned off when the item is DONE."
   :group 'org-agenda-skip
   :group 'org-agenda-skip
+  :group 'org-agenda-daily/weekly
   :type 'boolean)
   :type 'boolean)
 
 
 (defcustom org-agenda-skip-timestamp-if-done nil
 (defcustom org-agenda-skip-timestamp-if-done nil
   "Non-nil means don't select item by timestamp or -range if it is DONE."
   "Non-nil means don't select item by timestamp or -range if it is DONE."
   :group 'org-agenda-skip
   :group 'org-agenda-skip
+  :group 'org-agenda-daily/weekly
   :type 'boolean)
   :type 'boolean)
 
 
 (defcustom org-timeline-show-empty-dates 3
 (defcustom org-timeline-show-empty-dates 3
@@ -559,11 +589,6 @@ option will be ignored.."
   :group 'org-agenda-windows
   :group 'org-agenda-windows
   :type 'boolean)
   :type 'boolean)
 
 
-(defgroup org-agenda-daily/weekly nil
-  "Options concerning the daily/weekly agenda."
-  :tag "Org Agenda Daily/Weekly"
-  :group 'org-agenda)
-
 (defcustom org-agenda-ndays 7
 (defcustom org-agenda-ndays 7
   "Number of days to include in overview display.
   "Number of days to include in overview display.
 Should be 1 or 7."
 Should be 1 or 7."
@@ -640,7 +665,8 @@ and timeline buffers."
 (defcustom org-agenda-include-all-todo nil
 (defcustom org-agenda-include-all-todo nil
   "Set  means weekly/daily agenda will always contain all TODO entries.
   "Set  means weekly/daily agenda will always contain all TODO entries.
 The TODO entries will be listed at the top of the agenda, before
 The TODO entries will be listed at the top of the agenda, before
-the entries for specific days."
+the entries for specific days.
+This option is deprecated, it is better to define a block agenda instead."
   :group 'org-agenda-daily/weekly
   :group 'org-agenda-daily/weekly
   :type 'boolean)
   :type 'boolean)
 
 
@@ -1000,7 +1026,6 @@ or a list like `(:background \"Red\")'."
 		  (list (character :tag "Priority" :value ?A)
 		  (list (character :tag "Priority" :value ?A)
 			(sexp :tag "face")))))
 			(sexp :tag "face")))))
 
 
-
 (defgroup org-agenda-column-view nil
 (defgroup org-agenda-column-view nil
   "Options concerning column view in the agenda."
   "Options concerning column view in the agenda."
   :tag "Org Agenda Column View"
   :tag "Org Agenda Column View"
@@ -3248,13 +3273,7 @@ the documentation of `org-diary'."
 	(save-match-data
 	(save-match-data
 	  (beginning-of-line)
 	  (beginning-of-line)
 	  (setq beg (point) end (progn (outline-next-heading) (point)))
 	  (setq beg (point) end (progn (outline-next-heading) (point)))
-	  (when (or (and org-agenda-todo-ignore-with-date (goto-char beg)
-			 (re-search-forward org-ts-regexp end t))
-		    (and org-agenda-todo-ignore-scheduled (goto-char beg)
-			 (re-search-forward org-scheduled-time-regexp end t))
-		    (and org-agenda-todo-ignore-deadlines (goto-char beg)
-			 (re-search-forward org-deadline-time-regexp end t)
-			 (org-deadline-close (match-string 1))))
+	  (when (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item end)
 	    (goto-char (1+ beg))
 	    (goto-char (1+ beg))
 	    (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible))
 	    (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible))
 	    (throw :skip nil)))
 	    (throw :skip nil)))
@@ -3277,6 +3296,22 @@ the documentation of `org-diary'."
 	  (org-end-of-subtree 'invisible))))
 	  (org-end-of-subtree 'invisible))))
     (nreverse ee)))
     (nreverse ee)))
 
 
+;;;###autoload
+(defun org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item (&optional end)
+  "Do we have a reason to ignore this todo entry because it has a time stamp?"
+  (when (or org-agenda-todo-ignore-with-date
+	    org-agenda-todo-ignore-scheduled
+	    org-agenda-todo-ignore-deadlines)
+    (setq end (or end (save-excursion (outline-next-heading) (point))))
+    (save-excursion
+      (or (and org-agenda-todo-ignore-with-date
+	       (re-search-forward org-ts-regexp end t))
+	  (and org-agenda-todo-ignore-scheduled
+	       (re-search-forward org-scheduled-time-regexp end t))
+	  (and org-agenda-todo-ignore-deadlines
+	       (re-search-forward org-deadline-time-regexp end t)
+	       (org-deadline-close (match-string 1)))))))
+
 (defconst org-agenda-no-heading-message
 (defconst org-agenda-no-heading-message
   "No heading for this item in buffer or region.")
   "No heading for this item in buffer or region.")
 
 

+ 9 - 2
lisp/org.el

@@ -2497,6 +2497,9 @@ Normal means, no org-mode-specific context."
 (declare-function org-agenda-save-markers-for-cut-and-paste "org-agenda"
 (declare-function org-agenda-save-markers-for-cut-and-paste "org-agenda"
 		  (beg end))
 		  (beg end))
 (declare-function org-agenda-copy-local-variable "org-agenda" (var))
 (declare-function org-agenda-copy-local-variable "org-agenda" (var))
+(declare-function org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item
+		  "org-agenda" (&optional end))
+
 (declare-function parse-time-string "parse-time" (string))
 (declare-function parse-time-string "parse-time" (string))
 (declare-function remember "remember" (&optional initial))
 (declare-function remember "remember" (&optional initial))
 (declare-function remember-buffer-desc "remember" ())
 (declare-function remember-buffer-desc "remember" ())
@@ -2651,7 +2654,8 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
   (org-autoload "org-agenda"
   (org-autoload "org-agenda"
 		'(org-agenda org-agenda-list org-search-view
 		'(org-agenda org-agenda-list org-search-view
    org-todo-list org-tags-view org-agenda-list-stuck-projects
    org-todo-list org-tags-view org-agenda-list-stuck-projects
-   org-diary org-agenda-to-appt)))
+   org-diary org-agenda-to-appt
+   org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item)))
 
 
 ;; Autoload org-remember
 ;; Autoload org-remember
 
 
@@ -9327,7 +9331,10 @@ only lines with a TODO keyword are included in the output."
 	    ;; selective inheritance, remove uninherited ones
 	    ;; selective inheritance, remove uninherited ones
 	    (setcdr (car tags-alist)
 	    (setcdr (car tags-alist)
 		    (org-remove-uniherited-tags (cdar tags-alist))))
 		    (org-remove-uniherited-tags (cdar tags-alist))))
-	  (when (and (or (not todo-only) (member todo org-not-done-keywords))
+	  (when (and (or (not todo-only)
+			 (and (member todo org-not-done-keywords)
+			      (or (not org-agenda-tags-todo-honor-ignore-options)
+				  (not (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item)))))
 		     (let ((case-fold-search t)) (eval matcher))
 		     (let ((case-fold-search t)) (eval matcher))
 		     (or
 		     (or
 		      (not (member org-archive-tag tags-list))
 		      (not (member org-archive-tag tags-list))