aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2009-03-12 01:06:53 +0000
committerChong Yidong2009-03-12 01:06:53 +0000
commitdc40117535c7d0ddaf4a11518cb1e0b4096a9cf8 (patch)
tree5b3d33b4e7ed65dc72082acafb338cc209385c61
parent81f919fc6e7d929cd2d5820ca22783d4b51307bd (diff)
downloademacs-dc40117535c7d0ddaf4a11518cb1e0b4096a9cf8.tar.gz
emacs-dc40117535c7d0ddaf4a11518cb1e0b4096a9cf8.zip
(Repeated Loading): Simplify examples.
-rw-r--r--doc/lispref/loading.texi26
1 files changed, 7 insertions, 19 deletions
diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi
index 3938ee67bcf..d093fde1928 100644
--- a/doc/lispref/loading.texi
+++ b/doc/lispref/loading.texi
@@ -621,24 +621,18 @@ initialized. (@xref{Defining Variables}.)
621@end example 621@end example
622 622
623@noindent 623@noindent
624But this would add multiple elements if the library is reloaded. 624But this would add multiple elements if the library is reloaded. To
625To avoid the problem, write this: 625avoid the problem, use @code{add-to-list} (@pxref{List Variables}):
626
627@example
628(or (assq 'leif-mode minor-mode-alist)
629 (push '(leif-mode " Leif") minor-mode-alist))
630@end example
631
632@noindent
633or this:
634 626
635@example 627@example
636(add-to-list '(leif-mode " Leif") minor-mode-alist) 628(add-to-list '(leif-mode " Leif") minor-mode-alist)
637@end example 629@end example
638 630
639 Occasionally you will want to test explicitly whether a library has 631 Occasionally you will want to test explicitly whether a library has
640already been loaded. Here's one way to test, in a library, whether it 632already been loaded. If the library uses @code{provide} to provide a
641has been loaded before: 633named feature, you can use @code{featurep} earlier in the file to test
634whether the @code{provide} call has been executed before (@pxref{Named
635Features}). Alternatively, you could use something like this:
642 636
643@example 637@example
644(defvar foo-was-loaded nil) 638(defvar foo-was-loaded nil)
@@ -649,12 +643,6 @@ has been loaded before:
649@end example 643@end example
650 644
651@noindent 645@noindent
652If the library uses @code{provide} to provide a named feature, you can
653use @code{featurep} earlier in the file to test whether the
654@code{provide} call has been executed before.
655@ifnottex
656@xref{Named Features}.
657@end ifnottex
658 646
659@node Named Features 647@node Named Features
660@section Features 648@section Features
@@ -674,13 +662,13 @@ feature. Another program that uses them may ensure they are defined by
674@dfn{requiring} the feature. This loads the file of definitions if it 662@dfn{requiring} the feature. This loads the file of definitions if it
675hasn't been loaded already. 663hasn't been loaded already.
676 664
665@cindex load error with require
677 To require the presence of a feature, call @code{require} with the 666 To require the presence of a feature, call @code{require} with the
678feature name as argument. @code{require} looks in the global variable 667feature name as argument. @code{require} looks in the global variable
679@code{features} to see whether the desired feature has been provided 668@code{features} to see whether the desired feature has been provided
680already. If not, it loads the feature from the appropriate file. This 669already. If not, it loads the feature from the appropriate file. This
681file should call @code{provide} at the top level to add the feature to 670file should call @code{provide} at the top level to add the feature to
682@code{features}; if it fails to do so, @code{require} signals an error. 671@code{features}; if it fails to do so, @code{require} signals an error.
683@cindex load error with require
684 672
685 For example, in @file{emacs/lisp/prolog.el}, 673 For example, in @file{emacs/lisp/prolog.el},
686the definition for @code{run-prolog} includes the following code: 674the definition for @code{run-prolog} includes the following code: