# Auto-completion in Auctex automatically introduces dollar signs

My auto-completion all of a sudden changed its behavior, and I have no clue why. When I auto-complete a mathematical expression, like \subseteq, say, it will introduce dollar signs in front and at the end. However, it only does this, if I am in math-mode. To illustrate:

\subse TAB


gives

\subseteq


and

$\subse TAB  gives $$\subseteq$


which renders the auto completion completely useless, as everytime I have to delete the dollar signs.

Similarly,

$\int_{0}^{\inf TAB}$


gives

$\int_{0}^{$\infty$}$


Please find below the corresponding section from my .emacs file. I don't know any lisp.

(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
;; AucTex setup
(require 'auto-complete-auctex)
;; Stop completion
(define-key ac-complete-mode-map "\M-/" 'ac-stop)
;; Now you can stop completion by pressing M-/.
;; Completion by TAB
;; -----------------
(define-key ac-complete-mode-map "\t" 'ac-complete)
(define-key ac-complete-mode-map "\r" nil)
;; Do What I Mean mode
;; -------------------
;; If DWIM (Do What I Mean) mode is enabled,
;; the following features is available:
;;
;; a. TAB (ac-expand) behave as completion (ac-complete)
;;    when only one candidate is left
;; b. TAB (ac-expand) behave as completion (ac-complete)
;;    after you select candidate
;; c. Disapear automatically when you
;;    complete a candidate.
(setq ac-dwim t)
(setq ac-ignore-case nil) ; prevent autocomplete from changing capitalization

• Confusingly, it stopped. I did not run any system updates or similar in the meantime. – M. Luethi Jan 13 at 16:55

As I understand, '$' chars in TeX are paired to delimit math expression in a text, i.e.$something$should be interpreted using math mode. My guess it's TeX-electric-math variable: If non-nil and point is inside math mode right between a couple of single dollars, pressing ‘$’ will insert another pair of dollar signs and leave the point between them.
It can be customized: M-x customize-variable TeX-electric-math
To read documentation for almost any variable: C-h v _some-var-name_