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

Previous Next

Package: emacs;

Reported by: starback <at> stp.lingfil.uu.se (Per Starbäck)

Date: Sat, 29 Sep 2018 16:14:01 UTC

Severity: normal

Tags: confirmed, wontfix

Found in version 26.1

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: starback <at> stp.lingfil.uu.se (Per Starbäck)
To: 32876 <at> debbugs.gnu.org
Subject: bug#32876: 26.1; python-mode mixes existing tabs with new spaces
Date: Sat, 29 Sep 2018 18:13:30 +0200
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.




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

Previous Next


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