I'm trying to create a hook for ein package that will clean up split windows and focus on the rendered buffer. The package provides one hook (called ein:ipynb-mode-hook
), but running functions below doesn't work - it seems like the buffers are not ready by the time they are fired.
Is there any other way in emacs to wait/hook for such buffers?
(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)
)))