unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tim X <timx@nospam.dev.null>
To: help-gnu-emacs@gnu.org
Subject: Re: Eval elisp file automatically
Date: Sun, 30 Jan 2011 22:42:43 +1100	[thread overview]
Message-ID: <8739oaboss.fsf@puma.rapttech.com.au> (raw)
In-Reply-To: mailman.4.1296386344.21090.help-gnu-emacs@gnu.org

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	other threads:[~2011-01-30 11:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.4.1296386344.21090.help-gnu-emacs@gnu.org>
2011-01-30 11:42 ` Tim X [this message]
2011-02-08 14:54   ` Eval elisp file automatically Andrea Crotti
2011-02-08 15:38     ` Andrea Crotti
2011-02-08 17:54       ` Kevin Rodgers
2011-01-31  9:35 ` José A. Romero L.
2011-01-31 16:20 ` Stefan Monnier
2011-01-30 11:17 Andrea Crotti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8739oaboss.fsf@puma.rapttech.com.au \
    --to=timx@nospam.dev.null \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).