Browse Source

Fix false positive SCHEDULED lines in sparse tree

* lisp/org.el (org-check-before-date, org-check-after-date,
  org-check-dates-range): Make sure we're really at a timestamp before
  validating the entry.

Reported-by: James Harkins <jamshark70@qq.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/93126>
Nicolas Goaziou 6 years ago
parent
commit
c6d9a4ec22
1 changed files with 26 additions and 16 deletions
  1. 26 16
      lisp/org.el

+ 26 - 16
lisp/org.el

@@ -17289,9 +17289,13 @@ both scheduled and deadline timestamps."
   (let ((case-fold-search nil)
 	(regexp (org-re-timestamp org-ts-type))
 	(callback
-	 (lambda () (time-less-p
-		     (org-time-string-to-time (match-string 1))
-		     (org-time-string-to-time date)))))
+	 `(lambda ()
+	    (and ,(if (memq org-ts-type '(active inactive all))
+		      '(eq (org-element-type (org-element-context) 'timestamp))
+		    '(org-at-planning-p))
+		 (time-less-p
+		  (org-time-string-to-time (match-string 1))
+		  (org-time-string-to-time date))))))
     (message "%d entries before %s"
 	     (org-occur regexp nil callback) date)))
 
@@ -17301,10 +17305,13 @@ both scheduled and deadline timestamps."
   (let ((case-fold-search nil)
 	(regexp (org-re-timestamp org-ts-type))
 	(callback
-	 (lambda () (not
-		     (time-less-p
-		      (org-time-string-to-time (match-string 1))
-		      (org-time-string-to-time date))))))
+	 `(lambda ()
+	    (and ,(if (memq org-ts-type '(active inactive all))
+		      '(eq (org-element-type (org-element-context) 'timestamp))
+		    '(org-at-planning-p))
+		 (not (time-less-p
+		       (org-time-string-to-time (match-string 1))
+		       (org-time-string-to-time date)))))))
     (message "%d entries after %s"
 	     (org-occur regexp nil callback) date)))
 
@@ -17315,15 +17322,18 @@ both scheduled and deadline timestamps."
   (let ((case-fold-search nil)
 	(regexp (org-re-timestamp org-ts-type))
 	(callback
-	 (lambda ()
-	   (let ((match (match-string 1)))
-	     (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)))))))
+	 `(lambda ()
+	    (let ((match (match-string 1)))
+	      (and
+	       ,(if (memq org-ts-type '(active inactive all))
+		    '(eq (org-element-type (org-element-context) 'timestamp))
+		  '(org-at-planning-p))
+	       (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)))