浏览代码

org-agenda.el: Allow to use holiday strings for the `skip-weeks' arguments

* org-agenda.el (org-class): Allow to use holiday strings for
the `skip-weeks' arguments.

Thanks to Enda for this suggestion.

For example, this task will now be skipped only on new year's day:

* Task
  <%%(org-class 2012 1 1 2013 12 12 2 "New Year's Day")>
Bastien Guerry 12 年之前
父节点
当前提交
9b67fb855a
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      lisp/org-agenda.el

+ 6 - 4
lisp/org-agenda.el

@@ -5292,10 +5292,12 @@ 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.  If any of the SKIP-WEEKS arguments is the symbol
 `holidays', then any date that is known by the Emacs calendar to be a
-holiday will also be skipped."
+holiday will also be skipped.  If SKIP-WEEKS arguments are holiday strings,
+then those holidays will be skipped."
   (let* ((date1 (calendar-absolute-from-gregorian (list m1 d1 y1)))
 	 (date2 (calendar-absolute-from-gregorian (list m2 d2 y2)))
-	 (d (calendar-absolute-from-gregorian date)))
+	 (d (calendar-absolute-from-gregorian date))
+	 (h (when skip-weeks (calendar-check-holidays date))))
     (and
      (<= date1 d)
      (<= d date2)
@@ -5304,8 +5306,8 @@ holiday will also be skipped."
 	 (progn
 	   (require 'cal-iso)
 	   (not (member (car (calendar-iso-from-absolute d)) skip-weeks))))
-     (not (and (memq 'holidays skip-weeks)
-	       (calendar-check-holidays date)))
+     (not (or (and h (memq 'holidays skip-weeks))
+	      (delq nil (mapcar (lambda(g) (member g skip-weeks)) h))))
      entry)))
 
 (defun org-diary-class (m1 d1 y1 m2 d2 y2 dayname &rest skip-weeks)