[IPython-user] Question about ipython.el
bruno
bruno.chazelas@ias.u-psud...
Thu May 10 11:33:32 CDT 2007
Hello,
I am using emacs as my interface to python, mainly because of the
ipython integration and thus the ease o using interactive graph with the
matplotlib module.
I would like however to customize this interface to become more
efficient. In particular I regularly need to restart the ipython shell
to test python modules I write. I am quite a newbie to python and it is
the only sure way I found to be sure my modifications are taken into
account.
As a consequence I would like to add the following function to emacs :
kill ipython and restart it in a single key-stroke. I have begun to
learn Elisp to achieve this aim. I nearly managed to do so but my
attempt fails very near to completion. I am seeking for help.
here is the code I added to my .emacs :
(defun py-shell-stop-and-restart ()
"Stop the current python process"
(interactive)
(setq oldbuf (current-buffer))
(setq oldwindow (selected-window))
(if (get-process "Python")
(progn (kill-process "Python")
(message "Python Killed"))
(message "Python is not running Yet"))
(select-window oldwindow)
(switch-to-buffer oldbuf)
(py-shell)
)
(define-key py-mode-map "\C-c;" 'py-shell-stop-and-restart)
This codes properly kills the python interpreter if it is running, but
il fails to restart it. I don't understand why. It should restart via
the (py-shell-start) function. More strange the (py-shell) works when
the ipython shell is not working and thus cannot be killed.
any one has an idea ?
Thanks in advance and anyway thanks for the nice softwares
Bruno Chazelas
More information about the IPython-user
mailing list