Skip to content

Commit

Permalink
Abbreviate printing of AFunction objects
Browse files Browse the repository at this point in the history
Instead of printing as
  #object[clojure.core$_PLUS_ 0x4e648e99 "clojure.core$_PLUS_@4e648e99"]
they are now printed as
  #function clojure.core/+
  • Loading branch information
Malabarba committed Oct 18, 2015
1 parent 585b416 commit 950e9bc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/cider/nrepl/middleware/out.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,25 @@
guarantee that the channel that sent the clone message will properly
handle output replies."
(:require [cider.nrepl.middleware.util.cljs :as cljs]
[clojure.string :as s]
[clojure.tools.nrepl.middleware :refer [set-descriptor!]]
[clojure.tools.nrepl.middleware.interruptible-eval :as ie]
[clojure.tools.nrepl.middleware.session :as session])
(:import [java.io PrintWriter Writer]))
(:import clojure.lang.AFunction
[java.io PrintWriter Writer]))

;;; Prettier version of function objects
(defmethod print-method AFunction [c ^Writer w]
(.write w "#function ")
(.write w (-> (.getName (class c))
(s/replace-first "$" "/")
(s/replace "_QMARK_" "?")
(s/replace "_PLUS_" "+")
(s/replace "_BANG_" "!")
(s/replace "_EQ_" "=")
(s/replace "_SLASH_" "/")
(s/replace "_STAR_" "*")
(s/replace "_" "-"))))

;;; OutStream
(defonce original-out *out*)
Expand Down

0 comments on commit 950e9bc

Please sign in to comment.