unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Problems with defcustom setter functions during byte-compile
@ 2012-10-06  9:15 David Engster
  2012-10-06 12:44 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: David Engster @ 2012-10-06  9:15 UTC (permalink / raw)
  To: emacs-devel

I'd like to get some input on a problem I'm currently experiencing with
compiling CEDET upstream. Note that the following does not affect the
CEDET in Emacs trunk, since we do not generate the parsers there on the
fly.

The problem is a defcustom in srecode/map.el:

(defcustom srecode-map-load-path
   [... stuff snipped ...]
  :set 'srecode-map-load-path-set)

The :set function `srecode-map-load-path-set' is called as soon as this
file is loaded. This also happens when this file is byte-compiled.
However, this setter function will only work *after* CEDET was
successfully compiled since it depends on a parser which is generated
during build, so this is a typical chicken/egg problem.

While I can carefully rearrange the order of compilation so that this
still works, this is just destined to break regularly. Also, it slows
down compilation because the above is called pretty often.  Hence I
wonder if there's a "clean" way to avoid calling this setter function
during byte-compilation. Is there some kind of flag during
byte-compilation I could use? Or is there some clever 'eval-*' construct
which will fix this?

-David



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problems with defcustom setter functions during byte-compile
  2012-10-06  9:15 Problems with defcustom setter functions during byte-compile David Engster
@ 2012-10-06 12:44 ` Stefan Monnier
  2012-10-06 20:25   ` David Engster
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2012-10-06 12:44 UTC (permalink / raw)
  To: emacs-devel

> (defcustom srecode-map-load-path
>    [... stuff snipped ...]
>   :set 'srecode-map-load-path-set)
> The :set function `srecode-map-load-path-set' is called as soon as this
> file is loaded.

Actually, when the defcustom is executed, the it's the initializer
that's called, and it just so happens that the default initializer in
turn calls the setter.
So you should be able to work around this problem by adding ":initialize
#'custom-initialize-default".


        Stefan



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Problems with defcustom setter functions during byte-compile
  2012-10-06 12:44 ` Stefan Monnier
@ 2012-10-06 20:25   ` David Engster
  0 siblings, 0 replies; 3+ messages in thread
From: David Engster @ 2012-10-06 20:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier writes:
>> (defcustom srecode-map-load-path
>>    [... stuff snipped ...]
>>   :set 'srecode-map-load-path-set)
>> The :set function `srecode-map-load-path-set' is called as soon as this
>> file is loaded.
>
> Actually, when the defcustom is executed, the it's the initializer
> that's called, and it just so happens that the default initializer in
> turn calls the setter.
> So you should be able to work around this problem by adding ":initialize
> #'custom-initialize-default".

Nifty. I didn't know that feature. And while it works as advertised, the
SRecode unit tests now fail. I guess that `srecode-map-load-path-set'
(which calls `srecode-map-update-map') really must be called when
srecode/map is loaded, it just shouldn't happen during byte-compilation...

Anyway, I guess that's more a fault on our side. At least for know I
"solved" this issue by simply setting `srecode-map-load-path' to nil
during byte-compilation.

-David



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-06 20:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-06  9:15 Problems with defcustom setter functions during byte-compile David Engster
2012-10-06 12:44 ` Stefan Monnier
2012-10-06 20:25   ` David Engster

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).