* bug#20742: 24.5; python mode indentation fails pep8
2015-06-05 7:58 bug#20742: 24.5; python mode indentation fails pep8 Tommi Komulainen
@ 2015-06-05 20:16 ` Glenn Morris
2015-06-05 20:25 ` Tommi Komulainen
2015-06-08 16:28 ` Andreas Röhler
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2015-06-05 20:16 UTC (permalink / raw)
To: Tommi Komulainen; +Cc: 20742
Tommi Komulainen wrote:
> python-indent--calculate-indentation: Wrong type argument:
> number-or-marker-p, nil [2 times]
Perhaps the behaviour is not intended.
(Related to bug#20560?)
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#20742: 24.5; python mode indentation fails pep8
2015-06-05 7:58 bug#20742: 24.5; python mode indentation fails pep8 Tommi Komulainen
2015-06-05 20:16 ` Glenn Morris
@ 2015-06-08 16:28 ` Andreas Röhler
2015-06-19 17:04 ` bug#20742: Testcase for #20742 Tommi Komulainen
2015-06-20 10:56 ` bug#20742: 24.5; [PATCH] python.el: fix close paren indentation to match pep8 Tommi Komulainen
3 siblings, 0 replies; 12+ messages in thread
From: Andreas Röhler @ 2015-06-08 16:28 UTC (permalink / raw)
To: 20742
Am 05.06.2015 um 09:58 schrieb Tommi Komulainen:
May confirm that bug
GNU Emacs 25.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.23) of 2015-06-07
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#20742: Testcase for #20742
2015-06-05 7:58 bug#20742: 24.5; python mode indentation fails pep8 Tommi Komulainen
2015-06-05 20:16 ` Glenn Morris
2015-06-08 16:28 ` Andreas Röhler
@ 2015-06-19 17:04 ` Tommi Komulainen
2015-06-20 10:56 ` bug#20742: 24.5; [PATCH] python.el: fix close paren indentation to match pep8 Tommi Komulainen
3 siblings, 0 replies; 12+ messages in thread
From: Tommi Komulainen @ 2015-06-19 17:04 UTC (permalink / raw)
To: 20742@debbugs.gnu.org
[-- Attachment #1.1: Type: text/plain, Size: 100 bytes --]
Patch against emacs-24.5 branch to update the tests to check the closing
paren indentation as well.
[-- Attachment #1.2: Type: text/html, Size: 121 bytes --]
[-- Attachment #2: 0001-update-python-tests.el-for-pep8-indentation.patch --]
[-- Type: application/octet-stream, Size: 2717 bytes --]
From 37f56dd48ba6c21455681085579a872aeb267036 Mon Sep 17 00:00:00 2001
From: Tommi Komulainen <tommi.komulainen@iki.fi>
Date: Fri, 19 Jun 2015 18:53:52 +0200
Subject: [PATCH] update python-tests.el for pep8 indentation
Add (failing) test for closing paren indentation when opening paren is not
followed by newline. #20742
---
test/automated/python-tests.el | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index 42c26fc..b2631c4 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -172,15 +172,19 @@ aliqua."
(python-tests-with-temp-buffer
"# Aligned with opening delimiter
foo = long_function_name(var_one, var_two,
- var_three, var_four)
+ var_three, var_four,
+ )
"
(should (eq (car (python-indent-context)) :no-indent))
(should (= (python-indent-calculate-indentation) 0))
(python-tests-look-at "foo = long_function_name(var_one, var_two,")
(should (eq (car (python-indent-context)) :after-comment))
(should (= (python-indent-calculate-indentation) 0))
- (python-tests-look-at "var_three, var_four)")
+ (python-tests-look-at "var_three, var_four")
(should (eq (car (python-indent-context)) :inside-paren))
+ (should (= (python-indent-calculate-indentation) 25))
+ (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-pep8-2 ()
@@ -216,7 +220,8 @@ def long_function_name(
"# Extra indentation is not necessary.
foo = long_function_name(
var_one, var_two,
- var_three, var_four)
+ var_three, var_four,
+)
"
(should (eq (car (python-indent-context)) :no-indent))
(should (= (python-indent-calculate-indentation) 0))
@@ -226,9 +231,12 @@ foo = long_function_name(
(python-tests-look-at "var_one, var_two,")
(should (eq (car (python-indent-context)) :inside-paren-newline-start))
(should (= (python-indent-calculate-indentation) 4))
- (python-tests-look-at "var_three, var_four)")
+ (python-tests-look-at "var_three, var_four")
(should (eq (car (python-indent-context)) :inside-paren-newline-start))
- (should (= (python-indent-calculate-indentation) 4))))
+ (should (= (python-indent-calculate-indentation) 4))
+ (python-tests-look-at ")")
+ (should (eq (car (python-indent-context)) :inside-paren-at-closing-paren))
+ (should (= (python-indent-calculate-indentation) 0))))
(ert-deftest python-indent-base-case ()
"Check base case does not trigger errors."
--
2.4.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#20742: 24.5; [PATCH] python.el: fix close paren indentation to match pep8
2015-06-05 7:58 bug#20742: 24.5; python mode indentation fails pep8 Tommi Komulainen
` (2 preceding siblings ...)
2015-06-19 17:04 ` bug#20742: Testcase for #20742 Tommi Komulainen
@ 2015-06-20 10:56 ` Tommi Komulainen
2017-03-02 2:47 ` npostavs
3 siblings, 1 reply; 12+ messages in thread
From: Tommi Komulainen @ 2015-06-20 10:56 UTC (permalink / raw)
To: 20742
From da684af7265bf40e4140328c36011fea6b040373 Mon Sep 17 00:00:00 2001
From: Tommi Komulainen <tommi.komulainen@iki.fi>
Date: Fri, 19 Jun 2015 18:53:52 +0200
Subject: [PATCH] python.el: fix close paren indentation to match pep8
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
---
lisp/progmodes/python.el | 12 +++++++++---
test/automated/python-tests.el | 42 +++++++++++++++++++++++++++++++++---------
2 files changed, 42 insertions(+), 12 deletions(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index de2d2d1..013a565 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -952,12 +952,18 @@ possibilities can be narrowed to specific
indentation points."
(`(,(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)))
(`(,(or :after-block-start
:after-backslash-first-line
:inside-paren-newline-start) . ,start)
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index 42c26fc..f35f188 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -171,16 +171,28 @@ aliqua."
"First pep8 case."
(python-tests-with-temp-buffer
"# Aligned with opening delimiter
-foo = long_function_name(var_one, var_two,
- var_three, var_four)
+foo = long_function_name(var_one=[var_two, # comment
+ var_three
+ ],
+ var_four=0,
+ )
"
(should (eq (car (python-indent-context)) :no-indent))
(should (= (python-indent-calculate-indentation) 0))
- (python-tests-look-at "foo = long_function_name(var_one, var_two,")
+ (python-tests-look-at "foo = long_function_name(var_one")
(should (eq (car (python-indent-context)) :after-comment))
(should (= (python-indent-calculate-indentation) 0))
- (python-tests-look-at "var_three, var_four)")
+ (python-tests-look-at "var_three")
(should (eq (car (python-indent-context)) :inside-paren))
+ (should (= (python-indent-calculate-indentation) 34))
+ (python-tests-look-at "]")
+ (should (eq (car (python-indent-context))
:inside-paren-at-closing-nested-paren))
+ (should (= (python-indent-calculate-indentation) 34))
+ (python-tests-look-at "var_four")
+ (should (eq (car (python-indent-context)) :inside-paren))
+ (should (= (python-indent-calculate-indentation) 25))
+ (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-pep8-2 ()
@@ -215,20 +227,32 @@ def long_function_name(
(python-tests-with-temp-buffer
"# Extra indentation is not necessary.
foo = long_function_name(
- var_one, var_two,
- var_three, var_four)
+ var_one, var_two=[ # comment
+ var_three,
+ ],
+ var_four=0,
+)
"
(should (eq (car (python-indent-context)) :no-indent))
(should (= (python-indent-calculate-indentation) 0))
(python-tests-look-at "foo = long_function_name(")
(should (eq (car (python-indent-context)) :after-comment))
(should (= (python-indent-calculate-indentation) 0))
- (python-tests-look-at "var_one, var_two,")
+ (python-tests-look-at "var_one")
(should (eq (car (python-indent-context)) :inside-paren-newline-start))
(should (= (python-indent-calculate-indentation) 4))
- (python-tests-look-at "var_three, var_four)")
+ (python-tests-look-at "var_three")
(should (eq (car (python-indent-context)) :inside-paren-newline-start))
- (should (= (python-indent-calculate-indentation) 4))))
+ (should (= (python-indent-calculate-indentation) 8))
+ (python-tests-look-at "]")
+ (should (eq (car (python-indent-context))
:inside-paren-at-closing-nested-paren))
+ (should (= (python-indent-calculate-indentation) 4))
+ (python-tests-look-at "var_four")
+ (should (eq (car (python-indent-context)) :inside-paren-newline-start))
+ (should (= (python-indent-calculate-indentation) 4))
+ (python-tests-look-at ")")
+ (should (eq (car (python-indent-context)) :inside-paren-at-closing-paren))
+ (should (= (python-indent-calculate-indentation) 0))))
(ert-deftest python-indent-base-case ()
"Check base case does not trigger errors."
--
2.4.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#20742: 24.5; [PATCH] python.el: fix close paren indentation to match pep8
2015-06-20 10:56 ` bug#20742: 24.5; [PATCH] python.el: fix close paren indentation to match pep8 Tommi Komulainen
@ 2017-03-02 2:47 ` npostavs
2019-04-20 20:51 ` Noam Postavsky
0 siblings, 1 reply; 12+ messages in thread
From: npostavs @ 2017-03-02 2:47 UTC (permalink / raw)
To: Tommi Komulainen; +Cc: 20742
Tommi Komulainen <tommi.komulainen@iki.fi> writes:
>>From da684af7265bf40e4140328c36011fea6b040373 Mon Sep 17 00:00:00 2001
> From: Tommi Komulainen <tommi.komulainen@iki.fi>
> Date: Fri, 19 Jun 2015 18:53:52 +0200
> Subject: [PATCH] python.el: fix close paren indentation to match pep8
>
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#20742: 24.5; [PATCH] python.el: fix close paren indentation to match pep8
2017-03-02 2:47 ` npostavs
@ 2019-04-20 20:51 ` Noam Postavsky
2019-04-28 20:47 ` Noam Postavsky
2020-09-17 18:59 ` bug#20560: " Lars Ingebrigtsen
0 siblings, 2 replies; 12+ messages in thread
From: Noam Postavsky @ 2019-04-20 20:51 UTC (permalink / raw)
To: 20742; +Cc: Tommi Komulainen
[-- Attachment #1: Type: text/plain, Size: 805 bytes --]
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.
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1760 bytes --]
From e0acfb7254f97f623286e65483535c1b6312f4ba Mon Sep 17 00:00:00 2001
From: Tommi Komulainen <tommi.komulainen@iki.fi>
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
[-- Attachment #3: patch --]
[-- Type: text/plain, Size: 1436 bytes --]
From 8649d874d5158d91b0b6056bc66b9a99f4c1c31a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
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
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#20742: 24.5; [PATCH] python.el: fix close paren indentation to match pep8
2019-04-20 20:51 ` Noam Postavsky
@ 2019-04-28 20:47 ` Noam Postavsky
2020-09-17 18:59 ` bug#20560: " Lars Ingebrigtsen
1 sibling, 0 replies; 12+ messages in thread
From: Noam Postavsky @ 2019-04-28 20:47 UTC (permalink / raw)
To: 20742; +Cc: Tommi Komulainen
tags 20742 fixed
close 20742 27.1
quit
> I'll push to master in a week or so if there are no further comments.
Done.
3fc1d77a43 2019-04-28T16:45:13-04:00 "python.el: Fix close paren indentation to match pep8 (Bug#20742)"
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3fc1d77a43818666542740fc34167c1faee30d5f
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#20560: bug#20742: 24.5; [PATCH] python.el: fix close paren indentation to match pep8
2019-04-20 20:51 ` Noam Postavsky
2019-04-28 20:47 ` Noam Postavsky
@ 2020-09-17 18:59 ` Lars Ingebrigtsen
2020-09-17 19:22 ` Noam Postavsky
1 sibling, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-17 18:59 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 20742, 20560, Tommi Komulainen
Noam Postavsky <npostavs@gmail.com> writes:
> 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.
Looks like this was done, so I'm closing this bug report.
commit 3fc1d77a43818666542740fc34167c1faee30d5f
Author: Tommi Komulainen <tommi.komulainen@iki.fi>
AuthorDate: Fri Jun 19 18:53:52 2015 +0200
Commit: Noam Postavsky <npostavs@gmail.com>
CommitDate: Sun Apr 28 16:45:13 2019 -0400
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.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#20560: bug#20742: 24.5; [PATCH] python.el: fix close paren indentation to match pep8
2020-09-17 18:59 ` bug#20560: " Lars Ingebrigtsen
@ 2020-09-17 19:22 ` Noam Postavsky
2020-09-18 11:11 ` Lars Ingebrigtsen
0 siblings, 1 reply; 12+ messages in thread
From: Noam Postavsky @ 2020-09-17 19:22 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 20560
On Thu, 17 Sep 2020 at 14:59, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> Looks like this was done, so I'm closing this bug report.
> 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.
^^^^^^
You're mixing up bugs, I think. As far as I know, 20560/33979 isn't
fixed. I had closed 20742/19906 already when pushing that commit.
^ permalink raw reply [flat|nested] 12+ messages in thread