Thoughts on Perl and Emacs, technology and writing

Emacs Comint

I use both vim and emacs regularly1. For me, the most important difference between the two isn’t the modal/modeless thing. Nor is it even that emacs encourages working on multiple buffers within a single instance whereas vim users generally fire up a new instance for each file2.

No, what emacs has that vim does not is its superb handling of asynchronous processes.

The magic of comint

Comint is an emacs lisp library designed to simplify interaction with external interpreters. Here is an example of controlling a DOS prompt.

Sure, for a trivial example like this you would probably use dired, eshell or even my shell wrappers. However, in a similar way to expect, comint makes it easy to interact with anything that provides a stdin/stdout interface. The potential applications are limitless.

In my next comint post, I’ll show you how to interact with a simple subscriber.

Share this:

Like this:

Related

2 Responses

I never open multiple instances of Vim, unless I work on two projects at the same time, in which case I open one instance per project…

As for the async processes, since Vim has the ability to be extended using Python, you could write threaded, thus async parts. For example, I had connected the iNotify python library which is an async process with my ctags-based plug-in for refreshing the database.

I think with your single instance of vim per project, you are the exception that proves the rule.

And I didn’t say that vim can’t interact with asynchronous processes. My claim is that the asynchronous process support in emacs is superb whereas in vim it is not. Hopefully my next comint post will make it clear just how good/easy it is in emacs.