all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: 32876@debbugs.gnu.org
Subject: bug#32876: 26.1; python-mode mixes existing tabs with new spaces
Date: Sat, 29 Sep 2018 22:11:12 +0200	[thread overview]
Message-ID: <e06662c4-96d0-62fc-382f-09576a0597eb@easy-emacs.de> (raw)
In-Reply-To: <sa5in2o7045.fsf@numerus.lingfil.uu.se>

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.






  reply	other threads:[~2018-09-29 20:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-06-23 14:38 ` Lars Ingebrigtsen
2022-05-07 12:00   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e06662c4-96d0-62fc-382f-09576a0597eb@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=32876@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.