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: Tue, 5 Nov 2019 21:07:37 +0000 Message-ID: <20191105210737.GA6303__4155.84047311626$1572989895$gmane$org@ACM> References: <8736f4k8mi.fsf@mail.linkov.net> 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="240350"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 38049@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 05 22:38:10 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 1iS6Wb-0010Kv-F8 for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Nov 2019 22:38:05 +0100 Original-Received: from localhost ([::1]:50476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iS6Wa-00083F-7H for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Nov 2019 16:38:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34613) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iS63a-0002Th-En for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2019 16:08:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iS63Z-0001w7-83 for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2019 16:08:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iS63X-0001u2-BB; Tue, 05 Nov 2019 16:08:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iS63X-0001h0-4n; Tue, 05 Nov 2019 16:08:03 -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: Tue, 05 Nov 2019 21:08:03 +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.15729880646465 (code B ref 38049); Tue, 05 Nov 2019 21:08:03 +0000 Original-Received: (at 38049) by debbugs.gnu.org; 5 Nov 2019 21:07:44 +0000 Original-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 Original-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 Original-Received: (qmail 83771 invoked by uid 3782); 5 Nov 2019 21:07:40 -0000 Original-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 Original-Received: (qmail 6448 invoked by uid 1000); 5 Nov 2019 21:07:37 -0000 Content-Disposition: inline In-Reply-To: <8736f4k8mi.fsf@mail.linkov.net> 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:170987 Archived-At: 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).