--- Begin Message ---
Subject: |
27.0.50; font-lock-ensure fontifies the whole buffer |
Date: |
Wed, 19 Dec 2018 00:15:12 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
X-Debbugs-CC: Stefan Monnier <address@hidden>
The simplest test case to reproduce this is to eval in emacs -Q:
(with-temp-buffer
(insert "#include <stdio.h>\n\nmain()\n{\n printf(\"Hello, world\");\n}")
(c-mode)
(font-lock-ensure 21 (point-max))
(get-text-property (point-min) 'face))
that returns
=> font-lock-preprocessor-face
This means that `font-lock-ensure' fontifies not only the given region,
but also the whole buffer.
OTOH,
(with-temp-buffer
(insert "#include <stdio.h>\n\nmain()\n{\n printf(\"Hello, world\");\n}")
(c-mode)
(font-lock-fontify-region 21 (point-max))
(get-text-property (point-min) 'face))
returns `nil' that means that it fontifies only within the specified boundary.
This difference is essential for bug#33567: Syntactic fontification of diff
hunks
where fontifying the whole buffer might slow down fontification of diff hunks
that are small parts of the whole buffer.
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#33798: 27.0.50; font-lock-ensure fontifies the whole buffer |
Date: |
Wed, 19 Dec 2018 23:56:05 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
>> I can see the same effect in internal buffers created by diff-mode:
>> switching to these buffers I see that font-lock-ensure fontifies
>> the whole buffer, whereas using font-lock-fontify-region I see only
>> small parts of the source buffer fontified corresponding to diff hunks.
>
> I installed a patch into `master` which should fix this.
> Could you check it works for your cases?
I checked that it works now in all cases and fontifies only needed hunks,
so I updated diff-mode to always use font-lock-ensure.
--- End Message ---