jwiegley / emacs-async

Simple library for asynchronous processing in Emacs
GNU General Public License v3.0
832 stars 68 forks source link

More control over async Emacs process' environment? #85

Closed girzel closed 6 years ago

girzel commented 6 years ago

This may be a feature request, may be a documentation bug report, may be a wontfix...

I'm looking into ways to offload a time-consuming load routine into an asynchronous Emacs process. Long story short, I'm calling eieio-persistent-read to read a very large EIEIO object from disk, with many many make-instance calls therein.

The problem is, for this load routine to succeed, all the defclass statements for the various objects must already be loaded, or auto-loaded. Otherwise, when the object is read, it will raise a bunch of errors about undefined functions/classes.

I understand that I can inject variables into the sub-Emacs' environment, but is there any feasible way of injecting function definitions? To be really viable, this async routine would probably need to say "load all packages with a prefix of <foo>-", which would probably involve a call to package-initialize, which is probably a non-starter.

Anyway, if there's any obvious way of solving this problem, I'd love to hear about it.

jwiegley commented 6 years ago

There is no technical barrier to arbitrary injection. Even the variable injection is just a matter of building a big setq and evaluating it within the subordinate Emacs. We could premit an unsafe function to inject arbitrary sexps to be evaluated -- with the attendant security risks, of course. Does this sound like what you'd need, or is it too much flexibility?

girzel commented 6 years ago

Thanks for the response. I later went quiet on this because it occurred to me that I might be basically misunderstanding what async can do for me -- I wanted to use it to load objects into memory, and then pass those objects to the calling Emacs instance. Then it seemed pretty unlikely that it was possible to do that (pass chunks of memory to the parent process), and I decided to investigate further before making any more noise here. So far I haven't had time to investigate :)

jwiegley commented 6 years ago

You should be able to pass read'able sexps back and forth between the two.

girzel commented 6 years ago

Okay, thanks. I was mistaken, then. It's eval'ing the sexps that takes all the time -- I was hoping to somehow pass the results back to the calling Emacs, which I don't think is possible. I'll close this now...