bug-auctex
[Top][All Lists]
Advanced

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

Re: [Bug-AUCTeX] 11.87; Failure to insert smart quotes in some circumsta


From: Ralf Angeli
Subject: Re: [Bug-AUCTeX] 11.87; Failure to insert smart quotes in some circumstances
Date: Sat, 11 Jan 2014 12:00:04 +0100

* Mosè Giordano (2014-01-11) writes:

> thanks for your report.  The problem is in the `texmathp' function,
> and in particular in the regexp used for searching math togglers, ie
> `texmathp-toggle-regexp'.  Its value is
> "\\([^\\\\\\$]\\|\\`\\)\\(\\$\\$\\|\\$\\)", but this doesn't match a
> dollar preceded by two escapes.
> "\\(\\\\\\\\\\|[^\\\\\\$]\\|\\`\\)\\(\\$\\$\\|\\$\\)" should do the
> trick, but I'd like a confirmation by someone more experienced in
> regexps than me.  Actually we should make sure there is an even number
> of escapes, not just two, then perhaps something like `TeX-escaped-p'
> might be needed.

IIRC we used something like "[^\\]\\(\\\\\\\\\\)*" to check if something
is unescaped before we had `TeX-escaped-p'.  Let's assume the logic for
the regexp is the following:

match a pair of dollar signs or a single dollar sign under the condition
that a) in front of it there is no dollar sign or escape or b) if there
is a dollar sign in front if it, it is preceded by an odd number of
escapes or c) if there is an escape in front of it, it has to be
preceded by an odd number of escapes, so that there is an even number of
escapes in a row or d) the dollar sign(s) occur(s) at the start of the
buffer

In that case the regexp could look like this:

"\\([^\\$]\\|[^\\]\\(\\\\\\\\\\)*\\\\\\$\\|[^\\]\\(\\\\\\\\\\)+\\|\\`\\)\\(\\$\\$\\|\\$\\)"

Note: I think that the "[^\\\\\\$]" in the original regexp has too many
escapes.  "[^\\$]" should suffice because you don't need to escape the
characters in a character alternative.

The regexp would become rather complicated, so it might be worth to
check if using `TeX-escaped-p' is the nicer alternative.  Or somebody
has an idea how to simplify the regexp.

Regarding the suggestion to use the font locking code: I haven't checked
this in depth, but font-latex relies on facilities of font-lock
(`font-lock-syntactic-face-function' to be specific) in order to set the
math face.  However, `texmathp' should also work without font-lock.
Without font-lock, one could perhaps do a syntax-based search.  I tried
this with `(re-search-forward "\s$" nil t)' but this also returned
escaped dollars.  So one would have to examine further what to do to
make this work.

-- 
Ralf



reply via email to

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