Sync up with r21-4-14-chise-0_21-22.
[chise/xemacs-chise.git-] / info / lispref.info-46
1 This is ../info/lispref.info, produced by makeinfo version 4.0b from
2 lispref/lispref.texi.
3
4 INFO-DIR-SECTION XEmacs Editor
5 START-INFO-DIR-ENTRY
6 * Lispref: (lispref).           XEmacs Lisp Reference Manual.
7 END-INFO-DIR-ENTRY
8
9    Edition History:
10
11    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
12 Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
13 Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
14 XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
15 GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
16 Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
17 Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
18 Reference Manual (for 19.15 and 20.1, 20.2, 20.3) v3.2, April, May,
19 November 1997 XEmacs Lisp Reference Manual (for 21.0) v3.3, April 1998
20
21    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
22 Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
23 Copyright (C) 1995, 1996 Ben Wing.
24
25    Permission is granted to make and distribute verbatim copies of this
26 manual provided the copyright notice and this permission notice are
27 preserved on all copies.
28
29    Permission is granted to copy and distribute modified versions of
30 this manual under the conditions for verbatim copying, provided that the
31 entire resulting derived work is distributed under the terms of a
32 permission notice identical to this one.
33
34    Permission is granted to copy and distribute translations of this
35 manual into another language, under the above conditions for modified
36 versions, except that this permission notice may be stated in a
37 translation approved by the Foundation.
38
39    Permission is granted to copy and distribute modified versions of
40 this manual under the conditions for verbatim copying, provided also
41 that the section entitled "GNU General Public License" is included
42 exactly as in the original, and provided that the entire resulting
43 derived work is distributed under the terms of a permission notice
44 identical to this one.
45
46    Permission is granted to copy and distribute translations of this
47 manual into another language, under the above conditions for modified
48 versions, except that the section entitled "GNU General Public License"
49 may be included in a translation approved by the Free Software
50 Foundation instead of in the original English.
51
52 \1f
53 File: lispref.info,  Node: Style Tips,  Next: Compilation Tips,  Up: Tips
54
55 Writing Clean Lisp Programs
56 ===========================
57
58    Here are some tips for avoiding common errors in writing Lisp code
59 intended for widespread use:
60
61    * Since all global variables share the same name space, and all
62      functions share another name space, you should choose a short word
63      to distinguish your program from other Lisp programs.  Then take
64      care to begin the names of all global variables, constants, and
65      functions with the chosen prefix.  This helps avoid name conflicts.
66
67      This recommendation applies even to names for traditional Lisp
68      primitives that are not primitives in XEmacs Lisp--even to `cadr'.
69      Believe it or not, there is more than one plausible way to define
70      `cadr'.  Play it safe; append your name prefix to produce a name
71      like `foo-cadr' or `mylib-cadr' instead.
72
73      If you write a function that you think ought to be added to Emacs
74      under a certain name, such as `twiddle-files', don't call it by
75      that name in your program.  Call it `mylib-twiddle-files' in your
76      program, and send mail to `bug-gnu-emacs@prep.ai.mit.edu'
77      suggesting we add it to Emacs.  If and when we do, we can change
78      the name easily enough.
79
80      If one prefix is insufficient, your package may use two or three
81      alternative common prefixes, so long as they make sense.
82
83      Separate the prefix from the rest of the symbol name with a hyphen,
84      `-'.  This will be consistent with XEmacs itself and with most
85      Emacs Lisp programs.
86
87    * It is often useful to put a call to `provide' in each separate
88      library program, at least if there is more than one entry point to
89      the program.
90
91    * If a file requires certain other library programs to be loaded
92      beforehand, then the comments at the beginning of the file should
93      say so.  Also, use `require' to make sure they are loaded.
94
95    * If one file FOO uses a macro defined in another file BAR, FOO
96      should contain this expression before the first use of the macro:
97
98           (eval-when-compile (require 'BAR))
99
100      (And BAR should contain `(provide 'BAR)', to make the `require'
101      work.)  This will cause BAR to be loaded when you byte-compile
102      FOO.  Otherwise, you risk compiling FOO without the necessary
103      macro loaded, and that would produce compiled code that won't work
104      right.  *Note Compiling Macros::.
105
106      Using `eval-when-compile' avoids loading BAR when the compiled
107      version of FOO is _used_.
108
109    * If you define a major mode, make sure to run a hook variable using
110      `run-hooks', just as the existing major modes do.  *Note Hooks::.
111
112    * If the purpose of a function is to tell you whether a certain
113      condition is true or false, give the function a name that ends in
114      `p'.  If the name is one word, add just `p'; if the name is
115      multiple words, add `-p'.  Examples are `framep' and
116      `frame-live-p'.
117
118    * If a user option variable records a true-or-false condition, give
119      it a name that ends in `-flag'.
120
121    * Please do not define `C-c LETTER' as a key in your major modes.
122      These sequences are reserved for users; they are the *only*
123      sequences reserved for users, so we cannot do without them.
124
125      Instead, define sequences consisting of `C-c' followed by a
126      non-letter.  These sequences are reserved for major modes.
127
128      Changing all the major modes in Emacs 18 so they would follow this
129      convention was a lot of work.  Abandoning this convention would
130      make that work go to waste, and inconvenience users.
131
132    * Sequences consisting of `C-c' followed by `{', `}', `<', `>', `:'
133      or `;' are also reserved for major modes.
134
135    * Sequences consisting of `C-c' followed by any other punctuation
136      character are allocated for minor modes.  Using them in a major
137      mode is not absolutely prohibited, but if you do that, the major
138      mode binding may be shadowed from time to time by minor modes.
139
140    * You should not bind `C-h' following any prefix character (including
141      `C-c').  If you don't bind `C-h', it is automatically available as
142      a help character for listing the subcommands of the prefix
143      character.
144
145    * You should not bind a key sequence ending in <ESC> except following
146      another <ESC>.  (That is, it is ok to bind a sequence ending in
147      `<ESC> <ESC>'.)
148
149      The reason for this rule is that a non-prefix binding for <ESC> in
150      any context prevents recognition of escape sequences as function
151      keys in that context.
152
153    * Applications should not bind mouse events based on button 1 with
154      the shift key held down.  These events include `S-mouse-1',
155      `M-S-mouse-1', `C-S-mouse-1', and so on.  They are reserved for
156      users.
157
158    * Modes should redefine `mouse-2' as a command to follow some sort of
159      reference in the text of a buffer, if users usually would not want
160      to alter the text in that buffer by hand.  Modes such as Dired,
161      Info, Compilation, and Occur redefine it in this way.
162
163    * When a package provides a modification of ordinary Emacs behavior,
164      it is good to include a command to enable and disable the feature,
165      Provide a command named `WHATEVER-mode' which turns the feature on
166      or off, and make it autoload (*note Autoload::).  Design the
167      package so that simply loading it has no visible effect--that
168      should not enable the feature.  Users will request the feature by
169      invoking the command.
170
171    * It is a bad idea to define aliases for the Emacs primitives.  Use
172      the standard names instead.
173
174    * Redefining an Emacs primitive is an even worse idea.  It may do
175      the right thing for a particular program, but there is no telling
176      what other programs might break as a result.
177
178    * If a file does replace any of the functions or library programs of
179      standard XEmacs, prominent comments at the beginning of the file
180      should say which functions are replaced, and how the behavior of
181      the replacements differs from that of the originals.
182
183    * Please keep the names of your XEmacs Lisp source files to 13
184      characters or less.  This way, if the files are compiled, the
185      compiled files' names will be 14 characters or less, which is
186      short enough to fit on all kinds of Unix systems.
187
188    * Don't use `next-line' or `previous-line' in programs; nearly
189      always, `forward-line' is more convenient as well as more
190      predictable and robust.  *Note Text Lines::.
191
192    * Don't call functions that set the mark, unless setting the mark is
193      one of the intended features of your program.  The mark is a
194      user-level feature, so it is incorrect to change the mark except
195      to supply a value for the user's benefit.  *Note The Mark::.
196
197      In particular, don't use these functions:
198
199         * `beginning-of-buffer', `end-of-buffer'
200
201         * `replace-string', `replace-regexp'
202
203      If you just want to move point, or replace a certain string,
204      without any of the other features intended for interactive users,
205      you can replace these functions with one or two lines of simple
206      Lisp code.
207
208    * Use lists rather than vectors, except when there is a particular
209      reason to use a vector.  Lisp has more facilities for manipulating
210      lists than for vectors, and working with lists is usually more
211      convenient.
212
213      Vectors are advantageous for tables that are substantial in size
214      and are accessed in random order (not searched front to back),
215      provided there is no need to insert or delete elements (only lists
216      allow that).
217
218    * The recommended way to print a message in the echo area is with
219      the `message' function, not `princ'.  *Note The Echo Area::.
220
221    * When you encounter an error condition, call the function `error'
222      (or `signal').  The function `error' does not return.  *Note
223      Signaling Errors::.
224
225      Do not use `message', `throw', `sleep-for', or `beep' to report
226      errors.
227
228    * An error message should start with a capital letter but should not
229      end with a period.
230
231    * Try to avoid using recursive edits.  Instead, do what the Rmail `e'
232      command does: use a new local keymap that contains one command
233      defined to switch back to the old local keymap.  Or do what the
234      `edit-options' command does: switch to another buffer and let the
235      user switch back at will.  *Note Recursive Editing::.
236
237    * In some other systems there is a convention of choosing variable
238      names that begin and end with `*'.  We don't use that convention
239      in Emacs Lisp, so please don't use it in your programs.  (Emacs
240      uses such names only for program-generated buffers.)  The users
241      will find Emacs more coherent if all libraries use the same
242      conventions.
243
244    * Indent each function with `C-M-q' (`indent-sexp') using the
245      default indentation parameters.
246
247    * Don't make a habit of putting close-parentheses on lines by
248      themselves; Lisp programmers find this disconcerting.  Once in a
249      while, when there is a sequence of many consecutive
250      close-parentheses, it may make sense to split them in one or two
251      significant places.
252
253    * Please put a copyright notice on the file if you give copies to
254      anyone.  Use the same lines that appear at the top of the Lisp
255      files in XEmacs itself.  If you have not signed papers to assign
256      the copyright to the Foundation, then place your name in the
257      copyright notice in place of the Foundation's name.
258
259 \1f
260 File: lispref.info,  Node: Compilation Tips,  Next: Documentation Tips,  Prev: Style Tips,  Up: Tips
261
262 Tips for Making Compiled Code Fast
263 ==================================
264
265    Here are ways of improving the execution speed of byte-compiled Lisp
266 programs.
267
268    * Use the `profile' library to profile your program.  See the file
269      `profile.el' for instructions.
270
271    * Use iteration rather than recursion whenever possible.  Function
272      calls are slow in XEmacs Lisp even when a compiled function is
273      calling another compiled function.
274
275    * Using the primitive list-searching functions `memq', `member',
276      `assq', or `assoc' is even faster than explicit iteration.  It may
277      be worth rearranging a data structure so that one of these
278      primitive search functions can be used.
279
280    * Certain built-in functions are handled specially in byte-compiled
281      code, avoiding the need for an ordinary function call.  It is a
282      good idea to use these functions rather than alternatives.  To see
283      whether a function is handled specially by the compiler, examine
284      its `byte-compile' property.  If the property is non-`nil', then
285      the function is handled specially.
286
287      For example, the following input will show you that `aref' is
288      compiled specially (*note Array Functions::) while `elt' is not
289      (*note Sequence Functions::):
290
291           (get 'aref 'byte-compile)
292                => byte-compile-two-args
293           
294           (get 'elt 'byte-compile)
295                => nil
296
297    * If calling a small function accounts for a  substantial part of
298      your program's running time, make the function inline.  This
299      eliminates the function call overhead.  Since making a function
300      inline reduces the flexibility of changing the program, don't do
301      it unless it gives a noticeable speedup in something slow enough
302      that users care about the speed.  *Note Inline Functions::.
303
304 \1f
305 File: lispref.info,  Node: Documentation Tips,  Next: Comment Tips,  Prev: Compilation Tips,  Up: Tips
306
307 Tips for Documentation Strings
308 ==============================
309
310    Here are some tips for the writing of documentation strings.
311
312    * Every command, function, or variable intended for users to know
313      about should have a documentation string.
314
315    * An internal variable or subroutine of a Lisp program might as well
316      have a documentation string.  In earlier Emacs versions, you could
317      save space by using a comment instead of a documentation string,
318      but that is no longer the case.
319
320    * The first line of the documentation string should consist of one
321      or two complete sentences that stand on their own as a summary.
322      `M-x apropos' displays just the first line, and if it doesn't
323      stand on its own, the result looks bad.  In particular, start the
324      first line with a capital letter and end with a period.
325
326      The documentation string can have additional lines that expand on
327      the details of how to use the function or variable.  The
328      additional lines should be made up of complete sentences also, but
329      they may be filled if that looks good.
330
331    * For consistency, phrase the verb in the first sentence of a
332      documentation string as an infinitive with "to" omitted.  For
333      instance, use "Return the cons of A and B." in preference to
334      "Returns the cons of A and B."  Usually it looks good to do
335      likewise for the rest of the first paragraph.  Subsequent
336      paragraphs usually look better if they have proper subjects.
337
338    * Write documentation strings in the active voice, not the passive,
339      and in the present tense, not the future.  For instance, use
340      "Return a list containing A and B." instead of "A list containing
341      A and B will be returned."
342
343    * Avoid using the word "cause" (or its equivalents) unnecessarily.
344      Instead of, "Cause Emacs to display text in boldface," write just
345      "Display text in boldface."
346
347    * Do not start or end a documentation string with whitespace.
348
349    * Format the documentation string so that it fits in an Emacs window
350      on an 80-column screen.  It is a good idea for most lines to be no
351      wider than 60 characters.  The first line can be wider if
352      necessary to fit the information that ought to be there.
353
354      However, rather than simply filling the entire documentation
355      string, you can make it much more readable by choosing line breaks
356      with care.  Use blank lines between topics if the documentation
357      string is long.
358
359    * *Do not* indent subsequent lines of a documentation string so that
360      the text is lined up in the source code with the text of the first
361      line.  This looks nice in the source code, but looks bizarre when
362      users view the documentation.  Remember that the indentation
363      before the starting double-quote is not part of the string!
364
365    * A variable's documentation string should start with `*' if the
366      variable is one that users would often want to set interactively.
367      If the value is a long list, or a function, or if the variable
368      would be set only in init files, then don't start the
369      documentation string with `*'.  *Note Defining Variables::.
370
371    * The documentation string for a variable that is a yes-or-no flag
372      should start with words such as "Non-nil means...", to make it
373      clear that all non-`nil' values are equivalent and indicate
374      explicitly what `nil' and non-`nil' mean.
375
376    * When a function's documentation string mentions the value of an
377      argument of the function, use the argument name in capital letters
378      as if it were a name for that value.  Thus, the documentation
379      string of the function `/' refers to its second argument as
380      `DIVISOR', because the actual argument name is `divisor'.
381
382      Also use all caps for meta-syntactic variables, such as when you
383      show the decomposition of a list or vector into subunits, some of
384      which may vary.
385
386    * When a documentation string refers to a Lisp symbol, write it as it
387      would be printed (which usually means in lower case), with
388      single-quotes around it.  For example: `lambda'.  There are two
389      exceptions: write t and nil without single-quotes.  (In this
390      manual, we normally do use single-quotes for those symbols.)
391
392    * Don't write key sequences directly in documentation strings.
393      Instead, use the `\\[...]' construct to stand for them.  For
394      example, instead of writing `C-f', write `\\[forward-char]'.  When
395      Emacs displays the documentation string, it substitutes whatever
396      key is currently bound to `forward-char'.  (This is normally `C-f',
397      but it may be some other character if the user has moved key
398      bindings.)  *Note Keys in Documentation::.
399
400    * In documentation strings for a major mode, you will want to refer
401      to the key bindings of that mode's local map, rather than global
402      ones.  Therefore, use the construct `\\<...>' once in the
403      documentation string to specify which key map to use.  Do this
404      before the first use of `\\[...]'.  The text inside the `\\<...>'
405      should be the name of the variable containing the local keymap for
406      the major mode.
407
408      It is not practical to use `\\[...]' very many times, because
409      display of the documentation string will become slow.  So use this
410      to describe the most important commands in your major mode, and
411      then use `\\{...}' to display the rest of the mode's keymap.
412
413 \1f
414 File: lispref.info,  Node: Comment Tips,  Next: Library Headers,  Prev: Documentation Tips,  Up: Tips
415
416 Tips on Writing Comments
417 ========================
418
419    We recommend these conventions for where to put comments and how to
420 indent them:
421
422 `;'
423      Comments that start with a single semicolon, `;', should all be
424      aligned to the same column on the right of the source code.  Such
425      comments usually explain how the code on the same line does its
426      job.  In Lisp mode and related modes, the `M-;'
427      (`indent-for-comment') command automatically inserts such a `;' in
428      the right place, or aligns such a comment if it is already present.
429
430      This and following examples are taken from the Emacs sources.
431
432           (setq base-version-list                 ; there was a base
433                 (assoc (substring fn 0 start-vn)  ; version to which
434                        file-version-assoc-list))  ; this looks like
435                                                   ; a subversion
436
437 `;;'
438      Comments that start with two semicolons, `;;', should be aligned to
439      the same level of indentation as the code.  Such comments usually
440      describe the purpose of the following lines or the state of the
441      program at that point.  For example:
442
443           (prog1 (setq auto-fill-function
444                        ...
445                        ...
446             ;; update modeline
447             (redraw-modeline)))
448
449      Every function that has no documentation string (because it is use
450      only internally within the package it belongs to), should have
451      instead a two-semicolon comment right before the function,
452      explaining what the function does and how to call it properly.
453      Explain precisely what each argument means and how the function
454      interprets its possible values.
455
456 `;;;'
457      Comments that start with three semicolons, `;;;', should start at
458      the left margin.  Such comments are used outside function
459      definitions to make general statements explaining the design
460      principles of the program.  For example:
461
462           ;;; This Lisp code is run in XEmacs
463           ;;; when it is to operate as a server
464           ;;; for other processes.
465
466      Another use for triple-semicolon comments is for commenting out
467      lines within a function.  We use triple-semicolons for this
468      precisely so that they remain at the left margin.
469
470           (defun foo (a)
471           ;;; This is no longer necessary.
472           ;;;  (force-mode-line-update)
473             (message "Finished with %s" a))
474
475 `;;;;'
476      Comments that start with four semicolons, `;;;;', should be aligned
477      to the left margin and are used for headings of major sections of a
478      program.  For example:
479
480           ;;;; The kill ring
481
482 The indentation commands of the Lisp modes in XEmacs, such as `M-;'
483 (`indent-for-comment') and <TAB> (`lisp-indent-line') automatically
484 indent comments according to these conventions, depending on the number
485 of semicolons.  *Note Manipulating Comments: (xemacs)Comments.
486
487 \1f
488 File: lispref.info,  Node: Library Headers,  Prev: Comment Tips,  Up: Tips
489
490 Conventional Headers for XEmacs Libraries
491 =========================================
492
493    XEmacs has conventions for using special comments in Lisp libraries
494 to divide them into sections and give information such as who wrote
495 them.  This section explains these conventions.  First, an example:
496
497      ;;; lisp-mnt.el --- minor mode for Emacs Lisp maintainers
498      
499      ;; Copyright (C) 1992 Free Software Foundation, Inc.
500      
501      ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
502      ;; Maintainer: Eric S. Raymond <esr@snark.thyrsus.com>
503      ;; Created: 14 Jul 1992
504      ;; Version: 1.2
505      ;; Keywords: docs
506      
507      ;; This file is part of XEmacs.
508      COPYING PERMISSIONS...
509
510    The very first line should have this format:
511
512      ;;; FILENAME --- DESCRIPTION
513
514 The description should be complete in one line.
515
516    After the copyright notice come several "header comment" lines, each
517 beginning with `;; HEADER-NAME:'.  Here is a table of the conventional
518 possibilities for HEADER-NAME:
519
520 `Author'
521      This line states the name and net address of at least the principal
522      author of the library.
523
524      If there are multiple authors, you can list them on continuation
525      lines led by `;;' and a tab character, like this:
526
527           ;; Author: Ashwin Ram <Ram-Ashwin@cs.yale.edu>
528           ;;      Dave Sill <de5@ornl.gov>
529           ;;      Dave Brennan <brennan@hal.com>
530           ;;      Eric Raymond <esr@snark.thyrsus.com>
531
532 `Maintainer'
533      This line should contain a single name/address as in the Author
534      line, or an address only, or the string `FSF'.  If there is no
535      maintainer line, the person(s) in the Author field are presumed to
536      be the maintainers.  The example above is mildly bogus because the
537      maintainer line is redundant.
538
539      The idea behind the `Author' and `Maintainer' lines is to make
540      possible a Lisp function to "send mail to the maintainer" without
541      having to mine the name out by hand.
542
543      Be sure to surround the network address with `<...>' if you
544      include the person's full name as well as the network address.
545
546 `Created'
547      This optional line gives the original creation date of the file.
548      For historical interest only.
549
550 `Version'
551      If you wish to record version numbers for the individual Lisp
552      program, put them in this line.
553
554 `Adapted-By'
555      In this header line, place the name of the person who adapted the
556      library for installation (to make it fit the style conventions, for
557      example).
558
559 `Keywords'
560      This line lists keywords for the `finder-by-keyword' help command.
561      This field is important; it's how people will find your package
562      when they're looking for things by topic area.  To separate the
563      keywords, you can use spaces, commas, or both.
564
565    Just about every Lisp library ought to have the `Author' and
566 `Keywords' header comment lines.  Use the others if they are
567 appropriate.  You can also put in header lines with other header
568 names--they have no standard meanings, so they can't do any harm.
569
570    We use additional stylized comments to subdivide the contents of the
571 library file.  Here is a table of them:
572
573 `;;; Commentary:'
574      This begins introductory comments that explain how the library
575      works.  It should come right after the copying permissions.
576
577 `;;; Change log:'
578      This begins change log information stored in the library file (if
579      you store the change history there).  For most of the Lisp files
580      distributed with XEmacs, the change history is kept in the file
581      `ChangeLog' and not in the source file at all; these files do not
582      have a `;;; Change log:' line.
583
584 `;;; Code:'
585      This begins the actual code of the program.
586
587 `;;; FILENAME ends here'
588      This is the "footer line"; it appears at the very end of the file.
589      Its purpose is to enable people to detect truncated versions of
590      the file from the lack of a footer line.
591
592 \1f
593 File: lispref.info,  Node: Building XEmacs and Object Allocation,  Next: Standard Errors,  Prev: Tips,  Up: Top
594
595 Building XEmacs; Allocation of Objects
596 **************************************
597
598    This chapter describes how the runnable XEmacs executable is dumped
599 with the preloaded Lisp libraries in it and how storage is allocated.
600
601    There is an entire separate document, the `XEmacs Internals Manual',
602 devoted to the internals of XEmacs from the perspective of the C
603 programmer.  It contains much more detailed information about the build
604 process, the allocation and garbage-collection process, and other
605 aspects related to the internals of XEmacs.
606
607 * Menu:
608
609 * Building XEmacs::     How to preload Lisp libraries into XEmacs.
610 * Pure Storage::        A kludge to make preloaded Lisp functions sharable.
611 * Garbage Collection::  Reclaiming space for Lisp objects no longer used.
612
613 \1f
614 File: lispref.info,  Node: Building XEmacs,  Next: Pure Storage,  Up: Building XEmacs and Object Allocation
615
616 Building XEmacs
617 ===============
618
619    This section explains the steps involved in building the XEmacs
620 executable.  You don't have to know this material to build and install
621 XEmacs, since the makefiles do all these things automatically.  This
622 information is pertinent to XEmacs maintenance.
623
624    The `XEmacs Internals Manual' contains more information about this.
625
626    Compilation of the C source files in the `src' directory produces an
627 executable file called `temacs', also called a "bare impure XEmacs".
628 It contains the XEmacs Lisp interpreter and I/O routines, but not the
629 editing commands.
630
631    Before XEmacs is actually usable, a number of Lisp files need to be
632 loaded.  These define all the editing commands, plus most of the startup
633 code and many very basic Lisp primitives.  This is accomplished by
634 loading the file `loadup.el', which in turn loads all of the other
635 standardly-loaded Lisp files.
636
637    It takes a substantial time to load the standard Lisp files.
638 Luckily, you don't have to do this each time you run XEmacs; `temacs'
639 can dump out an executable program called `xemacs' that has these files
640 preloaded.  `xemacs' starts more quickly because it does not need to
641 load the files.  This is the XEmacs executable that is normally
642 installed.
643
644    To create `xemacs', use the command `temacs -batch -l loadup dump'.
645 The purpose of `-batch' here is to tell `temacs' to run in
646 non-interactive, command-line mode. (`temacs' can _only_ run in this
647 fashion.  Part of the code required to initialize frames and faces is
648 in Lisp, and must be loaded before XEmacs is able to create any frames.)
649 The argument `dump' tells `loadup.el' to dump a new executable named
650 `xemacs'.
651
652    The dumping process is highly system-specific, and some operating
653 systems don't support dumping.  On those systems, you must start XEmacs
654 with the `temacs -batch -l loadup run-temacs' command each time you use
655 it.  This takes a substantial time, but since you need to start Emacs
656 once a day at most--or once a week if you never log out--the extra time
657 is not too severe a problem. (In older versions of Emacs, you started
658 Emacs from `temacs' using `temacs -l loadup'.)
659
660    You are free to start XEmacs directly from `temacs' if you want,
661 even if there is already a dumped `xemacs'.  Normally you wouldn't want
662 to do that; but the Makefiles do this when you rebuild XEmacs using
663 `make all-elc', which builds XEmacs and simultaneously compiles any
664 out-of-date Lisp files. (You need `xemacs' in order to compile Lisp
665 files.  However, you also need the compiled Lisp files in order to dump
666 out `xemacs'.  If both of these are missing or corrupted, you are out
667 of luck unless you're able to bootstrap `xemacs' from `temacs'.  Note
668 that `make all-elc' actually loads the alternative loadup file
669 `loadup-el.el', which works like `loadup.el' but disables the
670 pure-copying process and forces XEmacs to ignore any compiled Lisp
671 files even if they exist.)
672
673    You can specify additional files to preload by writing a library
674 named `site-load.el' that loads them.  You may need to increase the
675 value of `PURESIZE', in `src/puresize.h', to make room for the
676 additional files.  You should _not_ modify this file directly, however;
677 instead, use the `--puresize' configuration option. (If you run out of
678 pure space while dumping `xemacs', you will be told how much pure space
679 you actually will need.) However, the advantage of preloading
680 additional files decreases as machines get faster.  On modern machines,
681 it is often not advisable, especially if the Lisp code is on a file
682 system local to the machine running XEmacs.
683
684    You can specify other Lisp expressions to execute just before dumping
685 by putting them in a library named `site-init.el'.  However, if they
686 might alter the behavior that users expect from an ordinary unmodified
687 XEmacs, it is better to put them in `default.el', so that users can
688 override them if they wish.  *Note Start-up Summary::.
689
690    Before `loadup.el' dumps the new executable, it finds the
691 documentation strings for primitive and preloaded functions (and
692 variables) in the file where they are stored, by calling
693 `Snarf-documentation' (*note Accessing Documentation::).  These strings
694 were moved out of the `xemacs' executable to make it smaller.  *Note
695 Documentation Basics::.
696
697  - Function: dump-emacs to-file from-file
698      This function dumps the current state of XEmacs into an executable
699      file TO-FILE.  It takes symbols from FROM-FILE (this is normally
700      the executable file `temacs').
701
702      If you use this function in an XEmacs that was already dumped, you
703      must set `command-line-processed' to `nil' first for good results.
704      *Note Command Line Arguments::.
705
706  - Function: run-emacs-from-temacs &rest args
707      This is the function that implements the `run-temacs' command-line
708      argument.  It is called from `loadup.el' as appropriate.  You
709      should most emphatically _not_ call this yourself; it will
710      reinitialize your XEmacs process and you'll be sorry.
711
712  - Command: emacs-version &optional arg
713      This function returns a string describing the version of XEmacs
714      that is running.  It is useful to include this string in bug
715      reports.
716
717      When called interactively with a prefix argument, insert string at
718      point.  Don't use this function in programs to choose actions
719      according to the system configuration; look at
720      `system-configuration' instead.
721
722           (emacs-version)
723             => "XEmacs 20.1 [Lucid] (i586-unknown-linux2.0.29)
724                            of Mon Apr  7 1997 on altair.xemacs.org"
725
726      Called interactively, the function prints the same information in
727      the echo area.
728
729  - Variable: emacs-build-time
730      The value of this variable is the time at which XEmacs was built
731      at the local site.
732
733           emacs-build-time "Mon Apr  7 20:28:52 1997"
734                =>
735
736  - Variable: emacs-version
737      The value of this variable is the version of Emacs being run.  It
738      is a string, e.g. `"20.1 XEmacs Lucid"'.
739
740    The following two variables did not exist before FSF GNU Emacs
741 version 19.23 and XEmacs version 19.10, which reduces their usefulness
742 at present, but we hope they will be convenient in the future.
743
744  - Variable: emacs-major-version
745      The major version number of Emacs, as an integer.  For XEmacs
746      version 20.1, the value is 20.
747
748  - Variable: emacs-minor-version
749      The minor version number of Emacs, as an integer.  For XEmacs
750      version 20.1, the value is 1.
751
752 \1f
753 File: lispref.info,  Node: Pure Storage,  Next: Garbage Collection,  Prev: Building XEmacs,  Up: Building XEmacs and Object Allocation
754
755 Pure Storage
756 ============
757
758    XEmacs Lisp uses two kinds of storage for user-created Lisp objects:
759 "normal storage" and "pure storage".  Normal storage is where all the
760 new data created during an XEmacs session is kept; see the following
761 section for information on normal storage.  Pure storage is used for
762 certain data in the preloaded standard Lisp files--data that should
763 never change during actual use of XEmacs.
764
765    Pure storage is allocated only while `temacs' is loading the
766 standard preloaded Lisp libraries.  In the file `xemacs', it is marked
767 as read-only (on operating systems that permit this), so that the
768 memory space can be shared by all the XEmacs jobs running on the machine
769 at once.  Pure storage is not expandable; a fixed amount is allocated
770 when XEmacs is compiled, and if that is not sufficient for the preloaded
771 libraries, `temacs' aborts with an error message.  If that happens, you
772 must increase the compilation parameter `PURESIZE' using the
773 `--puresize' option to `configure'.  This normally won't happen unless
774 you try to preload additional libraries or add features to the standard
775 ones.
776
777  - Function: purecopy object
778      This function makes a copy of OBJECT in pure storage and returns
779      it.  It copies strings by simply making a new string with the same
780      characters in pure storage.  It recursively copies the contents of
781      vectors and cons cells.  It does not make copies of other objects
782      such as symbols, but just returns them unchanged.  It signals an
783      error if asked to copy markers.
784
785      This function is a no-op except while XEmacs is being built and
786      dumped; it is usually called only in the file
787      `xemacs/lisp/prim/loaddefs.el', but a few packages call it just in
788      case you decide to preload them.
789
790  - Variable: pure-bytes-used
791      The value of this variable is the number of bytes of pure storage
792      allocated so far.  Typically, in a dumped XEmacs, this number is
793      very close to the total amount of pure storage available--if it
794      were not, we would preallocate less.
795
796  - Variable: purify-flag
797      This variable determines whether `defun' should make a copy of the
798      function definition in pure storage.  If it is non-`nil', then the
799      function definition is copied into pure storage.
800
801      This flag is `t' while loading all of the basic functions for
802      building XEmacs initially (allowing those functions to be sharable
803      and non-collectible).  Dumping XEmacs as an executable always
804      writes `nil' in this variable, regardless of the value it actually
805      has before and after dumping.
806
807      You should not change this flag in a running XEmacs.
808
809 \1f
810 File: lispref.info,  Node: Garbage Collection,  Prev: Pure Storage,  Up: Building XEmacs and Object Allocation
811
812 Garbage Collection
813 ==================
814
815    When a program creates a list or the user defines a new function
816 (such as by loading a library), that data is placed in normal storage.
817 If normal storage runs low, then XEmacs asks the operating system to
818 allocate more memory in blocks of 2k bytes.  Each block is used for one
819 type of Lisp object, so symbols, cons cells, markers, etc., are
820 segregated in distinct blocks in memory.  (Vectors, long strings,
821 buffers and certain other editing types, which are fairly large, are
822 allocated in individual blocks, one per object, while small strings are
823 packed into blocks of 8k bytes. [More correctly, a string is allocated
824 in two sections: a fixed size chunk containing the length, list of
825 extents, etc.; and a chunk containing the actual characters in the
826 string.  It is this latter chunk that is either allocated individually
827 or packed into 8k blocks.  The fixed size chunk is packed into 2k
828 blocks, as for conses, markers, etc.])
829
830    It is quite common to use some storage for a while, then release it
831 by (for example) killing a buffer or deleting the last pointer to an
832 object.  XEmacs provides a "garbage collector" to reclaim this
833 abandoned storage.  (This name is traditional, but "garbage recycler"
834 might be a more intuitive metaphor for this facility.)
835
836    The garbage collector operates by finding and marking all Lisp
837 objects that are still accessible to Lisp programs.  To begin with, it
838 assumes all the symbols, their values and associated function
839 definitions, and any data presently on the stack, are accessible.  Any
840 objects that can be reached indirectly through other accessible objects
841 are also accessible.
842
843    When marking is finished, all objects still unmarked are garbage.  No
844 matter what the Lisp program or the user does, it is impossible to refer
845 to them, since there is no longer a way to reach them.  Their space
846 might as well be reused, since no one will miss them.  The second
847 ("sweep") phase of the garbage collector arranges to reuse them.
848
849    The sweep phase puts unused cons cells onto a "free list" for future
850 allocation; likewise for symbols, markers, extents, events, floats,
851 compiled-function objects, and the fixed-size portion of strings.  It
852 compacts the accessible small string-chars chunks so they occupy fewer
853 8k blocks; then it frees the other 8k blocks.  Vectors, buffers,
854 windows, and other large objects are individually allocated and freed
855 using `malloc' and `free'.
856
857      Common Lisp note: unlike other Lisps, XEmacs Lisp does not call
858      the garbage collector when the free list is empty.  Instead, it
859      simply requests the operating system to allocate more storage, and
860      processing continues until `gc-cons-threshold' bytes have been
861      used.
862
863      This means that you can make sure that the garbage collector will
864      not run during a certain portion of a Lisp program by calling the
865      garbage collector explicitly just before it (provided that portion
866      of the program does not use so much space as to force a second
867      garbage collection).
868
869  - Command: garbage-collect
870      This command runs a garbage collection, and returns information on
871      the amount of space in use.  (Garbage collection can also occur
872      spontaneously if you use more than `gc-cons-threshold' bytes of
873      Lisp data since the previous garbage collection.)
874
875      `garbage-collect' returns a list containing the following
876      information:
877
878           ((USED-CONSES . FREE-CONSES)
879            (USED-SYMS . FREE-SYMS)
880            (USED-MARKERS . FREE-MARKERS)
881            USED-STRING-CHARS
882            USED-VECTOR-SLOTS
883            (PLIST))
884           
885           => ((73362 . 8325) (13718 . 164)
886           (5089 . 5098) 949121 118677
887           (conses-used 73362 conses-free 8329 cons-storage 658168
888           symbols-used 13718 symbols-free 164 symbol-storage 335216
889           bit-vectors-used 0 bit-vectors-total-length 0
890           bit-vector-storage 0 vectors-used 7882
891           vectors-total-length 118677 vector-storage 537764
892           compiled-functions-used 1336 compiled-functions-free 37
893           compiled-function-storage 44440 short-strings-used 28829
894           long-strings-used 2 strings-free 7722
895           short-strings-total-length 916657 short-string-storage 1179648
896           long-strings-total-length 32464 string-header-storage 441504
897           floats-used 3 floats-free 43 float-storage 2044 markers-used 5089
898           markers-free 5098 marker-storage 245280 events-used 103
899           events-free 835 event-storage 110656 extents-used 10519
900           extents-free 2718 extent-storage 372736
901           extent-auxiliarys-used 111 extent-auxiliarys-freed 3
902           extent-auxiliary-storage 4440 window-configurations-used 39
903           window-configurations-on-free-list 5
904           window-configurations-freed 10 window-configuration-storage 9492
905           popup-datas-used 3 popup-data-storage 72 toolbar-buttons-used 62
906           toolbar-button-storage 4960 toolbar-datas-used 12
907           toolbar-data-storage 240 symbol-value-buffer-locals-used 182
908           symbol-value-buffer-local-storage 5824
909           symbol-value-lisp-magics-used 22
910           symbol-value-lisp-magic-storage 1496
911           symbol-value-varaliases-used 43
912           symbol-value-varalias-storage 1032 opaque-lists-used 2
913           opaque-list-storage 48 color-instances-used 12
914           color-instance-storage 288 font-instances-used 5
915           font-instance-storage 180 opaques-used 11 opaque-storage 312
916           range-tables-used 1 range-table-storage 16 faces-used 34
917           face-storage 2584 glyphs-used 124 glyph-storage 4464
918           specifiers-used 775 specifier-storage 43869 weak-lists-used 786
919           weak-list-storage 18864 char-tables-used 40
920           char-table-storage 41920 buffers-used 25 buffer-storage 7000
921           extent-infos-used 457 extent-infos-freed 73
922           extent-info-storage 9140 keymaps-used 275 keymap-storage 12100
923           consoles-used 4 console-storage 384 command-builders-used 2
924           command-builder-storage 120 devices-used 2 device-storage 344
925           frames-used 3 frame-storage 624 image-instances-used 47
926           image-instance-storage 3008 windows-used 27 windows-freed 2
927           window-storage 9180 lcrecord-lists-used 15
928           lcrecord-list-storage 360 hash-tables-used 631
929           hash-table-storage 25240 streams-used 1 streams-on-free-list 3
930           streams-freed 12 stream-storage 91))
931
932      Here is a table explaining each element:
933
934     USED-CONSES
935           The number of cons cells in use.
936
937     FREE-CONSES
938           The number of cons cells for which space has been obtained
939           from the operating system, but that are not currently being
940           used.
941
942     USED-SYMS
943           The number of symbols in use.
944
945     FREE-SYMS
946           The number of symbols for which space has been obtained from
947           the operating system, but that are not currently being used.
948
949     USED-MARKERS
950           The number of markers in use.
951
952     FREE-MARKERS
953           The number of markers for which space has been obtained from
954           the operating system, but that are not currently being used.
955
956     USED-STRING-CHARS
957           The total size of all strings, in characters.
958
959     USED-VECTOR-SLOTS
960           The total number of elements of existing vectors.
961
962     PLIST
963           A list of alternating keyword/value pairs providing more
964           detailed information. (As you can see above, quite a lot of
965           information is provided.)
966
967  - User Option: gc-cons-threshold
968      The value of this variable is the number of bytes of storage that
969      must be allocated for Lisp objects after one garbage collection in
970      order to trigger another garbage collection.  A cons cell counts
971      as eight bytes, a string as one byte per character plus a few
972      bytes of overhead, and so on; space allocated to the contents of
973      buffers does not count.  Note that the subsequent garbage
974      collection does not happen immediately when the threshold is
975      exhausted, but only the next time the Lisp evaluator is called.
976
977      The initial threshold value is 500,000.  If you specify a larger
978      value, garbage collection will happen less often.  This reduces the
979      amount of time spent garbage collecting, but increases total
980      memory use.  You may want to do this when running a program that
981      creates lots of Lisp data.
982
983      You can make collections more frequent by specifying a smaller
984      value, down to 10,000.  A value less than 10,000 will remain in
985      effect only until the subsequent garbage collection, at which time
986      `garbage-collect' will set the threshold back to 10,000. (This does
987      not apply if XEmacs was configured with `--debug'.  Therefore, be
988      careful when setting `gc-cons-threshold' in that case!)
989
990  - Variable: pre-gc-hook
991      This is a normal hook to be run just before each garbage
992      collection.  Interrupts, garbage collection, and errors are
993      inhibited while this hook runs, so be extremely careful in what
994      you add here.  In particular, avoid consing, and do not interact
995      with the user.
996
997  - Variable: post-gc-hook
998      This is a normal hook to be run just after each garbage collection.
999      Interrupts, garbage collection, and errors are inhibited while
1000      this hook runs, so be extremely careful in what you add here.  In
1001      particular, avoid consing, and do not interact with the user.
1002
1003  - Variable: gc-message
1004      This is a string to print to indicate that a garbage collection is
1005      in progress.  This is printed in the echo area.  If the selected
1006      frame is on a window system and `gc-pointer-glyph' specifies a
1007      value (i.e. a pointer image instance) in the domain of the
1008      selected frame, the mouse cursor will change instead of this
1009      message being printed.
1010
1011  - Glyph: gc-pointer-glyph
1012      This holds the pointer glyph used to indicate that a garbage
1013      collection is in progress.  If the selected window is on a window
1014      system and this glyph specifies a value (i.e. a pointer image
1015      instance) in the domain of the selected window, the cursor will be
1016      changed as specified during garbage collection.  Otherwise, a
1017      message will be printed in the echo area, as controlled by
1018      `gc-message'.  *Note Glyphs::.
1019
1020    If XEmacs was configured with `--debug', you can set the following
1021 two variables to get direct information about all the allocation that
1022 is happening in a segment of Lisp code.
1023
1024  - Variable: debug-allocation
1025      If non-zero, print out information to stderr about all objects
1026      allocated.
1027
1028  - Variable: debug-allocation-backtrace
1029      Length (in stack frames) of short backtrace printed out by
1030      `debug-allocation'.
1031
1032 \1f
1033 File: lispref.info,  Node: Standard Errors,  Next: Standard Buffer-Local Variables,  Prev: Building XEmacs and Object Allocation,  Up: Top
1034
1035 Standard Errors
1036 ***************
1037
1038    Here is the complete list of the error symbols in standard Emacs,
1039 grouped by concept.  The list includes each symbol's message (on the
1040 `error-message' property of the symbol) and a cross reference to a
1041 description of how the error can occur.
1042
1043    Each error symbol has an `error-conditions' property that is a list
1044 of symbols.  Normally this list includes the error symbol itself and
1045 the symbol `error'.  Occasionally it includes additional symbols, which
1046 are intermediate classifications, narrower than `error' but broader
1047 than a single error symbol.  For example, all the errors in accessing
1048 files have the condition `file-error'.
1049
1050    As a special exception, the error symbol `quit' does not have the
1051 condition `error', because quitting is not considered an error.
1052
1053    *Note Errors::, for an explanation of how errors are generated and
1054 handled.
1055
1056 `SYMBOL'
1057      STRING; REFERENCE.
1058
1059 `error'
1060      `"error"'
1061      *Note Errors::.
1062
1063 `quit'
1064      `"Quit"'
1065      *Note Quitting::.
1066
1067 `args-out-of-range'
1068      `"Args out of range"'
1069      *Note Sequences Arrays Vectors::.
1070
1071 `arith-error'
1072      `"Arithmetic error"'
1073      See `/' and `%' in *Note Numbers::.
1074
1075 `beginning-of-buffer'
1076      `"Beginning of buffer"'
1077      *Note Motion::.
1078
1079 `buffer-read-only'
1080      `"Buffer is read-only"'
1081      *Note Read Only Buffers::.
1082
1083 `cyclic-function-indirection'
1084      `"Symbol's chain of function indirections contains a loop"'
1085      *Note Function Indirection::.
1086
1087 `domain-error'
1088      `"Arithmetic domain error"'
1089 `end-of-buffer'
1090      `"End of buffer"'
1091      *Note Motion::.
1092
1093 `end-of-file'
1094      `"End of file during parsing"'
1095      This is not a `file-error'.
1096      *Note Input Functions::.
1097
1098 `file-error'
1099      This error and its subcategories do not have error-strings,
1100      because the error message is constructed from the data items alone
1101      when the error condition `file-error' is present.
1102      *Note Files::.
1103
1104 `file-locked'
1105      This is a `file-error'.
1106      *Note File Locks::.
1107
1108 `file-already-exists'
1109      This is a `file-error'.
1110      *Note Writing to Files::.
1111
1112 `file-supersession'
1113      This is a `file-error'.
1114      *Note Modification Time::.
1115
1116 `invalid-byte-code'
1117      `"Invalid byte code"'
1118      *Note Byte Compilation::.
1119
1120 `invalid-function'
1121      `"Invalid function"'
1122      *Note Classifying Lists::.
1123
1124 `invalid-read-syntax'
1125      `"Invalid read syntax"'
1126      *Note Input Functions::.
1127
1128 `invalid-regexp'
1129      `"Invalid regexp"'
1130      *Note Regular Expressions::.
1131
1132 `mark-inactive'
1133      `"The mark is not active now"'
1134 `no-catch'
1135      `"No catch for tag"'
1136      *Note Catch and Throw::.
1137
1138 `overflow-error'
1139      `"Arithmetic overflow error"'
1140 `protected-field'
1141      `"Attempt to modify a protected field"'
1142 `range-error'
1143      `"Arithmetic range error"'
1144 `search-failed'
1145      `"Search failed"'
1146      *Note Searching and Matching::.
1147
1148 `setting-constant'
1149      `"Attempt to set a constant symbol"'
1150      *Note Variables that Never Change: Constant Variables.
1151
1152 `singularity-error'
1153      `"Arithmetic singularity error"'
1154 `tooltalk-error'
1155      `"ToolTalk error"'
1156      *Note ToolTalk Support::.
1157
1158 `undefined-keystroke-sequence'
1159      `"Undefined keystroke sequence"'
1160 `void-function'
1161      `"Symbol's function definition is void"'
1162      *Note Function Cells::.
1163
1164 `void-variable'
1165      `"Symbol's value as variable is void"'
1166      *Note Accessing Variables::.
1167
1168 `wrong-number-of-arguments'
1169      `"Wrong number of arguments"'
1170      *Note Classifying Lists::.
1171
1172 `wrong-type-argument'
1173      `"Wrong type argument"'
1174      *Note Type Predicates::.
1175
1176    These error types, which are all classified as special cases of
1177 `arith-error', can occur on certain systems for invalid use of
1178 mathematical functions.
1179
1180 `domain-error'
1181      `"Arithmetic domain error"'
1182      *Note Math Functions::.
1183
1184 `overflow-error'
1185      `"Arithmetic overflow error"'
1186      *Note Math Functions::.
1187
1188 `range-error'
1189      `"Arithmetic range error"'
1190      *Note Math Functions::.
1191
1192 `singularity-error'
1193      `"Arithmetic singularity error"'
1194      *Note Math Functions::.
1195
1196 `underflow-error'
1197      `"Arithmetic underflow error"'
1198      *Note Math Functions::.
1199