This article will describe using python-mode package which provides major mode for python.
Table of Contents
1 Install python-mode package
Install python-mode package with M-x package-list-packages.
python-mode 6.1.3 installed An Emacs mode for editing Python code
2 ${HOME}/.emacs
Load python-mode with autoload.
(autoload 'python-mode "python-mode" "Python editing mode." t)
(custom-set-variables
'(py-indent-offset 4)
)
(add-hook 'python-mode-hook
'(lambda()
(setq tab-width 4)
(setq indent-tabs-mode nil)
)
)
3 Install PyChecker
Install PyChecker for checking python syntax. In case of Ubuntu is as below.
$ sudo apt install -y pychecker
4 Key bindings
I use the following key bindings.
| TAB | Select indent |
| C-c C-r | Shift indent to right |
| C-c C-l | Shift indent to left |
| C-c C-w | Run PyChecker |
| C-c C-c | Run REPL |