Whenever I use M-x compile, I like to have the shell that's running to be configured with bash -ic so that I can easily type the compilation command (I switch between languages often, so the building mechanism varies and I need have an interactive shell for appropriate auto-completion and language-specific bash aliases to be activated).

The "easy solution" would be putting the following at the top of my init.el:

(setq shell-file-name "bash")
(setq shell-command-switch "-ic") 

However, having an interactive shell messes up a lot of important background tasks when launched by emacs (most importantly, emerge doesn't play nicely with it). Furthermore, interactive mode needlessly slows things down.

Is it possible to have one shell-command-switch when running M-x compile, and another for everything else? As a hacky first step, is it possible to redefine compile to first copy the old shell-command-switch value, set it to -ic, then evaluate the old compile, and finally switch the value back?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.