From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Jos=E9_A=2E_Romero_L=2E?= Newsgroups: gmane.emacs.help Subject: Re: Eval elisp file automatically Date: Mon, 31 Jan 2011 01:35:18 -0800 (PST) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1296466886 30102 80.91.229.12 (31 Jan 2011 09:41:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 31 Jan 2011 09:41:26 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 31 10:41:15 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PjqG2-0005zA-PN for geh-help-gnu-emacs@m.gmane.org; Mon, 31 Jan 2011 10:41:14 +0100 Original-Received: from localhost ([127.0.0.1]:46520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjqG1-0002ci-SM for geh-help-gnu-emacs@m.gmane.org; Mon, 31 Jan 2011 04:41:13 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!v31g2000vbs.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 25 Original-NNTP-Posting-Host: 213.17.133.2 Original-X-Trace: posting.google.com 1296466518 17870 127.0.0.1 (31 Jan 2011 09:35:18 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 31 Jan 2011 09:35:18 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v31g2000vbs.googlegroups.com; posting-host=213.17.133.2; posting-account=mkEKGAoAAACAV2vhv5r9WHXWqsdL_niD User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:2.0b10) Gecko/20100101 Firefox/4.0b10,gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:184714 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:78865 Archived-At: On Jan 30, 12:17=A0pm, Andrea Crotti wrote: > 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? (...) Make your "elisp.el" (provide 'the-stuff-as-an-elisp-feature), then in find-file-hook if you find you're about to visit a file in that directory (require 'the-stuff-as-an-elisp-feature). The (require) mechanism will take care of loading your code only once. Cheers, -- Jos=E9 A. Romero L. escherdragon at gmail "We who cut mere stones must always be envisioning cathedrals." (Quarry worker's creed)