Thank you, Ralf -- that works perfectly! On Sun, Aug 29, 2010 at 12:52 PM, Ralf Angeli <[email protected]> wrote: > * Non Aggie (2010-08-28) writes: > >> I am trying to syntax highlight the contents of certain environments. >> Following the suggestion of a long-ago post on this list >> (http://article.gmane.org/gmane.emacs.auctex.general/2875/match=font+lock+environment), >> I tried the following to highlight the contents of an environment >> called problem: >> >> (add-hook 'LaTeX-mode-hook >> (lambda () >> (font-lock-add-keywords >> 'latex-mode >> '(("\\\\begin{problem}\\(\\(.\\|\n\\)+?\\)\\\\end{problem}" 1 >> 'font-latex-sectioning-5-face) >> )) >> )) > > It's quite unlispy to let those poor parens alone on a line. > >> This works fine most of the time, but if the text inside the problem >> environment contains % or $, then none of the text in the environment >> is highlighted. > > By default the fontification will only be applied if the region does not > already contain fontified content. Comments and math are handled before > the keywords you added and that's why they are not applied. > >> How do I fix this? > > You can tell the font locking engine to override an existing > fontification with your stuff by adding an override flag. The following > should do the trick: > > (add-hook 'LaTeX-mode-hook > (lambda () > (font-lock-add-keywords > 'latex-mode > '(("\\\\begin{problem}\\(\\(.\\|\n\\)+?\\)\\\\end{problem}" 1 > 'font-latex-sectioning-5-face t))))) > > -- > Ralf >
_______________________________________________ auctex mailing list [email protected] http://lists.gnu.org/mailman/listinfo/auctex
