branch: externals/auctex commit 78c0f0961941178aad974e721e7964482ab9bbad Author: Arash Esbati <ar...@gnu.org> Commit: Arash Esbati <ar...@gnu.org>
Fix fontification of simple macros * font-latex.el (font-latex-match-simple-command): Change second part of regexp in order to be less greedy. This function now fontifies only letters and characters defined in `font-latex-match-simple-include-list' (bug#34712). (font-latex-match-simple-include-list): New variable. * style/expl3.el ("expl3"): Add "_" and ":" to `font-latex-match-simple-include-list'. --- font-latex.el | 25 +++++++++++++++++++++++-- style/expl3.el | 5 ++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/font-latex.el b/font-latex.el index bd504a8..8e8b4fc 100644 --- a/font-latex.el +++ b/font-latex.el @@ -1,6 +1,6 @@ ;;; font-latex.el --- LaTeX fontification for Font Lock mode. -;; Copyright (C) 1996-2017 Free Software Foundation, Inc. +;; Copyright (C) 1996-2019 Free Software Foundation, Inc. ;; Authors: Peter S. Galbraith <p...@debian.org> ;; Simon Marshall <simon.marsh...@esrin.esa.it> @@ -1714,6 +1714,14 @@ marks boundaries for searching for group ends." "List of characters directly after \"\\" excluded from fontification. Each character is a string.") +(defvar font-latex-match-simple-include-list '("@") + "List of characters allowed in a macro for fontification. +Each character is a string. This variable is initialized to +\"@\" since internal LaTeX commands are very often redefined in a +.tex file and the fontification should work correctly in those +cases.") +(make-variable-buffer-local 'font-latex-match-simple-include-list) + (defun font-latex-match-simple-command (limit) "Search for command like \foo before LIMIT." ;; \s_ matches chars with symbol syntax, \sw chars with word syntax, @@ -1726,7 +1734,20 @@ Each character is a string.") ;; like `\__module_foo:nnn' (let* ((search (lambda () (TeX-re-search-forward-unescaped - "\\\(\s_\|\sw\|\s.\)\(?:\s_\|\sw\)*" limit t))) + (concat + ;; Chars directly after backslash + "\\\(\s_\|\sw\|\s.\)" + ;; Start group of the following chars + "\(?:[" + ;; a-zA-Z are always allowed: + "a-zA-Z" + ;; Additional characters added by AUCTeX styles + (mapconcat #'identity + font-latex-match-simple-include-list + "") + ;; End group + "]\)*") + limit t))) (pos (funcall search))) (while (and pos (member (match-string 1) diff --git a/style/expl3.el b/style/expl3.el index c1bb029..4fdea24 100644 --- a/style/expl3.el +++ b/style/expl3.el @@ -1,6 +1,6 @@ ;;; expl3.el --- AUCTeX style for `expl3.sty' -;; Copyright (C) 2015, 2017, 2018 Free Software Foundation, Inc. +;; Copyright (C) 2015, 2017-2019 Free Software Foundation, Inc. ;; Author: Tassilo Horn <t...@gnu.org> ;; Maintainer: auctex-devel@gnu.org @@ -48,6 +48,9 @@ (set-syntax-table LaTeX-expl3-syntax-table) (when (and (fboundp 'font-latex-update-font-lock) (eq TeX-install-font-lock 'font-latex-setup)) + ;; Fontify _ and : as part of macros. + (add-to-list 'font-latex-match-simple-include-list "_" t) + (add-to-list 'font-latex-match-simple-include-list ":" t) ;; Tell font-lock about the update. (font-latex-update-font-lock t))) LaTeX-dialect) _______________________________________________ auctex-diffs mailing list auctex-di...@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-diffs