help-gnu-emacs
[Top][All Lists]
Advanced

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

incorrect warning when byte compiling?


From: Richard Hansen
Subject: incorrect warning when byte compiling?
Date: Sun, 24 Jun 2012 14:54:24 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

Hi all,

I'm getting a warning when byte compiling that I think shouldn't be a warning.

I'm using Emacs 23.3.1 on Linux.  If I put the following in foo.el:

    (defun whitespace-redraw ()
      (eval-when-compile (require 'whitespace nil t))
      (when (require 'whitespace nil t)
        (if whitespace-mode
            (whitespace-mode 0))
        (whitespace-mode 1)))

and then byte compile it:

    emacs -Q --batch --eval '(byte-compile-file "foo.el")'

I get the following warning:

    In end of data:
foo.el:7:1:Warning: the function `whitespace-mode' might not be defined at
        runtime.
    Wrote foo.elc

Yes, whitespace-mode can be undefined at runtime, but only if the whitespace feature isn't available. If whitespace is NOT available, the body of the 'when' will not execute, so it won't try to execute the undefined whitespace-mode function. If whitespace IS available, whitespace-mode is guaranteed to be defined. Either way, there's no way Emacs will try to execute an undefined whitespace-mode function.

So why is Emacs printing the warning?

Is this a bug/limitation in the Emacs byte compiler? Or is there a subtle bug in my code?

It's easy enough to silence this warning (e.g., with (when (fboundp 'whitespace-mode) ...)), but I want to know why Emacs thinks this is a problem.

Thanks,
Richard



reply via email to

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