Does cider-emacs automatically aliases the required namspace?

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=>

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?

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.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.