4

I am writing an emacs mode that interfaces with a shell process. The shell process is expensive to start which means that I would like to do it once and then send commands to it from emacs as need be. How is it possible to do this asyncronous two way communication with an external program through emacs.

From what I understand comint mode is close to what I need but it seems like that is only to be used for a major mode where the user supplies the input like interfacing with the python shell.

I would like the actual process and shell to be hidden from the end user.

Is there a reasonably easy way to do this? Or some resources on the subject>

Thank you all

Drew
  • 75,699
  • 9
  • 109
  • 225
Jules
  • 1,275
  • 7
  • 12

1 Answers1

4

The functionality used by comint mode is start-process, so I think you might like to start with that. You send data to the process with process-send-string, and the process's output is "automatically" read by Emacs and passed to the process filter, which is a function you provide via set-process-filter.

The main difficulty is that you don't get to choose the size of the chunks you receive from the process, so your process filter function will usually want to process only part of what it received and keep the rest for later (e.g. so as to process the output one line at a time).

Stefan
  • 26,154
  • 3
  • 46
  • 84