Permalink
Browse files

Made source caching even more robust.

  • Loading branch information...
1 parent a7ac19b commit c273e7f0b6cf78949abd3184210d2889033494a8 @tcrayford tcrayford committed Aug 15, 2010
Showing with 15 additions and 5 deletions.
  1. +10 −0 clojure-refactoring-mode.el
  2. +5 −5 src/clojure_refactoring/support/source.clj
@@ -245,6 +245,16 @@
map)
"Keymap for Clojure refactoring mode.")
+(defun clojure-refactoring-eval-async (string &optional handler)
+ (slime-eval-async `(swank:eval-and-grab-output ,string)
+ (or handler #'identity)))
+
+(defun clojure-refactoring-warm-cache ()
+ (clojure-refactoring-eval-async
+ "(require 'clojure-refactoring.support.source)(clojure-refactoring.support.source/populate-cache)"))
+
+(add-hook 'slime-connected-hook 'clojure-refactoring-warm-cache)
+
;;;###autoload
(define-minor-mode clojure-refactoring-mode
"A minor mode for a clojure refactoring tool"
@@ -116,14 +116,14 @@ Example: (get-source-from-var 'filter)"
(when v
(= (ns-resolve ns (.sym v)) v)))
-(defn reload-all-user-ns []
- (doseq [n (find-ns-in-user-dir)]
- (require (ns-name n) :reload)))
-
(defn require-and-return [ns]
(do (require (ns-name ns) :reload)
ns))
+(defn reload-all-user-ns []
+ (pmap #(require-and-return %)
+ (find-ns-in-user-dir)))
+
(defn all-ns-that-refer-to [v]
(->> (find-ns-in-user-dir)
(map require-and-return)
@@ -132,7 +132,7 @@ Example: (get-source-from-var 'filter)"
(defn all-vars [nses]
(->> (map ns-interns nses)
(map vals)
- (flatten)))
+ flatten))
(defn populate-cache []
(doseq [vars (->> (map require-and-return (find-ns-in-user-dir))

0 comments on commit c273e7f

Please sign in to comment.