# Make Emacs ignore “mismatched” \index parentheses

I'm indexing a LaTeX document using Emacs and AUCTeX and RefTeX. One thing that makes it harder to match delimiters in the document (or to spot mismatched ones) is the propensity of Emacs (or maybe AUCTeX or RefTeX—I'm not sure which is responsible) to misunderstand the `|(` and `|)` page range specifiers in `\index` commands.

For example, when I type something like `\index{ferrets|(}`, then as soon as I type the `}` I get a spurious "Mismatched parentheses" warning in the minibuffer. And from this point on, all delimiter matching the document gets screwed up. For example, take the following snippet:

``````\somecommand{
⋮
\index{ferrets|(}
⋮
}
``````

When I type the final `}`, Emacs wrongly tells me that the matching opening brace is at `\index`, not at `\somecommand`.

Is there any way I can teach Emacs (or AUCTeX or RefTeX) to ignore the contents of `\index` commands for the purpose of brace matching?

A possibility is to tell AUCTeX `index` is a verbatim-like macro. This isn't really true, but verbatim-like macros ignore brace pairing. Add the following code to your init file and restart Emacs:
``````(eval-after-load "latex"
• On further testing, it seems the only problem is that putting this code in my Emacs init file does not suppress the "mismatched parentheses" minibuffer warning when typing the final brace of something like `\index{foo|(}`. I had mistakenly assumed that this meant the code had no effect at all. However, I see now that it does restore proper brace matching for subsequently typed braces (as in the `\somecommand` example of my original question). – Psychonaut Dec 15 '15 at 9:46