-
Notifications
You must be signed in to change notification settings - Fork 113
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
Property :inherit keyword argument not working #460
Comments
Thanks for reporting this. Please try this branch and let me know if it works for you: https://github.com/alphapapa/org-ql/compare/fix/460-property-inherit |
Fixes #460. Reported-by: Stewmath <https://github.com/Stewmath>
So, the good news is that the I didn't really want to post this because of how horrifying it is, but this is the code I'm using:
I made this so that org-ql-find would automatically be filtered with a complex s-expression on top of whatever I input. This works, but only when the I wasn't able to reduce this to a simpler example I'm afraid. I don't even totally understand everything I did here, like why I had to quote "<=" within a quote. Amazingly though it does work now, but only when |
@Stewmath That is quite a hack. I think you should be able to use the Anyway, now that I see that, I think this would be a good time to talk about what you're actually trying to do with that |
@Stewmath Regarding:
That shouldn't be giving the same error, because I've added a test for that argument form, and it passes: a00be91#diff-aaf61b821b82dbfc5f6679559b92652d45c66273959968e67b9e41d2afcb4ff2R1347 But I'm afraid the problem here is that, although the Basically, as the documentation shows, the value argument is not really optional when passing (cl-defun foo (property &optional value &key inherit)
(list property value :inherit inherit))
(foo "PROPERTY" :inherit t) ; Errors.
(foo "PROPERTY" nil :inherit t) ;; ("PROPERTY" nil :inherit t) So when writing your code, if you want to specify the inherit keyword argument, you need to pass the value argument also. |
Fixes #460. Reported-by: Stewmath <https://github.com/Stewmath>
I didn't think that query-filter or query-prefix would work for my needs, as all they do is modify the input string that gets passed in - a non-sexp query, which doesn't seem very powerful. Certainly I couldn't use Speaking of which, do you know why the following use of string-to-number doesn't work, when this kind of query would work within the context of my hack?
It gives a backtrace like this:
The purpose of the I'm certainly open to other ideas to implement something like that!
I guess this falls under "elisp knowledge", but I assumed that since the value was an "optional" parameter, I didn't need to pass it. I suppose it conflicts with the keyword arguments though. I'd consider this resolved on my end, now that I know that. I only pointed out the other failure case in my code in case you wanted to fix that, but it sounds like that's not feasible. |
Then you probably should define your own query predicate, which could then be applied to the user input as a prefix string. See the tutorial.
Because that expression is not a valid Org QL query expression in terms of the So the best solution is probably to write your own query predicate, which could use the subtree-local value of that property. But you will still need to keep in mind that doing so makes that clause of the query impossible to optimize across a whole buffer, so it should probably be appended as the final clause in the query, and other clauses should be used which can be optimized to regexps to find initial matches, with your local-level-based predicate serving as a final clause. |
That sounds logical.
I guess my real question is why on earth this sexp was valid in my hacked function:
...But not in my other example. Because as you say, it doesn't seem valid to use string-to-number like that according to the documentation, and I was mildly surprised that it worked. It seems to be interpreting my inline elisp differently in that hacked-up context. |
This allows a query like this: (level <= (string-to-number (property PROPERTY))) to proceed without signaling an error from ORG-QL--QUERY-PREAMBLE. See #460. Reported-by: Stewmath <https://github.com/Stewmath>
I just pushed a fix for that: 6edcef1 Had to look at the backtrace more carefully (was probably too late at night before). I think it should work now; try this branch, please: https://github.com/alphapapa/org-ql/compare/wip/v0.8.9 |
This allows a query like this: (level <= (string-to-number (property PROPERTY))) to proceed without signaling an error from ORG-QL--QUERY-PREAMBLE. See #460. Reported-by: Stewmath <https://github.com/Stewmath>
This does seem to fix it. More specifically, this command now works when it didn't before your last changes:
I'm still not sure why I need to quote the I will say that I appreciate your fast responses. I'm unsure exactly if I'm finding bugs in org-ql or using it in unintended ways, but regardless I appreciate the help! |
Great!
Quoting is often confusing. In this case there are various levels of query pre-processing/rewriting, macro expansion, and pattern-matching going on. Sometimes the best answer is, that's just the way it is. :)
A little bit of both, I think, which is great, as I could never find all the bugs myself. :) I also appreciate your quick replies so these issues could be iterated on. I'll probably make the v0.8.9 release with these fixes soon. |
This allows a query like this: (level <= (string-to-number (property PROPERTY))) to proceed without signaling an error from ORG-QL--QUERY-PREAMBLE. See #460. Reported-by: Stewmath <https://github.com/Stewmath>
OS/platform
Arch Linux
Emacs version and provenance
Emacs-wayland v29.3 from Arch repositories
Emacs command
COLORTERM=truecolor emacs -nw
Org version and provenance
Org commit: f398724bd53eb6af3cf4187c864ec6f89a22ef59
From doom emacs
org-ql package version and provenance
fcb4e3e
Actions taken
I am probably missing something obvious here. But
(org-ql-search (current-buffer) '(property "QL_DEPTH"))
, which worked correctly(org-ql-search (current-buffer) '(property "QL_DEPTH" :inherit t))
, which returned no results(org-ql--predicate-property "QL_DEPTH" :inherit t)
for testing purposes which produced an error (see backtrace)Observed results
The :inherit keyword argument either caused errors or produced no results, even when there were results when
:inherit
wasn`t specified.Expected results
The :inherit keyword argument should produce results
Backtrace
Results of
(org-ql--predicate-property "QL_DEPTH" :inherit t)
:Removing
t
avoided the error but did not produce the correct result.Etc.
Setting
org-use-property-inheritance
tot
also had no effect on the queries.The text was updated successfully, but these errors were encountered: