emacs-devel
[Top][All Lists]
Advanced

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

Re: Using incremental parsing in Emacs


From: HaiJun Zhang
Subject: Re: Using incremental parsing in Emacs
Date: Tue, 7 Jan 2020 00:36:30 +0800

Thanks for your great explanation.
在 2020年1月6日 +0800 PM9:47,Stefan Monnier <address@hidden>,写道:
I see the buffer is fontified correctly. Does it parse the whole buffer?

We have different levels of parsing. At the bottom we have
`syntax-ppss` (whose workhorse, implemented in C, is
`parse-partial-sexp`) which only counts parentheses and looks for
comment and string markers. In the above case, `syntax-ppss` indeed
parses the whole buffer, but given its limited scope this parsing is
usually fast (it can be slow in some cases, because `parse-partial-sexp`
is supplemented by `syntax-propertize-function` to handle the "unusual"
cases of "strings/comments" (a typical example would be here-documents
in shell scripts) and this is all implemented in Elisp using regexp
searches).

After this parsing is done, font-lock looks at the few lines actually
displayed using its Elisp/regexps rules to apply the actual highlighting.
This may look at more parts of the buffer, tho, depending on the actual
font-lock rules.


Stefan


reply via email to

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