Question

I am newbie to Emacs.

I want to define a function in elisp to run a command in interactive command line mode (Asynchronously if possible).

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. The current shell-command function does not work.

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. If possible, I still want this feature in the code that you can help me with.

Any help would be appreciated.

Was it helpful?

Solution

I want to define a function in elisp to run a command in interactive command line mode (Asynchronously if possible).

Maybe async-shell-command is what you are looking for do C-h f async-shell-command RET for help on the function.

OTHER TIPS

Use the built in compile function in commint mode.

(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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top