Created
September 3, 2020 12:57
-
-
Save borkdude/e9d333b8e4fae210a36bafdd0bbfa3ab to your computer and use it in GitHub Desktop.
Regex printing override
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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