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

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

Re: Compilation warnings of ELisp seem wrong and misleading


From: Emanuel Berg
Subject: Re: Compilation warnings of ELisp seem wrong and misleading
Date: Tue, 31 Mar 2015 02:53:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

"Ludwig, Mark" <ludwig.mark@siemens.com> writes:

> emacs.el:255:10:Warning: reference to free variable
> `if' emacs.el:219:8:Warning: reference to free
> variable `save-excursion' emacs.el:331:41:Warning:
> reference to free variable `forward-char'
> emacs.el:261:17:Warning: reference to free variable
> `insert' emacs.el:261:17:Warning: reference to free
> variable `forward-sexp'
>
> Those are all valid functions. For example, here are
> lines 255-258:
>
> (if (not (= ans ?q)) (progn (goto-char found-start)
> (delete-region found-start found-end)))
>
> This is inside a large-ish "let*" form (111 lines).

It shouldn't say that of functions. Are you sure the
syntax is correct?

Nonetheless, I agree that the messages from the
compiler are sometimes cryptic and sometimes annoying.
But I've never experienced such crazy messages as
you report!

As for "should you compile your code?": one of the
reasons to do that apart from the supposed but seldom
noticed gains is that you can improve the quality of
your code and become a better lisper. It is
automatized feedback. And, because of that, it is even
more important that the error/warning messages
are understandable.

If you get the free variable warning when it is indeed
a variable that is mentioned, use the help -
`describe-variable' - to find out where it is defined,
then put (require 'library) above. If you don't want
to do that - for example for infrequently used modes -
use `defvar' yourself, e.g.

    (defvar ada-mode-hook)
    (setq ada-mode-hook
              (lambda ()
                (enable-line-mode)
                (setq ada-auto-case nil)
                (disable-super-global-keys) ))

> emacs.el:1326:76:Warning: Use `with-current-buffer'
> rather than save-excursion+set-buffer

Apart from them not adding even a single line
explanation why you should "rather" do that, this
warning is clear: instead of first `save-excursion'
(which has to do with point movement) and then
`set-buffer', you do `with-current-buffer'.
Those stuff do not seem to relate (to me), which is
why I'd be happy to see an explanation, but apparently
it is an intuitive (bad) thing to do, which they have
seen often, hence the warning.

> Mark Ludwig Lifecycle Coll Product Lifecycle
> Management
>
> Siemens Industry Sector Siemens Product Lifecycle
> Management Software Inc. 5939 Rice Creek Parkway
> Shoreview, MN 55126 United States Tel. :+1 (651)
> 855-6140 Fax :+1 (651) 855-6280
> ludwig.mark@siemens.com www.siemens.com/plm

Hint: Put your signature on a new line immediately
under two dashes and a whitespace, i.e. "-- ".
Go to this page [1] and make a search for
"Signature Convention" if you like details.

[1] http://www.ietf.org/rfc/rfc3676.txt

-- 
underground experts united
http://user.it.uu.se/~embe8573


reply via email to

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