aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-02-10 15:57:21 +0800
committerChong Yidong2012-02-10 15:57:21 +0800
commit6c1e4b46424d7554fcaa42ab78b9f313e7bd32ea (patch)
treeb2a47d8c1fac9a3d956f8787a496cba87b44f938
parent104dc9c6226ba6ac48814e2212ecd933d2e58e3d (diff)
downloademacs-6c1e4b46424d7554fcaa42ab78b9f313e7bd32ea.tar.gz
emacs-6c1e4b46424d7554fcaa42ab78b9f313e7bd32ea.zip
Update Loading chapter of Emacs manual.
* doc/emacs/loading.texi (Loading): Don't emphasize "library" terminology. (Library Search): load-path is not a user option. Mention role of -L option and packages. Improve examples. (Loading Non-ASCII): Don't mention unibyte Emacs, which is obsolete. (Autoload): Minor clarifications.
-rw-r--r--admin/FOR-RELEASE2
-rw-r--r--doc/lispref/ChangeLog9
-rw-r--r--doc/lispref/loading.texi173
-rw-r--r--lisp/help-fns.el19
4 files changed, 92 insertions, 111 deletions
diff --git a/admin/FOR-RELEASE b/admin/FOR-RELEASE
index e2ce5c59ff3..58662acb604 100644
--- a/admin/FOR-RELEASE
+++ b/admin/FOR-RELEASE
@@ -206,7 +206,7 @@ internals.texi
206intro.texi cyd 206intro.texi cyd
207keymaps.texi 207keymaps.texi
208lists.texi cyd 208lists.texi cyd
209loading.texi 209loading.texi cyd
210locals.texi 210locals.texi
211macros.texi cyd 211macros.texi cyd
212maps.texi 212maps.texi
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index a823f4272fc..9e6ecdec16a 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,12 @@
12012-02-10 Chong Yidong <cyd@gnu.org>
2
3 * loading.texi (Loading): Don't emphasize "library" terminology.
4 (Library Search): load-path is not a user option. Mention role of
5 -L option and packages. Improve examples.
6 (Loading Non-ASCII): Don't mention unibyte Emacs, which is
7 obsolete.
8 (Autoload): Minor clarifications.
9
12012-02-10 Glenn Morris <rgm@gnu.org> 102012-02-10 Glenn Morris <rgm@gnu.org>
2 11
3 * modes.texi (Basic Major Modes): Mention tabulated-list-mode. 12 * modes.texi (Basic Major Modes): Mention tabulated-list-mode.
diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi
index 0b822751df6..3c2fa60248e 100644
--- a/doc/lispref/loading.texi
+++ b/doc/lispref/loading.texi
@@ -10,9 +10,10 @@
10@cindex library 10@cindex library
11@cindex Lisp library 11@cindex Lisp library
12 12
13 Loading a file of Lisp code means bringing its contents into the Lisp 13 Loading a file of Lisp code means bringing its contents into the
14environment in the form of Lisp objects. Emacs finds and opens the 14Lisp environment in the form of Lisp objects. Emacs finds and opens
15file, reads the text, evaluates each form, and then closes the file. 15the file, reads the text, evaluates each form, and then closes the
16file. Such a file is also called a @dfn{Lisp library}.
16 17
17 The load functions evaluate all the expressions in a file just 18 The load functions evaluate all the expressions in a file just
18as the @code{eval-buffer} function evaluates all the 19as the @code{eval-buffer} function evaluates all the
@@ -29,11 +30,6 @@ into a buffer and evaluated there. (Indeed, most code is tested this
29way.) Most often, the forms are function definitions and variable 30way.) Most often, the forms are function definitions and variable
30definitions. 31definitions.
31 32
32 A file containing Lisp code is often called a @dfn{library}. Thus,
33the ``Rmail library'' is a file containing code for Rmail mode.
34Similarly, a ``Lisp library directory'' is a directory of files
35containing Lisp code.
36
37@menu 33@menu
38* How Programs Do Loading:: The @code{load} function and others. 34* How Programs Do Loading:: The @code{load} function and others.
39* Load Suffixes:: Details about the suffixes that @code{load} tries. 35* Load Suffixes:: Details about the suffixes that @code{load} tries.
@@ -88,8 +84,8 @@ this case, you must specify the precise file name you want, except
88that, if Auto Compression mode is enabled, @code{load} will still use 84that, if Auto Compression mode is enabled, @code{load} will still use
89@code{jka-compr-load-suffixes} to find compressed versions. By 85@code{jka-compr-load-suffixes} to find compressed versions. By
90specifying the precise file name and using @code{t} for 86specifying the precise file name and using @code{t} for
91@var{nosuffix}, you can prevent perverse file names such as 87@var{nosuffix}, you can prevent file names like @file{foo.el.el} from
92@file{foo.el.el} from being tried. 88being tried.
93 89
94If the optional argument @var{must-suffix} is non-@code{nil}, then 90If the optional argument @var{must-suffix} is non-@code{nil}, then
95@code{load} insists that the file name used must end in either 91@code{load} insists that the file name used must end in either
@@ -238,73 +234,37 @@ it skips the latter group.
238 When Emacs loads a Lisp library, it searches for the library 234 When Emacs loads a Lisp library, it searches for the library
239in a list of directories specified by the variable @code{load-path}. 235in a list of directories specified by the variable @code{load-path}.
240 236
241@defopt load-path 237@defvar load-path
242@cindex @code{EMACSLOADPATH} environment variable 238@cindex @code{EMACSLOADPATH} environment variable
243The value of this variable is a list of directories to search when 239The value of this variable is a list of directories to search when
244loading files with @code{load}. Each element is a string (which must be 240loading files with @code{load}. Each element is a string (which must be
245a directory name) or @code{nil} (which stands for the current working 241a directory name) or @code{nil} (which stands for the current working
246directory). 242directory).
247@end defopt 243@end defvar
248
249 The value of @code{load-path} is initialized from the environment
250variable @code{EMACSLOADPATH}, if that exists; otherwise its default
251value is specified in @file{emacs/src/epaths.h} when Emacs is built.
252Then the list is expanded by adding subdirectories of the directories
253in the list.
254
255 The syntax of @code{EMACSLOADPATH} is the same as used for @code{PATH};
256@samp{:} (or @samp{;}, according to the operating system) separates
257directory names, and @samp{.} is used for the current default directory.
258Here is an example of how to set your @code{EMACSLOADPATH} variable from
259a @code{csh} @file{.login} file:
260
261@smallexample
262setenv EMACSLOADPATH .:/user/bil/emacs:/usr/local/share/emacs/20.3/lisp
263@end smallexample
264 244
265 Here is how to set it using @code{sh}: 245 Each time Emacs starts up, it sets up the value of @code{load-path}
246in several steps. First, it initializes @code{load-path} to the
247directories specified by the environment variable @env{EMACSLOADPATH},
248if that exists. The syntax of @env{EMACSLOADPATH} is the same as used
249for @code{PATH}; directory names are separated by @samp{:} (or
250@samp{;}, on some operating systems), and @samp{.} stands for the
251current default directory. Here is an example of how to set
252@env{EMACSLOADPATH} variable from @command{sh}:
266 253
267@smallexample 254@smallexample
268export EMACSLOADPATH 255export EMACSLOADPATH
269EMACSLOADPATH=.:/user/bil/emacs:/usr/local/share/emacs/20.3/lisp 256EMACSLOADPATH=/home/foo/.emacs.d/lisp:/opt/emacs/lisp
270@end smallexample 257@end smallexample
271 258
272 Here is an example of code you can place in your init file (@pxref{Init 259@noindent
273File}) to add several directories to the front of your default 260Here is how to set it from @code{csh}:
274@code{load-path}:
275 261
276@smallexample 262@smallexample
277@group 263setenv EMACSLOADPATH /home/foo/.emacs.d/lisp:/opt/emacs/lisp
278(setq load-path
279 (append (list nil "/user/bil/emacs"
280 "/usr/local/lisplib"
281 "~/emacs")
282 load-path))
283@end group
284@end smallexample 264@end smallexample
285 265
286@c Wordy to rid us of an overfull hbox. --rjc 15mar92 266 If @env{EMACSLOADPATH} is not set (which is usually the case), Emacs
287@noindent 267initializes @code{load-path} with the following two directories:
288In this example, the path searches the current working directory first,
289followed then by the @file{/user/bil/emacs} directory, the
290@file{/usr/local/lisplib} directory, and the @file{~/emacs} directory,
291which are then followed by the standard directories for Lisp code.
292
293 Dumping Emacs uses a special value of @code{load-path}. If the value of
294@code{load-path} at the end of dumping is unchanged (that is, still the
295same special value), the dumped Emacs switches to the ordinary
296@code{load-path} value when it starts up, as described above. But if
297@code{load-path} has any other value at the end of dumping, that value
298is used for execution of the dumped Emacs also.
299
300 Therefore, if you want to change @code{load-path} temporarily for
301loading a few libraries in @file{site-init.el} or @file{site-load.el},
302you should bind @code{load-path} locally with @code{let} around the
303calls to @code{load}.
304
305 The default value of @code{load-path}, when running an Emacs which has
306been installed on the system, includes two special directories (and
307their subdirectories as well):
308 268
309@smallexample 269@smallexample
310"/usr/local/share/emacs/@var{version}/site-lisp" 270"/usr/local/share/emacs/@var{version}/site-lisp"
@@ -319,33 +279,42 @@ and
319 279
320@noindent 280@noindent
321The first one is for locally installed packages for a particular Emacs 281The first one is for locally installed packages for a particular Emacs
322version; the second is for locally installed packages meant for use with 282version; the second is for locally installed packages meant for use
323all installed Emacs versions. 283with all installed Emacs versions.
324
325 There are several reasons why a Lisp package that works well in one
326Emacs version can cause trouble in another. Sometimes packages need
327updating for incompatible changes in Emacs; sometimes they depend on
328undocumented internal Emacs data that can change without notice;
329sometimes a newer Emacs version incorporates a version of the package,
330and should be used only with that version.
331
332 Emacs finds these directories' subdirectories and adds them to
333@code{load-path} when it starts up. Both immediate subdirectories and
334subdirectories multiple levels down are added to @code{load-path}.
335
336 Not all subdirectories are included, though. Subdirectories whose
337names do not start with a letter or digit are excluded. Subdirectories
338named @file{RCS} or @file{CVS} are excluded. Also, a subdirectory which
339contains a file named @file{.nosearch} is excluded. You can use these
340methods to prevent certain subdirectories of the @file{site-lisp}
341directories from being searched.
342 284
343 If you run Emacs from the directory where it was built---that is, an 285 If you run Emacs from the directory where it was built---that is, an
344executable that has not been formally installed---then @code{load-path} 286executable that has not been formally installed---Emacs puts two more
345normally contains two additional directories. These are the @code{lisp} 287directories in @code{load-path}. These are the @code{lisp} and
346and @code{site-lisp} subdirectories of the main build directory. (Both 288@code{site-lisp} subdirectories of the main build directory. (Both
347are represented as absolute file names.) 289are represented as absolute file names.)
348 290
291 Next, Emacs ``expands'' the initial list of directories in
292@code{load-path} by adding the subdirectories of those directories.
293Both immediate subdirectories and subdirectories multiple levels down
294are added. But it excludes subdirectories whose names do not start
295with a letter or digit, and subdirectories named @file{RCS} or
296@file{CVS}, and subdirectories containing a file named
297@file{.nosearch}.
298
299 Next, Emacs adds any extra load directory that you specify using the
300@samp{-L} command-line option (@pxref{Action Arguments,,,emacs, The
301GNU Emacs Manual}). It also adds the directories where optional
302packages are installed, if any (@pxref{Packaging Basics}).
303
304 It is common to add code to one's init file (@pxref{Init File}) to
305add one or more directories to @code{load-path}. For example:
306
307@smallexample
308(push "~/.emacs.d/lisp" load-path)
309@end smallexample
310
311 Dumping Emacs uses a special value of @code{load-path}. If the
312value of @code{load-path} at the end of dumping is unchanged (that is,
313still the same special value), the dumped Emacs switches to the
314ordinary @code{load-path} value when it starts up, as described above.
315But if @code{load-path} has any other value at the end of dumping,
316that value is used for execution of the dumped Emacs also.
317
349@deffn Command locate-library library &optional nosuffix path interactive-call 318@deffn Command locate-library library &optional nosuffix path interactive-call
350This command finds the precise file name for library @var{library}. It 319This command finds the precise file name for library @var{library}. It
351searches for the library in the same way @code{load} does, and the 320searches for the library in the same way @code{load} does, and the
@@ -401,30 +370,26 @@ example) is read without decoding, the text of the program will be
401unibyte text, and its string constants will be unibyte strings. 370unibyte text, and its string constants will be unibyte strings.
402@xref{Coding Systems}. 371@xref{Coding Systems}.
403 372
404 The reason Emacs is designed this way is so that Lisp programs give 373 In most Emacs Lisp programs, the fact that non-@acronym{ASCII}
405predictable results, regardless of how Emacs was started. In addition, 374strings are multibyte strings should not be noticeable, since
406this enables programs that depend on using multibyte text to work even 375inserting them in unibyte buffers converts them to unibyte
407in a unibyte Emacs. 376automatically. However, if this does make a difference, you can force
408 377a particular Lisp file to be interpreted as unibyte by writing
409 In most Emacs Lisp programs, the fact that non-@acronym{ASCII} strings are 378@samp{-*-unibyte: t;-*-} in a comment on the file's first line. With
410multibyte strings should not be noticeable, since inserting them in 379that designator, the file will unconditionally be interpreted as
411unibyte buffers converts them to unibyte automatically. However, if 380unibyte, even in an ordinary multibyte Emacs session. This can matter
412this does make a difference, you can force a particular Lisp file to be 381when making keybindings to non-@acronym{ASCII} characters written as
413interpreted as unibyte by writing @samp{-*-unibyte: t;-*-} in a 382@code{?v@var{literal}}.
414comment on the file's first line. With that designator, the file will
415unconditionally be interpreted as unibyte, even in an ordinary
416multibyte Emacs session. This can matter when making keybindings to
417non-@acronym{ASCII} characters written as @code{?v@var{literal}}.
418 383
419@node Autoload 384@node Autoload
420@section Autoload 385@section Autoload
421@cindex autoload 386@cindex autoload
422 387
423 The @dfn{autoload} facility allows you to make a function or macro 388 The @dfn{autoload} facility allows you to register the existence of
424known in Lisp, but put off loading the file that defines it. The first 389a function or macro, but put off loading the file that defines it.
425call to the function automatically reads the proper file to install the 390The first call to the function automatically reads the proper file, in
426real definition and other associated code, then runs the real definition 391order to install the real definition and other associated code, then
427as if it had been loaded all along. 392runs the real definition as if it had been loaded all along.
428 393
429 There are two ways to set up an autoloaded function: by calling 394 There are two ways to set up an autoloaded function: by calling
430@code{autoload}, and by writing a special ``magic'' comment in the 395@code{autoload}, and by writing a special ``magic'' comment in the
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 183253878f5..0175ffa4d9a 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -707,12 +707,19 @@ it is displayed along with the global value."
707 (with-current-buffer standard-output 707 (with-current-buffer standard-output
708 (setq val-start-pos (point)) 708 (setq val-start-pos (point))
709 (princ "value is ") 709 (princ "value is ")
710 (let ((from (point))) 710 (let ((from (point))
711 (terpri) 711 (line-beg (line-beginning-position))
712 (pp val) 712 ;;
713 (if (< (point) (+ 68 (line-beginning-position 0))) 713 (print-rep
714 (delete-region from (1+ from)) 714 (let ((print-quoted t))
715 (delete-region (1- from) from)) 715 (prin1-to-string val))))
716 (if (< (+ (length print-rep) (point) (- line-beg)) 68)
717 (insert print-rep)
718 (terpri)
719 (pp val)
720 (if (< (point) (+ 68 (line-beginning-position 0)))
721 (delete-region from (1+ from))
722 (delete-region (1- from) from)))
716 (let* ((sv (get variable 'standard-value)) 723 (let* ((sv (get variable 'standard-value))
717 (origval (and (consp sv) 724 (origval (and (consp sv)
718 (condition-case nil 725 (condition-case nil