简体   繁体   English

Emacs的“启动过程”似乎会破坏过程输出

[英]Emacs `start-process` seems to mangle process output

I am at the bottom of a problem - I don't see how to dig any deeper because I am now running start-process from the process.C file. 我处于问题的根源-我现在看不到如何进行更深入的挖掘,因为我现在正在从process.C文件运行start-process Which is in Emacs internals and the next step seem to be looking at the C code. 这是在Emacs内部的,下一步似乎在看C代码。

Here's the my problem. 这是我的问题。 When I run 当我跑步

(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\" \".\"")))

I get in the buffer following output 我进入输出后的缓冲区

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

If I run it in the Windows command prompt as 如果我在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 ."

I get following output 我得到以下输出

#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

Noticed the difference ? 注意到区别了吗? When I use start-process the file name is being removed from the process output. 当我使用start-process ,文件名将从过程输出中删除。 Does anyone know what's the issue here ? 有人知道这是什么问题吗?

UPDATE 更新

I conducted few more experiments comparing output of various commands in the CMD shell and in Emacs shell . 我进行了更多的实验,比较了CMD Shell和Emacs shell中各种命令的输出。 One obvious contender was grep command 一个明显的竞争者是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\"")))

Prints 版画

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

The output of the console is identical 控制台的输出是相同的

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

Now for ag command 现在用于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\" .")))

Prints out the following: 打印以下内容:

   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

While in the console (CMD shell) 在控制台中(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

Seems like replacing cmdproxy with say bash from Git for Windows or cmd doesn't make a difference and results are the same. 似乎用Git for Windows或cmd中的bash替换cmdproxy并没有什么不同,结果是相同的。

So, it is something in ag console command that makes a difference. 因此,正是ag控制台命令中的某些功能有所不同。 On the other hand what's going on that start-process output is different from cmd output ? 另一方面, start-process输出与cmd输出有何不同?

Versions: 版本:

  • Microsoft Windows [Version 6.3.9600] Microsoft Windows [版本6.3.9600]
  • GNU Emacs 24.5.1 (i686-pc-mingw32) of 2015-04-11 on LEG570 LEG570上的2015年4月11日的GNU Emacs 24.5.1(i686-pc-mingw32)

I would guess that you need to include the --filename parameter to ag to fix that. 我猜想您需要将--filename参数包含在ag中以解决此问题。

As the reason of the divergence of outputs, my guess is that it would be related to environment variables. 作为产出差异的原因,我的猜测是,这将与环境变量有关。 Those might different between emacs and prompt (the path of ag binary, the HOME where ag looks for its defaults, etc). 这些可能在emacs和提示符(ag二进制文件的路径,ag查找其默认值的HOME等)之间有所不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM