tkf / emacs-ipython-notebook

IPython notebook client in Emacs
tkf.github.com/emacs-ipython-notebook/
GNU General Public License v3.0
548 stars 51 forks source link

ein-jack-in #127

Open julienchastang opened 11 years ago

julienchastang commented 11 years ago

First off, thanks for writing ein. It is fantastic emacs mode that I have spent countless hours benefiting from. Now my feature request:

Emacs Clojure developers benefit from a wonderful emacs command called nrepl-jack-in. From within emacs, nrepl-jack-in starts a Lisp (Clojure) server and connects the emacs REPL client to the server. You never have to leave emacs to start your clojure REPL and interact with this REPL from .clj files. I would like something similar in ein when opening .py files. In fact, I made a first attempt:

(defun ein:start-notebook (directory) "Start an ipython notebook server process in the directory of your choice" (interactive (list (read-string "directory: "))) (let ((default-directory directory)) (start-process "ipython" (get-buffer-create "ipython notebook") "ipython" "notebook")))

(defun ein:jack-in (directory) "Start an ipython notebook server and connect the current python buffer to it" (interactive (list (read-string "directory: "))) (ein:start-notebook directory) (sit-for 3) (ein:notebooklist-open) (ein:junk-new "tmpnb" 8888) (sit-for 3) (ein:connect-to-notebook "8888/tmpnb")

It is probably apparent I have not written a lot of elisp. But if you have suggestions for me, I could improve the code and submit a pull request.

Many thanks.

tkf commented 11 years ago

Thanks for an interesting idea. But I think difference between EIN and nrepl is that nrepl has a server per REPL (if I understand correctly) but IPython has one notebook server for all REPLs. So, how about just putting this in your init file (untested)?

(let ((default-directory "PATH/TO/YOUR/NOTE/DIR"))
  (start-process "ipython"
  (get-buffer-create "*ipython notebook*")
                     "ipython"
                     "notebook"))