Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #150] Replace clojure-complete with compliment #153

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ me know if you are!

Thanks to the developers of [Clojure](https://github.com/clojure/clojure),
[JLine](https://github.com/jline/jline2), [nREPL](https://github.com/clojure/tools.nrepl),
[clojure-complete](https://github.com/ninjudd/clojure-complete),
[compliment](https://github.com/alexander-yakushev/compliment),
[ClojureDocs](http://clojuredocs.org), and [clojuredocs-client](https://github.com/dakrone/clojuredocs-client),
for their work on the excellent projects that this project depends upon.

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[org.clojure/tools.cli "0.3.1"]
[com.cemerick/drawbridge "0.0.6"]
[trptcolin/versioneer "0.1.1"]
[clojure-complete "0.2.3"]
[compliment "0.2.0"]
[net.cgrand/sjacket "0.1.1"
:exclusions [org.clojure/clojure]]]
:min-lein-version "2.0.0"
Expand Down
6 changes: 3 additions & 3 deletions spec/reply/reader/jline/completion_spec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

(describe "construct-possible-completions-form"
(it "does correct quoting in completions form request"
(should= '(complete.core/completions (str "clojure.core/map-") (symbol "user"))
(construct-possible-completions-form "clojure.core/map-" "user"))))
(should= '(compliment.core/completions (str "clojure.core/map-") (symbol "user") nil)
(construct-possible-completions-form "clojure.core/map-" "user"))))

(describe "using the completer"

Expand All @@ -17,7 +17,7 @@
(it "populates the list with possible completions"
(let [candidates (java.util.LinkedList.)
word-start (.complete @completer " (map" 5 candidates)]
(should= ["map" "map-indexed" "map?" "mapcat" "mapv"]
(should= ["map" "map?" "mapv" "mapcat" "map-indexed"]
candidates)
(should= 1 @@redraw-count)
(should= 2 word-start)))
Expand Down
29 changes: 14 additions & 15 deletions src/clj/reply/initialization.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[clojure.repl]
[clojure.main]
[clojure.tools.nrepl :only [version]]
[compliment.core :only [all-files]]
[trptcolin.versioneer.core :as version]))

(def prelude
Expand Down Expand Up @@ -143,30 +144,29 @@
((ns-resolve (symbol "cd-client.core") (symbol "pr-examples-core"))
~ns-str ~var-str))))

(defn formify-file [f]
(read-string (str "(do " (slurp f) ")")))
(defn formify-files [files]
(read-string (str "(do " (apply str (map slurp files)) ")")))

(defn compliment-files []
(map #(-> (Thread/currentThread)
(.getContextClassLoader)
(.getResource %))
compliment.core/all-files))

(defn completion-code []
`(try
(require '[complete.core])
; hack for 1.2 support until we release the next clojure-complete version
~(export-definition 'reply.initialization/resolve-class)
(~'reply.exports/intern-with-meta
'~'complete.core '~'resolve-class ~'#'resolve-class)
(require '[compliment.core])

(catch Exception e#
(try
(eval
'~(try
(formify-file
(-> (Thread/currentThread)
(.getContextClassLoader)
(.getResource "complete/core.clj")))
(formify-files (compliment-files))
(catch Exception e
'(throw (Exception. "Couldn't find complete/core.clj")))))
'(throw (Exception. "Couldn't find compliment/core.clj")))))
(catch Exception f#
(intern (create-ns '~'complete.core) '~'completions
(fn [prefix# ns#] []))
(intern (create-ns '~'compliment.core) '~'completions
(fn [prefix# ns# context#] []))
(println "Unable to initialize completions."))))))

(defn default-init-code [{:keys [custom-help] :as options}]
Expand Down Expand Up @@ -228,4 +228,3 @@
~(when custom-eval custom-eval)
~(when custom-init custom-init)
nil))

4 changes: 2 additions & 2 deletions src/clj/reply/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"[experimental] Provide an error handler function (0-1 arguments)."
:parse-fn read-string]
["-i" "--init" "--custom-init"
"Provide a Clojure file to evaluate in the user ns"
:parse-fn initialization/formify-file]
"Provide Clojure files to evaluate in the user ns"
:parse-fn initialization/formify-files]
["--standalone" "Launch standalone mode instead of the default nREPL"
:flag true]
["--color" "Use color"
Expand Down
4 changes: 2 additions & 2 deletions src/clj/reply/reader/jline/completion.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(ns reply.reader.jline.completion
(:require [reply.completion :as completion]
[complete.core])
[compliment.core])
(:import [jline.console.completer Completer]))

(defn construct-possible-completions-form [prefix ns]
`(~'complete.core/completions (~'str ~prefix) (~'symbol ~ns)))
`(~'compliment.core/completions (~'str ~prefix) (~'symbol ~ns) nil))

(defn get-prefix [buffer cursor]
(let [buffer (or buffer "")]
Expand Down