Subject: bug#32876: 26.1; python-mode mixes existing tabs with new spaces

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 23 Jun 2021 16:38:45 +0200

[email-masked] (Per Starbäck) writes:

> 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.

Andreas Röhler <[email-masked]> writes:

> python.el hard-codes
>
> (set (make-local-variable 'indent-tabs-mode) nil)
>
> which should be customizable.

Well, I don't know -- the problem is that mixing them leads to invalid
programs, so specifying a single tab mode here makes sense, since it
will presumably lead to fewer problems in the long run.

That is, python-mode doesn't really support .py files with tabs in
them -- as a design decision.  So I think this works as designed.

Anybody else have an opinion here?

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