From 5a031bf5c19d274934f80d616d6fde62a6db5786 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Fri, 1 May 2020 06:20:46 -0500 Subject: [PATCH 1/2] Fix: (org-ql--select) Bind case-fold-search only around preamble Fixes #114. Thanks to @bitclick for reporting. Released as 0.4.5. --- README.org | 5 ++ org-ql.el | 14 ++--- org-ql.info | 124 ++++++++++++++++++++++++------------------- tests/test-org-ql.el | 7 +++ 4 files changed, 89 insertions(+), 61 deletions(-) diff --git a/README.org b/README.org index d6e654b..b272b15 100644 --- a/README.org +++ b/README.org @@ -398,6 +398,11 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience /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.4.5 + +*Fixed* ++ Non-case-folding predicates like ~(todo)~ unnecessarily disabled case-folding for other predicates. ([[https://github.com/alphapapa/org-ql/issues/114][Issue #114]]. Thanks to [[https://github.com/bitclick][@bitclick]] for reporting.) + ** 0.4.4 *Fixed* diff --git a/org-ql.el b/org-ql.el index aef1854..0307d78 100644 --- a/org-ql.el +++ b/org-ql.el @@ -2,7 +2,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.4.4 +;; Version: 0.4.5 ;; Package-Requires: ((emacs "26.1") (dash "2.13") (dash-functional "1.2.0") (f "0.17.2") (org "9.0") (org-super-agenda "1.2-pre") (ov "1.0.6") (peg "0.6") (s "1.12.0") (ts "0.2-pre")) ;; Keywords: hypermedia, outlines, Org, agenda @@ -355,12 +355,12 @@ If NARROW is non-nil, buffer will not be widened." (message "org-ql: No headings in buffer: %s" (current-buffer))) nil) ;; Find matching entries. - (cond (preamble (let ((case-fold-search preamble-case-fold)) - (cl-loop while (re-search-forward preamble nil t) - do (outline-back-to-heading 'invisible-ok) - when (funcall predicate) - collect (funcall action) - do (outline-next-heading)))) + (cond (preamble (cl-loop while (let ((case-fold-search preamble-case-fold)) + (re-search-forward preamble nil t)) + do (outline-back-to-heading 'invisible-ok) + when (funcall predicate) + collect (funcall action) + do (outline-next-heading))) (t (cl-loop when (funcall predicate) collect (funcall action) while (outline-next-heading)))))))) diff --git a/org-ql.info b/org-ql.info index 5919d5e..b5d86ef 100644 --- a/org-ql.info +++ b/org-ql.info @@ -63,6 +63,7 @@ Functions / Macros Changelog +* 0.4.5: 045. * 0.4.4: 044. * 0.4.3: 043. * 0.4.2: 042. @@ -151,7 +152,8 @@ File: README.info, Node: Usage, Next: Changelog, Prev: Installation, Up: Top 4 Usage ******* - • • • • + • • + • • • • • Feedback on these APIs is welcome. Eventually, after being tested and polished, they will be considered stable. @@ -706,6 +708,7 @@ releases. * Menu: +* 0.4.5: 045. * 0.4.4: 044. * 0.4.3: 043. * 0.4.2: 042. @@ -721,9 +724,21 @@ releases. * 0.1: 01.  -File: README.info, Node: 044, Next: 043, Up: Changelog +File: README.info, Node: 045, Next: 044, Up: Changelog -5.1 0.4.4 +5.1 0.4.5 +========= + +*Fixed* + • Non-case-folding predicates like ‘(todo)’ unnecessarily disabled + case-folding for other predicates. (Issue #114 + (https://github.com/alphapapa/org-ql/issues/114). Thanks to + @bitclick (https://github.com/bitclick) for reporting.) + + +File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog + +5.2 0.4.4 ========= *Fixed* @@ -735,7 +750,7 @@ File: README.info, Node: 044, Next: 043, Up: Changelog  File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog -5.2 0.4.3 +5.3 0.4.3 ========= *Fixed* @@ -745,7 +760,7 @@ File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog  File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog -5.3 0.4.2 +5.4 0.4.2 ========= *Fixed* @@ -754,7 +769,7 @@ File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog  File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog -5.4 0.4.1 +5.5 0.4.1 ========= *Fixed* @@ -764,7 +779,7 @@ File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog  File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog -5.5 0.4 +5.6 0.4 ======= _Note:_ The next release, 0.5, may include changes which will require @@ -845,7 +860,7 @@ as they will be pushed to the master branch when ready.  File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog -5.6 0.3.2 +5.7 0.3.2 ========= *Fixed* @@ -858,7 +873,7 @@ File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog  File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog -5.7 0.3.1 +5.8 0.3.1 ========= *Fixed* @@ -868,7 +883,7 @@ File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog  File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog -5.8 0.3 +5.9 0.3 ======= *Added* @@ -933,8 +948,8 @@ File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog  File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog -5.9 0.2.3 -========= +5.10 0.2.3 +========== *Fixed* • Priority queries could fail to match headings whose to-do keywords @@ -943,7 +958,7 @@ File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog  File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog -5.10 0.2.2 +5.11 0.2.2 ========== *Fixed* @@ -954,7 +969,7 @@ File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog  File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog -5.11 0.2.1 +5.12 0.2.1 ========== *Fixed* @@ -964,7 +979,7 @@ File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog  File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog -5.12 0.2 +5.13 0.2 ======== *Added* @@ -1047,7 +1062,7 @@ File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog  File: README.info, Node: 01, Prev: 02, Up: Changelog -5.13 0.1 +5.14 0.1 ======== First tagged release. @@ -1108,44 +1123,45 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1462 -Node: Screenshots1636 -Node: Installation1754 -Node: Quelpa2392 -Node: Usage2835 -Node: Commands3163 -Node: org-ql-search3636 -Node: helm-org-ql5284 -Node: org-ql-view5696 -Node: org-ql-view-sidebar5894 -Node: org-ql-view-recent-items6250 -Node: org-ql-sparse-tree6734 -Node: Queries7534 -Node: Non-sexp query syntax8442 -Node: General predicates10149 -Node: Ancestor/descendant predicates14956 -Node: Date/time predicates16084 -Node: Functions / Macros18739 -Node: Agenda-like views18972 -Node: Listing / acting-on results20377 -Node: Changelog24979 -Node: 04425568 -Node: 04325913 -Node: 04226108 -Node: 04126267 -Node: 0426506 -Node: 03230437 -Node: 03130814 -Node: 0331009 -Node: 02333982 -Node: 02234208 -Node: 02134476 -Node: 0234675 -Node: 0138710 -Node: Notes38811 -Node: Comparison with Org Agenda searches38973 -Node: org-sidebar39844 -Node: License40123 +Node: Contents1477 +Node: Screenshots1651 +Node: Installation1769 +Node: Quelpa2407 +Node: Usage2850 +Node: Commands3199 +Node: org-ql-search3672 +Node: helm-org-ql5320 +Node: org-ql-view5732 +Node: org-ql-view-sidebar5930 +Node: org-ql-view-recent-items6286 +Node: org-ql-sparse-tree6770 +Node: Queries7570 +Node: Non-sexp query syntax8478 +Node: General predicates10185 +Node: Ancestor/descendant predicates14992 +Node: Date/time predicates16120 +Node: Functions / Macros18775 +Node: Agenda-like views19008 +Node: Listing / acting-on results20413 +Node: Changelog25015 +Node: 04525619 +Node: 04425966 +Node: 04326323 +Node: 04226518 +Node: 04126677 +Node: 0426916 +Node: 03230847 +Node: 03131224 +Node: 0331419 +Node: 02334392 +Node: 02234620 +Node: 02134888 +Node: 0235087 +Node: 0139122 +Node: Notes39223 +Node: Comparison with Org Agenda searches39385 +Node: org-sidebar40256 +Node: License40535  End Tag Table diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index bf2340f..71c3ecf 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -707,6 +707,13 @@ RESULTS should be a list of strings as returned by (org-ql-it "with two plain strings in an OR" (org-ql-expect ((or "Take over" "universe") :sort todo) + '("Take over the universe" "Take over the world" "Take over Mars" "Take over the moon" "Get haircut"))) + + (org-ql-it "case-folding predicate with non-case-folding preamble" + ;; e.g. the (todo) predicate disables case-folding in its preamble, but that + ;; should not prevent case-folding in this and other predicates (issue #114). + (org-ql-expect ((and (todo "TODO") (regexp "take over")) + :sort todo) '("Take over the universe" "Take over the world" "Take over Mars" "Take over the moon" "Get haircut")))) (describe "(scheduled)" From 00800556907408ee11a23de3a4982061d08d3b85 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 12 Jul 2020 21:54:59 -0500 Subject: [PATCH 2/2] Fix: Copy macro peg-parse-string from peg-tests.el Unfortunately, the macro was moved from peg.el to peg-tests.el in later versions of peg, so we copy it for our use here. Fixes #75. Thanks to Karl Voit (@novoid) and @karlicoss for reporting. Released as 0.4.6. --- README.org | 5 +++ org-ql.el | 19 +++++++- org-ql.info | 126 +++++++++++++++++++++++++++++----------------------- 3 files changed, 93 insertions(+), 57 deletions(-) diff --git a/README.org b/README.org index b272b15..a7d79eb 100644 --- a/README.org +++ b/README.org @@ -398,6 +398,11 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience /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.4.6 + +*Fixed* ++ Compatibility with newer versions of the =peg= library, which removed a macro used by this package. (Fixes [[https://github.com/alphapapa/org-ql/issues/75][#75]]. Thanks to [[https://github.com/novoid][Karl Voit]] and [[https://github.com/karlicoss][@karlicoss]] for reporting.) + ** 0.4.5 *Fixed* diff --git a/org-ql.el b/org-ql.el index 0307d78..f7efbbf 100644 --- a/org-ql.el +++ b/org-ql.el @@ -2,7 +2,7 @@ ;; Author: Adam Porter ;; Url: https://github.com/alphapapa/org-ql -;; Version: 0.4.5 +;; Version: 0.4.6 ;; Package-Requires: ((emacs "26.1") (dash "2.13") (dash-functional "1.2.0") (f "0.17.2") (org "9.0") (org-super-agenda "1.2-pre") (ov "1.0.6") (peg "0.6") (s "1.12.0") (ts "0.2-pre")) ;; Keywords: hypermedia, outlines, Org, agenda @@ -1529,6 +1529,21 @@ element should be a regexp string." (defvar peg-errors nil) (defvar peg-stack nil) +(defmacro org-ql--peg-parse-string (rules string &optional noerror) + "Parse STRING according to RULES. +If NOERROR is non-nil, push nil resp. t if the parse failed +resp. succeded instead of signaling an error." + ;; Unfortunately, this macro was moved to peg-tests.el, so we copy it here. + `(with-temp-buffer + (insert ,string) + (goto-char (point-min)) + ,(if noerror + (let ((entry (make-symbol "entry")) + (start (caar rules))) + `(peg-parse (entry (or (and ,start `(-- t)) "")) + . ,rules)) + `(peg-parse . ,rules)))) + (cl-eval-when (compile load eval) ;; This `eval-when' is necessary, otherwise the macro does not define ;; the function correctly, apparently because `org-ql-predicates' @@ -1555,7 +1570,7 @@ Builds the PEG expression using predicates defined in "Return query parsed from plain query string INPUT. Multiple predicates are combined with BOOLEAN." (unless (s-blank-str? input) - (let* ((query (peg-parse-string + (let* ((query (org-ql--peg-parse-string ((query (+ term (opt (+ (syntax-class whitespace) (any))))) (term (or (and negation (list positive-term) diff --git a/org-ql.info b/org-ql.info index b5d86ef..213b610 100644 --- a/org-ql.info +++ b/org-ql.info @@ -63,6 +63,7 @@ Functions / Macros Changelog +* 0.4.6: 046. * 0.4.5: 045. * 0.4.4: 044. * 0.4.3: 043. @@ -708,6 +709,7 @@ releases. * Menu: +* 0.4.6: 046. * 0.4.5: 045. * 0.4.4: 044. * 0.4.3: 043. @@ -724,9 +726,22 @@ releases. * 0.1: 01.  -File: README.info, Node: 045, Next: 044, Up: Changelog +File: README.info, Node: 046, Next: 045, Up: Changelog -5.1 0.4.5 +5.1 0.4.6 +========= + +*Fixed* + • Compatibility with newer versions of the peg library, which removed + a macro used by this package. (Fixes #75 + (https://github.com/alphapapa/org-ql/issues/75). Thanks to Karl + Voit (https://github.com/novoid) and @karlicoss + (https://github.com/karlicoss) for reporting.) + + +File: README.info, Node: 045, Next: 044, Prev: 046, Up: Changelog + +5.2 0.4.5 ========= *Fixed* @@ -738,7 +753,7 @@ File: README.info, Node: 045, Next: 044, Up: Changelog  File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog -5.2 0.4.4 +5.3 0.4.4 ========= *Fixed* @@ -750,7 +765,7 @@ File: README.info, Node: 044, Next: 043, Prev: 045, Up: Changelog  File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog -5.3 0.4.3 +5.4 0.4.3 ========= *Fixed* @@ -760,7 +775,7 @@ File: README.info, Node: 043, Next: 042, Prev: 044, Up: Changelog  File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog -5.4 0.4.2 +5.5 0.4.2 ========= *Fixed* @@ -769,7 +784,7 @@ File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog  File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog -5.5 0.4.1 +5.6 0.4.1 ========= *Fixed* @@ -779,7 +794,7 @@ File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog  File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog -5.6 0.4 +5.7 0.4 ======= _Note:_ The next release, 0.5, may include changes which will require @@ -860,7 +875,7 @@ as they will be pushed to the master branch when ready.  File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog -5.7 0.3.2 +5.8 0.3.2 ========= *Fixed* @@ -873,7 +888,7 @@ File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog  File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog -5.8 0.3.1 +5.9 0.3.1 ========= *Fixed* @@ -883,8 +898,8 @@ File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog  File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog -5.9 0.3 -======= +5.10 0.3 +======== *Added* • Alternative, non-sexp query syntax for commands org-ql-search and @@ -948,7 +963,7 @@ File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog  File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog -5.10 0.2.3 +5.11 0.2.3 ========== *Fixed* @@ -958,7 +973,7 @@ File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog  File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog -5.11 0.2.2 +5.12 0.2.2 ========== *Fixed* @@ -969,7 +984,7 @@ File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog  File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog -5.12 0.2.1 +5.13 0.2.1 ========== *Fixed* @@ -979,7 +994,7 @@ File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog  File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog -5.13 0.2 +5.14 0.2 ======== *Added* @@ -1062,7 +1077,7 @@ File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog  File: README.info, Node: 01, Prev: 02, Up: Changelog -5.14 0.1 +5.15 0.1 ======== First tagged release. @@ -1123,45 +1138,46 @@ GPLv3  Tag Table: Node: Top225 -Node: Contents1477 -Node: Screenshots1651 -Node: Installation1769 -Node: Quelpa2407 -Node: Usage2850 -Node: Commands3199 -Node: org-ql-search3672 -Node: helm-org-ql5320 -Node: org-ql-view5732 -Node: org-ql-view-sidebar5930 -Node: org-ql-view-recent-items6286 -Node: org-ql-sparse-tree6770 -Node: Queries7570 -Node: Non-sexp query syntax8478 -Node: General predicates10185 -Node: Ancestor/descendant predicates14992 -Node: Date/time predicates16120 -Node: Functions / Macros18775 -Node: Agenda-like views19008 -Node: Listing / acting-on results20413 -Node: Changelog25015 -Node: 04525619 -Node: 04425966 -Node: 04326323 -Node: 04226518 -Node: 04126677 -Node: 0426916 -Node: 03230847 -Node: 03131224 -Node: 0331419 -Node: 02334392 -Node: 02234620 -Node: 02134888 -Node: 0235087 -Node: 0139122 -Node: Notes39223 -Node: Comparison with Org Agenda searches39385 -Node: org-sidebar40256 -Node: License40535 +Node: Contents1492 +Node: Screenshots1666 +Node: Installation1784 +Node: Quelpa2422 +Node: Usage2865 +Node: Commands3214 +Node: org-ql-search3687 +Node: helm-org-ql5335 +Node: org-ql-view5747 +Node: org-ql-view-sidebar5945 +Node: org-ql-view-recent-items6301 +Node: org-ql-sparse-tree6785 +Node: Queries7585 +Node: Non-sexp query syntax8493 +Node: General predicates10200 +Node: Ancestor/descendant predicates15007 +Node: Date/time predicates16135 +Node: Functions / Macros18790 +Node: Agenda-like views19023 +Node: Listing / acting-on results20428 +Node: Changelog25030 +Node: 04625649 +Node: 04526037 +Node: 04426396 +Node: 04326753 +Node: 04226948 +Node: 04127107 +Node: 0427346 +Node: 03231277 +Node: 03131654 +Node: 0331849 +Node: 02334824 +Node: 02235052 +Node: 02135320 +Node: 0235519 +Node: 0139554 +Node: Notes39655 +Node: Comparison with Org Agenda searches39817 +Node: org-sidebar40688 +Node: License40967  End Tag Table