GNU bug report logs - #76781
Fontification of expl3 code

Previous Next

Package: auctex;

Reported by: Arash Esbati <arash <at> gnu.org>

Date: Thu, 6 Mar 2025 13:00:02 UTC

Severity: normal

Fixed in version 14.1.0

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


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

From: Arash Esbati <arash <at> gnu.org>
To: "auctex-bugs" <bug-auctex <at> gnu.org>
Subject: Fontification of expl3 code
Date: Thu, 06 Mar 2025 13:58:37 +0100
[Message part 1 (text/plain, inline)]
Hi all,

with the recent updates to style/expl3.el, I think we have an issue with
fontification.  For this small test file:

--8<---------------cut here---------------start------------->8---
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{expl3}
\begin{document}
\DocInput{dtx-fontification.dtx}
\end{document}
%</driver>
% \fi
%
% \begin{macro}{\next}
%   Implement \cs{next} which is:
%    \begin{macrocode}
\cs_set:Npn \next:nn #1#2 { x #1~y #2 }
\cs_prefix_spec:N \next:nn

\cs_to_str:N \next
\end{macrocode}
% \end{macro}
%
% \endinput
% Local Variables:
% mode: docTeX
% TeX-master: t
% End:
--8<---------------cut here---------------end--------------->8---

The fontification looks like this with 'emacs -Q':
[before.png (image/png, inline)]
[Message part 3 (text/plain, inline)]
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:

--8<---------------cut here---------------start------------->8---
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
--8<---------------cut here---------------end--------------->8---

which then gives:
[after.png (image/png, inline)]
[Message part 5 (text/plain, inline)]
Any comments?

Best, Arash

This bug report was last modified 55 days ago.

Previous Next


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