Reputation: 2237
I am using emacs-for-python provided by gabrielelanaro at this link.
Indentation doesn't seem to be working for me at all.
It doesn't happen automatically when I create a class, function or any other block of code that requires automatic indentation(if, for etc.) and press enter or Ctrl + j
. Instead emacs says "Arithmetic Error".
It doesn't happen when I press Tab
anywhere in a .py file. Again, every Tab
press causes "Arithmetic error".
Also, when I manually indent code using spaces, I can't erase those spaces! Backspace-ing these indents also causes "Arithmetic Error".
This problem surfaces when I use the regular Python AC
mode as well.
emacs : GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7) of 2014-03-07 on lamiak, modified by Debian
Upvotes: 15
Views: 12734
Reputation: 3500
It is related to this bug
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15975
The quickest workaround which I found was too add Jorgens Answer into .emacs file, add the following at the end of your .emacs file
(add-hook 'python-mode-hook
(lambda () (setq python-indent-offset 4)))
Upvotes: 10
Reputation: 1216
Check the value of python-indent-offset
. If it is 0, change it M-x set-variable RET python-indent-offset RET 4 RET
.
Emacs tries to guess the offset used in a Python file when opening it. It might get confused and set that variable to 0 for some badly-formatted Python file. If this is indeed the problem, please do file a bug report using M-x report-emacs-bug
and the text of the Python file so that the auto-detection can be fixed.
Upvotes: 25
Reputation: 1822
Can you comment the lines related to auto-complete in your init.el?
; (add-to-list 'load-path "~/.emacs.d/auto-complete-1.3.1")
; (require 'auto-complete)
; (add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
; (require 'auto-complete-config)
; (ac-config-default)
; (global-auto-complete-mode t)
Upvotes: 1