From 770e60766a8f309943d68c1e7234e109904360ba Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 21 Feb 2024 04:51:30 -0600 Subject: [PATCH 1/4] Meta: v0.8.5-pre --- README.org | 4 + org-ql.el | 2 +- org-ql.info | 233 +++++++++++++++++++++++++++------------------------- 3 files changed, 127 insertions(+), 112 deletions(-) diff --git a/README.org b/README.org index 9175943..a1af574 100644 --- a/README.org +++ b/README.org @@ -553,6 +553,10 @@ Simple links may also be written manually in either sexp or non-sexp form, like: /Note:/ Breaking changes may be made before version 1.0, but in the event of major changes, attempts at backward compatibility will be made with obsolescence declarations, translation of arguments, etc. Users who need stability guarantees before 1.0 may choose to use tagged stable releases. +** 0.8.5-pre + +Nothing new yet. + ** 0.8.4 *Fixes* diff --git a/org-ql.el b/org-ql.el index 9f24c03..28e1b0f 100644 --- a/org-ql.el +++ b/org-ql.el @@ -4,7 +4,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.8.4 +;; Version: 0.8.5-pre ;; Package-Requires: ((emacs "27.1") (compat "29.1") (dash "2.18.1") (f "0.17.2") (map "2.1") (org "9.0") (org-super-agenda "1.2") (ov "1.0.6") (peg "1.0.1") (s "1.12.0") (transient "0.1") (ts "0.2-pre")) ;; Keywords: hypermedia, outlines, Org, agenda diff --git a/org-ql.info b/org-ql.info index 0ce52d0..a0cfe4a 100644 --- a/org-ql.info +++ b/org-ql.info @@ -72,6 +72,7 @@ Functions / Macros Changelog +* 0.8.5-pre: 085-pre. * 0.8.4: 084. * 0.8.3: 083. * 0.8.2: 082. @@ -1032,6 +1033,7 @@ releases. * Menu: +* 0.8.5-pre: 085-pre. * 0.8.4: 084. * 0.8.3: 083. * 0.8.2: 082. @@ -1069,9 +1071,17 @@ releases. * 0.1: 01.  -File: README.info, Node: 084, Next: 083, Up: Changelog +File: README.info, Node: 085-pre, Next: 084, Up: Changelog -5.1 0.8.4 +5.1 0.8.5-pre +============= + +Nothing new yet. + + +File: README.info, Node: 084, Next: 083, Prev: 085-pre, Up: Changelog + +5.2 0.8.4 ========= *Fixes* @@ -1085,7 +1095,7 @@ File: README.info, Node: 084, Next: 083, Up: Changelog  File: README.info, Node: 083, Next: 082, Prev: 084, Up: Changelog -5.2 0.8.3 +5.3 0.8.3 ========= *Fixes* @@ -1098,7 +1108,7 @@ File: README.info, Node: 083, Next: 082, Prev: 084, Up: Changelog  File: README.info, Node: 082, Next: 081, Prev: 083, Up: Changelog -5.3 0.8.2 +5.4 0.8.2 ========= *Fixes* @@ -1112,7 +1122,7 @@ File: README.info, Node: 082, Next: 081, Prev: 083, Up: Changelog  File: README.info, Node: 081, Next: 08, Prev: 082, Up: Changelog -5.4 0.8.1 +5.5 0.8.1 ========= *Fixes* @@ -1127,7 +1137,7 @@ File: README.info, Node: 081, Next: 08, Prev: 082, Up: Changelog  File: README.info, Node: 08, Next: 074, Prev: 081, Up: Changelog -5.5 0.8 +5.6 0.8 ======= *Additions* @@ -1183,7 +1193,7 @@ File: README.info, Node: 08, Next: 074, Prev: 081, Up: Changelog  File: README.info, Node: 074, Next: 073, Prev: 08, Up: Changelog -5.6 0.7.4 +5.7 0.7.4 ========= *Fixes* @@ -1193,7 +1203,7 @@ File: README.info, Node: 074, Next: 073, Prev: 08, Up: Changelog  File: README.info, Node: 073, Next: 072, Prev: 074, Up: Changelog -5.7 0.7.3 +5.8 0.7.3 ========= *Fixes* @@ -1211,7 +1221,7 @@ File: README.info, Node: 073, Next: 072, Prev: 074, Up: Changelog  File: README.info, Node: 072, Next: 071, Prev: 073, Up: Changelog -5.8 0.7.2 +5.9 0.7.2 ========= *Fixes* @@ -1232,8 +1242,8 @@ File: README.info, Node: 072, Next: 071, Prev: 073, Up: Changelog  File: README.info, Node: 071, Next: 07, Prev: 072, Up: Changelog -5.9 0.7.1 -========= +5.10 0.7.1 +========== *Fixes* • Function ‘org-ql-completing-read’ is more compatible with default @@ -1251,7 +1261,7 @@ File: README.info, Node: 071, Next: 07, Prev: 072, Up: Changelog  File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog -5.10 0.7 +5.11 0.7 ======== *Added* @@ -1310,7 +1320,7 @@ File: README.info, Node: 07, Next: 063, Prev: 071, Up: Changelog  File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog -5.11 0.6.3 +5.12 0.6.3 ========== *Fixed* @@ -1326,7 +1336,7 @@ File: README.info, Node: 063, Next: 062, Prev: 07, Up: Changelog  File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog -5.12 0.6.2 +5.13 0.6.2 ========== *Fixed* @@ -1337,7 +1347,7 @@ File: README.info, Node: 062, Next: 061, Prev: 063, Up: Changelog  File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog -5.13 0.6.1 +5.14 0.6.1 ========== *Fixed* @@ -1355,7 +1365,7 @@ File: README.info, Node: 061, Next: 06, Prev: 062, Up: Changelog  File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog -5.14 0.6 +5.15 0.6 ======== *Added* @@ -1422,7 +1432,7 @@ File: README.info, Node: 06, Next: 052, Prev: 061, Up: Changelog  File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog -5.15 0.5.2 +5.16 0.5.2 ========== *Fixed* @@ -1433,7 +1443,7 @@ File: README.info, Node: 052, Next: 051, Prev: 06, Up: Changelog  File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog -5.16 0.5.1 +5.17 0.5.1 ========== *Fixed* @@ -1446,7 +1456,7 @@ File: README.info, Node: 051, Next: 05, Prev: 052, Up: Changelog  File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog -5.17 0.5 +5.18 0.5 ======== *Added* @@ -1487,7 +1497,7 @@ File: README.info, Node: 05, Next: 049, Prev: 051, Up: Changelog  File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog -5.18 0.4.9 +5.19 0.4.9 ========== *Fixed* @@ -1498,7 +1508,7 @@ File: README.info, Node: 049, Next: 048, Prev: 05, Up: Changelog  File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog -5.19 0.4.8 +5.20 0.4.8 ========== *Fixed* @@ -1510,7 +1520,7 @@ File: README.info, Node: 048, Next: 047, Prev: 049, Up: Changelog  File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog -5.20 0.4.7 +5.21 0.4.7 ========== *Fixed* @@ -1523,7 +1533,7 @@ File: README.info, Node: 047, Next: 046, Prev: 048, Up: Changelog  File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog -5.21 0.4.6 +5.22 0.4.6 ========== *Fixed* @@ -1536,7 +1546,7 @@ File: README.info, Node: 046, Next: 045, Prev: 047, Up: Changelog  File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog -5.22 0.4.5 +5.23 0.4.5 ========== *Fixed* @@ -1548,7 +1558,7 @@ File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog  File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog -5.23 0.4.4 +5.24 0.4.4 ========== *Fixed* @@ -1560,7 +1570,7 @@ File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog  File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog -5.24 0.4.3 +5.25 0.4.3 ========== *Fixed* @@ -1570,7 +1580,7 @@ File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog  File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog -5.25 0.4.2 +5.26 0.4.2 ========== *Fixed* @@ -1579,7 +1589,7 @@ File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog  File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog -5.26 0.4.1 +5.27 0.4.1 ========== *Fixed* @@ -1589,7 +1599,7 @@ File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog  File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog -5.27 0.4 +5.28 0.4 ======== _Note:_ The next release, 0.5, may include changes which will require @@ -1670,7 +1680,7 @@ automatically, as they will be pushed to the ‘master’ branch when ready.  File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog -5.28 0.3.2 +5.29 0.3.2 ========== *Fixed* @@ -1683,7 +1693,7 @@ File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog  File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog -5.29 0.3.1 +5.30 0.3.1 ========== *Fixed* @@ -1693,7 +1703,7 @@ File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog  File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog -5.30 0.3 +5.31 0.3 ======== *Added* @@ -1761,7 +1771,7 @@ File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog  File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog -5.31 0.2.3 +5.32 0.2.3 ========== *Fixed* @@ -1771,7 +1781,7 @@ File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog  File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog -5.32 0.2.2 +5.33 0.2.2 ========== *Fixed* @@ -1782,7 +1792,7 @@ File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog  File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog -5.33 0.2.1 +5.34 0.2.1 ========== *Fixed* @@ -1792,7 +1802,7 @@ File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog  File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog -5.34 0.2 +5.35 0.2 ======== *Added* @@ -1875,7 +1885,7 @@ File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog  File: README.info, Node: 01, Prev: 02, Up: Changelog -5.35 0.1 +5.36 0.1 ======== First tagged release. @@ -1933,80 +1943,81 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1907 -Node: Screenshots2030 -Node: Installation2148 -Node: Quelpa2662 -Node: Helm support3190 -Node: Usage3593 -Node: Commands3991 -Node: org-ql-find4456 -Node: org-ql-open-link5364 -Node: org-ql-refile6219 -Node: org-ql-search6547 -Node: helm-org-ql8478 -Node: org-ql-view8856 -Node: org-ql-view-sidebar9386 -Node: org-ql-view-recent-items9766 -Node: org-ql-sparse-tree10262 -Node: Queries11062 -Node: Non-sexp query syntax12179 -Node: General predicates13938 -Node: Ancestor/descendant predicates20863 -Node: Date/time predicates21991 -Node: Functions / Macros25115 -Node: Agenda-like views25413 -Ref: Function org-ql-block25575 -Node: Listing / acting-on results26836 -Ref: Caching27044 -Ref: Function org-ql-select27957 -Ref: Function org-ql-query30383 -Ref: Macro org-ql (deprecated)32157 -Node: Custom predicates32472 -Ref: Macro org-ql-defpred32696 -Node: Dynamic block36137 -Node: Links38861 -Node: Tips39548 -Node: Changelog39872 -Node: 08440744 -Node: 08341184 -Node: 08241525 -Node: 08141918 -Node: 0842339 -Node: 07445063 -Node: 07345286 -Node: 07246018 -Node: 07146937 -Node: 0747746 -Node: 06350612 -Node: 06251145 -Node: 06151452 -Node: 0652022 -Node: 05255078 -Node: 05155380 -Node: 0555805 -Node: 04957336 -Node: 04857618 -Node: 04757967 -Node: 04658376 -Node: 04558784 -Node: 04459145 -Node: 04359504 -Node: 04259707 -Node: 04159868 -Node: 0460115 -Node: 03264216 -Node: 03164619 -Node: 0364816 -Node: 02368116 -Node: 02268350 -Node: 02168630 -Node: 0268835 -Node: 0172913 -Node: Notes73014 -Node: Comparison with Org Agenda searches73176 -Node: org-sidebar74065 -Node: License74344 +Node: Contents1929 +Node: Screenshots2052 +Node: Installation2170 +Node: Quelpa2684 +Node: Helm support3212 +Node: Usage3615 +Node: Commands4013 +Node: org-ql-find4478 +Node: org-ql-open-link5386 +Node: org-ql-refile6241 +Node: org-ql-search6569 +Node: helm-org-ql8500 +Node: org-ql-view8878 +Node: org-ql-view-sidebar9408 +Node: org-ql-view-recent-items9788 +Node: org-ql-sparse-tree10284 +Node: Queries11084 +Node: Non-sexp query syntax12201 +Node: General predicates13960 +Node: Ancestor/descendant predicates20885 +Node: Date/time predicates22013 +Node: Functions / Macros25137 +Node: Agenda-like views25435 +Ref: Function org-ql-block25597 +Node: Listing / acting-on results26858 +Ref: Caching27066 +Ref: Function org-ql-select27979 +Ref: Function org-ql-query30405 +Ref: Macro org-ql (deprecated)32179 +Node: Custom predicates32494 +Ref: Macro org-ql-defpred32718 +Node: Dynamic block36159 +Node: Links38883 +Node: Tips39570 +Node: Changelog39894 +Node: 085-pre40788 +Node: 08440900 +Node: 08341356 +Node: 08241697 +Node: 08142090 +Node: 0842511 +Node: 07445235 +Node: 07345458 +Node: 07246190 +Node: 07147109 +Node: 0747920 +Node: 06350786 +Node: 06251319 +Node: 06151626 +Node: 0652196 +Node: 05255252 +Node: 05155554 +Node: 0555979 +Node: 04957510 +Node: 04857792 +Node: 04758141 +Node: 04658550 +Node: 04558958 +Node: 04459319 +Node: 04359678 +Node: 04259881 +Node: 04160042 +Node: 0460289 +Node: 03264390 +Node: 03164793 +Node: 0364990 +Node: 02368290 +Node: 02268524 +Node: 02168804 +Node: 0269009 +Node: 0173087 +Node: Notes73188 +Node: Comparison with Org Agenda searches73350 +Node: org-sidebar74239 +Node: License74518  End Tag Table From b6efba9aebe24794101afd608ab60322e6e73277 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 21 Feb 2024 04:57:44 -0600 Subject: [PATCH 2/4] Fix: (heading) Don't match strings as regexps Reported-by: Alex Popescu --- README.org | 3 +- org-ql.el | 36 ++++--------------- org-ql.info | 85 +++++++++++++++++++++++--------------------- tests/test-org-ql.el | 10 ++++-- 4 files changed, 61 insertions(+), 73 deletions(-) diff --git a/README.org b/README.org index a1af574..d122bdd 100644 --- a/README.org +++ b/README.org @@ -555,7 +555,8 @@ Simple links may also be written manually in either sexp or non-sexp form, like: ** 0.8.5-pre -Nothing new yet. +*Fixes* ++ Predicate ~heading~ incorrectly matched strings as regular expressions, sometimes returning incorrect results. (See [[https://github.com/alphapapa/org-ql/discussions/410][discussion]]. Thanks to [[https://github.com/al3xandru][Alex Popescu]] for reporting.) ** 0.8.4 diff --git a/org-ql.el b/org-ql.el index 28e1b0f..da4456e 100644 --- a/org-ql.el +++ b/org-ql.el @@ -1461,40 +1461,16 @@ Org effort string, like \"5\" or \"0:05\"." (list :regexp (rx bol (0+ space) ":STYLE:" (1+ space) "habit" (0+ space) eol)))) :body (org-is-habit-p)) -(org-ql-defpred (heading h) (&rest strings) +(org-ql-defpred (heading h) (&rest _strings) "Return non-nil if current entry's heading matches all STRINGS. Matching is done case-insensitively." :coalesce t :normalizers ((`(,predicate-names . ,args) - ;; "h" alias. - `(heading ,@args))) - ;; TODO: Adjust regexp to avoid matching in tag list. - :preambles ((`(,predicate-names) - ;; This clause protects against the case in which the - ;; arguments are nil, which would cause an error in - ;; `rx-to-string' in other clauses. This can happen - ;; with `org-ql-completing-read', e.g. when the input - ;; is "h:" while the user is typing. - (list :regexp (rx bol (1+ "*") (1+ blank) (0+ nonl)) - :case-fold t :query query)) - (`(,predicate-names ,string) - ;; Only one string: match with preamble, then let predicate confirm (because - ;; the match could be in e.g. the tags rather than the heading text). - (list :regexp (rx-to-string `(seq bol (1+ "*") (1+ blank) (0+ nonl) - ,string) - 'no-group) - :case-fold t :query query)) - (`(,predicate-names . ,strings) - ;; Multiple strings: use preamble to match against first - ;; string, then let the predicate match the rest. - (list :regexp (rx-to-string `(seq bol (1+ "*") (1+ blank) (0+ nonl) - ,(car strings)) - 'no-group) - :case-fold t :query query))) - ;; TODO: In Org 9.2+, `org-get-heading' takes 2 more arguments. - :body (let ((heading (org-get-heading 'no-tags 'no-todo)) - (case-fold-search t)) - (--all? (string-match it heading) strings))) + ;; NOTE: Each string argument must be converted to a regexp + ;; for testing by the body, so we just normalize to the + ;; `heading-regexp' predicate, leaving this predicate as + ;; one that merely regexp-quotes its arguments. + `(heading-regexp ,@(mapcar #'regexp-quote args))))) (org-ql-defpred (heading-regexp h*) (&rest regexps) "Return non-nil if current entry's heading matches all REGEXPS (regexp strings). diff --git a/org-ql.info b/org-ql.info index a0cfe4a..33a3dca 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1076,7 +1076,12 @@ File: README.info, Node: 085-pre, Next: 084, Up: Changelog 5.1 0.8.5-pre ============= -Nothing new yet. +*Fixes* + • Predicate ‘heading’ incorrectly matched strings as regular + expressions, sometimes returning incorrect results. (See + discussion (https://github.com/alphapapa/org-ql/discussions/410). + Thanks to Alex Popescu (https://github.com/al3xandru) for + reporting.)  File: README.info, Node: 084, Next: 083, Prev: 085-pre, Up: Changelog @@ -1979,45 +1984,45 @@ Node: Links38883 Node: Tips39570 Node: Changelog39894 Node: 085-pre40788 -Node: 08440900 -Node: 08341356 -Node: 08241697 -Node: 08142090 -Node: 0842511 -Node: 07445235 -Node: 07345458 -Node: 07246190 -Node: 07147109 -Node: 0747920 -Node: 06350786 -Node: 06251319 -Node: 06151626 -Node: 0652196 -Node: 05255252 -Node: 05155554 -Node: 0555979 -Node: 04957510 -Node: 04857792 -Node: 04758141 -Node: 04658550 -Node: 04558958 -Node: 04459319 -Node: 04359678 -Node: 04259881 -Node: 04160042 -Node: 0460289 -Node: 03264390 -Node: 03164793 -Node: 0364990 -Node: 02368290 -Node: 02268524 -Node: 02168804 -Node: 0269009 -Node: 0173087 -Node: Notes73188 -Node: Comparison with Org Agenda searches73350 -Node: org-sidebar74239 -Node: License74518 +Node: 08441175 +Node: 08341631 +Node: 08241972 +Node: 08142365 +Node: 0842786 +Node: 07445510 +Node: 07345733 +Node: 07246465 +Node: 07147384 +Node: 0748195 +Node: 06351061 +Node: 06251594 +Node: 06151901 +Node: 0652471 +Node: 05255527 +Node: 05155829 +Node: 0556254 +Node: 04957785 +Node: 04858067 +Node: 04758416 +Node: 04658825 +Node: 04559233 +Node: 04459594 +Node: 04359953 +Node: 04260156 +Node: 04160317 +Node: 0460564 +Node: 03264665 +Node: 03165068 +Node: 0365265 +Node: 02368565 +Node: 02268799 +Node: 02169079 +Node: 0269284 +Node: 0173362 +Node: Notes73463 +Node: Comparison with Org Agenda searches73625 +Node: org-sidebar74514 +Node: License74793  End Tag Table diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 7bf6a9b..247fa78 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -218,7 +218,8 @@ with keyword arg NOW in PLIST." (it "coalesces a single AND clause that uses two predicates (and preserves predicate order)" (expect (org-ql--normalize-query '(and (rifle "foo") (rifle "bar") (heading "baz") (heading "buz"))) - :to-equal '(and (rifle :regexps '("foo" "bar")) (heading "baz" "buz")))) + ;; NOTE: `heading' is normalized to `heading-regexp'. + :to-equal '(and (rifle :regexps '("foo" "bar")) (heading-regexp "baz" "buz")))) (it "preserves independent OR clauses" (expect (org-ql--normalize-query '(and (or (rifle "foo") (rifle "bar")) (or (rifle "baz") (rifle "buz")))) @@ -1112,7 +1113,12 @@ with keyword arg NOW in PLIST." '("Take over the world"))) (org-ql-it "with two arguments" (org-ql-expect ('(heading "Take over" "world")) - '("Take over the world")))) + '("Take over the world"))) + (org-ql-it "does not match strings as regexps" + (org-ql-expect ('(heading "over")) + '("Take over the universe" "Take over the world" "Take over Mars" "Take over the moon")) + (org-ql-expect ('(heading "[over]")) + nil))) (describe "(heading-regexp)" (org-ql-it "with one argument" From c90bae0eabad948dad0b693f1005b79eec457f30 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 21 Feb 2024 05:41:49 -0600 Subject: [PATCH 3/4] Fix: (ancestors, parent) Normalize sub-queries I'm not sure why calling the REC labeled function didn't correctly normalize these sub-queries; it seemed to only normalize for one round, leaving some queries incorrectly normalized. But this fixes it. Fixes #365. Reported-by: Gabriele Mongiano --- README.org | 1 + org-ql.el | 4 +-- org-ql.info | 82 +++++++++++++++++++++++--------------------- tests/test-org-ql.el | 12 +++++++ 4 files changed, 58 insertions(+), 41 deletions(-) diff --git a/README.org b/README.org index d122bdd..4d9fcbe 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* + Predicate ~heading~ incorrectly matched strings as regular expressions, sometimes returning incorrect results. (See [[https://github.com/alphapapa/org-ql/discussions/410][discussion]]. Thanks to [[https://github.com/al3xandru][Alex Popescu]] for reporting.) ++ Predicates ~ancestor~ and ~parent~ did not normalize their sub-queries, sometimes returning incorrect results. ([[https://github.com/alphapapa/org-ql/issues/365][#365]]. Thanks to [[https://github.com/kofm][Gabriele Mongiano]] for reporting.) ** 0.8.4 diff --git a/org-ql.el b/org-ql.el index da4456e..2bc33f5 100644 --- a/org-ql.el +++ b/org-ql.el @@ -2077,7 +2077,7 @@ With KEYWORDS, return non-nil if its keyword is one of KEYWORDS." :normalizers ((`(,predicate-names ;; Avoid infinitely compiling already-compiled functions. ,(and query (guard (not (byte-code-function-p query))))) - `(ancestors ,(org-ql--query-predicate (rec query)))) + `(ancestors ,(org-ql--query-predicate (org-ql--normalize-query query)))) (`(,predicate-names) '(ancestors (lambda () t)))) :body (org-with-wide-buffer @@ -2089,7 +2089,7 @@ With KEYWORDS, return non-nil if its keyword is one of KEYWORDS." :normalizers ((`(,predicate-names ;; Avoid infinitely compiling already-compiled functions. ,(and query (guard (not (byte-code-function-p query))))) - `(parent ,(org-ql--query-predicate (rec query)))) + `(parent ,(org-ql--query-predicate (org-ql--normalize-query query)))) (`(,predicate-names) '(parent (lambda () t)))) :body (org-with-wide-buffer diff --git a/org-ql.info b/org-ql.info index 33a3dca..f17deee 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1082,6 +1082,10 @@ File: README.info, Node: 085-pre, Next: 084, Up: Changelog discussion (https://github.com/alphapapa/org-ql/discussions/410). Thanks to Alex Popescu (https://github.com/al3xandru) for reporting.) + • Predicates ‘ancestor’ and ‘parent’ did not normalize their + sub-queries, sometimes returning incorrect results. (#365 + (https://github.com/alphapapa/org-ql/issues/365). Thanks to + Gabriele Mongiano (https://github.com/kofm) for reporting.)  File: README.info, Node: 084, Next: 083, Prev: 085-pre, Up: Changelog @@ -1984,45 +1988,45 @@ Node: Links38883 Node: Tips39570 Node: Changelog39894 Node: 085-pre40788 -Node: 08441175 -Node: 08341631 -Node: 08241972 -Node: 08142365 -Node: 0842786 -Node: 07445510 -Node: 07345733 -Node: 07246465 -Node: 07147384 -Node: 0748195 -Node: 06351061 -Node: 06251594 -Node: 06151901 -Node: 0652471 -Node: 05255527 -Node: 05155829 -Node: 0556254 -Node: 04957785 -Node: 04858067 -Node: 04758416 -Node: 04658825 -Node: 04559233 -Node: 04459594 -Node: 04359953 -Node: 04260156 -Node: 04160317 -Node: 0460564 -Node: 03264665 -Node: 03165068 -Node: 0365265 -Node: 02368565 -Node: 02268799 -Node: 02169079 -Node: 0269284 -Node: 0173362 -Node: Notes73463 -Node: Comparison with Org Agenda searches73625 -Node: org-sidebar74514 -Node: License74793 +Node: 08441444 +Node: 08341900 +Node: 08242241 +Node: 08142634 +Node: 0843055 +Node: 07445779 +Node: 07346002 +Node: 07246734 +Node: 07147653 +Node: 0748464 +Node: 06351330 +Node: 06251863 +Node: 06152170 +Node: 0652740 +Node: 05255796 +Node: 05156098 +Node: 0556523 +Node: 04958054 +Node: 04858336 +Node: 04758685 +Node: 04659094 +Node: 04559502 +Node: 04459863 +Node: 04360222 +Node: 04260425 +Node: 04160586 +Node: 0460833 +Node: 03264934 +Node: 03165337 +Node: 0365534 +Node: 02368834 +Node: 02269068 +Node: 02169348 +Node: 0269553 +Node: 0173631 +Node: Notes73732 +Node: Comparison with Org Agenda searches73894 +Node: org-sidebar74783 +Node: License75062  End Tag Table diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 247fa78..8d2b84c 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -254,6 +254,18 @@ with keyword arg NOW in PLIST." (expect (org-ql--normalize-query "\"quoted phrase\"") :to-equal '(rifle :regexps '("\"quoted phrase\"")))) + (describe "Ancestor/Parent predicates" + ;; NOTE: Because the ancestor and parent predicates byte-compile their + ;; subquery predicates, we have to test the byte-compiled forms here. + (expect (org-ql--normalize-query '(ancestors "scheduled")) + ;; No colon after keyword, so not a predicate query. + :to-equal ;; '(ancestors (rifle :regexps '("scheduled"))) + `(ancestors #[nil "\300\301\302\"\207" [rifle :regexps ("scheduled")] 3])) + (expect (org-ql--normalize-query '(parent "scheduled")) + ;; No colon after keyword, so not a predicate query. + :to-equal ;; '(parent (rifle :regexps '("scheduled"))) + `(parent #[nil "\300\301\302\"\207" [rifle :regexps ("scheduled")] 3]))) + (describe "Plain strings" (it "normalizes plain strings to the default predicate (using AND)" (expect (org-ql--normalize-query '(and "string1" "string2")) From bfff0b5517d55d01bf12de27e10a73c9a077767b Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 21 Feb 2024 05:46:04 -0600 Subject: [PATCH 4/4] Release: v0.8.5 --- README.org | 2 +- org-ql.el | 2 +- org-ql.info | 162 ++++++++++++++++++++++++++-------------------------- 3 files changed, 83 insertions(+), 83 deletions(-) diff --git a/README.org b/README.org index 4d9fcbe..39f18c5 100644 --- a/README.org +++ b/README.org @@ -553,7 +553,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: /Note:/ Breaking changes may be made before version 1.0, but in the event of major changes, attempts at backward compatibility will be made with obsolescence declarations, translation of arguments, etc. Users who need stability guarantees before 1.0 may choose to use tagged stable releases. -** 0.8.5-pre +** 0.8.5 *Fixes* + Predicate ~heading~ incorrectly matched strings as regular expressions, sometimes returning incorrect results. (See [[https://github.com/alphapapa/org-ql/discussions/410][discussion]]. Thanks to [[https://github.com/al3xandru][Alex Popescu]] for reporting.) diff --git a/org-ql.el b/org-ql.el index 2bc33f5..d1f13a3 100644 --- a/org-ql.el +++ b/org-ql.el @@ -4,7 +4,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.8.5-pre +;; Version: 0.8.5 ;; Package-Requires: ((emacs "27.1") (compat "29.1") (dash "2.18.1") (f "0.17.2") (map "2.1") (org "9.0") (org-super-agenda "1.2") (ov "1.0.6") (peg "1.0.1") (s "1.12.0") (transient "0.1") (ts "0.2-pre")) ;; Keywords: hypermedia, outlines, Org, agenda diff --git a/org-ql.info b/org-ql.info index f17deee..ec5076b 100644 --- a/org-ql.info +++ b/org-ql.info @@ -72,7 +72,7 @@ Functions / Macros Changelog -* 0.8.5-pre: 085-pre. +* 0.8.5: 085. * 0.8.4: 084. * 0.8.3: 083. * 0.8.2: 082. @@ -1033,7 +1033,7 @@ releases. * Menu: -* 0.8.5-pre: 085-pre. +* 0.8.5: 085. * 0.8.4: 084. * 0.8.3: 083. * 0.8.2: 082. @@ -1071,10 +1071,10 @@ releases. * 0.1: 01.  -File: README.info, Node: 085-pre, Next: 084, Up: Changelog +File: README.info, Node: 085, Next: 084, Up: Changelog -5.1 0.8.5-pre -============= +5.1 0.8.5 +========= *Fixes* • Predicate ‘heading’ incorrectly matched strings as regular @@ -1088,7 +1088,7 @@ File: README.info, Node: 085-pre, Next: 084, Up: Changelog Gabriele Mongiano (https://github.com/kofm) for reporting.)  -File: README.info, Node: 084, Next: 083, Prev: 085-pre, Up: Changelog +File: README.info, Node: 084, Next: 083, Prev: 085, Up: Changelog 5.2 0.8.4 ========= @@ -1952,81 +1952,81 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1929 -Node: Screenshots2052 -Node: Installation2170 -Node: Quelpa2684 -Node: Helm support3212 -Node: Usage3615 -Node: Commands4013 -Node: org-ql-find4478 -Node: org-ql-open-link5386 -Node: org-ql-refile6241 -Node: org-ql-search6569 -Node: helm-org-ql8500 -Node: org-ql-view8878 -Node: org-ql-view-sidebar9408 -Node: org-ql-view-recent-items9788 -Node: org-ql-sparse-tree10284 -Node: Queries11084 -Node: Non-sexp query syntax12201 -Node: General predicates13960 -Node: Ancestor/descendant predicates20885 -Node: Date/time predicates22013 -Node: Functions / Macros25137 -Node: Agenda-like views25435 -Ref: Function org-ql-block25597 -Node: Listing / acting-on results26858 -Ref: Caching27066 -Ref: Function org-ql-select27979 -Ref: Function org-ql-query30405 -Ref: Macro org-ql (deprecated)32179 -Node: Custom predicates32494 -Ref: Macro org-ql-defpred32718 -Node: Dynamic block36159 -Node: Links38883 -Node: Tips39570 -Node: Changelog39894 -Node: 085-pre40788 -Node: 08441444 -Node: 08341900 -Node: 08242241 -Node: 08142634 -Node: 0843055 -Node: 07445779 -Node: 07346002 -Node: 07246734 -Node: 07147653 -Node: 0748464 -Node: 06351330 -Node: 06251863 -Node: 06152170 -Node: 0652740 -Node: 05255796 -Node: 05156098 -Node: 0556523 -Node: 04958054 -Node: 04858336 -Node: 04758685 -Node: 04659094 -Node: 04559502 -Node: 04459863 -Node: 04360222 -Node: 04260425 -Node: 04160586 -Node: 0460833 -Node: 03264934 -Node: 03165337 -Node: 0365534 -Node: 02368834 -Node: 02269068 -Node: 02169348 -Node: 0269553 -Node: 0173631 -Node: Notes73732 -Node: Comparison with Org Agenda searches73894 -Node: org-sidebar74783 -Node: License75062 +Node: Contents1921 +Node: Screenshots2044 +Node: Installation2162 +Node: Quelpa2676 +Node: Helm support3204 +Node: Usage3607 +Node: Commands4005 +Node: org-ql-find4470 +Node: org-ql-open-link5378 +Node: org-ql-refile6233 +Node: org-ql-search6561 +Node: helm-org-ql8492 +Node: org-ql-view8870 +Node: org-ql-view-sidebar9400 +Node: org-ql-view-recent-items9780 +Node: org-ql-sparse-tree10276 +Node: Queries11076 +Node: Non-sexp query syntax12193 +Node: General predicates13952 +Node: Ancestor/descendant predicates20877 +Node: Date/time predicates22005 +Node: Functions / Macros25129 +Node: Agenda-like views25427 +Ref: Function org-ql-block25589 +Node: Listing / acting-on results26850 +Ref: Caching27058 +Ref: Function org-ql-select27971 +Ref: Function org-ql-query30397 +Ref: Macro org-ql (deprecated)32171 +Node: Custom predicates32486 +Ref: Macro org-ql-defpred32710 +Node: Dynamic block36151 +Node: Links38875 +Node: Tips39562 +Node: Changelog39886 +Node: 08540772 +Node: 08441416 +Node: 08341868 +Node: 08242209 +Node: 08142602 +Node: 0843023 +Node: 07445747 +Node: 07345970 +Node: 07246702 +Node: 07147621 +Node: 0748432 +Node: 06351298 +Node: 06251831 +Node: 06152138 +Node: 0652708 +Node: 05255764 +Node: 05156066 +Node: 0556491 +Node: 04958022 +Node: 04858304 +Node: 04758653 +Node: 04659062 +Node: 04559470 +Node: 04459831 +Node: 04360190 +Node: 04260393 +Node: 04160554 +Node: 0460801 +Node: 03264902 +Node: 03165305 +Node: 0365502 +Node: 02368802 +Node: 02269036 +Node: 02169316 +Node: 0269521 +Node: 0173599 +Node: Notes73700 +Node: Comparison with Org Agenda searches73862 +Node: org-sidebar74751 +Node: License75030  End Tag Table