GNU bug report logs - #33937
26.1; mhtml-mode fails to capture font-lock-keywords-case-fold-search

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Mon, 31 Dec 2018 15:15:02 UTC

Severity: normal

Tags: fixed

Found in version 26.1

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33937 in the body.
You can then email your comments to 33937 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#33937; Package emacs. (Mon, 31 Dec 2018 15:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo Liu <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 31 Dec 2018 15:15:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1; mhtml-mode fails to capture font-lock-keywords-case-fold-search
Date: Mon, 31 Dec 2018 23:13:39 +0800
In mhtml-mode moving into <script>...</script> doesn't set up
font-lock-keywords-case-fold-search properly, which still has the value
carried over from html-mode.

The reason is font-lock doesn't make font-lock-keywords-case-fold-search
buffer-local when its value is nil thus it is skipped by
mhtml--construct-submode.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33937; Package emacs. (Wed, 30 Oct 2019 19:27:01 GMT) Full text and rfc822 format available.

Message #8 received at 33937 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 33937 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: 26.1; mhtml-mode fails to capture
 font-lock-keywords-case-fold-search
Date: Wed, 30 Oct 2019 20:26:44 +0100
Leo Liu <sdl.web <at> gmail.com> writes:

> In mhtml-mode moving into <script>...</script> doesn't set up
> font-lock-keywords-case-fold-search properly, which still has the value
> carried over from html-mode.
>
> The reason is font-lock doesn't make font-lock-keywords-case-fold-search
> buffer-local when its value is nil thus it is skipped by
> mhtml--construct-submode.

This is due to

commit 558ca3c1225f6035442733d5d3fb5fd4c40a0a45
Author: Stefan Monnier <monnier <at> iro.umontreal.ca>
Date:   Tue Feb 12 16:49:21 2008 +0000

    (font-lock-set-defaults): Unset previously set variables when needed.

which does this with many of the font-lock variables:

       ;; Case fold during regexp fontification?
-      (when (nth 2 defaults)
-	(set (make-local-variable 'font-lock-keywords-case-fold-search) t))
+      (if (nth 2 defaults)
+          (set (make-local-variable 'font-lock-keywords-case-fold-search) t)
+        (kill-local-variable 'font-lock-keywords-case-fold-search))

It's slightly puzzling -- font-lock-keywords-case-fold-search is
permanently buffer-local, but I guess that puzzlement was there before
this patch, but the kill-local-variable thing is what makes mhtlm not
work.

Stefan, do you remember the reason for this change?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33937; Package emacs. (Wed, 30 Oct 2019 21:20:02 GMT) Full text and rfc822 format available.

Message #11 received at 33937 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 33937 <at> debbugs.gnu.org, Leo Liu <sdl.web <at> gmail.com>
Subject: Re: 26.1;
 mhtml-mode fails to capture font-lock-keywords-case-fold-search
Date: Wed, 30 Oct 2019 17:19:00 -0400
>        ;; Case fold during regexp fontification?
> -      (when (nth 2 defaults)
> -	(set (make-local-variable 'font-lock-keywords-case-fold-search) t))
> +      (if (nth 2 defaults)
> +          (set (make-local-variable 'font-lock-keywords-case-fold-search) t)
> +        (kill-local-variable 'font-lock-keywords-case-fold-search))
>
> It's slightly puzzling -- font-lock-keywords-case-fold-search is
> permanently buffer-local, but I guess that puzzlement was there before
> this patch, but the kill-local-variable thing is what makes mhtlm not
> work.
>
> Stefan, do you remember the reason for this change?

I can't remember the specific case, but I remember that it was basically
the inverse situation where font-lock-keywords-case-fold-search was left
at `t` instead of resetting it to the default nil.

I guess we should just

    (setq-local font-lock-keywords-case-fold-search (nth 2 defaults))

instead,


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33937; Package emacs. (Thu, 31 Oct 2019 13:09:02 GMT) Full text and rfc822 format available.

Message #14 received at 33937 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 33937 <at> debbugs.gnu.org, Leo Liu <sdl.web <at> gmail.com>
Subject: Re: 26.1; mhtml-mode fails to capture
 font-lock-keywords-case-fold-search
Date: Thu, 31 Oct 2019 14:08:34 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>>        ;; Case fold during regexp fontification?
>> -      (when (nth 2 defaults)
>> -	(set (make-local-variable 'font-lock-keywords-case-fold-search) t))
>> +      (if (nth 2 defaults)
>> +          (set (make-local-variable 'font-lock-keywords-case-fold-search) t)
>> +        (kill-local-variable 'font-lock-keywords-case-fold-search))
>>
>> It's slightly puzzling -- font-lock-keywords-case-fold-search is
>> permanently buffer-local, but I guess that puzzlement was there before
>> this patch, but the kill-local-variable thing is what makes mhtlm not
>> work.
>>
>> Stefan, do you remember the reason for this change?
>
> I can't remember the specific case, but I remember that it was basically
> the inverse situation where font-lock-keywords-case-fold-search was left
> at `t` instead of resetting it to the default nil.
>
> I guess we should just
>
>     (setq-local font-lock-keywords-case-fold-search (nth 2 defaults))
>
> instead,

I've now done this change, which should fix the reported problem.  But
I'm slightly worried that this may have some impact if there's a global
setting somewhere that should be respected...  Not for
font-lock-keywords-case-fold-search (which is always buffer-local), but
for font-lock-syntax-table and font-lock-keywords-only.

Hm...  perhaps I should have left those two alone, although it seems odd
to treat them differently...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 31 Oct 2019 13:09:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 33937 <at> debbugs.gnu.org and Leo Liu <sdl.web <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 31 Oct 2019 13:09:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33937; Package emacs. (Thu, 31 Oct 2019 20:31:02 GMT) Full text and rfc822 format available.

Message #21 received at 33937 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 33937 <at> debbugs.gnu.org, Leo Liu <sdl.web <at> gmail.com>
Subject: Re: 26.1;
 mhtml-mode fails to capture font-lock-keywords-case-fold-search
Date: Thu, 31 Oct 2019 16:30:05 -0400
> I've now done this change, which should fix the reported problem.  But
> I'm slightly worried that this may have some impact if there's a global
> setting somewhere that should be respected...  Not for
> font-lock-keywords-case-fold-search (which is always buffer-local), but
> for font-lock-syntax-table and font-lock-keywords-only.

I think global settings for font-lock-syntax-table and
font-lock-keywords-only don't make much sense anyway, so it should
be fine.

> [...] it seems odd to treat them differently...

Indeed,


        Stefan





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 29 Nov 2019 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 121 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.