[PATCH] emacs: Fix "not defined at runtime" warning

Austin Clements amdragon at MIT.EDU
Thu Aug 9 07:12:11 PDT 2012


Quoth Tomi Ollila on Aug 09 at 10:46 am:
> On Thu, Aug 09 2012, Austin Clements <amdragon at MIT.EDU> wrote:
> 
> > Previously, the Emacs byte compiler produced the warning
> >
> >     the function `remove-if-not' might not be defined at runtime.
> >
> > because we only required cl at compile-time (not runtime).  This fixes
> > this warning by requiring cl at runtime, ensuring that the definition
> > of remove-if-not is available.
> > ---
> 
> LGTM. 
> 
> It took me a while to understand this. Now I just don't understand
> how did this work before. And why (require 'cl) is enough as 
> remove-if-not is defined in cl-seq.el -- cl-seq.el requires cl
> but not vice-versa -- or at least I don't see that. Anyway
> (require 'cl) is the common way.

This worked before in practice because 'cl is inevitably loaded by
some package, somewhere, but I'm sure it could be broken by a
sufficiently stripped down Emacs environment.

(require 'cl) is enough because cl.el contains
  (load "cl-loaddefs" nil 'quiet)
and cl-loaddefs.el defines an autoload for remove-if-not that in turn
loads cl-seq the first time remove-if-not is called.

In fact, we *can't* (require 'cl-seq) because cl-seq.el never (provide
'cl-seq)s.  We could (load ...) it, but the fact that it never
provides a package name strongly suggests that the division of cl into
separate files is an implementation detail.

> Tomi
> 
> >  emacs/notmuch-lib.el |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> > index 30db58f..900235b 100644
> > --- a/emacs/notmuch-lib.el
> > +++ b/emacs/notmuch-lib.el
> > @@ -24,7 +24,7 @@
> >  (require 'mm-view)
> >  (require 'mm-decode)
> >  (require 'json)
> > -(eval-when-compile (require 'cl))
> > +(require 'cl)
> >  
> >  (defvar notmuch-command "notmuch"
> >    "Command to run the notmuch binary.")


More information about the notmuch mailing list