From: Paul Pogonyshev <pogonyshev@gmx.net>
To: emacs-devel@gnu.org
Subject: generic buffer parsing cache data
Date: Sun, 1 Jul 2007 00:38:22 +0300 [thread overview]
Message-ID: <200707010038.23072.pogonyshev@gmx.net> (raw)
[ I'm not sure this topic was not discussed yet. Still, I haven't
seen this in any of the modes. ]
I propose adding a generic way of caching different kinds of parse
data in a buffer. Purpose is to speed up parsing when it requires
long trip back in a buffer, by reusing previous results. And to make
this generic enough, so that modes don't have to reinvent the wheel.
For instance, in `python-indentation-levels' I see:
(while (python-beginning-of-block)
...)
This means each time `python-indentaton-levels' is called, it will
temporarily travel back in the buffer until it reaches a block
starting in the first column (toplevel block.) This is not exactly
fast. Especially in major modes that need to parse something more
difficult than Python syntax.
I propose that each point position could have "cached parsing data".
This would be an alist indexed with cache data identifier. For
instance, Python mode could add sth. like
'python-mode . (def "foo" (8 4 0))
after each line starting a block. This means block type (def, class,
maybe other types if interesting to the mode), block name if
applicable, and indentation levels. Then `python-indentation-levels'
could be like this (in pseudocode):
python-beginning-of-block
forward-line
python-ensure-cache-data
return 3rd element of cache-data
where `python-ensure-cache-data' would be like
if there is cache data, just return
else:
travel to previous block
python-ensure-cache-data
build cache data for this block based on the previous
We can either reuse text property machinery or invent something else
for storing cache data. Difference of cache data is that it should
be automatically invalidated (by Emacs core, without major mode
interaction) from point position X onwards when text at X changes.
Thus, modes can be confident, that if there is some cached data at
some point Y, then it was computed with exactly the same text from
points 0 to Y.
With normal flow of work, when you navigate to some function and
start typing or editing code in it, there will be cache hits for
everything above that functions. So, reparsing will be needed only
of the function itself, not of anything above.
Does this sound as a good idea? Is it worth developing it in
more details? Or even starting with sample code?
Paul
next reply other threads:[~2007-06-30 21:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-30 21:38 Paul Pogonyshev [this message]
2007-07-01 11:48 ` generic buffer parsing cache data martin rudalics
2007-07-01 12:16 ` Paul Pogonyshev
2007-07-01 12:38 ` martin rudalics
2007-07-01 13:41 ` Paul Pogonyshev
2007-07-01 15:20 ` martin rudalics
2007-07-01 20:40 ` Richard Stallman
2007-07-01 12:45 ` Thien-Thi Nguyen
2007-07-01 13:10 ` Paul Pogonyshev
2007-07-01 13:16 ` Lennart Borgman (gmail)
2007-07-01 13:43 ` Paul Pogonyshev
2007-07-01 13:28 ` joakim
2007-07-01 12:52 ` Stefan Monnier
2007-07-01 13:49 ` Paul Pogonyshev
2007-07-01 20:08 ` Stefan Monnier
2007-07-01 20:44 ` Paul Pogonyshev
2007-07-01 21:23 ` Stefan Monnier
2007-07-01 16:32 ` Richard Stallman
2007-07-01 16:32 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200707010038.23072.pogonyshev@gmx.net \
--to=pogonyshev@gmx.net \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.