Fix: (property) Handle org-use-property-inheritance when unspecified

Fixes #356.

Reported-by: beast-pro <https://github.com/beast-pro>
Reported-by: pcompassion <https://github.com/pcompassion>
This commit is contained in:
Adam Porter 2023-12-16 04:59:12 -06:00
parent 004ed1ee0f
commit 1496185141
3 changed files with 72 additions and 59 deletions

View file

@ -248,7 +248,7 @@ Arguments are listed next to predicate names, where applicable.
- Aliases: ~olps~.
+ =path (&rest regexps)= :: Return non-nil if current heading's buffer's filename path matches any of ~REGEXPS~ (regexp strings). Without arguments, return non-nil if buffer is file-backed.
+ =priority (&rest args)= :: Return non-nil if current heading has a certain priority. ~ARGS~ may be either a list of one or more priority letters as strings, or a comparator function symbol followed by a priority letter string. For example: ~(priority "A") (priority "A" "B") (priority '>= "B")~ Note that items without a priority cookie never match this predicate (while Org itself considers items without a cookie to have the default priority, which, by default, is equal to priority ~B~).
+ =property (property &optional value &key inherit)= :: Return non-nil if current entry has ~PROPERTY~ (a string), and optionally ~VALUE~ (a string). If ~INHERIT~ is nil, only match entries with ~PROPERTY~ set on the entry; if t, also match entries with inheritance. If ~INHERIT~ is not specified, use the Boolean value of ~org-use-property-inheritance~, which see (i.e. it is only interpreted as nil or non-nil).
+ =property (property &optional value &key inherit)= :: Return non-nil if current entry has ~PROPERTY~ (a string), and optionally ~VALUE~ (a string). If ~INHERIT~ is nil, only match entries with ~PROPERTY~ set on the entry; if t, also match entries with inheritance. If ~INHERIT~ is not specified, use the value of ~org-use-property-inheritance~, which see.
+ =regexp (&rest regexps)= :: Return non-nil if current entry matches all of ~REGEXPS~ (regexp strings). Matches against entire entry, from beginning of its heading to the next heading.
- Aliases: =r=.
+ =rifle (&rest strings)= :: Return non-nil if each string is found in either the entry or its outline path. Works like =org-rifle=. This is probably the most useful, intuitive, general-purpose predicate.
@ -563,6 +563,10 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
+ Command ~org-ql-open-link~, which finds links in entries matching the given query, and opens the selected one with ~org-open-at-point~. (This is helpful when a collection of links are kept in Org files: rather than having to first visit the entry containing the desired link, then locate it within the entry, and then open it, the user can simply select the link and open it directly.)
+ Items in ~org-ql-view~ buffers now include the ~org-category~ text property, like Org Agenda buffers, which allows grouping with ~org-super-agenda~'s category-related selectors. ([[https://github.com/alphapapa/org-ql/issues/363][#363]]. Thanks to [[https://github.com/kofm][Gabriele Mongiano]] for reporting.)
*Fixes*
+ Predicate ~property~ correctly uses the value of ~org-use-property-inheritance~ when not specified ([[https://github.com/alphapapa/org-ql/issues/356][#356]]).
*Compatibility*
+ Org v9.7's ~org-element~ API changes required some adjustments. ([[https://github.com/alphapapa/org-ql/issues/364][#364]]. Thanks to several users for reporting, and to [[https://github.com/yantar92][Ihor Radchenko]] for his feedback.)

View file

@ -1823,10 +1823,14 @@ interpreted as nil or non-nil)."
;; otherwise would require ugly special-casing in the parsing).
(when (keywordp property)
(setf property (substring (symbol-name property) 1)))
(list 'property property value
:inherit (if (plist-member plist :inherit)
(plist-get plist :inherit)
org-use-property-inheritance))))
`(property ,property ,value
:inherit ,(if (plist-member plist :inherit)
(plist-get plist :inherit)
;; TODO: Add tests for these cases.
(pcase org-use-property-inheritance
(`nil nil) (`t t)
((pred stringp) org-use-property-inheritance)
((pred listp) `(quote ,org-use-property-inheritance)))))))
;; MAYBE: Should case folding be disabled for properties? What about values?
;; MAYBE: Support (property) without args.

View file

@ -521,9 +521,8 @@ Arguments are listed next to predicate names, where applicable.
Return non-nil if current entry has PROPERTY (a string), and
optionally VALUE (a string). If INHERIT is nil, only match
entries with PROPERTY set on the entry; if t, also match entries
with inheritance. If INHERIT is not specified, use the Boolean
value of org-use-property-inheritance, which see (i.e. it is
only interpreted as nil or non-nil).
with inheritance. If INHERIT is not specified, use the value of
org-use-property-inheritance, which see.
regexp (&rest regexps)
Return non-nil if current entry matches all of REGEXPS (regexp
strings). Matches against entire entry, from beginning of its
@ -1095,6 +1094,12 @@ File: README.info, Node: 08-pre, Next: 074, Up: Changelog
(https://github.com/alphapapa/org-ql/issues/363). Thanks to
Gabriele Mongiano (https://github.com/kofm) for reporting.)
*Fixes*
• Predicate property correctly uses the value of
org-use-property-inheritance when not specified (#356
(https://github.com/alphapapa/org-ql/issues/356)).
*Compatibility*
• Org v9.7s org-element API changes required some adjustments.
@ -1875,57 +1880,57 @@ Node: org-ql-sparse-tree10124
Node: Queries10924
Node: Non-sexp query syntax12041
Node: General predicates13800
Node: Ancestor/descendant predicates20787
Node: Date/time predicates21915
Node: Functions / Macros25039
Node: Agenda-like views25337
Ref: Function org-ql-block25499
Node: Listing / acting-on results26760
Ref: Caching26968
Ref: Function org-ql-select27881
Ref: Function org-ql-query30307
Ref: Macro org-ql (deprecated)32081
Node: Custom predicates32396
Ref: Macro org-ql-defpred32620
Node: Dynamic block36061
Node: Links38785
Node: Tips39472
Node: Changelog39796
Node: 08-pre40620
Node: 07442732
Node: 07342959
Node: 07243691
Node: 07144610
Node: 0745419
Node: 06348343
Node: 06248874
Node: 06149179
Node: 0649747
Node: 05252803
Node: 05153105
Node: 0553530
Node: 04955061
Node: 04855343
Node: 04755692
Node: 04656101
Node: 04556509
Node: 04456870
Node: 04357229
Node: 04257432
Node: 04157593
Node: 0457840
Node: 03261941
Node: 03162344
Node: 0362541
Node: 02365841
Node: 02266075
Node: 02166355
Node: 0266560
Node: 0170638
Node: Notes70739
Node: Comparison with Org Agenda searches70901
Node: org-sidebar71790
Node: License72069
Node: Ancestor/descendant predicates20725
Node: Date/time predicates21853
Node: Functions / Macros24977
Node: Agenda-like views25275
Ref: Function org-ql-block25437
Node: Listing / acting-on results26698
Ref: Caching26906
Ref: Function org-ql-select27819
Ref: Function org-ql-query30245
Ref: Macro org-ql (deprecated)32019
Node: Custom predicates32334
Ref: Macro org-ql-defpred32558
Node: Dynamic block35999
Node: Links38723
Node: Tips39410
Node: Changelog39734
Node: 08-pre40558
Node: 07442864
Node: 07343091
Node: 07243823
Node: 07144742
Node: 0745551
Node: 06348475
Node: 06249006
Node: 06149311
Node: 0649879
Node: 05252935
Node: 05153237
Node: 0553662
Node: 04955193
Node: 04855475
Node: 04755824
Node: 04656233
Node: 04556641
Node: 04457002
Node: 04357361
Node: 04257564
Node: 04157725
Node: 0457972
Node: 03262073
Node: 03162476
Node: 0362673
Node: 02365973
Node: 02266207
Node: 02166487
Node: 0266692
Node: 0170770
Node: Notes70871
Node: Comparison with Org Agenda searches71033
Node: org-sidebar71922
Node: License72201

End Tag Table