Closed garyo closed 11 months ago
Note that I also had to explicitly set lexical-binding to nil, otherwise I get variable undefined errors in the sentinel where it uses the free vars.
Which variables exactly is it complaining about? I'm a bit surprised by that - unless I missed something the sentinel should use only variables local to the output buffer, which should be available.
In case you're interested in my command to get a proper PATH on Windows, here's what I'm doing:
I'd add that as additional example to the documentation, if you don't mind. I'm using a native build of Emacs on my Windows machine nowadays, so I never looked into those path translations.
Also, if I read the documentation correctly, lexical-binding should always be nil, unless you explicitly set it. Which emacs version are you using?
I always run a pretty recent master emacs with everything turned on. My emacs is native too, but my shell is msys64 zsh, hence the path translation. (I do set some vars in Windows registry but only a subset of what I actually use day to day.)
Note that if you run your powershell example, the PATH you get back will be semicolon-separated (which is good because it'll have colons in the pathnames), so your hook to update exec-path
will have to be modified to deal with that. My version above is a terrible hack, but it's good enough for me. :-)
The variable it typically complains about (and errors out) is variable-names
.
I see you're doing setq-local
which should work, so I'm not sure why I see the errors actually. I agree, you shouldn't have to set lexical-binding
to nil
-- I could try it without that; maybe something else I did fixed it. (I was making two async calls before I switched one to sync; maybe that was confusing things?)
And yes you are welcome to add my example.
I always run a pretty recent master emacs with everything turned on
I'm on 29, but I did package various emacs versions to be installed in parallel. I've just kicked the emacs30 build, so I'll have one tomorrow to test as well. I couldn't reproduce that variable issue on my version at least.
Note that if you run your powershell example, the PATH you get back will be semicolon-separated (which is good because it'll have colons in the pathnames), so your hook to update exec-path will have to be modified to deal with that.
I actually may have that, I'll need to check - I just did a quick check that everything works after splitting my ancient code out into this. I just have the Windows system due to a project requiring me to do some work on Arm64 Windows (which Emacs doesn't compile for natively), so it's all a very special kind of broken. I'll update that bit in the documentation, though.
I see you're doing setq-local which should work, so I'm not sure why I see the errors actually. I agree, you shouldn't have to set lexical-binding to nil
Could you remove it from the pull request for now? The rest looks good to merge. I don't think having that there should have any negative effect, as it's effectively just explicitly setting the default behaviour, but I'd rather not merge something I don't understand.
Will do.
One other small thing: in my hook, I switched the order of exec-path
to put my path first, then the default exec-path
. I think it's best that way, since the exec-path
doc says this:
By default the last element of this list is ‘exec-directory’. The
last element is not always used, for example in shell completion
(‘shell-dynamic-complete-command’).
Will do.
Thanks, I've just merged it.
One other small thing: in my hook, I switched the order of exec-path to put my path first, then the default exec-path. I think it's best that way, since the exec-path doc says this:
That's a good point, thanks. I'll update that tomorrow.
I'm closing this issue now, if you do have more variable errors please open an issue for that - I'll also see if I can reproduce that myself with emacs30 tomorrow.
The async command I need to issue to get a proper Windows path is a bit complex, and rather than deal with quoting issues I thought it would be easier to allow the command to be a list. This works for me:
Note that I also had to explicitly set
lexical-binding
to nil, otherwise I get variable undefined errors in the sentinel where it uses the free vars.In case you're interested in my command to get a proper PATH on Windows, here's what I'm doing:
That converts the msys zsh path to Windows (with forward slashes), so "/usr/bin" turns into "c:/msys64/usr/bin" and so on, and it uses semicolon as the path separator (Windows-style) so it's correct for (non-cygwin) emacs. Later in the hook to update exec-path I handle the semicolon separator like this: