bug-auctex
[Top][All Lists]
Advanced

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

Re: [Bug-AUCTeX] 11.81; help needed with font-latex-user-keyword-classe


From: Ralf Angeli
Subject: Re: [Bug-AUCTeX] 11.81; help needed with font-latex-user-keyword-classes
Date: Sat, 15 Oct 2005 12:24:14 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

* Patrick Drechsler (2005-10-15) writes:

> I'm not sure if my last reply was sent, so forgive me if it's
> posted twice.

It was sent.  But to me only.

> Ralf Angeli wrote on 14 Oct 2005 08:56:11 MET:
>
>> * Patrick Drechsler (2005-10-13) writes:
>>
>>> I was wondering if somebody could help me suppress syntax
>>> highlighting of the math environment within a certain macro?
>> [...]
>>> Here is the value: \Sexpr{b$p.value} some more text.
>>
>> I'd add this macro to `LaTeX-verbatim-macros-with-braces'.
>
> Thanks, this got me on the right track.
>
> Customizing `font-latex-verbatim-macros' solved my problem. I
> could not find `LaTeX-verbatim-macros-with-braces'. Is this a cvs
> feature?

Yes.  `LaTeX-verbatim-macros-with-braces' replaces
`font-latex-verbatim-macros'.

> Here is a situation were it still gives unwanted fontification:
[...]
> not fine: $P=\Sexpr{b$p.value}$ some text in verbatim color.
[...]
> Everything after the last `$' is fontified as verbatim.

Good heavens!  That's a tough one.  Frankly I don't know a good way
how to fix this.  As a workaround you can write

  \(P=\Sexpr{b$p.value}\)

instead of

  $P=\Sexpr{b$p.value}$

For technically oriented people: Problem here is how syntactic
fontification is done.  When `font-lock-fontify-syntactically-region'
is called there are several hotspots in "$P=\Sexpr{b$p.value}$".
Those are the three $ characters with a `"' syntax in font-lock's
syntax table and the braces of the \Sexpr macro with `|' syntax
properties(!) (inserted by
`font-lock-fontify-syntactic-keywords-region').  Now
`font-lock-fontify-syntactically-region' approaches the text from the
left, sees the first $ character and the calls `parse-partial-sexp' to
find a matching closing one.  That's the one inside of the \Sexpr
macro.  By this we are past the syntax property of the opening brace
which will never be considered.  And this screws fontification of the
whole construct.

Now why is "\(P=\Sexpr{b$p.value}\)" working?  The \(...\) pair is not
fontified syntactically but by means of keywords.  And fontification
of keywords happens after the syntactic pass.  That means syntactic
fontification can take care of the \Sexpr macro and mark it as
verbatim (disregarding/skipping the $ character).  After that keywords
fontification will mark the \(...\) pair as math.

A remedy for the problem with $...$ could be to fontify this by means
of keyword fontification as well.  But I am afraid that this will slow
down font locking dramatically.  Also, I don't know how good we could
cope with syntactic states (like `parse-partial-sexp', `syntax-ppss',
etc. is able to do).

-- 
Ralf




reply via email to

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