[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] font-latex.el: Better support for verbatim macros
From: |
Arash Esbati |
Subject: |
Re: [AUCTeX-devel] font-latex.el: Better support for verbatim macros |
Date: |
Fri, 24 Mar 2017 16:04:39 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 |
Arash Esbati <address@hidden> writes:
> font-latex.el can not handle verbatim macros with optional and/or
> mandatory arguments before the actual verbatim part.
Following-up myself and after looking at this again, I think there is no
way to make it all work within font-latex.el. I think the best way is
to patch font-latex.el in order to understand optional arguments after
verbatim macros (delimited or with braces) like this:
--8<---------------cut here---------------start------------->8---
diff --git a/font-latex.el b/font-latex.el
index a56d3ce1..d6f56ecf 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1005,6 +1005,10 @@ have changed."
(unless (= (length verb-macros-with-delims) 0)
(add-to-list 'font-latex-syntactic-keywords
`(,(concat "\\\\\\(?:" verb-macros-with-delims "\\)"
+ ;; Some macros take an optional
+ ;; argument. This is the same line as
+ ;; above for environments.
+ "\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
;; An opening curly brace as delimiter
;; is valid, but allowing it might screw
;; up fontification of stuff like
@@ -1019,6 +1023,10 @@ have changed."
(unless (= (length verb-macros-with-braces) 0)
(add-to-list 'font-latex-syntactic-keywords
`(,(concat "\\\\\\(?:" verb-macros-with-braces "\\)"
+ ;; Some macros take an optional
+ ;; argument. This is the same line as
+ ;; above for environments.
+ "\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
"\\({\\).*?[^\\]\\(?:\\\\\\\\\\)*\\(}\\)")
(1 "|") (2 "|")))))
(when font-latex-syntactic-keywords-extra
--8<---------------cut here---------------end--------------->8---
Style files like minted.el can add their special requirements to
`font-latex-syntactic-keywords-extra'. The result can look like this:
x3.png
Description: PNG image
The entire patch is attached.
font-lock.diff
Description: Text Data
The questions remaining are:
1) Should user defined macros like \perlinline be fontified like
\newmintinline?
2) If yes, should \verb be fontified as well?
Any comments welcome.
Best, Arash