tags:

views:

97

answers:

2

I want to debug data structures and/or algorithms visually in inferior buffers (mainly python and haskell, but any interpreter running in a buffer should be the same).

For this I would like to have a mechanism for setting display properties, creating images via markup. For example in a python inferior buffer:

<dot>
digraph G {Hello->World}
</dot>

*foo* _quux_

should be replaced with an image that contains the rendered graph followed by bold text foo, and underlined text quux.

(Of course the xml like notation for the image and the news like for the text is just an idea, any other notation is OK.)

Rendered/raw view should be switchable, and IMHO it should be be a minor mode, so it can be enabled without losing the functionality of the inferior mode.

Does something like this already exist? If not, how should I start, what documentation, code, examples to read?

A: 

I'm not sure if this is done completely but a couple of things come to mind. Emacs Muse mode has (if my memory serves me correctly) a tag which allows arbitrary lisp code to be executed at that point. Perhaps you can look at that and adapt it for your purposes. Similarly, the popular org-mode has the concept of a dynamic block which will update when a function is called. You might be able to adapt that as well.

The inferior process buffers can't directly be manipulated but it might make sense to write a major mode that's a wrapper on top of it in which case, take a look at http://www.emacswiki.org/emacs/ModeTutorial.

Noufal Ibrahim
A: 

I don't know of a mode that does that already, but in cogre (at http://cedet.sf.net/cogre.shtml) you will find a tool that does UML in an Emacs buffer. It has code that calls out to DOT, and displays it in a buffer.

The specific function, cogre-export-dot-png exports a COGRE graph to a PNG file. In there, you will see a CEDET utility being used called cedet-graphviz-translate-file. If you write a bit of code that scans for the style tags and copies the contents into a file, you can use the CEDET utils to convert to a png.

Once you've done that, you can use the 'ezimage' package (also in CEDET) to put your image over the text with ezimage-insert-over-text. You'll need to use defezimage first to create an image from the file.

Eric