From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#22256: 25.0.50; multiline font-lock rules broken in C mode Date: 29 Dec 2015 21:06:11 -0000 Organization: muc.de e.V. Message-ID: <20151229210611.64245.qmail@mail.muc.de> References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1451423242 18812 80.91.229.3 (29 Dec 2015 21:07:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 29 Dec 2015 21:07:22 +0000 (UTC) Cc: 22256@debbugs.gnu.org To: Anders Lindgren Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 29 22:07:14 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aE1U8-0007rd-Lo for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Dec 2015 22:07:12 +0100 Original-Received: from localhost ([::1]:50161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aE1U8-0000S8-01 for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Dec 2015 16:07:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aE1U4-0000RX-4P for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2015 16:07:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aE1U2-00060w-PN for bug-gnu-emacs@gnu.org; Tue, 29 Dec 2015 16:07:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41379) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aE1Ty-00060Z-AS; Tue, 29 Dec 2015 16:07:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aE1Ty-00044C-3I; Tue, 29 Dec 2015 16:07: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: Tue, 29 Dec 2015 21:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22256 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 22256-submit@debbugs.gnu.org id=B22256.145142317415563 (code B ref 22256); Tue, 29 Dec 2015 21:07:02 +0000 Original-Received: (at 22256) by debbugs.gnu.org; 29 Dec 2015 21:06:14 +0000 Original-Received: from localhost ([127.0.0.1]:48981 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aE1TC-00042w-69 for submit@debbugs.gnu.org; Tue, 29 Dec 2015 16:06:14 -0500 Original-Received: from mail.muc.de ([193.149.48.3]:55995) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aE1TA-00042n-Bg for 22256@debbugs.gnu.org; Tue, 29 Dec 2015 16:06:12 -0500 Original-Received: (qmail 64246 invoked by uid 3782); 29 Dec 2015 21:06:11 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.3.1-20141224 ("Tallant") (UNIX) (FreeBSD/10.2-RELEASE-p7 (amd64)) 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: 208.118.235.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:110986 Archived-At: Hello, Anders. In article you wrote: > [-- text/plain, encoding 7bit, charset: UTF-8, 143 lines --] > Hi! > In C and related modes, multiline font-lock rules no longer work as > expected. It looks like a few lines are highlighted, but not all of them. > For example: > Eval the following: > (defvar my-multiline-test-keywords > '(("^X" > ("^.+$" > (progn (beginning-of-line) > (point-max)) > nil > (0 'highlight))))) > (defun my-multiline-test-add () > (interactive) > (font-lock-add-keywords nil my-multiline-test-keywords) > (font-lock-flush)) > Insert the following in a new buffer: > X START OF A HIGHLIGHTED BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK > Do: > M-x c-mode RET > M-x my-multiline-test-add RET > I expect the entire buffer to be highlighted. However, only the first eight > lines are highlighted. When the block is edited, different parts of the > block is highlighted and unhighlighted. This is caused by the jit-lock mechanism. The first eight lines are 500 characters (jit-lock-chunk-size) rounded up to a whole number of lines. What happens is this: when the first jit-lock-chunk (8 lines) is fontified, the `fontified' property (the one the display engine uses) is set only on these 8 lines. The `face' property is then set on all the characters of the file, as requested by the my-multiline-test-keywords form. Next thing, jit-lock fontifies the next chunk of ~7 lines starting where the `fontified' property is nil. The first thing done is to set `fontified' on these ~7 lines, then the `face' property on them is erased. There is now no matching font lock pattern to apply any new faces to these ~7 lines, since the "X" is many lines back. The same thing happens with the next 500 byte chunk, and so on till the end of the buffer. If you set `font-lock-support-mode' to nil and restart font locking, the problem isn't apparent. (Then set the variable back to 'jit-lock-mode.) This is a fundamental problem with jit-lock-mode: the assumption that text to be fontified has no non-trivial context. This is a difficult problem to solve in general. CC Mode uses some ad-hoc tricks to catch, for example, long struct declarations. > As a contrast, when `emacs-lisp-mode' is used, the entire block is > highlighted, and editing does not change the highlighting. I do not see this in Emacs 24.5. For me, even in emacs-lisp-mode, I still see just the 8 lines being fontified. If you could give me a recipe (starting from emacs-24.5 -Q) to reproduce this, I'd be very interested. > This worked as intended in Emacs 24.5. > -- Anders Lindgren > In GNU Emacs 25.0.50.60 (x86_64-apple-darwin14.5.0, NS appkit-1348.17 > Version 10.10.5 (Build 14F27)) > of 2015-12-28 > Repository revision: e9916d8880561cc06b6cb73bafe7257b93ffbf4c > Windowing system distributor 'Apple', version 10.3.1348 > Configured using: > 'configure --without-dbus' > Configured features: > ACL ZLIB TOOLKIT_SCROLL_BARS NS > Important settings: > value of $LC_CTYPE: UTF-8 > locale-coding-system: utf-8-unix > Major mode: C/l > Minor modes in effect: > preproc-font-lock-global-mode: t > preproc-font-lock-mode: t > tooltip-mode: t > global-eldoc-mode: t > electric-indent-mode: t > mouse-wheel-mode: t > tool-bar-mode: t > menu-bar-mode: t > file-name-shadow-mode: t > global-font-lock-mode: t > font-lock-mode: t > blink-cursor-mode: t > auto-composition-mode: t > auto-encryption-mode: t > auto-compression-mode: t > line-number-mode: t > transient-mark-mode: t > abbrev-mode: t [ .... ] -- Alan Mackenzie (Nuremberg, Germany).