From 0057972069a39fa03f941ee63aa211db3e2177fc Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Thu, 9 Jun 2022 22:45:51 -0500 Subject: [PATCH] Add: (org-ql-default-predicate) --- README.org | 1 + org-ql.el | 12 +++++++++-- org-ql.info | 59 ++++++++++++++++++++++++++++------------------------- 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/README.org b/README.org index 64233d0..2a07b87 100644 --- a/README.org +++ b/README.org @@ -539,6 +539,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like: *Added* + Commands ~org-ql-find~, ~org-ql-find-heading~, and ~org-ql-find-path~, which jump to entries selected using Emacs's built-in completion facilities and Org QL queries (like ~helm-org-ql~, but doesn't require Helm.). ++ Option ~org-ql-default-predicate~, applied to plain-string query tokens (before, the ~regexp~ predicate was always used, but now it may be customized). *Changed* + Give more useful error message for invalid queries. diff --git a/org-ql.el b/org-ql.el index ebd3f89..56ab9ea 100644 --- a/org-ql.el +++ b/org-ql.el @@ -298,6 +298,14 @@ See Info node `(org-ql)Queries'." :type 'boolean :risky t) +(defcustom org-ql-default-predicate 'regexp + "Predicate used for plain-string tokens without a specified predicate." + :type '(choice (const heading) + (const heading-regexp) + (const regexp) + (const outline-path) + (const outline-path-segment))) + ;;;; Functions ;;;;; Query execution @@ -862,7 +870,7 @@ value of `org-ql-predicates')." positive-term)) (positive-term (or (and predicate-with-args `(pred args -- (cons (intern pred) args))) (and predicate-without-args `(pred -- (list (intern pred)))) - (and plain-string `(s -- (list 'regexp s))))) + (and plain-string `(s -- (list org-ql-default-predicate s))))) (plain-string (or quoted-arg unquoted-arg)) (predicate-with-args (substring predicate) ":" args) (predicate-without-args (substring predicate) ":") @@ -945,7 +953,7 @@ defined in `org-ql-predicates' by calling `org-ql-defpred'." (`(unless ,condition . ,clauses) `(unless ,(rec condition) ,@(mapcar #'rec clauses))) ;; TODO: Combine (regexp) when appropriate (i.e. inside an OR, not an AND). - ((pred stringp) `(regexp ,element)) + ((pred stringp) `(,org-ql-default-predicate ,element)) ,@normalizer-patterns diff --git a/org-ql.info b/org-ql.info index 89eede3..5205d5c 100644 --- a/org-ql.info +++ b/org-ql.info @@ -1008,6 +1008,9 @@ File: README.info, Node: 07-pre, Next: 062, Up: Changelog ‘org-ql-find-path’, which jump to entries selected using Emacs’s built-in completion facilities and Org QL queries (like ‘helm-org-ql’, but doesn’t require Helm.). + • Option ‘org-ql-default-predicate’, applied to plain-string query + tokens (before, the ‘regexp’ predicate was always used, but now it + may be customized). *Changed* • Give more useful error message for invalid queries. @@ -1656,34 +1659,34 @@ Node: Links36258 Node: Tips36945 Node: Changelog37269 Node: 07-pre38037 -Node: 06238465 -Node: 06138773 -Node: 0639341 -Node: 05242395 -Node: 05142695 -Node: 0543118 -Node: 04944647 -Node: 04844927 -Node: 04745274 -Node: 04645683 -Node: 04546091 -Node: 04446452 -Node: 04346811 -Node: 04247014 -Node: 04147175 -Node: 0447422 -Node: 03251523 -Node: 03151926 -Node: 0352123 -Node: 02355423 -Node: 02255657 -Node: 02155937 -Node: 0256142 -Node: 0160220 -Node: Notes60321 -Node: Comparison with Org Agenda searches60483 -Node: org-sidebar61372 -Node: License61651 +Node: 06238642 +Node: 06138950 +Node: 0639518 +Node: 05242572 +Node: 05142872 +Node: 0543295 +Node: 04944824 +Node: 04845104 +Node: 04745451 +Node: 04645860 +Node: 04546268 +Node: 04446629 +Node: 04346988 +Node: 04247191 +Node: 04147352 +Node: 0447599 +Node: 03251700 +Node: 03152103 +Node: 0352300 +Node: 02355600 +Node: 02255834 +Node: 02156114 +Node: 0256319 +Node: 0160397 +Node: Notes60498 +Node: Comparison with Org Agenda searches60660 +Node: org-sidebar61549 +Node: License61828  End Tag Table