gpt4 book ai didi

emacs:如何从发送到 comint 缓冲区的命令返回输出(又名劣质进程)

转载 作者:行者123 更新时间:2023-12-04 05:07:27 26 4
gpt4 key购买 nike

我要解决的具体问题是

  • 向正在运行的 telnet 发送命令 session
  • 使用 message 回显命令的结果

  • 但一般问题是将命令发送到下级(comint)进程
    并等待输出返回并出现新的提示,然后返回输出。

    我有:
    (defun dired-vlc-test ()
    (interactive)
    (let* ((buf (process-buffer dired-vlc-telnet-proc))
    (old-max (with-current-buffer buf
    (point-max))))
    (telnet-simple-send dired-vlc-telnet-proc "get_time")
    (accept-process-output dired-vlc-telnet-proc 5)
    (message (buffer-substring-no-properties old-max (with-current-buffer buf
    (point-max))))))

    但是我总是得到的输出是“get_time”,即 Emacs 不等待新的输出。

    我得到了 accept-process-output来自此的想法 question

    最佳答案

    accept-process-output在您的情况下返回太早,因为它在接受某些输出后立即返回,但在您的情况下,您希望继续接受输出,直到收到新的提示。请注意,远程进程不会告诉 Emacs“这是一个提示”,因此您必须调整您的进程过滤器以识别“哦,我们收到了一些看起来像提示的内容”,您必须调用 accept-process-output在一个循环中,直到进程过滤器告诉它(可能通过一些全局变量)它已经看到了一个提示。

    关于emacs:如何从发送到 comint 缓冲区的命令返回输出(又名劣质进程),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15344288/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com