Hi all, some verbatim-like environments, notably those provided by the fancyvrb and listings packages, takes an optional argument. As reported here [1], AUCTeX fails to correctly fontify optional arguments longer than one line. Do you have objections against installing the attached patch in AUCTeX? It is the same code provided in the answer in the above link, plus some comments. In the answer there are also examples of how the patch improves fontification.
Actually, I found a limitation: fontification gets broken while one edits the longer-than-one-line-optional-argument, and this is fixed by reverting the buffer, but for the time being fontification of these longer-than-one-line-optional-arguments is somewhat wrong anyway. [1] http://tex.stackexchange.com/q/169609/31416 Bye, Mosè
diff --git a/font-latex.el b/font-latex.el index 33eb1ad..39be372 100644 --- a/font-latex.el +++ b/font-latex.el @@ -896,8 +896,20 @@ have changed." font-latex-syntactic-keywords nil) (unless (= (length verb-envs) 0) (add-to-list 'font-latex-syntactic-keywords - `(,(concat "^[ \t]*\\\\begin *{\\(?:" verb-envs - "\\)}.*\\(\n\\)") + `(,(concat + "^[ \t]*\\\\begin *{\\(?:" verb-envs "\\)}" + ;; Some environments accept an optional argument that can + ;; span over more lines. Between "\begin{<envname>}" and + ;; the optional argument there can be whitespaces and the + ;; newline can be commented by a "%" character. + "[ \t]*\\(?:%.*\n[ \t]*\\)?" + ;; The following line of the regexp matches the optional + ;; argument and allows for up to one level of brackets + ;; inside the argument (e.g., the dialect of a language + ;; in the `lstlisting' environment by the `listings' + ;; package). + "\\(?:\\[[^\]\[]*\\(?:\\[[^\]\[]*\\][^\]\[]*\\)*\\]\\)?" + "\\(\n\\)") (1 "|" t))) (add-to-list 'font-latex-syntactic-keywords ;; Using the newline character for the syntax
_______________________________________________ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel