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

restart and execute all #199

Open anarcat opened 6 years ago

anarcat commented 6 years ago

Hi!

There's a functionality from the web interface in Jupyter that I miss here: the Restart and Run All menu. Could we have the same thing in the EIN menus?

I wrote the following crappy lisp by cargo-culting stuff around:

(defun anarcat/ein:restart-execute-all (ws)
  "restart the kernel, wait for ready, then execute all cells"
  (interactive (list (ein:worksheet--get-ws-or-error)))
  (ein:notebook-restart-kernel-command)
  ;; wait for the kernel to *stop*
  (sit-for 1.0) ;; we should not need this.
  (let ((kernel (ein:get-kernel--worksheet))
        (timeout 3.0) ;; XXX: should be a parameter
        (tick-time 0.1))
    (loop repeat (floor (/ timeout tick-time))
          do (sit-for tick-time)
          until (ein:kernel-live-p kernel))
    (ein:worksheet-execute-all-cell ws)))

But I don't quite like it... isn't there something that can do this already?

By the way, I love this plugin. I've been struggling to work with Jupyter notebooks in the web interface: the project is great, but the editor drove me nuts, until I found this. So thanks. :)