From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#20742: 24.5; [PATCH] python.el: fix close paren indentation to match pep8 Date: Sat, 20 Apr 2019 16:51:23 -0400 Message-ID: <87sguctn78.fsf@gmail.com> References: <87wpc8bdjk.fsf@users.sourceforge.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="268232"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: Tommi Komulainen To: 20742@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 20 22:52:11 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hHwy2-0017e1-V8 for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Apr 2019 22:52:11 +0200 Original-Received: from localhost ([127.0.0.1]:45272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHwy1-000079-NH for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Apr 2019 16:52:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHwxv-00006m-R1 for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2019 16:52:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHwxu-0000mg-MS for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2019 16:52:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33314) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hHwxu-0000ma-FL for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2019 16:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hHwxu-0006Vs-6Z for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2019 16:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Apr 2019 20:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20742 X-GNU-PR-Package: emacs Original-Received: via spool by 20742-submit@debbugs.gnu.org id=B20742.155579349424998 (code B ref 20742); Sat, 20 Apr 2019 20:52:02 +0000 Original-Received: (at 20742) by debbugs.gnu.org; 20 Apr 2019 20:51:34 +0000 Original-Received: from localhost ([127.0.0.1]:46858 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hHwxR-0006V2-89 for submit@debbugs.gnu.org; Sat, 20 Apr 2019 16:51:33 -0400 Original-Received: from mail-qk1-f173.google.com ([209.85.222.173]:44653) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hHwxP-0006Uj-O9; Sat, 20 Apr 2019 16:51:32 -0400 Original-Received: by mail-qk1-f173.google.com with SMTP id y5so4561015qkc.11; Sat, 20 Apr 2019 13:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=OWPGKqseuGKI2TrEqkcsmcFLeJiwtP9CCN3CE6/efX0=; b=iRwUlt6BtpAdxbye7fJGRo/QqniHscPQS7oEt4V7InB3Bhd9jE/4xxq5R8chWgY+Z4 YlsofRVl2xFP9SMXV7x28Eq/geDHHO07MY4G5MjowTpJX47adZm4lAghXeVmojg7etNM LB92JXW1Z32fWfEAldzM5lkFV6TaABTouWoRU2+TRcn4Izqhr9niKN1uxIwpPIihyFPa 7S0MoIyXt6hk6VFPCPCc7pB6fb23Jdl3H3O5hne89ql0vW5buNAo8Kiblhp1gY4zHiBI vpGUwiOoBA/wmNCu48z1tY6Ny1zxt2aArq1CjvcQ7Yfi7+S3pSobqu/FFk1KP+npLgmG 7COA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=OWPGKqseuGKI2TrEqkcsmcFLeJiwtP9CCN3CE6/efX0=; b=Zj+4/rXfoYxvnMzzJKB+QiLu6pdTpJIdxnXUKwYBEp9ko2rk0HADWRzATT+hg3ZLzf wVOgw/ASviIs/Jj6eNrVuIY3Q6po1UQJMACzAA2gACIlVsWYiSKkq8ydiJ+SrTmkx793 9hkeIIswns4fR0a/9LiodOQOnJLYJ9cK6V5KbhGccNaTvB8JjTXaJ2+DJyMblc5x4oEN xiIIwYaABfHrNOfNn7uVftfOfPcqI0QsxvVvzzNQByHbCtsBRfgp9mBIrWL9L+C4fQF+ ngzdlkHNTZwxi8JQdcuc+rB41v3WHzhFCAA4x/8St6BbSkpgSjMOb7uDVneKwM8aZ3Qn zP6g== X-Gm-Message-State: APjAAAW20znpyX2e2XAY5RSBoUvFCd+IcAVge7LHu7cOWTyoRK/pKhV7 wEVpiZLwDNUt1DiQS6fLZMBqM2xF X-Google-Smtp-Source: APXvYqw/lNisXOMu82hbCvoNeasYz82/L//ZoVQGqM03ZycIvQjEXG1PaALfuQabtuPZM9gYmqwdeQ== X-Received: by 2002:a37:614e:: with SMTP id v75mr8890422qkb.27.1555793486143; Sat, 20 Apr 2019 13:51:26 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id e4sm4131236qkg.6.2019.04.20.13.51.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Apr 2019 13:51:24 -0700 (PDT) In-Reply-To: <87wpc8bdjk.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Wed, 01 Mar 2017 21:47:11 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.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" Xref: news.gmane.org gmane.emacs.bugs:157915 Archived-At: --=-=-= Content-Type: text/plain tags 20742 + patch quit >> When opening paren is followed by newline the closing paren should follow >> the current indentation. Otherwise the closing paren should be aligned >> with the opening paren. This fixes the latter case. #20742 > > I'm having trouble applying this. > > error: corrupt patch at line 11 > Applying: python.el: fix close paren indentation to match pep8 > Patch failed at 0001 python.el: fix close paren indentation to match pep8 I managed to get this applied; I've replaced the python-test.el modifications, partly because they're written as updates to the existing tests which makes them a bit harder to follow, and partly to make more clear that the patch is below the 15 line copyright limit. I'll push to master in a week or so if there are no further comments. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-python.el-Fix-close-paren-indentation-to-match-pep8-.patch Content-Description: patch >From e0acfb7254f97f623286e65483535c1b6312f4ba Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Fri, 19 Jun 2015 18:53:52 +0200 Subject: [PATCH 1/2] python.el: Fix close paren indentation to match pep8 (Bug#20742) * lisp/progmodes/python.el (python-indent--calculate-indentation): When opening paren is followed by newline the closing paren should follow the current indentation. Otherwise the closing paren should be aligned with the opening paren. This fixes the latter case. Copyright-paperwork-exempt: yes --- lisp/progmodes/python.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index eb3e31c4b7..188bc973d9 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1070,12 +1070,18 @@ (defun python-indent--calculate-indentation () (`(,(or :after-line :after-comment :inside-string - :after-backslash - :inside-paren-at-closing-paren - :inside-paren-at-closing-nested-paren) . ,start) + :after-backslash) . ,start) ;; Copy previous indentation. (goto-char start) (current-indentation)) + (`(,(or :inside-paren-at-closing-paren + :inside-paren-at-closing-nested-paren) . ,start) + (goto-char (+ 1 start)) + (if (looking-at "[ \t]*\\(?:#\\|$\\)") + ;; Copy previous indentation. + (current-indentation) + ;; Align with opening paren. + (current-column))) (`(:inside-docstring . ,start) (let* ((line-indentation (current-indentation)) (base-indent (progn -- 2.11.0 --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0002-Add-test-for-previous-change.patch Content-Description: patch >From 8649d874d5158d91b0b6056bc66b9a99f4c1c31a Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 20 Apr 2019 15:31:51 -0400 Subject: [PATCH 2/2] ; Add test for previous change * test/lisp/progmodes/python-tests.el (python-indent-hanging-close-paren): New test. --- test/lisp/progmodes/python-tests.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index b940f45bb9..a517909717 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -260,6 +260,19 @@ (ert-deftest python-indent-pep8-3 () (should (eq (car (python-indent-context)) :inside-paren-newline-start)) (should (= (python-indent-calculate-indentation) 4)))) +(ert-deftest python-indent-hanging-close-paren () + "Like first pep8 case, but with hanging close paren." ;; See Bug#20742. + (python-tests-with-temp-buffer + "\ +foo = long_function_name(var_one, var_two, + var_three, var_four + ) +" + (should (= (python-indent-calculate-indentation) 0)) + (python-tests-look-at ")") + (should (eq (car (python-indent-context)) :inside-paren-at-closing-paren)) + (should (= (python-indent-calculate-indentation) 25)))) + (ert-deftest python-indent-base-case () "Check base case does not trigger errors." (python-tests-with-temp-buffer -- 2.11.0 --=-=-=--