From unknown Thu Sep 11 11:56:27 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#22256 <22256@debbugs.gnu.org> To: bug#22256 <22256@debbugs.gnu.org> Subject: Status: 25.0.50; multiline font-lock rules broken in C mode Reply-To: bug#22256 <22256@debbugs.gnu.org> Date: Thu, 11 Sep 2025 18:56:27 +0000 retitle 22256 25.0.50; multiline font-lock rules broken in C mode reassign 22256 emacs,cc-mode submitter 22256 Anders Lindgren severity 22256 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 05:19:46 2015 Received: (at submit) by debbugs.gnu.org; 28 Dec 2015 10:19:46 +0000 Received: from localhost ([127.0.0.1]:45332 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aDUu1-0000NL-Ng for submit@debbugs.gnu.org; Mon, 28 Dec 2015 05:19:46 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54504) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aDUtz-0000N8-26 for submit@debbugs.gnu.org; Mon, 28 Dec 2015 05:19:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aDUtr-00060c-Sr for submit@debbugs.gnu.org; Mon, 28 Dec 2015 05:19:37 -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,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:35728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDUtr-00060X-PD for submit@debbugs.gnu.org; Mon, 28 Dec 2015 05:19:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDUtp-0005wP-NK for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2015 05:19:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aDUtn-000600-H3 for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2015 05:19:33 -0500 Received: from mail-vk0-x229.google.com ([2607:f8b0:400c:c05::229]:34515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDUtn-0005zv-BC for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2015 05:19:31 -0500 Received: by mail-vk0-x229.google.com with SMTP id a123so18596146vkh.1 for ; Mon, 28 Dec 2015 02:19:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=CeG11GVmIm4irSHi54T+/34/MlnGlNq41BZQfIp0rO0=; b=w4p2P48tFiUMVIzE280mmGNmep7VHmXJ2+jMG62cZZ4NLbXsxsY00mgmJRYNM65HH+ krFNZxn6mzREbm4cfjkQhQLsKm3SBXZb+w2oyN+Ake+Nr3/vvRphRlplfjhsH3DOG7TM R6MCg0NXUgnuXgBbuVpLEOdH6dnxJhL7G8XkCs5CS/ppO/ePD/tqrwkzKJp5jPrsel/c pgxL+i35YnfVSDSPnYMqvCAmkMv0t18wVEE2cBaSjS4EYa16a8AXG7g6brMyqFby1w+M gYIp/a0H/HG76lIfeE6VUpqaAXcplZTTDD7t6eWh7Jljyrj712APxotZ/5jFXt+qrb+k T8yg== MIME-Version: 1.0 X-Received: by 10.31.54.134 with SMTP id d128mr31519701vka.26.1451297970623; Mon, 28 Dec 2015 02:19:30 -0800 (PST) Received: by 10.31.214.131 with HTTP; Mon, 28 Dec 2015 02:19:30 -0800 (PST) Date: Mon, 28 Dec 2015 11:19:30 +0100 Message-ID: Subject: 25.0.50; multiline font-lock rules broken in C mode From: Anders Lindgren To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary=001a11438ee8009b7f0527f2a46a X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) 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: -4.0 (----) --001a11438ee8009b7f0527f2a46a Content-Type: text/plain; charset=UTF-8 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. As a contrast, when `emacs-lisp-mode' is used, the entire block is highlighted, and editing does not change the highlighting. 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 Recent messages: previous-line: Beginning of buffer [6 times] Preproc-Font-Lock mode enabled in current buffer Making completion list... [2 times] Type C-x 1 to delete the help window. Making completion list... [2 times] previous-line: Beginning of buffer [4 times] Saving file /Users/anders/emacs/src/bugs/multiline.c... Wrote /Users/anders/emacs/src/bugs/multiline.c Making completion list... [2 times] Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message dired format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils pp help-fns dabbrev character-fold misearch multi-isearch cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs cus-start cus-load preproc-font-lock easy-mmode vc-dispatcher vc-svn seq byte-opt gv bytecomp byte-compile cconv cl-extra help-mode easymenu cl-loaddefs pcase cl-lib time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel ns-win term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote cocoa ns multi-tty make-network-process emacs) Memory information: ((conses 16 125810 6766) (symbols 48 22477 0) (miscs 40 92 691) (strings 32 31081 19325) (string-bytes 1 1057796) (vectors 16 15058) (vector-slots 8 499686 7007) (floats 8 160 240) (intervals 56 3315 21) (buffers 976 15)) --001a11438ee8009b7f0527f2a46a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi!

In C and related modes, multiline font-lock rul= es no longer work as expected. It looks like a few lines are highlighted, b= ut not all of them.

For example:
Eval the following:
(defvar m= y-multiline-test-keywords
=C2=A0'(("^X"
=C2=A0 =C2=A0 = =C2=A0("^.+$"
=C2=A0 =C2=A0 =C2=A0 (progn (beginning-of-line)<= br>=C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0(point-max))
=C2= =A0 =C2=A0 =C2=A0 nil
=C2=A0 =C2=A0 =C2=A0 (0 'highlight)))))
(defun my-multiline-test-add ()
=C2=A0 (interactive)
=C2=A0 (font-lo= ck-add-keywords nil my-multiline-test-keywords)
=C2=A0 (font-lock-flush)= )

Insert the following in a new buffer:

X START OF A HIGHLIGH= TED 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=C2=A0the fi= rst eight lines are highlighted. When the block is edited, different parts = of the block is highlighted and unhighlighted.

As a contrast, when `= emacs-lisp-mode' is used, the entire block is highlighted, and editing = does not change the highlighting.

This worked as intended in Emacs 2= 4.5.

=C2=A0 =C2=A0 -- 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= ))
=C2=A0of 2015-12-28
Repository revision: e9916d8880561cc06b6cb73ba= fe7257b93ffbf4c
Windowing system distributor 'Apple', version 10= .3.1348
Configured using:
=C2=A0'configure --without-dbus'
Configured features:
ACL ZLIB TOOLKIT_SCROLL_BARS NS

Importa= nt settings:
=C2=A0 value of $LC_CTYPE: UTF-8
=C2=A0 locale-coding-sy= stem: utf-8-unix

Major mode: C/l

Minor modes in effect:
= =C2=A0 preproc-font-lock-global-mode: t
=C2=A0 preproc-font-lock-mode: t=
=C2=A0 tooltip-mode: t
=C2=A0 global-eldoc-mode: t
=C2=A0 electri= c-indent-mode: t
=C2=A0 mouse-wheel-mode: t
=C2=A0 tool-bar-mode: t=C2=A0 menu-bar-mode: t
=C2=A0 file-name-shadow-mode: t
=C2=A0 glob= al-font-lock-mode: t
=C2=A0 font-lock-mode: t
=C2=A0 blink-cursor-mod= e: t
=C2=A0 auto-composition-mode: t
=C2=A0 auto-encryption-mode: t=C2=A0 auto-compression-mode: t
=C2=A0 line-number-mode: t
=C2=A0 t= ransient-mark-mode: t
=C2=A0 abbrev-mode: t

Recent messages:
p= revious-line: Beginning of buffer [6 times]
Preproc-Font-Lock mode enabl= ed in current buffer
Making completion list... [2 times]
Type C-x 1 t= o delete the help window.
Making completion list... [2 times]

pre= vious-line: Beginning of buffer [4 times]
Saving file /Users/anders/emac= s/src/bugs/multiline.c...
Wrote /Users/anders/emacs/src/bugs/multiline.c=
Making completion list... [2 times]

Load-path shadows:
None f= ound.

Features:
(shadow sort gnus-util mail-extr emacsbug message= dired format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail= -parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 = ietf-drums
mm-util mail-prsvr mail-utils pp help-fns dabbrev character-f= old
misearch multi-isearch cc-mode cc-fonts cc-guess cc-menus cc-cmdscc-styles cc-align cc-engine cc-vars cc-defs cus-start cus-load
preproc= -font-lock easy-mmode vc-dispatcher vc-svn seq byte-opt gv
bytecomp byte= -compile cconv cl-extra help-mode easymenu cl-loaddefs
pcase cl-lib time= -date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp= -float-type mwheel ns-win term/common-win
tool-bar dnd fontset image reg= exp-opt fringe tabulated-list newcomment
elisp-mode lisp-mode prog-mode = register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-loc= k font-lock syntax facemenu font-core
frame cl-generic cham georgian utf= -8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese e= ucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic ind= ian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help s= imple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-f= ace macroexp files
text-properties overlay sha1 md5 base64 format env co= de-pages mule
custom widget hashtable-print-readable backquote cocoa ns = multi-tty
make-network-process emacs)

Memory information:
((co= nses 16 125810 6766)
=C2=A0(symbols 48 22477 0)
=C2=A0(miscs 40 92 69= 1)
=C2=A0(strings 32 31081 19325)
=C2=A0(string-bytes 1 1057796)
= =C2=A0(vectors 16 15058)
=C2=A0(vector-slots 8 499686 7007)
=C2=A0(fl= oats 8 160 240)
=C2=A0(intervals 56 3315 21)
=C2=A0(buffers 976 15))<= /div> --001a11438ee8009b7f0527f2a46a-- From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 29 16:06:14 2015 Received: (at 22256) by debbugs.gnu.org; 29 Dec 2015 21:06:14 +0000 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 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 Received: (qmail 64246 invoked by uid 3782); 29 Dec 2015 21:06:11 -0000 Date: 29 Dec 2015 21:06:11 -0000 Message-ID: <20151229210611.64245.qmail@mail.muc.de> From: Alan Mackenzie To: Anders Lindgren Subject: Re: bug#22256: 25.0.50; multiline font-lock rules broken in C mode Organization: muc.de e.V. In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.3.1-20141224 ("Tallant") (UNIX) (FreeBSD/10.2-RELEASE-p7 (amd64)) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 22256 Cc: 22256@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: -0.0 (/) 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). From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 30 00:50:36 2015 Received: (at 22256) by debbugs.gnu.org; 30 Dec 2015 05:50:36 +0000 Received: from localhost ([127.0.0.1]:49265 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aE9ed-0008HF-Q7 for submit@debbugs.gnu.org; Wed, 30 Dec 2015 00:50:36 -0500 Received: from mail-vk0-f54.google.com ([209.85.213.54]:36284) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aE9ec-0008H2-0h for 22256@debbugs.gnu.org; Wed, 30 Dec 2015 00:50:34 -0500 Received: by mail-vk0-f54.google.com with SMTP id f2so161556413vkb.3 for <22256@debbugs.gnu.org>; Tue, 29 Dec 2015 21:50:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=NSotWEyOOFPlxHEdJfY5A7jNk2XEPBjOwy1iR80dNoc=; b=Tgi9MGbp525UruPFI9I4iDGJ4XIBCyEq+LTXDo/eVpFfSTvmBBUK9NGCX2REb+7mb2 R11kv0dOGlgO4iD2g3uCcZMbm4CJhP/0kLwVFGMeiULgRS3Jsx48k5B3Sg8BtQwfGjLO 3bL7rxE1U6JRn9IkvvdAatG/TrNw6z1RWrrev2EAElmlL2E87f4iRqrH9GHpVK7h7Mx+ ih9BtBEk4CLu+579JGKk/cFXkAlIgzoDYFCfOiuj60QvWKvd7s9PFgeEo7afRFESjr39 NGLu9577gcSJ+5eiB5lKIAi3rBxF9JgQYV2rwHu9LXIwjZnwnA4RJxlituR7e/IoopJY tMzg== MIME-Version: 1.0 X-Received: by 10.31.54.134 with SMTP id d128mr37305312vka.26.1451454628405; Tue, 29 Dec 2015 21:50:28 -0800 (PST) Received: by 10.31.214.131 with HTTP; Tue, 29 Dec 2015 21:50:28 -0800 (PST) In-Reply-To: <20151229210611.64245.qmail@mail.muc.de> References: <20151229210611.64245.qmail@mail.muc.de> Date: Wed, 30 Dec 2015 06:50:28 +0100 Message-ID: Subject: Re: bug#22256: 25.0.50; multiline font-lock rules broken in C mode From: Anders Lindgren To: Alan Mackenzie Content-Type: multipart/alternative; boundary=001a11438ee888a52b0528171dae X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 22256 Cc: 22256@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: -0.7 (/) --001a11438ee888a52b0528171dae Content-Type: text/plain; charset=UTF-8 Hi! I just realized that I missed one vital thing in the example I posted. `font-lock-multiline' must be set. Also, I add code so that it works when `font-lock-flush' isn't defined. (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) (setq font-lock-multiline t) (if (fboundp 'font-lock-flush) (font-lock-flush) (when font-lock-mode (with-no-warnings (font-lock-fontify-buffer))))) Recipe: emacs -Q Eval the code above C-x b test RET Insert the text starting with an X (from the first mail) M-x c-mode RET M-x my-multiline-test-add RET Alternatively, use emacs-lisp-mode instead of C mode. When tested on Emacs 24.5 and Emacs 25, the only combination that doesn't work is Emacs 25 + C mode. There are a number of font-lock packages that utilize that this work, including my https://github.com/Lindydancer/preproc-font-lock package. -- Anders On Tue, Dec 29, 2015 at 10:06 PM, Alan Mackenzie wrote: > > 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" > > ("^.+quot; > > (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). > --001a11438ee888a52b0528171dae Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Hi!

I just realized that I missed one vital thi= ng in the example I posted. `font-lock-multiline' must be set. Also, I = add code so that it works when `font-lock-flush' isn't defined.
=
(defvar my-multiline-test-keywords
=C2=A0'(("^X"
= =C2=A0 =C2=A0 =C2=A0("^.+$"
=C2=A0 =C2=A0 =C2=A0 (progn (begin= ning-of-line)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(point-max= ))
=C2=A0 =C2=A0 =C2=A0 nil
=C2=A0 =C2=A0 =C2=A0 (0 'highlight)))= ))

(defun my-multiline-test-add ()
=C2=A0 (interactive)
=C2=A0= (font-lock-add-keywords nil my-multiline-test-keywords)
=C2=A0 (setq fo= nt-lock-multiline t)
=C2=A0 (if (fboundp 'font-lock-flush)
=C2=A0= =C2=A0 =C2=A0 (font-lock-flush)
=C2=A0 =C2=A0 (when font-lock-mode
= =C2=A0 =C2=A0 =C2=A0 (with-no-warnings
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (font= -lock-fontify-buffer)))))

Recipe:

emacs -Q
<= div>Eval the code above
C-x b test RET
Insert the text = starting with an X (from the first mail)
M-x c-mode RET
M-x my-multiline-test-add RET

Alternatively, use = emacs-lisp-mode instead of C mode.

When tested on = Emacs 24.5 and Emacs 25, the only combination that doesn't work is Emac= s 25 + C mode.

There are a number of font-lock pac= kages that utilize that this work, including my https://github.com/Lindydancer/preproc-fo= nt-lock package.

=C2=A0 =C2=A0 -- Anders
=

On Tue, Dec 29, 2015 at 10:06 PM, Alan Mackenzie <acm@muc.de> wrote:
>
> Hello= , Anders.
>
> In article <mailman.1133.1451298006.843.bug-gnu-emac= s@gnu.org> you wrote:
> > [-- text/plain, encoding 7bit, ch= arset: UTF-8, 143 lines --]
>
> > Hi!
>
> > I= n 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 th= em.
>
> > For example:
> > Eval the following:
&= gt; > (defvar my-multiline-test-keywords
> > =C2=A0'(("= ;^X"
> > =C2=A0 =C2=A0 =C2=A0("^.+quot;
> > =C2=A0 =C2=A0 =C2=A0 (progn (beginning-of-= line)
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(point-m= ax))
> > =C2=A0 =C2=A0 =C2=A0 nil
> > =C2=A0 =C2=A0 =C2= =A0 (0 'highlight)))))
>
> > (defun my-multiline-test-ad= d ()
> > =C2=A0 (interactive)
> > =C2=A0 (font-lock-add-k= eywords nil my-multiline-test-keywords)
> > =C2=A0 (font-lock-flus= h))
>
> > Insert the following in a new buffer:
>
&= gt; > X START OF A HIGHLIGHTED BLOCK
> > LONG LINES IN THE BLOC= K LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> > LONG LINES I= N THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> > LO= NG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
&g= t; > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE B= LOCK
> > LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINE= S 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 LON= G 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 LI= NES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> &g= t; LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK<= br>> > 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 LIN= ES IN THE BLOCK LONG LINES IN THE BLOCK
> > LONG LINES IN THE BLOC= K LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> > LONG LINES I= N THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
>
>= > Do:
> > M-x c-mode RET
> > M-x my-multiline-test-ad= d RET
>
> > I expect the entire buffer to be highlighted. Ho= wever, only the first eight
> > lines are highlighted. When the bl= ock is edited, different parts of the
> > block is highlighted and= unhighlighted.
>
> This is caused by the jit-lock mechanism.= =C2=A0 The first eight lines are 500
> characters (jit-lock-chunk-siz= e) rounded up to a whole number of lines.
>
> What happens is t= his: when the first jit-lock-chunk (8 lines) is
> fontified, the `fon= tified' property (the one the display engine uses) is
> set only = on these 8 lines.=C2=A0 The `face' property is then set on all the
&= gt; characters of the file, as requested by the my-multiline-test-keywords<= br>> form.
>
> Next thing, jit-lock fontifies the next chunk= of ~7 lines starting where
> the `fontified' property is nil.=C2= =A0 The first thing done is to set
> `fontified' on these ~7 line= s, then the `face' property on them is
> erased.=C2=A0 There is n= ow no matching font lock pattern to apply any new
> faces to these ~7= lines, since the "X" is many lines back.=C2=A0 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 n= il and restart font locking, the
> problem isn't apparent. =C2=A0= (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.=C2=A0 This is a difficult
&= gt; problem to solve in general.=C2=A0 CC Mode uses some ad-hoc tricks to c= atch,
> for example, long struct declarations.
>
> > A= s a contrast, when `emacs-lisp-mode' is used, the entire block is
&g= t; > highlighted, and editing does not change the highlighting.
><= br>> I do not see this in Emacs 24.5.=C2=A0 For me, even in emacs-lisp-m= ode, I
> still see just the 8 lines being fontified.=C2=A0 If you cou= ld give me a
> recipe (starting from emacs-24.5 -Q) to reproduce this= , I'd be very
> interested.
>
> > This worked as i= ntended in Emacs 24.5.
>
> > =C2=A0 =C2=A0 -- Anders Lindgre= n
>
> > In GNU Emacs 25.0.50.60 (x86_64-apple-darwin14.5.0, = NS appkit-1348.17
> > Version 10.10.5 (Build 14F27))
> > = =C2=A0of 2015-12-28
> > Repository revision: e9916d8880561cc06b6cb= 73bafe7257b93ffbf4c
> > Windowing system distributor 'Apple= 9;, version 10.3.1348
> > Configured using:
> > =C2=A0= 9;configure --without-dbus'
>
> > Configured features:> > ACL ZLIB TOOLKIT_SCROLL_BARS NS
>
> > Important = settings:
> > =C2=A0 value of $LC_CTYPE: UTF-8
> > =C2=A0= locale-coding-system: utf-8-unix
>
> > Major mode: C/l
&= gt;
> > Minor modes in effect:
> > =C2=A0 preproc-font-lo= ck-global-mode: t
> > =C2=A0 preproc-font-lock-mode: t
> >= ; =C2=A0 tooltip-mode: t
> > =C2=A0 global-eldoc-mode: t
> &= gt; =C2=A0 electric-indent-mode: t
> > =C2=A0 mouse-wheel-mode: t<= br>> > =C2=A0 tool-bar-mode: t
> > =C2=A0 menu-bar-mode: t> > =C2=A0 file-name-shadow-mode: t
> > =C2=A0 global-font= -lock-mode: t
> > =C2=A0 font-lock-mode: t
> > =C2=A0 bli= nk-cursor-mode: t
> > =C2=A0 auto-composition-mode: t
> >= =C2=A0 auto-encryption-mode: t
> > =C2=A0 auto-compression-mode: = t
> > =C2=A0 line-number-mode: t
> > =C2=A0 transient-mar= k-mode: t
> > =C2=A0 abbrev-mode: t
>
> [ .... ]
&g= t;
> --
> Alan Mackenzie (Nuremberg, Germany).
>
--001a11438ee888a52b0528171dae-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 08 16:34:18 2016 Received: (at 22256) by debbugs.gnu.org; 8 Jan 2016 21:34:18 +0000 Received: from localhost ([127.0.0.1]:43470 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHefp-00047G-My for submit@debbugs.gnu.org; Fri, 08 Jan 2016 16:34:18 -0500 Received: from mail-vk0-f42.google.com ([209.85.213.42]:34005) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHefn-000470-5L for 22256@debbugs.gnu.org; Fri, 08 Jan 2016 16:34:16 -0500 Received: by mail-vk0-f42.google.com with SMTP id a123so167833140vkh.1 for <22256@debbugs.gnu.org>; Fri, 08 Jan 2016 13:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=lEPa3M8EiGZxJGTRhnm2O+r4ihgxhnDUKW+HSvZ+CLQ=; b=HiAjSKiZNiv9F0Rv5iNGxL8g8yKv1ZTTq1TAR0Q/4ViIo6ABy0E8tQN3kg6XD80gNW hHerGnXir+YsEpb9LJ5nI5PiL77h2yegI5ecUyXwodLd8i0McNGG6WSX/JQXVeXcgoOm ggMRgR4iPmEUmM4c0kcgu7/nDPYc1EpR9uE6Wkddk8ElZUBdUhe6uD2lXVXdp9fbEaFA PoKGHqpIaJXu6Yvh53U0C4cZJ4J3DbBre9w2JeWWaMC56JDJu/5/SrTClO2sDauiB92M TwNU0nYQpP7Q8qGrdYyMHgkgZPcgn4hqW0hYWH6i6FhC+h3qR7YhlLd8cqMaLiI7N93c kCZQ== MIME-Version: 1.0 X-Received: by 10.31.10.199 with SMTP id 190mr81366726vkk.51.1452288849757; Fri, 08 Jan 2016 13:34:09 -0800 (PST) Received: by 10.31.214.131 with HTTP; Fri, 8 Jan 2016 13:34:09 -0800 (PST) In-Reply-To: References: <20151229210611.64245.qmail@mail.muc.de> Date: Fri, 8 Jan 2016 22:34:09 +0100 Message-ID: Subject: Re: bug#22256: 25.0.50; multiline font-lock rules broken in C mode From: Anders Lindgren To: Alan Mackenzie Content-Type: multipart/alternative; boundary=001a11440176004c590528d95902 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 22256 Cc: 22256@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: -0.7 (/) --001a11440176004c590528d95902 Content-Type: text/plain; charset=UTF-8 Hi Alan (and the list), I made a "git bisect" and found the culprit: -------- b31d359d182eb252a11f0468a7dc1ee1eafb28e9 is the first bad commit commit b31d359d182eb252a11f0468a7dc1ee1eafb28e9 Author: Alan Mackenzie Date: Sun Feb 1 21:20:35 2015 +0000 CC Mode: Stop Font Lock forcing fontification from BOL. Fixes debbugs#19669. cc-mode.el (c-font-lock-init): Setq font-lock-extend-region-functions to nil. -------- The reason this breaks multiline keywords is that `font-lock-extend-region-multiline' is normally part of `font-lock-extend-region-functions'. -- Anders On Wed, Dec 30, 2015 at 6:50 AM, Anders Lindgren wrote: > > > Hi! > > I just realized that I missed one vital thing in the example I posted. `font-lock-multiline' must be set. Also, I add code so that it works when `font-lock-flush' isn't defined. > > (defvar my-multiline-test-keywords > '(("^X" > ("^.+quot; > (progn (beginning-of-line) > (point-max)) > nil > (0 'highlight))))) > > (defun my-multiline-test-add () > (interactive) > (font-lock-add-keywords nil my-multiline-test-keywords) > (setq font-lock-multiline t) > (if (fboundp 'font-lock-flush) > (font-lock-flush) > (when font-lock-mode > (with-no-warnings > (font-lock-fontify-buffer))))) > > Recipe: > > emacs -Q > Eval the code above > C-x b test RET > Insert the text starting with an X (from the first mail) > M-x c-mode RET > M-x my-multiline-test-add RET > > Alternatively, use emacs-lisp-mode instead of C mode. > > When tested on Emacs 24.5 and Emacs 25, the only combination that doesn't work is Emacs 25 + C mode. > > There are a number of font-lock packages that utilize that this work, including my https://github.com/Lindydancer/preproc-font-lock package. > > -- Anders > > On Tue, Dec 29, 2015 at 10:06 PM, Alan Mackenzie wrote: > > > > 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" > > > ("^.+quot; > > > > (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). > > --001a11440176004c590528d95902 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Alan (and the list),

I made a "git bisect&q= uot; and found the culprit:

--------
b31d359d182eb252a11f0468a7dc= 1ee1eafb28e9 is the first bad commit
commit b31d359d182eb252a11f0468a7dc= 1ee1eafb28e9
Author: Alan Mackenzie <ac= m@muc.de>
Date: =C2=A0 Sun Feb 1 21:20:35 2015 +0000

=C2= =A0 =C2=A0 CC Mode: Stop Font Lock forcing fontification from BOL.=C2=A0 Fi= xes debbugs#19669.
=C2=A0 =C2=A0 cc-mode.el (c-font-lock-init): Setq fon= t-lock-extend-region-functions to=C2=A0nil.
--------

The reason t= his breaks multiline keywords is that `font-lock-extend-region-multiline= 9; is normally part of `font-lock-extend-region-functions'.

=C2=A0 =C2=A0 -- Anders


On Wed, Dec 30, 2015 at 6:50 AM,= Anders Lindgren <andlind@gmail.com= > wrote:
>
>
> Hi!
>
> I just realized= that I missed one vital thing in the example I posted. `font-lock-multilin= e' must be set. Also, I add code so that it works when `font-lock-flush= ' isn't defined.
>
> (defvar my-multiline-test-keywords=
> =C2=A0'(("^X"
> =C2=A0 =C2=A0 =C2=A0("^.+= quot;
> =C2=A0 =C2=A0 =C2=A0 (pro= gn (beginning-of-line)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(point-max))
> =C2=A0 =C2=A0 =C2=A0 nil
> =C2=A0 =C2=A0 = =C2=A0 (0 'highlight)))))
>
> (defun my-multiline-test-add = ()
> =C2=A0 (interactive)
> =C2=A0 (font-lock-add-keywords nil = my-multiline-test-keywords)
> =C2=A0 (setq font-lock-multiline t)
= > =C2=A0 (if (fboundp 'font-lock-flush)
> =C2=A0 =C2=A0 =C2=A0= (font-lock-flush)
> =C2=A0 =C2=A0 (when font-lock-mode
> =C2= =A0 =C2=A0 =C2=A0 (with-no-warnings
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 (fo= nt-lock-fontify-buffer)))))
>
> Recipe:
>
> emacs -= Q
> Eval the code above
> C-x b test RET
> Insert the tex= t starting with an X (from the first mail)
> M-x c-mode RET
> M= -x my-multiline-test-add RET
>
> Alternatively, use emacs-lisp-= mode instead of C mode.
>
> When tested on Emacs 24.5 and Emacs= 25, the only combination that doesn't work is Emacs 25 + C mode.
&g= t;
> There are a number of font-lock packages that utilize that this = work, including my https://github.com/Lindydancer/preproc-font-lock package.
><= br>> =C2=A0 =C2=A0 -- Anders
>
> On Tue, Dec 29, 2015 at 10:= 06 PM, Alan Mackenzie <acm@muc.de> = wrote:
> >
> > Hello, Anders.
> >
> > I= n article <mailman.1133.1451298006.843.bug-gnu-emacs@gnu.org> you wrote= :
> > > [-- text/plain, encoding 7bit, charset: UTF-8, 143 line= s --]
> >
> > > Hi!
> >
> > > In = C and related modes, multiline font-lock rules no longer work as
> &g= t; > expected. It looks like a few lines are highlighted, but not all of= them.
> >
> > > For example:
> > > Eval t= he following:
> > > (defvar my-multiline-test-keywords
> = > > =C2=A0'(("^X"
> > > =C2=A0 =C2=A0 =C2= =A0("^.+quot;
>
> > > =C2=A0 =C2=A0 =C2=A0 (progn (b= eginning-of-line)
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(point-max))
> > > =C2=A0 =C2=A0 =C2=A0 nil
> &= gt; > =C2=A0 =C2=A0 =C2=A0 (0 'highlight)))))
> >
> &= gt; > (defun my-multiline-test-add ()
> > > =C2=A0 (interact= ive)
> > > =C2=A0 (font-lock-add-keywords nil my-multiline-test= -keywords)
> > > =C2=A0 (font-lock-flush))
> >
>= > > Insert the following in a new buffer:
> >
> > = > X START OF A HIGHLIGHTED BLOCK
> > > LONG LINES IN THE BLO= CK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> > > LONG L= INES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> &= gt; > 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 LON= G LINES IN THE BLOCK
> > > LONG LINES IN THE BLOCK LONG LINES I= N THE BLOCK LONG LINES IN THE BLOCK
> > > LONG LINES IN THE BLO= CK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> > > LONG L= INES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> &= gt; > 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 LON= G LINES IN THE BLOCK
> > > LONG LINES IN THE BLOCK LONG LINES I= N THE BLOCK LONG LINES IN THE BLOCK
> > > LONG LINES IN THE BLO= CK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> > > LONG L= INES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> &= gt; > 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 LON= G LINES IN THE BLOCK
> > > LONG LINES IN THE BLOCK LONG LINES I= N THE BLOCK LONG LINES IN THE BLOCK
> > > LONG LINES IN THE BLO= CK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> > > LONG L= INES IN THE BLOCK LONG LINES IN THE BLOCK LONG LINES IN THE BLOCK
> &= gt;
> > > 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.
> ><= br>> > This is caused by the jit-lock mechanism.=C2=A0 The first eigh= t lines are 500
> > characters (jit-lock-chunk-size) rounded up to= a whole number of lines.
> >
> > What happens is this: w= hen the first jit-lock-chunk (8 lines) is
> > fontified, the `font= ified' property (the one the display engine uses) is
> > set o= nly on these 8 lines.=C2=A0 The `face' property is then set on all the<= br>> > 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 `fonti= fied' property is nil.=C2=A0 The first thing done is to set
> >= ; `fontified' on these ~7 lines, then the `face' property on them i= s
> > erased.=C2=A0 There is now no matching font lock pattern to = apply any new
> > faces to these ~7 lines, since the "X"= is many lines back.=C2=A0 The same
> > thing happens with the nex= t 500 byte chunk, and so on till the end of the
> > buffer.
>= ; >
> > If you set `font-lock-support-mode' to nil and rest= art font locking, the
> > problem isn't apparent. =C2=A0(Then = set the variable back to 'jit-lock-mode.)
> >
> > Thi= s is a fundamental problem with jit-lock-mode: the assumption that
> = > text to be fontified has no non-trivial context.=C2=A0 This is a diffi= cult
> > problem to solve in general.=C2=A0 CC Mode uses some ad-h= oc tricks to catch,
> > for example, long struct declarations.
= > >
> > > As a contrast, when `emacs-lisp-mode' is us= ed, the entire block is
> > > highlighted, and editing does not= change the highlighting.
> >
> > I do not see this in Em= acs 24.5.=C2=A0 For me, even in emacs-lisp-mode, I
> > still see j= ust the 8 lines being fontified.=C2=A0 If you could give me a
> > = recipe (starting from emacs-24.5 -Q) to reproduce this, I'd be very
= > > interested.
> >
> > > This worked as intende= d in Emacs 24.5.
> >
> > > =C2=A0 =C2=A0 -- Anders Lin= dgren
> >
> > > In GNU Emacs 25.0.50.60 (x86_64-apple-= darwin14.5.0, NS appkit-1348.17
> > > Version 10.10.5 (Build 14= F27))
> > > =C2=A0of 2015-12-28
> > > Repository re= vision: e9916d8880561cc06b6cb73bafe7257b93ffbf4c
> > > Windowin= g system distributor 'Apple', version 10.3.1348
> > > C= onfigured using:
> > > =C2=A0'configure --without-dbus'=
> >
> > > Configured features:
> > > ACL = ZLIB TOOLKIT_SCROLL_BARS NS
> >
> > > Important settin= gs:
> > > =C2=A0 value of $LC_CTYPE: UTF-8
> > > = =C2=A0 locale-coding-system: utf-8-unix
> >
> > > Majo= r mode: C/l
> >
> > > Minor modes in effect:
> &= gt; > =C2=A0 preproc-font-lock-global-mode: t
> > > =C2=A0 p= reproc-font-lock-mode: t
> > > =C2=A0 tooltip-mode: t
> &= gt; > =C2=A0 global-eldoc-mode: t
> > > =C2=A0 electric-inde= nt-mode: t
> > > =C2=A0 mouse-wheel-mode: t
> > > = =C2=A0 tool-bar-mode: t
> > > =C2=A0 menu-bar-mode: t
> &= gt; > =C2=A0 file-name-shadow-mode: t
> > > =C2=A0 global-fo= nt-lock-mode: t
> > > =C2=A0 font-lock-mode: t
> > >= ; =C2=A0 blink-cursor-mode: t
> > > =C2=A0 auto-composition-mod= e: t
> > > =C2=A0 auto-encryption-mode: t
> > > =C2= =A0 auto-compression-mode: t
> > > =C2=A0 line-number-mode: t> > > =C2=A0 transient-mark-mode: t
> > > =C2=A0 abb= rev-mode: t
> >
> > [ .... ]
> >
> > --=
> > Alan Mackenzie (Nuremberg, Germany).
> >
--001a11440176004c590528d95902-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 09 07:16:52 2016 Received: (at 22256) by debbugs.gnu.org; 9 Jan 2016 12:16:52 +0000 Received: from localhost ([127.0.0.1]:43646 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHsRw-0004MH-Gm for submit@debbugs.gnu.org; Sat, 09 Jan 2016 07:16:52 -0500 Received: from mail.muc.de ([193.149.48.3]:28861) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHsRv-0004M9-Dt for 22256@debbugs.gnu.org; Sat, 09 Jan 2016 07:16:51 -0500 Received: (qmail 92059 invoked by uid 3782); 9 Jan 2016 12:16:50 -0000 Received: from acm.muc.de (p5B146176.dip0.t-ipconnect.de [91.20.97.118]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 09 Jan 2016 13:16:47 +0100 Received: (qmail 4603 invoked by uid 1000); 9 Jan 2016 12:19:08 -0000 Date: Sat, 9 Jan 2016 12:19:08 +0000 To: Anders Lindgren Subject: Re: bug#22256: 25.0.50; multiline font-lock rules broken in C mode Message-ID: <20160109121907.GA4598@acm.fritz.box> References: <20151229210611.64245.qmail@mail.muc.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) 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: 22256 Cc: 22256@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: -0.0 (/) Hello, Anders. Thanks for doing all the donkey work. On Fri, Jan 08, 2016 at 10:34:09PM +0100, Anders Lindgren wrote: > Hi Alan (and the list), > I made a "git bisect" and found the culprit: > -------- > b31d359d182eb252a11f0468a7dc1ee1eafb28e9 is the first bad commit > commit b31d359d182eb252a11f0468a7dc1ee1eafb28e9 > Author: Alan Mackenzie > Date: Sun Feb 1 21:20:35 2015 +0000 > CC Mode: Stop Font Lock forcing fontification from BOL. Fixes > debbugs#19669. > cc-mode.el (c-font-lock-init): Setq font-lock-extend-region-functions > to nil. > -------- > The reason this breaks multiline keywords is that > `font-lock-extend-region-multiline' is normally part of > `font-lock-extend-region-functions'. OK. The fix is then fairly obvious: to remove the one function from `font-lock-extend-region-functions' which was causing the problem, leaving the other functions (in particular `font-lock-extend-region-multiline') in place. Could you try out this patch, please. It seems to work OK for me, here. diff -r a73bd5d1bd06 cc-mode.el --- a/cc-mode.el Fri Jan 08 22:25:59 2016 +0000 +++ b/cc-mode.el Sat Jan 09 12:00:10 2016 +0000 @@ -1324,12 +1324,13 @@ . c-mark-function))) ;; Prevent `font-lock-default-fontify-region' extending the region it will - ;; fontify to whole lines by removing `font-lock-extend-region-whole-lines' - ;; (and, coincidentally, `font-lock-extend-region-multiline' (which we do - ;; not need)) from `font-lock-extend-region-functions'. (Emacs only). This - ;; fixes Emacs bug #19669. + ;; fontify to whole lines by removing `font-lock-extend-region-wholelines' + ;; from `font-lock-extend-region-functions'. (Emacs only). This fixes + ;; Emacs bug #19669. (when (boundp 'font-lock-extend-region-functions) - (setq font-lock-extend-region-functions nil)) + (setq font-lock-extend-region-functions + (delq 'font-lock-extend-region-wholelines + font-lock-extend-region-functions))) (make-local-variable 'font-lock-fontify-region-function) (setq font-lock-fontify-region-function 'c-font-lock-fontify-region) > -- Anders -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 09 08:40:33 2016 Received: (at 22256) by debbugs.gnu.org; 9 Jan 2016 13:40:33 +0000 Received: from localhost ([127.0.0.1]:43675 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHtkv-0007vq-0T for submit@debbugs.gnu.org; Sat, 09 Jan 2016 08:40:33 -0500 Received: from mail-vk0-f46.google.com ([209.85.213.46]:34434) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHtks-0007vd-Lb for 22256@debbugs.gnu.org; Sat, 09 Jan 2016 08:40:32 -0500 Received: by mail-vk0-f46.google.com with SMTP id a123so174250604vkh.1 for <22256@debbugs.gnu.org>; Sat, 09 Jan 2016 05:40:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=EddWVldJq33M7YZ3Ux2mLjS+Zde3Cg1nIKhNVvKFbjo=; b=LuCGbw5zk8hqsJgWZlD3/25oDCW77ShdLlJSM5b6MZfBi/rTCW9TWheSs7SM3+fd+l IO1RC708/ztINczhb0L60bzD2bdoNx0RBcFl94IkaiQDFv0n4h/6uUinDxZTSHg0vVxb 5ifquaC7okNhuUs46q5Tl/0IDnwxLK2+3EX5PdJX4qt68Tqlw2NA2I87qjc5RHHZqThb eFt8Uewf4q+vxbSspSD/5BmhKeDU/OaZYvJoqr5vrFOAEEx1iL+Ea8OcWdWuNBQM3B63 dObAfVxZjTodYgw+TaywsUi8Mmcc7/UUI47AshxSIKvlA8mmQP/d4fRuTo1HV0v5PjO5 thGQ== MIME-Version: 1.0 X-Received: by 10.31.54.134 with SMTP id d128mr75973865vka.26.1452346824902; Sat, 09 Jan 2016 05:40:24 -0800 (PST) Received: by 10.31.214.131 with HTTP; Sat, 9 Jan 2016 05:40:24 -0800 (PST) In-Reply-To: <20160109121907.GA4598@acm.fritz.box> References: <20151229210611.64245.qmail@mail.muc.de> <20160109121907.GA4598@acm.fritz.box> Date: Sat, 9 Jan 2016 14:40:24 +0100 Message-ID: Subject: Re: bug#22256: 25.0.50; multiline font-lock rules broken in C mode From: Anders Lindgren To: Alan Mackenzie Content-Type: multipart/alternative; boundary=001a11438ee896cc750528e6d8b1 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 22256 Cc: 22256@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: -0.7 (/) --001a11438ee896cc750528e6d8b1 Content-Type: text/plain; charset=UTF-8 Hi! I just tested this and I can verify that this solved my multiline problem. Thanks! -- Anders On Sat, Jan 9, 2016 at 1:19 PM, Alan Mackenzie wrote: > Hello, Anders. > > Thanks for doing all the donkey work. > > On Fri, Jan 08, 2016 at 10:34:09PM +0100, Anders Lindgren wrote: > > Hi Alan (and the list), > > > I made a "git bisect" and found the culprit: > > > -------- > > b31d359d182eb252a11f0468a7dc1ee1eafb28e9 is the first bad commit > > commit b31d359d182eb252a11f0468a7dc1ee1eafb28e9 > > Author: Alan Mackenzie > > Date: Sun Feb 1 21:20:35 2015 +0000 > > > CC Mode: Stop Font Lock forcing fontification from BOL. Fixes > > debbugs#19669. > > cc-mode.el (c-font-lock-init): Setq font-lock-extend-region-functions > > to nil. > > -------- > > > The reason this breaks multiline keywords is that > > `font-lock-extend-region-multiline' is normally part of > > `font-lock-extend-region-functions'. > > OK. The fix is then fairly obvious: to remove the one function from > `font-lock-extend-region-functions' which was causing the problem, > leaving the other functions (in particular > `font-lock-extend-region-multiline') in place. > > Could you try out this patch, please. It seems to work OK for me, here. > > > > diff -r a73bd5d1bd06 cc-mode.el > --- a/cc-mode.el Fri Jan 08 22:25:59 2016 +0000 > +++ b/cc-mode.el Sat Jan 09 12:00:10 2016 +0000 > @@ -1324,12 +1324,13 @@ > . c-mark-function))) > > ;; Prevent `font-lock-default-fontify-region' extending the region it > will > - ;; fontify to whole lines by removing > `font-lock-extend-region-whole-lines' > - ;; (and, coincidentally, `font-lock-extend-region-multiline' (which we > do > - ;; not need)) from `font-lock-extend-region-functions'. (Emacs only). > This > - ;; fixes Emacs bug #19669. > + ;; fontify to whole lines by removing > `font-lock-extend-region-wholelines' > + ;; from `font-lock-extend-region-functions'. (Emacs only). This fixes > + ;; Emacs bug #19669. > (when (boundp 'font-lock-extend-region-functions) > - (setq font-lock-extend-region-functions nil)) > + (setq font-lock-extend-region-functions > + (delq 'font-lock-extend-region-wholelines > + font-lock-extend-region-functions))) > > (make-local-variable 'font-lock-fontify-region-function) > (setq font-lock-fontify-region-function 'c-font-lock-fontify-region) > > > > -- Anders > > -- > Alan Mackenzie (Nuremberg, Germany). > --001a11438ee896cc750528e6d8b1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi!

I just tested this and I can verify= that this solved my multiline problem.

Thanks!

=C2=A0 =C2=A0 -- Anders


On S= at, Jan 9, 2016 at 1:19 PM, Alan Mackenzie <acm@muc.de> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">Hello, Anders.

Thanks for doing all the donkey work.

On Fri, Jan 08, 2016 at 10:34:09PM +0100, Anders Lindgren wrote:
> Hi Alan (and the list),

> I made a "git bisect" and found the culprit:

> --------
> b31d359d182eb252a11f0468a7dc1ee1eafb28e9 is the first bad commit
> commit b31d359d182eb252a11f0468a7dc1ee1eafb28e9
> Author: Alan Mackenzie <acm@muc.de>
> Date:=C2=A0 =C2=A0Sun Feb 1 21:20:35 2015 +0000

>=C2=A0 =C2=A0 =C2=A0CC Mode: Stop Font Lock forcing fontification from = BOL.=C2=A0 Fixes
> debbugs#19669.
>=C2=A0 =C2=A0 =C2=A0cc-mode.el (c-font-lock-init): Setq font-lock-exten= d-region-functions
> to nil.
> --------

> The reason this breaks multiline keywords is that
> `font-lock-extend-region-multiline' is normally part of
> `font-lock-extend-region-functions'.

OK.=C2=A0 The fix is then fairly obvious: to remove the one function= from
`font-lock-extend-region-functions' which was causing the problem,
leaving the other functions (in particular
`font-lock-extend-region-multiline') in place.

Could you try out this patch, please.=C2=A0 It seems to work OK for me, her= e.



diff -r a73bd5d1bd06 cc-mode.el
--- a/cc-mode.el=C2=A0 =C2=A0 =C2=A0 =C2=A0 Fri Jan 08 22:25:59 2016 +0000<= br> +++ b/cc-mode.el=C2=A0 =C2=A0 =C2=A0 =C2=A0 Sat Jan 09 12:00:10 2016 +0000<= br> @@ -1324,12 +1324,13 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0. c-mark-function)))

=C2=A0 =C2=A0;; Prevent `font-lock-default-fontify-region' extending th= e region it will
-=C2=A0 ;; fontify to whole lines by removing `font-lock-extend-region-whol= e-lines'
-=C2=A0 ;; (and, coincidentally, `font-lock-extend-region-multiline' (w= hich we do
-=C2=A0 ;; not need)) from `font-lock-extend-region-functions'.=C2=A0 (= Emacs only).=C2=A0 This
-=C2=A0 ;; fixes Emacs bug #19669.
+=C2=A0 ;; fontify to whole lines by removing `font-lock-extend-region-whol= elines'
+=C2=A0 ;; from `font-lock-extend-region-functions'.=C2=A0 (Emacs only)= .=C2=A0 This fixes
+=C2=A0 ;; Emacs bug #19669.
=C2=A0 =C2=A0(when (boundp 'font-lock-extend-region-functions)
-=C2=A0 =C2=A0 (setq font-lock-extend-region-functions nil))
+=C2=A0 =C2=A0 (setq font-lock-extend-region-functions
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(delq 'font-lock-extend-region-whole= lines
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0font-lock-extend-re= gion-functions)))

=C2=A0 =C2=A0(make-local-variable 'font-lock-fontify-region-function) =C2=A0 =C2=A0(setq font-lock-fontify-region-function 'c-font-lock-fonti= fy-region)


>=C2=A0 =C2=A0 =C2=A0-- Anders

--
Alan Mackenzie (Nuremberg, Germany).

--001a11438ee896cc750528e6d8b1-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 09 10:23:25 2016 Received: (at 22256-done) by debbugs.gnu.org; 9 Jan 2016 15:23:25 +0000 Received: from localhost ([127.0.0.1]:44543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHvMT-00025O-DE for submit@debbugs.gnu.org; Sat, 09 Jan 2016 10:23:25 -0500 Received: from mail.muc.de ([193.149.48.3]:38018) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aHvMR-00025F-9z for 22256-done@debbugs.gnu.org; Sat, 09 Jan 2016 10:23:23 -0500 Received: (qmail 78642 invoked by uid 3782); 9 Jan 2016 15:23:22 -0000 Received: from acm.muc.de (p5B146176.dip0.t-ipconnect.de [91.20.97.118]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 09 Jan 2016 16:23:20 +0100 Received: (qmail 6998 invoked by uid 1000); 9 Jan 2016 15:25:41 -0000 Date: Sat, 9 Jan 2016 15:25:41 +0000 To: Anders Lindgren Subject: Re: bug#22256: 25.0.50; multiline font-lock rules broken in C mode Message-ID: <20160109152541.GA6965@acm.fritz.box> References: <20151229210611.64245.qmail@mail.muc.de> <20160109121907.GA4598@acm.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) 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: 22256-done Cc: 22256-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: -0.0 (/) Hello, Anders. On Sat, Jan 09, 2016 at 02:40:24PM +0100, Anders Lindgren wrote: > Hi! > I just tested this and I can verify that this solved my multiline problem. > Thanks! Well, thank you! I've committed that change, and I'm closing the bug as fixed. > -- Anders -- Alan Mackenzie (Nuremberg, Germany). From unknown Thu Sep 11 11:56: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, 07 Feb 2016 12:24:03 +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