Subject: Re: bug#16184: 24.3.50; edebug and eval-when-compiler don't work together

From: Katsumi Yamaoka <[email-masked]>
Date: Fri, 20 Dec 2013 09:01:35 +0900

Anders Lindgren wrote:
> The construct 'eval-when-compile' seems to throw debug off. When
> pressing C-u C-M-x on the following, an error is issued. This worked
> correctly in 24.3. This makes it hard to use edebug on functions in
> cc-mode (like c-font-lock-declarations), as it makes heavy use of
> eval-when-compile.

> (defun test (limit)
>   (eval-when-compile
>     (boundp 'parse-sexp-lookup-properties)))

I'm not sure of it but the patch below seems to solve it.
This works for the bug#14646 case[1], too.  WDYT?

[1] <http://thread.gmane.org/gmane.emacs.bugs/80778>

--- lisp/emacs-lisp/byte-run.el~	2013-11-21 22:12:14 +0000
+++ lisp/emacs-lisp/byte-run.el	2013-12-19 23:45:41 +0000
@@ -391,7 +391,7 @@
   "Like `progn', but evaluates the body at compile time if you're compiling.
 Thus, the result of the body appears to the compiler as a quoted constant.
 In interpreted code, this is entirely equivalent to `progn'."
-  (declare (debug (def-body)) (indent 0))
+  (declare (debug (&rest def-form)) (indent 0))
   (list 'quote (eval (cons 'progn body) lexical-binding)))
 
 (defmacro eval-and-compile (&rest body)
--- lisp/progmodes/cc-defs.el~	2013-06-02 22:06:34 +0000
+++ lisp/progmodes/cc-defs.el	2013-12-19 23:45:40 +0000
@@ -1137,7 +1137,7 @@
 ;; Make edebug understand the macros.
 ;(eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
 ;  '(progn
-(def-edebug-spec cc-eval-when-compile t)
+(def-edebug-spec cc-eval-when-compile (&rest def-form))
 (def-edebug-spec c-point t)
 (def-edebug-spec c-set-region-active t)
 (def-edebug-spec c-safe t)