GNU bug report logs - #63959
python-mode does not keep indentation in square brackets []

Previous Next

Package: emacs;

Reported by: Konstantin Kharlamov <hi-angel <at> yandex.ru>

Date: Thu, 8 Jun 2023 09:40:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: kobarity <kobarity <at> gmail.com>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Konstantin Kharlamov <hi-angel <at> yandex.ru>, Stefan Monnier <monnier <at> iro.umontreal.ca>, 63959 <at> debbugs.gnu.org
Subject: bug#63959: python-mode does not keep indentation in square brackets []
Date: Sat, 01 Jul 2023 22:42:55 +0900
Andreas Röhler wrote:
> Thanks for your explanation, which makes me better understand your
> endeavour. A question remains: is this new feature worth that possibly
> raise of complexity? Your patch provides a higher degree of freedom
> while keeping regularity  - which is a pro.

I think it is natural for many people to indent the same as the
previous line.  In fact, it is standard behavior outside the parens.
For example, if you intentionally change the indentation of the first
line of a block, the following lines will have the same indentation:

def func():
        a = 1  # Intentionally changed.
        b = 2  # Same indent as previous line

You can even do the following, although it will result in an
IndentationError when executed:

def func():
    a = 1
        b = 2  # Intentionally changed.
        c = 3  # Same indent as previous line

If inside the parens, the following will not result in an
IndentationError:

a = (
    1,
        2,  # Intentionally changed.
        3)  # Same indent as previous line

So I rather think the rule of indenting the same as the previous line
is more useful inside parens.

I would consider making the indentation the same as the previous line
inside the parens a fix rather than a new feature.  This is why I
named the commit "Fix Python indentation of continuation lines within
parens."




This bug report was last modified 2 years and 11 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.