Search code examples
emacsclojureslime

Clojure import versus :import


Reading the clojure API for import I see that :import in the ns macro is preferred to import, however when i'm coding using swank/slime/emacs, I can't c-x c-e the (ns .. ) s-expression to get the deps into the repl, but using (import ...) I can.

Whats the reason why :import is preferred over import, and is there fast way to import the deps from a (ns ...) s-expr from my .clj file to the repl? (Same question can be generalized to :use and :refer.. thanks)


Solution

  • Here is my preferred workflow:

    • Start Swank/Slime
    • Open the file I want to work on in Emacs
    • Do C-c C-k to compile and load the file in question
    • Do , followed by i, then type the name of the namespace you're working on and press Enter

    Now your Slime REPL should be in the namespace you're working on, and you can add to the ns declaration at the top and just C-c C-k as you change things (including your ns imports).