Closed timmc closed 6 years ago
For reference, here's what the integration looks like from my working branch of a relying Clojure project:
(defn ^Integer default-history-size
"Get default history size from system settings, or nil if not set.
Set `app-name` for jline's reading of inputrc, or null for default."
[app-name]
(try
(-> (ConsoleKeys. app-name (ConsoleReader/getInputRc))
(.getVariable "history-size")
(Integer/parseInt))
(catch IOException ioe
(binding [*out* *err*]
(println "Error retrieving history size for REPL-y:" ioe))
nil)))
(defn configure-history
"Configure a MemoryHistory or FileHistory's max-size, if non-nil."
[hist size]
(when size
(.setMaxSize hist size)))
...
(doto (FileHistory. (make-history-file history-file) false)
(configure-history (default-history-size))
(.load))
...
For #277. Two parts:
FileHistory
so thatsetMaxSize
can be called before load (otherwise backing file is truncated)ConsoleReader.getInputRc
to allow retrieval ofhistory-size
variable from inputrc for use inFileHistory.setMaxSize