millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 122 forks source link

How to hook a function when all buffers load? #874

Open danielkrajnik opened 1 year ago

danielkrajnik commented 1 year ago

I'm trying to clear the clutter that is created when opening .ipynb file by default - unfortunately this doesn't work. I assume that this must fire before all buffers are created.

(add-hook 'ein:ipynb-mode-hook
          (lambda ()
            (cl-letf (((symbol-function 'read-directory-name)
                       (lambda (_prompt dir &rest _args) dir)))
              (ein:process-find-file-callback)
              (mapc 'switch-to-buffer
                     (cl-remove-if-not (lambda (b)
                      (and
                       (string-match-p "ein" (buffer-name b))
                       (string-match-p "ipynb" (buffer-name b))))
                    (buffer-list)))
              (delete-other-windows)
                )))

Is there any way to wait until everything is ready to run it?

You really just want to open that rendered buffer - it really isn't necessary to split the workspace or keep raw json buffer.