GNU bug report logs - #37726
[PATCH] Indent python multiline strings to start and previous levels

Previous Next

Package: emacs;

Reported by: Carlos Pita <carlosjosepita <at> gmail.com>

Date: Sun, 13 Oct 2019 04:30:02 UTC

Severity: wishlist

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37726 in the body.
You can then email your comments to 37726 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Sun, 13 Oct 2019 04:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Carlos Pita <carlosjosepita <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 13 Oct 2019 04:30:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Indent python multiline strings to start and previous levels
Date: Sun, 13 Oct 2019 01:29:26 -0300
[Message part 1 (text/plain, inline)]
This adds an additional indentation level that matches indentation of
previous line in a multiline string. Then Tab iterates between 0, the
start indentation level and the previous line level. This is useful
when writing docstrings in numpy/google formats that use indentation
to convey meaning.

For example:

0    4    8
     This is the first item
           This is a sub item
>   >    >

Then pressing Tab while in the third line will iterate between 0, 4
and 8, starting in 8, then 4, then 0. Compare with the current
implementation which will jump just between 0 and 4, which is not
convenient when the subitem is more than one line. A cursory
google/reddit search will show that this is a problem for some people.

Best regards
--
Carlos
[0001-Indent-python-multiline-strings-to-start-and-previou.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Sun, 13 Oct 2019 05:05:02 GMT) Full text and rfc822 format available.

Message #8 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 37726 <at> debbugs.gnu.org
Date: Sun, 13 Oct 2019 02:04:21 -0300
[Message part 1 (text/plain, inline)]
I've amended the previous patch so that it more conveniently align
string continuations to opening quotes, for example:

x = """aaaa
          bbbb
>   >     >

If you prefer I could also add an extra level:

x = """aaaa
          bbbb
>   >  >  >

in order to support other styles of indentation.
[0001-Indent-python-multiline-strings-to-start-and-previou.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Sun, 13 Oct 2019 18:36:01 GMT) Full text and rfc822 format available.

Message #11 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 37726 <at> debbugs.gnu.org
Subject: Re:
Date: Sun, 13 Oct 2019 15:35:32 -0300
[Message part 1 (text/plain, inline)]
Here is a version of the patch rebased on top of emacs-26 (the other
was for master / 27).
[0001-Indent-python-multiline-strings-to-start-and-previou.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Sun, 13 Oct 2019 19:08:03 GMT) Full text and rfc822 format available.

Message #14 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 37726 <at> debbugs.gnu.org
Cc: Noam Postavsky <npostavs <at> gmail.com>
Subject: Re:
Date: Sun, 13 Oct 2019 16:06:54 -0300
Noam, I'm CC'ing you because I see you have been committing some stuff
related to docstrings in python.el recently.

Btw, I'm glad to see some renewed activity in python.el which had been
quite forgotten for many months. A time ago I proposed myself to
maintain that module and I would still be glad to do it if you want.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Sat, 19 Oct 2019 08:33:02 GMT) Full text and rfc822 format available.

Message #17 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 37726 <at> debbugs.gnu.org
Cc: Noam Postavsky <npostavs <at> gmail.com>
Subject: Re:
Date: Sat, 19 Oct 2019 05:32:03 -0300
[Message part 1 (text/plain, inline)]
This new patch:

* Removes accidentally introduced blank line.
* Improves commit message.
[0001-Indent-python-multiline-strings-to-start-and-previou.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Wed, 23 Oct 2019 00:26:02 GMT) Full text and rfc822 format available.

Message #20 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: 37726 <at> debbugs.gnu.org
Subject: Re: bug#37726: [PATCH] Indent python multiline strings to start and
 previous levels
Date: Tue, 22 Oct 2019 20:25:29 -0400
severity 137726 wishlist
quit

To be honest, I don't write enough python to say whether this makes
sense or not, but it looks fairly reasonable.

Carlos Pita <carlosjosepita <at> gmail.com> writes:

> * progmodes/python.el (python-indent--calculate-indentation): Add an
> additional indentation point to match indentation of previous line in
> a multiline string. Then Tab iterates between 0, the start indentation
                     ^
                     Sentences should be double-spaced.

> level and the previous line level.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Wed, 23 Oct 2019 00:35:01 GMT) Full text and rfc822 format available.

Message #23 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: 37726 <at> debbugs.gnu.org
Subject: Re: bug#37726: [PATCH] Indent python multiline strings to start and
 previous levels
Date: Tue, 22 Oct 2019 20:34:49 -0400
Carlos Pita <carlosjosepita <at> gmail.com> writes:
>
> Btw, I'm glad to see some renewed activity in python.el which had been
> quite forgotten for many months. A time ago I proposed myself to
> maintain that module and I would still be glad to do it if you want.

Yeah, I think it would be good to have someone in charge of it.  If you
have a Savannah account, you can ask for write access by making a
"Request for Inclusion" to the "emacs" group at
<https://savannah.gnu.org/my/groups.php>




Severity set to 'wishlist' from 'normal' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 23 Oct 2019 00:36:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Sun, 09 Aug 2020 18:47:02 GMT) Full text and rfc822 format available.

Message #28 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: Noam Postavsky <npostavs <at> gmail.com>, 37726 <at> debbugs.gnu.org
Subject: Re: bug#37726:
Date: Sun, 09 Aug 2020 20:46:07 +0200
Carlos Pita <carlosjosepita <at> gmail.com> writes:

> * progmodes/python.el (python-indent--calculate-indentation): Add an
> additional indentation point to match indentation of previous line in
> a multiline string. Then Tab iterates between 0, the start indentation
> level and the previous line level.

This sounds reasonable to me, so I've applied it to Emacs 28.  I'm no
Python expert, though, so if there are any objections, feel free to
revert.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 09 Aug 2020 18:47:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 37726 <at> debbugs.gnu.org and Carlos Pita <carlosjosepita <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 09 Aug 2020 18:47:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Sun, 09 Aug 2020 21:45:02 GMT) Full text and rfc822 format available.

Message #35 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Carlos Pita <carlosjosepita <at> gmail.com>, Noam Postavsky <npostavs <at> gmail.com>,
 37726 <at> debbugs.gnu.org
Subject: Re: bug#37726:
Date: Sun, 09 Aug 2020 17:44:21 -0400
This causes test failures; ref eg

https://hydra.nixos.org/build/125002682




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Sun, 09 Aug 2020 21:51:02 GMT) Full text and rfc822 format available.

Message #38 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: Carlos Pita <carlosjosepita <at> gmail.com>, Noam Postavsky <npostavs <at> gmail.com>,
 37726 <at> debbugs.gnu.org
Subject: Re: bug#37726:
Date: Sun, 09 Aug 2020 23:50:31 +0200
Glenn Morris <rgm <at> gnu.org> writes:

> This causes test failures; ref eg
>
> https://hydra.nixos.org/build/125002682

I see the same thing here -- I'll revert the patch.  

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug No longer marked as fixed in versions 28.1 and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 09 Aug 2020 21:53:01 GMT) Full text and rfc822 format available.

Removed tag(s) fixed and patch. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 09 Aug 2020 21:53:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Sun, 09 Aug 2020 21:55:01 GMT) Full text and rfc822 format available.

Message #45 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: Noam Postavsky <npostavs <at> gmail.com>, 37726 <at> debbugs.gnu.org
Subject: Re: bug#37726:
Date: Sun, 09 Aug 2020 23:54:26 +0200
Carlos Pita <carlosjosepita <at> gmail.com> writes:

> This new patch:
>
> * Removes accidentally introduced blank line.
> * Improves commit message.
>

If you have a string like:

multiline = '''
bunch
of
lines
'''

After the patch, and if you hit TAB at the start of the lines, you'll
end up with:

multiline = '''
            bunch
            of
            lines
            '''

But that's a different string, isn't it?  The leading spaces are part of
the string itself, which isn't what we want.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37726; Package emacs. (Tue, 13 Oct 2020 03:57:02 GMT) Full text and rfc822 format available.

Message #48 received at 37726 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: Noam Postavsky <npostavs <at> gmail.com>, 37726 <at> debbugs.gnu.org
Subject: Re: bug#37726:
Date: Tue, 13 Oct 2020 05:56:13 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> But that's a different string, isn't it?  The leading spaces are part of
> the string itself, which isn't what we want.

So this wishlist patch doesn't seem applicable, and I'm closing this bug
report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 37726 <at> debbugs.gnu.org and Carlos Pita <carlosjosepita <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 13 Oct 2020 03:57:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 10 Nov 2020 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 161 days ago.

Previous Next


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