Reputation:
I am editing python code in emacs. For some unknown reason, sometimes I open a .py file in emacs and different blocks are indented differently even though they run correctly. I have a block that looks like:
class Foo:
def __init__(self, params, p):
"""
Foo
"""
self.params = params
self.p = p
if self.p:
if (not ('A' in self.params)) or \
(not 'B' in self.params):
raise Exception, "Error"
the indentation of self.params = ...
line is clearly not the same as the next line self.p = p
, yet the code runs.
What is causing this and how can it be fixed?
when I run:
$ reindent -d ~/code.py
on the above file, nothing is printed.
Actually, when I pasted it into this text box it looked correctly until I pressed the {}
button to make it look like code. Any clue what is happening here? it is impossible to write code with this behavior.
I don't think it's mixing tabs and spaces because whitespace-mode
in emacs shows:
Upvotes: 1
Views: 250
Reputation: 6379
This does not reproduce for me. Make sure you're using Emacs 24.3 and that the problem occurs with emacs -nw -Q
.
Upvotes: 1