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

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

Re: Eval elisp file automatically


From: Tim X
Subject: Re: Eval elisp file automatically
Date: Sun, 30 Jan 2011 22:42:43 +1100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Andrea Crotti <andrea.crotti.0@gmail.com> writes:

> I have some functions and variables which I only need in one particular
> directory.
>
> Now it would be nice that the first time that I visit a file in that
> subdirectory the file "elisp.el" gets evaluated.
>
> Using find-file-hook might be easy, but How can I make it evaluate only
> once?
>
> Another cool thing would be to reset to the defaut value the variables
> when I'm not, but it's not really necessary...
>

Emacs does support .dir-locals, which provides functionality similar to
file variables, but at the directory level. See the section on
Per-Directory local variables in the manual. However, your request seems
slightly misguided to me. I'm not trying to be rude, but do wonder what
you feel this will achieve or what problem will it address?

My suspicion is there is a either a better solution or you are concerned
about a non-problem for elisp or I'm just not understanding what you are
trying to do. 

The standard ways to address the function issue is to use autoloads or
provide/require, which you either put in a file or possibly a load hook
so that the functions are only loaded when you load some other mode etc. 

Your reference to restoring default values sounds like you may be
talking about buffer local variables, but I'm not sure. These variables
are like other variables, except when you modify them, thos
modifications are local to the buffer in which it occured. IN this way,
the variables sort of have a default 'global' value and a local value.
Any reference made to the variable outside the buffer that has set it as
a local variable will see the global (default) value. Once you set that
variable to a new value, that new value will be seen by code running in
that buffer, but other buffers (who have not set their own local copy)
will see the global value.

Normally, you just don't bother undefining functions or variables. The
effort it takes is not worth the resources saved. 


Tim


-- 
tcross (at) rapttech dot com dot au


reply via email to

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