However, it may happen that the previous line is indented for the
inner paren as in the ERT `python-indent-inside-paren-2':
data = {'key': {
'objlist': [
{'pk': 1,
'name': 'first'},
{'pk': 2,
'name': 'second'}
]
}}
The line "{'pk': 2," is considered as the continuation line, but it
should not respect the indentation of the PREVIOUS line "'name':
'first'},". So skipping such lines with inner parens were needed.
It searches backward for the line which starts with the item of the
same opening paren as the target line.
In the case of the above example, if the target line is "{'pk': 2,",
its opening paren is "[" in the line "'objlist': [". It first checks
the previous line "'name': 'first'},", but its opening paren is "{" in
"{'pk': 1,". So this line is skipped. Next, it checks the line
"{'pk': 1," and its opening paren is "[" in the line "'objlist': [",
which is same as the target line. So the target line's indentation
will be as same as the line "{'pk': 1,".
It would be helpful if you could try this patch.
Thank you, tested, works for me!
Does anyone think we should have a customize variable that switches
between the traditional behavior of ignoring the indentation of the
previous line and this new behavior?
I doubt it's useful. It is in general how indentation works in many modes, and I
don't think there ever been a variable to disable that. Stefan Monnier in
particular has a paper called "SMIE: weakness is power", where such indentation
is shortly discussed.
IMO the question of previous lines indentation isn't raised here, as a more
specific rule applies: inside a non-empty list
indent with its first element. Whereas if list starts empty, as with "[" here,
next indents as that line plus offset.