Hi João,
sorry for not being self-contained. This was my first GNU bug report ;-)
Concerning the fix, I tried texmathp today and indeed it works fine. I have in mind something like the following snippet (to be run whenever $ is hit):
(interactive)
(if (texmathp)
(if (looking-at-p "[$]")
(forward-char 1)
(insert "$"))
(insert "$$")
(backward-char 1)))
This also takes care of the issue that when I delete the closing $ by hitting backspace and then type $ again, a new pair used to be inserted.
A minor drawback is that this only works for $...$ specifically and it requires AUCTeX, which not everybody may be using. But $...$ is good enough for me and if I understand you correctly, one could include texmathp.el in the Emacs source.
Cheers,
Patrick