1

I've searched all about, and all I could find was this similar isssue: improper exiting from indentation in emacs python-mode where someone is unable to exit from the proper indentation.

Whenever I create an if statement, say

if(foo):
    bar()

Python-mode refuses to allow me to indent the bar line, forcing me to leave it as

if(foo):
bar()

Which will throw an indentation error. This happens in all .py files. It works fine while using python.el, but I much prefer the features of python-mode. Has anyone else found a solution / run into this?

My .emacs file is only the lines for loading python-mode.

Community
  • 1
  • 1
Magitrek
  • 545
  • 5
  • 19
  • 1
    I don't have emacs, but have you tried putting a space after `if` as is typical? The parens are also redundant, although I doubt that would break anything. – kindall Jun 14 '13 at 18:06
  • I tried both, but neither seemed to make a difference. I've resorted to just manually adding spaces. – Magitrek Jun 14 '13 at 19:09
  • Your comment about much preferring python-mode.el's features worries me (as an Emacs maintainer who's been dealing with what to include in Emacs w.r.t Python support). Obviously, SO is not the place to discuss it, but please send us some comments to emacs-devel or bug-gnu-emacs about those features of python-mode.el. – Stefan Jun 17 '13 at 15:51
  • Maybe you can try the way described by @sanityinc in http://stackoverflow.com/questions/2111041/change-emacs-ruby-mode-indent-to-4-spaces. – ryu Jun 18 '13 at 10:08

2 Answers2

0

It's a bug. Thanks reporting.

https://bugs.launchpad.net/python-mode/+bug/1191133

This is fixed in trunk now. See revision 1266 at

https://launchpad.net/python-mode

Should also appear also at

https://github.com/emacsmirror/python-mode

Andreas

Andreas Röhler
  • 4,804
  • 14
  • 18
0

Otherwise, As I commented before, if the issue still couldn't be resolved I think you'd better download the latest python-mode from ELPA, which should run M-x package-list-packages and then put below statement to your .emacs file.I am using python-mode-6.0.10 and it works well.

(require 'python-mode)
ryu
  • 651
  • 9
  • 23
  • Don't see python-mode.el distributed by ELPA. Recommend current trunk via bazaar: `bzr branch lp:python-mode`. Last release is here: `https://launchpad.net/python-mode/+download` – Andreas Röhler Jun 18 '13 at 11:59
  • put below to your .emacs, maybe it is in melpa packages list – ryu Jun 18 '13 at 12:07
  • (require 'package) (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/")) (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t) (package-initialize) – ryu Jun 18 '13 at 12:08