Windows, Emacs, Git Bash, and shell-command

Windows 7. Emacs 24.3.1. Git 1.8.1.msysgit.1. I have the following in my equivalent .emacs file:

(if (equal system-type 'windows-nt)
    (progn (setq explicit-shell-file-name
                 "C:/Program Files (x86)/Git/bin/sh.exe")
           (setq shell-file-name "bash")
           (setq explicit-sh.exe-args '("--login" "-i"))
           (setenv "SHELL" shell-file-name)
           (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)))

This works great when I want to do M-x shell: I can pop open a shell and type “ls”.

However, M-x shell-command is failing. When I try to run “ls” via shell-command (which should print its output in the *Shell Command Output* buffer, according to C-h f shell-command), I get a single error message:

“Searching for program: permission denied, bash”

There are some very old suggestions on the Google about call-process and many questions on StackOverflow about getting the shell to work in Emacs. Please note that M-x shell works great, and what I’d like to work is shell-command.



Try setting both variables to point to the same executable and make sure the path is in exec-path:

(setq explicit-shell-file-name
      "C:/Program Files (x86)/Git/bin/bash.exe")
(setq shell-file-name explicit-shell-file-name)
(add-to-list 'exec-path "C:/Program Files (x86)/Git/bin")

Emacs: Ansi-term not tab-completing

Alright, I fixed it. The problem was with yasnippets, but the suggestion on the link didn’t work. For some reason setting yas-minor-mode to -1 didn’t work. What I had to do was set yas-dont-activate to something.

Suggested fix that did NOT work for me:

(add-hook 'term-mode-hook (lambda()
                (yas-minor-mode -1)))

What DID work for me:

(add-hook 'term-mode-hook (lambda()
        (setq yas-dont-activate t)))

I’m running emacs 23.4.1