From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas =?UTF-8?Q?R=C3=B6hler?= Newsgroups: gmane.emacs.bugs Subject: bug#17658: Python mode has odd indentation behavior Date: Mon, 02 Jun 2014 18:05:49 +0200 Message-ID: <538CA0DD.1080901@easy-emacs.de> References: <538B4772.2010109@easy-emacs.de> <538C1754.40903@easy-emacs.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1401725250 17124 80.91.229.3 (2 Jun 2014 16:07:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Jun 2014 16:07:30 +0000 (UTC) Cc: "=?UTF-8?Q?Fabi=C3=A1n?= E. Gallina" , 17658@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 02 18:07:24 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WrUlf-0000XU-GK for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Jun 2014 18:07:23 +0200 Original-Received: from localhost ([::1]:47579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrUle-0000Iy-Vy for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Jun 2014 12:07:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrUlT-0000DP-8s for bug-gnu-emacs@gnu.org; Mon, 02 Jun 2014 12:07:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrUlK-000131-Ru for bug-gnu-emacs@gnu.org; Mon, 02 Jun 2014 12:07:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrUlK-00012r-OS for bug-gnu-emacs@gnu.org; Mon, 02 Jun 2014 12:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WrUlJ-0005BU-Sx for bug-gnu-emacs@gnu.org; Mon, 02 Jun 2014 12:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Jun 2014 16:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17658 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17658-submit@debbugs.gnu.org id=B17658.140172518219846 (code B ref 17658); Mon, 02 Jun 2014 16:07:01 +0000 Original-Received: (at 17658) by debbugs.gnu.org; 2 Jun 2014 16:06:22 +0000 Original-Received: from localhost ([127.0.0.1]:41070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WrUkb-00059t-M1 for submit@debbugs.gnu.org; Mon, 02 Jun 2014 12:06:22 -0400 Original-Received: from mout.kundenserver.de ([212.227.126.187]:55155) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WrUkU-00059N-RO for 17658@debbugs.gnu.org; Mon, 02 Jun 2014 12:06:15 -0400 Original-Received: from [192.168.178.32] (brln-4d0cb981.pool.mediaWays.net [77.12.185.129]) by mrelayeu.kundenserver.de (node=mreue001) with ESMTP (Nemesis) id 0Ls3iR-1Wg8Hu3IJb-013ugj; Mon, 02 Jun 2014 18:06:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Icedove/24.5.0 In-Reply-To: X-Provags-ID: V02:K0:+a8NMcBfFZB+jsmwIp7C9RAePK+JZcOCflJHI+bwgz1 Xvi/gtB3mG/tX0KEX3g2tSw3BL4A9x7X01W6m8bUZH8WojKKY6 vMpGQPML4q8zKTGUnXV87d+3YIwtgNyW1YxBzL9x1lka1p68Gl ulirQJptAWTKeg5LyYsvWBpq8yXpgo/O/bl8Rlwr1841QJE3J1 7LaLlm0xDm2t34CPUkuW9lwTE+rd8kCXb2Vck6JMJsWr+eDFGm Uyo2sYdA73x0ZGiV2jOP3ItRkp56WyRyqnMSzmXMA6EUM7snO3 /NGBsSrU+vOR2rqXvHQC6/wAq/UZI17UcY0UHlrdb2kaMSyU9O 8Aj9hfIuvgSnobE4I0o9t4ASPoU1QFOEFg4QMxLcm X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:89891 Archived-At: On 02.06.2014 15:36, Stefan Monnier wrote: >>> Makes no difference, >> Did you try it? > > I tried it in Emacs-24.3 which doesn't enable electric-indent-mode by > default, but suffers from the same problem. Admittedly, In 24.4, > I half-fixed the problem by linking this python-mode feature to > electric-indent-mode, so that it can be turned off. > >> The chars, which trigger an indent, may differ. In this case a comma >> triggers it. > > Any char triggers it. As I said: > > The important detail is not to hit "," but to insert a char right > before the inner close paren. > > The comma is not in electric-indent-chars. > > Here's the offending code in python-indent-post-self-insert-function: > > ((and (not (bolp)) > (memq (char-after) '(?\) ?\] ?\}))) > (save-excursion > (goto-char (line-beginning-position)) > ;; If after going to the beginning of line the point > ;; is still inside a paren it's ok to do the trick > (when (python-syntax-context 'paren) > (let ((indentation (python-indent-calculate-indentation))) > (when (< (current-indentation) indentation) > (indent-line-to indentation)))))) > > This means that current line is reindented whenever you insert a char > right before a close-paren and line-beginning-position is inside some > parentheses. Since reindenting a line is problematic in Python, it > should only be done when we really know for sure that the current indent > is wrong. So clearly the above condition triggers too often. > But I don't understand the intention of the code, i.e. I don't > understand when the above is meant to trigger reindentation, so I don't > know how to fix it. Presumably Fabián should be able to shed some > light here. > > > > Stefan > Agree, thanks a lot for the details! Andreas