[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error: Symbol's value as variable is void
From: |
Kevin Rodgers |
Subject: |
Re: Error: Symbol's value as variable is void |
Date: |
Mon, 28 Mar 2005 13:18:31 -0700 |
User-agent: |
Mozilla Thunderbird 0.9 (X11/20041105) |
Joe Corneli wrote:
> I wrote some code that contains the following forms:
>
> (defvar nero-link-regexp "\\[\\([0-9]+\\)\\]"
> "Regular expression that tells nero what links look like.
> The first parenthesized subexpression is the unique string
> denoting the webpage to load, which will sought among the
> references.")
>
> (defvar nero-font-lock-keywords
> (eval-when-compile
> (list `(,nero-link-regexp . font-lock-keyword-face)))
> "Font lock for `nero-mode'.
> Currently, only numbered links are fontified.")
>
> These work fine for me, but another person using the code reports the
> following error upon byte-compiling:
>
> Compiling file /stor/garray/src/nero.el at Fri Mar 25 08:21:48 2005
> nero.el:295:33:Error: Symbol's value as variable is void:
nero-link-regexp
>
>
> I don't see any such error when I byte compile. I'm just curious to
> know if using `eval-when-compile' here is bad form, or what. I think
> I've seen it being used in other packages in a similar context, but I
> don't understand it well enough to know whether I should be using it
> here.
You don't get an error because you have nero.el[c] already loaded when
you byte compile it, but the other person doesn't. It's more reliable
to byte compile .el files in an uncustomized emacs (i.e. invoked with -q
and perhaps --no-site-file).
> Removing it did make the other user's error go away. I told him to
> create a bug report, but if its just the fault of my bad code, I'd
> like to know. More generally, as a point of style, when is it good to
> use `eval-when-compile'?
Only when you need it. But since the simpler form is equivalent for
your purposes (I assume), why use the more complex eval-when-compile and
backquote form?
(defvar nero-font-lock-keywords
(list (cons nero-link-regexp 'font-lock-keyword-face))
"Font lock for `nero-mode'.
Currently, only numbered links are fontified.")
--
Kevin Rodgers