I discovered that auctex's texmathp-match-switch
does not check whether or not dollar signs are commented out or not, therefore i get wrong results when i all M-x `texmathp'
in very specific contexts. So i wanted to redefine the function in a custom library that is loaded automatically as soon as LaTeX-Mode is invoked (by adding the library to the LaTeX-mode-hook
). The relevant parts of my code are:
(require 'tex)
(require 'latex)
(defun texmathp-match-switch (bound)
"Search backward for any of the math switches.
Limit searched to BOUND."
;; The return value is like ("\\(" . (point)).
(save-excursion
(if (and (re-search-backward texmathp-onoff-regexp bound t)
;; my addition (and the `and' above):
(not (TeX-in-commented-line)))
(cons (buffer-substring-no-properties (match-beginning 1) (match-end 1))
(match-beginning 1))
nil)))
Unfortunalety, this naive approach doesn't work.
Whenever I am in a tex file and do M-h 'texmathp-match-switch'
it says "texmathp-match-switch is an autoloaded compiled Lisp function in `texmathp.el'.
". Ho do I do this the right way?
EDIT: In case, it's relevant: AUCTeX-version is 11.87; emacs-version is 24.3.1. And no, I cannot update either: "Never change a running system".