Merge: v0.8.9
This commit is contained in:
commit
c3519fb4a0
5 changed files with 227 additions and 153 deletions
60
org-ql.el
60
org-ql.el
|
|
@ -1537,7 +1537,8 @@ COMPARATOR may be `<', `<=', `>', or `>='."
|
|||
;; is "h:" while the user is typing.
|
||||
(list :regexp (rx bol (1+ "*") " ")
|
||||
:case-fold t))
|
||||
(`(,predicate-names ,comparator-or-num ,num)
|
||||
((and `(,predicate-names ,comparator-or-num ,num)
|
||||
(guard (numberp num)))
|
||||
(let ((repeat (pcase comparator-or-num
|
||||
('< `(repeat 1 ,(1- num) "*"))
|
||||
('<= `(repeat 1 ,num "*"))
|
||||
|
|
@ -1546,7 +1547,8 @@ COMPARATOR may be `<', `<=', `>', or `>='."
|
|||
((pred integerp) `(repeat ,comparator-or-num ,num "*")))))
|
||||
(list :regexp (rx-to-string `(seq bol ,repeat " ") t)
|
||||
:case-fold t)))
|
||||
(`(,predicate-names ,num)
|
||||
((and `(,predicate-names ,num)
|
||||
(guard (numberp num)))
|
||||
(list :regexp (rx-to-string `(seq bol (repeat ,num "*") " ") t)
|
||||
:case-fold t)))
|
||||
;; NOTE: It might be necessary to take into account `org-odd-levels'; see docstring for
|
||||
|
|
@ -1802,34 +1804,62 @@ interpreted as nil or non-nil)."
|
|||
;; predicate test for whether an entry has local
|
||||
;; properties when no arguments are given.
|
||||
(list 'property ""))
|
||||
(`(,predicate-names ,property ,value . ,plist)
|
||||
(`(,predicate-names ,property)
|
||||
;; Convert keyword property arguments to strings. Non-sexp
|
||||
;; queries result in keyword property arguments (because to do
|
||||
;; otherwise would require ugly special-casing in the parsing).
|
||||
(when (keywordp property)
|
||||
(setf property (substring (symbol-name property) 1)))
|
||||
(list 'property property value
|
||||
:inherit (cond ((plist-member plist :inherit) (plist-get plist :inherit))
|
||||
((listp org-use-property-inheritance) ''selective)
|
||||
(t org-use-property-inheritance)))))
|
||||
(list 'property property))
|
||||
(`(,predicate-names ,property . ,rest)
|
||||
(pcase rest
|
||||
(`(,value)
|
||||
;; Convert keyword property arguments to strings. Non-sexp
|
||||
;; queries result in keyword property arguments (because to do
|
||||
;; otherwise would require ugly special-casing in the parsing).
|
||||
(when (keywordp property)
|
||||
(setf property (substring (symbol-name property) 1)))
|
||||
(list 'property property value))
|
||||
((and `(,value . ,plist)
|
||||
(guard (not (keywordp value))))
|
||||
;; Convert keyword property arguments to strings. Non-sexp
|
||||
;; queries result in keyword property arguments (because to do
|
||||
;; otherwise would require ugly special-casing in the parsing).
|
||||
(when (keywordp property)
|
||||
(setf property (substring (symbol-name property) 1)))
|
||||
(list 'property property value
|
||||
:inherit (cond ((plist-member plist :inherit) (plist-get plist :inherit))
|
||||
((listp org-use-property-inheritance) ''selective)
|
||||
(t org-use-property-inheritance))))
|
||||
((and plist (guard (keywordp (car rest))))
|
||||
;; Convert keyword property arguments to strings. Non-sexp
|
||||
;; queries result in keyword property arguments (because to do
|
||||
;; otherwise would require ugly special-casing in the parsing).
|
||||
(when (keywordp property)
|
||||
(setf property (substring (symbol-name property) 1)))
|
||||
(list 'property property nil
|
||||
:inherit (cond ((plist-member plist :inherit) (plist-get plist :inherit))
|
||||
((listp org-use-property-inheritance) ''selective)
|
||||
(t org-use-property-inheritance)))))))
|
||||
;; MAYBE: Should case folding be disabled for properties? What about values?
|
||||
;; MAYBE: Support (property) without args.
|
||||
|
||||
;; NOTE: When inheritance is enabled, the preamble can't be used,
|
||||
;; which will make the search slower.
|
||||
:preambles ((`(,predicate-names ,property ,value . ,(map :inherit))
|
||||
:preambles (((and `(,predicate-names ,property ,value)
|
||||
(guard (atom value)))
|
||||
;; We do NOT return nil, because the predicate still needs to be tested,
|
||||
;; because the regexp could match a string not inside a property drawer.
|
||||
(list :regexp (unless inherit
|
||||
(rx-to-string `(seq bol (0+ space) ":" ,property ":"
|
||||
(1+ space) ,value (0+ space) eol)))
|
||||
(list :regexp (rx-to-string `(seq bol (0+ space) ":" ,property ":"
|
||||
(1+ space) ,value (0+ space) eol))
|
||||
:query query))
|
||||
(`(,predicate-names ,property . ,(map :inherit))
|
||||
;; We do NOT return nil, because the predicate still needs to be tested,
|
||||
((and `(,predicate-names ,property ,value . ,plist)
|
||||
(guard (keywordp (car plist))))
|
||||
;; WE do NOT return nil, because the predicate still needs to be tested,
|
||||
;; because the regexp could match a string not inside a property drawer.
|
||||
;; NOTE: The preamble only matches if there appears to be a value.
|
||||
;; A line like ":ID: " without any other text does not match.
|
||||
(list :regexp (unless inherit
|
||||
(list :regexp (unless (plist-get plist :inherit)
|
||||
(rx-to-string `(seq bol (0+ space) ":" ,property ":" (1+ space)
|
||||
(minimal-match (1+ not-newline)) eol)))
|
||||
:query query)))
|
||||
|
|
@ -1841,7 +1871,7 @@ interpreted as nil or non-nil)."
|
|||
;; Check that PROPERTY exists
|
||||
(org-ql--value-at
|
||||
(point) (lambda ()
|
||||
(org-entry-get (point) property))))
|
||||
(org-entry-get (point) property inherit))))
|
||||
(_
|
||||
;; Check that PROPERTY has VALUE.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue