* elint and the byte-compiler
@ 2015-06-26 15:48 Emanuel Berg
2015-06-26 17:07 ` Ian Zimmerman
0 siblings, 1 reply; 8+ messages in thread
From: Emanuel Berg @ 2015-06-26 15:48 UTC (permalink / raw)
To: help-gnu-emacs
I just did `elint-directory' on my 3964 lines
of Elisp.
The only warning it found was of the type:
In top level expression:
mail.el:46:Warning: Setting previously unbound symbol: read-mail-command
which was found countless of times.
This sounds sort of the same as the familiar warning
from the byte-compiler:
~/.emacs:25:7:Warning: assignment to free variable `tramp-verbose'
which can be muted either with
(require 'tramp)
or
(defvar tramp-verbose)
Questions:
Is there a difference between an unbound symbol and
a free variable? No? If so, why does the byte-compiler
react to some, but not nearly as many as elint? Is it
because the byte-compiler considers to context whereas
elint only the individual file? Is there any sense
muting the elint warnings as well with the same
method(s)? And what method is prefered, to `require'
or do the `defvar' hack? As for me, I'm fine loading
things when I need them first time (and then have them
loaded) only then if I set the variable before that,
is there a danger what is loaded will in it's own init
process write over what I already set?
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: elint and the byte-compiler
2015-06-26 15:48 elint and the byte-compiler Emanuel Berg
@ 2015-06-26 17:07 ` Ian Zimmerman
2015-06-26 22:27 ` Emanuel Berg
0 siblings, 1 reply; 8+ messages in thread
From: Ian Zimmerman @ 2015-06-26 17:07 UTC (permalink / raw)
To: help-gnu-emacs
On 2015-06-26 17:48 +0200, Emanuel Berg wrote:
> only then if I set the variable before that, is there a danger what is
> loaded will in it's own init process write over what I already set?
Not if the loaded module uses defvar:
(defvar SYMBOL &optional INITVALUE DOCSTRING)
Define SYMBOL as a variable, and return SYMBOL.
You are not required to define a variable in order to use it,
but the definition can supply documentation and an initial value
in a way that tags can recognize.
INITVALUE is evaluated, and used to set SYMBOL, only if SYMBOL's value
is void.
--
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: elint and the byte-compiler
2015-06-26 17:07 ` Ian Zimmerman
@ 2015-06-26 22:27 ` Emanuel Berg
2015-06-26 23:15 ` Ian Zimmerman
0 siblings, 1 reply; 8+ messages in thread
From: Emanuel Berg @ 2015-06-26 22:27 UTC (permalink / raw)
To: help-gnu-emacs
Ian Zimmerman <itz@buug.org> writes:
>> only then if I set the variable before that, is
>> there a danger what is loaded will in it's own init
>> process write over what I already set?
>
> Not if the loaded module uses defvar ...
Is there some fast way of finding out other than
checking the source for each module and variable?
I know of the line "You can customize this variable."
in the help which is a consequence (?) of setting it
up with `defcustom'.
Maybe I should just remove all the `require' stuff and
use `defvar' and see what happens... Or, I should
require *everything* first thing and then be done with
it! (...but I like to think that only beginner
programmers think in binary.)
It would help to know exactly when the byte-compiler
say that free variable stuff, and ditto elint
unbound variable.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: elint and the byte-compiler
2015-06-26 22:27 ` Emanuel Berg
@ 2015-06-26 23:15 ` Ian Zimmerman
2015-06-26 23:19 ` Emanuel Berg
0 siblings, 1 reply; 8+ messages in thread
From: Ian Zimmerman @ 2015-06-26 23:15 UTC (permalink / raw)
To: help-gnu-emacs
On 2015-06-27 00:27 +0200, Emanuel Berg wrote:
Emanuel> only then if I set the variable before that, is there a danger
Emanuel> what is loaded will in it's own init process write over what I
Emanuel> already set?
Ian> Not if the loaded module uses defvar ...
Emanuel> Is there some fast way of finding out other than checking the
Emanuel> source for each module and variable?
Any code which sets global variables unconditionally probably cannot
make it past code review and into Emacs proper, so I wouldn't worry
about this possibility for modules that come with Emacs.
For others, I would try byte-compiling them with a virgin Emacs (ie. one
started with -q). If they misbehave they should cause exactly the same
warning.
--
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: elint and the byte-compiler
2015-06-26 23:15 ` Ian Zimmerman
@ 2015-06-26 23:19 ` Emanuel Berg
2015-06-27 0:18 ` Ian Zimmerman
0 siblings, 1 reply; 8+ messages in thread
From: Emanuel Berg @ 2015-06-26 23:19 UTC (permalink / raw)
To: help-gnu-emacs
Ian Zimmerman <itz@buug.org> writes:
> Any code which sets global variables unconditionally
> probably cannot make it past code review and into
> Emacs proper, so I wouldn't worry about this
> possibility for modules that come with Emacs.
OK - so in other words I can remove all the requires
and to make the byte-compiler shut up just use defvar
before I set the variable.
> For others, I would try byte-compiling them with
> a virgin Emacs (ie. one started with -q). If they
> misbehave they should cause exactly the
> same warning.
OK. Well, the only thing I use along those lines is
Emacs-w3m so it shouldn't be that much work.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: elint and the byte-compiler
2015-06-26 23:19 ` Emanuel Berg
@ 2015-06-27 0:18 ` Ian Zimmerman
2015-06-27 1:40 ` Emanuel Berg
2015-06-27 1:45 ` Emanuel Berg
0 siblings, 2 replies; 8+ messages in thread
From: Ian Zimmerman @ 2015-06-27 0:18 UTC (permalink / raw)
To: help-gnu-emacs
On 2015-06-27 01:19 +0200, Emanuel Berg wrote:
> OK - so in other words I can remove all the requires and to make the
> byte-compiler shut up just use defvar before I set the variable.
Right, that's what I do and it works. Though my setup seems to be much
simpler than yours :-)
--
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: elint and the byte-compiler
2015-06-27 0:18 ` Ian Zimmerman
@ 2015-06-27 1:40 ` Emanuel Berg
2015-06-27 1:45 ` Emanuel Berg
1 sibling, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2015-06-27 1:40 UTC (permalink / raw)
To: help-gnu-emacs
Ian Zimmerman <itz@buug.org> writes:
>> OK - so in other words I can remove all the
>> requires and to make the byte-compiler shut up just
>> use defvar before I set the variable.
>
> Right, that's what I do and it works. Though my
> setup seems to be much simpler than yours :-)
Yeah, Emacs is a lifestyle to many and a religion to
some. To me it is a place to be a programmer. It is
just like the shell (zsh) where I have tons of stuff
as well.
Many years ago I did apply for random programming
jobs. I guess I should thank them for turning me down,
because otherwise I would have been a Java and PHP
programmer by now, instead of a Lisper ... Ha! What am
I saying? That would never have happened.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: elint and the byte-compiler
2015-06-27 0:18 ` Ian Zimmerman
2015-06-27 1:40 ` Emanuel Berg
@ 2015-06-27 1:45 ` Emanuel Berg
1 sibling, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2015-06-27 1:45 UTC (permalink / raw)
To: help-gnu-emacs
Ian Zimmerman <itz@buug.org> writes:
> Right, that's what I do and it works. Though my
> setup seems to be much simpler than yours :-)
I have now waded through all my source and examined
the `require' situation, and in nine out of ten cases
it wasn't an issue of variables, but *functions*!
In but a few cases, it was a matter of variables, only
then there were tons of them and they belonged to
modules I use every session (e.g., ERC) so I thought
it still cleaner and more efficient to use
`require' there.
In fewer cases still it was a matter of one or two
variables. I changed those from require to `defvar'.
I don't see how this surgical procedure will have any
practical impact whatsoever, but yeah, it is still
interesting to reason and be active about
the material.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-06-27 1:45 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26 15:48 elint and the byte-compiler Emanuel Berg
2015-06-26 17:07 ` Ian Zimmerman
2015-06-26 22:27 ` Emanuel Berg
2015-06-26 23:15 ` Ian Zimmerman
2015-06-26 23:19 ` Emanuel Berg
2015-06-27 0:18 ` Ian Zimmerman
2015-06-27 1:40 ` Emanuel Berg
2015-06-27 1:45 ` Emanuel Berg
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.