Emacs 23 inline python.el indentation broken using tabs with width 4

I am using the python.el version found here for several years in Emacs 23 without incident. I decided to try python.el stock and ran into a weird problem:

When using tabs for indentation and tab width 4, the stock of python.el will cause two tab characters to be indented for each level, not 1. With tab width 5, this will be 1 tab plus 3 spaces. So, when indent-tabs-mode is t , indent-for-tab-command always seems to force tab sizes 8, no matter what the tab-width .

Is there any other tab-related variable that I can set to override this behavior?

+4
source share
2 answers

I think I realized this after digging out the source code for Emacs 23 stock python.el and the newest python.el on the block .

Given these settings in the python-mode buffer, tabbed padding and tab width 4 work as expected in python.el stock:

 (setq indent-tabs-mode t tab-width 4 python-indent 4) 

For the new python.el you need to change python-indent to python-indent-offset . I use both settings for both modes without any problems.

If someone has a better solution to this problem, add it, and I gladly accept it as the correct answer.

+5
source

stuck with tabs? check

try emacs 23 using python.el? check

I ran into the same wall as you recently ... what I found out is that I really hate tabs and that I find the value of the python skips incredibly annoying.

Do you set tab width in your init or with customization?

I had to change the tab width in the โ€œEditing Basicsโ€ section, setting up โ€œ4 spacesโ€ in (to have something in common with the global / local area) to add tabs . But the fun does not end ... python.el seems to only want to back down to the first tab stop (now this column 4), and no further, no matter what I set for the indent-tab-mode or tab-always parameter -indent to. I finally gave up and reverted to using python-mode.el, which has its own set of features, but at least the python code delays "correctly."

+1
source

Source: https://habr.com/ru/post/1341057/


All Articles