unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#32876: 26.1; python-mode mixes existing tabs with new spaces
@ 2018-09-29 16:13 Per Starbäck
  2018-09-29 20:11 ` Andreas Röhler
  2021-06-23 14:38 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 4+ messages in thread
From: Per Starbäck @ 2018-09-29 16:13 UTC (permalink / raw)
  To: 32876

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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-07 12:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-29 16:13 bug#32876: 26.1; python-mode mixes existing tabs with new spaces Per Starbäck
2018-09-29 20:11 ` Andreas Röhler
2021-06-23 14:38 ` Lars Ingebrigtsen
2022-05-07 12:00   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).