auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] fontifying contents of an environment


From: Non Aggie
Subject: Re: [AUCTeX] fontifying contents of an environment
Date: Sun, 29 Aug 2010 15:32:06 -0400

Thank you, Ralf -- that works perfectly!

On Sun, Aug 29, 2010 at 12:52 PM, Ralf Angeli <address@hidden> 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
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]