2

I recently encountered a situation in which specifying a :set function for a defcustom raised a Symbol's function definition is void error.

This is because the :set function relies on another function in the same package, which is not yet loaded when the defcustom is initialized.

The way I handled this is to explicitly define the :initialize function to be custom-initialize-default. Is this the best way? If I wanted to use the :set function for initialization, how best to do that[1]?

[1]: Elisp does not have forward declaration AFAIK; declare-function doesn't seem to work for functions in the same file

2

Yes, if the :set function is not appropriate also for initialization, explicitly provide a different :initialize function. Using custom-initialize-default is a common use case for this.

If you really do not want to do that, but you want to use just :set, then your :set function will need to do the necessary initialization, either conditionally or systematically. You might have a use case for this, but it would likely be unusual. It is by design that initialization stuff is separated from the rest, by making :initialize available.

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.