【发布时间】:2017-07-05 23:01:29
【问题描述】:
我想在 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 的所有文本。
我已尝试应用发布到此问题的解决方案:sleep in 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 的来源是here on line 3717
【问题讨论】:
-
comint-redi....函数返回
t -
您正在为 comint 进程设置哨兵。如果您向该进程发送命令,则不能指望在发送到该进程的下级命令完成时获得 comint 进程哨兵的状态更改。 comint 进程仍在运行。
标签: emacs comint-mode