improper exiting from indentation in emacs python-mode

南楼画角 提交于 2019-12-05 04:39:23
unutbu

For modern versions of Emacs, use python.el, not python-mode.el. If you remove all those lines from your .emacs, I think python.el will be enabled by default, and you'll get a Python mode when you open a .py file.

I tested the blank default setting on my system and backspace properly goes back one level of indention in your example.

So the answer seems to be, "do nothing!" :)


On Ubuntu, python.el is provided by the emacs23-common package which is part of the standard emacs installation:

% dpkg -S /usr/share/emacs/23.3/lisp/progmodes/python.elc
emacs23-common: /usr/share/emacs/23.3/lisp/progmodes/python.elc

My guess is that python-mode.el does not support having different indentation width. Your last example uses 2 and 3 spaces for indentation. Why don't you use 4 spaces per indentation always? Using 4 spaces is standard style.

EDITED: When I open a new file and copied your last example I could reproduce what you said. However, when I close it and reopened it, I could exit from the indentation correctly. I could do the same thing by selecting the code and hit C-c : (py-guess-indent-offset) without close/reopen.

Andreas Röhler

This is a bug.

py-smart-indentation has wrongly been guessing a value of 4 lately.

To get things fixed quickly, please report python-mode.el bugs at:

https://bugs.launchpad.net/python-mode

Instead of backspacing, just press <tab>. It should jump to the next logical indent location.

Andreas Röhler

fixed in current trunk

get it using bazaar:

bzr branch lp:python-mode

or via html download-button

https://launchpad.net/python-mode resp. http://bazaar.launchpad.net/~python-mode-devs/python-mode/python-mode/files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!