From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#38049: C mode fontification broken with reposition-window Date: Wed, 6 Nov 2019 20:56:05 +0000 Message-ID: <20191106205605.GB7377@ACM> References: <8736f4k8mi.fsf@mail.linkov.net> <20191105210737.GA6303@ACM> <83zhh9exmf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="193766"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 38049@debbugs.gnu.org, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 06 21:57:17 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iSSMe-000oHY-LL for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Nov 2019 21:57:16 +0100 Original-Received: from localhost ([::1]:35080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSSMd-0006PG-AN for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Nov 2019 15:57:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50635) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSSMV-0006Ov-Nn for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2019 15:57:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iSSMU-00070b-Jq for bug-gnu-emacs@gnu.org; Wed, 06 Nov 2019 15:57:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60732) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iSSMQ-0006zh-IG; Wed, 06 Nov 2019 15:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iSSMQ-00060e-DR; Wed, 06 Nov 2019 15:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Wed, 06 Nov 2019 20:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38049 X-GNU-PR-Package: emacs,cc-mode Original-Received: via spool by 38049-submit@debbugs.gnu.org id=B38049.157307377223020 (code B ref 38049); Wed, 06 Nov 2019 20:57:02 +0000 Original-Received: (at 38049) by debbugs.gnu.org; 6 Nov 2019 20:56:12 +0000 Original-Received: from localhost ([127.0.0.1]:41320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iSSLb-0005zC-5T for submit@debbugs.gnu.org; Wed, 06 Nov 2019 15:56:12 -0500 Original-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 ) id 1iSSLZ-0005z0-65 for 38049@debbugs.gnu.org; Wed, 06 Nov 2019 15:56:09 -0500 Original-Received: (qmail 58209 invoked by uid 3782); 6 Nov 2019 20:56:07 -0000 Original-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 Original-Received: (qmail 18558 invoked by uid 1000); 6 Nov 2019 20:56:05 -0000 Content-Disposition: inline In-Reply-To: <83zhh9exmf.fsf@gnu.org> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:171045 Archived-At: 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 > > 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).