[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Emacs 25.0.94: Is require failing to define macros and functions at

From: Drew Adams
Subject: RE: Emacs 25.0.94: Is require failing to define macros and functions at compile time?
Date: Wed, 29 Jun 2016 15:42:00 -0700 (PDT)

> > Is there a way to have it load the .el version of the file first and
> > then byte-compile it if that is what I want?
> Sure (there is always a way in Emacs...), but I don't think it's a good
> idea to use such a hack just for a more cosmetic purpose.
> IIRC the currently compiled file can be referred to with the variable
> `byte-compile-current-file', even from the file itself.  I don't recall
> the downsides of loading the file while compiling (apart from making
> compiling slow and loading the package unnecessarily when compiling).

>From (elisp) `Named Features':

   When 'require' is used at top level in a file, it takes effect when
 you byte-compile that file (*note Byte Compilation::) as well as when
 you load it.  This is in case the required package contains macros that
 the byte compiler must know about.  It also avoids byte compiler
 warnings for functions and variables defined in the file loaded with

   Although top-level calls to 'require' are evaluated during byte
 compilation, 'provide' calls are not.  Therefore, you can ensure that a
 file of definitions is loaded before it is byte-compiled by including a
 'provide' followed by a 'require' for the same feature, as in the
 following example.

     (provide 'my-feature)  ; Ignored by byte compiler,
                            ;   evaluated by 'load'.
     (require 'my-feature)  ; Evaluated by byte compiler.

 The compiler ignores the 'provide', then processes the 'require' by
 loading the file in question.  Loading the file does execute the
 'provide' call, so the subsequent 'require' call does nothing when the
 file is loaded.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]