>
Why cannot your my/compile function do this:
>
> (setq-local shell-file-name "C:/msys64/usr/bin/bash")
>
> instead of let-binding it?
This is only for the current file buffer.
For example, if you focus on a project file buffer
(e.g. test.hs) and M-x my/compile,
it only sets `shell-file-name' for that file buffer. However, the `compile` actually using the `shell-file-name' belongs to the *compilation* buffer.
```
(defun compilation-start (command &optional mode name-function highlight-regexp
continue)
...
(with-current-buffer outbuf ; <--- The `outbuf' is the *compilation* buffer
...
(comint-exec
outbuf (compilation--downcase-mode-name mode-name)
shell-file-name ;
<--- use the buffer local variable
shell-file-name
in the *compilation* buffer
nil `(,shell-command-switch ,command))
...
)
...
)
```
So the following code doesn't work:
```
(defun my/compile ()
(interactive)
(let (
(compilation-environment "PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl")
)
(setq-local shell-file-name "C:/msys64/usr/bin/bash")
(compile "ls")
))
```
M-x my/compile
Compilation exited abnormally.
Best regards,
Siyuan Chen