[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#32876: 26.1; python-mode mixes existing tabs with new spaces
From: |
Per Starbäck |
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.
- bug#32876: 26.1; python-mode mixes existing tabs with new spaces,
Per Starbäck <=