Browse Source

New function `org-diary-schedule' to schedule classes with skipped weeks.

This is modified from a proposal by Daniel Martins.
Carsten Dominik 15 years ago
parent
commit
1951c6202a
2 changed files with 31 additions and 0 deletions
  1. 4 0
      lisp/ChangeLog
  2. 27 0
      lisp/org-agenda.el

+ 4 - 0
lisp/ChangeLog

@@ -1,3 +1,7 @@
+2009-12-28  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-agenda.el (org-diary-class): New function.
+
 2009-12-24  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-latex.el (org-export-latex-preprocess): Do process the text

+ 27 - 0
lisp/org-agenda.el

@@ -4154,6 +4154,33 @@ the documentation of `org-diary'."
 	  (push txt ee))))
     (nreverse ee)))
 
+(defun org-diary-class (m1 d1 y1 m2 d2 y2 dayname &rest skip-weeks)
+  "Entry applies if date is between dates on DAYNAME, but skips SKIP-WEEKS.
+Order of the parameters is M1, D1, Y1, M2, D2, Y2 if
+`european-calendar-style' is nil, and D1, M1, Y1, D2, M2, Y2 if
+`european-calendar-style' is t.  
+DAYNAME is a number between 0 (Sunday) and 6 (Saturday).  SKIP-WEEKS
+is any number of ISO weeks in the block period for which the item should
+be skipped."
+  (let* ((date1 (calendar-absolute-from-gregorian
+		 (if european-calendar-style
+		     (list d1 m1 y1)
+		   (list m1 d1 y1))))
+	 (date2 (calendar-absolute-from-gregorian
+		 (if european-calendar-style
+		     (list d2 m2 y2)
+		   (list m2 d2 y2))))
+	 (d (calendar-absolute-from-gregorian date)))
+    (and
+     (<= date1 d)
+     (<= d date2)
+     (= (calendar-day-of-week date) dayname)
+     (or (not skip-weeks)
+	 (progn
+	   (require 'cal-iso)
+	   (not (member (car (calendar-iso-from-absolute d)) skip-weeks))))
+     entry)))
+
 (defalias 'org-get-closed 'org-agenda-get-progress)
 (defun org-agenda-get-progress ()
   "Return the logged TODO entries for agenda display."