In two of my packages I have a macro where the body depends on a variable defined in a defcustom form.

When installing the packages from Melpa, the byte-compilation ends with:

Error: Symbol's value as variable is void: my-defcustom-variable

Then, manually byte-compiling the file by opening it in a buffer works.

I tried with an autoload cookie but still have the same behavior.

I'm missing something important here.

  • 1
    Depending on a defcustom in a macro body is a strange thing to do, for the defcustom will only ever come into effect during byte-compilation (where the macro is expanded). This doesn't seem to make much sense to me. – user227 Nov 17 '14 at 14:18
  • Thank you Sebastian, you are right and it explains a lot of things. – syl20bnr Nov 17 '14 at 15:11

The defcustom expression are not evaluated during byte-compilation, so when your macro is expanded, the variable does not exist yet because that defcustom was compiled but not run. You can either move the defcustom to another file (which you then require at the beginning of your file), or you can wrap the defcustom inside eval-and-compile.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.