* Conditional compilation to avoid "assignment to free variable"
@ 2008-09-24 19:46 Michael Hoffman
2008-09-24 19:54 ` Joost Diepenmaat
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Michael Hoffman @ 2008-09-24 19:46 UTC (permalink / raw)
To: help-gnu-emacs
I use the same .emacs file on multiple systems, and each have various
packages installed. There are various forms in my .emacs to only
interact with these packages if they are actually installed:
(when (locate-library "auctex")
(load "auctex.el" nil t t)
(setq TeX-auto-save t))
When I byte-compile, however, I get a warning like this:
emacs.el:320:9:Warning: assignment to free variable `TeX-auto-save'
Is there a way to skip over that form at compile time if the library
cannot be found? I tried various permutations of using
eval-when-compile, but I still get the warning.
I suppose the other solution is to wrap the setq in a boundp check, but
this seems silly as the result of the boundp check will be the same as
the result of locate-library.
In this case, I may be able to use a custom variable instead but I am
looking for a more general solution.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Conditional compilation to avoid "assignment to free variable"
2008-09-24 19:46 Conditional compilation to avoid "assignment to free variable" Michael Hoffman
@ 2008-09-24 19:54 ` Joost Diepenmaat
2008-09-24 21:34 ` Chetan
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Joost Diepenmaat @ 2008-09-24 19:54 UTC (permalink / raw)
To: help-gnu-emacs
Michael Hoffman <4g4trz802@sneakemail.com> writes:
> I use the same .emacs file on multiple systems, and each have various
> packages installed. There are various forms in my .emacs to only
> interact with these packages if they are actually installed:
>
> (when (locate-library "auctex")
> (load "auctex.el" nil t t)
> (setq TeX-auto-save t))
>
> When I byte-compile, however, I get a warning like this:
>
> emacs.el:320:9:Warning: assignment to free variable `TeX-auto-save'
>
> Is there a way to skip over that form at compile time if the library
> cannot be found? I tried various permutations of using
> eval-when-compile, but I still get the warning.
Did you try the following?
(eval-when-compile
(require 'my-macro-package))
(when (locate-library "auctex")
(setq TeX-auto-save t))
HTH,
Joost.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Conditional compilation to avoid "assignment to free variable"
2008-09-24 19:46 Conditional compilation to avoid "assignment to free variable" Michael Hoffman
2008-09-24 19:54 ` Joost Diepenmaat
@ 2008-09-24 21:34 ` Chetan
2008-09-24 22:09 ` Glenn Morris
2008-09-25 0:11 ` Chetan
3 siblings, 0 replies; 5+ messages in thread
From: Chetan @ 2008-09-24 21:34 UTC (permalink / raw)
To: help-gnu-emacs
Michael Hoffman <4g4trz802@sneakemail.com> writes:
> I use the same .emacs file on multiple systems, and each have various packages
> installed. There are various forms in my .emacs to only interact with these
> packages if they are actually installed:
>
> (when (locate-library "auctex")
> (load "auctex.el" nil t t)
> (setq TeX-auto-save t))
>
> When I byte-compile, however, I get a warning like this:
>
> emacs.el:320:9:Warning: assignment to free variable `TeX-auto-save'
>
> Is there a way to skip over that form at compile time if the library cannot be
> found? I tried various permutations of using eval-when-compile, but I still get
> the warning.
>
> I suppose the other solution is to wrap the setq in a boundp check, but this
> seems silly as the result of the boundp check will be the same as the result of
> locate-library.
>
> In this case, I may be able to use a custom variable instead but I am looking
> for a more general solution.
C-h f eval-when-compile
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Conditional compilation to avoid "assignment to free variable"
2008-09-24 19:46 Conditional compilation to avoid "assignment to free variable" Michael Hoffman
2008-09-24 19:54 ` Joost Diepenmaat
2008-09-24 21:34 ` Chetan
@ 2008-09-24 22:09 ` Glenn Morris
2008-09-25 0:11 ` Chetan
3 siblings, 0 replies; 5+ messages in thread
From: Glenn Morris @ 2008-09-24 22:09 UTC (permalink / raw)
To: help-gnu-emacs
Michael Hoffman wrote:
> (when (locate-library "auctex")
> (load "auctex.el" nil t t)
> (setq TeX-auto-save t))
>
> When I byte-compile, however, I get a warning like this:
>
> emacs.el:320:9:Warning: assignment to free variable `TeX-auto-save'
Byte-compiling your .emacs is pretty much a waste of time (you've
probably already invested more time in it than it might ever save you).
Worry about warnings while doing so is really a waste of time; but the
standard method of suppressing free variable warnings is
(defvar TeX-auto-save)
(setq TeX-auto-save t)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Conditional compilation to avoid "assignment to free variable"
2008-09-24 19:46 Conditional compilation to avoid "assignment to free variable" Michael Hoffman
` (2 preceding siblings ...)
2008-09-24 22:09 ` Glenn Morris
@ 2008-09-25 0:11 ` Chetan
3 siblings, 0 replies; 5+ messages in thread
From: Chetan @ 2008-09-25 0:11 UTC (permalink / raw)
To: help-gnu-emacs
Michael Hoffman <4g4trz802@sneakemail.com> writes:
> I use the same .emacs file on multiple systems, and each have various packages
> installed. There are various forms in my .emacs to only interact with these
> packages if they are actually installed:
>
> (when (locate-library "auctex")
> (load "auctex.el" nil t t)
> (setq TeX-auto-save t))
>
> When I byte-compile, however, I get a warning like this:
>
> emacs.el:320:9:Warning: assignment to free variable `TeX-auto-save'
>
> Is there a way to skip over that form at compile time if the library cannot be
> found? I tried various permutations of using eval-when-compile, but I still get
> the warning.
>
> I suppose the other solution is to wrap the setq in a boundp check, but this
> seems silly as the result of the boundp check will be the same as the result of
> locate-library.
>
> In this case, I may be able to use a custom variable instead but I am looking
> for a more general solution.
I don't have auctex installed, so I cannot check. However, I am
wondering, what is this variable used for? Does tex mode not use
auto-save-mode? Or if it is for saving file before running tex, does is
not use the compile infrastructure?
Chetan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-09-25 0:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-24 19:46 Conditional compilation to avoid "assignment to free variable" Michael Hoffman
2008-09-24 19:54 ` Joost Diepenmaat
2008-09-24 21:34 ` Chetan
2008-09-24 22:09 ` Glenn Morris
2008-09-25 0:11 ` Chetan
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.