I am using Emacs 23 with python-mode 5.1.0 to edit my python programs. Sometimes when writing a program I want to run a small throwaway python script and so I run the interactive move (C-c !). This is fine, but it neither indents nor highlights the code, and if I try running python mode while in it, it no longer evaluates. So, how do I set it to indent and highlight?
+2
A:
Adding these to my .emacs seems to have done it.
The bit where it checks the buffer name in the advice would probably be better as a test on a buffer-local variable set by set-pycomint-keywords, but you get the idea.
(defun set-pycomint-keywords ()
(setq font-lock-keywords python-font-lock-keywords))
(add-hook 'py-shell-hook 'set-pycomint-keywords)
(defadvice comint-send-input (around block-comint-formatting activate)
(if (string= (buffer-name) "*Python*")
(letf (((symbol-function 'add-text-properties) (lambda (x y z) nil)))
ad-do-it))
ad-do-it)
thouis
2010-01-15 01:03:13
I tried this, and it does colour the text properly. However when I write def fn(a): and press enter it does not go into a ... but instead always raises an indentation error.
Nikwin
2010-01-15 12:57:22
A:
I don't have time to try it now, but i found you can replace python shell when you press C-c with this that should be more powerful:
http://ipython.scipy.org/moin/
When i'll have time I'll give it a try
nios
2010-02-02 13:48:38