我的操作系统是Windows 7,编辑器是Emacs 24.3.1,版本控制工具是Git 1.8.1.msysgit.1。在我的.emacs文件中,我有以下内容:
(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)))
当我想要执行M-x shell时,这个方法非常有效:我可以打开一个shell并输入"ls"。
然而,M-x shell-command却失败了。当我尝试通过shell-command运行"ls"(根据C-h f shell-command的说法,它应该在*Shell Command Output*缓冲区中打印其输出)时,我会收到以下错误信息:
"正在查找程序:权限被拒绝,bash"
关于call-process有一些非常古老的建议,以及许多关于如何使shell在Emacs中工作的StackOverflow问题。请注意,M-x shell功能正常,我想让的是shell-command。
(原因:https://github.com/donkirkby/live-py-plugin#installing-the-emacs-mode)