Update environment earlier#80
Update environment earlier#80wyuenho wants to merge 1 commit intowbolster:mainfrom wyuenho:early-reliable-update-env
Conversation
| (direnv--maybe-update-environment)) | ||
| (setq direnv--active-directory default-directory) | ||
| (add-hook 'change-major-mode-after-body-hook #'direnv--maybe-update-environment) | ||
| (add-to-list 'window-buffer-change-functions #'direnv--maybe-update-environment-wsc) |
There was a problem hiding this comment.
An alternative implementation could be hooking into buffer-list-update-hook, but this works equally well. @wbolster what do you think?
|
@wbolster WDYT? |
|
ah yes, i gave this a try earlier. some of the behavioural changes actually annoyed me: i lost my direnv environment even though i didn't want to. examples are opening a new scratch buffer to jot down some notes or copy-paste stuff from elsewhere, switching to a flycheck error window, opening an emacs debugger (e.g. on error). sure, expanding i don't remember any issue with the change to the hooks/events that trigger (potential) direnv updated. |
Why would you want a per directory environment when you are doing these things?
What does this do? Is this a boolean flag to keep the current behavior? If nil, the behavior of this PR kicks in?
I'm not sure what you mean, does it mean this PR doesn't interfere with normal emacs ops? |
|
I'm going to close this as I've switched to envrc as it makes no sense to change the entire Emacs process's environment late. |
This PR should fix #17 and #28.
The problems are firstly,
before-hack-local-variables-hookdoesn't get run if the file has not file local variables, and secondlypost-command-hookis run after all the major mode hooks. If any major mode hooks expectsexec-pathto be the most updated value, the current implementation does not work for this expectation. It also runs too frequently unnecessarily.To update the environment as early as possible, this PR moves the decision to just before the major mode hooks are run but after the major mode has been set up, after a window buffer change and after a window is selected.
In addition, this PR resets the environment to the
HOMEdir's whenever the user selects a non-file and non-whitelisted window buffer so as to mitigate the perception problem that justified the entire existence of this package.