unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#32120: 26.1; In python.el tab-width should default to 4
@ 2018-07-10 22:05 Carlos Pita
  2018-07-11  9:33 ` Robert Pluim
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Carlos Pita @ 2018-07-10 22:05 UTC (permalink / raw)
  To: 32120

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





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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2018-07-10 22:05 bug#32120: 26.1; In python.el tab-width should default to 4 Carlos Pita
@ 2018-07-11  9:33 ` Robert Pluim
  2018-07-11 13:50   ` Carlos Pita
  2019-01-07  3:13 ` bug#32120: Carlos Pita
  2019-09-13 11:03 ` bug#32120: 26.1; In python.el tab-width should default to 4 Stefan Kangas
  2 siblings, 1 reply; 14+ messages in thread
From: Robert Pluim @ 2018-07-11  9:33 UTC (permalink / raw)
  To: Carlos Pita; +Cc: 32120

Carlos Pita <carlosjosepita@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





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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2018-07-11  9:33 ` Robert Pluim
@ 2018-07-11 13:50   ` Carlos Pita
  2018-07-11 17:19     ` Glenn Morris
  0 siblings, 1 reply; 14+ messages in thread
From: Carlos Pita @ 2018-07-11 13:50 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 32120

[-- Attachment #1: Type: text/plain, Size: 292 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 755 bytes --]

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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2018-07-11 13:50   ` Carlos Pita
@ 2018-07-11 17:19     ` Glenn Morris
  2018-07-11 17:25       ` Carlos Pita
  0 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2018-07-11 17:19 UTC (permalink / raw)
  To: Carlos Pita; +Cc: 32120, Robert Pluim

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





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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2018-07-11 17:19     ` Glenn Morris
@ 2018-07-11 17:25       ` Carlos Pita
  2018-07-11 20:15         ` Glenn Morris
  2019-03-30  3:17         ` Noam Postavsky
  0 siblings, 2 replies; 14+ messages in thread
From: Carlos Pita @ 2018-07-11 17:25 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 32120, Robert Pluim

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





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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2018-07-11 17:25       ` Carlos Pita
@ 2018-07-11 20:15         ` Glenn Morris
  2018-07-11 20:23           ` Carlos Pita
  2019-03-30  3:17         ` Noam Postavsky
  1 sibling, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2018-07-11 20:15 UTC (permalink / raw)
  To: Carlos Pita; +Cc: 32120, Robert Pluim


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.





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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2018-07-11 20:15         ` Glenn Morris
@ 2018-07-11 20:23           ` Carlos Pita
  0 siblings, 0 replies; 14+ messages in thread
From: Carlos Pita @ 2018-07-11 20:23 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 32120, Robert Pluim

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!





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

* bug#32120:
  2018-07-10 22:05 bug#32120: 26.1; In python.el tab-width should default to 4 Carlos Pita
  2018-07-11  9:33 ` Robert Pluim
@ 2019-01-07  3:13 ` Carlos Pita
  2019-09-13 11:03 ` bug#32120: 26.1; In python.el tab-width should default to 4 Stefan Kangas
  2 siblings, 0 replies; 14+ messages in thread
From: Carlos Pita @ 2019-01-07  3:13 UTC (permalink / raw)
  To: 32120

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.





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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2018-07-11 17:25       ` Carlos Pita
  2018-07-11 20:15         ` Glenn Morris
@ 2019-03-30  3:17         ` Noam Postavsky
  2019-03-30  3:25           ` Carlos Pita
  1 sibling, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2019-03-30  3:17 UTC (permalink / raw)
  To: Carlos Pita; +Cc: Robert Pluim, 32120

Carlos Pita <carlosjosepita@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.






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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2019-03-30  3:17         ` Noam Postavsky
@ 2019-03-30  3:25           ` Carlos Pita
  2019-03-30 12:52             ` Noam Postavsky
  0 siblings, 1 reply; 14+ messages in thread
From: Carlos Pita @ 2019-03-30  3:25 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Robert Pluim, 32120

[-- Attachment #1: Type: text/plain, Size: 559 bytes --]

Hi Noam,

On Sat, Mar 30, 2019 at 12:17 AM Noam Postavsky <npostavs@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.

[-- Attachment #2: Type: text/html, Size: 903 bytes --]

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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2019-03-30  3:25           ` Carlos Pita
@ 2019-03-30 12:52             ` Noam Postavsky
  2019-03-30 13:33               ` Carlos Pita
  0 siblings, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2019-03-30 12:52 UTC (permalink / raw)
  To: Carlos Pita; +Cc: Robert Pluim, 32120

Carlos Pita <carlosjosepita@gmail.com> writes:

> On Sat, Mar 30, 2019 at 12:17 AM Noam Postavsky <npostavs@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





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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2019-03-30 12:52             ` Noam Postavsky
@ 2019-03-30 13:33               ` Carlos Pita
  2019-03-30 13:37                 ` Carlos Pita
  0 siblings, 1 reply; 14+ messages in thread
From: Carlos Pita @ 2019-03-30 13:33 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Robert Pluim, 32120

[-- Attachment #1: Type: text/plain, Size: 257 bytes --]

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!

[-- Attachment #2: Type: text/html, Size: 288 bytes --]

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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2019-03-30 13:33               ` Carlos Pita
@ 2019-03-30 13:37                 ` Carlos Pita
  0 siblings, 0 replies; 14+ messages in thread
From: Carlos Pita @ 2019-03-30 13:37 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Robert Pluim, 32120

[-- Attachment #1: Type: text/plain, Size: 272 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 348 bytes --]

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

* bug#32120: 26.1; In python.el tab-width should default to 4
  2018-07-10 22:05 bug#32120: 26.1; In python.el tab-width should default to 4 Carlos Pita
  2018-07-11  9:33 ` Robert Pluim
  2019-01-07  3:13 ` bug#32120: Carlos Pita
@ 2019-09-13 11:03 ` Stefan Kangas
  2 siblings, 0 replies; 14+ messages in thread
From: Stefan Kangas @ 2019-09-13 11:03 UTC (permalink / raw)
  To: Carlos Pita; +Cc: Robert Pluim, Noam Postavsky, 32120

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]

tags 32120 + notabug
close 32120
quit

Carlos Pita <carlosjosepita@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

[-- Attachment #2: Type: text/html, Size: 659 bytes --]

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

end of thread, other threads:[~2019-09-13 11:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-10 22:05 bug#32120: 26.1; In python.el tab-width should default to 4 Carlos Pita
2018-07-11  9:33 ` Robert Pluim
2018-07-11 13:50   ` Carlos Pita
2018-07-11 17:19     ` Glenn Morris
2018-07-11 17:25       ` Carlos Pita
2018-07-11 20:15         ` Glenn Morris
2018-07-11 20:23           ` Carlos Pita
2019-03-30  3:17         ` Noam Postavsky
2019-03-30  3:25           ` Carlos Pita
2019-03-30 12:52             ` Noam Postavsky
2019-03-30 13:33               ` Carlos Pita
2019-03-30 13:37                 ` Carlos Pita
2019-01-07  3:13 ` bug#32120: Carlos Pita
2019-09-13 11:03 ` bug#32120: 26.1; In python.el tab-width should default to 4 Stefan Kangas

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