Function: cider-ensure-macro

cider-ensure-macro is a byte-compiled function defined in cider-client.el.

Signature

(cider-ensure-macro OPERATOR)

Documentation

Signal a helpful user-error unless OPERATOR names a resolvable macro.

This turns the silent "nothing happens" case (e.g. the namespace hasn't been evaluated yet) into an actionable message, distinguishing an unresolved symbol from a special form or an ordinary (non-macro) var.

A nil or non-symbol OPERATOR (a literal, reader syntax like `::kw` or
`#(...)`, and so on) passes the check: expanding it is a no-op on the
runtime side, but the reader may still normalize the form usefully.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-client.el
(defun cider-ensure-macro (operator)
  "Signal a helpful `user-error' unless OPERATOR names a resolvable macro.
This turns the silent \"nothing happens\" case (e.g. the namespace hasn't
been evaluated yet) into an actionable message, distinguishing an unresolved
symbol from a special form or an ordinary (non-macro) var.

A nil or non-symbol OPERATOR (a literal, reader syntax like \\=`::kw\\=` or
\\=`#(...)\\=`, and so on) passes the check: expanding it is a no-op on the
runtime side, but the reader may still normalize the form usefully."
  (when (cider--symbol-operator-p operator)
    (let ((info (cider-var-info operator)))
      (cond
       ((null info)
        (user-error "%s" (cider-resolution-failure-message operator)))
       ;; `let', `fn', `loop' and `letfn' carry both `:macro' and
       ;; `:special-form' metadata - they are real macros delegating to the
       ;; `*'-suffixed special forms - so the macro check must come first.
       ((nrepl-dict-get info "macro") nil)
       ((nrepl-dict-get info "special-form")
        (user-error "`%s' is a special form; there's nothing to macroexpand" operator))
       (t
        (user-error "`%s' is not a macro" operator))))))