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

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.