简体   繁体   English

Emacs如何在elisp中以交互式命令行模式运行命令

[英]Emacs how to run command in Interactive command line mode in elisp

I am newbie to Emacs. 我是Emacs的新手。

I want to define a function in elisp to run a command in interactive command line mode (Asynchronously if possible). 我想在elisp中定义一个函数,以在交互式命令行模式(如果可能的话,异步地)中运行命令。

my current code is: 我当前的代码是:

 (defun ma () ;run maxima batch on the current file
  (interactive) 
  (let* 
    ((fn (buffer-file-name)) (cmd (concat "maxima -b " fn)))    
    (message "cmd:%s" cmd)
    (shell-command cmd)
  )  
 )

this works fine when I do not have break points in the maxima code. 当我在最大值代码中没有断点时,这可以正常工作。 When I have break points "break()", I have to interact with the program. 当我有断点“ break()”时,我必须与程序进行交互。 The current shell-command function does not work. 当前的shell命令功能不起作用。

I also like the mechanism of "shell-command" function that the screen will automatically split into two and show the programming running info in a second window. 我也喜欢“ shell-command”功能的机制,该屏幕将自动拆分为两个并在第二个窗口中显示编程运行信息。 If possible, I still want this feature in the code that you can help me with. 如果可能的话,我仍然希望代码中有此功能,可以为您提供帮助。

Any help would be appreciated. 任何帮助,将不胜感激。

I want to define a function in elisp to run a command in interactive command line mode (Asynchronously if possible). 我想在elisp中定义一个函数,以在交互式命令行模式(如果可能的话,异步地)中运行命令。

Maybe async-shell-command is what you are looking for do Ch f async-shell-command RET for help on the function. 也许async-shell-command是您要寻找的功能,请参阅Ch f async-shell-command RET获得有关该功能的帮助。

Use the built in compile function in commint mode. 在commint模式下使用内置的compile功能。

(defun ma (&optional filename)
  (interactive)
  (compile (format "maxima -b %s" (or filename (buffer-file-name))) t))

This will open up a new window and will show you the output of the program running. 这将打开一个新窗口,并向您显示正在运行的程序的输出。 Commint mode means that the compilation process is interactive, you will be able to send input to the program from the compilation buffer. Commint模式意味着编译过程是交互式的,您将能够从编译缓冲区将输入发送到程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM