Skip to content

Instantly share code, notes, and snippets.

@borkdude
Created September 3, 2020 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borkdude/e9d333b8e4fae210a36bafdd0bbfa3ab to your computer and use it in GitHub Desktop.
Save borkdude/e9d333b8e4fae210a36bafdd0bbfa3ab to your computer and use it in GitHub Desktop.
Regex printing override
(def ^:dynamic *print-config* nil)
(def old-method (get-method print-method java.util.regex.Pattern))
(defmethod print-method java.util.regex.Pattern [v ^java.io.Writer w]
(if *print-config*
(.write w (pr-str (tagged-literal 'regex (.pattern v))))
(old-method v w)))
(prn #"foo")
(binding [*print-config* true]
(prn #"foo"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment