]> code.delx.au - gnu-emacs/blobdiff - doc/lispref/loading.texi
Merge from mainline.
[gnu-emacs] / doc / lispref / loading.texi
index ec10c51b236705e06ad65e32418fa9c5aa474239..ca233ac5f21a41247905309bdc1f0437bccf5efb 100644 (file)
@@ -1,7 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001,
-@c   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+@c Copyright (C) 1990-1995, 1998-1999, 2001-2011
+@c   Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @setfilename ../../info/loading
 @node Loading, Byte Compilation, Customization, Top
@@ -43,9 +43,9 @@ containing Lisp code.
 * Repeated Loading::        Precautions about loading a file twice.
 * Named Features::          Loading a library if it isn't already loaded.
 * Where Defined::           Finding which file defined a certain symbol.
-* Unloading::              How to "unload" a library that was loaded.
-* Hooks for Loading::      Providing code to be run when
-                             particular libraries are loaded.
+* Unloading::               How to "unload" a library that was loaded.
+* Hooks for Loading::       Providing code to be run when
+                              particular libraries are loaded.
 @end menu
 
 @node How Programs Do Loading
@@ -106,6 +106,10 @@ in @code{load-path}, where @code{nil} stands for the default directory.
 @code{load-path}, then all three suffixes in the second directory, and
 so on.  @xref{Library Search}.
 
+Whatever the name under which the file is eventually found, and the
+directory where Emacs found it, Emacs sets the value of the variable
+@code{load-file-name} to that file's name.
+
 If you get a warning that @file{foo.elc} is older than @file{foo.el}, it
 means you should consider recompiling @file{foo.el}.  @xref{Byte
 Compilation}.
@@ -156,6 +160,12 @@ This variable is non-@code{nil} if Emacs is in the process of loading a
 file, and it is @code{nil} otherwise.
 @end defvar
 
+@defvar load-file-name
+When Emacs is in the process of loading a file, this variable's value
+is the name of that file, as Emacs found it during the search
+described earlier in this section.
+@end defvar
+
 @defvar load-read-function
 @anchor{Definition of load-read-function}
 @c do not allow page break at anchor; work around Texinfo deficiency.
@@ -352,6 +362,31 @@ interactively, the argument @var{interactive-call} is @code{t}, and this
 tells @code{locate-library} to display the file name in the echo area.
 @end deffn
 
+@cindex shadowed Lisp files
+@deffn Command list-load-path-shadows &optional stringp
+This command shows a list of @dfn{shadowed} Emacs Lisp files.  A
+shadowed file is one that will not normally be loaded, despite being
+in a directory on @code{load-path}, due to the existence of another
+similarly-named file in a directory earlier on @code{load-path}.
+
+For instance, suppose @code{load-path} is set to
+
+@smallexample
+  ("/opt/emacs/site-lisp" "/usr/share/emacs/23.3/lisp")
+@end smallexample
+
+@noindent
+and that both these directories contain a file named @file{foo.el}.
+Then @code{(require 'foo)} never loads the file in the second
+directory.  Such a situation might indicate a problem in the way Emacs
+was installed.
+
+When called from Lisp, this function prints a message listing the
+shadowed files, instead of displaying them in a buffer.  If the
+optional argument @code{stringp} is non-@code{nil}, it instead returns
+the shadowed files as a string.
+@end deffn
+
 @node Loading Non-ASCII
 @section Loading Non-@acronym{ASCII} Characters
 
@@ -366,13 +401,6 @@ example) is read without decoding, the text of the program will be
 unibyte text, and its string constants will be unibyte strings.
 @xref{Coding Systems}.
 
-  To make the results more predictable, Emacs always performs decoding
-into the multibyte representation when loading Lisp files, even if it
-was started with the @samp{--unibyte} option.  This means that string
-constants with non-@acronym{ASCII} characters translate into multibyte
-strings.  The only exception is when a particular file specifies no
-decoding.
-
   The reason Emacs is designed this way is so that Lisp programs give
 predictable results, regardless of how Emacs was started.  In addition,
 this enables programs that depend on using multibyte text to work even
@@ -823,7 +851,7 @@ without extension.
 @code{load-history}.
 
 @defvar load-history
-This value of this variable is an alist that associates the names of
+The value of this variable is an alist that associates the names of
 loaded library files with the names of the functions and variables
 they defined, as well as the features they provided or required.
 
@@ -958,7 +986,8 @@ example, @file{my_inst.elc} or @file{my_inst.elc.gz} in some directory
 @end example
 
 @var{library} can also be a feature (i.e.@: a symbol), in which case
-@var{form} is evaluated when @code{(provide @var{library})} is called.
+@var{form} is evaluated at the end of any file where
+@code{(provide @var{library})} is called.
 
 An error in @var{form} does not undo the load, but does prevent
 execution of the rest of @var{form}.
@@ -971,10 +1000,6 @@ it immediately---there is no need to wait until the library is loaded.
 If you need to call functions defined by that library, you should load
 the library, preferably with @code{require} (@pxref{Named Features}).
 
-But it is OK to use @code{eval-after-load} in your personal
-customizations if you don't feel that they must meet the design
-standards for programs meant for wider use.
-
 @defvar after-load-alist
 This variable stores an alist built by @code{eval-after-load},
 containing the expressions to evaluate when certain libraries are
@@ -989,7 +1014,3 @@ symbol, and the value is a list of forms.  The forms are evaluated
 when the key matches the absolute true name or feature name of the
 library being loaded.
 @end defvar
-
-@ignore
-   arch-tag: df731f89-0900-4389-a436-9105241b6f7a
-@end ignore