[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: |
Mosè Giordano |
Subject: |
Re: [Bug-AUCTeX] 11.87; Failure to insert smart quotes in some circumstances |
Date: |
Sat, 11 Jan 2014 19:22:43 +0100 |
Hi Ralf,
2014/1/11 Ralf Angeli <address@hidden>:
> * 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:
>
> "\\([^\\$]\\|[^\\]\\(\\\\\\\\\\)*\\\\\\$\\|[^\\]\\(\\\\\\\\\\)+\\|\\`\\)\\(\\$\\$\\|\\$\\)"
>
Thanks for your suggestions! Unfortunately, this regexp doesn't match
the opening dollar in
\\$something$
> 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.
>
I think you're right, `re-builder' confirms your idea.
> 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.
>
The attached patch uses the same logic of `TeX-escaped-p', but fails
to recognize the math mode in
\$$something$
because finds `$$' preceded by an escape. All in all, a single well
conceived regexp probably is better.
Bye,
Mosè
texmathp.el.patch
Description: Text Data