Support dynamic org-agenda-files in org-ql-view buffers on refresh
If I call (org-ql-search (org-agenda-files) '(todo)) it opens an org-ql-view buffer.
Pressing v i I can see that it has the expected:
a.org
Then in a scratch buffer I add b.org to org-agenda-files.
I go back to the org-ql-view buffer and refresh.
expected: The org-ql-view buffer calls (org-agenda-files) and searches b.org
actual: Only a.org is searched
We could allow the value of the BUFFERS-FILES argument to be a function.
We could allow the value of the BUFFERS-FILES argument to be a function.
This would be great. My current workaround is killing the buffer and calling the query again lol.
I looked at trying to implement this a while back but didn't understand elisp well enough. I hope to get time to look at it again soon, will post any questions/updates.
Ok, thanks.
The reason this is tricky is that we allow org-ql searches to be encoded as Org links, and if we were to allow the buffers-files argument to be a function, we would have to be very careful to prevent malicious functions from being run by unsuspecting users (e.g. imagine a malicious user sent an Org file to a target user with an org-ql-search link that had the buffers-files argument as a function that did something evil, like exfiltrate or delete data--when the user opened the link, the evil function would be called).
It might be sufficient to only permit named functions (i.e. function symbols--IOW, to refuse to call lambdas), but I'm not sure about that. I really don't want to ship code with security vulnerabilities, especially because this is not a context in which Emacs/Org users expect security vulnerabilities to even be possible, so they wouldn't be expecting to have to be careful about opening such links (compared to, e.g. getting spam or phishing emails).
For org-agenda-files specifically, we could just encode the variable differently than the function and use them as appropriate. Or maybe even just always call the org-agenda-files function rather than using the variable, which IIRC would provide the desired behavior.
What do you think?
I think you are right: Always calling (org-agenda-files) should work.