LightTable/Clojure — pull request #11 by ndr-qef (2014-02-20 21:10:17+00:00)
Title: Add result type :return to custom eval

A new :result-type for custom evallers that allows to pass the evaluation's result to an arbitrary object instead of displaying it. (For those familiar with Clojure development on Emacs, this would be analogous to CIDER's eval-and-get-value, with the additional benefit of being async.)

Such a facility would be rather useful for plugin development. It grants the caller easy programmatic access to the result of a custom eval, allowing them to behave accordingly.
For example, a factoring command could listen for the result of an analysis, then use its value to produce a snippet and move the cursor to the most convenient position in the editor.

The current implementation enforces a one-to-one correspondence between handlers and behaviors, because a custom evaller of type :return always raises the same trigger. An immediate improvement that I judge rather desirable would be to allow the caller to also specify which trigger to raise upon successful eval, so that a single object may manage multiple events.
If you are interested in this PR, I will extend the patch with this functionality before merging.