[Python-mode] edit-style considering empty line
Andreas Röhler
andreas.roehler at online.de
Tue Sep 24 10:04:53 CEST 2013
Am 24.09.2013 08:45, schrieb Diez B. Roggisch:
>
> On Sep 23, 2013, at 9:57 PM, Andreas Röhler <andreas.roehler at online.de> wrote:
>
>> Hi Barry, hi all,
>>
>> there was an expample at
>>
>> http://stackoverflow.com/questions/18940719/python-indentation-with-emacs/18940836#18940836
>>
>> if 1 < 2:
>> print("this line is part of the if statement")
>>
>> print("this is NOT part of the if statement")
>>
>>
>> The OP wanted the Editor intends the second "print" to column 0.
>> IMO it's possibly establishing an edit rule saying: if an empty line follows a block, consider this block closed.
>>
>> Now seeing the example below at
>>
>> http://pyvideo.org/video/1708/distributed-coordination-with-python
>>
>> def find(seq, target):
>> for i, value in enumerate(seq):
>> if value == tgt:
>> break
>> else:
>> return -1
>> return i
>>
>> If an empty line after "break" is inserted:
>>
>> def find(seq, target):
>> for i, value in enumerate(seq):
>> if value == tgt:
>> break
>>
>> else:
>> return -1
>> return i
>>
>> That would allow to calulate the "else:" to column 4 right away.
>> Also for me it's slightly better readable.
>>
>> Question: Would you welcome such an edit-style or rather discourage?
>
> If it's optional, and initially off, I wouldn't mind.
Would be off by default.
BTW if enabled, C-j than would keep indent at first step.
A second C-j would leave that empty line empty but re-calculate if it should dedent now after that new rule.
More information about the Python-mode
mailing list