1

Even when I open pure emacs -Q and a python file in it:

| - cursor

if smth:
|   print("asd")       # press TAB and cursor moves to "p" symbol, it's ok

if smth:
   |print("asd")       # press TAB and I get this:

if smth:
print("asd")           # press TAB and I get prev step

So TAB makes a cyclic change of indentation level. Which I absolutely don't want to.
If to use smart-tab problem can be solved. But yasnippet (yas-global-mode 1) brings it again.
And that's where I can't find why.

If you had this problem (python+yasnippet+correct indent) - please give me a tip. Or just a link to a working config.

Latest Emacs (24.3.50.1)

Sergey
  • 19,487
  • 13
  • 44
  • 68
  • 1
    Is this what you are looking for? `(setq yas-indent-line nil)`   "Controls indenting applied to a recent snippet expansion. The following values are possible: - 'fixed' Indent the snippet to the current column; - 'auto' Indent each line of the snippet with `indent-according-to-mode'. Every other value means don't apply any snippet-side indendtation after expansion (the manual per-line \"$>\" indentation still applies)." – lawlist Mar 09 '14 at 21:59
  • No, the lines are still "jumping" – Sergey Mar 09 '14 at 22:14
  • Which `smart-tab` is this? – npostavs Mar 10 '14 at 01:33
  • Try setting `python-indent-trigger-commands` to nil. –  Mar 10 '14 at 01:54

1 Answers1

1

One way of controlling the cycling with TAB is to customize python-indent-trigger-commands. The docstring of the variable states

Commands that might trigger a `python-indent-line' call.

However it is not clear from the docstring that the variable can be used to control cycling (actually I am not even sure if setting this variable if the correct way of controlling indentation cycling). The docstring of python-indent-line explains the purpose of this variable better

When the variable last-command' is equal to one of the symbols inside python-indent-trigger-commands or FORCE-TOGGLE is non-nil it cycles levels indicated in the variable python-indent-levels by setting the current level in the variable `python-indent-current-level'.

So (setq python-indent-trigger-commands nil) (or you can just remove indent-for-tab-command from the list) can be used for disabling indentation cycling. There is a slight disadvantage of this approach that you cannot use TAB indent code like the following where else can either close for or if.

for ..:
    if ..:
        ...
        break
else:
    ...

You will have hit backspace before else to reindent it such that it closes the for (by default it will be indented such that it closes the if)