DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T l

⟦41778ed09⟧ TextFile

    Length: 51587 (0xc983)
    Types: TextFile
    Names: »lispref-1«

Derivation

└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
    └─⟦c06c473ab⟧ »./UNRELEASED/lispref.tar.Z« 
        └─⟦1b57a2ffe⟧ 
            └─⟦this⟧ »lispref-1« 

TextFile

Info file: lispref,    -*-Text-*-
produced by texinfo-format-buffer
from file: lispref.texinfo









This file documents GNU Emacs Lisp.

This is Edition 0.1 Beta of the GNU Emacs Lisp Reference Manual, for
Emacs Version 18, with some references to Emacs Version 19.

Please read this document for review purposes.

Published by the Free Software Foundation, 675 Massachusetts Avenue,
Cambridge, MA 02139 USA

Copyright (C) 1989 Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation
approved by the Foundation.



▶1f◀
File: lispref  Node: Top, Prev: (dir), Up: (dir), Next: Introduction


This Info file documents GNU Emacs Lisp.

* Menu:

* Introduction::	
* Types of Lisp Object::	
* Numbers::	
* Strings and Characters::	

* Lists::	
* Sequences Arrays Vectors::   
* Symbols::	
* Variables::	

* Functions::	
* Macros::	
* Control Structures::	
* Evaluation::	

* Loading::	
* Byte Compilation::	
* Debugging::	
* Streams::	

* Minibuffers::	
* Command Loop::	
* Keymaps::	
* Major and Minor Modes::	

* Documentation::	
* Files::	
* Backups and Auto Saving::	
* Buffers::	

* Windows::	
* Positions::	
* Markers::	
* Text::	

* Searching and Matching::	
* Syntax Tables::	
* Lisp Expressions::	
* Abbreviations::

* Processes::	
* Operating System Interface::	
* Emacs Display::	

Appendices
* Tips and Standards::
* GNU Emacs Internals::	
* Standard Errors::	
* Standard Buffer Local Variables::	
* Standard Keymaps::	
* Hooks::	

* Index::


▶1f◀
File: lispref  Node: License, Prev: Top, Up: Top, Next: Introduction

GNU GENERAL PUBLIC LICENSE
**************************
                        Version 1, February 1989

     Copyright (C) 1989 Free Software Foundation, Inc.
     675 Mass Ave, Cambridge, MA 02139, USA

     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.


Preamble
========

  The license agreements of most software companies try to keep users at
the mercy of those companies.  By contrast, our General Public License
is intended to guarantee your freedom to share and change free
software---to make sure the software is free for all its users.  The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.  You
can use it for your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must tell them their rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  The precise terms and conditions for copying, distribution and
modification follow.


                          TERMS AND CONDITIONS

  1. This License Agreement applies to any program or other work which
     contains a notice placed by the copyright holder saying it may be
     distributed under the terms of this General Public License.  The
     ``Program'', below, refers to any such program or work, and a
     ``work based on the Program'' means either the Program or any work
     containing the Program or a portion of it, either verbatim or with
     modifications.  Each licensee is addressed as ``you''.

  2. You may copy and distribute verbatim copies of the Program's source
     code as you receive it, in any medium, provided that you
     conspicuously and appropriately publish on each copy an appropriate
     copyright notice and disclaimer of warranty; keep intact all the
     notices that refer to this General Public License and to the
     absence of any warranty; and give any other recipients of the
     Program a copy of this General Public License along with the
     Program.  You may charge a fee for the physical act of transferring
     a copy.

  3. You may modify your copy or copies of the Program or any portion of
     it, and copy and distribute such modifications under the terms of
     Paragraph 1 above, provided that you also do the following:

        * cause the modified files to carry prominent notices stating
          that you changed the files and the date of any change; and

        * cause the whole of any work that you distribute or publish,
          that in whole or in part contains the Program or any part
          thereof, either with or without modifications, to be licensed
          at no charge to all third parties under the terms of this
          General Public License (except that you may choose to grant
          warranty protection to some or all third parties, at your
          option).

        * If the modified program normally reads commands interactively
          when run, you must cause it, when started running for such
          interactive use in the simplest and most usual way, to print
          or display an announcement including an appropriate copyright
          notice and a notice that there is no warranty (or else, saying
          that you provide a warranty) and that users may redistribute
          the program under these conditions, and telling the user how
          to view a copy of this General Public License.

        * You may charge a fee for the physical act of transferring a
          copy, and you may at your option offer warranty protection in
          exchange for a fee.

     Mere aggregation of another independent work with the Program (or
     its derivative) on a volume of a storage or distribution medium
     does not bring the other work under the scope of these terms.

  4. You may copy and distribute the Program (or a portion or derivative
     of it, under Paragraph 2) in object code or executable form under
     the terms of Paragraphs 1 and 2 above provided that you also do one
     of the following:

        * accompany it with the complete corresponding machine-readable
          source code, which must be distributed under the terms of
          Paragraphs 1 and 2 above; or,

        * accompany it with a written offer, valid for at least three
          years, to give any third party free (except for a nominal
          charge for the cost of distribution) a complete
          machine-readable copy of the corresponding source code, to be
          distributed under the terms of Paragraphs 1 and 2 above; or,

        * accompany it with the information you received as to where the
          corresponding source code may be obtained.  (This alternative
          is allowed only for noncommercial distribution and only if you
          received the program in object code or executable form alone.)

     Source code for a work means the preferred form of the work for
     making modifications to it.  For an executable file, complete
     source code means all the source code for all modules it contains;
     but, as a special exception, it need not include source code for
     modules which are standard libraries that accompany the operating
     system on which the executable file runs, or for standard header
     files or definitions files that accompany that operating system.

  5. You may not copy, modify, sublicense, distribute or transfer the
     Program except as expressly provided under this General Public
     License.  Any attempt otherwise to copy, modify, sublicense,
     distribute or transfer the Program is void, and will automatically
     terminate your rights to use the Program under this License.
     However, parties who have received copies, or rights to use copies,
     from you under this General Public License will not have their
     licenses terminated so long as such parties remain in full
     compliance.

  6. By copying, distributing or modifying the Program (or any work
     based on the Program) you indicate your acceptance of this license
     to do so, and all its terms and conditions.

  7. Each time you redistribute the Program (or any work based on the
     Program), the recipient automatically receives a license from the
     original licensor to copy, distribute or modify the Program subject
     to these terms and conditions.  You may not impose any further
     restrictions on the recipients' exercise of the rights granted
     herein.

  8. The Free Software Foundation may publish revised and/or new
     versions of the General Public License from time to time.  Such new
     versions will be similar in spirit to the present version, but may
     differ in detail to address new problems or concerns.

     Each version is given a distinguishing version number.  If the
     Program specifies a version number of the license which applies to
     it and ``any later version'', you have the option of following the
     terms and conditions either of that version or of any later version
     published by the Free Software Foundation.  If the Program does not
     specify a version number of the license, you may choose any version
     ever published by the Free Software Foundation.

  9. If you wish to incorporate parts of the Program into other free
     programs whose distribution conditions are different, write to the
     author to ask for permission.  For software which is copyrighted by
     the Free Software Foundation, write to the Free Software
     Foundation; we sometimes make exceptions for this.  Our decision
     will be guided by the two goals of preserving the free status of
     all derivatives of our free software and of promoting the sharing
     and reuse of software generally.


                                 NO WARRANTY

 10. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
     WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
     LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS
     AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY
     OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND
     PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
     DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR
     OR CORRECTION.

 11. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
     WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
     MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
     LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
     INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
     INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
     DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
     OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
     OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
     ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


                      END OF TERMS AND CONDITIONS


Appendix: How to Apply These Terms to Your New Programs
=======================================================

  If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
``copyright'' line and a pointer to where the full notice is found.

     ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
     Copyright (C) 19YY  NAME OF AUTHOR

     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 1, or (at your option)
     any later version.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

     Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
     Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
     This is free software, and you are welcome to redistribute it
     under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License.  Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items---whatever suits your
program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a ``copyright disclaimer'' for the program, if
necessary.  Here a sample; alter the names:

     Yoyodyne, Inc., hereby disclaims all copyright interest in the
     program `Gnomovision' (a program to direct compilers to make passes
     at assemblers) written by James Hacker.

     SIGNATURE OF TY COON, 1 April 1989
     Ty Coon, President of Vice

That's all there is to it!

▶1f◀
File: lispref  Node: Introduction, Prev: License, Up: Top, Next: Types of Lisp Object

Introduction
************

  The greater part of the GNU Emacs text editor is written in the
programming language called Emacs Lisp.  You can write new code in Emacs
Lisp and install it as an extension to the editor.  At the same time,
Emacs Lisp is more than a mere `extension language'; it is a full
computer programming language in its own right.  You can use it as you
would any other programming language.

  Because Emacs Lisp is designed for use in an editor, it has special
features for handling different kinds of text---plain text, marked-up
manuscripts, source code, mail, and the like---as well as for handling
files, buffers, displays, subprocesses, and so on.

  This manual describes Emacs Lisp.  Generally speaking, the first part
of the manual describes those features of Emacs Lisp that are shared by
all programming languages, and the latter part describes those features
that are special.

* Menu:

* Caveats::             Flaws and a request for help.
* Lisp History::        Emacs Lisp is descended from MacLisp.
* Conventions::         How the manual is formatted.

▶1f◀
File: lispref  Node: Caveats, Prev: Introduction, Up: Introduction, Next: Lisp History

Caveats
=======

  This manual has gone through numerous drafts.  It is nearly complete
but not flawless.  There are a few sections which are not included,
either because we consider them secondary (such as most of the
individual modes) or because they are yet to be written.

  Because we are not able to deal with them completely, we have left out
several parts intentionally.  This includes most references to VMS and
all the Suntool and X related items.

  The manual should, however, be fully correct in what it does say; and
it is therefore open to criticism on anything it does include---from
specific examples and descriptive text, to the ordering of chapters and
sections.  If something is confusing, or you find that you have to look
at the sources or experiment to learn something not covered in the
manual, then perhaps the manual should be fixed.  Please let us know.



As you use this manual in Info, we ask that you send corrections as soon
as you find them.  If you think of a simple, real life example for a
function or group of functions, please make an effort to write it up and
send it in.  Please reference any comments to the node name and function
or variable name, as appropriate.

Mail comments and corrections to lisp-manual-bugs@prep.ai.mit.edu.

      --Bil Lewis       31-Oct-87 
      --Dan LaLiberte   01-Apr-89

▶1f◀
File: lispref  Node: Lisp History, Prev: Caveats, Up: Introduction, Next: Conventions

Lisp History
============

  Lisp (LISt Processing Language) was first developed in the late 1950s
at the Massachusetts Institute of Technology for research in artificial
intelligence.  The great power of the Lisp language makes it superior
for other purposes as well, such as writing editor commands.

  Dozens of Lisp implementations have been built over the years, each
with its own idiosyncrasies.  Many of them were inspired by MacLisp,
which was written in the 1960's at MIT's Project MAC.  Eventually the
implementors of the descendents of MacLisp came together and developed a
standard for Lisp systems, called Common Lisp.

  GNU Emacs Lisp is largely inspired by MacLisp, and a little by Common
Lisp.  If you know Common Lisp, you will notice many similarities.  But
many of the features of Common Lisp have been omitted or simplified in
order to reduce the memory requirements of GNU Emacs.  Sometimes the
simplifications are so drastic that a Common Lisp user might be very
confused.  We will occasionally point out how GNU Emacs Lisp differs
from Common Lisp.  If you don't know Common Lisp, don't worry about it;
this manual is self-contained.

▶1f◀
File: lispref  Node: Conventions, Prev: Lisp History, Up: Introduction

Conventions
===========

This section explains the notational conventions that are used in this
manual.  You may want to skip this section and refer back to it later.

* Menu:

* Some Terms::   
* nil and t::   
* Evaluation Notation:: 
* Printing Notation::   
* Error Messages::      
* Buffer Text Notation::        
* Format of Descriptions::      

▶1f◀
File: lispref  Node: Some Terms, Prev: Conventions, Up: Conventions, Next: nil and t

Some Terms
----------
  Throughout this manual, the phrases ``the Lisp reader'' and ``the Lisp
printer'' are used to refer to those routines in Lisp that read
expressions and print text.  *Note Print Representation and Read
Syntax::, for more details.  You, the person reading this manual, are
assumed to be ``the programmer'' and you may be referred to as ``you''.
``The user'' is the person who uses the code that you write.

▶1f◀
File: lispref  Node: nil and t, Prev: Some Terms, Up: Conventions, Next: Evaluation Notation

nil and t
---------

  In GNU Emacs Lisp, the symbol `nil' is overloaded with three meanings:
it is a symbol with the name `nil'; it is the logical truth value
"false"; and it is the empty list---the list of zero elements.

  As far as the Lisp reader is concerned, `()' and `nil' are identical.
The Lisp reader interprets them the same way.  The different ways of
writing them are intented entirely for the human reader.  After the Lisp
reader has read either `()' or `nil', there is no way to determine which
representation was actually written by the programmer.

  Throughout this manual, we use `()' when we wish to emphasize that it
means the empty list, and we use `nil' when we wish to emphasize that it
means the truth value false.

     (cons 'foo ())                ; Emphasize the empty list
     (not nil)                     ; Emphasize the truth value false

  The symbol `t' always has only one meaning, the value `t'.  It is the
preferred way to represent the truth value "true", although any
non-`nil' value is considered to be true as well.

  In Emacs Lisp, `nil' and `t' are special symbols that always evaluate
to themselves.  An attempt to change their values results in a
`setting-constant' error.

▶1f◀
File: lispref  Node: Evaluation Notation, Prev: nil and t, Up: Conventions, Next: Printing Notation

Evaluation Notation
-------------------

  When you evaluate a piece of Lisp code, it produces a result.  In the
examples in this manual, this will be indicated with `=>':

     (car '(1 2))
          => 1

You can read this as ```(car '(1 2))' evaluates to 1''.

  When a form is a macro call, it expands into a new form for Lisp to
evaluate.  We show the result of the expansion with `==>'.  We may or
may not show the actual result of the evaluation of the expanded form.

     (third '(a b c))
          ==> (car (cdr (cdr '(a b c))))
          => c

  In some instances, when we describe one form, we show another form
which produces identical results.  The exact equivalency of two forms is
indicated with `=='.

     (make-sparse-keymap) == (list 'keymap)

▶1f◀
File: lispref  Node: Printing Notation, Prev: Evaluation Notation, Up: Conventions, Next: Error Messages

Printing Notation
-----------------

  Many of the examples in this manual print text when they are
evaluated.  If you execute the code from an example in a Lisp
Interaction buffer (such as the buffer `*scratch*'), the printed text is
inserted into the buffer.  If the example is executed by other means
(such as by evaluating the function `eval-region'), then the text is
printed in the echo area.  You should be aware that text printed in the
echo area will not all be visible if more than one line is required.

  In examples that print text after the code is evaluated, the printed
text is indicated with `-|', irrespective of how the form is executed.

The value returned by evaluating the form will follow on the next line
(here `bar').

     (progn (print 'foo) (print 'bar))
          => foo
          => bar
          -| bar

▶1f◀
File: lispref  Node: Error Messages, Prev: Printing Notation, Up: Conventions, Next: Buffer Text Notation

Error Messages
--------------

  Some of the examples cause errors to be signaled.  In those cases, the
error messages (which always appear in the echo area) is shown on a line
starting with `error-->'.  Note that `error-->' itself does not appear
in the echo area.

     (+ 23 'x)
     error--> Wrong type argument: integer-or-marker-p, x

▶1f◀
File: lispref  Node: Buffer Text Notation, Prev: Error Messages, Up: Conventions, Next: Format of Descriptions

Buffer Text Notation
--------------------

  Some examples show modifications to text in a buffer, often with
`before' and `after' versions.  In such cases, the entire contents of
the buffer in question are included between two lines of dashes
containing the buffer name.  In addition, the location of point is shown
as `-!-'.  (The symbol for point, of course, is not in the actual
buffer; it indicates the place *between* two characters where point is
located.)

     ---------- Buffer: foo ----------
     This is the -!-contents of foo.
     ---------- Buffer: foo ----------

     (insert " changed ")
          => nil
     ---------- Buffer: foo ----------
     This is the changed -!-contents of foo.
     ---------- Buffer: foo ----------


▶1f◀
File: lispref  Node: Format of Descriptions, Prev: Buffer Text Notation, Up: Conventions

Format of Descriptions
----------------------

  Functions, variables, macros, commands, user options, and special
forms are all described in this manual in a uniform format.  The first
line of the description contains the name of the item followed by its
arguments, if appropriate.  The category---function, variable, or
whatever---is printed on the right hand end of the line.  The
description follows on succeeding lines, sometimes with examples.

For example,

* Function: inc INTEGER

       The function `inc' adds 1 to its argument, INTEGER.

          (inc 3)
               => 4
          (inc 7)
               => 8

  Commands are simply functions that may be called interactively.
Macros and special forms process their arguments in a different way from
functions, but otherwise appear the same.

  Although all variables and constants are modifiable, "options" are
variables that exist so that users can change them.  (The word
`constant' describes the intended permanence of a particular value;
however Emacs is flexible and you can change the value of a constant,
such as the regular expression describing the end of a sentence.  *Note
Global Variables::.)  Variables and constants are describing using the
same format as functions.

  Examples of code appear in this font or form: `(list 1 2 3)'.  Names
that represent arguments appear in this font or form: PARAMETER-1.

* Menu:

* A Sample Function Description::       
* A Sample Variable Description::   

▶1f◀
File: lispref  Node: A Sample Function Description, Prev: Format of Descriptions, Up: Format of Descriptions, Next: A Sample Variable Description

A Sample Function Description
.............................

  In a function description, the name of the function being described
appears first.  It is followed on the same line by a list of parameters.
The names used for the parameters are also used in the body of the
description.  Command, macro, and special form descriptions have the
same form, but at the end of the first line, `Function' is replaced by
`Command', `Macro', or `Special Form', respectively.

  In function and macro descriptions, the appearance of the keyword
`&optional' in the parameter list indicates that the arguments for the
parameters following it may be left out (in which case the parameters
default to `nil' if the description does not specifically mention a
different value).

  The keyword `&rest' (which will always be followed by a single
parameter) indicates that any number of arguments can follow the
required and optional ones.  The additional arguments will be made into
a list to which the last parameter will be bound.

Here is a description of the imaginary `foo' function:

* Function: foo INTEGER1 &optional INTEGER2 &rest INTEGERS

       The function `foo' subtracts INTEGER1 from INTEGER2, then adds
     all the rest of the arguments to the result.  If INTEGER2 is not
     supplied, then the number 19 is used by default.

          (foo 1 5 3 9)
               => 16
          (foo 5)
               => 14

     More generally,

          (foo W X Y Z)
          ==
          (+ (- X W) Y Z)

  Special form descriptions use a different notation to specify optional
and repeated parameters because the possibilities are quite a bit more
complex.  ``[OPTIONAL-ARG]'' means that OPTIONAL-ARG is optional and
`REPEATED-ARGS...'  means that REPEATED-ARGS may be repeated zero or
more times.  *Note Lambda Expressions::, for an example of the use of
this notation and for a more complete description of the optional and
rest arguments.

  Any parameter whose name contains the name of a type (e.g., INTEGER,
INTEGER1, BUFFERS) is expected to be of that type.  Parameters with
other names (e.g., NAME) are discussed specifically.  Parameters named
OBJECT may be of any type.  (*Note Types of Lisp Object::, for a list of
Emacs object types.)  In some sections, features common to a set of
parameters are described first.

▶1f◀
File: lispref  Node: A Sample Variable Description, Prev: A Sample Function Description, Up: Format of Descriptions

A Sample Variable Description
.............................

  Here is a description of the imaginary `electric-future-map' variable.
Option and constant descriptions have the same form, but `Variable' on
the right edge of the page is replaced by `User Option' or `Constant'.

* Variable: electric-future-map

       The value of this variable is a full keymap used by electric
     command future mode.  The functions in this map will allow you to
     edit commands you have not yet thought about executing.

▶1f◀
File: lispref  Node: Types of Lisp Object, Prev: Introduction, Up: Top, Next: Numbers

Types of Lisp Object
********************

  A Lisp "object" is a piece of data used and manipulated by Lisp
programs.  For our purposes, a "type" is a set of possible objects.

  Every object belongs to at least one type.  Objects of the same type
have a similar structure and may usually be used in the same contexts.
Types can overlap, and objects may belong to two or more types.
Consequently, we can ask whether an object belongs to a particular type,
but not for ``the'' type of an object.

  A small set of fundamental object types are built into Emacs.  These
are called "primitive types".  All other types are constructed from
these types.  The primitive types are "integer", "cons", "symbol",
"string", "vector", "subr" and several special types, such as "buffer",
that are related to editing.  (*Note Editing Types::.)

  While an object may be a member of more than one type, every object is
a member of exactly one primitive type.  The primitive type of an object
is stored along with the object's data.  A Lisp function is provided for
each primitive type to check whether an object is a member of that type.

  Note that while many other languages employ type declarations to
specify an object's type, Lisp objects are ``self-typing''.  The
primitive type of the object is implicit in the object itself.  For
example, if an object is a vector, nothing will be able to treat it as a
number because Lisp knows it is a vector, not a number.

  There are special terms for dealing with classes of types.  A
"supertype" is a union of "subtypes".  For example, strings and vectors
are both considered arrays, so the string and vector types are both
subtypes of the array supertype.

  This chapter describes the purpose, print representation, and read
syntax of each of the standard types in GNU Emacs Lisp.  Details on how
to use these types can be found in later chapters.

* Menu:

* Print Representation and Read Syntax::
* Comments::                    Comments and their formatting conventions.
* Programming Types::           Types found in all Lisp systems.
* Editing Types::               Types specific to Emacs.
* Type Predicates::             Tests related to types.
* Equality Predicates::         Tests of equality between any two objects.

▶1f◀
File: lispref  Node: Print Representation and Read Syntax, Prev: Types of Lisp Object, Up: Types of Lisp Object, Next: Comments

Print Representation and Read Syntax
====================================

  The "print representation" of an object is the format of the output
generated by the Lisp printer (the function `print') for that object.
The "read syntax" of an object is the format of the input accepted by
the Lisp reader (the function `read') for that object.  Very often, the
print representation and the read syntax are the same.

  It is important to distinguish between the textual representation of a
object (that you, the human, reads) and the object which results from
calling `read' on that text.

  Note that reading an object does not cause evaluation.  Reading
returns a Lisp object, which may or may not be evaluated later.
Evaluation is a separate process (*Note Evaluation::).  Generally, when
you evaluate an expression interactively, the Lisp interpreter first
reads the textual representation of it and then evaluates the Lisp
object returned.

*Note Input Functions::, for a description of `read', which is the most
basic function for reading objects.

  All types have a print representation.  Some types have no read
syntax, since it may not make sense to enter objects of these types
directly in a Lisp program.  Objects of these types are always printed
in "hash notation": the characters `#<' followed by a descriptive string
(typically the type name followed by the name of the object), and closed
with a matching `>'.  Hash notation cannot be read; and, the Lisp reader
signals the error `invalid-read-syntax' whenever a `#' is encountered.
For example, the buffer type does not have a read syntax.

     (current-buffer)
          => #<buffer objects.texinfo>

▶1f◀
File: lispref  Node: Comments, Prev: Print Representation and Read Syntax, Up: Types of Lisp Object, Next: Programming Types

Comments
========

  The Lisp reader skips comments.  A "comment" starts with a semicolon
(`;') and continues to the end of line.

You are encouraged to format comments according to several useful
conventions:


`;'
     Comments that start with a single semicolon, `;', should be all
     aligned to the same column on the right, or to the right of such a
     column if that is not possible.  Such comments usually apply only
     to code written on the same line.  In Emacs, in the Lisp modes, the
     `M-;' (`indent-for-comment') command automatically inserts such a
     `;' in the right place, or aligns such a comment if it is already
     inserted.

     (The following examples are taken from the Emacs sources.)

          (setq base-version-list                 ; there was a base
                (assoc (substring fn 0 start-vn)  ; version to which
                       file-version-assoc-list))  ; this looks like
                                                  ; a subversion

`;;'
     Comments that start with a two semicolons, `;;', should be aligned
     to the same level of indentation as the code.  Such comments are
     used to describe the section that follows or the state of the
     program at that point.  For example,

            (prog1 (setq auto-fill-hook
                         ...
                         ...
              ;; update mode-line
              (set-buffer-modified-p (buffer-modified-p))))

`;;;'
     Comments that start with a three semicolons, `;;;', should be
     aligned to the left margin.  Such comments are not used within
     function definitions, but are used to make more general comments.
     For example,

          ;;; This Lisp code is run in Emacs when it is to operate as
          ;;; a server for other processes.

`;;;;'
     Comments that start with a four semicolons, `;;;;', should be
     aligned to the left margin and are used to indicate section
     headings.  For example,

          ;;;; The kill ring

In the Lisp modes in Emacs, various indentation commands follow these
conventions, such as `M-;' (`indent-for-comment') and TAB
(`lisp-indent-line').  They automatically indent comments the right way,
according the the number of semicolons.

  Any character may be included in a comment, but it is advisable to
precede any unpaired special characters, such as `(' and `)', with a `\'
to hide their normal meaning from Lisp editing commands.

▶1f◀
File: lispref  Node: Programming Types, Prev: Comments, Up: Types of Lisp Object, Next: Editing Types

Programming Types
=================

  Types in Emacs Lisp can be divided into two general categories: those
having to do with Lisp programming, and those having to do with editing.
The former are provided in many Lisp implementations, in one form or
another.  The latter are unique to Emacs Lisp.

* Menu:

* Number Type::	        Primarily integers.
* Character Type::	The representation of letters, numbers and
                        control characters .
* Sequence Type::	A supertype of lists and arrays.
* List Type::	        What gave Lisp its name (not to mention reputation).
* Array Type::	        A supertype of strings and vectors.
* String Type::	        An (efficient) array of characters.
* Vector Type::	        One-dimensional arrays.
* Symbol Type::	        A multi-use object that refers to a function,
                        variable, property list, or itself.
* Lisp Function Type::	A piece of executable code.
* Lisp Macro Type::	A different kind of executable code from a function.
* Primitive Function Type::	A function written in C, callable from Lisp.
* Autoload Type::	A type used for automatically loading seldom
                        used functions.

▶1f◀
File: lispref  Node: Number Type, Prev: Programming Types, Up: Programming Types, Next: Character Type

Number Type
-----------


  Integers are the only kind of number in GNU Emacs Lisp, version 18.
The range of values for integers is -8388608 to 8388607 (24 bits; i.e.,
 
-2**24 to
 
2**24 - 1 ) on most machines, although it is 25 or 26 bits on some.  It
is important to note that the Emacs Lisp arithmetic functions do not
check for overflow.  Thus `(1+ 8388607)' is -8388608, on 24-bit
implementations.

Version 19 supports floating point numbers.

  The read syntax for numbers is a sequence of (base ten) digits with an
optional sign.  The print representation produced by the Lisp
interpreter never has a leading `+'.

     -1               ; The integer -1.
     1                ; The integer 1.
     +1               ; Also the integer 1.
     16777217         ; Also the integer 1! (on a 24-bit implementation)

  *Note Numbers::, for more information.

▶1f◀
File: lispref  Node: Character Type, Prev: Number Type, Up: Programming Types, Next: Sequence Type

Character Type
--------------


  A "character" object in Emacs Lisp is nothing more than an integer.
In other words, characters are represented internally with their
eight-bit ASCII values.  For example, the character `A' is represented
internally as the integer 65.  If an arbitrary integer is used as a
character, only the lower eight bits are significant.

  It is unusual for a programmer to work with individual characters.  It
is far more common to work with *strings*, which are sequences composed
of characters (*Note String Type::).


  Characters have a variety of read syntax formats, such as `?A' and
`?\101'.  Every different read syntax for characters starts with a
leading question mark.

  The usual read syntax for alphanumeric characters is a question mark
followed by the character; for example, `?A' for the character `A', `?B'
for the character `B', and `?a' for the character `a'.  For example,

     ?Q
          => 81

     ?q
          => 113

  The characters backspace, tab, vertical tab, formfeed, newline,
return, and escape may be represented as `?\b', `?\t', `?\n', `?\v',
`?\f', `?\r', `?\e', respectively.  Those values are 8, 9, 10, 11, 12,
13, and 27 in decimal.  Thus,

     ?\b                             ; backspace, BS, `C-h'
          => 8
     ?\t                             ; tab, TAB, `C-i'
          => 9
     ?\n                             ; newline, LFD, `C-j'
          => 10
     ?\v                             ; vertical tab, `C-k'
          => 11
     ?\f                             ; formfeed character, `C-l'
          => 12
     ?\r                             ; carriage return, RET, `C-m'
          => 13
     ?\e                             ; escape character, ESC, `C-['
          => 27
     ?\\                             ; backslash character, \
          => 92

  Control characters may be represented using yet another read syntax.
This consists of a question mark followed by a backslash, hat, and the
corresponding non-control character, in either upper or lowercase.  For
example, either `?\^I' or `?\^i' may be used as the read syntax for the
character `C-I', the character with the print syntax of `9'.

  The `^' may be replaced by `C-'; for example, `?\^I' may be replaced
by `?\C-I' and `?\^i' may be replaced by `?\C-i'.  For example,

     ?\^I
          => 9
     ?\C-I
          => 9

  When you represent control characters in files or strings, use of the
`^' syntax is preferred; but when you refer to keyboard input, the `C-'
syntax is preferred.

  A "meta character" is a character that has its eighth bit set.  The
read syntax for these characters is question mark, backslash, `M-', and
the corresponding seven-bit character; for example, `?\M-A' for `M-A',
the character with the print representation 193.  The seven-bit
character can be specified by any of the `\' escapes mentioned above or
below.  Not only can `M-A' be specified as `?\M-A', but also as
`?\M-\101' or as `?\301'.

  Similarly, the character whose decimal print representation is 130 can
use any one of the following for its read syntax: `?\202', `?\M-\C-b',
`?\C-\M-b', or `?\M-\002'.  For example,

     ?\C-\M-b                        ?\M-\C-b
          => 130               => 130
     ?\^\M-b                         ?\M-\002
          => 130               => 130

  Finally, the most general read syntax consists of a question mark
followed by a backslash and the ASCII value of the character in octal
(up to three octal digits); for example, `?\101' for the character `A',
`?\001' for the character `C-a', and `?\002' for the character `C-b'.
Although this syntax can represent any character, it is preferred when
the precise octal value is more important than the ASCII representation.
(The backslash character is also known as an "escape character", not to
be confused with ESC.)

     ?\012
          => 10
     ?\n
          => 10
     ?\C-j
          => 10

     ?A
          => 65
     ?\101
          => 65

     ?\M-A                           
          => 193                   
     ?\M-\101
          => 193
     ?\301
          => 193

  Any character without a special escape meaning may be preceded by a
backslash.  Thus `?A' is equivalent to `?\A'.  But any of the characters
`()\|;'`"#.,' *must* be preceded by a backslash to work reliably in all
contexts.  The space character, tab, newline, formfeed and literal
control characters must also be preceded by a backslash.  Furthermore,
it is better and more reliable to use one of the easily readable formats
rather than directly enter an invisible control character, such as a
tab; that's what the other formats are for, after all.

▶1f◀
File: lispref  Node: Sequence Type, Prev: Character Type, Up: Programming Types, Next: List Type

Types of Sequences
------------------

  Lists and arrays are two types of "sequence".  That is, an object of
type list or of type array is also considered a sequence.  The sequence
type is therefore sometimes called a supertype of the two subtypes.

  In addition, there are two kinds of array: strings and vectors.

  All these types share a common property: they consist of ordered
collections of elements.  Sequences are interesting because some Lisp
functions accept any sequence object as an argument, without
distinguishing between the three subtypes.

  Sequences are always created anew upon reading; in other words, it is
impossible to read the same sequence twice, in the sense of `eq' (*Note
Equality Predicates::).  There is one exception: the empty list `()' is
always read as the same object, `nil'.

  *Note Sequences Arrays Vectors::, for functions that work on
sequences.

▶1f◀
File: lispref  Node: List Type, Prev: Sequence Type, Up: Programming Types, Next: Array Type

List Type
---------

  A "list" object is a series of cons cells, linked together.  A "cons
cell" is an object comprised of two pointers named the "car" and the
"cdr", each of which can point to any Lisp object.  In most
circumstances, though, the CDR points to either another cons cell or the
empty list.  (Unfortunately, the names `car' and `cdr' have only
historical meaning now.  The original Lisp implementation on an IBM 704
computer referred to an ``address register'' and ``decrement register''.
Hence, `CAR' referred to the contents of the address register, and `CDR'
referred to the contents of the decrement register.  By comparison,
`cons' is named for the function `cons' which ``constructs'' cells of a
kind that came to be called cons cells.)

  When a list as a whole is evaluated, the elements may or may not be
evaluated.  When a list, or any object, is merely read, nothing is
evaluated.  (That is, reading and evaluation are different steps.)

  *Note Lists::, for functions that work on lists.

  The read syntax and print representation for lists are identical, and
consist of a left parenthesis, an arbitrary number of elements, and a
right parenthesis.

   Upon reading, any object at all inside the parentheses is made into
an element of the list.  That is, a cons cell is made for each element.
Its CAR points to the element, and its CDR points to a cons cell, the
CAR of which points to the next element in the list.  The CDR of the
last cons cell is set to point to `nil'.

  A list can be illustrated using diagrams in which the cons cells are
shown as pairs of boxes.  The following represents the three element
list `(rose violet buttercup)':

         ___ ___      ___ ___      ___ ___ 
        |___|___|--> |___|___|--> |___|___|--> nil
          |            |            |      
          |            |            |
           --> rose     --> violet   --> buttercup

  In the diagram, each box represents a slot that can refer to any Lisp
object.  Each pair of boxes represents a cons cell.  Each arrow is a
reference to an atom or to another cons cell.  The first box, the CAR of
the first cons cell, refers to or ``contains'' `rose'.  The second box,
the CDR of the first cons cell is a reference to the next pair of boxes,
the second cons cell.  The CAR of the second cons cell refers to
`violet' and the CDR refers to the third cons cell.  The CDR of the
third (and last) cons cell refers to `nil'.

Here is another diagram of the exact same list, `(rose violet
buttercup)', sketched in a different manner.

      ---------------         ----------------         -------------------
     |car    |cdr    |       |car     |cdr    |       |car        |cdr    |
     |       |   o---------->|        |   o---------->|           |  nil  |
     | rose  |       |       | violet |       |       | buttercup |       |
      ---------------         ----------------         -------------------

  A list with no elements in it is the "empty list"; it is identical to
the symbol `nil'.  In other words, `nil' is both a symbol and a list.

     (A 2 "A")            ; A list of three elements.
     ()                   ; A list of no elements (the empty list).
     nil                  ; A list of no elements (the empty list).
     ("A ()")             ; A list of one element: the string `"A ()"'.
     (A ())               ; A list of two elements: A and the empty list.
     ((A B C))            ; A list of one element (which is a list of 3).

  The functions `symbolp', `listp' and `atom' test whether their
argument is a symbol, list or atom, respectively.  As the example shows,
all three tests return true when applied to `nil'.  (*Note Type
Predicates::, for more information on such predicates.)  The function
`eq' tests whether its two arguments are the same object internally in
the computer.  As the example shows, this is indeed the case.

     (symbolp nil)
          => t
     (listp nil)
          => t
     (atom nil)
          => t
     (eq () nil)
          => t

* Menu:

* Dotted Pair Notation::	An alternative syntax for lists.
* Association List Type::	A specially constructed list.

▶1f◀
File: lispref  Node: Dotted Pair Notation, Prev: List Type, Up: List Type, Next: Association List Type

Dotted Pair Notation
....................

  "Dotted pair notation" is an alternative syntax for lists.  It
explicitly represents lists as cons cells.  In this syntax, `(A . B)' is
the cons cell whose CAR is the object A, and whose CDR is the object B.
Dotted pair notation is therefore more general than the syntax given
before.  In the dotted pair notation, the list `(1 2 3)' is written as
`(1 .  (2 . (3 .  nil)))'; the two notations are equivalent; but the
former is usually more convenient.  When printing a list, the dotted
pair notation is only used if the CDR of a cell is not a list.

  `Box notation' can also be used to illustrate what dotted pairs look
like.  (The Lisp reader cannot read such an illustration; unlike either
the regular or dotted pair notation, which can be understood both by
you, a human, and by the computer, the box illustrations can only be
understood by you.)

  For example, `(rose . violet)' is diagrammed as follows:

         ________ ________
        |________|________|
          |          |   
          |          |
           --> rose   --> violet

The three element list `(rose violet . buttercup)' looks like this:

         ___ ___      ________ _________
        |___|___|--> |________|_________|
          |            |           |
          |            |           |
           --> rose     --> violet  --> buttercup

  These diagrams make it evident that `(rose . violet .  buttercup)'
must have an invalid syntax since it would require that a cons cell have
three parts rather than two.

  The list `(rose violet)' is equivalent to `(rose . (violet))' and
looks like this:

         ___ ___      ___ ___ 
        |___|___|--> |___|___|--> nil
          |            | 
          |            |
           --> rose     --> violet

  Similarly, the three element list `(rose violet buttercup)' is
equivalent to `(rose . violet . (buttercup)))' and looks like this:

         ___ ___      ___ ___      ___ ___ 
        |___|___|--> |___|___|--> |___|___|--> nil
          |            |            |      
          |            |            |
           --> rose     --> violet   --> buttercup

This last list is perhaps best illustrated by a different style of
diagram, one that emphasizes the notion that the cons cells `contain'
the information to which they refer:

          ---------------------------------------------
         |car   |cdr                                   |
         |      |                                      |
         |      |   --------------------------------   |
         |      |  |car     |cdr                    |  |
         | rose |  |        |                       |  |
         |      |  | violet |   -----------------   |  |
         |      |  |        |  |car        |cdr  |  |  |
         |      |  |        |  |           |     |  |  |
         |      |  |        |  | buttercup | nil |  |  |
         |      |  |        |  |           |     |  |  |
         |      |  |        |   -----------------   |  |
         |      |  |        |                       |  |
         |      |   --------------------------------   |
         |      |                                      |
          ---------------------------------------------

     (rose violet buttercup) == (rose . (violet . (buttercup)))

▶1f◀