Posts Tagged ‘comint’

I’ve finally published the next installment of my mini-series on Emacs Comint. I’ve decided to publish it as a Squidoo lens. In it, I demonstrate how to create a slick, emacs-based interface to a stock price publisher. Part 1 in the series can be found here.

The first version extracts the ticker and price and displays them nicely in a seperate buffer. The later version highlights the updated line by flashing a magenta background for half a second after any update.

The lens covers the following emacs features: comint, process filters, overlays and timers. Let me know any comments or suggestions you have either here or on the lens itself. Please visit my emacs comint lens.


Read Full Post »

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.

(require 'comint)

  (apply 'make-comint "cmd" "cmd" nil '())
  (switch-to-buffer-other-window "*cmd*")
  (other-window -1))

(comint-send-string (get-buffer-process "*cmd*") "dir\n")

And lo and behold, scroll up and scroll down work properly!

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.

1. Is that the sound of 90% of my readers leaving?

2. Yes, I’m aware that vim can work on multiple buffers. In my experience most vimmers (myself included) don’t work like that.

Read Full Post »