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: Alan Mackenzie
Subject: bug#38049: C mode fontification broken with reposition-window
Date: Wed, 6 Nov 2019 20:56:05 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

Hello, Eli.

On Wed, Nov 06, 2019 at 19:13:44 +0200, Eli Zaretskii wrote:
> > 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.

Indeed.

> 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?

Yes.  Thinking about it, font locking might present
c-font-lock-fontify-region a chunk in any state of narrowing.  It just
doesn't happen that way very often, though.  So CC Mode needs to widen
the buffer to make sure it has adequate access.

> > 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.

Yes, accepted and understood.

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

I'll do that.  It just needs a simple widen in a save-restriction.

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

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