Indentation problem
Isaac To
kkto at csis.hku.hk
Tue Mar 26 00:53:59 EST 2002
>>>>> "Skip" == Skip Montanaro <skip at pobox.com> writes:
Isaac> I'd rather suggest to have a Python-specific indentation command
Isaac> in Emacs that will "reindent a region in a way that fits the
Isaac> current indentation style and fit in the current context, but
Isaac> retain the original meaning". This really shouldn't be that
Isaac> difficult. Anyone will try his elisp skills?
Skip> Check out python-mode:
Skip> http://www.python.org/emacs/python-mode/
Skip> It already has key bindings C-c > and C-c < which indent or dedent
Skip> the selected region by the indentation delta. Works like a charm.
This is somewhat close to what I say, but a little bit off: it won't
reindent to the correct tab width. E.g., if you have the following
def f(a):
print("Trying " + a)
if (a <= 0):
return 1
else
return a * f(a-1)
print("Done")
and you try to use the C-c > command, you end up with
def f(a):
print("Trying " + a)
if (a <= 0):
return 1
else
return a * f(a-1)
print("Done")
It still works, but it doesn't look nice. What I want is a real
reindentation which understand how Python reads indentation, making it
def f(a):
print("Trying " + a)
if (a <= 0):
return 1
else
return a * f(a-1)
print("Done")
Yes, it is very Python specific.
Regards,
Isaac.
More information about the Python-list
mailing list