From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: Very basic questions. Date: Mon, 18 Sep 2006 15:42:52 +1000 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <873bapafxf.fsf@lion.rapttech.com.au> References: <450bdfd3$0$75037$14726298@news.sunsite.dk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1158561632 15535 80.91.229.2 (18 Sep 2006 06:40:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 18 Sep 2006 06:40:32 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 18 08:40:31 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GPCnn-0005jF-Mn for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Sep 2006 08:40:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GPCnn-00022q-5h for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Sep 2006 02:40:23 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news4.google.com!news.glorb.com!sn-xt-sjc-05!sn-xt-sjc-01!sn-xt-sjc-07!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:4rFxMBusaCB+b7nYgSNgcA8kudE= Original-X-Complaints-To: abuse@supernews.com Original-Lines: 91 Original-Xref: shelby.stanford.edu gnu.emacs.help:141823 Original-To: help-gnu-emacs@gnu.org 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:37445 Archived-At: "jronald" writes: > "Colin S. Miller" > ??????:450bdfd3$0$75037$14726298@news.sunsite.dk... >>> >>> In runtime, how does "require" know where the feature list is? There is >>> only machine code then. >>> >> John, >> >> (require 'feature) >> searches the paths listed in 'load-path', >> this can be added to using (add-path). >> It looks for a file called "feature.el" or "feature.elc". >> >> > Do you mean that "provide" modifies the files, both .el and .elc? I just > can't imagine. > >> Emacs packages can either be in source-code, >> which have an extension '.el', or be pre-compiled, >> where they have the extension '.elc'. >> >> Pre-compiled packages run faster than packages dynamically >> compiled from source. >> >> The pre-compiled emacs tends to come with its packages pre-compiled >> as well, there will be sources for the packages where you got >> emacs from. >> >> HTH, >> Coin S. Miller >> >> -- >> Replace the obvious in my email address with the first three letters of >> the hostname to reply. > > John, I htink your over thinking this whole issue. Its very basic really. When you create an emacs lisp package, you add the following line. Often it is added at the end of the file so that it doesn't run unless the file loads correctly (provide 'feature) where 'feature is some symbol/name that reflects what is provided by the code in that file. When this file is loaded, emacs will keep track of this information and will know that this "feature" has been added. The other side of the coin is "require', usually put at the top of a file and indicates some feature or support library your code will require, for example (require 'feature) When you load a file with this requirement into emacs, it will first check to see if the feature has already been loaded (see C-h f featurep for details of a predicate that can be used to determine if a feature has been loaded). If the feature/library has not been loaded, emacs will search the load-path for a file called feature.el or feature.elc. If it finds one, it will load that file - note that that file may also include more require statements, resulting in other files being loaded. This whole mechanism is a bit similar to using C macros to ensure header files are loaded and only loaded once. In a C header file feature.h, you might have a line like #define _FEATURE_H_ and in one of your other .c or .h files, you might have a line like #ifndef _FEATURE_H_ #include "feature.h" #endif The issues regarding whether the files are byte compiled or just interpreted are pretty much irrelevant and can be ignored with respect to this mechanism. HTH Tim -- tcross (at) rapttech dot com dot au