store/[org.clojure/clojure "1.8.0"] clj::clojure.core/refer

Official Documentation

Add notes
Arities
==================================================
   [ns-sym & filters]

Docstring
==================================================
  refers to all public vars of ns, subject to filters.
  filters can include at most one each of:

  :exclude list-of-symbols
  :only list-of-symbols
  :rename map-of-fromsymbol-tosymbol

  For each public interned var in the namespace named by the symbol,
  adds a mapping from the name of the var to the var to the current
  namespace.  Throws an exception if name is already mapped to
  something else in the current namespace. Filters can be used to
  select a subset, via inclusion or exclusion, or to provide a mapping
  to a symbol different from the var's name, in order to prevent
  clashes. Use :use in the ns macro in preference to calling this directly.

Source

(defn refer
  "refers to all public vars of ns, subject to filters.
  filters can include at most one each of:

  :exclude list-of-symbols
  :only list-of-symbols
  :rename map-of-fromsymbol-tosymbol

  For each public interned var in the namespace named by the symbol,
  adds a mapping from the name of the var to the var to the current
  namespace.  Throws an exception if name is already mapped to
  something else in the current namespace. Filters can be used to
  select a subset, via inclusion or exclusion, or to provide a mapping
  to a symbol different from the var's name, in order to prevent
  clashes. Use :use in the ns macro in preference to calling this directly."
  {:added "1.0"}
  [ns-sym & filters]
    (let [ns (or (find-ns ns-sym) (throw (new Exception (str "No namespace: " ns-sym))))
          fs (apply hash-map filters)
          nspublics (ns-publics ns)
          rename (or (:rename fs) {})
          exclude (set (:exclude fs))
          to-do (if (= :all (:refer fs))
                  (keys nspublics)
                  (or (:refer fs) (:only fs) (keys nspublics)))]
      (when (and to-do (not (instance? clojure.lang.Sequential to-do)))
        (throw (new Exception ":only/:refer value must be a sequential collection of symbols")))
      (doseq [sym to-do]
        (when-not (exclude sym)
          (let [v (nspublics sym)]
            (when-not v
              (throw (new java.lang.IllegalAccessError
                          (if (get (ns-interns ns) sym)
                            (str sym " is not public")
                            (str sym " does not exist")))))
            (. *ns* (refer (or (rename sym) sym) v)))))))

Example 1

Edit
;;; `:only' accepts only original names.
;; wrong
(refer 'clojure.string
       :rename '{capitalize cap, trim trm}
       :only '[cap trm])
;; => IllegalAccessError cap does not exist  clojure.core/refer (core.clj:3849)

;; right
(refer 'clojure.string
       :rename '{capitalize cap, trim trm}
       :only '[capitalize trim])
;; => nil

;; work well
(cap (trm " hOnduRAS  "))
;; => "Honduras"

;; and also, cannot use either of them.
(join \, [1 2 3])
;; => CompilerException java.lang.RuntimeException: Unable to resolve symbol: join in this context, compiling:(NO_SOURCE_PATH:1:1)

Example 2

Edit
(refer 'clojure.string
       :rename '{capitalize cap, trim trm})
;; > WARNING: replace already refers to: #'clojure.core/replace in namespace: user, being replaced by: #'clojure.string/replace
;; > WARNING: reverse already refers to: #'clojure.core/reverse in namespace: user, being replaced by: #'clojure.string/reverse
;; => nil

(cap (trm " hOnduRAS  "))
;; => "Honduras"

(join \, [1 2 3])
;; => "1,2,3"

Example 3

Edit
(refer 'clojure.string :only '[capitalize trim])
;; => nil

(capitalize (trim " hOnduRAS  "))
;; => "Honduras"

Uses on crossclj