org-ql
org-ql copied to clipboard
Empty results after running org-agenda
Hi, I have an issue that I am not able to debug. My org-ql-search results are empty after having run org-agenda just once. Before that, everything works OK.
Does that ring a bell?
Thanks
I have narrowed it down. The problem only appears after using agenda custom commands that use a tag filter preset like
("H" "Home Daily Action List"
((agenda ""
((org-agenda-span 1)
(org-agenda-sorting-strategy
(quote
((agenda time-up category-up tag-up))))
(org-agenda-tag-filter-preset
(quote
("+home")))
(org-deadline-warning-days 7))))
nil nil)
The standard agenda views do not cause the problem.
I also have noticed that even after having generated a problematic agenda view, if I generate a standard agenda view, org-ql-search yields the correct results.
I suppose that some org-variable gets set by the agenda views and affects org-ql-search, but I can't find which one.
OK. I've got a workaround. If I wrap the calls to org-ql-search with
(let ((org-agenda-tag-filter nil))
...
)
I get what I expect.
I don't know if this is a bug or an expected behaviour.
I any case, org-ql is an amazing tool.
Thanks!
I also have noticed that even after having generated a problematic agenda view, if I generate a standard agenda view, org-ql-search yields the correct results.
I suppose that some org-variable gets set by the agenda views and affects org-ql-search, but I can't find which one.
org-ql
doesn't use org-agenda-tag-filter
.
From the things you've shared, it's not clear what you are actually doing, like whether you are using org-agenda-custom-commands
with org-ql-block
or calling org-ql-search
directly. Please slow down a little and give complete, start-to-finish examples.
Hi,
Sorry for the noise and the lack of proper explanation. I have prepared a minimal example to illustrate the issue. mwe-org-ql.tar.gz
The attached tarball contains an init.el to configure org (with one agenda file) and org-ql with an interactive command to perform a search. There are 2 org files, one for the agenda and the other for the org-ql search.
To reproduce the issue:
-
emacs -Q -l init.el
-
M-x org-agenda
, then choose 'a' -
M-x my/org-ql-test
-> this produces the expected result - In the agenda buffer,
M-x org-agenda-filter
and enter 'home' -> this filters the agenda by the 'home' tag - In the org-ql view buffer
M-x org-ql-view-refresh
(or 'g') -> the view becomes empty
If you go back to the agenda and remove the filters and then refresh the org-ql view, the correct results are shown.
This seems to indicate that the filters currently applied to the org-agenda, are also active in the org-ql view.
For example, if I evaluate
(let ((org-agenda-tag-filter nil))
(my/org-ql-test))
in the scratch buffer, the results are correct.
I hope this helps to understand the issue and decide whether this is a bug or an expected behaviour.
I am using emacs compiled from master.
Thanks for your patience.
Thank you. I think the problem is that we call org-agenda-finalize
, which probably hides lines that don't match the filter:
https://github.com/alphapapa/org-ql/blob/94f9e6f3031b32cf5e2149beca7074807235dcb0/org-ql-view.el#L448
One could argue that, as long as we're doing that (i.e. until a more bespoke org-ql-view-mode
is defined), the filter functionality could be useful, so it might as well be left functional. So I'm not sure what to do about this.
What do you think? Thanks.
Thanks for your quick response.
I personally found it strange, because I «live» in the agenda, so I apply filters all the time, while I use org-ql-search for other tasks and for files that may not be in the agenda (I use it to find backlinks in my custom-made zettelkasten). So I would prefer that they be decoupled,
OTOH, I understand that this can be useful. So there may be 2 non exclusive options: state this behaviour in the documentation and/or give the possibility of customizing the behaviour.
But, now that I have a workaround, I am fine with any option, even leaving things as they are.
Again, thank you very much for your great work!
Well, it is documented that the view buffers are in org-agenda-mode
, and that some features may work, but it's not guaranteed that everything will. You're the first person to report this particular issue; I don't think many people use agenda filters (I forget they even exist).
I don't think adding documentation about this particular issue would be useful, because most people wouldn't read it carefully enough to notice. :)
It might be worth resetting the filter when the view buffer is updated, so I'll leave this issue open to consider that.
Thanks for the kind words and for reporting this issue.