Function: macroexp-warn-and-return

macroexp-warn-and-return is a byte-compiled function defined in macroexp.el.gz.

Signature

(macroexp-warn-and-return MSG FORM &optional CATEGORY COMPILE-ONLY)

Documentation

Return code equivalent to FORM labeled with warning MSG.

CATEGORY is the category of the warning, like the categories that can appear in byte-compile-warnings. COMPILE-ONLY non-nil means no warning should be emitted if the code is executed without being compiled first.

Probably introduced at or before Emacs version 28.1.

Aliases

macroexp--warn-and-return (obsolete since 28.1)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/macroexp.el.gz
(defun macroexp-warn-and-return (msg form &optional category compile-only)
  "Return code equivalent to FORM labeled with warning MSG.
CATEGORY is the category of the warning, like the categories that
can appear in `byte-compile-warnings'.
COMPILE-ONLY non-nil means no warning should be emitted if the code
is executed without being compiled first."
  (cond
   ((null msg) form)
   ((macroexp-compiling-p)
    (if (and (consp form) (gethash form macroexp--warned))
        ;; Already wrapped this exp with a warning: avoid inf-looping
        ;; where we keep adding the same warning onto `form' because
        ;; macroexpand-all gets right back to macroexpanding `form'.
        form
      (puthash form form macroexp--warned)
      (macroexp--warn-wrap msg form category)))
   (t
    (unless compile-only
      (message "%sWarning: %s"
               (if (stringp load-file-name)
                   (concat (file-relative-name load-file-name) ": ")
                 "")
               msg))
    form)))