0

More precisely, I would like TAB to indent the current line when there are 0 or more whitespace characters between the start of line and the point and to advance to the next tab stop otherwise. I used to have this behavior 1 or 2 major versions ago, but I lost it in an upgrade (I'm currently using 27.2).

I tried customizing tab-always-indent to nil as defined in indent.el, but I think the programming mode is overriding this behavior (I primarily deal in curly-brace languages).

I use this behavior to create "columns" in my source. i.e.

private int       able;
private boolean   baker;

public    int       getAble()                    { return able; }
public    boolean   getBaker()                   { return baker; }

Turns out I needed to pay closer attention to the description when customizing tab-always-indent and customize c-tab-always-indent as:

Some programming language modes have their own variable to control this, e.g., 'c-tab-always-indent', and do not respect this variable.

3
  • What's the output of C-h c <TAB> and C-h v <tab-always-indent>, both with your Emacs setup and when starting it without customizations (e.g.$ emacs -Q)? What is the major-mode of the buffer?
    – Y. E.
    Dec 11, 2021 at 12:28
  • That set of questions from Y. E. led me to the right answer. I should have paid more attention when I customized tab-always-indent. The bottom of the descriptions reads: "Some programming language modes have their own variable to control this, e.g., ‘c-tab-always-indent’, and do not respect this variable." customizing c-tab-always-indent fixed by problem for java Dec 12, 2021 at 0:32
  • Please write a quick Answer explaining the solution to that problem, and then you can Accept your own answer. This will help future readers who have the same problem.
    – phils
    Dec 12, 2021 at 2:29

1 Answer 1

0

A more careful reading of the customize description for tab-always-indent points to c-tab-always-indent as controlling this behavior for the c programing family (c, c++, java, probably c#).

Controls the operation of the TAB key. If t, hitting TAB always just indents the current line. If nil, hitting TAB indents the current line if point is at the left margin or in the line’s indentation, otherwise it inserts a "real" TAB character. If ‘complete’, TAB first tries to indent the current line, and if the line was already indented, then try to complete the thing at point.

Some programming language modes have their own variable to control this, e.g., ‘c-tab-always-indent’, and do not respect this variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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