bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17658: Python mode has odd indentation behavior


From: Fabián Ezequiel Gallina
Subject: bug#17658: Python mode has odd indentation behavior
Date: Mon, 30 Jun 2014 23:33:10 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

> ------------------------------ 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]