Browse Source

Merge branch 'bugfix'

Ihor Radchenko 3 years ago
parent
commit
6304afcaa4
3 changed files with 36 additions and 5 deletions
  1. 7 2
      lisp/org.el
  2. 4 0
      testing/examples/agenda-file.org
  3. 25 3
      testing/lisp/test-org-agenda.el

+ 7 - 2
lisp/org.el

@@ -15254,7 +15254,11 @@ When matching, the match groups are the following:
   group 4: day name
   group 4: day name
   group 5: hours, if any
   group 5: hours, if any
   group 6: minutes, if any"
   group 6: minutes, if any"
-  (let* ((regexp (if extended org-ts-regexp3 org-ts-regexp2))
+  (let* ((regexp (if extended
+                     (if (eq extended 'agenda)
+                         org-element--timestamp-regexp
+		       org-ts-regexp3)
+                   org-ts-regexp2))
 	 (pos (point))
 	 (pos (point))
 	 (match?
 	 (match?
 	  (let ((boundaries (org-in-regexp regexp)))
 	  (let ((boundaries (org-in-regexp regexp)))
@@ -15285,7 +15289,8 @@ When matching, the match groups are the following:
      ((org-pos-in-match-range pos 8)      'minute)
      ((org-pos-in-match-range pos 8)      'minute)
      ((or (org-pos-in-match-range pos 4)
      ((or (org-pos-in-match-range pos 4)
 	  (org-pos-in-match-range pos 5)) 'day)
 	  (org-pos-in-match-range pos 5)) 'day)
-     ((and (> pos (or (match-end 8) (match-end 5)))
+     ((and (or (match-end 8) (match-end 5))
+           (> pos (or (match-end 8) (match-end 5)))
 	   (< pos (match-end 0)))
 	   (< pos (match-end 0)))
       (- pos (or (match-end 8) (match-end 5))))
       (- pos (or (match-end 8) (match-end 5))))
      (t                                   'day))))
      (t                                   'day))))

+ 4 - 0
testing/examples/agenda-file.org

@@ -20,3 +20,7 @@ SCHEDULED: <2022-01-03 Mon>
 :PROPERTIES:
 :PROPERTIES:
 :CREATED: <2022-03-22 Tue>
 :CREATED: <2022-03-22 Tue>
 :END:
 :END:
+* test sexp timestamp inside properties
+:PROPERTIES:
+:CREATED: <%%(diary-date 03 25 2022)>
+:END:

+ 25 - 3
testing/lisp/test-org-agenda.el

@@ -72,6 +72,9 @@
   (let ((org-agenda-span 'day)
   (let ((org-agenda-span 'day)
 	(org-agenda-files `(,(expand-file-name "examples/agenda-file.org"
 	(org-agenda-files `(,(expand-file-name "examples/agenda-file.org"
 					       org-test-dir))))
 					       org-test-dir))))
+    ;; NOTE: Be aware that `org-agenda-list' may or may not display
+    ;; past scheduled items depending whether the date is today
+    ;; `org-today' or not.
     (org-agenda-list nil  "<2017-03-10 Fri>")
     (org-agenda-list nil  "<2017-03-10 Fri>")
     (set-buffer org-agenda-buffer-name)
     (set-buffer org-agenda-buffer-name)
     (should (= 3 (count-lines (point-min) (point-max)))))
     (should (= 3 (count-lines (point-min) (point-max)))))
@@ -85,6 +88,9 @@
   (let ((org-agenda-span 'day)
   (let ((org-agenda-span 'day)
 	(org-agenda-files `(,(expand-file-name "examples/agenda-file.org"
 	(org-agenda-files `(,(expand-file-name "examples/agenda-file.org"
 					       org-test-dir))))
 					       org-test-dir))))
+    ;; NOTE: Be aware that `org-agenda-list' may or may not display
+    ;; past scheduled items depending whether the date is today
+    ;; `org-today' or not.
     (org-agenda-list nil "<2017-07-19 Wed>")
     (org-agenda-list nil "<2017-07-19 Wed>")
     (set-buffer org-agenda-buffer-name)
     (set-buffer org-agenda-buffer-name)
     (should
     (should
@@ -101,6 +107,9 @@ See https://list.orgmode.org/20220101200103.GB29829@itccanarias.org/T/#t."
   (let ((org-agenda-span 'day)
   (let ((org-agenda-span 'day)
 	(org-agenda-files `(,(expand-file-name "examples/agenda-file.org"
 	(org-agenda-files `(,(expand-file-name "examples/agenda-file.org"
 					       org-test-dir))))
 					       org-test-dir))))
+    ;; NOTE: Be aware that `org-agenda-list' may or may not display
+    ;; past scheduled items depending whether the date is today
+    ;; `org-today' or not.
     (org-agenda-list nil "<2022-01-03 Mon>")
     (org-agenda-list nil "<2022-01-03 Mon>")
     (set-buffer org-agenda-buffer-name)
     (set-buffer org-agenda-buffer-name)
     (should (= 2 (count-lines (point-min) (point-max)))))
     (should (= 2 (count-lines (point-min) (point-max)))))
@@ -115,10 +124,18 @@ See https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com"
   (let ((org-agenda-span 'day)
   (let ((org-agenda-span 'day)
 	(org-agenda-files `(,(expand-file-name "examples/agenda-file.org"
 	(org-agenda-files `(,(expand-file-name "examples/agenda-file.org"
 					       org-test-dir))))
 					       org-test-dir))))
+    ;; NOTE: Be aware that `org-agenda-list' may or may not display
+    ;; past scheduled items depending whether the date is today
+    ;; `org-today' or not.
     (org-agenda-list nil "<2022-03-22 Tue>")
     (org-agenda-list nil "<2022-03-22 Tue>")
     (set-buffer org-agenda-buffer-name)
     (set-buffer org-agenda-buffer-name)
-    (message "%s" (buffer-string))
-    (should (= 4 (count-lines (point-min) (point-max)))))
+    (should (= 3 (count-lines (point-min) (point-max))))
+    ;; NOTE: Be aware that `org-agenda-list' may or may not display
+    ;; past scheduled items depending whether the date is today
+    ;; `org-today' or not.
+    (org-agenda-list nil "<2022-03-25 Fri>")
+    (set-buffer org-agenda-buffer-name)
+    (should (= 3 (count-lines (point-min) (point-max)))))
   (org-test-agenda--kill-all-agendas))
   (org-test-agenda--kill-all-agendas))
 
 
 (ert-deftest test-org-agenda/set-priority ()
 (ert-deftest test-org-agenda/set-priority ()
@@ -129,9 +146,11 @@ See https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com"
   (let ((org-agenda-span 'day)
   (let ((org-agenda-span 'day)
 	(org-agenda-files `(,(expand-file-name "examples/agenda-file.org"
 	(org-agenda-files `(,(expand-file-name "examples/agenda-file.org"
 					       org-test-dir))))
 					       org-test-dir))))
+    ;; NOTE: Be aware that `org-agenda-list' may or may not display
+    ;; past scheduled items depending whether the date is today
+    ;; `org-today' or not.
     (org-agenda-list nil "<2017-07-19 Wed>")
     (org-agenda-list nil "<2017-07-19 Wed>")
     (set-buffer org-agenda-buffer-name)
     (set-buffer org-agenda-buffer-name)
-
     (should
     (should
      (progn (goto-line 3)
      (progn (goto-line 3)
 	    (org-agenda-priority ?B)
 	    (org-agenda-priority ?B)
@@ -224,6 +243,9 @@ See https://list.orgmode.org/06d301d83d9e$f8b44340$ea1cc9c0$@tomdavey.com"
 			    (dayname "\\W")))
 			    (dayname "\\W")))
 	(org-agenda-span 'day)
 	(org-agenda-span 'day)
 	(org-agenda-include-diary t))
 	(org-agenda-include-diary t))
+    ;; NOTE: Be aware that `org-agenda-list' may or may not display
+    ;; past scheduled items depending whether the date is today
+    ;; `org-today' or not.
     (org-agenda-list nil "<2019-01-08>")
     (org-agenda-list nil "<2019-01-08>")
     (should (search-forward "f0bcf0cd8bad93c1451bb6e1b2aaedef5cce7cbb" nil t))
     (should (search-forward "f0bcf0cd8bad93c1451bb6e1b2aaedef5cce7cbb" nil t))
     (org-test-agenda--kill-all-agendas)))
     (org-test-agenda--kill-all-agendas)))