>>>> I guess we could fork Emacs early on and keep this second process >>>> around as a "process from which to generate new clean slates". >>> I've been thinking about something like this for a while… if it worked >>> at least as well as starting a new Emacs instance on all platforms, I'd >>> favor this approach. >> IIUC "fork" is not really an option for w32. > For the intended application spawn should work as well?
Could be: depends on the precise semantics of spawn, which I don't know. >> Along the same lines, we could try to use unload-feature. > I thought this was potentially dangerous, but reading the docstring > again maybe not. Let me try that as well. It's fundamentally tricky just in the same way as your proposed "namespace cleanup": if you undefine a function that's still registered on some hook, process filter, ... you may get subsequent errors, some of which may render Emacs completely unusable. So it's risky to call unload-feature on a random package, but it's not too hard for a package to make sure it survives unload-feature. Tho currently, there are some significant shortcomings (IIRC there are cases where the package's autoloads aren't re-instated, for example). Stefan