e2a39c4506f5f8202af67c0d9379fce964a77fdf
[chise/xemacs-chise.git.1] / info / lispref.info-2
1 This is ../info/lispref.info, produced by makeinfo version 4.0 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: Copying,  Next: Introduction,  Prev: Top,  Up: Top
54
55 GNU GENERAL PUBLIC LICENSE
56 **************************
57
58                          Version 2, June 1991
59
60      Copyright (C) 1989, 1991 Free Software Foundation, Inc.
61      675 Mass Ave, Cambridge, MA 02139, USA
62      
63      Everyone is permitted to copy and distribute verbatim copies
64      of this license document, but changing it is not allowed.
65
66 Preamble
67 ========
68
69    The licenses for most software are designed to take away your
70 freedom to share and change it.  By contrast, the GNU General Public
71 License is intended to guarantee your freedom to share and change free
72 software--to make sure the software is free for all its users.  This
73 General Public License applies to most of the Free Software
74 Foundation's software and to any other program whose authors commit to
75 using it.  (Some other Free Software Foundation software is covered by
76 the GNU Library General Public License instead.)  You can apply it to
77 your programs, too.
78
79    When we speak of free software, we are referring to freedom, not
80 price.  Our General Public Licenses are designed to make sure that you
81 have the freedom to distribute copies of free software (and charge for
82 this service if you wish), that you receive source code or can get it
83 if you want it, that you can change the software or use pieces of it in
84 new free programs; and that you know you can do these things.
85
86    To protect your rights, we need to make restrictions that forbid
87 anyone to deny you these rights or to ask you to surrender the rights.
88 These restrictions translate to certain responsibilities for you if you
89 distribute copies of the software, or if you modify it.
90
91    For example, if you distribute copies of such a program, whether
92 gratis or for a fee, you must give the recipients all the rights that
93 you have.  You must make sure that they, too, receive or can get the
94 source code.  And you must show them these terms so they know their
95 rights.
96
97    We protect your rights with two steps: (1) copyright the software,
98 and (2) offer you this license which gives you legal permission to copy,
99 distribute and/or modify the software.
100
101    Also, for each author's protection and ours, we want to make certain
102 that everyone understands that there is no warranty for this free
103 software.  If the software is modified by someone else and passed on, we
104 want its recipients to know that what they have is not the original, so
105 that any problems introduced by others will not reflect on the original
106 authors' reputations.
107
108    Finally, any free program is threatened constantly by software
109 patents.  We wish to avoid the danger that redistributors of a free
110 program will individually obtain patent licenses, in effect making the
111 program proprietary.  To prevent this, we have made it clear that any
112 patent must be licensed for everyone's free use or not licensed at all.
113
114    The precise terms and conditions for copying, distribution and
115 modification follow.
116
117     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
118
119   0. This License applies to any program or other work which contains a
120      notice placed by the copyright holder saying it may be distributed
121      under the terms of this General Public License.  The "Program",
122      below, refers to any such program or work, and a "work based on
123      the Program" means either the Program or any derivative work under
124      copyright law: that is to say, a work containing the Program or a
125      portion of it, either verbatim or with modifications and/or
126      translated into another language.  (Hereinafter, translation is
127      included without limitation in the term "modification".)  Each
128      licensee is addressed as "you".
129
130      Activities other than copying, distribution and modification are
131      not covered by this License; they are outside its scope.  The act
132      of running the Program is not restricted, and the output from the
133      Program is covered only if its contents constitute a work based on
134      the Program (independent of having been made by running the
135      Program).  Whether that is true depends on what the Program does.
136
137   1. You may copy and distribute verbatim copies of the Program's
138      source code as you receive it, in any medium, provided that you
139      conspicuously and appropriately publish on each copy an appropriate
140      copyright notice and disclaimer of warranty; keep intact all the
141      notices that refer to this License and to the absence of any
142      warranty; and give any other recipients of the Program a copy of
143      this License along with the Program.
144
145      You may charge a fee for the physical act of transferring a copy,
146      and you may at your option offer warranty protection in exchange
147      for a fee.
148
149   2. You may modify your copy or copies of the Program or any portion
150      of it, thus forming a work based on the Program, and copy and
151      distribute such modifications or work under the terms of Section 1
152      above, provided that you also meet all of these conditions:
153
154        a. You must cause the modified files to carry prominent notices
155           stating that you changed the files and the date of any change.
156
157        b. You must cause any work that you distribute or publish, that
158           in whole or in part contains or is derived from the Program
159           or any part thereof, to be licensed as a whole at no charge
160           to all third parties under the terms of this License.
161
162        c. If the modified program normally reads commands interactively
163           when run, you must cause it, when started running for such
164           interactive use in the most ordinary way, to print or display
165           an announcement including an appropriate copyright notice and
166           a notice that there is no warranty (or else, saying that you
167           provide a warranty) and that users may redistribute the
168           program under these conditions, and telling the user how to
169           view a copy of this License.  (Exception: if the Program
170           itself is interactive but does not normally print such an
171           announcement, your work based on the Program is not required
172           to print an announcement.)
173
174      These requirements apply to the modified work as a whole.  If
175      identifiable sections of that work are not derived from the
176      Program, and can be reasonably considered independent and separate
177      works in themselves, then this License, and its terms, do not
178      apply to those sections when you distribute them as separate
179      works.  But when you distribute the same sections as part of a
180      whole which is a work based on the Program, the distribution of
181      the whole must be on the terms of this License, whose permissions
182      for other licensees extend to the entire whole, and thus to each
183      and every part regardless of who wrote it.
184
185      Thus, it is not the intent of this section to claim rights or
186      contest your rights to work written entirely by you; rather, the
187      intent is to exercise the right to control the distribution of
188      derivative or collective works based on the Program.
189
190      In addition, mere aggregation of another work not based on the
191      Program with the Program (or with a work based on the Program) on
192      a volume of a storage or distribution medium does not bring the
193      other work under the scope of this License.
194
195   3. You may copy and distribute the Program (or a work based on it,
196      under Section 2) in object code or executable form under the terms
197      of Sections 1 and 2 above provided that you also do one of the
198      following:
199
200        a. Accompany it with the complete corresponding machine-readable
201           source code, which must be distributed under the terms of
202           Sections 1 and 2 above on a medium customarily used for
203           software interchange; or,
204
205        b. Accompany it with a written offer, valid for at least three
206           years, to give any third party, for a charge no more than your
207           cost of physically performing source distribution, a complete
208           machine-readable copy of the corresponding source code, to be
209           distributed under the terms of Sections 1 and 2 above on a
210           medium customarily used for software interchange; or,
211
212        c. Accompany it with the information you received as to the offer
213           to distribute corresponding source code.  (This alternative is
214           allowed only for noncommercial distribution and only if you
215           received the program in object code or executable form with
216           such an offer, in accord with Subsection b above.)
217
218      The source code for a work means the preferred form of the work for
219      making modifications to it.  For an executable work, complete
220      source code means all the source code for all modules it contains,
221      plus any associated interface definition files, plus the scripts
222      used to control compilation and installation of the executable.
223      However, as a special exception, the source code distributed need
224      not include anything that is normally distributed (in either
225      source or binary form) with the major components (compiler,
226      kernel, and so on) of the operating system on which the executable
227      runs, unless that component itself accompanies the executable.
228
229      If distribution of executable or object code is made by offering
230      access to copy from a designated place, then offering equivalent
231      access to copy the source code from the same place counts as
232      distribution of the source code, even though third parties are not
233      compelled to copy the source along with the object code.
234
235   4. You may not copy, modify, sublicense, or distribute the Program
236      except as expressly provided under this License.  Any attempt
237      otherwise to copy, modify, sublicense or distribute the Program is
238      void, and will automatically terminate your rights under this
239      License.  However, parties who have received copies, or rights,
240      from you under this License will not have their licenses
241      terminated so long as such parties remain in full compliance.
242
243   5. You are not required to accept this License, since you have not
244      signed it.  However, nothing else grants you permission to modify
245      or distribute the Program or its derivative works.  These actions
246      are prohibited by law if you do not accept this License.
247      Therefore, by modifying or distributing the Program (or any work
248      based on the Program), you indicate your acceptance of this
249      License to do so, and all its terms and conditions for copying,
250      distributing or modifying the Program or works based on it.
251
252   6. Each time you redistribute the Program (or any work based on the
253      Program), the recipient automatically receives a license from the
254      original licensor to copy, distribute or modify the Program
255      subject to these terms and conditions.  You may not impose any
256      further restrictions on the recipients' exercise of the rights
257      granted herein.  You are not responsible for enforcing compliance
258      by third parties to this License.
259
260   7. If, as a consequence of a court judgment or allegation of patent
261      infringement or for any other reason (not limited to patent
262      issues), conditions are imposed on you (whether by court order,
263      agreement or otherwise) that contradict the conditions of this
264      License, they do not excuse you from the conditions of this
265      License.  If you cannot distribute so as to satisfy simultaneously
266      your obligations under this License and any other pertinent
267      obligations, then as a consequence you may not distribute the
268      Program at all.  For example, if a patent license would not permit
269      royalty-free redistribution of the Program by all those who
270      receive copies directly or indirectly through you, then the only
271      way you could satisfy both it and this License would be to refrain
272      entirely from distribution of the Program.
273
274      If any portion of this section is held invalid or unenforceable
275      under any particular circumstance, the balance of the section is
276      intended to apply and the section as a whole is intended to apply
277      in other circumstances.
278
279      It is not the purpose of this section to induce you to infringe any
280      patents or other property right claims or to contest validity of
281      any such claims; this section has the sole purpose of protecting
282      the integrity of the free software distribution system, which is
283      implemented by public license practices.  Many people have made
284      generous contributions to the wide range of software distributed
285      through that system in reliance on consistent application of that
286      system; it is up to the author/donor to decide if he or she is
287      willing to distribute software through any other system and a
288      licensee cannot impose that choice.
289
290      This section is intended to make thoroughly clear what is believed
291      to be a consequence of the rest of this License.
292
293   8. If the distribution and/or use of the Program is restricted in
294      certain countries either by patents or by copyrighted interfaces,
295      the original copyright holder who places the Program under this
296      License may add an explicit geographical distribution limitation
297      excluding those countries, so that distribution is permitted only
298      in or among countries not thus excluded.  In such case, this
299      License incorporates the limitation as if written in the body of
300      this License.
301
302   9. The Free Software Foundation may publish revised and/or new
303      versions of the General Public License from time to time.  Such
304      new versions will be similar in spirit to the present version, but
305      may differ in detail to address new problems or concerns.
306
307      Each version is given a distinguishing version number.  If the
308      Program specifies a version number of this License which applies
309      to it and "any later version", you have the option of following
310      the terms and conditions either of that version or of any later
311      version published by the Free Software Foundation.  If the Program
312      does not specify a version number of this License, you may choose
313      any version ever published by the Free Software Foundation.
314
315  10. If you wish to incorporate parts of the Program into other free
316      programs whose distribution conditions are different, write to the
317      author to ask for permission.  For software which is copyrighted
318      by the Free Software Foundation, write to the Free Software
319      Foundation; we sometimes make exceptions for this.  Our decision
320      will be guided by the two goals of preserving the free status of
321      all derivatives of our free software and of promoting the sharing
322      and reuse of software generally.
323
324                                 NO WARRANTY
325
326  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
327      WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
328      LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
329      HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
330      WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
331      NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
332      FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
333      QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
334      PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
335      SERVICING, REPAIR OR CORRECTION.
336
337  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
338      WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
339      MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
340      LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
341      INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
342      INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
343      DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
344      OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
345      OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
346      ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
347
348                       END OF TERMS AND CONDITIONS
349
350 How to Apply These Terms to Your New Programs
351 =============================================
352
353    If you develop a new program, and you want it to be of the greatest
354 possible use to the public, the best way to achieve this is to make it
355 free software which everyone can redistribute and change under these
356 terms.
357
358    To do so, attach the following notices to the program.  It is safest
359 to attach them to the start of each source file to most effectively
360 convey the exclusion of warranty; and each file should have at least
361 the "copyright" line and a pointer to where the full notice is found.
362
363      ONE LINE TO GIVE THE PROGRAM'S NAME AND AN IDEA OF WHAT IT DOES.
364      Copyright (C) 19YY  NAME OF AUTHOR
365      
366      This program is free software; you can redistribute it and/or
367      modify it under the terms of the GNU General Public License
368      as published by the Free Software Foundation; either version 2
369      of the License, or (at your option) any later version.
370      
371      This program is distributed in the hope that it will be useful,
372      but WITHOUT ANY WARRANTY; without even the implied warranty of
373      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
374      GNU General Public License for more details.
375      
376      You should have received a copy of the GNU General Public License
377      along with this program; if not, write to the Free Software
378      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
379
380    Also add information on how to contact you by electronic and paper
381 mail.
382
383    If the program is interactive, make it output a short notice like
384 this when it starts in an interactive mode:
385
386      Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
387      Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
388      type `show w'.  This is free software, and you are welcome
389      to redistribute it under certain conditions; type `show c'
390      for details.
391
392    The hypothetical commands `show w' and `show c' should show the
393 appropriate parts of the General Public License.  Of course, the
394 commands you use may be called something other than `show w' and `show
395 c'; they could even be mouse-clicks or menu items--whatever suits your
396 program.
397
398    You should also get your employer (if you work as a programmer) or
399 your school, if any, to sign a "copyright disclaimer" for the program,
400 if necessary.  Here is a sample; alter the names:
401
402      Yoyodyne, Inc., hereby disclaims all copyright
403      interest in the program `Gnomovision'
404      (which makes passes at compilers) written
405      by James Hacker.
406      
407      SIGNATURE OF TY COON, 1 April 1989
408      Ty Coon, President of Vice
409
410    This General Public License does not permit incorporating your
411 program into proprietary programs.  If your program is a subroutine
412 library, you may consider it more useful to permit linking proprietary
413 applications with the library.  If this is what you want to do, use the
414 GNU Library General Public License instead of this License.
415
416 \1f
417 File: lispref.info,  Node: Introduction,  Next: Lisp Data Types,  Prev: Copying,  Up: Top
418
419 Introduction
420 ************
421
422    Most of the XEmacs text editor is written in the programming
423 language called XEmacs Lisp.  You can write new code in XEmacs Lisp and
424 install it as an extension to the editor.  However, XEmacs Lisp is more
425 than a mere "extension language"; it is a full computer programming
426 language in its own right.  You can use it as you would any other
427 programming language.
428
429    Because XEmacs Lisp is designed for use in an editor, it has special
430 features for scanning and parsing text as well as features for handling
431 files, buffers, displays, subprocesses, and so on.  XEmacs Lisp is
432 closely integrated with the editing facilities; thus, editing commands
433 are functions that can also conveniently be called from Lisp programs,
434 and parameters for customization are ordinary Lisp variables.
435
436    This manual describes XEmacs Lisp, presuming considerable familiarity
437 with the use of XEmacs for editing.  (See `The XEmacs Reference
438 Manual', for this basic information.)  Generally speaking, the earlier
439 chapters describe features of XEmacs Lisp that have counterparts in many
440 programming languages, and later chapters describe features that are
441 peculiar to XEmacs Lisp or relate specifically to editing.
442
443    This is edition 3.3.
444
445 * Menu:
446
447 * Caveats::             Flaws and a request for help.
448 * Lisp History::        XEmacs Lisp is descended from Maclisp.
449 * Conventions::         How the manual is formatted.
450 * Acknowledgements::    The authors, editors, and sponsors of this manual.
451
452 \1f
453 File: lispref.info,  Node: Caveats,  Next: Lisp History,  Up: Introduction
454
455 Caveats
456 =======
457
458    This manual has gone through numerous drafts.  It is nearly complete
459 but not flawless.  There are a few topics that are not covered, either
460 because we consider them secondary (such as most of the individual
461 modes) or because they are yet to be written.  Because we are not able
462 to deal with them completely, we have left out several parts
463 intentionally.  This includes most information about usage on VMS.
464
465    The manual should be fully correct in what it does cover, and it is
466 therefore open to criticism on anything it says--from specific examples
467 and descriptive text, to the ordering of chapters and sections.  If
468 something is confusing, or you find that you have to look at the sources
469 or experiment to learn something not covered in the manual, then perhaps
470 the manual should be fixed.  Please let us know.
471
472    As you use this manual, we ask that you send corrections as soon as
473 you find them.  If you think of a simple, real life example for a
474 function or group of functions, please make an effort to write it up
475 and send it in.  Please reference any comments to the node name and
476 function or variable name, as appropriate.  Also state the number of
477 the edition which you are criticizing.
478
479    This manual was originally written for FSF Emacs 19 and was updated
480 by Ben Wing (ben@xemacs.org) for Lucid Emacs 19.10 and later for XEmacs
481 19.12, 19.13, 19.14, and 20.0.  It was further updated by the XEmacs
482 Development Team for 19.15 and 20.1.  Please send comments and
483 corrections relating to XEmacs-specific portions of this manual to
484      xemacs@xemacs.org
485
486    or post to the newsgroup
487      comp.emacs.xemacs
488
489       --Ben Wing
490
491 \1f
492 File: lispref.info,  Node: Lisp History,  Next: Conventions,  Prev: Caveats,  Up: Introduction
493
494 Lisp History
495 ============
496
497    Lisp (LISt Processing language) was first developed in the late
498 1950's at the Massachusetts Institute of Technology for research in
499 artificial intelligence.  The great power of the Lisp language makes it
500 superior for other purposes as well, such as writing editing commands.
501
502    Dozens of Lisp implementations have been built over the years, each
503 with its own idiosyncrasies.  Many of them were inspired by Maclisp,
504 which was written in the 1960's at MIT's Project MAC.  Eventually the
505 implementors of the descendants of Maclisp came together and developed a
506 standard for Lisp systems, called Common Lisp.
507
508    XEmacs Lisp is largely inspired by Maclisp, and a little by Common
509 Lisp.  If you know Common Lisp, you will notice many similarities.
510 However, many of the features of Common Lisp have been omitted or
511 simplified in order to reduce the memory requirements of XEmacs.
512 Sometimes the simplifications are so drastic that a Common Lisp user
513 might be very confused.  We will occasionally point out how XEmacs Lisp
514 differs from Common Lisp.  If you don't know Common Lisp, don't worry
515 about it; this manual is self-contained.
516
517 \1f
518 File: lispref.info,  Node: Conventions,  Next: Acknowledgements,  Prev: Lisp History,  Up: Introduction
519
520 Conventions
521 ===========
522
523    This section explains the notational conventions that are used in
524 this manual.  You may want to skip this section and refer back to it
525 later.
526
527 * Menu:
528
529 * Some Terms::               Explanation of terms we use in this manual.
530 * nil and t::                How the symbols `nil' and `t' are used.
531 * Evaluation Notation::      The format we use for examples of evaluation.
532 * Printing Notation::        The format we use for examples that print output.
533 * Error Messages::           The format we use for examples of errors.
534 * Buffer Text Notation::     The format we use for buffer contents in examples.
535 * Format of Descriptions::   Notation for describing functions, variables, etc.
536
537 \1f
538 File: lispref.info,  Node: Some Terms,  Next: nil and t,  Up: Conventions
539
540 Some Terms
541 ----------
542
543    Throughout this manual, the phrases "the Lisp reader" and "the Lisp
544 printer" are used to refer to those routines in Lisp that convert
545 textual representations of Lisp objects into actual Lisp objects, and
546 vice versa.  *Note Printed Representation::, for more details.  You, the
547 person reading this manual, are thought of as "the programmer" and are
548 addressed as "you".  "The user" is the person who uses Lisp programs,
549 including those you write.
550
551    Examples of Lisp code appear in this font or form: `(list 1 2 3)'.
552 Names that represent arguments or metasyntactic variables appear in
553 this font or form: FIRST-NUMBER.
554
555 \1f
556 File: lispref.info,  Node: nil and t,  Next: Evaluation Notation,  Prev: Some Terms,  Up: Conventions
557
558 `nil' and `t'
559 -------------
560
561    In Lisp, the symbol `nil' has three separate meanings: it is a
562 symbol with the name `nil'; it is the logical truth value FALSE; and it
563 is the empty list--the list of zero elements.  When used as a variable,
564 `nil' always has the value `nil'.
565
566    As far as the Lisp reader is concerned, `()' and `nil' are
567 identical: they stand for the same object, the symbol `nil'.  The
568 different ways of writing the symbol are intended entirely for human
569 readers.  After the Lisp reader has read either `()' or `nil', there is
570 no way to determine which representation was actually written by the
571 programmer.
572
573    In this manual, we use `()' when we wish to emphasize that it means
574 the empty list, and we use `nil' when we wish to emphasize that it
575 means the truth value FALSE.  That is a good convention to use in Lisp
576 programs also.
577
578      (cons 'foo ())                ; Emphasize the empty list
579      (not nil)                     ; Emphasize the truth value FALSE
580
581    In contexts where a truth value is expected, any non-`nil' value is
582 considered to be TRUE.  However, `t' is the preferred way to represent
583 the truth value TRUE.  When you need to choose a value which represents
584 TRUE, and there is no other basis for choosing, use `t'.  The symbol
585 `t' always has value `t'.
586
587    In XEmacs Lisp, `nil' and `t' are special symbols that always
588 evaluate to themselves.  This is so that you do not need to quote them
589 to use them as constants in a program.  An attempt to change their
590 values results in a `setting-constant' error.  *Note Accessing
591 Variables::.
592
593 \1f
594 File: lispref.info,  Node: Evaluation Notation,  Next: Printing Notation,  Prev: nil and t,  Up: Conventions
595
596 Evaluation Notation
597 -------------------
598
599    A Lisp expression that you can evaluate is called a "form".
600 Evaluating a form always produces a result, which is a Lisp object.  In
601 the examples in this manual, this is indicated with `=>':
602
603      (car '(1 2))
604           => 1
605
606 You can read this as "`(car '(1 2))' evaluates to 1".
607
608    When a form is a macro call, it expands into a new form for Lisp to
609 evaluate.  We show the result of the expansion with `==>'.  We may or
610 may not show the actual result of the evaluation of the expanded form.
611
612      (news-cadr '(a b c))
613           ==> (car (cdr '(a b c)))
614           => b
615
616    Sometimes to help describe one form we show another form that
617 produces identical results.  The exact equivalence of two forms is
618 indicated with `=='.
619
620      (cons 'a nil) == (list 'a)
621
622 \1f
623 File: lispref.info,  Node: Printing Notation,  Next: Error Messages,  Prev: Evaluation Notation,  Up: Conventions
624
625 Printing Notation
626 -----------------
627
628    Many of the examples in this manual print text when they are
629 evaluated.  If you execute example code in a Lisp Interaction buffer
630 (such as the buffer `*scratch*'), the printed text is inserted into the
631 buffer.  If you execute the example by other means (such as by
632 evaluating the function `eval-region'), the printed text is displayed
633 in the echo area.  You should be aware that text displayed in the echo
634 area is truncated to a single line.
635
636    Examples in this manual indicate printed text with `-|',
637 irrespective of where that text goes.  The value returned by evaluating
638 the form (here `bar') follows on a separate line.
639
640      (progn (print 'foo) (print 'bar))
641           -| foo
642           -| bar
643           => bar
644
645 \1f
646 File: lispref.info,  Node: Error Messages,  Next: Buffer Text Notation,  Prev: Printing Notation,  Up: Conventions
647
648 Error Messages
649 --------------
650
651    Some examples signal errors.  This normally displays an error message
652 in the echo area.  We show the error message on a line starting with
653 `error-->'.  Note that `error-->' itself does not appear in the echo
654 area.
655
656      (+ 23 'x)
657      error--> Wrong type argument: integer-or-marker-p, x
658
659 \1f
660 File: lispref.info,  Node: Buffer Text Notation,  Next: Format of Descriptions,  Prev: Error Messages,  Up: Conventions
661
662 Buffer Text Notation
663 --------------------
664
665    Some examples show modifications to text in a buffer, with "before"
666 and "after" versions of the text.  These examples show the contents of
667 the buffer in question between two lines of dashes containing the buffer
668 name.  In addition, `-!-' indicates the location of point.  (The symbol
669 for point, of course, is not part of the text in the buffer; it
670 indicates the place _between_ two characters where point is located.)
671
672      ---------- Buffer: foo ----------
673      This is the -!-contents of foo.
674      ---------- Buffer: foo ----------
675      
676      (insert "changed ")
677           => nil
678      ---------- Buffer: foo ----------
679      This is the changed -!-contents of foo.
680      ---------- Buffer: foo ----------
681
682 \1f
683 File: lispref.info,  Node: Format of Descriptions,  Prev: Buffer Text Notation,  Up: Conventions
684
685 Format of Descriptions
686 ----------------------
687
688    Functions, variables, macros, commands, user options, and special
689 forms are described in this manual in a uniform format.  The first line
690 of a description contains the name of the item followed by its
691 arguments, if any.  The category--function, variable, or
692 whatever--appears at the beginning of the line.  The description
693 follows on succeeding lines, sometimes with examples.
694
695 * Menu:
696
697 * A Sample Function Description::       A description of an imaginary
698                                           function, `foo'.
699 * A Sample Variable Description::       A description of an imaginary
700                                           variable,
701                                           `electric-future-map'.
702
703 \1f
704 File: lispref.info,  Node: A Sample Function Description,  Next: A Sample Variable Description,  Up: Format of Descriptions
705
706 A Sample Function Description
707 .............................
708
709    In a function description, the name of the function being described
710 appears first.  It is followed on the same line by a list of parameters.
711 The names used for the parameters are also used in the body of the
712 description.
713
714    The appearance of the keyword `&optional' in the parameter list
715 indicates that the arguments for subsequent parameters may be omitted
716 (omitted parameters default to `nil').  Do not write `&optional' when
717 you call the function.
718
719    The keyword `&rest' (which will always be followed by a single
720 parameter) indicates that any number of arguments can follow.  The value
721 of the single following parameter will be a list of all these arguments.
722 Do not write `&rest' when you call the function.
723
724    Here is a description of an imaginary function `foo':
725
726  - Function: foo integer1 &optional integer2 &rest integers
727      The function `foo' subtracts INTEGER1 from INTEGER2, then adds all
728      the rest of the arguments to the result.  If INTEGER2 is not
729      supplied, then the number 19 is used by default.
730
731           (foo 1 5 3 9)
732                => 16
733           (foo 5)
734                => 14
735
736      More generally,
737
738           (foo W X Y...)
739           ==
740           (+ (- X W) Y...)
741
742    Any parameter whose name contains the name of a type (e.g., INTEGER,
743 INTEGER1 or BUFFER) is expected to be of that type.  A plural of a type
744 (such as BUFFERS) often means a list of objects of that type.
745 Parameters named OBJECT may be of any type.  (*Note Lisp Data Types::,
746 for a list of XEmacs object types.)  Parameters with other sorts of
747 names (e.g., NEW-FILE) are discussed specifically in the description of
748 the function.  In some sections, features common to parameters of
749 several functions are described at the beginning.
750
751    *Note Lambda Expressions::, for a more complete description of
752 optional and rest arguments.
753
754    Command, macro, and special form descriptions have the same format,
755 but the word `Function' is replaced by `Command', `Macro', or `Special
756 Form', respectively.  Commands are simply functions that may be called
757 interactively; macros process their arguments differently from functions
758 (the arguments are not evaluated), but are presented the same way.
759
760    Special form descriptions use a more complex notation to specify
761 optional and repeated parameters because they can break the argument
762 list down into separate arguments in more complicated ways.
763 ``[OPTIONAL-ARG]'' means that OPTIONAL-ARG is optional and
764 `REPEATED-ARGS...' stands for zero or more arguments.  Parentheses are
765 used when several arguments are grouped into additional levels of list
766 structure.  Here is an example:
767
768  - Special Form: count-loop (VAR [FROM TO [INC]]) BODY...
769      This imaginary special form implements a loop that executes the
770      BODY forms and then increments the variable VAR on each iteration.
771      On the first iteration, the variable has the value FROM; on
772      subsequent iterations, it is incremented by 1 (or by INC if that
773      is given).  The loop exits before executing BODY if VAR equals TO.
774      Here is an example:
775
776           (count-loop (i 0 10)
777             (prin1 i) (princ " ")
778             (prin1 (aref vector i)) (terpri))
779
780      If FROM and TO are omitted, then VAR is bound to `nil' before the
781      loop begins, and the loop exits if VAR is non-`nil' at the
782      beginning of an iteration.  Here is an example:
783
784           (count-loop (done)
785             (if (pending)
786                 (fixit)
787               (setq done t)))
788
789      In this special form, the arguments FROM and TO are optional, but
790      must both be present or both absent.  If they are present, INC may
791      optionally be specified as well.  These arguments are grouped with
792      the argument VAR into a list, to distinguish them from BODY, which
793      includes all remaining elements of the form.
794
795 \1f
796 File: lispref.info,  Node: A Sample Variable Description,  Prev: A Sample Function Description,  Up: Format of Descriptions
797
798 A Sample Variable Description
799 .............................
800
801    A "variable" is a name that can hold a value.  Although any variable
802 can be set by the user, certain variables that exist specifically so
803 that users can change them are called "user options".  Ordinary
804 variables and user options are described using a format like that for
805 functions except that there are no arguments.
806
807    Here is a description of the imaginary `electric-future-map'
808 variable.
809
810  - Variable: electric-future-map
811      The value of this variable is a full keymap used by Electric
812      Command Future mode.  The functions in this map allow you to edit
813      commands you have not yet thought about executing.
814
815    User option descriptions have the same format, but `Variable' is
816 replaced by `User Option'.
817
818 \1f
819 File: lispref.info,  Node: Acknowledgements,  Prev: Conventions,  Up: Introduction
820
821 Acknowledgements
822 ================
823
824    This manual was based on the GNU Emacs Lisp Reference Manual, version
825 2.4, written by Robert Krawitz, Bil Lewis, Dan LaLiberte, Richard M.
826 Stallman and Chris Welty, the volunteers of the GNU manual group, in an
827 effort extending over several years.  Robert J. Chassell helped to
828 review and edit the manual, with the support of the Defense Advanced
829 Research Projects Agency, ARPA Order 6082, arranged by Warren A. Hunt,
830 Jr. of Computational Logic, Inc.
831
832    Ben Wing adapted this manual for XEmacs 19.14 and 20.0, and earlier
833 for Lucid Emacs 19.10, XEmacs 19.12, and XEmacs 19.13.  He is the sole
834 author of many of the manual sections, in particular the XEmacs-specific
835 sections: events, faces, extents, glyphs, specifiers, toolbar, menubars,
836 scrollbars, dialog boxes, devices, consoles, hash tables, range tables,
837 char tables, databases, and others.  The section on annotations was
838 originally written by Chuck Thompson.  Corrections to v3.1 and later
839 were done by Martin Buchholz, Steve Baur, and Hrvoje Niksic.
840
841    Corrections to the original GNU Emacs Lisp Reference Manual were
842 supplied by Karl Berry, Jim Blandy, Bard Bloom, Stephane Boucher, David
843 Boyes, Alan Carroll, Richard Davis, Lawrence R. Dodd, Peter Doornbosch,
844 David A. Duff, Chris Eich, Beverly Erlebacher, David Eckelkamp, Ralf
845 Fassel, Eirik Fuller, Stephen Gildea, Bob Glickstein, Eric Hanchrow,
846 George Hartzell, Nathan Hess, Masayuki Ida, Dan Jacobson, Jak Kirman,
847 Bob Knighten, Frederick M. Korz, Joe Lammens, Glenn M. Lewis, K. Richard
848 Magill, Brian Marick, Roland McGrath, Skip Montanaro, John Gardiner
849 Myers, Thomas A. Peterson, Francesco Potorti, Friedrich Pukelsheim,
850 Arnold D. Robbins, Raul Rockwell, Per Starback, Shinichirou Sugou, Kimmo
851 Suominen, Edward Tharp, Bill Trost, Rickard Westman, Jean White, Matthew
852 Wilding, Carl Witty, Dale Worley, Rusty Wright, and David D. Zuhn.
853
854 \1f
855 File: lispref.info,  Node: Lisp Data Types,  Next: Numbers,  Prev: Introduction,  Up: Top
856
857 Lisp Data Types
858 ***************
859
860    A Lisp "object" is a piece of data used and manipulated by Lisp
861 programs.  For our purposes, a "type" or "data type" is a set of
862 possible objects.
863
864    Every object belongs to at least one type.  Objects of the same type
865 have similar structures and may usually be used in the same contexts.
866 Types can overlap, and objects can belong to two or more types.
867 Consequently, we can ask whether an object belongs to a particular type,
868 but not for "the" type of an object.
869
870    A few fundamental object types are built into XEmacs.  These, from
871 which all other types are constructed, are called "primitive types".
872 Each object belongs to one and only one primitive type.  These types
873 include "integer", "character" (starting with XEmacs 20.0), "float",
874 "cons", "symbol", "string", "vector", "bit-vector", "subr",
875 "compiled-function", "hash-table", "range-table", "char-table",
876 "weak-list", and several special types, such as "buffer", that are
877 related to editing.  (*Note Editing Types::.)
878
879    Each primitive type has a corresponding Lisp function that checks
880 whether an object is a member of that type.
881
882    Note that Lisp is unlike many other languages in that Lisp objects
883 are "self-typing": the primitive type of the object is implicit in the
884 object itself.  For example, if an object is a vector, nothing can treat
885 it as a number; Lisp knows it is a vector, not a number.
886
887    In most languages, the programmer must declare the data type of each
888 variable, and the type is known by the compiler but not represented in
889 the data.  Such type declarations do not exist in XEmacs Lisp.  A Lisp
890 variable can have any type of value, and it remembers whatever value
891 you store in it, type and all.
892
893    This chapter describes the purpose, printed representation, and read
894 syntax of each of the standard types in Emacs Lisp.  Details on how to
895 use these types can be found in later chapters.
896
897 * Menu:
898
899 * Printed Representation::      How Lisp objects are represented as text.
900 * Comments::                    Comments and their formatting conventions.
901 * Primitive Types::             List of all primitive types in XEmacs.
902 * Programming Types::           Types found in all Lisp systems.
903 * Editing Types::               Types specific to XEmacs.
904 * Window-System Types::         Types specific to windowing systems.
905 * Type Predicates::             Tests related to types.
906 * Equality Predicates::         Tests of equality between any two objects.
907
908 \1f
909 File: lispref.info,  Node: Printed Representation,  Next: Comments,  Up: Lisp Data Types
910
911 Printed Representation and Read Syntax
912 ======================================
913
914    The "printed representation" of an object is the format of the
915 output generated by the Lisp printer (the function `prin1') for that
916 object.  The "read syntax" of an object is the format of the input
917 accepted by the Lisp reader (the function `read') for that object.
918 Most objects have more than one possible read syntax.  Some types of
919 object have no read syntax; except for these cases, the printed
920 representation of an object is also a read syntax for it.
921
922    In other languages, an expression is text; it has no other form.  In
923 Lisp, an expression is primarily a Lisp object and only secondarily the
924 text that is the object's read syntax.  Often there is no need to
925 emphasize this distinction, but you must keep it in the back of your
926 mind, or you will occasionally be very confused.
927
928    Every type has a printed representation.  Some types have no read
929 syntax, since it may not make sense to enter objects of these types
930 directly in a Lisp program.  For example, the buffer type does not have
931 a read syntax.  Objects of these types are printed in "hash notation":
932 the characters `#<' followed by a descriptive string (typically the
933 type name followed by the name of the object), and closed with a
934 matching `>'.  Hash notation cannot be read at all, so the Lisp reader
935 signals the error `invalid-read-syntax' whenever it encounters `#<'.
936
937      (current-buffer)
938           => #<buffer "objects.texi">
939
940    When you evaluate an expression interactively, the Lisp interpreter
941 first reads the textual representation of it, producing a Lisp object,
942 and then evaluates that object (*note Evaluation::).  However,
943 evaluation and reading are separate activities.  Reading returns the
944 Lisp object represented by the text that is read; the object may or may
945 not be evaluated later.  *Note Input Functions::, for a description of
946 `read', the basic function for reading objects.
947
948 \1f
949 File: lispref.info,  Node: Comments,  Next: Primitive Types,  Prev: Printed Representation,  Up: Lisp Data Types
950
951 Comments
952 ========
953
954    A "comment" is text that is written in a program only for the sake
955 of humans that read the program, and that has no effect on the meaning
956 of the program.  In Lisp, a semicolon (`;') starts a comment if it is
957 not within a string or character constant.  The comment continues to
958 the end of line.  The Lisp reader discards comments; they do not become
959 part of the Lisp objects which represent the program within the Lisp
960 system.
961
962    The `#@COUNT' construct, which skips the next COUNT characters, is
963 useful for program-generated comments containing binary data.  The
964 XEmacs Lisp byte compiler uses this in its output files (*note Byte
965 Compilation::).  It isn't meant for source files, however.
966
967    *Note Comment Tips::, for conventions for formatting comments.
968
969 \1f
970 File: lispref.info,  Node: Primitive Types,  Next: Programming Types,  Prev: Comments,  Up: Lisp Data Types
971
972 Primitive Types
973 ===============
974
975    For reference, here is a list of all the primitive types that may
976 exist in XEmacs.  Note that some of these types may not exist in some
977 XEmacs executables; that depends on the options that XEmacs was
978 configured with.
979
980    * bit-vector
981
982    * buffer
983
984    * char-table
985
986    * character
987
988    * charset
989
990    * coding-system
991
992    * cons
993
994    * color-instance
995
996    * compiled-function
997
998    * console
999
1000    * database
1001
1002    * device
1003
1004    * event
1005
1006    * extent
1007
1008    * face
1009
1010    * float
1011
1012    * font-instance
1013
1014    * frame
1015
1016    * glyph
1017
1018    * hash-table
1019
1020    * image-instance
1021
1022    * integer
1023
1024    * keymap
1025
1026    * marker
1027
1028    * process
1029
1030    * range-table
1031
1032    * specifier
1033
1034    * string
1035
1036    * subr
1037
1038    * subwindow
1039
1040    * symbol
1041
1042    * toolbar-button
1043
1044    * tooltalk-message
1045
1046    * tooltalk-pattern
1047
1048    * vector
1049
1050    * weak-list
1051
1052    * window
1053
1054    * window-configuration
1055
1056    * x-resource
1057
1058    In addition, the following special types are created internally but
1059 will never be seen by Lisp code.  You may encounter them, however, if
1060 you are debugging XEmacs.  The printed representation of these objects
1061 begins `#<INTERNAL EMACS BUG', which indicates to the Lisp programmer
1062 that he has found an internal bug in XEmacs if he ever encounters any
1063 of these objects.
1064
1065    * char-table-entry
1066
1067    * command-builder
1068
1069    * extent-auxiliary
1070
1071    * extent-info
1072
1073    * lcrecord-list
1074
1075    * lstream
1076
1077    * opaque
1078
1079    * opaque-list
1080
1081    * popup-data
1082
1083    * symbol-value-buffer-local
1084
1085    * symbol-value-forward
1086
1087    * symbol-value-lisp-magic
1088
1089    * symbol-value-varalias
1090
1091    * toolbar-data
1092
1093 \1f
1094 File: lispref.info,  Node: Programming Types,  Next: Editing Types,  Prev: Primitive Types,  Up: Lisp Data Types
1095
1096 Programming Types
1097 =================
1098
1099    There are two general categories of types in XEmacs Lisp: those
1100 having to do with Lisp programming, and those having to do with
1101 editing.  The former exist in many Lisp implementations, in one form or
1102 another.  The latter are unique to XEmacs Lisp.
1103
1104 * Menu:
1105
1106 * Integer Type::        Numbers without fractional parts.
1107 * Floating Point Type:: Numbers with fractional parts and with a large range.
1108 * Character Type::      The representation of letters, numbers and
1109                         control characters.
1110 * Symbol Type::         A multi-use object that refers to a function,
1111                         variable, or property list, and has a unique identity.
1112 * Sequence Type::       Both lists and arrays are classified as sequences.
1113 * Cons Cell Type::      Cons cells, and lists (which are made from cons cells).
1114 * Array Type::          Arrays include strings and vectors.
1115 * String Type::         An (efficient) array of characters.
1116 * Vector Type::         One-dimensional arrays.
1117 * Bit Vector Type::     An (efficient) array of bits.
1118 * Function Type::       A piece of executable code you can call from elsewhere.
1119 * Macro Type::          A method of expanding an expression into another
1120                           expression, more fundamental but less pretty.
1121 * Primitive Function Type::     A function written in C, callable from Lisp.
1122 * Compiled-Function Type::      A function written in Lisp, then compiled.
1123 * Autoload Type::       A type used for automatically loading seldom-used
1124                         functions.
1125 * Char Table Type::     A mapping from characters to Lisp objects.
1126 * Hash Table Type::     A fast mapping between Lisp objects.
1127 * Range Table Type::    A mapping from ranges of integers to Lisp objects.
1128 * Weak List Type::      A list with special garbage-collection properties.
1129
1130 \1f
1131 File: lispref.info,  Node: Integer Type,  Next: Floating Point Type,  Up: Programming Types
1132
1133 Integer Type
1134 ------------
1135
1136    The range of values for integers in XEmacs Lisp is -134217728 to
1137 134217727 (28 bits; i.e., -2**27 to 2**27 - 1) on most machines.  (Some
1138 machines, in particular 64-bit machines such as the DEC Alpha, may
1139 provide a wider range.)  It is important to note that the XEmacs Lisp
1140 arithmetic functions do not check for overflow.  Thus `(1+ 134217727)'
1141 is -134217728 on most machines. (However, you _will_ get an error if
1142 you attempt to read an out-of-range number using the Lisp reader.)
1143
1144    The read syntax for integers is a sequence of (base ten) digits with
1145 an optional sign at the beginning. (The printed representation produced
1146 by the Lisp interpreter never has a leading `+'.)
1147
1148      -1               ; The integer -1.
1149      1                ; The integer 1.
1150      +1               ; Also the integer 1.
1151      268435457        ; Causes an error on a 28-bit implementation.
1152
1153    *Note Numbers::, for more information.
1154
1155 \1f
1156 File: lispref.info,  Node: Floating Point Type,  Next: Character Type,  Prev: Integer Type,  Up: Programming Types
1157
1158 Floating Point Type
1159 -------------------
1160
1161    XEmacs supports floating point numbers.  The precise range of
1162 floating point numbers is machine-specific.
1163
1164    The printed representation for floating point numbers requires either
1165 a decimal point (with at least one digit following), an exponent, or
1166 both.  For example, `1500.0', `15e2', `15.0e2', `1.5e3', and `.15e4'
1167 are five ways of writing a floating point number whose value is 1500.
1168 They are all equivalent.
1169
1170    *Note Numbers::, for more information.
1171