我正在为 python 脚本编写 comint 模式。
可以使用以下命令启动脚本:
/usr/bin/python3.3 tool-name arg0
我正在使用 comint 模式,因为此调用会在运行前在提示中询问一些信息。
如果我创建:
(defun create-app ()
"create application by using python tool"
(interactive)
(progn
(setq default-directory "/path/to/tool")
(setq buffer (get-buffer-create "*buffer_name*"))
(apply 'make-comint-in-buffer "tool" buffer "/usr/bin/python3.3" nil nil)
)
)
一切正常,python 已启动,但如果我写:
(defun create-app ()
"create application by using python tool"
(interactive)
(progn
(setq default-directory "/path/to/tool")
(setq buffer (get-buffer-create "*buffer_name*"))
(apply 'make-comint-in-buffer "tool" buffer "/usr/bin/python3.3 tool-name arg0" nil nil)
)
)
缓冲区告诉我它无法执行程序“/usr/bin/python3.3 tool-name arg0”
有谁知道(有或没有 comint)如何启动这个 python 进程并让脚本在启动前询问一些信息?
最佳答案
make-comint-in-buffer
的文档字符串 (C-hfmake-comint-in-buffer
RET)指出以下内容
(make-comint-in-buffer NAME BUFFER PROGRAM &optional STARTFILE &rest SWITCHES) Make a Comint process NAME in BUFFER, running PROGRAM. If BUFFER is nil, it defaults to NAME surrounded by `*'s. If there is a running process in BUFFER, it is not restarted. PROGRAM should be one of the following: - a string, denoting an executable program to create via `start-file-process' - a cons pair of the form (HOST . SERVICE), denoting a TCP connection to be opened via `open-network-stream' - nil, denoting a newly-allocated pty. ... If PROGRAM is a string, any more args are arguments to PROGRAM.
So the correct way to use the function is to have the only name of the program as a string and pass the arguments to be passed to the program, as additional arguments to make-comint-in-buffer
as follows
(apply 'make-comint-in-buffer "tool" buffer "/usr/bin/python3.3" nil "tool-name" "arg0")
关于python - 在 emacs 中以 comint 模式执行带有参数的 python 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22561151/