[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17658: Python mode has odd indentation behavior
From: |
Stefan Monnier |
Subject: |
bug#17658: Python mode has odd indentation behavior |
Date: |
Sat, 31 May 2014 22:47:59 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (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 ------------------------------
> 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.
Indeed, I can reproduce this in Emacs-24.3.91. The important detail is
not to hit "," but to insert a char right before the inner close paren.
The problem seems to be in python-indent-post-self-insert-function,
where the "still in parenthesis" check doesn't realize that it's within
a different pair of parens.
> Is this a bug?
Looks like it, yes. Fabián, can you take care of it?
> Is there a way to turn this off?
A temporary workaround could be
(add-hook 'python-mode-hook
(lambda ()
(remove-hook 'post-self-insert-hook
#'python-indent-post-self-insert-function 'local)))
-- Stefan