Phillip B Oldham
Phillip B Oldham

Reputation: 19385

Enable auto-indent in python-mode (python.el) in Emacs 24?

I've recently declared emacs bankruptcy and in rebuilding my config switched from the old python-mode.el to the built-in python.el.

One thing that's I'm missing is the old behaviour of auto-indenting to the correct level when hitting RET. Is there any way to re-enable this?

Upvotes: 4

Views: 1680

Answers (2)

user355252
user355252

Reputation:

In upcoming Emacs 24.4 auto-indendation is enabled by default thanks to electric-indent-mode. Since Emacs 24.4 has been in feature-freeze for quite some time now, there should be no major breaking bugs left, so you could already make a switch.

Upvotes: 4

abo-abo
abo-abo

Reputation: 20342

Try this:

(add-hook 'python-mode-hook 'my-python-hook)

(defun my-python-hook ()
  (define-key python-mode-map (kbd "RET") 'newline-and-indent))

Upvotes: 2

Related Questions