2

Each major mode seems to (quite unfortunately) have its own naming conventions for the special variable used to control indentation level. For example, c-mode has c-basic-offset, python-mode has python-indent-offset, perl-mode has cperl-indent-level.

How can I determine which variable I should set for any given mode?

4

There are some common patterns (you've already noted that "offset" and "indent" are likely terms), but ultimately each mode is free to implement indentation however it likes using any arbitrary variable name(s) it wants to use, so there is no guaranteed way to determine this information.

Furthermore a derived mode might rely entirely on its parent mode for indentation, and consequently the variable(s) in question may not even have the name prefix you expect.

My best advice is check the customize-group interface for the library in question, or to use apropos-variable with the pattern offset\|indent, and if that fails, be sure to check the parent mode (if any; use describe-function or find-function) so that you can chase up the same things in that mode (or indeed its own parent, etc...)

There's also SMIE, which is the nearest thing to a "standard" approach to indentation in Emacs that I know of, but which is relatively new and so presumably unlikely to have been adopted by very many pre-existing modes. I don't know too much about it, but you can read about it in the manual: C-hig (elisp) SMIE Customization RET

| improve this answer | |

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.