tags:

views:

833

answers:

6

I'd like to take an existing application (written in OCaml) and create an Emacs "interface" for it (like, for example, the Emacs GDB mode). I would prefer to do this without writing a ton of Lisp code. In MVC terms, I'd like for the View to be Emacs, but for the Model and Controller to remain (primarily) OCaml.

Does anybody know of a way to write Emacs extensions in a language other than Lisp? This could either take the form of bindings to the Emacs extension API in some other language (e.g., making OCaml a first-class Emacs extension language) or an Emacs interaction mode where, for example, the extension has a pipe into which it can write Emacs Lisp expressions and read out result values.

+3  A: 

I don't know if this will work for your particular problem, but I have been doing something similar using the shell-command-to-string function:

(shell-command-to-string
    "bash -c \"script-to-exec args\"")

So for example, we have existing scripts written in python which will mangle a file, so the above lets me invoke the script via emacs lisp.

A quick google search found this page describing a system to write extensions in Python, so it seems feasible to do what you want... you will just have to see if anyone has written a similar framework for OCaml.

Mike Stone
A: 

Mike Stone,

I'd like a richer interface than shell-command-to-string provides. PyMacs is interesting. I'll have to look at how the interface is implemented. I suspect it relies on both sides being dynamic to pass data back and forth.

Chris Conway
+6  A: 

http://www.emacswiki.org/cgi-bin/emacs-en?CategoryExtensionLanguage is a list of all non-Elisp extension languages you can use.

It does appear to be dynamic language centric.

http://common-lisp.net/project/slime/ is missing from that list, as it is not quite an extension language, but an Elisp-Common Lisp bridge. Its source code would show how to communicate back and forth over sockets.

A similar IDE for Erlang is Distel, at http://fresh.homeunix.net/~luke/distel/ (currently down) and http://code.google.com/p/distel/.

Good luck!

anonfunc
A: 

There is no "Extension API". Emacs Lisp is way in there, and it ain't moving.

You can run Emacs commands from your other process. Have a look at Gnuserv.

There are plenty of applications where Emacs is the View for a Model/Controller in a separate process. The Emacs GDB interface is a good example. I'm not sure of a simpler example, maybe sql-postgresql?

jfm3
+3  A: 

Try PyMacs.

rassie
+2  A: 

Someday you may be able to use JavaScript.

Bart