This looks awesome, great work Stephen! On Wed, Dec 3, 2008 at 9:27 AM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote: > > I was just about to do that, Randall. :-) > > clojure.contrib.repl-ln is a repl that supports lines and line > numbers. Here's a session that demonstrates it. > > --Steve > > % java -cp clojure.jar:clojure-contrib.jar clojure.main -e "(use > 'clojure.contrib.repl-ln)" -e "(repl)" > 1:1 user=> ; clojure.contrib.repl-ln provides a repl that supports > lines and line numbers in the input stream > 1:2 user=> ; every input line is counted. Every input line that's not > within a clojure object generates a prompt > 1:3 user=> > 1:4 user=> > 1:5 user=> ; even blank lines > 1:6 user=> 1 2 3 ; multiple objects on one line are all printed, but > only produce one prompt > 1 > 2 > 3 > 1:7 user=> jkl ; exceptions show the repl name and line number where > they happened > java.lang.Exception: Unable to resolve symbol: jkl in this context > (repl-1:7) > 1:8 user=> (/ 1 0) > java.lang.ArithmeticException: Divide by zero (repl-1:8) > 1:9 user=> (defn greet [] " > hello" > ) > #'user/greet > 1:12 user=> (meta (var greet)) ; metadata for definitions include repl > name and line number > {:file "repl-1", :line 9, :ns #<Namespace user>, :name > greet, :arglists ([])} > 1:13 user=> ; the repl name is configurable. It defaults to: "repl-%S" > where %S is the repl serial number > 1:14 user=> (repl) ; creating a new repl produces a nested repl with a > new serial number > 2:1 user=> ; and a fresh set of line numbers > 2:2 user=> ; the default prompt is "%S:%L %N=> ", serial number, line > number, and namespace name > 2:3 user=> (in-ns 'cool) > #<Namespace cool> > 2:4 cool=> ; quitting a repl pops namespace as well > 2:5 cool=> ^D > nil > 1:15 user=> (repl) ; creating a new repl produces a nested repl with a > new serial number > 3:1 user=> ; if the prompt is too busy for your taste, you can set it > to something more familar: > 3:2 user=> (set-repl-prompt "%N=> ") > nil > user=> (repl) ; nested repls inherit their name format and prompt > format from their parent > user=> ; this one is serial number 4, but if it's not in the prompt, > how can we know? > user=> (repl-info) ; repls have properties accessible this way > {:name "repl-4", :started #<Date Wed Dec 03 09:02:59 EST 2008>, :name- > fmt "repl-%S", :prompt-fmt "%N=> ", :serial 4, :thread 1, :depth > 3, :line 2} > user=> (print-repl-info) ; or this way > Name: repl-4 > Started: Wed Dec 03 09:02:59 EST 2008 > Name-fmt: "repl-%S" > Prompt-fmt: "%N=> " > Serial: 4 > Thread: 1 > Depth: 3 > Line: 3 > nil > user=> ; thread id and nesting level are also available for use in the > prompt and repl name. > user=> ; a long running clojure could create many of them, say, over > sockets. > user=> (set-repl-prompt "%S:%T:%D:%L %N=> ") ; a big ol' prompt > nil > 4:1:3:7 user=> > 4:1:3:8 user=> > 4:1:3:9 user=> > 4:1:3:10 user=> (set-repl-name "clojure-%S:%T:%D") > nil > 4:1:3:11 user=> kjd > java.lang.Exception: Unable to resolve symbol: kjd in this context > (clojure-4:1:3:11) > 4:1:3:12 user=> ; end-of-stream (^D at the beginning of the line on > Unix/Mac OS X) quits the repl > 4:1:3:13 user=> ^D > nil > user=> ^D > nil > 1:16 user=> ^D > % > > > > >
--~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---