GNU bug report logs - #17658
Python mode has odd indentation behavior

Previous Next

Package: emacs;

Reported by: Adam Connor <adamc55 <at> gmail.com>

Date: Sun, 1 Jun 2014 02:25:02 UTC

Severity: normal

Done: fgallina <at> gnu.org (Fabián Ezequiel Gallina)

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: fgallina <at> gnu.org (Fabián Ezequiel Gallina)
To: 17658 <at> debbugs.gnu.org
Subject: bug#17658: Python mode has odd indentation behavior
Date: Mon, 30 Jun 2014 23:33:10 -0300
> ------------------------------ snip ------------------------------
> from django.conf.urls import patterns, include, url

> from django.contrib import admin

> from myapp import views

> urlpatterns = patterns('',
>     url(r'^$', views.index),
> )
> ------------------------------ snip ------------------------------

While this is a pretty recurrent style in Django's documentation, this
indentation style goes against PEP8.

http://legacy.python.org/dev/peps/pep-0008/#indentation

Here's a nice answer on SO with an example similar to yours:

http://stackoverflow.com/questions/15435811/what-is-pep8s-e128-continuation-line-under-indented-for-visual-indent/15435837#15435837

> When I try to change the "url..." line to
> ------------------------------ snip ------------------------------
>     url(r'^$', views.index, name="myapp_index"),
> ------------------------------ snip ------------------------------

> the moment I type the comma, the whole line bounces way over to the left.

Right, that was absolutely intended in the code. I'm now working in a
variant that would prevent triggering the indentation in that particular
case.

Notice, that even with this fix, python.el will still use the first
argument indentation as default value for further url definitions, so I
would suggest to embrace the PEP8 way intead -- unless you are really
contributing to Django and are forced to follow that convention.



Regards,
Fabián




This bug report was last modified 11 years and 49 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.