comparison lispref/loading.texi @ 89910:548375b6b1f8

Update unicode branch
author Miles Bader <miles@gnu.org>
date Mon, 19 Apr 2004 07:01:43 +0000
parents 375f2633d815
children 4c90ffeb71c5
comparison
equal deleted inserted replaced
89909:68c22ea6027c 89910:548375b6b1f8
35 containing Lisp code. 35 containing Lisp code.
36 36
37 @menu 37 @menu
38 * How Programs Do Loading:: The @code{load} function and others. 38 * How Programs Do Loading:: The @code{load} function and others.
39 * Library Search:: Finding a library to load. 39 * Library Search:: Finding a library to load.
40 * Loading Non-ASCII:: Non-@sc{ascii} characters in Emacs Lisp files. 40 * Loading Non-ASCII:: Non-@acronym{ASCII} characters in Emacs Lisp files.
41 * Autoload:: Setting up a function to autoload. 41 * Autoload:: Setting up a function to autoload.
42 * Repeated Loading:: Precautions about loading a file twice. 42 * Repeated Loading:: Precautions about loading a file twice.
43 * Named Features:: Loading a library if it isn't already loaded. 43 * Named Features:: Loading a library if it isn't already loaded.
44 * Unloading:: How to ``unload'' a library that was loaded. 44 * Unloading:: How to ``unload'' a library that was loaded.
45 * Hooks for Loading:: Providing code to be run when 45 * Hooks for Loading:: Providing code to be run when
138 @defvar load-in-progress 138 @defvar load-in-progress
139 This variable is non-@code{nil} if Emacs is in the process of loading a 139 This variable is non-@code{nil} if Emacs is in the process of loading a
140 file, and it is @code{nil} otherwise. 140 file, and it is @code{nil} otherwise.
141 @end defvar 141 @end defvar
142 142
143 @anchor{Definition of load-read-function}
143 @defvar load-read-function 144 @defvar load-read-function
144 This variable specifies an alternate expression-reading function for 145 This variable specifies an alternate expression-reading function for
145 @code{load} and @code{eval-region} to use instead of @code{read}. 146 @code{load} and @code{eval-region} to use instead of @code{read}.
146 The function should accept one argument, just as @code{read} does. 147 The function should accept one argument, just as @code{read} does.
147 148
148 Normally, the variable's value is @code{nil}, which means those 149 Normally, the variable's value is @code{nil}, which means those
149 functions should use @code{read}. 150 functions should use @code{read}.
150 151
151 @strong{Note:} Instead of using this variable, it is cleaner to use 152 Instead of using this variable, it is cleaner to use another, newer
152 another, newer feature: to pass the function as the @var{read-function} 153 feature: to pass the function as the @var{read-function} argument to
153 argument to @code{eval-region}. @xref{Eval}. 154 @code{eval-region}. @xref{Definition of eval-region,, Eval}.
154 @end defvar 155 @end defvar
155 156
156 For information about how @code{load} is used in building Emacs, see 157 For information about how @code{load} is used in building Emacs, see
157 @ref{Building Emacs}. 158 @ref{Building Emacs}.
158 159
170 directory). 171 directory).
171 @end defopt 172 @end defopt
172 173
173 The value of @code{load-path} is initialized from the environment 174 The value of @code{load-path} is initialized from the environment
174 variable @code{EMACSLOADPATH}, if that exists; otherwise its default 175 variable @code{EMACSLOADPATH}, if that exists; otherwise its default
175 value is specified in @file{emacs/src/paths.h} when Emacs is built. 176 value is specified in @file{emacs/src/epaths.h} when Emacs is built.
176 Then the list is expanded by adding subdirectories of the directories 177 Then the list is expanded by adding subdirectories of the directories
177 in the list. 178 in the list.
178 179
179 The syntax of @code{EMACSLOADPATH} is the same as used for @code{PATH}; 180 The syntax of @code{EMACSLOADPATH} is the same as used for @code{PATH};
180 @samp{:} (or @samp{;}, according to the operating system) separates 181 @samp{:} (or @samp{;}, according to the operating system) separates
287 @end deffn 288 @end deffn
288 289
289 @defvar load-suffixes 290 @defvar load-suffixes
290 This variable is a list of suffixes (strings) that @code{load} should 291 This variable is a list of suffixes (strings) that @code{load} should
291 try adding to the specified file name. The default value is 292 try adding to the specified file name. The default value is
292 @code{(".el" ".elc")}. There is no need to include the null suffix. 293 @code{(".elc" ".el")}. There is no need to include the null suffix.
293 @end defvar 294 @end defvar
294 295
295 @node Loading Non-ASCII 296 @node Loading Non-ASCII
296 @section Loading Non-@sc{ascii} Characters 297 @section Loading Non-@acronym{ASCII} Characters
297 298
298 When Emacs Lisp programs contain string constants with non-@sc{ascii} 299 When Emacs Lisp programs contain string constants with non-@acronym{ASCII}
299 characters, these can be represented within Emacs either as unibyte 300 characters, these can be represented within Emacs either as unibyte
300 strings or as multibyte strings (@pxref{Text Representations}). Which 301 strings or as multibyte strings (@pxref{Text Representations}). Which
301 representation is used depends on how the file is read into Emacs. If 302 representation is used depends on how the file is read into Emacs. If
302 it is read with decoding into multibyte representation, the text of the 303 it is read with decoding into multibyte representation, the text of the
303 Lisp program will be multibyte text, and its string constants will be 304 Lisp program will be multibyte text, and its string constants will be
307 @xref{Coding Systems}. 308 @xref{Coding Systems}.
308 309
309 To make the results more predictable, Emacs always performs decoding 310 To make the results more predictable, Emacs always performs decoding
310 into the multibyte representation when loading Lisp files, even if it 311 into the multibyte representation when loading Lisp files, even if it
311 was started with the @samp{--unibyte} option. This means that string 312 was started with the @samp{--unibyte} option. This means that string
312 constants with non-@sc{ascii} characters translate into multibyte 313 constants with non-@acronym{ASCII} characters translate into multibyte
313 strings. The only exception is when a particular file specifies no 314 strings. The only exception is when a particular file specifies no
314 decoding. 315 decoding.
315 316
316 The reason Emacs is designed this way is so that Lisp programs give 317 The reason Emacs is designed this way is so that Lisp programs give
317 predictable results, regardless of how Emacs was started. In addition, 318 predictable results, regardless of how Emacs was started. In addition,
319 in a unibyte Emacs. Of course, such programs should be designed to 320 in a unibyte Emacs. Of course, such programs should be designed to
320 notice whether the user prefers unibyte or multibyte text, by checking 321 notice whether the user prefers unibyte or multibyte text, by checking
321 @code{default-enable-multibyte-characters}, and convert representations 322 @code{default-enable-multibyte-characters}, and convert representations
322 appropriately. 323 appropriately.
323 324
324 In most Emacs Lisp programs, the fact that non-@sc{ascii} strings are 325 In most Emacs Lisp programs, the fact that non-@acronym{ASCII} strings are
325 multibyte strings should not be noticeable, since inserting them in 326 multibyte strings should not be noticeable, since inserting them in
326 unibyte buffers converts them to unibyte automatically. However, if 327 unibyte buffers converts them to unibyte automatically. However, if
327 this does make a difference, you can force a particular Lisp file to be 328 this does make a difference, you can force a particular Lisp file to be
328 interpreted as unibyte by writing @samp{-*-unibyte: t;-*-} in a 329 interpreted as unibyte by writing @samp{-*-unibyte: t;-*-} in a
329 comment on the file's first line. With that designator, the file will 330 comment on the file's first line. With that designator, the file will
330 unconditionally be interpreted as unibyte, even in an ordinary 331 unconditionally be interpreted as unibyte, even in an ordinary
331 multibyte Emacs session. This can matter when making keybindings to 332 multibyte Emacs session. This can matter when making keybindings to
332 non-@sc{ascii} characters written as @code{?v@var{literal}}. 333 non-@acronym{ASCII} characters written as @code{?v@var{literal}}.
333 334
334 @node Autoload 335 @node Autoload
335 @section Autoload 336 @section Autoload
336 @cindex autoload 337 @cindex autoload
337 338
654 The argument @var{feature} must be a symbol. @code{provide} returns 655 The argument @var{feature} must be a symbol. @code{provide} returns
655 @var{feature}. 656 @var{feature}.
656 657
657 If provided, @var{subfeatures} should be a list of symbols indicating 658 If provided, @var{subfeatures} should be a list of symbols indicating
658 a set of specific subfeatures provided by this version of @var{feature}. 659 a set of specific subfeatures provided by this version of @var{feature}.
660 You can test the presence of a subfeature using @code{featurep}.
659 661
660 @smallexample 662 @smallexample
661 features 663 features
662 @result{} (bar bish) 664 @result{} (bar bish)
663 665
666 features 668 features
667 @result{} (foo bar bish) 669 @result{} (foo bar bish)
668 @end smallexample 670 @end smallexample
669 671
670 When a file is loaded to satisfy an autoload, and it stops due to an 672 When a file is loaded to satisfy an autoload, and it stops due to an
671 error in the evaluating its contents, any function definitions or 673 error in the evaluation of its contents, any function definitions or
672 @code{provide} calls that occurred during the load are undone. 674 @code{provide} calls that occurred during the load are undone.
673 @xref{Autoload}. 675 @xref{Autoload}.
674 @end defun 676 @end defun
675 677
676 @defun require feature &optional filename noerror 678 @defun require feature &optional filename noerror
721 library with @code{defun}, @code{defalias}, @code{defsubst}, 723 library with @code{defun}, @code{defalias}, @code{defsubst},
722 @code{defmacro}, @code{defconst}, @code{defvar}, and @code{defcustom}. 724 @code{defmacro}, @code{defconst}, @code{defvar}, and @code{defcustom}.
723 It then restores any autoloads formerly associated with those symbols. 725 It then restores any autoloads formerly associated with those symbols.
724 (Loading saves these in the @code{autoload} property of the symbol.) 726 (Loading saves these in the @code{autoload} property of the symbol.)
725 727
728 @vindex unload-feature-special-hooks
726 Before restoring the previous definitions, @code{unload-feature} runs 729 Before restoring the previous definitions, @code{unload-feature} runs
727 @code{remove-hook} to remove functions in the library from certain 730 @code{remove-hook} to remove functions in the library from certain
728 hooks. These hooks include variables whose names end in @samp{hook} or 731 hooks. These hooks include variables whose names end in @samp{hook}
729 @samp{-hooks}, plus those listed in @code{loadhist-special-hooks}. This 732 or @samp{-hooks}, plus those listed in
730 is to prevent Emacs from ceasing to function because important hooks 733 @code{unload-feature-special-hooks}. This is to prevent Emacs from
731 refer to functions that are no longer defined. 734 ceasing to function because important hooks refer to functions that
735 are no longer defined.
732 736
733 @vindex @var{feature}-unload-hook 737 @vindex @var{feature}-unload-hook
734 If these measures are not sufficient to prevent malfunction, a library 738 If these measures are not sufficient to prevent malfunction, a library
735 can define an explicit unload hook. If @code{@var{feature}-unload-hook} 739 can define an explicit unload hook. If @code{@var{feature}-unload-hook}
736 is defined, it is run as a normal hook before restoring the previous 740 is defined, it is run as a normal hook before restoring the previous
784 788
785 The command @code{eval-region} updates @code{load-history}, but does so 789 The command @code{eval-region} updates @code{load-history}, but does so
786 by adding the symbols defined to the element for the file being visited, 790 by adding the symbols defined to the element for the file being visited,
787 rather than replacing that element. @xref{Eval}. 791 rather than replacing that element. @xref{Eval}.
788 792
789 Preloaded libraries don't contribute initially to @code{load-history}. 793 @defvar unload-feature-special-hooks
790 Instead, preloading writes information about preloaded libraries into a
791 file, which can be loaded later on to add information to
792 @code{load-history} describing the preloaded files. This file is
793 installed in @code{exec-directory} and has a name of the form
794 @file{fns-@var{emacsversion}.el}.
795
796 @findex symbol-file
797 See the source for the function @code{symbol-file}, for an example of
798 code that loads this file to find functions in preloaded libraries.
799
800 @defvar loadhist-special-hooks
801 This variable holds a list of hooks to be scanned before unloading a 794 This variable holds a list of hooks to be scanned before unloading a
802 library, to remove functions defined in the library. 795 library, to remove functions defined in the library.
803 @end defvar 796 @end defvar
804 797
805 @node Hooks for Loading 798 @node Hooks for Loading
850 The function @code{load} checks @code{after-load-alist} in order to 843 The function @code{load} checks @code{after-load-alist} in order to
851 implement @code{eval-after-load}. 844 implement @code{eval-after-load}.
852 @end defvar 845 @end defvar
853 846
854 @c Emacs 19 feature 847 @c Emacs 19 feature
848
849 @ignore
850 arch-tag: df731f89-0900-4389-a436-9105241b6f7a
851 @end ignore