unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tim X <timx@nospam.dev.null>
Subject: Re: Very basic questions.
Date: Mon, 18 Sep 2006 15:42:52 +1000	[thread overview]
Message-ID: <873bapafxf.fsf@lion.rapttech.com.au> (raw)
In-Reply-To: eegouu$i0j$1@news.yaako.com

"jronald" <followait@163.com> writes:

> "Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk> 
> ??????: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

  parent reply	other threads:[~2006-09-18  5:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-15 19:07 Very basic questions jronald
2006-09-16  3:40 ` John Sullivan
     [not found] ` <mailman.7000.1158379340.9609.help-gnu-emacs@gnu.org>
2006-09-16 11:18   ` jronald
2006-09-16 11:28     ` Colin S. Miller
2006-09-16 11:59       ` jronald
2006-09-16 12:43         ` Colin S. Miller
2006-09-16 18:13           ` jronald
2006-09-16 18:42             ` Colin S. Miller
2006-09-18  5:42         ` Tim X [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-09-15 20:22 Jay Bingham
     [not found] <mailman.6992.1158351893.9609.help-gnu-emacs@gnu.org>
2006-09-15 20:48 ` jronald
2006-09-15 20:50 ` jronald

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=873bapafxf.fsf@lion.rapttech.com.au \
    --to=timx@nospam.dev.null \
    /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).