[Top][All Lists]

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

Re: font-lock-syntactic-keywords obsolet?

From: Dmitry Gutov
Subject: Re: font-lock-syntactic-keywords obsolet?
Date: Tue, 21 Jun 2016 19:28:03 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2

On 06/21/2016 06:26 PM, Alan Mackenzie wrote:

If Emacs is supposed to keep the syntax-table value on the last
character up to date using after-change-functions, it will have to scan
the whole 300000 line buffer after every keypress.

Could it not restrict the scanning to cases where a "`" is inserted or

Even if we could, it would be more like "cases where `, /, " or % are inserted or deleted" (with actually more cases, and complex logic for the cases' detection).

But "auuugh Ruby Mode is slow when I type /" would be a problem anyway, just look at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22884.

Do you not have to do the scanning anyway when you type in "`"
at the end of the "b = :`" line?

I don't. ` has the syntax "string delimiter" in ruby-mode-syntax-table.

When ruby-syntax-propertize is called on the last line, it just checks what (syntax-ppss POSITION-OF-THE-LAST-`) returns. If the return value says "inside a string", we do not apply syntax-table value "symbol" to the last `. Otherwise, we do.

This way, the full scan is replaced with a call to (syntax-ppss), which uses cache. In more complex cases, we can go look at the actual character that begins the string (or a string-like literal) that we're currently inside, parse the text around it locally a bit, and so on, but this is always faster that scanning the whole buffer.

reply via email to

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