bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#38049: C mode fontification broken with reposition-window


From: Eli Zaretskii
Subject: bug#38049: C mode fontification broken with reposition-window
Date: Wed, 06 Nov 2019 19:13:44 +0200

> Date: Tue, 5 Nov 2019 21:07:37 +0000
> From: Alan Mackenzie <acm@muc.de>
> Cc: 38049@debbugs.gnu.org
> 
> (i) reposition-window narrows to (2758 3940) in
> repos-count-screen-lines.
> (ii) This latter function uses vertical-motion to count the lines.
> (iii) vertical-motion triggers jit-lock fontification.
> (iv) This calls (eventually) c-font-lock-fontify-region.
> (v) c-font-lock-fontify-region attempts to examine buffer text before
>   the start of the jit-lock chunk to find syntactic context.
> (vi) This is outside the visible region, so Emacs raises an exception.
> (vii) The exception is caught and discarded by an unwind-protect in
>   c-font-lock-fontify-region.
> (viii) The jit-lock chunk remains unfontified.
> 
> As Stefan M has sometimes remarked, narrowing is often not a good idea.

Narrowing is part of life.

Why can't c-font-lock-fontify-region be fixed so as not to signal an
error in these cases?  If we do, will that fix the original problem?

> It would seem undesirable for the vertical-motion in (iii) to trigger
> font-locking, since it is merely trying to count lines.

vertical-motion calls functions from the display engine, which
fontifies the text it traverses.  It doesn't only count lines, it also
counts columns in canonical character width units (i.e. actually in
pixels).  So it cannot possibly avoid fontifications because
fontification might affect how many pixels characters take on
display.  Fontifications can also affect the line count, if some
fontification code actually puts display properties on the fontified
text -- something that you rarely if ever see, but Lisp programs can
rightfully expect that.  So this idea:

> Perhaps there should be a macro `without-fontifying' which could be
> wrapped around this call to vertical-motion, if there isn't such a
> thing anyway.

cannot fly, sorry.

Let's try to fix the problem in c-font-lock-fontify-region instead,
okay?





reply via email to

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