-(put 'cc-eval-when-compile 'lisp-indent-hook 0)
-(defmacro cc-eval-when-compile (&rest body)
- "Like `progn', but evaluates the body at compile time.
-The result of the body appears to the compiler as a quoted constant.
-
-This variant works around what looks like a bug in
-`eval-when-compile': During byte compilation it byte compiles its
-contents before evaluating it. That can cause forms to be compiled in
-situations they aren't intended to be compiled. See cc-bytecomp.el
-for further discussion."
- ;;
- ;; Example: It's not possible to defsubst a primitive, e.g. the
- ;; following will produce an error (in any emacs flavor), since
- ;; `nthcdr' is a primitive function that's handled specially by the
- ;; byte compiler and thus can't be redefined:
- ;;
- ;; (defsubst nthcdr (val) val)
- ;;
- ;; `defsubst', like `defmacro', needs to be evaluated at compile
- ;; time, so this will produce an error during byte compilation.
- ;;
- ;; CC Mode occasionally needs to do things like this for cross-emacs
- ;; compatibility (although we try to avoid it since it results in
- ;; byte code that isn't compatible between emacsen). It therefore
- ;; uses the following to conditionally do a `defsubst':
- ;;
- ;; (eval-when-compile
- ;; (if (not (fboundp 'foo))
- ;; (defsubst foo ...)))
- ;;
- ;; But `eval-when-compile' byte compiles its contents and _then_
- ;; evaluates it (in all current emacs versions, up to and including
- ;; Emacs 20.6 and XEmacs 21.1 as of this writing). So this will
- ;; still produce an error, since the byte compiler will get to the
- ;; defsubst anyway. That's arguably a bug because the point with
- ;; `eval-when-compile' is that it should evaluate rather than
- ;; compile its contents.
- `(eval-when-compile (eval '(progn ,@body))))