3

我想在 comint 启动的进程完成后读取缓冲区的输出。

(comint-redirect-send-command-to-process 
                 command-string ;; tested to work in the commint buffer
                 output-buffer-name ;; random text
                 buffer-process ;; (get-buffer-process (current-buffer))
                 nil ;; don't echo input back
                 t) ;; don't show output buffer immediatly

此 sexp 在运行 comint 进程的缓冲区中进行评估。output-buffer-name一旦过程完成,我想阅读所有文本。

我已尝试应用发布到此问题的解决方案:在 emacs lisp中通过在进程启动命令下方添加此解决方案:

(defun on-status-change (process status)
        (message "status done"))

(set-process-sentinel buffer-process 'on-status-change)

此消息不会出现在 中*Messages*

输出缓冲区文本中没有提示,但我可以编写一个函数,t根据完整的输出文本在输出完成时返回。

如何对缓冲区完成/更改做出反应,或者如何强制 comint 同步运行此功能。


源代码comint-redirect-send-command-to-process第 3717 行

4

1 回答 1

2

如果其他人有类似的问题,我最终“解决”了这个问题。

(while (not comint-redirect-completed)
  (sleep-for 0.01))

comint-redirect-completed的值为 nil

文档:如果重定向已在当前缓冲区中完成,则为非零。

显然不是一个很好的解决方案,但我无法得到任何其他工作。

于 2017-07-06T03:20:31.613 回答