[#707] Add pp from clojure.pprint
This commit is contained in:
parent
721e3a4fdb
commit
3d27677186
5 changed files with 16 additions and 10 deletions
|
|
@ -4,6 +4,10 @@ For a list of breaking changes, check [here](#breaking-changes).
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### New
|
||||||
|
|
||||||
|
- Add `pp` from `clojure.pprint` #707
|
||||||
|
|
||||||
### Fixed / enhancd
|
### Fixed / enhancd
|
||||||
|
|
||||||
- Fix issue with unzipping nested directory [babashka/pod-registry#4](https://github.com/babashka/pod-registry/issues/4)
|
- Fix issue with unzipping nested directory [babashka/pod-registry#4](https://github.com/babashka/pod-registry/issues/4)
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@
|
||||||
|
|
||||||
(def ^{:doc "A sequence of lib specs that are applied to `require`
|
(def ^{:doc "A sequence of lib specs that are applied to `require`
|
||||||
by default when a new command-line REPL is started."} repl-requires
|
by default when a new command-line REPL is started."} repl-requires
|
||||||
'[[clojure.repl :refer (dir doc)]
|
'[[clojure.repl :refer (source apropos pst dir doc find-doc)]
|
||||||
[clojure.pprint :refer (pprint)]])
|
[clojure.pprint :refer (pp pprint)]])
|
||||||
|
|
||||||
(defn repl
|
(defn repl
|
||||||
"Generic, reusable, read-eval-print loop. By default, reads from *in*,
|
"Generic, reusable, read-eval-print loop. By default, reads from *in*,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
{:no-doc true}
|
{:no-doc true}
|
||||||
(:require [clojure.pprint :as pprint]
|
(:require [clojure.pprint :as pprint]
|
||||||
[sci.core :as sci]
|
[sci.core :as sci]
|
||||||
[sci.impl.namespaces :refer [copy-var]]
|
|
||||||
[sci.impl.vars :as vars]))
|
[sci.impl.vars :as vars]))
|
||||||
|
|
||||||
(alter-var-root #'pprint/write-option-table
|
(alter-var-root #'pprint/write-option-table
|
||||||
|
|
@ -71,11 +70,12 @@
|
||||||
(pprint/pprint s writer))))
|
(pprint/pprint s writer))))
|
||||||
|
|
||||||
(def pprint-namespace
|
(def pprint-namespace
|
||||||
{'pprint (copy-var pprint pprint-ns)
|
{'pp (sci/copy-var pprint/pp pprint-ns)
|
||||||
'print-table (copy-var print-table pprint-ns)
|
'pprint (sci/copy-var pprint pprint-ns)
|
||||||
|
'print-table (sci/copy-var print-table pprint-ns)
|
||||||
'*print-right-margin* print-right-margin
|
'*print-right-margin* print-right-margin
|
||||||
'cl-format (copy-var pprint/cl-format pprint-ns)
|
'cl-format (sci/copy-var pprint/cl-format pprint-ns)
|
||||||
;; we alter-var-root-ed write above, so this should copy the right function
|
;; we alter-var-root-ed write above, so this should copy the right function
|
||||||
'write (copy-var pprint/write pprint-ns)
|
'write (sci/copy-var pprint/write pprint-ns)
|
||||||
'simple-dispatch (copy-var pprint/simple-dispatch pprint-ns)
|
'simple-dispatch (sci/copy-var pprint/simple-dispatch pprint-ns)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
(sio/println "Use :repl/quit or :repl/exit to quit the REPL.")
|
(sio/println "Use :repl/quit or :repl/exit to quit the REPL.")
|
||||||
(sio/println "Clojure rocks, Bash reaches.")
|
(sio/println "Clojure rocks, Bash reaches.")
|
||||||
(sio/println))
|
(sio/println))
|
||||||
(eval-form sci-ctx '(use 'clojure.repl))))
|
(eval-form sci-ctx `(apply require (quote ~m/repl-requires)))))
|
||||||
:read (or read
|
:read (or read
|
||||||
(fn [_request-prompt request-exit]
|
(fn [_request-prompt request-exit]
|
||||||
(let [v (parser/parse-next sci-ctx in)]
|
(let [v (parser/parse-next sci-ctx in)]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
(ns babashka.impl.repl-test
|
(ns babashka.impl.repl-test
|
||||||
(:require
|
(:require
|
||||||
|
[babashka.impl.pprint :refer [pprint-namespace]]
|
||||||
[babashka.impl.repl :refer [start-repl!]]
|
[babashka.impl.repl :refer [start-repl!]]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[clojure.test :as t :refer [deftest is]]
|
[clojure.test :as t :refer [deftest is]]
|
||||||
|
|
@ -15,7 +16,8 @@
|
||||||
|
|
||||||
(defn repl! []
|
(defn repl! []
|
||||||
(start-repl! (init {:bindings {'*command-line-args*
|
(start-repl! (init {:bindings {'*command-line-args*
|
||||||
["a" "b" "c"]}})))
|
["a" "b" "c"]}
|
||||||
|
:namespaces {'clojure.pprint pprint-namespace}})))
|
||||||
|
|
||||||
(defn assert-repl [expr expected]
|
(defn assert-repl [expr expected]
|
||||||
(is (str/includes? (sci/with-out-str
|
(is (str/includes? (sci/with-out-str
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue