From ffc3477013f0ebdb5e223d5af5c1ef489d8b0055 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 26 Jun 2024 10:52:31 -0500 Subject: [PATCH] Fix: (org-ql-regexp-part-ts-date) Allow punctuation in day-of-week Fixes . Closes . Reported-by: Florian D. --- README.org | 1 + org-ql.el | 5 +-- org-ql.info | 87 +++++++++++++++++++++++--------------------- tests/data-ts.org | 6 +++ tests/test-org-ql.el | 29 +++++++++++---- 5 files changed, 76 insertions(+), 52 deletions(-) diff --git a/README.org b/README.org index c746528..6180135 100644 --- a/README.org +++ b/README.org @@ -557,6 +557,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *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]].) ++ Timestamps with day-of-the-week abbreviations are matched more flexibly (allowing, e.g. a period in French locales). (See [[https://github.com/alphapapa/org-ql/discussions/429][#429]], [[https://github.com/alphapapa/org-ql/issues/432][#432]]. Thanks to [[https://github.com/neurolit][Florian D.]] for reporting.) + Command ~org-ql-search~ did not narrow properly when called interactively. ** 0.8.6 diff --git a/org-ql.el b/org-ql.el index 569bdaa..6300dd0 100644 --- a/org-ql.el +++ b/org-ql.el @@ -157,10 +157,9 @@ This list should not contain any duplicates.")) (defvar org-ql-regexp-part-ts-date (rx (repeat 4 digit) "-" (repeat 2 digit) "-" (repeat 2 digit) ;; Day of week - (optional " " (1+ alpha))) + (optional " " (1+ (or alpha punct)))) "Matches the inner, date part of an Org timestamp, both active and inactive. -Also matches optional day-of-week. Used to build other timestamp -regexps.") +Used to build other timestamp regexps.") (defvar org-ql-regexp-part-ts-repeaters ;; Repeaters (not sure if the colon is necessary, but it's in the org.el one) diff --git a/org-ql.info b/org-ql.info index cce0f1e..325eeb0 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1089,6 +1089,11 @@ File: README.info, Node: 087-pre, Next: 086, Up: Changelog (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).) + • Timestamps with day-of-the-week abbreviations are matched more + flexibly (allowing, e.g. a period in French locales). (See #429 + (https://github.com/alphapapa/org-ql/discussions/429), #432 + (https://github.com/alphapapa/org-ql/issues/432). Thanks to + Florian D. (https://github.com/neurolit) for reporting.) • Command ‘org-ql-search’ did not narrow properly when called interactively. @@ -2020,47 +2025,47 @@ Node: Links38911 Node: Tips39598 Node: Changelog39922 Node: 087-pre40844 -Node: 08641544 -Node: 08541782 -Node: 08442438 -Node: 08342890 -Node: 08243231 -Node: 08143624 -Node: 0844045 -Node: 07446769 -Node: 07346992 -Node: 07247726 -Node: 07148647 -Node: 0749458 -Node: 06352324 -Node: 06252857 -Node: 06153164 -Node: 0653734 -Node: 05256790 -Node: 05157092 -Node: 0557517 -Node: 04959048 -Node: 04859330 -Node: 04759679 -Node: 04660088 -Node: 04560496 -Node: 04460857 -Node: 04361216 -Node: 04261419 -Node: 04161580 -Node: 0461827 -Node: 03265928 -Node: 03166331 -Node: 0366528 -Node: 02369828 -Node: 02270062 -Node: 02170342 -Node: 0270547 -Node: 0174625 -Node: Notes74726 -Node: Comparison with Org Agenda searches74888 -Node: org-sidebar75777 -Node: License76056 +Node: 08641879 +Node: 08542117 +Node: 08442773 +Node: 08343225 +Node: 08243566 +Node: 08143959 +Node: 0844380 +Node: 07447104 +Node: 07347327 +Node: 07248061 +Node: 07148982 +Node: 0749793 +Node: 06352659 +Node: 06253192 +Node: 06153499 +Node: 0654069 +Node: 05257125 +Node: 05157427 +Node: 0557852 +Node: 04959383 +Node: 04859665 +Node: 04760014 +Node: 04660423 +Node: 04560831 +Node: 04461192 +Node: 04361551 +Node: 04261754 +Node: 04161915 +Node: 0462162 +Node: 03266263 +Node: 03166666 +Node: 0366863 +Node: 02370163 +Node: 02270397 +Node: 02170677 +Node: 0270882 +Node: 0174960 +Node: Notes75061 +Node: Comparison with Org Agenda searches75223 +Node: org-sidebar76112 +Node: License76391  End Tag Table diff --git a/tests/data-ts.org b/tests/data-ts.org index 01ebd57..a5169a7 100644 --- a/tests/data-ts.org +++ b/tests/data-ts.org @@ -17,6 +17,12 @@ DEADLINE: <2024-06-25 Tue 08:00-09:00 ++7d> ** Multi-timestamp, without repeater <2024-06-25 Tue 08:00>--<2024-06-26 Wed 08:00> +* Day-of-week abbreviations + +** French + +<2024-07-12 Fri> + * Canary /This entry should never be matched./ diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 8721e0f..6717472 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -1700,16 +1700,16 @@ with keyword arg NOW in PLIST." (1- (cl-loop while (re-search-forward org-heading-regexp nil t) sum 1)))))) - (org-ql-it "without specified timestamp" + (org-ql-it "without :with-time" (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" "French"))) + (org-ql-it ":with-time t" + (org-ql-expect ('(ts-active :on "2024-06-25" :with-time t)) '("Single-timestamp, without repeater" "Single-timestamp, with repeater (deadline)" "Multi-timestamp, without repeater")) - (org-ql-expect ('(ts-active :on "2024-06-26")) + (org-ql-expect ('(ts-active :on "2024-06-26" :with-time t)) '("Multi-timestamp, without repeater"))) - (org-ql-it "with specified time values" - (org-ql-expect ('(ts-active :to "2024-06-25 09:00")) + (org-ql-it ":with-time t and with specified time value in :to" + (org-ql-expect ('(ts-active :to "2024-06-25 09:00" :with-time t)) '("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 @@ -1856,7 +1856,20 @@ with keyword arg NOW in PLIST." '("Visit Mars"))) (org-ql-then (:now "2019-07-07") (org-ql-expect ('(ts :on today)) - nil))))) + nil)))) + + (describe "Day-of-week abbreviations" + (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 "matches French abbreviations (with trailing period)" + (org-ql-expect ('(ts :on "2024-07-12")) + '("French"))))) (describe "Compound queries"