emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: /srv/bzr/emacs/trunk r101338: * lisp/emacs-lisp/syntax.el (syntax-pp


From: Dmitry Gutov
Subject: Re: /srv/bzr/emacs/trunk r101338: * lisp/emacs-lisp/syntax.el (syntax-ppss): More sanity check to catch
Date: Thu, 13 Feb 2014 05:28:46 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 12.02.2014 16:23, Stefan Monnier wrote:
In 99% of the cases, syntax-ppss is only called once during font-lock.
So, while in theory, yes, we might still get some benefits, in practice
we don't.

`syntax-propertize' can call it multiple times, though (at least in the case of ruby-mode), and that's called as often as font-lock.

Of course, another issue is "which syntax-table and syntax-propertize
function to use".  How does mmm-mode handle that currently?

It has a function called `mmm-update-submode-region', which restores the saved buffer-local values, syntax table, etc, for the mode at point. It's called:

* From post-command-hook.
* From `mmm-syntax-propertize-function', which iterates over regions, calls the aforementioned function and then the submode's syntax-propertize-function.
* From `mmm-fontify-region', which is similar, but for font-lock.
* From `mmm-indent-line' and the specialized `mmm-indent-line', because we usually want to indent by the rules of the submode at indentation, and it might be different in the middle of the line.

IOW, various stuff works, as long as mmm-mode is aware of the respective facility. Each has to be supported explicitly, though.

By the way, AFAICT, the juggling of local variables between modes (save, restore, rinse, repeat) is one of the major factors in mmm-mode performance.

There was an old `multi-mode' by Dave Love that used indirect buffers to keep the buffer-local values around, and switched between them in post-command-hook (which might or might not have been a good idea) and in `multi-fontify-region', taking advantage of the fact that fontification in an indirect buffer translates into the base buffer.

Now I hear that we shouldn't use indirect buffers. Would there be a fast way to save and restore all local variables in a buffer? This would cut down on both mmm-mode overhead and complexity.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]