I'm trying to run a hook that should start after buffers are loaded - it hooks into ein package that starts an "ipython server" that takes some time to start and it seems that the subsequent functions don't "await" for it.
Which makes me wonder if there is any way to have async/await behavior in emacs, so that the next function runs only after the buffers are ready:
(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)
)))