GNU bug report logs - #32120
26.1; In python.el tab-width should default to 4

Previous Next

Package: emacs;

Reported by: Carlos Pita <carlosjosepita <at> gmail.com>

Date: Tue, 10 Jul 2018 22:06:02 UTC

Severity: wishlist

Tags: notabug

Found in version 26.1

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32120 in the body.
You can then email your comments to 32120 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Tue, 10 Jul 2018 22:06:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Carlos Pita <carlosjosepita <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 10 Jul 2018 22:06:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1; In python.el tab-width should default to 4
Date: Tue, 10 Jul 2018 19:05:01 -0300
Most python source code uses a tab step of 4 spaces. I think it doesn't
make a lot of sense to default tab-width to 4. Maybe there is a reason
I'm failing to grasp.

---

In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2018-05-29 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description:	Manjaro Linux

Recent messages:
Undo!
Redo!
Undo! [2 times]
user-error: No further undo information [7 times]
(No changes need to be saved)
Undo!
Mark saved where search started
apply: Buffer is read-only: #<buffer python.el.gz>
funcall-interactively: Buffer is read-only: #<buffer python.el.gz>
Mark saved where search started [2 times]

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 MODULES THREADS LIBSYSTEMD LCMS2

Important settings:
  value of $LC_MONETARY: es_AR.UTF-8
  value of $LC_NUMERIC: es_AR.UTF-8
  value of $LC_TIME: es_AR.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  display-line-numbers-mode: t
  flymake-mode: t
  pyvenv-mode: t
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  xclip-mode: t
  winner-mode: t
  show-paren-mode: t
  ido-ubiquitous-mode: t
  ido-everywhere: t
  global-company-mode: t
  company-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail noutline
outline jka-compr cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs eieio-opt speedbar sb-image dframe
pandoc-mode-utils dash semantic/format ezimage semantic/tag-ls
semantic/ctxt semantic/dep semantic/find semantic/wisent/python-wy
semantic/wisent semantic/wisent/wisent semantic/util-modes semantic/util
semantic semantic/tag semantic/lex semantic/fw mode-local find-func
cedet rx misearch multi-isearch autoload lisp-mnt pp cl-print
display-line-numbers checkdoc cl-extra yasnippet elec-pair
highlight-indentation flymake-proc flymake warnings help-fns radix-tree
help-mode elpy find-file-in-project ivy delsel colir color ivy-overlay
ffap thingatpt elpy-shell pyvenv esh-var esh-io esh-cmd esh-opt esh-ext
esh-proc esh-arg esh-groups eshell esh-module esh-mode esh-util
elpy-profile elpy-django elpy-refactor subr-x python tramp-sh tramp
tramp-compat tramp-loaddefs trampver ucs-normalize shell pcomplete
parse-time format-spec advice json map grep compile comint ansi-color
files-x doom-themes-org windmove vc-git diff-mode easy-mmode
company-oddmuse company-keywords company-etags etags xref project
company-gtags company-dabbrev-code company-dabbrev company-files
company-capf company-cmake company-xcode company-clang company-semantic
company-eclim company-template company-bbdb doom-tomorrow-night-theme
doom-themes doom-themes-common xclip winner ring paren
ido-completing-read+ memoize s cus-edit minibuf-eldef ido gnus nnheader
gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums mail-utils
mm-util mail-prsvr wid-edit company edmacro kmacro pcase cus-start
cus-load finder-inf info package easymenu epg-config url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache url-vars seq byte-opt gv bytecomp byte-compile cconv
cl-loaddefs cl-lib server time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 842499 39143)
 (symbols 48 42525 1)
 (miscs 40 2367 341)
 (strings 32 94216 4085)
 (string-bytes 1 2809306)
 (vectors 16 71900)
 (vector-slots 8 1835729 170938)
 (floats 8 444 224)
 (intervals 56 5089 98)
 (buffers 992 29))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Wed, 11 Jul 2018 09:34:01 GMT) Full text and rfc822 format available.

Message #8 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: 32120 <at> debbugs.gnu.org
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Wed, 11 Jul 2018 11:33:24 +0200
Carlos Pita <carlosjosepita <at> gmail.com> writes:

> Most python source code uses a tab step of 4 spaces.

This:

>I think it doesn't
> make a lot of sense to default tab-width to 4.

is in contrast with the bug title, which is

    tab-width should default to 4

python.el defaults tab-width to 8, but sets indent-tabs-mode to nil,
and uses an indent of 4 for me from emacs -Q (by using
python-indent-offset autodetection).

What would you like changed?

Regards

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Wed, 11 Jul 2018 13:51:02 GMT) Full text and rfc822 format available.

Message #11 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 32120 <at> debbugs.gnu.org
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Wed, 11 Jul 2018 10:50:39 -0300
[Message part 1 (text/plain, inline)]
>
>
> >I think it doesn't
> > make a lot of sense to default tab-width to 4.
>

Sorry, s/4/8/ here.

>
>
> python.el defaults tab-width to 8, but sets indent-tabs-mode to nil,
>

When you do rigid indentation, say C-x Tab and then S-Right, you get
8-spaces tab steps with that configuration.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Wed, 11 Jul 2018 17:20:02 GMT) Full text and rfc822 format available.

Message #14 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: 32120 <at> debbugs.gnu.org, Robert Pluim <rpluim <at> gmail.com>
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Wed, 11 Jul 2018 13:19:26 -0400
Carlos Pita wrote:

> When you do rigid indentation, say C-x Tab and then S-Right, you get
> 8-spaces tab steps with that configuration.

Right. What is your justification for wanting this to be 4?
Python generally discourages tabs, but when they are present, seems to
follow the historical convention mapping them to 8 spaces. Eg

https://docs.python.org/3/reference/lexical_analysis.html#indentation

    Tabs are replaced (from left to right) by one to eight spaces such
    that the total number of characters up to and including the
    replacement is a multiple of eight (this is intended to be the same
    rule as used by Unix).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Wed, 11 Jul 2018 17:27:01 GMT) Full text and rfc822 format available.

Message #17 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 32120 <at> debbugs.gnu.org, Robert Pluim <rpluim <at> gmail.com>
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Wed, 11 Jul 2018 14:25:57 -0300
> Right. What is your justification for wanting this to be 4?
> Python generally discourages tabs, but when they are present, seems to
> follow the historical convention mapping them to 8 spaces.

Sure, I don't want to enter tab characters at all, I just want to
rigidly indent using 4-space tab stops. And setting tab-width to 4 and
indent-tabs-mode to nil makes C-x Tab S-Right do just that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Wed, 11 Jul 2018 20:16:02 GMT) Full text and rfc822 format available.

Message #20 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: 32120 <at> debbugs.gnu.org, Robert Pluim <rpluim <at> gmail.com>
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Wed, 11 Jul 2018 16:15:30 -0400
I guess this is why python-indent-shift-left/right exist.
They indent by python-indent-offset (ie 4), not tab-width.
ISTM that tab-width should remain 8.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Wed, 11 Jul 2018 20:24:02 GMT) Full text and rfc822 format available.

Message #23 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 32120 <at> debbugs.gnu.org, Robert Pluim <rpluim <at> gmail.com>
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Wed, 11 Jul 2018 17:23:12 -0300
Ok, I didn't know about those python specific functions!

Nevertheless I fail to see why you prefer a tab width of 8, but my
immediate problem is solved.

Thanks!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Mon, 07 Jan 2019 03:14:01 GMT) Full text and rfc822 format available.

Message #26 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 32120 <at> debbugs.gnu.org
Date: Mon, 7 Jan 2019 00:13:26 -0300
Some months later, I'm insisting on this.

I don't see any point in setting the default to 8 when:

1. PEP 8 clearly states: use 4 spaces per indentation level.
2. Python mode specific rigid indentation mechanism defaults to 4 spaces.

AFAICS the only thing you get by setting tab-width to 8 is
incompatibility of emacs standard rigid indentation mechanism (M-x
Tab) with both 1 and 2. I think it's important to play well with
standard facilities (despite python mode providing it's own variant)
and, in any case, there is no good reason, no trade off, not to do it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Sat, 30 Mar 2019 03:18:01 GMT) Full text and rfc822 format available.

Message #29 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, Robert Pluim <rpluim <at> gmail.com>,
 32120 <at> debbugs.gnu.org
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Fri, 29 Mar 2019 23:17:14 -0400
Carlos Pita <carlosjosepita <at> gmail.com> writes:

>> Right. What is your justification for wanting this to be 4?
>> Python generally discourages tabs, but when they are present, seems to
>> follow the historical convention mapping them to 8 spaces.

>> https://docs.python.org/3/reference/lexical_analysis.html#indentation
>>
>>     Tabs are replaced (from left to right) by one to eight spaces such
>>     that the total number of characters up to and including the
>>     replacement is a multiple of eight (this is intended to be the same
>>     rule as used by Unix).

> Sure, I don't want to enter tab characters at all, I just want to
> rigidly indent using 4-space tab stops. And setting tab-width to 4 and
> indent-tabs-mode to nil makes C-x Tab S-Right do just that.

> Some months later, I'm insisting on this.
>
> I don't see any point in setting the default to 8 when:
>
> 1. PEP 8 clearly states: use 4 spaces per indentation level.
> 2. Python mode specific rigid indentation mechanism defaults to 4 spaces.
>
> AFAICS the only thing you get by setting tab-width to 8 is
> incompatibility of emacs standard rigid indentation mechanism (M-x
> Tab) with both 1 and 2. I think it's important to play well with
> standard facilities (despite python mode providing it's own variant)
> and, in any case, there is no good reason, no trade off, not to do it.

Seems clear to me that the proper solution is simply to rebind C-x Tab
S-left/right to use python-indent-shift-left/right.  That will solve the
actual problem you experience, without incorrectly showing any existing
tab charaters as 4 spaces.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Sat, 30 Mar 2019 03:27:01 GMT) Full text and rfc822 format available.

Message #32 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, Robert Pluim <rpluim <at> gmail.com>,
 32120 <at> debbugs.gnu.org
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Sat, 30 Mar 2019 00:25:46 -0300
[Message part 1 (text/plain, inline)]
Hi Noam,

On Sat, Mar 30, 2019 at 12:17 AM Noam Postavsky <npostavs <at> gmail.com> wrote:

>
> Seems clear to me that the proper solution is simply to rebind C-x Tab
> S-left/right to use python-indent-shift-left/right.  That will solve the
> actual problem you experience, without incorrectly showing any existing
> tab charaters as 4 spaces.
>
>
 I would agree with you if I understood why is it incorrect to show 4
spaces for a tab. OTOH I'm not saying it is correct, just that it would be
more consistent with a (suggested by a PEP) 4-space indentation step.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Sat, 30 Mar 2019 12:53:02 GMT) Full text and rfc822 format available.

Message #35 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, Robert Pluim <rpluim <at> gmail.com>,
 32120 <at> debbugs.gnu.org
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Sat, 30 Mar 2019 08:52:33 -0400
Carlos Pita <carlosjosepita <at> gmail.com> writes:

> On Sat, Mar 30, 2019 at 12:17 AM Noam Postavsky <npostavs <at> gmail.com> wrote:
>
>>
>> Seems clear to me that the proper solution is simply to rebind C-x Tab
>> S-left/right to use python-indent-shift-left/right.  That will solve the
>> actual problem you experience, without incorrectly showing any existing
>> tab charaters as 4 spaces.
>>
>>
>  I would agree with you if I understood why is it incorrect to show 4
> spaces for a tab.

Because, as Glenn mentioned, the Python spec specifically says that tabs
should be 8 spaces.

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32120#14




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Sat, 30 Mar 2019 13:34:01 GMT) Full text and rfc822 format available.

Message #38 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, Robert Pluim <rpluim <at> gmail.com>,
 32120 <at> debbugs.gnu.org
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Sat, 30 Mar 2019 10:33:01 -0300
[Message part 1 (text/plain, inline)]
Ah ok, it seems to me that when he mentioned that I was somehow confused
about the role of tab-width regarding tab steps and, later, I'd probably
forgotten about that part of the reference and was thinking about the PEP
only. I'm closing this then. Thanks!
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Sat, 30 Mar 2019 13:39:01 GMT) Full text and rfc822 format available.

Message #41 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, Robert Pluim <rpluim <at> gmail.com>,
 32120 <at> debbugs.gnu.org
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Sat, 30 Mar 2019 10:37:52 -0300
[Message part 1 (text/plain, inline)]
> And setting tab-width to 4 and indent-tabs-mode to nil makes C-x Tab
S-Right do just that.

My suggestion at the time included disabling indent-tabs, so it was ok.
Then I forgot about that. Anyway, considering that again, I'm not as
convinced about my earlier proposal.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32120; Package emacs. (Fri, 13 Sep 2019 11:04:01 GMT) Full text and rfc822 format available.

Message #44 received at 32120 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, Robert Pluim <rpluim <at> gmail.com>,
 Noam Postavsky <npostavs <at> gmail.com>, 32120 <at> debbugs.gnu.org
Subject: Re: bug#32120: 26.1; In python.el tab-width should default to 4
Date: Fri, 13 Sep 2019 13:03:06 +0200
[Message part 1 (text/plain, inline)]
tags 32120 + notabug
close 32120
quit

Carlos Pita <carlosjosepita <at> gmail.com> writes:

> Ah ok, it seems to me that when he mentioned that I was somehow
> confused about the role of tab-width regarding tab steps and, later,
> I'd probably forgotten about that part of the reference and was
> thinking about the PEP only. I'm closing this then. Thanks!

The conclusion of the discussion was that this should be closed, but it
was never done at the time.  I'm therefore closing this now.

Best regards,
Stefan Kangas
[Message part 2 (text/html, inline)]

Added tag(s) notabug. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Fri, 13 Sep 2019 11:04:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 32120 <at> debbugs.gnu.org and Carlos Pita <carlosjosepita <at> gmail.com> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Fri, 13 Sep 2019 11:04:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 11 Oct 2019 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 171 days ago.

Previous Next


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