【发布时间】:2015-11-17 06:12:55
【问题描述】:
我处于问题的底部 - 我不知道如何深入挖掘,因为我现在正在从 process.C 文件运行 start-process。这在 Emacs 内部,下一步似乎是查看 C 代码。
这是我的问题。当我跑步时
(let ((default-directory "C:/Users/esharapov/.emacs.d/"))
(apply 'start-process "ag" (get-buffer-create "test")
"c:\\App\\emacs\\libexec\\emacs\\24.5\\i686-pc-mingw32\\cmdproxy.exe"
(list "-c" "\"ag\" \"--nocolor\" \"--literal\" \"--line-number\" \"--smart-case\" \"--nogroup\" \"--column\" \"--stats\" \"--\" \"keymap-on\" \".\"")))
我在输出后进入缓冲区
194:15: (defmacro keymap-on-key (name keys)
233:9: (keymap-on-key ctl-x-f-map "C-x f")
572:7: (keymap-on-key ctl-z-w-map "C-z w")
194:15: (defmacro keymap-on-key (name keys)
233:9: (keymap-on-key ctl-x-f-map "C-x f")
572:7: (keymap-on-key ctl-z-w-map "C-z w")
6 matches
382 files searched
8993756 bytes searched
0.446822 seconds
Process ag finished
如果我在 Windows 命令提示符下运行它
c:\\App\\emacs\\libexec\\emacs\\24.5\\i686-pc-mingw32\\cmdproxy.exe /c "C:\\App\\bin\\ag.exe --nocolor --literal --line-number --smart-case --nogroup --column --stats -- keymap-on ."
我得到以下输出
#configuration.org#:194:15: (defmacro keymap-on-key (name keys)
#configuration.org#:233:9: (keymap-on-key ctl-x-f-map "C-x f")
#configuration.org#:572:7: (keymap-on-key ctl-z-w-map "C-z w")
configuration.org:194:15: (defmacro keymap-on-key (name keys)
configuration.org:233:9: (keymap-on-key ctl-x-f-map "C-x f")
configuration.org:572:7: (keymap-on-key ctl-z-w-map "C-z w")
6 matches
382 files searched
8993756 bytes searched
0.483917 seconds
注意到不同了吗?当我使用start-process 时,文件名将从进程输出中删除。有谁知道这里有什么问题?
更新
我又进行了一些实验,比较了CMD shell 和 Emacs shell 中各种命令的输出。一个明显的竞争者是grep 命令
(let ((default-directory "C:/Users/esharapov/Dev/Test/"))
(apply 'start-process "grep" (get-buffer-create "test") "c:\\App\\emacs\\libexec\\emacs\\24.5\\i686-pc-mingw32\\cmdproxy.exe" (list "-c" "\"grep\" \"-nH\" \"-e\" \"Metlife\" \"*.txt\"")))
打印
Evgeniy_Review.txt:192: 1. Finishing Harmony Docker container and presenting it to the Metlife SWAT
Evgeniys_20141031.txt:16: 1. Finishing Harmony Docker container and presenting it to the Metlife SWAT
Process grep finished
控制台的输出是一样的
C:\Users\esharapov\Dev\Test>grep -nH -e Metlife *.txt
Evgeniy_Review.txt:192: 1. Finishing Harmony Docker container and presenting it to the Metlife SWAT
Evgeniys_20141031.txt:16: 1. Finishing Harmony Docker container and presenting it to the Metlife SWAT
现在使用ag 命令
(let ((default-directory "C:/Users/esharapov/Dev/Test/"))
(apply 'start-process "ag" (get-buffer-create "test") "c:\\App\\emacs\\libexec\\emacs\\24.5\\i686-pc-mingw32\\cmdproxy.exe" (list "-c" "\"ag\" --nocolor --nogroup \"Metlife\" .")))
打印出以下内容:
1. Finishing Harmony Docker container and presenting it to the Metlife SWAT
1. Finishing Harmony Docker container and presenting it to the Metlife SWAT
Process ag finished
在控制台中(CMD shell)
C:\Users\esharapov\Dev\Test>ag --nocolor --nogroup Metlife .
Evgeniys_20141031.txt:16: 1. Finishing Harmony Docker container and presenting it to the Metlife SWAT
Evgeniy_Review.txt:192: 1. Finishing Harmony Docker container and presenting it to the Metlife SWAT
似乎用 Git for Windows 中的 bash 或 cmd 替换 cmdproxy 并没有什么不同,结果是一样的。
因此,ag 控制台命令中的某些内容会有所不同。另一方面,start-process 输出与 cmd 输出不同是怎么回事?
版本:
- Microsoft Windows [版本 6.3.9600]
- 2015-04-11 在 LEG570 上的 GNU Emacs 24.5.1 (i686-pc-mingw32)
【问题讨论】:
-
我认为
ag而不是 Emacs 可能是罪魁祸首。如果你在没有控制终端的情况下运行它,使用简化的环境等,你能重现你在 Emacs 下得到的输出吗?
标签: windows shell emacs console elisp