troncle Troncle <https://github.com/coventry/troncle> is a proof-of-concept integration of clojure's tracing tools with emacs, built around technomancy's innovative nrepl-discover<https://github.com/technomancy/nrepl-discover> and a robust (very simple) code-walking/wrapping macro<https://github.com/coventry/troncle/blob/master/src/troncle/macroshka.clj> I've developed. It's available for download at https://github.com/coventry/troncle
clojure.tools.trace is super-handy for exploring how code is executing, but wrapping and unwrapping subforms with (ctt/trace ...) gets tedious. The main idea with troncle is to take most of that tedium away by letting you use emacs to point at the forms you want to wrap and then doing the wrapping for you automatically during compilation. In the end, I hope to turn this into a stepping debugger, in the spirit of elisp's edebug<http://www.gnu.org/software/emacs/manual/html_node/elisp/Edebug.html> . This release is a very rough first cut, which I've published mostly because I'm hoping to talk to people at the Clojure Conj about what directions to take it in. If this seems like an interesting project to you, please take a look at the roadmap <https://github.com/coventry/troncle#roadmap> and let me know what you think. (Whether you're at the Conj or not, of course.) If it seems useless or otherwise misguided, please also let me know what you think. :-) All feedback is welcome. <https://github.com/coventry/troncle#usage>Usage Currently, troncle has one function: You mark a region of your code, hitM-x troncle-trace-region(C-c t R), and troncle sends the top-level defun containing point to clojure for compilation. Any forms contained in the marked region, as well as any forms generated by their macroexpansion, are wrapped in a call to clojure.tools.trace/trace so that the results of their evaluation during execution are reported in the repl buffer. In order to do this, you have to let troncle know how to execute the code it's compiled. You tell it using the function troncle.traces/st (for "set test.") For instance, suppose that you have the following code in tst.clj open in emacs and have selected the cyan region: (ns troncle.tst) (defn ^String capitalize [^CharSequence s] (let [s (.toString s)] (if (< (count s) 2) (.toUpperCase s) (str (.toUpperCase (subs s 0 1)) (.toLowerCase (subs s 1)))))) After installing <https://github.com/coventry/troncle#installation> troncle and compiling this file with C-c C-k, type the following into the nrepl buffer to tell troncle how you want to test this function: user> (troncle.traces/st #(println (troncle.tst/capitalize "foo"))) Now go to the tst.clj buffer, and highlight the region with the cyan background shown above. TypeC-c t R, and the following should appear in the nrepl buffer: TRACE [4 11] (.toString s): "foo"TRACE [5 12] (count s): 3TRACE [5 9] (< (count s) 2): falseFoo [4 11] gives the line/column position of the form (.toString s) in the buffer."foo"` is the result of its evaluation. Only three forms are traced, because those are the only forms in the selected region. <https://github.com/coventry/troncle#installation>Roadmap<https://github.com/coventry/troncle#extended-functionality>Extended functionality This is a very simple application at the moment, but I think it has a lot of potential. The core functionality is introncle.macroshka, which is a very robust code-walking scheme. (I've run it over the entire clojure source code.) These are the directions I'd like to move it in: 1. Emacs convenience functions for passing "load this file" and "run this test" functions totronce.traces/st. 2. Tracing instrumentation for multiple regions within a top-level form. 3. Filtered tracing: Only report a trace when a given predicate returns true. Predicate can be specified in terms of return values of the forms under consideration. 4. Save and restore current tracing configuration. 5. Tracing of bindings to local variables. 6. Send trace reports to a clojure list, rather than/as well as the repl, so that they can be queried programmatically. 7. Replay a series of trace reports using emacs overlays (nrepl-discover's overlay facility should make this easy.) 8. Replace the tracing with source-level step debugging. See you all at the conj! -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.