1

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
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(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
2

In Emacs besides auto-completion there's another method of automatic insertion: electric characters.
In some prog modes, some predefined characters in addition to inserting themselves, also reindent the current line, and optionally also insert newlines.

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_
Doc buffer for a variable shoud contain a link to a customize buffer for that variable.

There are several other electric chars in TeX mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.