diff options
| author | Chong Yidong | 2012-02-10 15:57:21 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-02-10 15:57:21 +0800 |
| commit | 6c1e4b46424d7554fcaa42ab78b9f313e7bd32ea (patch) | |
| tree | b2a47d8c1fac9a3d956f8787a496cba87b44f938 | |
| parent | 104dc9c6226ba6ac48814e2212ecd933d2e58e3d (diff) | |
| download | emacs-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-RELEASE | 2 | ||||
| -rw-r--r-- | doc/lispref/ChangeLog | 9 | ||||
| -rw-r--r-- | doc/lispref/loading.texi | 173 | ||||
| -rw-r--r-- | lisp/help-fns.el | 19 |
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 | |||
| 206 | intro.texi cyd | 206 | intro.texi cyd |
| 207 | keymaps.texi | 207 | keymaps.texi |
| 208 | lists.texi cyd | 208 | lists.texi cyd |
| 209 | loading.texi | 209 | loading.texi cyd |
| 210 | locals.texi | 210 | locals.texi |
| 211 | macros.texi cyd | 211 | macros.texi cyd |
| 212 | maps.texi | 212 | maps.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 @@ | |||
| 1 | 2012-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 | |||
| 1 | 2012-02-10 Glenn Morris <rgm@gnu.org> | 10 | 2012-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 |
| 14 | environment in the form of Lisp objects. Emacs finds and opens the | 14 | Lisp environment in the form of Lisp objects. Emacs finds and opens |
| 15 | file, reads the text, evaluates each form, and then closes the file. | 15 | the file, reads the text, evaluates each form, and then closes the |
| 16 | file. 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 |
| 18 | as the @code{eval-buffer} function evaluates all the | 19 | as the @code{eval-buffer} function evaluates all the |
| @@ -29,11 +30,6 @@ into a buffer and evaluated there. (Indeed, most code is tested this | |||
| 29 | way.) Most often, the forms are function definitions and variable | 30 | way.) Most often, the forms are function definitions and variable |
| 30 | definitions. | 31 | definitions. |
| 31 | 32 | ||
| 32 | A file containing Lisp code is often called a @dfn{library}. Thus, | ||
| 33 | the ``Rmail library'' is a file containing code for Rmail mode. | ||
| 34 | Similarly, a ``Lisp library directory'' is a directory of files | ||
| 35 | containing 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 | |||
| 88 | that, if Auto Compression mode is enabled, @code{load} will still use | 84 | that, 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 |
| 90 | specifying the precise file name and using @code{t} for | 86 | specifying 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. | 88 | being tried. |
| 93 | 89 | ||
| 94 | If the optional argument @var{must-suffix} is non-@code{nil}, then | 90 | If 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 |
| 239 | in a list of directories specified by the variable @code{load-path}. | 235 | in 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 |
| 243 | The value of this variable is a list of directories to search when | 239 | The value of this variable is a list of directories to search when |
| 244 | loading files with @code{load}. Each element is a string (which must be | 240 | loading files with @code{load}. Each element is a string (which must be |
| 245 | a directory name) or @code{nil} (which stands for the current working | 241 | a directory name) or @code{nil} (which stands for the current working |
| 246 | directory). | 242 | directory). |
| 247 | @end defopt | 243 | @end defvar |
| 248 | |||
| 249 | The value of @code{load-path} is initialized from the environment | ||
| 250 | variable @code{EMACSLOADPATH}, if that exists; otherwise its default | ||
| 251 | value is specified in @file{emacs/src/epaths.h} when Emacs is built. | ||
| 252 | Then the list is expanded by adding subdirectories of the directories | ||
| 253 | in 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 | ||
| 257 | directory names, and @samp{.} is used for the current default directory. | ||
| 258 | Here is an example of how to set your @code{EMACSLOADPATH} variable from | ||
| 259 | a @code{csh} @file{.login} file: | ||
| 260 | |||
| 261 | @smallexample | ||
| 262 | setenv 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} |
| 246 | in several steps. First, it initializes @code{load-path} to the | ||
| 247 | directories specified by the environment variable @env{EMACSLOADPATH}, | ||
| 248 | if that exists. The syntax of @env{EMACSLOADPATH} is the same as used | ||
| 249 | for @code{PATH}; directory names are separated by @samp{:} (or | ||
| 250 | @samp{;}, on some operating systems), and @samp{.} stands for the | ||
| 251 | current default directory. Here is an example of how to set | ||
| 252 | @env{EMACSLOADPATH} variable from @command{sh}: | ||
| 266 | 253 | ||
| 267 | @smallexample | 254 | @smallexample |
| 268 | export EMACSLOADPATH | 255 | export EMACSLOADPATH |
| 269 | EMACSLOADPATH=.:/user/bil/emacs:/usr/local/share/emacs/20.3/lisp | 256 | EMACSLOADPATH=/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 |
| 273 | File}) to add several directories to the front of your default | 260 | Here is how to set it from @code{csh}: |
| 274 | @code{load-path}: | ||
| 275 | 261 | ||
| 276 | @smallexample | 262 | @smallexample |
| 277 | @group | 263 | setenv 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 | 267 | initializes @code{load-path} with the following two directories: |
| 288 | In this example, the path searches the current working directory first, | ||
| 289 | followed then by the @file{/user/bil/emacs} directory, the | ||
| 290 | @file{/usr/local/lisplib} directory, and the @file{~/emacs} directory, | ||
| 291 | which 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 | ||
| 295 | same 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 | ||
| 298 | is used for execution of the dumped Emacs also. | ||
| 299 | |||
| 300 | Therefore, if you want to change @code{load-path} temporarily for | ||
| 301 | loading a few libraries in @file{site-init.el} or @file{site-load.el}, | ||
| 302 | you should bind @code{load-path} locally with @code{let} around the | ||
| 303 | calls to @code{load}. | ||
| 304 | |||
| 305 | The default value of @code{load-path}, when running an Emacs which has | ||
| 306 | been installed on the system, includes two special directories (and | ||
| 307 | their 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 |
| 321 | The first one is for locally installed packages for a particular Emacs | 281 | The first one is for locally installed packages for a particular Emacs |
| 322 | version; the second is for locally installed packages meant for use with | 282 | version; the second is for locally installed packages meant for use |
| 323 | all installed Emacs versions. | 283 | with all installed Emacs versions. |
| 324 | |||
| 325 | There are several reasons why a Lisp package that works well in one | ||
| 326 | Emacs version can cause trouble in another. Sometimes packages need | ||
| 327 | updating for incompatible changes in Emacs; sometimes they depend on | ||
| 328 | undocumented internal Emacs data that can change without notice; | ||
| 329 | sometimes a newer Emacs version incorporates a version of the package, | ||
| 330 | and 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 | ||
| 334 | subdirectories multiple levels down are added to @code{load-path}. | ||
| 335 | |||
| 336 | Not all subdirectories are included, though. Subdirectories whose | ||
| 337 | names do not start with a letter or digit are excluded. Subdirectories | ||
| 338 | named @file{RCS} or @file{CVS} are excluded. Also, a subdirectory which | ||
| 339 | contains a file named @file{.nosearch} is excluded. You can use these | ||
| 340 | methods to prevent certain subdirectories of the @file{site-lisp} | ||
| 341 | directories 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 |
| 344 | executable that has not been formally installed---then @code{load-path} | 286 | executable that has not been formally installed---Emacs puts two more |
| 345 | normally contains two additional directories. These are the @code{lisp} | 287 | directories in @code{load-path}. These are the @code{lisp} and |
| 346 | and @code{site-lisp} subdirectories of the main build directory. (Both | 288 | @code{site-lisp} subdirectories of the main build directory. (Both |
| 347 | are represented as absolute file names.) | 289 | are 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. | ||
| 293 | Both immediate subdirectories and subdirectories multiple levels down | ||
| 294 | are added. But it excludes subdirectories whose names do not start | ||
| 295 | with 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 | ||
| 301 | GNU Emacs Manual}). It also adds the directories where optional | ||
| 302 | packages are installed, if any (@pxref{Packaging Basics}). | ||
| 303 | |||
| 304 | It is common to add code to one's init file (@pxref{Init File}) to | ||
| 305 | add 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 | ||
| 312 | value of @code{load-path} at the end of dumping is unchanged (that is, | ||
| 313 | still the same special value), the dumped Emacs switches to the | ||
| 314 | ordinary @code{load-path} value when it starts up, as described above. | ||
| 315 | But if @code{load-path} has any other value at the end of dumping, | ||
| 316 | that 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 |
| 350 | This command finds the precise file name for library @var{library}. It | 319 | This command finds the precise file name for library @var{library}. It |
| 351 | searches for the library in the same way @code{load} does, and the | 320 | searches 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 | |||
| 401 | unibyte text, and its string constants will be unibyte strings. | 370 | unibyte 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} |
| 405 | predictable results, regardless of how Emacs was started. In addition, | 374 | strings are multibyte strings should not be noticeable, since |
| 406 | this enables programs that depend on using multibyte text to work even | 375 | inserting them in unibyte buffers converts them to unibyte |
| 407 | in a unibyte Emacs. | 376 | automatically. However, if this does make a difference, you can force |
| 408 | 377 | a 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 |
| 410 | multibyte strings should not be noticeable, since inserting them in | 379 | that designator, the file will unconditionally be interpreted as |
| 411 | unibyte buffers converts them to unibyte automatically. However, if | 380 | unibyte, even in an ordinary multibyte Emacs session. This can matter |
| 412 | this does make a difference, you can force a particular Lisp file to be | 381 | when making keybindings to non-@acronym{ASCII} characters written as |
| 413 | interpreted as unibyte by writing @samp{-*-unibyte: t;-*-} in a | 382 | @code{?v@var{literal}}. |
| 414 | comment on the file's first line. With that designator, the file will | ||
| 415 | unconditionally be interpreted as unibyte, even in an ordinary | ||
| 416 | multibyte Emacs session. This can matter when making keybindings to | ||
| 417 | non-@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 |
| 424 | known in Lisp, but put off loading the file that defines it. The first | 389 | a function or macro, but put off loading the file that defines it. |
| 425 | call to the function automatically reads the proper file to install the | 390 | The first call to the function automatically reads the proper file, in |
| 426 | real definition and other associated code, then runs the real definition | 391 | order to install the real definition and other associated code, then |
| 427 | as if it had been loaded all along. | 392 | runs 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 |