emacs-pretest-bug
[Top][All Lists]
Advanced

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

Conditional font locking


From: Ralf Angeli
Subject: Conditional font locking
Date: Wed, 05 May 2004 10:16:14 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

[This is a follow-up to the article
 <news:address@hidden> originally posted
 to gnu.emacs.help.  It accompanies a bug report sent to
 emacs-pretest-bug.]

Hello everybody,

there are certain situations where it can be necessary to inhibit font
locking or use a different scheme for it.

Suppose you have the following LaTeX file:

\documentclass{article}
\begin{document}
Here is some text
\begin{verbatim}
\textbf{
\end{verbatim}
and here the text goes on.
\end{document}

A lot of text after the \textbf{ will incorrectly be fontified bold.

Because verbatim-like environments can hold all sorts of things that
can confuse font locking, it would be a good idea to inhibit font
locking inside those environments.  Now what I am searching for is a
way to plug in the condition "if inside verbatim-like environment,
don't do font locking".

If you take this further and look e.g. at the LaTeX package `listings'
which is able to nicely format code snippets of several programming
languages, it would be nice if you could not only say "stop
fontification in environment foo" but "do fontification according to
fontification scheme bar in environment foo".

According to Stefan Monnier on gnu.emacs.help such an
interface/functionality does not exist yet.

While the above shows a bug in the font locking functionality of
`tex-mode.el', AUCTeX is affected by the same problem.  AUCTeX, more
specifically `font-latex.el', does not include \textbf{} and similar
things directly in `font-lock-keywords' but uses a function to
determine the match.  This allows me to code around some of the
effects of the problem.  But attaching band-aids to various places
does not seem to be the right way to fix those font locking bugs.  A
possibility to suppress font locking based on certain conditions would
be a much better way and very much relieve my headaches.

-- 
Ralf




reply via email to

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