tags:

views:

124

answers:

2

I have an asynchronous process in Emacs, which creates a TAGS file.

This process creates a process buffer called *ctags*. If the process result is "finished\n", I kill the buffer.

If the process result is anything else I want to display the process buffer similar to the *compilation* status output when running M-x compile.

I.e. I want to vertically split the screen and show the *ctags* buffer at the bottom. Pressing q would preferably kill the bottom buffer and just show my original buffer.

I tried using this in my process sentinel callback:

(split-window-vertically)
(set-window-buffer (selected-window) (get-buffer "*ctags*"))

but aside from the fact that it puts the *ctags* buffer on top, the buffer does not have the same characteristics as the *compilation* output, e.g. pressing q inserts q.

How do I create a buffer like *compilation*?

EDIT:

Inspired by Trey Jackson's answer below, this does exactly what I want:

(pop-to-buffer (get-buffer "*ctags*"))
(compilation-mode)

It selects the *ctags* buffer, puts it into compilation mode and q will quit the window.

EDIT2: Using

(compilation-mode)
(major mode instead of minor mode) since Emacs somehow doesn't like reapplying the minor mode to an exisiting buffer.

The Error message I get is:

Toggling compilation-minor-mode off; better pass explicit argument.
+3  A: 

To get the behavior of the *compilation* buffer, add this to your script:

(compilation-mode)
Trey Jackson
Great! Exactly what I needed. For completeness sake, (compilation-minor-mode) works as well.
cschol
+1  A: 

It's better to derive your own mode from compilation-mode, and define error regex, etc.

Alex Ott
Can you elaborate or point to an example?
cschol