-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
org-ql-query got error: \"‘CATEGORY’ is a malformed function\" #356
Comments
I can't reproduce this problem. You likely have a corrupted installation of the package. |
I don't know. It seems unlikely, but not impossible. I recommend:
|
i have this problem as well, it's hard to use edebug,
toggling this produces error or not. it seems to happen near
where you apply predicates function, it is somehow treating inherited tag as function |
I think I found where it comes from so org-use-property-inheritance can be list of strings, and org-ql assumes it's t or nil.
|
@pcompassion Thanks for digging into that. I can confirm the bug. This code seems to fix the problem. Please let me know if it does for you: (org-ql-defpred property (property &optional value &key inherit)
"Return non-nil if current entry has PROPERTY, and optionally VALUE.
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)."
:normalizers ((`(,predicate-names)
;; HACK: This clause protects against the case in
;; which the arguments are nil, which would cause an
;; error in `rx-to-string' in other clauses. This
;; can happen with `org-ql-completing-read',
;; e.g. when the input is "property:" while the user
;; is typing.
;; FIXME: Instead of this being moot, make this
;; predicate test for whether an entry has local
;; properties when no arguments are given.
(list 'property ""))
(`(,predicate-names ,property ,value . ,plist)
;; 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)))
`(property ,property ,value
:inherit ,(if (plist-member plist :inherit)
(plist-get plist :inherit)
(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.
;; NOTE: When inheritance is enabled, the preamble can't be used,
;; which will make the search slower.
:preambles ((`(,predicate-names ,property ,value . ,(map :inherit))
;; 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)))
:query query))
(`(,predicate-names ,property . ,(map :inherit))
;; 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
(rx-to-string `(seq bol (0+ space) ":" ,property ":" (1+ space)
(minimal-match (1+ not-newline)) eol)))
:query query)))
:body
(pcase property
('nil (user-error "Property matcher requires a PROPERTY argument"))
(_ (pcase value
('nil
;; Check that PROPERTY exists
(org-ql--value-at
(point) (lambda ()
(org-entry-get (point) property))))
(_
;; Check that PROPERTY has VALUE.
;; TODO: Since --value-at doesn't account for inheritance,
;; we should generalize --tags-at to also work for property
;; inheritance and use it here, which should be much faster.
(string-equal value (org-ql--value-at
(point) (lambda ()
(org-entry-get (point) property inherit))))))))) |
@alphapapa I confirm it works for my case. Thank you for library and support. As newcomer to elisp, I felt it was way hard to debug org-ql.el because I couldn't find the definition of the macro. Now you had requested to test that code, I couldn't find the definition using my search tool (rg) just to let you know. it could help outside people to diagnose the problem. |
@pcompassion Which macro did you have trouble finding the definition of? |
@alphapapa org-ql.el was completely hidden from me because my project search use "rg" and well c-h f could do it, but i was using my project search. under the repos directory but, at the time of debugging, i didn't know the function name, because i didn't know which function i should debug. |
The issue is that this regular expression has a null byte: Line 854 in 1314078
rg man page's documentation on the --binary option.
For libraries that are loaded into Emacs, I still don't know which macro you were looking for the definition of, though. :) |
Thanks to all for reporting and investigating this bug. I'll need to add some more tests before merging, so since this isn't a new bug, I'm retargeting for v0.8. Any users who are affected by this bug are welcome to add the code in this comment to their Emacs config temporarily: #356 (comment) |
aight, it's not so important , but not everything has to be important.. Here's what happend to me, and i thought it might happen to others, Hit a bug, only thing I could think of was , it was macro magic. I was debugging org-ql-select, and couldn't find definitions of functions that were used in org-ql-select. I didn't know until it was because rg was not scanning the file .. When I filed the bug, I was gonna try to fix the bug myself, but couldn't find the org-ql-defred When you asked me to test it, what? I couldn't find it, how am i gonna edit that function to test it. So if someone like me who's using rg and who's not familiar with elisp, might have hard time debugging the org-ql code. Today I had hard time, with org-ql again... |
Thanks for the explanation. The only possible misunderstanding I can see is this:
FYI, you can modify the variable With regard to ripgrep: shrug It's not inconceivable that a source code file might contain a null byte, so maybe you should configure ripgrep to use
I don't know what you mean by this. If you're asking for help, you'll need to be specific. But please do so in an appropriate place, not this bug report. |
Fixes #356. Reported-by: beast-pro <https://github.com/beast-pro> Reported-by: pcompassion <https://github.com/pcompassion>
Closes #346. See also #356. Reported-by: Bram Schoenmakers <https://github.com/bram85> Co-developed-by: Bram Schoenmakers <https://github.com/bram85>
org file and query:
Error Message:
org-ql--byte-compile-warning: Invalid Org QL query: "Invalid Org QL query: \"‘CATEGORY’ is a malformed function\", :warning", :error
screenshot:
org-ql version:
The text was updated successfully, but these errors were encountered: