浏览代码

org.el: New command `org-check-dates-range'.

* org.el (org-check-dates-range): New command.
(org-sparse-tree): Use it.

Thanks to Marc-Oliver Ihm for discussions and code
about similar features.
Bastien Guerry 13 年之前
父节点
当前提交
e5d5a1e721
共有 1 个文件被更改,包括 24 次插入1 次删除
  1. 24 1
      lisp/org.el

+ 24 - 1
lisp/org.el

@@ -12424,7 +12424,7 @@ b      Show deadlines and scheduled items before a date.
 a      Show deadlines and scheduled items after a date."
 a      Show deadlines and scheduled items after a date."
   (interactive "P")
   (interactive "P")
   (let (ans kwd value)
   (let (ans kwd value)
-    (message "Sparse tree: [r]egexp [/]regexp [t]odo [T]odo-kwd [m]atch [p]roperty\n             [d]eadlines [b]efore-date [a]fter-date")
+    (message "Sparse tree: [r]egexp [/]regexp [t]odo [T]odo-kwd [m]atch [p]roperty\n             [d]eadlines [b]efore-date [a]fter-date [D]ates range")
     (setq ans (read-char-exclusive))
     (setq ans (read-char-exclusive))
     (cond
     (cond
      ((equal ans ?d)
      ((equal ans ?d)
@@ -12433,6 +12433,8 @@ a      Show deadlines and scheduled items after a date."
       (call-interactively 'org-check-before-date))
       (call-interactively 'org-check-before-date))
      ((equal ans ?a)
      ((equal ans ?a)
       (call-interactively 'org-check-after-date))
       (call-interactively 'org-check-after-date))
+     ((equal ans ?D)
+      (call-interactively 'org-check-dates-range))
      ((equal ans ?t)
      ((equal ans ?t)
       (org-show-todo-tree nil))
       (org-show-todo-tree nil))
      ((equal ans ?T)
      ((equal ans ?T)
@@ -15546,6 +15548,27 @@ days.  If the prefix is a raw \\[universal-argument] prefix, all deadlines are s
     (message "%d entries after %s"
     (message "%d entries after %s"
 	     (org-occur regexp nil callback) date)))
 	     (org-occur regexp nil callback) date)))
 
 
+(defun org-check-dates-range (start-date end-date)
+  "Check for deadlines/scheduled entries between START-DATE and END-DATE."
+  (interactive (list (org-read-date nil nil nil "Range starts")
+		     (org-read-date nil nil nil "Range end")))
+  (let ((case-fold-search nil)
+	(regexp (concat "\\<\\(" org-deadline-string
+			"\\|" org-scheduled-string
+			"\\) *<\\([^>]+\\)>"))
+	(callback
+	 (lambda ()
+	   (let ((match (match-string 2)))
+	     (and
+	      (not (time-less-p
+		    (org-time-string-to-time match)
+		    (org-time-string-to-time start-date)))
+	      (time-less-p
+	       (org-time-string-to-time match)
+	       (org-time-string-to-time end-date)))))))
+    (message "%d entries between %s and %s"
+	     (org-occur regexp nil callback) start-date end-date)))
+
 (defun org-evaluate-time-range (&optional to-buffer)
 (defun org-evaluate-time-range (&optional to-buffer)
   "Evaluate a time range by computing the difference between start and end.
   "Evaluate a time range by computing the difference between start and end.
 Normally the result is just printed in the echo area, but with prefix arg
 Normally the result is just printed in the echo area, but with prefix arg