1

最近购买了 Windows 7 Ultimate 以访问 SUA - http://www.suacommunity.com - 子系​​统,我一直在努力让 SUA 的 bash 实用程序 (/usr/local/bin/bash) 与 EmacsW32 一起工作。SUA默认自带ksh和csh,所以我安装了一个社区包来获取bash进程。

Mx shell 通常调用一个 shell 进程并通过 Emacs 缓冲区管道 stdio。这适用于 Cygwin。我尝试调整 w32-shell-* 之类的 emacs 变量以将其指向 SUA bash 可执行文件,还尝试通过 SUA 提供的 posix.exe 工具调用 bash。我经常看到与 bash 进程关联的文件描述符在 EmacsW32 创建进程后立即被删除。

与 SUA 相比,Cygwin 非常慢,所以我非常希望让这个工具与 EmacsW32 + SUA 组合一起工作。任何提示,经验,解决方案将不胜感激。

4

1 回答 1

1

我不知道 w32-shell-* 变量。也许您可以显示一些代码来说明您的意思。

我也不知道SUA。我在 Windows 上使用 GNU emacs v22,并将 powershell 作为劣质 shell 运行。最初我遇到了一些困难,类似于你的,并通过更好地理解如何启动 shell 来解决它们。也许这会对你有所帮助。

我使用这些变量:

(setq explicit-shell-file-name 
      "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe")  
(setq explicit-powershell.exe-args 
      '("-Command" "-" )) ;; interactive, but no command prompt

在我意识到两件事之前,我遇到了困难:

  1. 如果你没有为 shell 进程指定命令行参数,emacs 默认默认使用-i. 在 powershell 的情况下,该论点要么不受支持,要么它做了我想要的以外的事情(我忘记了)。所以我必须明确设置参数来调用 shell。

  2. 用于指定 shell 参数的变量的名称取决于用于启动 shell 的程序的名称。据我所知,这没有记录(除非您认为源代码是文档!)。如果您在 Linux 上运行 sh,则变量为explicit-sh-args. 如果是 bsh,那么explicit-bsh-args. 如果您使用的是 Windows,则需要使用正确的 exe 名称,包括 .exe 后缀。它产生了一个看起来很奇怪的变量名,但它确实有效。

将 powershell 作为劣质 emacs shell 启动的完整代码如下所示:

;; get a name for the buffer
(setq buffer (get-buffer-create "*PowerShell*"))

(let ((tmp-shellfile explicit-shell-file-name))
  (setq explicit-shell-file-name 
        "c:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe")  
  (setq explicit-powershell.exe-args 
        '("-Command" "-" )) ; interactive, but no command prompt

  ;; launch the shell
  (shell buffer)

  ; restore the original shell
  (if tmp-shellfile
    (setq explicit-shell-file-name tmp-shellfile)))

也许这样的东西对你有用。

于 2010-05-20T17:31:18.283 回答