On Jan 17, 10:05 pm, Meikel Brandmeyer <m...@kotka.de> wrote: > Salut Laurent, > > Am 17.01.2009 um 21:40 schrieb lpetit: > > > Now that's interesting. It may be easier to share code because you too > > decided to not follow slime/swank which, I guess, imposes as a middle > > language something closer to emacs-lisp than to clojure for the > > exchanged data structures. > > Well. I'm not sure I understand you correctly. The current layout > is as follows: > > A Ruby interface in Vim, which extracts data etc. and sends > via the Ruby telnet client simple clojure expressions to some > TCP port. > > There a Clojure server listens and simply executes the expressions > in Repl and sends back the result. > > There is no real protocol defined at the moment and I'm somewhat > limited with the results, since implementing parser in Vim is no > fun.... But this simple setup already allows gems like a remote > clojure server or a Repl in a Vim buffer. > > At the moment I'm investigating nailgun to eliminate the Ruby > stuff... > > > And we could indeed also share the whole code of the server side. > > That would be a tremendous win. I think interfacing to the IDE/editor > is already quite some work. > > > I'm in the process of refactoring the code (client and server) for > > clojuredev. > > > We have currently one single function, that returns a big map with all > > the information for the namespace. > > This has allowed me to do a namespace browser for clojuredev : > >http://code.google.com/p/clojure-dev/wiki/NamespaceBrowser > > Uh. Nice. I'll give that a try. Let's see whether I can interface > to that.
The code that creates data structure for the namespace browser is really simple, so instead of pointing you in the svn repo, I'll put it right after the following explanations. I've made simple yet powerful (I think :-) choices : when I want to display data as nodes, every node will be represented as a map. One key of the map gives the name of the node. By convention, always with key :name. And for allowing different types (for different behaviour based on different data types), a :type key by convention. If the node has children, its corresponding map will have a :children key, which will be a vector of maps, each map will be a subnode ... etc... Ah, and I've made every value but the children vector strings, to be sure that it is plain clojure data structure for read/pr for example : { :name "namespaces" :type "namespaces" :children [ { :name "clojure.core" :type "ns" :children [ { :name "defn" :type "var" ... key/values from (meta ) Now the code : ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; support code (defn- meta-info [v] (reduce (fn [m e] (merge m { (first e) (str (second e)) })) {} (meta v))) (defn- symbol-info [s] (merge { :type "symbol" :name (str s) } (meta-info (find-var s)))) (defn- var-info [v] (merge { :type "var" :name (str v) } (meta-info v))) (defn- ns-info [n] { :name ((comp str ns-name) n) :type "ns" :children (apply vector (map #(var-info (second %)) (ns-interns n))) }) (defn namespaces-info [] { :name "namespaces" :type "namespaces" :children (apply vector (map ns-info (all-ns))) }) Regards, -- Laurent --~--~---------~--~----~------------~-------~--~----~ 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---