GNU bug report logs - #32876
26.1; python-mode mixes existing tabs with new spaces

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: starback@HIDDEN (Per Starbäck); Keywords: confirmed; dated Sat, 29 Sep 2018 16:14:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) confirmed. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 29 Sep 2018 20:06:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 29 16:06:47 2018
Received: from localhost ([127.0.0.1]:59194 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1g6LVm-0008Jd-Ot
	for submit <at> debbugs.gnu.org; Sat, 29 Sep 2018 16:06:46 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47688)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <andreas.roehler@HIDDEN>) id 1g6LVl-0008JQ-1E
 for submit <at> debbugs.gnu.org; Sat, 29 Sep 2018 16:06:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <andreas.roehler@HIDDEN>) id 1g6LVf-0007Hj-9B
 for submit <at> debbugs.gnu.org; Sat, 29 Sep 2018 16:06:39 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:57372)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <andreas.roehler@HIDDEN>)
 id 1g6LVf-0007Hb-5l
 for submit <at> debbugs.gnu.org; Sat, 29 Sep 2018 16:06:39 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57297)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <andreas.roehler@HIDDEN>) id 1g6LVe-0003q3-By
 for bug-gnu-emacs@HIDDEN; Sat, 29 Sep 2018 16:06:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <andreas.roehler@HIDDEN>) id 1g6LVb-0007Fx-7e
 for bug-gnu-emacs@HIDDEN; Sat, 29 Sep 2018 16:06:38 -0400
Received: from mout.kundenserver.de ([212.227.126.130]:36651)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <andreas.roehler@HIDDEN>)
 id 1g6LVa-0007Ey-Up
 for bug-gnu-emacs@HIDDEN; Sat, 29 Sep 2018 16:06:35 -0400
Received: from [192.168.178.35] ([188.103.26.138]) by mrelayeu.kundenserver.de
 (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id
 1MDyoW-1fwU9c3CT6-009vqi for <bug-gnu-emacs@HIDDEN>; Sat, 29 Sep 2018
 22:06:33 +0200
Received: from [192.168.178.35] ([188.103.26.138]) by mrelayeu.kundenserver.de
 (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id
 1MDyoW-1fwU9c3CT6-009vqi for <bug-gnu-emacs@HIDDEN>; Sat, 29 Sep 2018
 22:06:33 +0200
Subject: Re: bug#32876: 26.1; python-mode mixes existing tabs with new spaces
To: bug-gnu-emacs@HIDDEN
References: <sa5in2o7045.fsf@HIDDEN>
From: =?UTF-8?Q?Andreas_R=c3=b6hler?= <andreas.roehler@HIDDEN>
Message-ID: <e06662c4-96d0-62fc-382f-09576a0597eb@HIDDEN>
Date: Sat, 29 Sep 2018 22:11:12 +0200
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101
 Thunderbird/52.9.1
MIME-Version: 1.0
In-Reply-To: <sa5in2o7045.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Provags-ID: V03:K1:haKK0d/uZ+HybFvMi5S3QwU8Y2XJWNOp1zuE22s6NWYPMWIe0QC
 LcwjYxYR1e/15gWSeKn05kDeOSS8+bTgaUeWl4nCGEbdzpFtkcuiD0Id8euHopI5VXF4Wy9
 fpBS5BIwpxZMPg+nFLVevWdbuludV0uniSITT/Zlb8xKWFhvnEsmjCyA4mrywzXf1MjGKTH
 mbKt/1Aallq55mN1VWqNg==
X-UI-Out-Filterresults: notjunk:1;V01:K0:ezZpmKumUxk=:m+CAUWgRLkfoY9hJIzE1mc
 sbDbj6We32qaU9liQolfDYZWuIewOmA6b+t7pICH9Qu22vB3MTEKw6t12NnUGdSfKIkHZU5M2
 X0/SDBQalk5yPox7qm6AUrlWAHibRDHK6dG0puk0YWzpVmmxHc4X7YmwRO7+HmecAVCRdln0E
 JgoimTnI9VqE6CUD7y9ADGehNAghE+mYIuZIjZlxcHmIsl/psGbnAUhBMP/47e8L5itP7etCV
 eMb+3yGsOvTyhJj2vo0OY9tnFXYaEDMa9alRi/5YotMGYsXvPsxs70MntguRiUPz0RMGs2VgA
 AR1H23sIcs/AmUqadoizJm9VkpUo6Uxf4e/2+xlOvyMwErlLDOZP8bw/7A5UrfGxcAft+Dspj
 ROSDa6r1eN5J+NIhlJTcQc6WKT9I6wcStEzDtL35hn1omZtsiqQie2XiFm6QdIIepboXyd3rR
 AcEv5+X6Xb4A0QRXfohaXjvpXxvOkdjESL8dx/budD8nXlppG6nz6IwfqDLAHlNi9nkaOB4r7
 5mv9dpnre1B8jFWJSO3vb68mXIpeUiV9tLqNrqIGyh1LMDDX/MUs45NSRdxOiZph7Ts6cjGKi
 dL19Z5qfA1zPQUWH8ZjXu+cpu8hHadsuPDDHQRpXrk6DBnmBE++lG4ItwxHodl4RNS8NClQl3
 5P/knO0OEi0Na6Mr9/xxulwHI4cjiMvt8zJ1ZYSc6btf5TB+MGG3pJXr2JXyjQDlew+msSMOu
 UXvPYz8CdIIKkHif
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

On 29.09.2018 18:13, Per Starbäck wrote:
> In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.26)
> 
> ### Problem ###
> 
> I did "emacs -Q pytab.py" where pytab.py contains the two lines:
> 
> ------------------------------
> def foo():
> 	print('hello')
> ------------------------------
> 
> The second line begins with a TAB.
> 
> Then I add a line to this marvellous program with
> 
> 	M-> TAB print('world') C-x C-s
> 
> This new line will have eight spaces in the beginning, and because of
> that this is no longer a valid Python3 program!
> 
> ### Background ###
> 
> Earlier you could mix spaces and tabs (seen as 8 spaces) in Python, but
> Python3 disallows mixing them.
> 
> Spaces are preferred, and the style guide "PEP 8" says that
> 
>    Tabs should be used solely to remain consistent with code that is
>    already indented with tabs.
> 
> So python-mode ought to help you remain consistent with such old
> code. I think that checking with what characters the current block is
> indented all the time would be overdoing it for something that shouldn't
> occur that often, but that it should suffice to just scan through the
> visited file to see if it contains any tabs in that case instead turn on
> indent-tabs-mode instead of turning it off.
> 
> 
> 

May confirm that with

GNU Emacs 27.0.50 (build 1, i686-pc-linux-gnu, GTK+ Version 3.14.5) of 
2018-09-19

python.el hard-codes

(set (make-local-variable 'indent-tabs-mode) nil)

which should be customizable.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#32876; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 29 Sep 2018 16:13:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 29 12:13:47 2018
Received: from localhost ([127.0.0.1]:59103 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1g6HsJ-0002i6-5P
	for submit <at> debbugs.gnu.org; Sat, 29 Sep 2018 12:13:47 -0400
Received: from eggs.gnu.org ([208.118.235.92]:36971)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <starback@HIDDEN>) id 1g6HsI-0002hs-0R
 for submit <at> debbugs.gnu.org; Sat, 29 Sep 2018 12:13:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <starback@HIDDEN>) id 1g6HsB-00071D-PS
 for submit <at> debbugs.gnu.org; Sat, 29 Sep 2018 12:13:40 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:51175)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <starback@HIDDEN>)
 id 1g6HsB-000719-Ki
 for submit <at> debbugs.gnu.org; Sat, 29 Sep 2018 12:13:39 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46574)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <starback@HIDDEN>) id 1g6HsA-0002da-QC
 for bug-gnu-emacs@HIDDEN; Sat, 29 Sep 2018 12:13:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <starback@HIDDEN>) id 1g6Hs7-0006yn-Lj
 for bug-gnu-emacs@HIDDEN; Sat, 29 Sep 2018 12:13:38 -0400
Received: from numerus.lingfil.uu.se ([130.238.78.148]:45624)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <starback@HIDDEN>) id 1g6Hs7-0006wy-DK
 for bug-gnu-emacs@HIDDEN; Sat, 29 Sep 2018 12:13:35 -0400
Received: from localhost (localhost [127.0.0.1])
 by numerus.lingfil.uu.se (Postfix) with ESMTP id A9273A19E427;
 Sat, 29 Sep 2018 18:13:31 +0200 (CEST)
X-Virus-Scanned: amavisd-new at lingfil.uu.se
Received: from numerus.lingfil.uu.se ([127.0.0.1])
 by localhost (numerus.lingfil.uu.se [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 0bFLJOlxm7GP; Sat, 29 Sep 2018 18:13:30 +0200 (CEST)
Received: from numerus.lingfil.uu.se (localhost [127.0.0.1])
 by numerus.lingfil.uu.se (Postfix) with ESMTP id E2259A19E426;
 Sat, 29 Sep 2018 18:13:30 +0200 (CEST)
Received: (from starback@localhost)
 by numerus.lingfil.uu.se (8.14.7/8.14.7/Submit) id w8TGDU3v027767;
 Sat, 29 Sep 2018 18:13:30 +0200
From: starback@HIDDEN (Per =?iso-8859-1?Q?Starb=E4ck?=)
To: bug-gnu-emacs@HIDDEN
Subject: 26.1; python-mode mixes existing tabs with new spaces
Date: Sat, 29 Sep 2018 18:13:30 +0200
Message-ID: <sa5in2o7045.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.26)

### Problem ###

I did "emacs -Q pytab.py" where pytab.py contains the two lines:

------------------------------
def foo():
	print('hello')
------------------------------

The second line begins with a TAB.

Then I add a line to this marvellous program with

	M-> TAB print('world') C-x C-s

This new line will have eight spaces in the beginning, and because of
that this is no longer a valid Python3 program!

### Background ###

Earlier you could mix spaces and tabs (seen as 8 spaces) in Python, but
Python3 disallows mixing them.

Spaces are preferred, and the style guide "PEP 8" says that

  Tabs should be used solely to remain consistent with code that is
  already indented with tabs.

So python-mode ought to help you remain consistent with such old
code. I think that checking with what characters the current block is
indented all the time would be overdoing it for something that shouldn't
occur that often, but that it should suffice to just scan through the
visited file to see if it contains any tabs in that case instead turn on
indent-tabs-mode instead of turning it off.




Acknowledgement sent to starback@HIDDEN (Per Starbäck):
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#32876; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 25 Oct 2018 01:00:02 UTC

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