unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33937: 26.1; mhtml-mode fails to capture font-lock-keywords-case-fold-search
@ 2018-12-31 15:13 Leo Liu
  2019-10-30 19:26 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Liu @ 2018-12-31 15:13 UTC (permalink / raw)
  To: 33937


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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#33937: 26.1; mhtml-mode fails to capture font-lock-keywords-case-fold-search
  2018-12-31 15:13 bug#33937: 26.1; mhtml-mode fails to capture font-lock-keywords-case-fold-search Leo Liu
@ 2019-10-30 19:26 ` Lars Ingebrigtsen
  2019-10-30 21:19   ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-30 19:26 UTC (permalink / raw)
  To: Leo Liu; +Cc: 33937, Stefan Monnier

Leo Liu <sdl.web@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@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#33937: 26.1; mhtml-mode fails to capture font-lock-keywords-case-fold-search
  2019-10-30 19:26 ` Lars Ingebrigtsen
@ 2019-10-30 21:19   ` Stefan Monnier
  2019-10-31 13:08     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2019-10-30 21:19 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 33937, Leo Liu

>        ;; 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






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#33937: 26.1; mhtml-mode fails to capture font-lock-keywords-case-fold-search
  2019-10-30 21:19   ` Stefan Monnier
@ 2019-10-31 13:08     ` Lars Ingebrigtsen
  2019-10-31 20:30       ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-31 13:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 33937, Leo Liu

Stefan Monnier <monnier@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#33937: 26.1; mhtml-mode fails to capture font-lock-keywords-case-fold-search
  2019-10-31 13:08     ` Lars Ingebrigtsen
@ 2019-10-31 20:30       ` Stefan Monnier
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2019-10-31 20:30 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 33937, Leo Liu

> 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






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-31 20:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-31 15:13 bug#33937: 26.1; mhtml-mode fails to capture font-lock-keywords-case-fold-search Leo Liu
2019-10-30 19:26 ` Lars Ingebrigtsen
2019-10-30 21:19   ` Stefan Monnier
2019-10-31 13:08     ` Lars Ingebrigtsen
2019-10-31 20:30       ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).