views:

79

answers:

1

I like to use python-mode.el and (gnu) emacs for editing my python files. If I use parentheses for multiline continuations, indentation works as I expect. For example,

foo_long_long_long_long = (
    bar_long_long_long_long[
        (x_long_long_long_long == X) &
        (y_long_long_long_long == Y)])

is just the way I like it.

On the other hand, if I use a backslash for continuations, a single indentation is created and all subsequent lines stop using the extra indentation logic. Below the third and fourth lines fail to have any extra indentation

foo_long_long_long_long = \
    bar_long_long_long_long[
    (x_long_long_long_long == X) &
    (y_long_long_long_long == Y)]

Does anyone know how to fix python-mode.el (5.1.0) so that backslash continuations indent the same as parenthesis continuations?


EDIT: Although I'm happy to just use parens all day long (python is after all, rather lisp like...), I collaborate with others who use backslash continuations. Emacs messes up the indentation when I press TAB, which I often do as a reflex. It'd be nice to be able to edit their files and have emacs keep all its indentation smarts when working with backslash line continuations.

+2  A: 

Don't use blackslash continuations.

Allen
For my own code, that's what I've done. This unfortunately is problematic when I work on files written by collaborators who prefer backslash continuations that work fine in their non-emacs editors. When I edit their files, it's easy for me to mess up the indentation with emacs (not in a semantic way, but in an aesthetically unpleasing way).
Mr Fooz