在 emacs 中,使用 Mx comint-run 时如何自定义使用哪个 shell 来启动进程
我在 Windows 上运行 emacs。我使用 cygwin,并且还安装了 cygwin 版本的 ruby 和 rdebug。当我调用 Mx comint-run ENTER rdebug ENTER 时,我注意到它正在尝试通过 Microsoft 命令提示符运行 rdebug.bat,而不是使用 bash 运行 rdebug(没有 .bat)。 我希望 comint-run 使用 bash 来调用要求启动的任何进程。关于我如何做到这一点有什么想法吗?
如果您对我这样做的原因感兴趣,请参阅此处的长篇故事:解决 emacs 错误的想法:“apply:生成子进程:exec 格式错误”
小进展
我在 comint-run 的 elisp 代码中进行了一些挖掘,看起来像这样最后调用 start-process - 不幸的是,我被困住了,因为 start-process 是 C 源代码中定义的函数。由于某种原因,启动进程似乎忽略了explicit-shell-file-name 和shell-file-name 的值。
I run emacs on windows. I use cygwin and I have cygwin versions of ruby and rdebug installed as well. When I invoke M-x comint-run ENTER rdebug ENTER, I noticed that it is attempting to run rdebug.bat via the Microsoft Command prompt, instead of using bash to run rdebug (without the .bat).
I'd like comint-run to use bash to invoke any process that it is asked to start. Any ideas on how I can do this?
If you are interested in why I'm doing this, see here for the long story: Ideas for troubleshooting emacs error: "apply: Spawning child process: exec format error"
Minor progress
I did some digging around in the elisp code for comint-run and it looks like it finally calls into start-process - unfortunately, here I'm stuck since start-process is a function defined in C source code. And start-process, for some reason, seems to ignore the values of explicit-shell-file-name and shell-file-name.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我的 .emacs 中有这个,
我不是 elisp 黑客,我很久以前从某个地方复制并粘贴了这段代码。我不知道它是否会对你有帮助。但至少当我执行“Mx shell”时它会运行 bash。
I have this in my .emacs
I'm no elisp hacker and I copied and pasted this code from somewhere a long time ago. I don't know if it will help you. But at least it runs bash when I do "M-x shell".
据我所知,Emacs
start-process
根本不使用任何 shell — 它直接启动您指定的程序,无需中间进程。当然,如果您指定批处理文件 (.BAT),它将使用 Microsoft Command Shell 执行。如果您有多个名称相似的文件(一个以 .BAT 结尾,另一个不是),我建议您通过指定完整路径来确保执行正确的文件。启动 Command Shell 来解释 Emacs 要求其执行的批处理文件的不是 Emacs,而是 Windows。
Emacs
start-process
does not use any shell at all as far as I can tell — it launches the program you specify directly without intermediate processes. Naturally, if you specify a batch file (.BAT), it will be executed using the Microsoft Command Shell.If you have multiple files named similarly (one ending in .BAT, and another not), I suggest you make sure the correct one is executed by specifying the full path. It is not Emacs, but Windows that is launching the Command Shell to interpret the batch file Emacs asked it to execute.
Jörgen Lundberg 的 answer 肯定会起作用,但是 Emacs 首先查看变量
explicit-shell-file-name
的值来确定为 交互式劣质 shell(查看文档链接)。因此,肯定的答案是设置:Jörgen Lundberg's answer will surely work, however Emacs first looks at the value of the variable
explicit-shell-file-name
to determine which shell to run for an interactive inferior shell (check the link for documentation). So, the sure-fire answer would be to set:尽管进行了大量的 elisp 调试,我还是无法找到一种自定义启动过程以使用 cygwin bash 的方法。现在我回顾这一点,这对我来说有点意义:假设 emacs 使用 start-process 来启动它内部需要的不同进程,start-process 总是需要调用一个取决于底层操作的 shell系统而不是任何用户定制。
In spite of a lot of elisp debugging, I couldn't figure out a way to customise the start-process to use cygwin bash. Now that I look back on this, it sort of makes sense to me: assuming that emacs uses start-process to start different processes that it needs internally as well, start-process would always need to invoke a shell which depends on the underlying operating system rather than any user customisations.