Does cider-emacs automatically aliases the required namspace?


#1

When I require an ns in the cider-repl in emacs using just a require with no :as for an alias, I am still able to access the symbols of the ns using only the last component of the ns’s name. See below.
I find this surprising as it changes how require work.

the-divine-cheese-code.core=> (require 'the-divine-cheese-code.visualization.svg)
nil

the-divine-cheese-code.core=>  (ns-aliases *ns*)
{svg #namespace[the-divine-cheese-code.visualization.svg]}

the-divine-cheese-code.core=>

#2

I’m unable to reproduce with the following:

(ns th.playground)

(require 'clojure.edn)
(ns-aliases *ns*)
;; => {}

But I noticed that If I (require '[clojure.edn :as edn]), re-evaluating the (ns) form didn’t drop the old aliases. Perhaps you have some old state lying around? Consider re-checking from a fresh repl?


#3

Since you are already in the-divine-cheese-code.core namespace, anything that namespace has required/refer’d is already going to be in place (assuming you required that ns and then switched CIDER over to it).

So if that ns has:

(ns the-divine-cheese-code.core
  (:require [the-divine-cheese-code.visualization.svg :as svg]))

then when you require that core ns and switch to it, it’s already going to have an alias for svg.