From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 03 15:31:37 2019 Received: (at submit) by debbugs.gnu.org; 3 Nov 2019 20:31:37 +0000 Received: from localhost ([127.0.0.1]:35184 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iRMXB-0003kF-E3 for submit@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 ) id 1iRMXA-0003k1-DB for submit@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 ) id 1iRMX9-00065T-Aj for bug-gnu-emacs@gnu.org; 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 ) id 1iRMX8-0005P3-BE for bug-gnu-emacs@gnu.org; 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 ) id 1iRMX8-0005Lz-2d for bug-gnu-emacs@gnu.org; Sun, 03 Nov 2019 15:31:34 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 93D0F3C0B92 for ; 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 ; Sun, 3 Nov 2019 20:31:32 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org 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@jurta.org 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 ; 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@jurta.org) by pdx1-sub0-mail-a83.g.dreamhost.com (Postfix) with ESMTPSA id AD54C82D92 for ; Sun, 3 Nov 2019 12:31:25 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a83 From: Juri Linkov To: bug-gnu-emacs@gnu.org Subject: C mode fontification broken with reposition-window Organization: LINKOV.NET Date: Sun, 03 Nov 2019 22:28:05 +0200 Message-ID: <8736f4k8mi.fsf@mail.linkov.net> 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@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 03 16:27:10 2019 Received: (at 38049) by debbugs.gnu.org; 3 Nov 2019 21:27:10 +0000 Received: from localhost ([127.0.0.1]:35371 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iRNOw-0005N6-F7 for submit@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 ) id 1iRNOu-0005Mp-2I for 38049@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@mail.muc.de> From: Alan Mackenzie To: Juri Linkov Subject: Re: bug#38049: C mode fontification broken with reposition-window Organization: muc.de e.V. In-Reply-To: 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@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) In article 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). From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 05 16:07:44 2019 Received: (at 38049) by debbugs.gnu.org; 5 Nov 2019 21:07:44 +0000 Received: from localhost ([127.0.0.1]:39133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iS63E-0001gD-9p for submit@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 ) id 1iS63B-0001g3-W1 for 38049@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 Subject: Re: bug#38049: C mode fontification broken with reposition-window Message-ID: <20191105210737.GA6303@ACM> References: <8736f4k8mi.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8736f4k8mi.fsf@mail.linkov.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38049 Cc: 38049@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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). From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 05 17:58:21 2019 Received: (at 38049) by debbugs.gnu.org; 5 Nov 2019 22:58:21 +0000 Received: from localhost ([127.0.0.1]:39176 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iS7mH-0004vy-7y for submit@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 ) id 1iS7mE-0004vk-IE for 38049@debbugs.gnu.org; Tue, 05 Nov 2019 17:58:19 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org 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@jurta.org 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@jurta.org 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@jurta.org) 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 To: Alan Mackenzie Subject: Re: bug#38049: C mode fontification broken with reposition-window Organization: LINKOV.NET References: <8736f4k8mi.fsf@mail.linkov.net> <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@mail.linkov.net> 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@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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? From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 06 12:14:09 2019 Received: (at 38049) by debbugs.gnu.org; 6 Nov 2019 17:14:09 +0000 Received: from localhost ([127.0.0.1]:41199 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iSOsi-0003zn-Oh for submit@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 ) id 1iSOsg-0003zB-Kd for 38049@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 ) 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 ) 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@gnu.org> From: Eli Zaretskii To: Alan Mackenzie 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@mail.linkov.net> <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@debbugs.gnu.org, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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. 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? From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 06 15:56:12 2019 Received: (at 38049) by debbugs.gnu.org; 6 Nov 2019 20:56:12 +0000 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 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 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 Subject: Re: bug#38049: C mode fontification broken with reposition-window 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 Content-Disposition: inline In-Reply-To: <83zhh9exmf.fsf@gnu.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38049 Cc: 38049@debbugs.gnu.org, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 > > 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). From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 09 09:45:22 2019 Received: (at 38049-done) by debbugs.gnu.org; 9 Nov 2019 14:45:22 +0000 Received: from localhost ([127.0.0.1]:48381 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iTRzO-0000W4-DE for submit@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 ) id 1iTRzM-0000Vu-Dr for 38049-done@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 Subject: Re: bug#38049: C mode fontification broken with reposition-window Message-ID: <20191109144517.GB5546@ACM> References: <8736f4k8mi.fsf@mail.linkov.net> <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 X-Primary-Address: acm@muc.de X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38049-done Cc: 38049-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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). From unknown Fri Jun 13 10:55:27 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 08 Dec 2019 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator