Add: (org-ql-default-predicate)

This commit is contained in:
Adam Porter 2022-06-09 22:45:51 -05:00
parent c8c89be7bc
commit 0057972069
3 changed files with 42 additions and 30 deletions

View file

@ -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.

View file

@ -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

View file

@ -1008,6 +1008,9 @@ File: README.info, Node: 07-pre, Next: 062, Up: Changelog
org-ql-find-path, which jump to entries selected using Emacss
built-in completion facilities and Org QL queries (like
helm-org-ql, but doesnt 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