装python-mode的包
https://gitlab.com/python-mode-devs/python-mode/tree/master
python-mode
emacswiki文档
emacswiki文档里的配置方法是这样提供的
https://www.emacswiki.org/emacs/IndentingPython
(add-hook 'python-mode-hook
(lambda ()
(setq-default indent-tabs-mode t)
(setq-default tab-width 4)
(setq-default py-indent-tabs-mode t)
(add-to-list 'write-file-functions 'delete-trailing-whitespace)))
我的配置
通过实践,并阅读了python-mode.el的源码,发现上面的配置并不生效。
应如下配置:
(add-hook 'python-mode-hook
(lambda ()
(setq-default py-indent-offset 8)
(setq-default py-indent-tabs-mode t)))