I want to write an interactive function to

  1. Call an external binary
  2. Write the output of the binary into a buffer
  3. Process the buffer to extracts args for next call
  4. Call another external binary using args
  5. Display output of second call

Step 3 should only be called after step 2 is complete.

How can I do this?

  • 1
    Have a look at the section of the Emacs manual relating to asynchronous processes: gnu.org/software/emacs/manual/html_node/elisp/… For example, the function start-process has an optional argument to create a buffer containing the output of the external binary. Monitoring the output to determine if it has completed can be done with a set-process-sentinel. The output can be filtered with a set-process-filter and the output examined as it arrives .... E.g., stackoverflow.com/a/42879986/2112489 – lawlist May 27 '19 at 19:02
  • Questions about "what is the best way to..." are primarily opinion-based; they are generally not great candidates for SE, but they might be right for a discussion site such as Reddit. I changed your question to "how can I...". You can choose whichever answer you feel is most appropriate (perhaps "best" in some sense in your eyes). – Drew May 27 '19 at 20:35
  • 2
    Is there any reason for the calls to be asynchronous? You can do it either way, but if it's fast enough to be synchronous then that's going to be simpler. – phils May 27 '19 at 21:57
  • 1
    As @phils points out, synchronous is simpler, so assuming that's enough for your purposes, the function you want is probably call-process - documentation here. – NickD May 28 '19 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.