Question

Emacs's Python mode has an annoying "feature" that automatically indents line continuations from parentheses and brackets against the opening bracket in the previous line. So we get stuff like

myfunc(a, b, c,
       d, e, f)

This is annoying because it makes the indentation throughout the file look inconsistent, but also because you get stuff like

myfunc(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, (x,
                                                                             y, z))

(I've made it so long to illustrate that this usually happens automatically based on the column size)

If I were to add more arguments to myfunc, everything would be stuck over there with the x.

I want it to always indent additional lines four spaces more than the first line. Continuations against \ seem to do the right thing (I'm not positive that it's right 100% of the time, though, as I rarely use \). For example, what I want for the above would be

myfunc(a, b, c,
    d, e, f)

and

myfunc(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, (x,
    y, z))

So I guess I want the reverse of Proper indendation with backslash line continuations in python-mode.el.

Was it helpful?

Solution 2

I'm still new to lisp, so this probably could have been done without editing the source code, but for me, this is the easiest way. I have modified python.el at https://github.com/asmeurer/python.el/tree/indentation to remove this. I also removed the automatic alignment of dots (like multi lines python indentation on emacs), but it's a separate commit.

OTHER TIPS

the value is fetched from py-compute-indentation, just now at line 5091 of current trunks python-mode.el

bzr branch lp:python-mode

introcuce a boolean there: (if my-boolean py-indent-offset (INSTEAD OF COUMPUTED VALUE RETURNED...

OTOH that value seems reasonable as is, not mixing up with block design

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top