Emacs 从elisp正确调用交互式脚本

Emacs 从elisp正确调用交互式脚本,emacs,elisp,Emacs,Elisp,我有一个外部命令行程序,我想从elisp调用它。使用shell命令很容易做到这一点,但当命令行程序是交互式的时,它不能正常工作,在我的特殊情况下是这样的:被调用的脚本在读取stdin时会看到EOF,当我这样调用它时: ;; upload command is a string with the name of ;; a python script and some args (shell-command upload-command (get-buf

我有一个外部命令行程序,我想从elisp调用它。使用shell命令很容易做到这一点,但当命令行程序是交互式的时,它不能正常工作,在我的特殊情况下是这样的:被调用的脚本在读取stdin时会看到EOF,当我这样调用它时:

  ;; upload command is a string with the name of
  ;; a python script and some args
  (shell-command upload-command
                 (get-buffer-create "*upload output*")))))
由upload命令标识的python脚本可能会询问一些是/否问题,它可能会提示输入密码,我希望使用隐藏输入。理想情况下,所有这些交互都将发生在微型缓冲区中


如何安排事情,以便通过elisp调用时,我的外部交互命令可以通过minibuffer与用户交互?

最简单的方法是使用
make comint
make comint in buffer

(make-comint-in-buffer "upload-script-process" "*upload output*" upload-command)
这将在一个类似于
shell
buffer的缓冲区中运行脚本,因此它不能满足所有交互都在minibuffer中发生的要求。但是,如果密码提示与comint password prompt regexp匹配,它将自动从微型缓冲区中读取掩码形式的密码

请注意,在此示例中,
upload命令
需要是
exec path
上可执行文件的名称。脚本的任何额外开关或其他参数必须作为字符串参数传递给
make comint

(make-comint-in-buffer "upload-script-process" "*upload output*" 
   upload-command nil "--verbose" "--other-option")
有关更多详细信息,请参阅Emacs文档