diff options
| author | Chong Yidong | 2009-03-12 01:06:53 +0000 |
|---|---|---|
| committer | Chong Yidong | 2009-03-12 01:06:53 +0000 |
| commit | dc40117535c7d0ddaf4a11518cb1e0b4096a9cf8 (patch) | |
| tree | 5b3d33b4e7ed65dc72082acafb338cc209385c61 | |
| parent | 81f919fc6e7d929cd2d5820ca22783d4b51307bd (diff) | |
| download | emacs-dc40117535c7d0ddaf4a11518cb1e0b4096a9cf8.tar.gz emacs-dc40117535c7d0ddaf4a11518cb1e0b4096a9cf8.zip | |
(Repeated Loading): Simplify examples.
| -rw-r--r-- | doc/lispref/loading.texi | 26 |
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 |
| 624 | But this would add multiple elements if the library is reloaded. | 624 | But this would add multiple elements if the library is reloaded. To |
| 625 | To avoid the problem, write this: | 625 | avoid 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 | ||
| 633 | or 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 |
| 640 | already been loaded. Here's one way to test, in a library, whether it | 632 | already been loaded. If the library uses @code{provide} to provide a |
| 641 | has been loaded before: | 633 | named feature, you can use @code{featurep} earlier in the file to test |
| 634 | whether the @code{provide} call has been executed before (@pxref{Named | ||
| 635 | Features}). 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 |
| 652 | If the library uses @code{provide} to provide a named feature, you can | ||
| 653 | use @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 |
| 675 | hasn't been loaded already. | 663 | hasn'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 |
| 678 | feature name as argument. @code{require} looks in the global variable | 667 | feature 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 |
| 680 | already. If not, it loads the feature from the appropriate file. This | 669 | already. If not, it loads the feature from the appropriate file. This |
| 681 | file should call @code{provide} at the top level to add the feature to | 670 | file 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}, |
| 686 | the definition for @code{run-prolog} includes the following code: | 674 | the definition for @code{run-prolog} includes the following code: |