Merge: Match timestamps with inner time ranges
Note that this is a form of basic, initial support. More comprehensive support will require refactoring of how timestamp values are handled, which is deferred until a future version. See <https://github.com/alphapapa/org-ql/pull/237> and <https://github.com/alphapapa/org-ql/issues/371>. Reported-by: Ihor Radchenko <yantar92@gmail.com>
This commit is contained in:
commit
4af08e37f9
5 changed files with 107 additions and 45 deletions
|
|
@ -555,7 +555,8 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
|
|||
|
||||
** 0.8.7-pre
|
||||
|
||||
Nothing new yet.
|
||||
*Fixes*
|
||||
+ Timestamps with internal time ranges (e.g. ~<2024-06-26 10:00-11:00>~) are matched for simple queries. (This support is not yet comprehensive, e.g. a query that depends on the specific inner time range may not behave as expected. Previously such timestamps were not matched at all. See [[https://github.com/alphapapa/org-ql/pull/237][#237]] and [[https://github.com/alphapapa/org-ql/issues/371][#371]]. Thanks to [[https://github.com/yantar92][Ihor Radchenko]].)
|
||||
|
||||
** 0.8.6
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,8 @@ regexps.")
|
|||
Includes leading space character.")
|
||||
|
||||
(defvar org-ql-regexp-part-ts-time
|
||||
(rx " " (repeat 1 2 digit) ":" (repeat 2 digit))
|
||||
(rx " " (repeat 1 2 digit) ":" (repeat 2 digit)
|
||||
(optional "-" (repeat 1 2 digit) ":" (repeat 2 digit)))
|
||||
"Matches the inner, time part of an Org timestamp (i.e. HH:MM).
|
||||
Includes leading space character. Used to build other timestamp
|
||||
regexps.")
|
||||
|
|
|
|||
92
org-ql.info
92
org-ql.info
|
|
@ -1080,7 +1080,15 @@ File: README.info, Node: 087-pre, Next: 086, Up: Changelog
|
|||
5.1 0.8.7-pre
|
||||
=============
|
||||
|
||||
Nothing new yet.
|
||||
*Fixes*
|
||||
• Timestamps with internal time ranges (e.g. ‘<2024-06-26
|
||||
10:00-11:00>’) are matched for simple queries. (This support is
|
||||
not yet comprehensive, e.g. a query that depends on the specific
|
||||
inner time range may not behave as expected. Previously such
|
||||
timestamps were not matched at all. See #237
|
||||
(https://github.com/alphapapa/org-ql/pull/237) and #371
|
||||
(https://github.com/alphapapa/org-ql/issues/371). Thanks to Ihor
|
||||
Radchenko (https://github.com/yantar92).)
|
||||
|
||||
|
||||
File: README.info, Node: 086, Next: 085, Prev: 087-pre, Up: Changelog
|
||||
|
|
@ -2010,47 +2018,47 @@ Node: Links38911
|
|||
Node: Tips39598
|
||||
Node: Changelog39922
|
||||
Node: 087-pre40844
|
||||
Node: 08640956
|
||||
Node: 08541194
|
||||
Node: 08441850
|
||||
Node: 08342302
|
||||
Node: 08242643
|
||||
Node: 08143036
|
||||
Node: 0843457
|
||||
Node: 07446181
|
||||
Node: 07346404
|
||||
Node: 07247138
|
||||
Node: 07148059
|
||||
Node: 0748870
|
||||
Node: 06351736
|
||||
Node: 06252269
|
||||
Node: 06152576
|
||||
Node: 0653146
|
||||
Node: 05256202
|
||||
Node: 05156504
|
||||
Node: 0556929
|
||||
Node: 04958460
|
||||
Node: 04858742
|
||||
Node: 04759091
|
||||
Node: 04659500
|
||||
Node: 04559908
|
||||
Node: 04460269
|
||||
Node: 04360628
|
||||
Node: 04260831
|
||||
Node: 04160992
|
||||
Node: 0461239
|
||||
Node: 03265340
|
||||
Node: 03165743
|
||||
Node: 0365940
|
||||
Node: 02369240
|
||||
Node: 02269474
|
||||
Node: 02169754
|
||||
Node: 0269959
|
||||
Node: 0174037
|
||||
Node: Notes74138
|
||||
Node: Comparison with Org Agenda searches74300
|
||||
Node: org-sidebar75189
|
||||
Node: License75468
|
||||
Node: 08641453
|
||||
Node: 08541691
|
||||
Node: 08442347
|
||||
Node: 08342799
|
||||
Node: 08243140
|
||||
Node: 08143533
|
||||
Node: 0843954
|
||||
Node: 07446678
|
||||
Node: 07346901
|
||||
Node: 07247635
|
||||
Node: 07148556
|
||||
Node: 0749367
|
||||
Node: 06352233
|
||||
Node: 06252766
|
||||
Node: 06153073
|
||||
Node: 0653643
|
||||
Node: 05256699
|
||||
Node: 05157001
|
||||
Node: 0557426
|
||||
Node: 04958957
|
||||
Node: 04859239
|
||||
Node: 04759588
|
||||
Node: 04659997
|
||||
Node: 04560405
|
||||
Node: 04460766
|
||||
Node: 04361125
|
||||
Node: 04261328
|
||||
Node: 04161489
|
||||
Node: 0461736
|
||||
Node: 03265837
|
||||
Node: 03166240
|
||||
Node: 0366437
|
||||
Node: 02369737
|
||||
Node: 02269971
|
||||
Node: 02170251
|
||||
Node: 0270456
|
||||
Node: 0174534
|
||||
Node: Notes74635
|
||||
Node: Comparison with Org Agenda searches74797
|
||||
Node: org-sidebar75686
|
||||
Node: License75965
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
|
|
|||
23
tests/data-ts.org
Normal file
23
tests/data-ts.org
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#+title: Timestamp-specific tests
|
||||
|
||||
/Timestamps in this file are active ones./
|
||||
|
||||
* Single-timestamp ranges
|
||||
|
||||
** Single-timestamp, without repeater
|
||||
<2024-06-25 Tue 08:00-09:00>
|
||||
|
||||
** Single-timestamp, with repeater (deadline)
|
||||
DEADLINE: <2024-06-25 Tue 08:00-09:00 ++7d>
|
||||
|
||||
* Multi-timestamp ranges
|
||||
|
||||
/Not sure that it would make sense to use repeaters for this kind of range./
|
||||
|
||||
** Multi-timestamp, without repeater
|
||||
<2024-06-25 Tue 08:00>--<2024-06-26 Wed 08:00>
|
||||
|
||||
* Canary
|
||||
|
||||
/This entry should never be matched./
|
||||
|
||||
|
|
@ -1688,7 +1688,36 @@ with keyword arg NOW in PLIST."
|
|||
(org-ql-expect ((org-ql--query-string-to-sexp "ts-active:with-time="))
|
||||
'("Take over the universe" "Take over the world" "Visit Mars" "Visit the moon" "Practice leaping tall buildings in a single bound" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp"))
|
||||
(org-ql-expect ((org-ql--query-string-to-sexp "ts-active:with-time=t"))
|
||||
'("Skype with president of Antarctica" "Renew membership in supervillain club" "Order a pizza"))))
|
||||
'("Skype with president of Antarctica" "Renew membership in supervillain club" "Order a pizza")))
|
||||
|
||||
(describe "matches timestamps with inner time ranges"
|
||||
(before-each
|
||||
(setq org-ql-test-buffer (org-ql-test-data-buffer "data-ts.org")
|
||||
org-ql-test-num-headings (with-current-buffer org-ql-test-buffer
|
||||
(org-with-wide-buffer
|
||||
(goto-char (point-min))
|
||||
;; Exclude the "Canary" heading.
|
||||
(1- (cl-loop while (re-search-forward org-heading-regexp nil t)
|
||||
sum 1))))))
|
||||
|
||||
(org-ql-it "without specified timestamp"
|
||||
(org-ql-expect ('(ts-active))
|
||||
'("Single-timestamp, without repeater" "Single-timestamp, with repeater (deadline)" "Multi-timestamp, without repeater")))
|
||||
(org-ql-it "with specified timestamps"
|
||||
(org-ql-expect ('(ts-active :on "2024-06-25"))
|
||||
'("Single-timestamp, without repeater" "Single-timestamp, with repeater (deadline)" "Multi-timestamp, without repeater"))
|
||||
(org-ql-expect ('(ts-active :on "2024-06-26"))
|
||||
'("Multi-timestamp, without repeater")))
|
||||
(org-ql-it "with specified time values"
|
||||
(org-ql-expect ('(ts-active :to "2024-06-25 09:00"))
|
||||
'("Single-timestamp, without repeater" "Single-timestamp, with repeater (deadline)" "Multi-timestamp, without repeater"))
|
||||
;; FIXME: The test below fails because timestamps with
|
||||
;; ranges are not yet parsed into multiple timestamps and
|
||||
;; compared as a range. This will have to be addressed in
|
||||
;; a new version.
|
||||
;; (org-ql-expect ('(ts-active :from "2024-06-25 08:30"))
|
||||
;; '("Single-timestamp, without repeater" "Single-timestamp, with repeater (deadline)" "Multi-timestamp, without repeater"))
|
||||
)))
|
||||
|
||||
(describe "inactive"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue