all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Howto disable syntax-highlighting for '$'-enclosed math?
@ 2010-03-19 16:05 Stefan Klinger
  2010-03-22 13:09 ` Thamer Mahmoud
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Klinger @ 2010-03-19 16:05 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I need to disable the syntax-highlighting for '$'-enclosed math in LaTeX
mode. This is quite important for me: I'm typesetting a lot of XQuery code
snippets that contain '$' characters to mark variable names:

  \iquery{$q = "foo"}
  
or, as an environment:

  \begin{query}
fn:count($doc//target)
  \end{query}
  
These code snippets are typeset with the "listings" package.

Emacs always displays text following a '$' in green until another '$'
occurs. This is annoying, and basically wrong because I never entered math
mode. As a workaround I started adding "%$<newline>" sequences to end the
highlighting, but this interferes heavily with M-q (bound to
fill-paragraph). Also, it's an ugly hack.

So how can I make the LaTeX-mode handle $ as an ordinary character?

Btw.: Using \$ in the queries is not a good option: I failed to configure the
listings package to accept this. Also, an advantage of the listings package is
that the queries do not need escaping.

Thak you very much!
Stefan



-- 
Stefan Klinger                                      o/klettern
                                                    /\/  bis zum
send plaintext only - max size 32kB - no spam         \   Abfallen
http://stefan-klinger.de




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Howto disable syntax-highlighting for '$'-enclosed math?
  2010-03-19 16:05 Howto disable syntax-highlighting for '$'-enclosed math? Stefan Klinger
@ 2010-03-22 13:09 ` Thamer Mahmoud
  0 siblings, 0 replies; 2+ messages in thread
From: Thamer Mahmoud @ 2010-03-22 13:09 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Klinger <all-lists@stefan-klinger.de> writes:

> Hello,
>
> I need to disable the syntax-highlighting for '$'-enclosed math in LaTeX
> mode.
[...]
> Emacs always displays text following a '$' in green until another '$'
> occurs. This is annoying, and basically wrong because I never entered math
> mode.

I think you're better of using AUCTeX, which has built-in support for
syntax-highlighting in listings environment (and many other features).

Get it from here:
http://www.gnu.org/software/auctex/

As for vanilla tex-mode, this should partially work (it works for the
text after the `$', but not the `$' itself):

(font-lock-remove-keywords nil ''("\\$\\$\\([^$]+\\)\\$\\$" 1 tex-math-face))
(font-lock-remove-keywords nil ''("\\$\\$\\([^$]+\\)\\$\\$" (1 tex-math-face)))

I got this information by looking at the value of `font-lock-keywords'
(using C-h v). Also see the documentation of `font-lock-remove-keywords'
(using C-h f) for other options.

hth,
Thamer





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-22 13:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-19 16:05 Howto disable syntax-highlighting for '$'-enclosed math? Stefan Klinger
2010-03-22 13:09 ` Thamer Mahmoud

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.