On Oct 18, 2018 5:48 PM, "Nicolas Goaziou" <m...@nicolasgoaziou.fr> wrote:

> Are you saying that queries are turned into regexp searches within Org
files? If so, I don't think they should.

Yes, because this is the fastest way to search for matching entries in a
buffer, when it's possible to use a regexp search.

> Queries should only operate on the output of the data extraction,
possibly a list of defstructs. I.e., you first extract all meaningful data
from the document (during idle time, with cache, or whatever optimization
would be chosen), store it in an appropriate format, then query it.
>
> WDYT?

That would be ideal. The problem I foresee is that, when a buffer's cache
is not up-to-date, and the user runs an agenda query, the user will have to
wait for the buffer to be parsed and cached, which is much slower than a
regexp search through the buffer.

That was what I first tried with org-agenda-ng: I parsed the whole buffer
with org-element and ran predicates against the element tree.  It was much
too slow to be practical, so I switched to the current approach, which runs
predicates against each node, only checking the necessary metadata. It's
fast enough to be useful, but can still be slow in some cases, and I don't
think it would be fast enough as a replacement for the current agenda
code.  But with further optimization, like using whole-buffer regexp
searches when possible, it might be.

Another idea I've had, similar to yours, would be to pre-process buffers,
adding metadata as text-properties on heading lines. However, I haven't
tested it, and I don't know what the performance would be like. And it
would still suffer from the caching problem I mentioned.

I think the fundamental problems are 1) keeping the cache in sync with the
raw buffer, and 2) the slow speed of parsing an entire buffer's metadata at
once (depending on the size of the files, of course, but mine are big
enough to be slow, and I'm sure many users have larger ones).

Of course, maybe someone cleverer than me can figure out a clever solution
to these problems. :)

Reply via email to