1 This is ../info/lispref.info, produced by makeinfo version 4.0 from
4 INFO-DIR-SECTION XEmacs Editor
6 * Lispref: (lispref). XEmacs Lisp Reference Manual.
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
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.
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.
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.
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.
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.
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.
53 File: lispref.info, Node: Style Tips, Next: Compilation Tips, Up: Tips
55 Writing Clean Lisp Programs
56 ===========================
58 Here are some tips for avoiding common errors in writing Lisp code
59 intended for widespread use:
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.
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.
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.
80 If one prefix is insufficient, your package may use two or three
81 alternative common prefixes, so long as they make sense.
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
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
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.
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:
98 (eval-when-compile (require 'BAR))
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::.
106 Using `eval-when-compile' avoids loading BAR when the compiled
107 version of FOO is _used_.
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::.
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
118 * If a user option variable records a true-or-false condition, give
119 it a name that ends in `-flag'.
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.
125 Instead, define sequences consisting of `C-c' followed by a
126 non-letter. These sequences are reserved for major modes.
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.
132 * Sequences consisting of `C-c' followed by `{', `}', `<', `>', `:'
133 or `;' are also reserved for major modes.
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.
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
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
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.
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
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.
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.
171 * It is a bad idea to define aliases for the Emacs primitives. Use
172 the standard names instead.
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.
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.
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.
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::.
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::.
197 In particular, don't use these functions:
199 * `beginning-of-buffer', `end-of-buffer'
201 * `replace-string', `replace-regexp'
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
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
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
218 * The recommended way to print a message in the echo area is with
219 the `message' function, not `princ'. *Note The Echo Area::.
221 * When you encounter an error condition, call the function `error'
222 (or `signal'). The function `error' does not return. *Note
225 Do not use `message', `throw', `sleep-for', or `beep' to report
228 * An error message should start with a capital letter but should not
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::.
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
244 * Indent each function with `C-M-q' (`indent-sexp') using the
245 default indentation parameters.
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
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.
260 File: lispref.info, Node: Compilation Tips, Next: Documentation Tips, Prev: Style Tips, Up: Tips
262 Tips for Making Compiled Code Fast
263 ==================================
265 Here are ways of improving the execution speed of byte-compiled Lisp
268 * Use the `profile' library to profile your program. See the file
269 `profile.el' for instructions.
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.
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.
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.
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::):
291 (get 'aref 'byte-compile)
292 => byte-compile-two-args
294 (get 'elt 'byte-compile)
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::.
305 File: lispref.info, Node: Documentation Tips, Next: Comment Tips, Prev: Compilation Tips, Up: Tips
307 Tips for Documentation Strings
308 ==============================
310 Here are some tips for the writing of documentation strings.
312 * Every command, function, or variable intended for users to know
313 about should have a documentation string.
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.
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.
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.
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.
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."
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."
347 * Do not start or end a documentation string with whitespace.
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.
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
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!
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::.
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.
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'.
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
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.)
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::.
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
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.
414 File: lispref.info, Node: Comment Tips, Next: Library Headers, Prev: Documentation Tips, Up: Tips
416 Tips on Writing Comments
417 ========================
419 We recommend these conventions for where to put comments and how to
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.
430 This and following examples are taken from the Emacs sources.
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
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:
443 (prog1 (setq auto-fill-function
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.
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:
462 ;;; This Lisp code is run in XEmacs
463 ;;; when it is to operate as a server
464 ;;; for other processes.
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.
471 ;;; This is no longer necessary.
472 ;;; (force-mode-line-update)
473 (message "Finished with %s" a))
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:
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: (emacs)Comments.
488 File: lispref.info, Node: Library Headers, Prev: Comment Tips, Up: Tips
490 Conventional Headers for XEmacs Libraries
491 =========================================
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:
497 ;;; lisp-mnt.el --- minor mode for Emacs Lisp maintainers
499 ;; Copyright (C) 1992 Free Software Foundation, Inc.
501 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
502 ;; Maintainer: Eric S. Raymond <esr@snark.thyrsus.com>
503 ;; Created: 14 Jul 1992
507 ;; This file is part of XEmacs.
508 COPYING PERMISSIONS...
510 The very first line should have this format:
512 ;;; FILENAME --- DESCRIPTION
514 The description should be complete in one line.
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:
521 This line states the name and net address of at least the principal
522 author of the library.
524 If there are multiple authors, you can list them on continuation
525 lines led by `;;' and a tab character, like this:
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>
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.
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.
543 Be sure to surround the network address with `<...>' if you
544 include the person's full name as well as the network address.
547 This optional line gives the original creation date of the file.
548 For historical interest only.
551 If you wish to record version numbers for the individual Lisp
552 program, put them in this line.
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
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.
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.
570 We use additional stylized comments to subdivide the contents of the
571 library file. Here is a table of them:
574 This begins introductory comments that explain how the library
575 works. It should come right after the copying permissions.
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.
585 This begins the actual code of the program.
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.
593 File: lispref.info, Node: Building XEmacs and Object Allocation, Next: Standard Errors, Prev: Tips, Up: Top
595 Building XEmacs; Allocation of Objects
596 **************************************
598 This chapter describes how the runnable XEmacs executable is dumped
599 with the preloaded Lisp libraries in it and how storage is allocated.
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.
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.
614 File: lispref.info, Node: Building XEmacs, Next: Pure Storage, Up: Building XEmacs and Object Allocation
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.
624 The `XEmacs Internals Manual' contains more information about this.
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
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.
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
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
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'.)
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.)
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.
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::.
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::.
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').
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::.
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.
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
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.
723 => "XEmacs 20.1 [Lucid] (i586-unknown-linux2.0.29)
724 of Mon Apr 7 1997 on altair.xemacs.org"
726 Called interactively, the function prints the same information in
729 - Variable: emacs-build-time
730 The value of this variable is the time at which XEmacs was built
733 emacs-build-time "Mon Apr 7 20:28:52 1997"
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"'.
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.
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.
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.
753 File: lispref.info, Node: Pure Storage, Next: Garbage Collection, Prev: Building XEmacs, Up: Building XEmacs and Object Allocation
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.
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
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.
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.
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.
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.
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.
807 You should not change this flag in a running XEmacs.
810 File: lispref.info, Node: Garbage Collection, Prev: Pure Storage, Up: Building XEmacs and Object Allocation
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.])
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.)
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
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.
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'.
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
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
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.)
875 `garbage-collect' returns a list containing the following
878 ((USED-CONSES . FREE-CONSES)
879 (USED-SYMS . FREE-SYMS)
880 (USED-MARKERS . FREE-MARKERS)
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))
932 Here is a table explaining each element:
935 The number of cons cells in use.
938 The number of cons cells for which space has been obtained
939 from the operating system, but that are not currently being
943 The number of symbols in use.
946 The number of symbols for which space has been obtained from
947 the operating system, but that are not currently being used.
950 The number of markers in use.
953 The number of markers for which space has been obtained from
954 the operating system, but that are not currently being used.
957 The total size of all strings, in characters.
960 The total number of elements of existing vectors.
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.)
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.
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.
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!)
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
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.
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.
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::.
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.
1024 - Variable: debug-allocation
1025 If non-zero, print out information to stderr about all objects
1028 - Variable: debug-allocation-backtrace
1029 Length (in stack frames) of short backtrace printed out by
1033 File: lispref.info, Node: Standard Errors, Next: Standard Buffer-Local Variables, Prev: Building XEmacs and Object Allocation, Up: Top
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.
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'.
1050 As a special exception, the error symbol `quit' does not have the
1051 condition `error', because quitting is not considered an error.
1053 *Note Errors::, for an explanation of how errors are generated and
1068 `"Args out of range"'
1069 *Note Sequences Arrays Vectors::.
1072 `"Arithmetic error"'
1073 See `/' and `%' in *Note Numbers::.
1075 `beginning-of-buffer'
1076 `"Beginning of buffer"'
1080 `"Buffer is read-only"'
1081 *Note Read Only Buffers::.
1083 `cyclic-function-indirection'
1084 `"Symbol's chain of function indirections contains a loop"'
1085 *Note Function Indirection::.
1088 `"Arithmetic domain error"'
1094 `"End of file during parsing"'
1095 This is not a `file-error'.
1096 *Note Input Functions::.
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.
1105 This is a `file-error'.
1108 `file-already-exists'
1109 This is a `file-error'.
1110 *Note Writing to Files::.
1113 This is a `file-error'.
1114 *Note Modification Time::.
1117 `"Invalid byte code"'
1118 *Note Byte Compilation::.
1121 `"Invalid function"'
1122 *Note Classifying Lists::.
1124 `invalid-read-syntax'
1125 `"Invalid read syntax"'
1126 *Note Input Functions::.
1130 *Note Regular Expressions::.
1133 `"The mark is not active now"'
1135 `"No catch for tag"'
1136 *Note Catch and Throw::.
1139 `"Arithmetic overflow error"'
1141 `"Attempt to modify a protected field"'
1143 `"Arithmetic range error"'
1146 *Note Searching and Matching::.
1149 `"Attempt to set a constant symbol"'
1150 *Note Variables that Never Change: Constant Variables.
1153 `"Arithmetic singularity error"'
1156 *Note ToolTalk Support::.
1158 `undefined-keystroke-sequence'
1159 `"Undefined keystroke sequence"'
1161 `"Symbol's function definition is void"'
1162 *Note Function Cells::.
1165 `"Symbol's value as variable is void"'
1166 *Note Accessing Variables::.
1168 `wrong-number-of-arguments'
1169 `"Wrong number of arguments"'
1170 *Note Classifying Lists::.
1172 `wrong-type-argument'
1173 `"Wrong type argument"'
1174 *Note Type Predicates::.
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.
1181 `"Arithmetic domain error"'
1182 *Note Math Functions::.
1185 `"Arithmetic overflow error"'
1186 *Note Math Functions::.
1189 `"Arithmetic range error"'
1190 *Note Math Functions::.
1193 `"Arithmetic singularity error"'
1194 *Note Math Functions::.
1197 `"Arithmetic underflow error"'
1198 *Note Math Functions::.