* Ralf Angeli (2010-11-21) writes:
> At the moment I'm not sure yet how to fix this. Perhaps putting the
> syntax property on the characters after the opening and before the
> closing brace would help. But I'll have to check if this is the right
> thing to do.
Attached is a patch that does this. Just in case you want to test it.
But I am not yet convinced this is the right thing to do because it will
mess with the syntax of characters between the braces. For instance, in
your example the closing brace of "transform()" will lose its original
syntax class and something like Show Paren mode will get confused if you
put point on the opening brace. Another drawback is that single chars
(things like \lstinline{x}) will not be highlighted correctly.
Another option one could test in order to fix this bug is to stop
treating the braces of the verbatim macros as braces (i.e. accept that
they now have a different syntax) and rather handle it like \verb|...|
(for which there is actually no support yet).
Other suggestions appreciated.
By the way, it could be that some of the problems go away if you keep
the stuff for the optional argument of `lstlisting' on the line with the
\begin macro.
This is now getting a bit technical, so I'm setting a follow-up to
auctex-devel.
--
Ralf
--- font-latex.el.~5.191.~ 2010-09-12 11:47:59.000000000 +0200
+++ font-latex.el 2010-11-23 22:15:54.000000000 +0100
@@ -841,6 +841,15 @@
The form should be the same as in `font-lock-syntactic-keywords'.")
(make-variable-buffer-local 'font-latex-syntactic-keywords-extra)
+(defun font-latex-propertize-verb-macro-with-braces (start end)
+ "Put syntax properties on a verbatim macro with braces.
+START is the position just behind the opening brace and END is
+the position just before the closing brace."
+ (if (= (- end start) 1)
+ (put-text-property start (1+ start) 'syntax-table (string-to-syntax "."))
+ (put-text-property start (1+ start) 'syntax-table (string-to-syntax "|"))
+ (put-text-property (1- end) end 'syntax-table (string-to-syntax "|"))))
+
(defun font-latex-set-syntactic-keywords ()
"Set the variable `font-latex-syntactic-keywords'.
This function can be used to refresh the variable in case other
@@ -894,8 +903,9 @@
(unless (= (length verb-macros-with-braces) 0)
(add-to-list 'font-latex-syntactic-keywords
`(,(concat "\\\\\\(?:" verb-macros-with-braces "\\)"
- "\\({\\).*?[^\\]\\(?:\\\\\\\\\\)*\\(}\\)")
- (1 "|") (2 "|")))))
+ "{\\(.*?[^\\]\\(?:\\\\\\\\\\)*\\)}")
+ (1 (ignore (font-latex-propertize-verb-macro-with-braces
+ (match-beginning 1) (match-end 1))))))))
(when font-latex-syntactic-keywords-extra
(nconc font-latex-syntactic-keywords font-latex-syntactic-keywords-extra))
;; Cater for docTeX mode.
_______________________________________________
auctex-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex-devel