GNU bug report logs - #38049
C mode fontification broken with reposition-window

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs,cc-mode; Reported by: Juri Linkov <juri@HIDDEN>; Done: Alan Mackenzie <acm@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 38049-done <at> debbugs.gnu.org:


Received: (at 38049-done) by debbugs.gnu.org; 9 Nov 2019 14:45:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 09 09:45:22 2019
Received: from localhost ([127.0.0.1]:48381 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iTRzO-0000W4-DE
	for submit <at> debbugs.gnu.org; Sat, 09 Nov 2019 09:45:22 -0500
Received: from colin.muc.de ([193.149.48.1]:12361 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1iTRzM-0000Vu-Dr
 for 38049-done <at> debbugs.gnu.org; Sat, 09 Nov 2019 09:45:21 -0500
Received: (qmail 30531 invoked by uid 3782); 9 Nov 2019 14:45:18 -0000
Received: from acm.muc.de (p4FE155B2.dip0.t-ipconnect.de [79.225.85.178]) by
 colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 09 Nov 2019 15:45:17 +0100
Received: (qmail 8638 invoked by uid 1000); 9 Nov 2019 14:45:17 -0000
Date: Sat, 9 Nov 2019 14:45:17 +0000
To: Juri Linkov <juri@HIDDEN>
Subject: Re: bug#38049: C mode fontification broken with reposition-window
Message-ID: <20191109144517.GB5546@ACM>
References: <8736f4k8mi.fsf@HIDDEN>
 <20191105210737.GA6303@ACM>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20191105210737.GA6303@ACM>
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Delivery-Agent: TMDA/1.1.12 (Macallan)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38049-done
Cc: 38049-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Juri.

On Tue, Nov 05, 2019 at 21:07:37 +0000, Alan Mackenzie wrote:
> On Sun, Nov 03, 2019 at 22:28:05 +0200, Juri Linkov wrote:
> > Version: 27.0.50

> > This is a reproducible test case:

> > 0. emacs -Q
> > 1. C-x C-f emacs/lib-src/emacsclient.c
> > 2. M-: (progn (search-forward "create-frame" nil t) (reposition-window))

> > Then half screen displays unfontified lines.

> > Fontification doesn't fail in other modes, only in C mode.

> > This has something to do with interaction between c-font-lock
> > and buffer navigation in reposition-window.

> Indeed it does.

> Briefly,
> (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.

[ .... ]

I have fixed this bug by widening around c-font-lock-fontify-region.  I
am closing the bug with this post.

-- 
Alan Mackenzie (Nuremberg, Germany).




Notification sent to Juri Linkov <juri@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Alan Mackenzie <acm@HIDDEN>:
You have taken responsibility. Full text available.

Message received at 38049 <at> debbugs.gnu.org:


Received: (at 38049) by debbugs.gnu.org; 6 Nov 2019 20:56:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 06 15:56:12 2019
Received: from localhost ([127.0.0.1]:41320 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iSSLb-0005zC-5T
	for submit <at> debbugs.gnu.org; Wed, 06 Nov 2019 15:56:12 -0500
Received: from colin.muc.de ([193.149.48.1]:63752 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1iSSLZ-0005z0-65
 for 38049 <at> debbugs.gnu.org; Wed, 06 Nov 2019 15:56:09 -0500
Received: (qmail 58209 invoked by uid 3782); 6 Nov 2019 20:56:07 -0000
Received: from acm.muc.de (p4FE15A63.dip0.t-ipconnect.de [79.225.90.99]) by
 colin.muc.de (tmda-ofmipd) with ESMTP;
 Wed, 06 Nov 2019 21:56:05 +0100
Received: (qmail 18558 invoked by uid 1000); 6 Nov 2019 20:56:05 -0000
Date: Wed, 6 Nov 2019 20:56:05 +0000
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#38049: C mode fontification broken with reposition-window
Message-ID: <20191106205605.GB7377@ACM>
References: <8736f4k8mi.fsf@HIDDEN> <20191105210737.GA6303@ACM>
 <83zhh9exmf.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <83zhh9exmf.fsf@HIDDEN>
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Delivery-Agent: TMDA/1.1.12 (Macallan)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38049
Cc: 38049 <at> debbugs.gnu.org, juri@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

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@HIDDEN>
> > Cc: 38049 <at> 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).




Information forwarded to bug-gnu-emacs@HIDDEN, bug-cc-mode@HIDDEN:
bug#38049; Package emacs,cc-mode. Full text available.

Message received at 38049 <at> debbugs.gnu.org:


Received: (at 38049) by debbugs.gnu.org; 6 Nov 2019 17:14:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 06 12:14:09 2019
Received: from localhost ([127.0.0.1]:41199 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iSOsi-0003zn-Oh
	for submit <at> debbugs.gnu.org; Wed, 06 Nov 2019 12:14:09 -0500
Received: from eggs.gnu.org ([209.51.188.92]:34511)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1iSOsg-0003zB-Kd
 for 38049 <at> debbugs.gnu.org; Wed, 06 Nov 2019 12:14:07 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:52363)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1iSOsa-00035a-Pe; Wed, 06 Nov 2019 12:14:00 -0500
Received: from [176.228.60.248] (port=3417 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1iSOsa-0000Zi-3M; Wed, 06 Nov 2019 12:14:00 -0500
Date: Wed, 06 Nov 2019 19:13:44 +0200
Message-Id: <83zhh9exmf.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
In-reply-to: <20191105210737.GA6303@ACM> (message from Alan Mackenzie on Tue, 
 5 Nov 2019 21:07:37 +0000)
Subject: Re: bug#38049: C mode fontification broken with reposition-window
References: <8736f4k8mi.fsf@HIDDEN> <20191105210737.GA6303@ACM>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 38049
Cc: 38049 <at> debbugs.gnu.org, juri@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Tue, 5 Nov 2019 21:07:37 +0000
> From: Alan Mackenzie <acm@HIDDEN>
> Cc: 38049 <at> 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?




Information forwarded to bug-gnu-emacs@HIDDEN, bug-cc-mode@HIDDEN:
bug#38049; Package emacs,cc-mode. Full text available.

Message received at 38049 <at> debbugs.gnu.org:


Received: (at 38049) by debbugs.gnu.org; 5 Nov 2019 22:58:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 05 17:58:21 2019
Received: from localhost ([127.0.0.1]:39176 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iS7mH-0004vy-7y
	for submit <at> debbugs.gnu.org; Tue, 05 Nov 2019 17:58:21 -0500
Received: from dog.birch.relay.mailchannels.net ([23.83.209.48]:3152)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1iS7mE-0004vk-IE
 for 38049 <at> debbugs.gnu.org; Tue, 05 Nov 2019 17:58:19 -0500
X-Sender-Id: dreamhost|x-authsender|jurta@HIDDEN
Received: from relay.mailchannels.net (localhost [127.0.0.1])
 by relay.mailchannels.net (Postfix) with ESMTP id 20AE15006E0;
 Tue,  5 Nov 2019 22:58:17 +0000 (UTC)
Received: from pdx1-sub0-mail-a64.g.dreamhost.com
 (100-96-60-110.trex.outbound.svc.cluster.local [100.96.60.110])
 (Authenticated sender: dreamhost)
 by relay.mailchannels.net (Postfix) with ESMTPA id A19F950086B;
 Tue,  5 Nov 2019 22:58:16 +0000 (UTC)
X-Sender-Id: dreamhost|x-authsender|jurta@HIDDEN
Received: from pdx1-sub0-mail-a64.g.dreamhost.com ([TEMPUNAVAIL].
 [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384)
 by 0.0.0.0:2500 (trex/5.18.5); Tue, 05 Nov 2019 22:58:17 +0000
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|jurta@HIDDEN
X-MailChannels-Auth-Id: dreamhost
X-Little-Shade: 45495efa7ffa7de8_1572994696893_3919433319
X-MC-Loop-Signature: 1572994696893:345676443
X-MC-Ingress-Time: 1572994696893
Received: from pdx1-sub0-mail-a64.g.dreamhost.com (localhost [127.0.0.1])
 by pdx1-sub0-mail-a64.g.dreamhost.com (Postfix) with ESMTP id 24BEE7F51E;
 Tue,  5 Nov 2019 14:58:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc
 :subject:references:date:in-reply-to:message-id:mime-version
 :content-type; s=linkov.net; bh=X0l+SXfdqOVVP+Wmxv16SPe3988=; b=
 Akcz0wC7w8VyqrkJvX3uymEvCQIrFCLFTswPzChguLm5jHCDCtBTXUFYpxvjJqSe
 7SftJBg5vWljiFCqoVsDSpLZ1IY/4cG30XKrWLVSyE+TCLbVqvsGUfr7LdfC3Px1
 0c0yGDu3/s+hqa62px2daXGz+m593SmnhbKqPg8vGz4=
Received: from mail.jurta.org (m91-129-101-77.cust.tele2.ee [91.129.101.77])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 (Authenticated sender: jurta@HIDDEN)
 by pdx1-sub0-mail-a64.g.dreamhost.com (Postfix) with ESMTPSA id 49F667F512;
 Tue,  5 Nov 2019 14:58:08 -0800 (PST)
X-DH-BACKEND: pdx1-sub0-mail-a64
From: Juri Linkov <juri@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#38049: C mode fontification broken with reposition-window
Organization: LINKOV.NET
References: <8736f4k8mi.fsf@HIDDEN> <20191105210737.GA6303@ACM>
Date: Wed, 06 Nov 2019 00:10:29 +0200
In-Reply-To: <20191105210737.GA6303@ACM> (Alan Mackenzie's message of "Tue,
 5 Nov 2019 21:07:37 +0000")
Message-ID: <87lfsu9e6a.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38049
Cc: 38049 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> Briefly,
> (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.
>
> It would seem undesirable for the vertical-motion in (iii) to trigger
> font-locking, since it is merely trying to count lines.  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.

ISTR there was some macro to disable font-lock temporarily,
but I can't find it.  Maybe just let-binding font-lock-mode to nil
could help?




Information forwarded to bug-gnu-emacs@HIDDEN, bug-cc-mode@HIDDEN:
bug#38049; Package emacs,cc-mode. Full text available.

Message received at 38049 <at> debbugs.gnu.org:


Received: (at 38049) by debbugs.gnu.org; 5 Nov 2019 21:07:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 05 16:07:44 2019
Received: from localhost ([127.0.0.1]:39133 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iS63E-0001gD-9p
	for submit <at> debbugs.gnu.org; Tue, 05 Nov 2019 16:07:44 -0500
Received: from colin.muc.de ([193.149.48.1]:59970 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1iS63B-0001g3-W1
 for 38049 <at> debbugs.gnu.org; Tue, 05 Nov 2019 16:07:42 -0500
Received: (qmail 83771 invoked by uid 3782); 5 Nov 2019 21:07:40 -0000
Received: from acm.muc.de (p4FE15CF4.dip0.t-ipconnect.de [79.225.92.244]) by
 colin.muc.de (tmda-ofmipd) with ESMTP;
 Tue, 05 Nov 2019 22:07:37 +0100
Received: (qmail 6448 invoked by uid 1000); 5 Nov 2019 21:07:37 -0000
Date: Tue, 5 Nov 2019 21:07:37 +0000
To: Juri Linkov <juri@HIDDEN>
Subject: Re: bug#38049: C mode fontification broken with reposition-window
Message-ID: <20191105210737.GA6303@ACM>
References: <8736f4k8mi.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <8736f4k8mi.fsf@HIDDEN>
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Delivery-Agent: TMDA/1.1.12 (Macallan)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38049
Cc: 38049 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Juri.

On Sun, Nov 03, 2019 at 22:28:05 +0200, Juri Linkov wrote:
> Version: 27.0.50

> This is a reproducible test case:

> 0. emacs -Q
> 1. C-x C-f emacs/lib-src/emacsclient.c
> 2. M-: (progn (search-forward "create-frame" nil t) (reposition-window))

> Then half screen displays unfontified lines.

> Fontification doesn't fail in other modes, only in C mode.

> This has something to do with interaction between c-font-lock
> and buffer navigation in reposition-window.

Indeed it does.

Briefly,
(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.

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

Maybe there are other calls of vertical-motion which are similarly
dangerous.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN, bug-cc-mode@HIDDEN:
bug#38049; Package emacs,cc-mode. Full text available.

Message received at 38049 <at> debbugs.gnu.org:


Received: (at 38049) by debbugs.gnu.org; 3 Nov 2019 21:27:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 03 16:27:10 2019
Received: from localhost ([127.0.0.1]:35371 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iRNOw-0005N6-F7
	for submit <at> debbugs.gnu.org; Sun, 03 Nov 2019 16:27:10 -0500
Received: from colin.muc.de ([193.149.48.1]:28165 helo=mail.muc.de)
 by debbugs.gnu.org with smtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1iRNOu-0005Mp-2I
 for 38049 <at> debbugs.gnu.org; Sun, 03 Nov 2019 16:27:08 -0500
Received: (qmail 76965 invoked by uid 3782); 3 Nov 2019 21:27:06 -0000
Date: 3 Nov 2019 21:27:06 -0000
Message-ID: <20191103212706.76964.qmail@HIDDEN>
From: Alan Mackenzie <acm@HIDDEN>
To: Juri Linkov <juri@HIDDEN>
Subject: Re: bug#38049: C mode fontification broken with reposition-window
Organization: muc.de e.V.
In-Reply-To: <mailman.552.1572813126.13325.bug-gnu-emacs@HIDDEN>
X-Newsgroups: gnu.emacs.bug
User-Agent: tin/2.4.2-20171224 ("Lochhead") (UNIX) (FreeBSD/11.3-RELEASE-p3
 (amd64))
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38049
Cc: 38049 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

In article <mailman.552.1572813126.13325.bug-gnu-emacs@HIDDEN> you wrote:
> Version: 27.0.50

> This is a reproducible test case:

> 0. emacs -Q
> 1. C-x C-f emacs/lib-src/emacsclient.c
> 2. M-: (progn (search-forward "create-frame" nil t) (reposition-window))

> Then half screen displays unfontified lines.

Yes.  This is an interesting bug.

The unfontified area seems to be one jit-lock chunk immediately below
the line containing "create-frame".

> Fontification doesn't fail in other modes, only in C mode.

> This has something to do with interaction between c-font-lock
> and buffer navigation in reposition-window.

reposition-window, as far as I've been able to make out so far, seems to
assume that point starts in the current visible window.  That is not the
case here, where window-start is still at BOB, but point is at line 116.

I'll look at this in more detail when it's not so late.

-- 
Alan Mackenzie (Nuremberg, Germany).





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#38049; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 3 Nov 2019 20:31:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 03 15:31:37 2019
Received: from localhost ([127.0.0.1]:35184 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iRMXB-0003kF-E3
	for submit <at> debbugs.gnu.org; Sun, 03 Nov 2019 15:31:37 -0500
Received: from lists.gnu.org ([209.51.188.17]:50505)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1iRMXA-0003k1-DB
 for submit <at> debbugs.gnu.org; Sun, 03 Nov 2019 15:31:36 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:48965)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <juri@HIDDEN>) id 1iRMX9-00065T-Aj
 for bug-gnu-emacs@HIDDEN; Sun, 03 Nov 2019 15:31:36 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <juri@HIDDEN>) id 1iRMX8-0005P3-BE
 for bug-gnu-emacs@HIDDEN; Sun, 03 Nov 2019 15:31:35 -0500
Received: from cadetblue.birch.relay.mailchannels.net ([23.83.209.28]:20370)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <juri@HIDDEN>) id 1iRMX8-0005Lz-2d
 for bug-gnu-emacs@HIDDEN; Sun, 03 Nov 2019 15:31:34 -0500
X-Sender-Id: dreamhost|x-authsender|jurta@HIDDEN
Received: from relay.mailchannels.net (localhost [127.0.0.1])
 by relay.mailchannels.net (Postfix) with ESMTP id 93D0F3C0B92
 for <bug-gnu-emacs@HIDDEN>; Sun,  3 Nov 2019 20:31:32 +0000 (UTC)
Received: from pdx1-sub0-mail-a83.g.dreamhost.com
 (100-96-169-194.trex.outbound.svc.cluster.local [100.96.169.194])
 (Authenticated sender: dreamhost)
 by relay.mailchannels.net (Postfix) with ESMTPA id 145223C0CFF
 for <bug-gnu-emacs@HIDDEN>; Sun,  3 Nov 2019 20:31:32 +0000 (UTC)
X-Sender-Id: dreamhost|x-authsender|jurta@HIDDEN
Received: from pdx1-sub0-mail-a83.g.dreamhost.com ([TEMPUNAVAIL].
 [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384)
 by 0.0.0.0:2500 (trex/5.18.5); Sun, 03 Nov 2019 20:31:32 +0000
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|jurta@HIDDEN
X-MailChannels-Auth-Id: dreamhost
X-Keen-Obese: 2a3e710c098690d6_1572813092380_1406177609
X-MC-Loop-Signature: 1572813092380:375963069
X-MC-Ingress-Time: 1572813092380
Received: from pdx1-sub0-mail-a83.g.dreamhost.com (localhost [127.0.0.1])
 by pdx1-sub0-mail-a83.g.dreamhost.com (Postfix) with ESMTP id C958682D90
 for <bug-gnu-emacs@HIDDEN>; Sun,  3 Nov 2019 12:31:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to
 :subject:date:message-id:mime-version:content-type; s=
 linkov.net; bh=DMtKcH179JcCZdhLpaZDXNPS9sE=; b=uJtnEkLM1a17hWjPv
 l5byxkdeuMx0u5KKAlmS9y0toyc7KbiaKJ7fNtOQ5WvJaOmmwiynitW2jg0hcWkI
 /6agnZNPzNoHpjOSqDbAT2VQWqbMcbmFRVzqDbDBQ54k1UrZAMlUapdmrbhrK7GT
 CQxke1EboLtmLAfvE8a+B4V0P0=
Received: from mail.jurta.org (m91-129-101-77.cust.tele2.ee [91.129.101.77])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 (Authenticated sender: jurta@HIDDEN)
 by pdx1-sub0-mail-a83.g.dreamhost.com (Postfix) with ESMTPSA id AD54C82D92
 for <bug-gnu-emacs@HIDDEN>; Sun,  3 Nov 2019 12:31:25 -0800 (PST)
X-DH-BACKEND: pdx1-sub0-mail-a83
From: Juri Linkov <juri@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: C mode fontification broken with reposition-window
Organization: LINKOV.NET
Date: Sun, 03 Nov 2019 22:28:05 +0200
Message-ID: <8736f4k8mi.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 23.83.209.28
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

Version: 27.0.50

This is a reproducible test case:

0. emacs -Q
1. C-x C-f emacs/lib-src/emacsclient.c
2. M-: (progn (search-forward "create-frame" nil t) (reposition-window))

Then half screen displays unfontified lines.

Fontification doesn't fail in other modes, only in C mode.

This has something to do with interaction between c-font-lock
and buffer navigation in reposition-window.




Acknowledgement sent to Juri Linkov <juri@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#38049; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 9 Nov 2019 15:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.