LightTable / Clojure

Light Table Clojure language plugin
MIT License
99 stars 47 forks source link

Unreadable forms should be wrapped in #<...> #2

Open brandonbloom opened 10 years ago

brandonbloom commented 10 years ago

Right now, if I evaluate something that returns a function, the little result just shows "fn". You can't tell if it's a symbol or whatever. Seems like functions are special cased to render that way, since *ns* shows a normal toString representation for a namespace. Ideally, there would be a way to see the string representation of the function, since Clojure goes to the trouble to make sure names are in there when possible, but minimally, it should print as #<fn> so it's visually distinct and known unreadable.

cldwalker commented 10 years ago

Agree that we should have a toggle source command that looks up the current symbol and displays a widget - similar to the toggle-doc command. I don't have a strong opinion on fn vs #<fn>.

carocad commented 8 years ago

just for the record in case someone wants to work on this. Here are the relevant line:

(defn clean-serialize [res & [opts]]
  (binding [*print-length* (or (:print-length opts) *print-length* 1000)]
    (cond
     (fn? res) 'fn
     (var? res) (if-not (:allow-var? opts)
                  res
                  (str res)
                  )
     (nil? res) "nil"
     (false? res) "false"
     (and (instance? clojure.lang.Atom res)
          (:result opts)) (str "atom[" @res "]")
     (instance? clojure.lang.Atom res) (str "atom")
     ;(is-non-clojure? res) (str res)
     (and (string? res) (:verbatim opts)) res
     :else (pr-str res))))

I guess something like (fn? res) (clojure.main/demunge res) should do the job.