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