<p>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.</p>

<p>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.</p>

[{'answer_id': 15260, 'author': 'Mike Stone', 'author_id': 122, 'author_profile': 'https://Stackoverflow.com/users/122', 'pm_score': 2, 'selected': False, 'text': '<p>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:</p>\n\n<pre><code>(shell-command-to-string\n    "bash -c \\"script-to-exec args\\"")\n</code></pre>\n\n<p>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.</p>\n\n<p>A quick google search <a href="http://pymacs.progiciels-bpi.ca/" rel="nofollow noreferrer">found this page</a> 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.</p>\n'}, {'answer_id': 25549, 'author': 'Dwight Holman', 'author_id': 2667, 'author_profile': 'https://Stackoverflow.com/users/2667', 'pm_score': 4, 'selected': False, 'text': '<p><a href="http://www.emacswiki.org/cgi-bin/emacs-en?CategoryExtensionLanguage" rel="nofollow noreferrer">http://www.emacswiki.org/cgi-bin/emacs-en?CategoryExtensionLanguage</a> is a list of all non-Elisp extension languages you can use.</p>\n\n<p>It does appear to be dynamic language centric.</p>\n\n<p><a href="http://common-lisp.net/project/slime/" rel="nofollow noreferrer">http://common-lisp.net/project/slime/</a> 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.</p>\n\n<p>A similar IDE for Erlang is Distel, at <a href="http://fresh.homeunix.net/~luke/distel/" rel="nofollow noreferrer">http://fresh.homeunix.net/~luke/distel/</a> (currently down) and <a href="https://github.com/massemanet/distel" rel="nofollow noreferrer">https://github.com/massemanet/distel</a>.</p>\n\n<p>Good luck!</p>\n'}, {'answer_id': 69892, 'author': 'jfm3', 'author_id': 11138, 'author_profile': 'https://Stackoverflow.com/users/11138', 'pm_score': 0, 'selected': False, 'text': '<p>There is no "Extension API".  Emacs Lisp is way in there, and it ain\'t moving.</p>\n\n<p>You can run Emacs commands from your other process.  Have a look at Gnuserv.</p>\n\n<p>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?</p>\n'}, {'answer_id': 77372, 'author': 'Nikolai Prokoschenko', 'author_id': 6460, 'author_profile': 'https://Stackoverflow.com/users/6460', 'pm_score': 2, 'selected': False, 'text': '<p>Try <a href="https://github.com/pinard/Pymacs" rel="nofollow noreferrer">PyMacs</a>, which allows extending Emacs in Python.</p>\n\n<p><em>edit</em>: updated link.</p>\n'}, {'answer_id': 28643496, 'author': 'Erik Kaplun', 'author_id': 247623, 'author_profile': 'https://Stackoverflow.com/users/247623', 'pm_score': 2, 'selected': False, 'text': '<p>From the statically typed languages side, there is something that looks quite performant and well featured for Haskell:</p>\n\n<p><a href="https://github.com/knupfer/haskell-emacs" rel="nofollow">https://github.com/knupfer/haskell-emacs</a></p>\n\n<p>there is also probably something useful for Scala to be reused from the Ensime project (has a bridge for both Emacs and Vim):</p>\n\n<p><a href="https://github.com/ensime/ensime-server" rel="nofollow">https://github.com/ensime/ensime-server</a></p>\n\n<p>Furthermore, a quick google search revealed another potential candidate for extending Emacs with a classic FP language, OCaml; the project has a lot of <code>.ml</code> source files so there\'s got to be an Emacs-OCaml bridge somewhere:</p>\n\n<p><a href="https://github.com/the-lambda-church/merlin" rel="nofollow">https://github.com/the-lambda-church/merlin</a></p>\n'}, {'answer_id': 34952434, 'author': 'AdrieanKhisbe', 'author_id': 1806019, 'author_profile': 'https://Stackoverflow.com/users/1806019', 'pm_score': 2, 'selected': False, 'text': '<p>Some Extension Api is now possible with the incoming emacs 25.1 and dynamic modules</p>\n\n<p>A Library, <a href="https://github.com/tromey/emacs-ffi" rel="nofollow"><code>emacs-ffi</code></a> offer a foreign function interface based on <code>libffi</code>.</p>\n\n<p>Check out complete documentation on the <a href="https://github.com/tromey/emacs-ffi/blob/master/README.md" rel="nofollow">README</a>.</p>\n'}]
['https://Stackoverflow.com/questions/15187', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1412/']