Subject: bug#76781: Fontification of expl3 code

From: Ikumi Keita <[email-masked]>
Date: Fri, 07 Mar 2025 15:07:38 +0900

Hi Arash,

>>>>> Arash Esbati <[email-masked]> writes:
> The fontification looks like this with 'emacs -Q':
> x
> Note the broken fontification for \next:nn and \cs_prefix_spec:N,
> \cs_to_str:N.  This is mostly because : and _ have the symbol syntax in
> this case and font-latex looks for word boundaries (\\>).  I think we
> can cure this with this small change:
> diff --git a/style/expl3.el b/style/expl3.el
> index 9ce0e4b0..f35088df 100644
> --- a/style/expl3.el
> +++ b/style/expl3.el
> @@ -38,9 +38,9 @@

>  (defvar LaTeX-expl3-syntax-table
>    (let ((st (copy-syntax-table LaTeX-mode-syntax-table)))
> -    ;; Make _ and : symbol chars
> -    (modify-syntax-entry ?\_ "_" st)
> -    (modify-syntax-entry ?\: "_" st)
> +    ;; Make _ and : word chars
> +    (modify-syntax-entry ?\_ "w" st)
> +    (modify-syntax-entry ?\: "w" st)
>      st))

>  (defun LaTeX-expl3--set-TeX-exit-mark (_optional &optional pos)
> @@ -710,7 +710,10 @@ Pass OPTIONAL, PROMPT and NO-PARAM to `TeX-arg-expl3-macro', which see."

>                                  ("cs_undefine:N" "\\")
>                                  ("cs_undefine:c" "\\"))
> -                              'function)))
> +                              'function))
> +   ;; Also tell font-lock to update its internals
> +   (setq font-lock-major-mode nil)
> +   (font-lock-set-defaults))
>   TeX-dialect)

>  (defvar LaTeX-expl3-package-options-list
> which then gives:
> x
> Any comments?

Well, I don't notice any difference between the two images. I actually
applied the proposed patch and opened the sample .dtx file, but it still
doesn't exhibit differences to my eyes. Am I missing some subtle
changes?

> +   ;; Also tell font-lock to update its internals
> +   (setq font-lock-major-mode nil)
> +   (font-lock-set-defaults))

1. What is the point to reset `font-lock-major-mode'? Isn't this
   `font-lock-set-defaults'?
2. Why do we need to tell font-lock to update its internals? No other
   style files do that.

Please forgive me if I'm saying something stupid.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
#Gaza #StopMassiveKilling #CeasefireNOW