This is (yet) another question related to electric-indent-mode and Python, but since I couldn't find what I address here in the other ones, here we go.
I find the behavior of electric-indent-mode quite useful in general, but there is a minor thing that annoys me:
Say we have the following buffer, where |
(pipe) represents the cursor position:
def example():
if True:
print("Electricity")
|
With electric-indent-mode on, pressing RET results in the following state:
def example():
if True:
print("Electricity")
|
The automatic indentation of the newline regards only the first non-empty (i.e., that consists not only of whitespace) previous line. However, what I would like is to have it take into account the cursor position of the previous line if the previous line consists only of whitespace (and after pressing enter, still remove the whitespace on the previous line afterwards if there was any):
def example():
if True:
print("Electricity")
|
How can I tweak electric-indent-mode configurations to achieve the desired behavior? Conversely, what are the possible solutions (regardless of using electric-indent-mode or not)?