It works!

This commit is contained in:
Adam Porter 2020-11-22 08:16:41 -06:00
parent 4237f4bc53
commit 0d0b6bb808

View file

@ -194,13 +194,14 @@ See Info node `(org-ql)Queries'."
;; the function correctly, apparently because `org-ql-predicates' ;; the function correctly, apparently because `org-ql-predicates'
;; ends up being not defined correctly at expansion time. ;; ends up being not defined correctly at expansion time.
(defmacro org-ql--def-plain-query-fn () (defun org-ql--def-plain-query-fn ()
"Define function `org-ql--plain-query'. "Define function `org-ql--plain-query'.
Builds the PEG expression using predicates defined in Builds the PEG expression using predicates defined in
`org-ql-predicates' and `org-ql-predicates-extra-aliases'." `org-ql-predicates' and `org-ql-predicates-extra-aliases'."
(let* ((predicates (--map (symbol-name (plist-get it :name)) (let* ((predicates (--map (symbol-name (plist-get (cdr it) :name))
org-ql-predicates)) org-ql-predicates))
(aliases (->> org-ql-predicates (aliases (->> org-ql-predicates
(-map #'cdr)
(--map (plist-get it :aliases)) (--map (plist-get it :aliases))
-non-nil -non-nil
-flatten -flatten
@ -211,7 +212,10 @@ Builds the PEG expression using predicates defined in
;; obscure bug in `peg': when one keyword is a substring of another, ;; obscure bug in `peg': when one keyword is a substring of another,
;; and the shorter one is listed first, the shorter one fails to match. ;; and the shorter one is listed first, the shorter one fails to match.
(-sort (-on #'> #'length))))) (-sort (-on #'> #'length)))))
`(cl-defun org-ql--plain-query (input &optional (boolean 'and)) (fset 'org-ql--plain-query
(byte-compile
`(cl-function
(lambda (input &optional (boolean 'and))
"Return query parsed from plain query string INPUT. "Return query parsed from plain query string INPUT.
Multiple predicates are combined with BOOLEAN." Multiple predicates are combined with BOOLEAN."
(unless (s-blank-str? input) (unless (s-blank-str? input)
@ -241,7 +245,7 @@ Multiple predicates are combined with BOOLEAN."
;; element. I don't know what it means, but we don't want it. ;; element. I don't know what it means, but we don't want it.
(if (> (length (cdr query)) 1) (if (> (length (cdr query)) 1)
(cons boolean (nreverse (cdr query))) (cons boolean (nreverse (cdr query)))
(cadr query)))))))) (cadr query)))))))))))
;;;;; Predicate definition ;;;;; Predicate definition