Proper indendation with backslash line continuatio

2019-04-03 00:08发布

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条回答
时光不老,我们不散
2楼-- · 2019-04-03 00:36

Don't use blackslash continuations.

查看更多
再贱就再见
3楼-- · 2019-04-03 00:54

This got Bug lp:629916, fixed in https://launchpad.net/python-mode

查看更多
登录 后发表回答