The command you need is electric-indent-local-mode
. You can use this to turn off electric-indent-mode in any buffer by calling it manually: M-x electric-indent-local-mode
. This is a toggle, so calling it again in the same buffer turns it back on again.
To do this automatically from your init file, you need to set up a hook. First, define the hook:
(defun remove-electric-indent-mode ()
(electric-indent-local-mode -1))
Then add it to the appropriate mode hooks. To turn off electric-indent-mode for the LaTeX mode provided by AUCTex, use this:
(add-hook 'LaTeX-mode-hook 'remove-electric-indent-mode)
For the default texmode, use:
(add-hook 'tex-mode-hook 'remove-electric-indent-mode)
The same pattern holds for any other mode you want to turn off electric indentation.
For more details on mode hooks, see the built-in Emacs manual node [(emacs) Hooks][1]
. You can get there from Emacs via C-h i r m Hooks <enter>
: C-h
for help, i
for info, r
for read the manual, m
for menu item, and Hooks
to pick the menu item. (or you can follow the link above to see the html version).