From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#17658: Python mode has odd indentation behavior Date: Mon, 02 Jun 2014 09:36:56 -0400 Message-ID: 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 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1401722274 11570 80.91.229.3 (2 Jun 2014 15:17:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 2 Jun 2014 15:17:54 +0000 (UTC) Cc: "=?UTF-8?Q?Fabi=C3=A1n?= E. Gallina" , 17658@debbugs.gnu.org To: Andreas =?UTF-8?Q?R=C3=B6hler?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 02 17:17:47 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 1WrTze-0007Nm-Fo for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Jun 2014 17:17:46 +0200 Original-Received: from localhost ([::1]:45170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrSTI-0003dk-IG for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Jun 2014 09:40:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrSRI-0001Fv-3L for bug-gnu-emacs@gnu.org; Mon, 02 Jun 2014 09:38:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrSR9-0003go-8w for bug-gnu-emacs@gnu.org; Mon, 02 Jun 2014 09:38:12 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41577) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrSR9-0003gh-6c for bug-gnu-emacs@gnu.org; Mon, 02 Jun 2014 09:38:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WrSR8-0000xx-GX for bug-gnu-emacs@gnu.org; Mon, 02 Jun 2014 09:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Jun 2014 13:38:02 +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.14017162363657 (code B ref 17658); Mon, 02 Jun 2014 13:38:02 +0000 Original-Received: (at 17658) by debbugs.gnu.org; 2 Jun 2014 13:37:16 +0000 Original-Received: from localhost ([127.0.0.1]:40454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WrSQJ-0000wo-IJ for submit@debbugs.gnu.org; Mon, 02 Jun 2014 09:37:16 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:62254) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WrSQB-0000w9-2x for 17658@debbugs.gnu.org; Mon, 02 Jun 2014 09:37:08 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCws0EhQYDSSIBAjSGReOegeEOASpGYFqg0wh X-IPAS-Result: ArUGAIDvNVPO+IOj/2dsb2JhbABZgwaDSsA9gRcXdIIlAQEBAQIBViMFCws0EhQYDSSIBAjSGReOegeEOASpGYFqg0wh X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="65341291" Original-Received: from 206-248-131-163.dsl.teksavvy.com (HELO pastel.home) ([206.248.131.163]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 02 Jun 2014 09:36:57 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id E0138600E1; Mon, 2 Jun 2014 09:36:56 -0400 (EDT) In-Reply-To: <538C1754.40903@easy-emacs.de> ("Andreas =?UTF-8?Q?R=C3=B6hler?="'s message of "Mon, 02 Jun 2014 08:19:00 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) 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:89884 Archived-At: >> 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=E1n should be able to shed some light here. Stefan