[Tex/LaTex] AUCTex indentation settings

auctexindentation

I don't really like how AUCTeX indents latex code, and overall I find it pretty unpredictable (I guess I'm not used to the way it works). Some modes just bind the tab key to "move the current line so that it begins at next tab stop". Is there a way to achieve this in AUCTeX? Ideally, lines would be indented with spaces.

Similarly, is there a way to bind Shift+Tab to "indent the current line back to previous tab stop"?

I managed to change the behaviour of the Tab key, but only to insert tabs at the current position, which isn't really great.

Best Answer

Alright, I'm not very good with emacs, but since no one else seems to have any ideas I thought I'd have a stab at providing the resources that might help fix the problem:

I found the following note which looks promising:

M-i Indent from point to the next prespecified tab stop column (tab-to-tab-stop).

[...]

If you just want to insert a tab character in the buffer, you can type C-q TAB.

You should be able to rebind the key to M-i, or whatever function M-i calls. There is more information on this in the second on Tab Stops.

Other resources I've found that might help:

http://www.emacswiki.org/emacs/IndentingC#toc7 Describes how to turn off automatic tabbing and have it insert a tabstop each time tab is pressed. However this is for c-mode, and I don't know if the hooks are the same for ACUTeX.

http://www.gnu.org/software/emacs/manual/html_node/ccmode/Indentation-Commands.html#Indentation-Commands describes how to make the key simply insert either a set number of spaces or a tab-character.

Related Question