Reload Clojure files in emacs

I'm just starting to learn Clojure and Emacs. I have a Clojure Box for windows, and I would like to be able to write code in a buffer and then run it in REPL without calling

(use 'example.code)

all time. I know about Cc Ck, but it does not reload the namespace. If i use

(in-ns 'example.code)

to change the namespace in repl which it works. What is the right way to do this?

+5
source share
2 answers

in-ns - one of the right ways.

, "" , - (require '[example.code :as ec]) user REPL; , user ec/foo ( , foo). (require :reload-all 'example.code) ( use), .

, ( ) , use:

(defn unuse [ns]
  (doseq [[n v] (ns-refers *ns*)]
    (if (= (.. v ns name) ns)
      (ns-unmap *ns* n))))

,

(defn reuse [ns]
  (unuse ns)
  (remove-ns ns)
  (use :reload-all ns))

(reuse 'example.code), - . ( , 1,2 , deftype defrecord, ... , unuse import ed - deftype - . :reload-all - deftype et al., , , ... , , , - .)

+10

, "" repl (ns 'example.code). , . , .

0

All Articles