What's the right way to disable Emacs' default indent-relative behaviour and make sure that TAB always indents by a single level (be it a tab or whitespace character)?

There doesn't seem to much information about this in Emacs, but I get the impression that perhaps tab-stop-list is part of the solution if I remap indent-relative to tab-to-tab-stop.

  • 3
    indent-relative is a function that is defined to add sufficient whitespace to align the current line relative to the previous line. If what you really want is tab-to-tab-stop, you should use that instead, rather than redefining indent-relative. In many modes, M-i is bound to tab-to-tab-stop, and you can always bind it to something more convenient (including possibly whatever indent-relative is bound to in the mode).
    – Tyler
    Aug 14 '18 at 14:51
  • You're right, I realised my mistake with tab-to-tab-stop later. Thanks for clarifying. For the time being I only bound TAB to indent-for-tab-command. Fancy adding an answer or shall I answer my own question based on your inputs?
    – user66
    Aug 14 '18 at 16:29

If you want to use tab-to-tab-stop, just do so! tab-to-tab-stop and indent-relative are different functions, designed to do different things. Different modes will bind one or the other (or something else) to TAB, according to what the mode writer thought would be most convenient. If you prefer to use something other than the default, just rebind the key to use your preferred function.

Redefining the function, particularly with built-in functions, is likely to cause unexpected problems later on.

Your Answer

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