Skip to content

Commit

Permalink
Use transducers for local keyword completions
Browse files Browse the repository at this point in the history
  • Loading branch information
mfikes committed May 21, 2017
1 parent f6e1484 commit 6555ccf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions planck-cljs/src/planck/repl.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 480,10 @@

(defn- spec-registered-keywords
[ns]
(->> (s/registry)
keys
(eduction
(filter keyword?)
(filter #(= (str ns) (namespace %)))))
(filter #(= (str ns) (namespace %)))
(keys (s/registry))))

(defn- local-keyword-str
[kw]
Expand All @@ -497,10 497,12 @@
(defn- local-keyword-completions
[buffer kw-name]
(let [buffer-prefix (subs buffer 0 (- (count buffer) (count kw-name) 2))]
(clj->js (->> (spec-registered-keywords @current-ns)
(map local-keyword-str)
(filter #(string/starts-with? % (str "::" kw-name)))
(map #(str buffer-prefix %))))))
(clj->js (sequence
(comp
(map local-keyword-str)
(filter #(string/starts-with? % (str "::" kw-name)))
(map #(str buffer-prefix %)))
(spec-registered-keywords @current-ns)))))

(defn- ^:export get-completions
[buffer]
Expand Down

0 comments on commit 6555ccf

Please sign in to comment.