]> code.delx.au - gnu-emacs/blobdiff - doc/misc/cl.texi
Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[gnu-emacs] / doc / misc / cl.texi
index 12fd76e2e1c454f99322c7bf10e3b19386c6e358..c3657415078eb8bea71c43a205970a59c6749d44 100644 (file)
@@ -6,7 +6,7 @@
 @copying
 This file documents the GNU Emacs Common Lisp emulation package.
 
-Copyright @copyright{} 1993, 2001-2012 Free Software Foundation, Inc.
+Copyright @copyright{} 1993, 2001--2013 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -17,8 +17,7 @@ and with the Back-Cover Texts as in (a) below.  A copy of the license
 is included in the section entitled ``GNU Free Documentation License''.
 
 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
-modify this GNU manual.  Buying copies from the FSF supports it in
-developing GNU and promoting software freedom.''
+modify this GNU manual.''
 @end quotation
 @end copying
 
@@ -54,27 +53,29 @@ developing GNU and promoting software freedom.''
 @end ifnottex
 
 @menu
-* Overview::             Basics, usage, etc.
-* Program Structure::    Arglists, @code{cl-eval-when}, @code{defalias}.
-* Predicates::           @code{cl-typep} and @code{cl-equalp}.
-* Control Structure::    @code{setf}, @code{cl-do}, @code{cl-loop}, etc.
-* Macros::               Destructuring, @code{cl-define-compiler-macro}.
+* Overview::             Basics, usage, organization, naming conventions.
+* Program Structure::    Arglists, @code{cl-eval-when}.
+* Predicates::           Type predicates and equality predicates.
+* Control Structure::    Assignment, conditionals, blocks, looping.
+* Macros::               Destructuring, compiler macros.
 * Declarations::         @code{cl-proclaim}, @code{cl-declare}, etc.
-* Symbols::              Property lists, @code{cl-gensym}.
+* Symbols::              Property lists, creating symbols.
 * Numbers::              Predicates, functions, random numbers.
 * Sequences::            Mapping, functions, searching, sorting.
-* Lists::                @code{cl-caddr}, @code{cl-sublis}, @code{cl-member}, @code{cl-assoc}, etc.
+* Lists::                Functions, substitution, sets, associations.
 * Structures::           @code{cl-defstruct}.
-* Assertions::           @code{cl-check-type}, @code{cl-assert}, @code{ignore-errors}.
-
-* Efficiency Concerns::         Hints and techniques.
-* Common Lisp Compatibility::   All known differences with Steele.
-* Old CL Compatibility::        All known differences with old cl.el.
-* Porting Common Lisp::         Hints for porting Common Lisp code.
+* Assertions::           Assertions and type checking.
 
+Appendices
+* Efficiency Concerns::            Hints and techniques.
+* Common Lisp Compatibility::      All known differences with Steele.
+* Porting Common Lisp::            Hints for porting Common Lisp code.
+* Obsolete Features::              Obsolete features.
 * GNU Free Documentation License:: The license for this documentation.
-* Function Index::
-* Variable Index::
+
+Indexes
+* Function Index::                 An entry for each documented function.
+* Variable Index::                 An entry for each documented variable.
 @end menu
 
 @node Overview
@@ -93,9 +94,9 @@ As Emacs Lisp programmers have grown in number, and the applications
 they write have grown more ambitious, it has become clear that Emacs
 Lisp could benefit from many of the conveniences of Common Lisp.
 
-The @code{CL} package adds a number of Common Lisp functions and
+The @dfn{CL} package adds a number of Common Lisp functions and
 control structures to Emacs Lisp.  While not a 100% complete
-implementation of Common Lisp, @code{CL} adds enough functionality
+implementation of Common Lisp, it adds enough functionality
 to make Emacs Lisp programming significantly more convenient.
 
 Some Common Lisp features have been omitted from this package
@@ -105,40 +106,37 @@ for various reasons:
 @item
 Some features are too complex or bulky relative to their benefit
 to Emacs Lisp programmers.  CLOS and Common Lisp streams are fine
-examples of this group.
+examples of this group.  (The separate package EIEIO implements
+a subset of CLOS functionality.  @xref{Top, , Introduction, eieio, EIEIO}.)
 
 @item
 Other features cannot be implemented without modification to the
 Emacs Lisp interpreter itself, such as multiple return values,
 case-insensitive symbols, and complex numbers.
-The @code{CL} package generally makes no attempt to emulate these
-features.
+This package generally makes no attempt to emulate these features.
 
 @end itemize
 
-The package described here was originally written by Dave Gillespie,
-@file{daveg@@synaptics.com}, as a total rewrite of an earlier
-1986 @file{cl.el} package by Cesar Quiroz.  Most features of the
-Quiroz package were retained; any incompatibilities are
-noted in the descriptions below.  Care has been taken in this
-version to ensure that each function is defined efficiently,
-concisely, and with minimal impact on the rest of the Emacs
-environment.  Stefan Monnier added the file @file{cl-lib.el} and
-rationalized the namespace for Emacs 24.3.
+This package was originally written by Dave Gillespie,
+@file{daveg@@synaptics.com}, as a total rewrite of an earlier 1986
+@file{cl.el} package by Cesar Quiroz.  Care has been taken to ensure
+that each function is defined efficiently, concisely, and with minimal
+impact on the rest of the Emacs environment.  Stefan Monnier added the
+file @file{cl-lib.el} and rationalized the namespace for Emacs 24.3.
 
 @menu
-* Usage::                How to use the CL package.
-* Organization::         The package's five component files.
-* Naming Conventions::   Notes on CL function names.
+* Usage::                How to use this package.
+* Organization::         The package's component files.
+* Naming Conventions::   Notes on function names.
 @end menu
 
 @node Usage
 @section Usage
 
 @noindent
-The @code{CL} package is distributed with Emacs, so there is no need
+This package is distributed with Emacs, so there is no need
 to install any additional files in order to start using it.  Lisp code
-that uses features from the @code{CL} package should simply include at
+that uses features from this package should simply include at
 the beginning:
 
 @example
@@ -147,7 +145,7 @@ the beginning:
 
 @noindent
 You may wish to add such a statement to your init file, if you
-make frequent use of CL features.
+make frequent use of features from this package.
 
 @node Organization
 @section Organization
@@ -185,25 +183,37 @@ All you have to do is @code{(require 'cl-lib)}, and @file{cl-lib.el}
 will take care of pulling in the other files when they are
 needed.
 
-There is another file, @file{cl.el}, which was the main entry point
-to the CL package prior to Emacs 24.3.  Nowadays, it is replaced
-by @file{cl-lib.el}.  The two provide the same features, but use
-different function names (in fact, @file{cl.el} just defines aliases
-to the @file{cl-lib.el} definitions).  In particular, the old @file{cl.el}
-does not use a clean namespace.  For this reason, Emacs has a policy
-that packages distributed with Emacs must not load @code{cl} at run time.
-(It is ok for them to load @code{cl} at @emph{compile} time, with
-@code{eval-when-compile}, and use the macros it provides.)  There is
-no such restriction on the use of @code{cl-lib}.  New code should use
-@code{cl-lib} rather than @code{cl}.  @xref{Naming Conventions}.
+There is another file, @file{cl.el}, which was the main entry point to
+this package prior to Emacs 24.3.  Nowadays, it is replaced by
+@file{cl-lib.el}.  The two provide the same features (in most cases),
+but use different function names (in fact, @file{cl.el} mainly just
+defines aliases to the @file{cl-lib.el} definitions).  Where
+@file{cl-lib.el} defines a function called, for example,
+@code{cl-incf}, @file{cl.el} uses the same name but without the
+@samp{cl-} prefix, e.g., @code{incf} in this example.  There are a few
+exceptions to this.  First, functions such as @code{cl-defun} where
+the unprefixed version was already used for a standard Emacs Lisp
+function.  In such cases, the @file{cl.el} version adds a @samp{*}
+suffix, e.g., @code{defun*}.  Second, there are some obsolete features
+that are only implemented in @file{cl.el}, not in @file{cl-lib.el},
+because they are replaced by other standard Emacs Lisp features.
+Finally, in a very few cases the old @file{cl.el} versions do not
+behave in exactly the same way as the @file{cl-lib.el} versions.
+@xref{Obsolete Features}.
+@c There is also cl-mapc, which was called cl-mapc even before cl-lib.el.
+@c But not autoloaded, so maybe not much used?
+
+Since the old @file{cl.el} does not use a clean namespace, Emacs has a
+policy that packages distributed with Emacs must not load @code{cl} at
+run time.  (It is ok for them to load @code{cl} at @emph{compile}
+time, with @code{eval-when-compile}, and use the macros it provides.)
+There is no such restriction on the use of @code{cl-lib}.  New code
+should use @code{cl-lib} rather than @code{cl}.
 
 There is one more file, @file{cl-compat.el}, which defines some
-routines from the older CL package that are not otherwise
-present in the new package.  This includes internal routines
-like @code{setelt} and @code{zip-lists}, deprecated features
-like @code{defkeyword}, and an emulation of the old-style
-multiple-values feature.  This file is obsolete and should not be used
-in new code.  @xref{Old CL Compatibility}.
+routines from the older Quiroz @file{cl.el} package that are not otherwise
+present in the new package.  This file is obsolete and should not be
+used in new code.
 
 @node Naming Conventions
 @section Naming Conventions
@@ -215,43 +225,44 @@ names that are those of Common Lisp plus a @samp{cl-} prefix.
 
 Internal function and variable names in the package are prefixed
 by @code{cl--}.  Here is a complete list of functions prefixed by
-@code{cl-} that were not taken from Common Lisp:
+@code{cl-} that were @emph{not} taken from Common Lisp:
 
-@c FIXME lexical-let lexical-let*
 @example
-cl-callf         cl-callf2        cl-defsubst
-cl-floatp-safe   cl-letf          cl-letf*
+cl-callf           cl-callf2          cl-defsubst
+cl-letf            cl-letf*
 @end example
 
+@c This is not uninteresting I suppose, but is of zero practical relevance
+@c to the user, and seems like a hostage to changing implementation details.
 The following simple functions and macros are defined in @file{cl-lib.el};
 they do not cause other components like @file{cl-extra} to be loaded.
 
 @example
-cl-floatp-safe   cl-endp
-cl-evenp         cl-oddp          cl-plusp         cl-minusp
-cl-caaar .. cl-cddddr
-cl-list*         cl-ldiff         cl-rest          cl-first .. cl-tenth
-cl-copy-list     cl-subst         cl-mapcar [2]
-cl-adjoin [3]    cl-acons         cl-pairlis
-cl-pushnew [3,4] cl-incf [4]      cl-decf [4]
-cl-proclaim      cl-declaim
+cl-evenp           cl-oddp            cl-minusp
+cl-plusp           cl-endp            cl-subst
+cl-copy-list       cl-list*           cl-ldiff
+cl-rest            cl-decf [1]        cl-incf [1]
+cl-acons           cl-adjoin [2]      cl-pairlis
+cl-pushnew [1,2]   cl-declaim         cl-proclaim
+cl-caaar@dots{}cl-cddddr                  cl-first@dots{}cl-tenth
+cl-mapcar [3]
 @end example
 
 @noindent
-[2] Only for one sequence argument or two list arguments.
+[1] Only when @var{place} is a plain variable name.
 
 @noindent
-[3] Only if @code{:test} is @code{eq}, @code{equal}, or unspecified,
+[2] Only if @code{:test} is @code{eq}, @code{equal}, or unspecified,
 and @code{:key} is not used.
 
 @noindent
-[4] Only when @var{place} is a plain variable name.
+[3] Only for one sequence argument or two list arguments.
 
 @node Program Structure
 @chapter Program Structure
 
 @noindent
-This section describes features of the @code{CL} package that have to
+This section describes features of this package that have to
 do with programs as a whole: advanced argument lists for functions,
 and the @code{cl-eval-when} construct.
 
@@ -260,10 +271,6 @@ and the @code{cl-eval-when} construct.
 * Time of Evaluation::   The @code{cl-eval-when} construct.
 @end menu
 
-@iftex
-@secno=1
-@end iftex
-
 @node Argument Lists
 @section Argument Lists
 
@@ -279,48 +286,51 @@ this package to implement Common Lisp argument lists seamlessly.
 Instead, this package defines alternates for several Lisp forms
 which you must use if you need Common Lisp argument lists.
 
-@defspec cl-defun name arglist body...
+@defmac cl-defun name arglist body@dots{}
 This form is identical to the regular @code{defun} form, except
 that @var{arglist} is allowed to be a full Common Lisp argument
 list.  Also, the function body is enclosed in an implicit block
 called @var{name}; @pxref{Blocks and Exits}.
-@end defspec
+@end defmac
 
-@defspec cl-defsubst name arglist body...
+@defmac cl-defsubst name arglist body@dots{}
 This is just like @code{cl-defun}, except that the function that
 is defined is automatically proclaimed @code{inline}, i.e.,
 calls to it may be expanded into in-line code by the byte compiler.
 This is analogous to the @code{defsubst} form;
 @code{cl-defsubst} uses a different method (compiler macros) which
 works in all versions of Emacs, and also generates somewhat more
+@c For some examples,
+@c see http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00009.html
 efficient inline expansions.  In particular, @code{cl-defsubst}
 arranges for the processing of keyword arguments, default values,
 etc., to be done at compile-time whenever possible.
-@end defspec
+@end defmac
 
-@defspec cl-defmacro name arglist body...
+@defmac cl-defmacro name arglist body@dots{}
 This is identical to the regular @code{defmacro} form,
 except that @var{arglist} is allowed to be a full Common Lisp
 argument list.  The @code{&environment} keyword is supported as
-described in Steele.  The @code{&whole} keyword is supported only
+described in Steele's book @cite{Common Lisp, the Language}.
+The @code{&whole} keyword is supported only
 within destructured lists (see below); top-level @code{&whole}
 cannot be implemented with the current Emacs Lisp interpreter.
 The macro expander body is enclosed in an implicit block called
 @var{name}.
-@end defspec
+@end defmac
 
-@defspec cl-function symbol-or-lambda
+@defmac cl-function symbol-or-lambda
 This is identical to the regular @code{function} form,
 except that if the argument is a @code{lambda} form then that
 form may use a full Common Lisp argument list.
-@end defspec
+@end defmac
 
 Also, all forms (such as @code{cl-flet} and @code{cl-labels}) defined
 in this package that include @var{arglist}s in their syntax allow
 full Common Lisp argument lists.
 
 Note that it is @emph{not} necessary to use @code{cl-defun} in
-order to have access to most @code{CL} features in your function.
+order to have access to most CL features in your function.
 These features are always present; @code{cl-defun}'s only
 difference from @code{defun} is its more flexible argument
 lists and its implicit block.
@@ -328,11 +338,11 @@ lists and its implicit block.
 The full form of a Common Lisp argument list is
 
 @example
-(@var{var}...
- &optional (@var{var} @var{initform} @var{svar})...
+(@var{var}@dots{}
+ &optional (@var{var} @var{initform} @var{svar})@dots{}
  &rest @var{var}
- &key ((@var{keyword} @var{var}) @var{initform} @var{svar})...
- &aux (@var{var} @var{initform})...)
+ &key ((@var{keyword} @var{var}) @var{initform} @var{svar})@dots{}
+ &aux (@var{var} @var{initform})@dots{})
 @end example
 
 Each of the five argument list sections is optional.  The @var{svar},
@@ -422,11 +432,11 @@ function uses both @code{&rest} and @code{&key} at the same time,
 the ``rest'' argument is bound to the keyword list as it appears
 in the call.  For example:
 
-@smallexample
+@example
 (cl-defun find-thing (thing &rest rest &key need &allow-other-keys)
   (or (apply 'cl-member thing thing-list :allow-other-keys t rest)
       (if need (error "Thing not found"))))
-@end smallexample
+@end example
 
 @noindent
 This function takes a @code{:need} keyword argument, but also
@@ -455,7 +465,7 @@ Argument lists support @dfn{destructuring}.  In Common Lisp,
 destructuring is only allowed with @code{defmacro}; this package
 allows it with @code{cl-defun} and other argument lists as well.
 In destructuring, any argument variable (@var{var} in the above
-diagram) can be replaced by a list of variables, or more generally,
+example) can be replaced by a list of variables, or more generally,
 a recursive argument list.  The corresponding argument value must
 be a list whose elements match this recursive argument list.
 For example:
@@ -463,7 +473,7 @@ For example:
 @example
 (cl-defmacro dolist ((var listform &optional resultform)
                    &rest body)
-  ...)
+  @dots{})
 @end example
 
 This says that the first argument of @code{dolist} must be a list
@@ -502,7 +512,7 @@ For example, the compiler effectively evaluates @code{defmacro} forms
 at compile-time so that later parts of the file can refer to the
 macros that are defined.
 
-@defspec cl-eval-when (situations...) forms...
+@defmac cl-eval-when (situations@dots{}) forms@dots{}
 This form controls when the body @var{forms} are evaluated.
 The @var{situations} list may contain any set of the symbols
 @code{compile}, @code{load}, and @code{eval} (or their long-winded
@@ -572,19 +582,19 @@ last four would have been equivalent to the corresponding @code{setq}s.
 Note that @code{(cl-eval-when (load eval) @dots{})} is equivalent
 to @code{(progn @dots{})} in all contexts.  The compiler treats
 certain top-level forms, like @code{defmacro} (sort-of) and
-@code{require}, as if they were wrapped in @code{(eval-when
+@code{require}, as if they were wrapped in @code{(cl-eval-when
 (compile load eval) @dots{})}.
-@end defspec
+@end defmac
 
 Emacs includes two special forms related to @code{cl-eval-when}.
+@xref{Eval During Compile,,,elisp,GNU Emacs Lisp Reference Manual}.
 One of these, @code{eval-when-compile}, is not quite equivalent to
-any @code{eval-when} construct and is described below.
+any @code{cl-eval-when} construct and is described below.
 
 The other form, @code{(eval-and-compile @dots{})}, is exactly
-equivalent to @samp{(eval-when (compile load eval) @dots{})} and
-so is not itself defined by this package.
+equivalent to @samp{(cl-eval-when (compile load eval) @dots{})}.
 
-@defspec eval-when-compile forms...
+@defmac eval-when-compile forms@dots{}
 The @var{forms} are evaluated at compile-time; at execution time,
 this form acts like a quoted constant of the resulting value.  Used
 at top-level, @code{eval-when-compile} is just like @samp{eval-when
@@ -593,9 +603,9 @@ allows code to be evaluated once at compile-time for efficiency
 or other reasons.
 
 This form is similar to the @samp{#.} syntax of true Common Lisp.
-@end defspec
+@end defmac
 
-@defspec cl-load-time-value form
+@defmac cl-load-time-value form
 The @var{form} is evaluated at load-time; at execution time,
 this form acts like a quoted constant of the resulting value.
 
@@ -632,11 +642,11 @@ Byte-compiled, the above defun will result in the following code
   (insert "This function was executed on: "
           (current-time-string)
           ", compiled on: "
-          '"Wed Jun 23 18:33:43 1993"
+          '"Wed Oct 31 16:32:28 2012"
           ", and loaded on: "
           --temp--))
 @end example
-@end defspec
+@end defmac
 
 @node Predicates
 @chapter Predicates
@@ -653,10 +663,6 @@ facts are true or false.
 @node Type Predicates
 @section Type Predicates
 
-@noindent
-The @code{CL} package defines a version of the Common Lisp @code{typep}
-predicate.
-
 @defun cl-typep object type
 Check if @var{object} is of type @var{type}, where @var{type} is a
 (quoted) type name of the sort used by Common Lisp.  For example,
@@ -697,10 +703,13 @@ The type symbol @code{real} is a synonym for @code{number}, and
 The type symbols @code{character} and @code{string-char} match
 integers in the range from 0 to 255.
 
+@c No longer relevant, so covered by first item above (float -> floatp).
+@ignore
 @item
 The type symbol @code{float} uses the @code{cl-floatp-safe} predicate
 defined by this package rather than @code{floatp}, so it will work
 correctly even in Emacs versions without floating-point support.
+@end ignore
 
 @item
 The type list @code{(integer @var{low} @var{high})} represents all
@@ -737,7 +746,7 @@ related to @code{cl-typep}.
 @defun cl-coerce object type
 This function attempts to convert @var{object} to the specified
 @var{type}.  If @var{object} is already of that type as determined by
-@code{typep}, it is simply returned.  Otherwise, certain types of
+@code{cl-typep}, it is simply returned.  Otherwise, certain types of
 conversions will be made:  If @var{type} is any sequence type
 (@code{string}, @code{list}, etc.) then @var{object} will be
 converted to that type if possible.  If @var{type} is
@@ -748,13 +757,13 @@ floats.  In all other circumstances, @code{cl-coerce} signals an
 error.
 @end defun
 
-@defspec cl-deftype name arglist forms...
+@defmac cl-deftype name arglist forms@dots{}
 This macro defines a new type called @var{name}.  It is similar
 to @code{defmacro} in many ways; when @var{name} is encountered
 as a type name, the body @var{forms} are evaluated and should
 return a type specifier that is equivalent to the type.  The
 @var{arglist} is a Common Lisp argument list of the sort accepted
-by @code{cl-defmacro}.  The type specifier @samp{(@var{name} @var{args}...)}
+by @code{cl-defmacro}.  The type specifier @samp{(@var{name} @var{args}@dots{})}
 is expanded by calling the expander with those arguments; the type
 symbol @samp{@var{name}} is expanded by calling the expander with
 no arguments.  The @var{arglist} is processed the same as for
@@ -776,10 +785,10 @@ unsigned-byte  @equiv{}  (integer 0 *)
 The last example shows how the Common Lisp @code{unsigned-byte}
 type specifier could be implemented if desired; this package does
 not implement @code{unsigned-byte} by default.
-@end defspec
+@end defmac
 
-The @code{cl-typecase} and @code{cl-check-type} macros also use type
-names.  @xref{Conditionals}.  @xref{Assertions}.  The @code{cl-map},
+The @code{cl-typecase} (@pxref{Conditionals}) and @code{cl-check-type}
+(@pxref{Assertions}) macros also use type names.  The @code{cl-map},
 @code{cl-concatenate}, and @code{cl-merge} functions take type-name
 arguments to specify the type of sequence to return.  @xref{Sequences}.
 
@@ -816,23 +825,19 @@ In Emacs, use @code{memq} (or @code{cl-member}) and @code{assq} (or
 
 @noindent
 The features described in the following sections implement
-various advanced control structures, including the powerful
-@c FIXME setf is now in gv.el, not cl.
-@code{setf} facility and a number of looping and conditional
+various advanced control structures, including extensions to the
+standard @code{setf} facility, and a number of looping and conditional
 constructs.
 
-@c FIXME setf, push are standard now.
-@c lexical-let is obsolete; flet is not cl-flet.
-@c values is not cl-values.
 @menu
 * Assignment::             The @code{cl-psetq} form.
-* Generalized Variables::  @code{setf}, @code{cl-incf}, @code{push}, etc.
-* Variable Bindings::      @code{cl-progv}, @code{lexical-let}, @code{flet}, @code{cl-macrolet}.
+* Generalized Variables::  Extensions to generalized variables.
+* Variable Bindings::      @code{cl-progv}, @code{cl-flet}, @code{cl-macrolet}.
 * Conditionals::           @code{cl-case}, @code{cl-typecase}.
 * Blocks and Exits::       @code{cl-block}, @code{cl-return}, @code{cl-return-from}.
 * Iteration::              @code{cl-do}, @code{cl-dotimes}, @code{cl-dolist}, @code{cl-do-symbols}.
-* Loop Facility::          The Common Lisp @code{cl-loop} macro.
-* Multiple Values::        @code{values}, @code{cl-multiple-value-bind}, etc.
+* Loop Facility::          The Common Lisp @code{loop} macro.
+* Multiple Values::        @code{cl-values}, @code{cl-multiple-value-bind}, etc.
 @end menu
 
 @node Assignment
@@ -842,7 +847,7 @@ constructs.
 The @code{cl-psetq} form is just like @code{setq}, except that multiple
 assignments are done in parallel rather than sequentially.
 
-@defspec cl-psetq [symbol form]@dots{}
+@defmac cl-psetq [symbol form]@dots{}
 This special form (actually a macro) is used to assign to several
 variables simultaneously.  Given only one @var{symbol} and @var{form},
 it has the same effect as @code{setq}.  Given several @var{symbol}
@@ -870,132 +875,79 @@ provides an even more convenient way to swap two variables;
 @pxref{Modify Macros}.)
 
 @code{cl-psetq} always returns @code{nil}.
-@end defspec
+@end defmac
 
-@c FIXME now in gv.el.
 @node Generalized Variables
 @section Generalized Variables
 
-@noindent
-A ``generalized variable'' or ``place form'' is one of the many places
-in Lisp memory where values can be stored.  The simplest place form is
-a regular Lisp variable.  But the cars and cdrs of lists, elements
-of arrays, properties of symbols, and many other locations are also
-places where Lisp values are stored.
-
-The @code{setf} form is like @code{setq}, except that it accepts
-arbitrary place forms on the left side rather than just
-symbols.  For example, @code{(setf (car a) b)} sets the car of
-@code{a} to @code{b}, doing the same operation as @code{(setcar a b)}
-but without having to remember two separate functions for setting
-and accessing every type of place.
-
-Generalized variables are analogous to ``lvalues'' in the C
-language, where @samp{x = a[i]} gets an element from an array
-and @samp{a[i] = x} stores an element using the same notation.
-Just as certain forms like @code{a[i]} can be lvalues in C, there
-is a set of forms that can be generalized variables in Lisp.
+A @dfn{generalized variable} or @dfn{place form} is one of the many
+places in Lisp memory where values can be stored.  The simplest place
+form is a regular Lisp variable.  But the @sc{car}s and @sc{cdr}s of lists,
+elements of arrays, properties of symbols, and many other locations
+are also places where Lisp values are stored.  For basic information,
+@pxref{Generalized Variables,,,elisp,GNU Emacs Lisp Reference Manual}.
+This package provides several additional features related to
+generalized variables.
 
 @menu
-* Basic Setf::         @code{setf} and place forms.
-* Modify Macros::      @code{cl-incf}, @code{push}, @code{cl-rotatef}, @code{letf}, @code{cl-callf}, etc.
-* Customizing Setf::   @code{define-modify-macro}, @code{defsetf}, @code{define-setf-method}.
+* Setf Extensions::    Additional @code{setf} places.
+* Modify Macros::      @code{cl-incf}, @code{cl-rotatef}, @code{cl-letf}, @code{cl-callf}, etc.
 @end menu
 
-@node Basic Setf
-@subsection Basic Setf
-
-@noindent
-The @code{setf} macro is the most basic way to operate on generalized
-variables.
-
-@defspec setf [place form]@dots{}
-This macro evaluates @var{form} and stores it in @var{place}, which
-must be a valid generalized variable form.  If there are several
-@var{place} and @var{form} pairs, the assignments are done sequentially
-just as with @code{setq}.  @code{setf} returns the value of the last
-@var{form}.
+@node Setf Extensions
+@subsection Setf Extensions
 
-The following Lisp forms will work as generalized variables, and
-so may appear in the @var{place} argument of @code{setf}:
-
-@itemize @bullet
-@item
-A symbol naming a variable.  In other words, @code{(setf x y)} is
-exactly equivalent to @code{(setq x y)}, and @code{setq} itself is
-strictly speaking redundant now that @code{setf} exists.  Many
-programmers continue to prefer @code{setq} for setting simple
-variables, though, purely for stylistic or historical reasons.
-The macro @code{(setf x y)} actually expands to @code{(setq x y)},
-so there is no performance penalty for using it in compiled code.
+Several standard (e.g., @code{car}) and Emacs-specific
+(e.g., @code{window-point}) Lisp functions are @code{setf}-able by default.
+This package defines @code{setf} handlers for several additional functions:
 
+@itemize
 @item
-A call to any of the following Lisp functions:
-
-@smallexample
-car                 cdr                 caar .. cddddr
-nth                 rest                first .. tenth
-aref                elt                 nthcdr
-symbol-function     symbol-value        symbol-plist
-get                 get*                getf
-gethash             subseq
-@end smallexample
+Functions from this package:
+@example
+cl-rest        cl-subseq      cl-get         cl-getf
+cl-caaar@dots{}cl-cddddr          cl-first@dots{}cl-tenth
+@end example
 
 @noindent
-Note that for @code{nthcdr} and @code{getf}, the list argument
-of the function must itself be a valid @var{place} form.  For
-example, @code{(setf (nthcdr 0 foo) 7)} will set @code{foo} itself
-to 7.  Note that @code{push} and @code{pop} on an @code{nthcdr}
-place can be used to insert or delete at any position in a list.
-The use of @code{nthcdr} as a @var{place} form is an extension
-to standard Common Lisp.
+Note that for @code{cl-getf} (as for @code{nthcdr}), the list argument
+of the function must itself be a valid @var{place} form.
 
 @item
-The following Emacs-specific functions are also @code{setf}-able.
-
-@smallexample
-buffer-file-name                  marker-position
-buffer-modified-p                 match-data
-buffer-name                       mouse-position
-buffer-string                     overlay-end
-buffer-substring                  overlay-get
-current-buffer                    overlay-start
-current-case-table                point
-current-column                    point-marker
-current-global-map                point-max
-current-input-mode                point-min
-current-local-map                 process-buffer
-current-window-configuration      process-filter
-default-file-modes                process-sentinel
-default-value                     read-mouse-position
-documentation-property            screen-height
-extent-data                       screen-menubar
-extent-end-position               screen-width
-extent-start-position             selected-window
-face-background                   selected-screen
-face-background-pixmap            selected-frame
-face-font                         standard-case-table
-face-foreground                   syntax-table
-face-underline-p                  window-buffer
-file-modes                        window-dedicated-p
-frame-height                      window-display-table
-frame-parameters                  window-height
-frame-visible-p                   window-hscroll
-frame-width                       window-point
-get-register                      window-start
-getenv                            window-width
-global-key-binding                x-get-secondary-selection
-keymap-parent                     x-get-selection
-local-key-binding                 
-mark                              
-mark-marker
-@end smallexample
+General Emacs Lisp functions:
+@example
+buffer-file-name                   getenv
+buffer-modified-p                  global-key-binding
+buffer-name                        local-key-binding
+buffer-string                      mark
+buffer-substring                   mark-marker
+current-buffer                     marker-position
+current-case-table                 mouse-position
+current-column                     point
+current-global-map                 point-marker
+current-input-mode                 point-max
+current-local-map                  point-min
+current-window-configuration       read-mouse-position
+default-file-modes                 screen-height
+documentation-property             screen-width
+face-background                    selected-window
+face-background-pixmap             selected-screen
+face-font                          selected-frame
+face-foreground                    standard-case-table
+face-underline-p                   syntax-table
+file-modes                         visited-file-modtime
+frame-height                       window-height
+frame-parameters                   window-width
+frame-visible-p                    x-get-secondary-selection
+frame-width                        x-get-selection
+get-register
+@end example
 
 Most of these have directly corresponding ``set'' functions, like
 @code{use-local-map} for @code{current-local-map}, or @code{goto-char}
 for @code{point}.  A few, like @code{point-min}, expand to longer
-sequences of code when they are @code{setf}'d (@code{(narrow-to-region
-x (point-max))} in this case).
+sequences of code when they are used with @code{setf}
+(@code{(narrow-to-region x (point-max))} in this case).
 
 @item
 A call of the form @code{(substring @var{subplace} @var{n} [@var{m}])},
@@ -1022,6 +974,10 @@ a
 The generalized variable @code{buffer-substring}, listed above,
 also works in this way by replacing a portion of the current buffer.
 
+@c FIXME?  Also `eq'? (see cl-lib.el)
+
+@c Currently commented out in cl.el.
+@ignore
 @item
 A call of the form @code{(apply '@var{func} @dots{})} or
 @code{(apply (function @var{func}) @dots{})}, where @var{func}
@@ -1030,28 +986,27 @@ in the sense described in Steele's book; since none of the standard
 Emacs place functions are suitable in this sense, this feature is
 only interesting when used with places you define yourself with
 @code{define-setf-method} or the long form of @code{defsetf}.
+@xref{Obsolete Setf Customization}.
+@end ignore
 
+@c FIXME?  Is this still true?
 @item
 A macro call, in which case the macro is expanded and @code{setf}
 is applied to the resulting form.
-
-@item
-Any form for which a @code{defsetf} or @code{define-setf-method}
-has been made.
 @end itemize
 
-Using any forms other than these in the @var{place} argument to
-@code{setf} will signal an error.
-
+@c FIXME should this be in lispref?  It seems self-evident.
+@c Contrast with the cl-incf example later on.
+@c Here it really only serves as a contrast to wrong-order.
 The @code{setf} macro takes care to evaluate all subforms in
 the proper left-to-right order; for example,
 
 @example
-(setf (aref vec (incf i)) i)
+(setf (aref vec (cl-incf i)) i)
 @end example
 
 @noindent
-looks like it will evaluate @code{(incf i)} exactly once, before the
+looks like it will evaluate @code{(cl-incf i)} exactly once, before the
 following access to @code{i}; the @code{setf} expander will insert
 temporary variables as necessary to ensure that it does in fact work
 this way no matter what setf-method is defined for @code{aref}.
@@ -1071,35 +1026,34 @@ will be preserved.  Adapting an example from Steele, given
 the form @code{(setf (wrong-order @var{a} @var{b}) 17)} will
 evaluate @var{b} first, then @var{a}, just as in an actual call
 to @code{wrong-order}.
-@end defspec
 
 @node Modify Macros
 @subsection Modify Macros
 
 @noindent
-This package defines a number of other macros besides @code{setf}
-that operate on generalized variables.  Many are interesting and
-useful even when the @var{place} is just a variable name.
+This package defines a number of macros that operate on generalized
+variables.  Many are interesting and useful even when the @var{place}
+is just a variable name.
 
-@defspec psetf [place form]@dots{}
+@defmac cl-psetf [place form]@dots{}
 This macro is to @code{setf} what @code{cl-psetq} is to @code{setq}:
 When several @var{place}s and @var{form}s are involved, the
 assignments take place in parallel rather than sequentially.
 Specifically, all subforms are evaluated from left to right, then
 all the assignments are done (in an undefined order).
-@end defspec
+@end defmac
 
-@defspec incf place &optional x
+@defmac cl-incf place &optional x
 This macro increments the number stored in @var{place} by one, or
 by @var{x} if specified.  The incremented value is returned.  For
-example, @code{(incf i)} is equivalent to @code{(setq i (1+ i))}, and
-@code{(incf (car x) 2)} is equivalent to @code{(setcar x (+ (car x) 2))}.
+example, @code{(cl-incf i)} is equivalent to @code{(setq i (1+ i))}, and
+@code{(cl-incf (car x) 2)} is equivalent to @code{(setcar x (+ (car x) 2))}.
 
-Once again, care is taken to preserve the ``apparent'' order of
-evaluation.  For example,
+As with @code{setf}, care is taken to preserve the ``apparent'' order
+of evaluation.  For example,
 
 @example
-(incf (aref vec (incf i)))
+(cl-incf (aref vec (cl-incf i)))
 @end example
 
 @noindent
@@ -1109,93 +1063,81 @@ does, which means the above form is @emph{not} equivalent to the
 ``obvious'' expansion,
 
 @example
-(setf (aref vec (incf i)) (1+ (aref vec (incf i))))   ; Wrong!
+(setf (aref vec (cl-incf i))
+      (1+ (aref vec (cl-incf i))))   ; wrong!
 @end example
 
 @noindent
 but rather to something more like
 
 @example
-(let ((temp (incf i)))
+(let ((temp (cl-incf i)))
   (setf (aref vec temp) (1+ (aref vec temp))))
 @end example
 
 @noindent
-Again, all of this is taken care of automatically by @code{incf} and
+Again, all of this is taken care of automatically by @code{cl-incf} and
 the other generalized-variable macros.
 
-As a more Emacs-specific example of @code{incf}, the expression
-@code{(incf (point) @var{n})} is essentially equivalent to
+As a more Emacs-specific example of @code{cl-incf}, the expression
+@code{(cl-incf (point) @var{n})} is essentially equivalent to
 @code{(forward-char @var{n})}.
-@end defspec
+@end defmac
 
-@defspec decf place &optional x
+@defmac cl-decf place &optional x
 This macro decrements the number stored in @var{place} by one, or
 by @var{x} if specified.
-@end defspec
+@end defmac
 
-@defspec pop place
-This macro removes and returns the first element of the list stored
-in @var{place}.  It is analogous to @code{(prog1 (car @var{place})
-(setf @var{place} (cdr @var{place})))}, except that it takes care
-to evaluate all subforms only once.
-@end defspec
-
-@defspec push x place
-This macro inserts @var{x} at the front of the list stored in
-@var{place}.  It is analogous to @code{(setf @var{place} (cons
-@var{x} @var{place}))}, except for evaluation of the subforms.
-@end defspec
-
-@defspec pushnew x place @t{&key :test :test-not :key}
+@defmac cl-pushnew x place @t{&key :test :test-not :key}
 This macro inserts @var{x} at the front of the list stored in
 @var{place}, but only if @var{x} was not @code{eql} to any
 existing element of the list.  The optional keyword arguments
-are interpreted in the same way as for @code{adjoin}.
+are interpreted in the same way as for @code{cl-adjoin}.
 @xref{Lists as Sets}.
-@end defspec
+@end defmac
 
-@defspec shiftf place@dots{} newvalue
+@defmac cl-shiftf place@dots{} newvalue
 This macro shifts the @var{place}s left by one, shifting in the
 value of @var{newvalue} (which may be any Lisp expression, not just
 a generalized variable), and returning the value shifted out of
-the first @var{place}.  Thus, @code{(shiftf @var{a} @var{b} @var{c}
+the first @var{place}.  Thus, @code{(cl-shiftf @var{a} @var{b} @var{c}
 @var{d})} is equivalent to
 
 @example
 (prog1
     @var{a}
-  (psetf @var{a} @var{b}
-         @var{b} @var{c}
-         @var{c} @var{d}))
+  (cl-psetf @var{a} @var{b}
+            @var{b} @var{c}
+            @var{c} @var{d}))
 @end example
 
 @noindent
 except that the subforms of @var{a}, @var{b}, and @var{c} are actually
 evaluated only once each and in the apparent order.
-@end defspec
+@end defmac
 
-@defspec rotatef place@dots{}
+@defmac cl-rotatef place@dots{}
 This macro rotates the @var{place}s left by one in circular fashion.
-Thus, @code{(rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to
+Thus, @code{(cl-rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to
 
 @example
-(psetf @var{a} @var{b}
-       @var{b} @var{c}
-       @var{c} @var{d}
-       @var{d} @var{a})
+(cl-psetf @var{a} @var{b}
+          @var{b} @var{c}
+          @var{c} @var{d}
+          @var{d} @var{a})
 @end example
 
 @noindent
-except for the evaluation of subforms.  @code{rotatef} always
-returns @code{nil}.  Note that @code{(rotatef @var{a} @var{b})}
+except for the evaluation of subforms.  @code{cl-rotatef} always
+returns @code{nil}.  Note that @code{(cl-rotatef @var{a} @var{b})}
 conveniently exchanges @var{a} and @var{b}.
-@end defspec
+@end defmac
 
 The following macros were invented for this package; they have no
 analogues in Common Lisp.
 
-@defspec letf (bindings@dots{}) forms@dots{}
+@defmac cl-letf (bindings@dots{}) forms@dots{}
 This macro is analogous to @code{let}, but for generalized variables
 rather than just symbols.  Each @var{binding} should be of the form
 @code{(@var{place} @var{value})}; the original contents of the
@@ -1208,943 +1150,610 @@ error.
 For example,
 
 @example
-(letf (((point) (point-min))
-       (a 17))
-  ...)
+(cl-letf (((point) (point-min))
+          (a 17))
+     @dots{})
 @end example
 
 @noindent
-moves ``point'' in the current buffer to the beginning of the buffer,
+moves point in the current buffer to the beginning of the buffer,
 and also binds @code{a} to 17 (as if by a normal @code{let}, since
 @code{a} is just a regular variable).  After the body exits, @code{a}
 is set back to its original value and point is moved back to its
 original position.
 
-Note that @code{letf} on @code{(point)} is not quite like a
+Note that @code{cl-letf} on @code{(point)} is not quite like a
 @code{save-excursion}, as the latter effectively saves a marker
 which tracks insertions and deletions in the buffer.  Actually,
-a @code{letf} of @code{(point-marker)} is much closer to this
+a @code{cl-letf} of @code{(point-marker)} is much closer to this
 behavior.  (@code{point} and @code{point-marker} are equivalent
 as @code{setf} places; each will accept either an integer or a
 marker as the stored value.)
 
 Since generalized variables look like lists, @code{let}'s shorthand
 of using @samp{foo} for @samp{(foo nil)} as a @var{binding} would
-be ambiguous in @code{letf} and is not allowed.
+be ambiguous in @code{cl-letf} and is not allowed.
 
 However, a @var{binding} specifier may be a one-element list
 @samp{(@var{place})}, which is similar to @samp{(@var{place}
 @var{place})}.  In other words, the @var{place} is not disturbed
-on entry to the body, and the only effect of the @code{letf} is
-to restore the original value of @var{place} afterwards.  (The
-redundant access-and-store suggested by the @code{(@var{place}
+on entry to the body, and the only effect of the @code{cl-letf} is
+to restore the original value of @var{place} afterwards.
+@c I suspect this may no longer be true; either way it's
+@c implementation detail and so not essential to document.
+@ignore
+(The redundant access-and-store suggested by the @code{(@var{place}
 @var{place})} example does not actually occur.)
-
-In most cases, the @var{place} must have a well-defined value on
-entry to the @code{letf} form.  The only exceptions are plain
-variables and calls to @code{symbol-value} and @code{symbol-function}.
-If the symbol is not bound on entry, it is simply made unbound by
-@code{makunbound} or @code{fmakunbound} on exit.
-@end defspec
-
-@defspec letf* (bindings@dots{}) forms@dots{}
-This macro is to @code{letf} what @code{let*} is to @code{let}:
+@end ignore
+
+Note that in this case, and in fact almost every case, @var{place}
+must have a well-defined value outside the @code{cl-letf} body.
+There is essentially only one exception to this, which is @var{place}
+a plain variable with a specified @var{value} (such as @code{(a 17)}
+in the above example).
+@c See http://debbugs.gnu.org/12758
+@c Some or all of this was true for cl.el, but not for cl-lib.el.
+@ignore
+The only exceptions are plain variables and calls to
+@code{symbol-value} and @code{symbol-function}.  If the symbol is not
+bound on entry, it is simply made unbound by @code{makunbound} or
+@code{fmakunbound} on exit.
+@end ignore
+@end defmac
+
+@defmac cl-letf* (bindings@dots{}) forms@dots{}
+This macro is to @code{cl-letf} what @code{let*} is to @code{let}:
 It does the bindings in sequential rather than parallel order.
-@end defspec
+@end defmac
 
-@defspec callf @var{function} @var{place} @var{args}@dots{}
+@defmac cl-callf @var{function} @var{place} @var{args}@dots{}
 This is the ``generic'' modify macro.  It calls @var{function},
 which should be an unquoted function name, macro name, or lambda.
 It passes @var{place} and @var{args} as arguments, and assigns the
-result back to @var{place}.  For example, @code{(incf @var{place}
-@var{n})} is the same as @code{(callf + @var{place} @var{n})}.
+result back to @var{place}.  For example, @code{(cl-incf @var{place}
+@var{n})} is the same as @code{(cl-callf + @var{place} @var{n})}.
 Some more examples:
 
 @example
-(callf abs my-number)
-(callf concat (buffer-name) "<" (int-to-string n) ">")
-(callf union happy-people (list joe bob) :test 'same-person)
+(cl-callf abs my-number)
+(cl-callf concat (buffer-name) "<" (number-to-string n) ">")
+(cl-callf cl-union happy-people (list joe bob) :test 'same-person)
 @end example
 
-@xref{Customizing Setf}, for @code{define-modify-macro}, a way
-to create even more concise notations for modify macros.  Note
-again that @code{callf} is an extension to standard Common Lisp.
-@end defspec
+Note again that @code{cl-callf} is an extension to standard Common Lisp.
+@end defmac
 
-@defspec callf2 @var{function} @var{arg1} @var{place} @var{args}@dots{}
-This macro is like @code{callf}, except that @var{place} is
+@defmac cl-callf2 @var{function} @var{arg1} @var{place} @var{args}@dots{}
+This macro is like @code{cl-callf}, except that @var{place} is
 the @emph{second} argument of @var{function} rather than the
 first.  For example, @code{(push @var{x} @var{place})} is
-equivalent to @code{(callf2 cons @var{x} @var{place})}.
-@end defspec
+equivalent to @code{(cl-callf2 cons @var{x} @var{place})}.
+@end defmac
+
+The @code{cl-callf} and @code{cl-callf2} macros serve as building
+blocks for other macros like @code{cl-incf}, and @code{cl-pushnew}.
+The @code{cl-letf} and @code{cl-letf*} macros are used in the processing
+of symbol macros; @pxref{Macro Bindings}.
 
-The @code{callf} and @code{callf2} macros serve as building
-blocks for other macros like @code{incf}, @code{pushnew}, and
-@code{define-modify-macro}.  The @code{letf} and @code{letf*}
-macros are used in the processing of symbol macros;
-@pxref{Macro Bindings}.
 
-@node Customizing Setf
-@subsection Customizing Setf
+@node Variable Bindings
+@section Variable Bindings
 
 @noindent
-Common Lisp defines three macros, @code{define-modify-macro},
-@code{defsetf}, and @code{define-setf-method}, that allow the
-user to extend generalized variables in various ways.
+These Lisp forms make bindings to variables and function names,
+analogous to Lisp's built-in @code{let} form.
 
-@defspec define-modify-macro name arglist function [doc-string]
-This macro defines a ``read-modify-write'' macro similar to
-@code{incf} and @code{decf}.  The macro @var{name} is defined
-to take a @var{place} argument followed by additional arguments
-described by @var{arglist}.  The call
+@xref{Modify Macros}, for the @code{cl-letf} and @code{cl-letf*} forms which
+are also related to variable bindings.
 
-@example
-(@var{name} @var{place} @var{args}...)
-@end example
+@menu
+* Dynamic Bindings::     The @code{cl-progv} form.
+* Function Bindings::    @code{cl-flet} and @code{cl-labels}.
+* Macro Bindings::       @code{cl-macrolet} and @code{cl-symbol-macrolet}.
+@end menu
+
+@node Dynamic Bindings
+@subsection Dynamic Bindings
 
 @noindent
-will be expanded to
+The standard @code{let} form binds variables whose names are known
+at compile-time.  The @code{cl-progv} form provides an easy way to
+bind variables whose names are computed at run-time.
 
-@example
-(callf @var{func} @var{place} @var{args}...)
-@end example
+@defmac cl-progv symbols values forms@dots{}
+This form establishes @code{let}-style variable bindings on a
+set of variables computed at run-time.  The expressions
+@var{symbols} and @var{values} are evaluated, and must return lists
+of symbols and values, respectively.  The symbols are bound to the
+corresponding values for the duration of the body @var{form}s.
+If @var{values} is shorter than @var{symbols}, the last few symbols
+are bound to @code{nil}.
+If @var{symbols} is shorter than @var{values}, the excess values
+are ignored.
+@end defmac
+
+@node Function Bindings
+@subsection Function Bindings
 
 @noindent
-which in turn is roughly equivalent to
+These forms make @code{let}-like bindings to functions instead
+of variables.
 
-@example
-(setf @var{place} (@var{func} @var{place} @var{args}...))
-@end example
+@defmac cl-flet (bindings@dots{}) forms@dots{}
+This form establishes @code{let}-style bindings on the function
+cells of symbols rather than on the value cells.  Each @var{binding}
+must be a list of the form @samp{(@var{name} @var{arglist}
+@var{forms}@dots{})}, which defines a function exactly as if
+it were a @code{cl-defun} form.  The function @var{name} is defined
+accordingly for the duration of the body of the @code{cl-flet}; then
+the old function definition, or lack thereof, is restored.
 
-For example:
+You can use @code{cl-flet} to disable or modify the behavior of
+functions (including Emacs primitives) in a temporary, localized fashion.
+(Compare this with the idea of advising functions.
+@xref{Advising Functions,,,elisp,GNU Emacs Lisp Reference Manual}.)
 
-@example
-(define-modify-macro incf (&optional (n 1)) +)
-(define-modify-macro concatf (&rest args) concat)
-@end example
+The bindings are lexical in scope.  This means that all references to
+the named functions must appear physically within the body of the
+@code{cl-flet} form.
 
-Note that @code{&key} is not allowed in @var{arglist}, but
-@code{&rest} is sufficient to pass keywords on to the function.
+Functions defined by @code{cl-flet} may use the full Common Lisp
+argument notation supported by @code{cl-defun}; also, the function
+body is enclosed in an implicit block as if by @code{cl-defun}.
+@xref{Program Structure}.
 
-Most of the modify macros defined by Common Lisp do not exactly
-follow the pattern of @code{define-modify-macro}.  For example,
-@code{push} takes its arguments in the wrong order, and @code{pop}
-is completely irregular.  You can define these macros ``by hand''
-using @code{get-setf-method}, or consult the source file
-@file{cl-macs.el} to see how to use the internal @code{setf}
-building blocks.
-@end defspec
-
-@defspec defsetf access-fn update-fn
-This is the simpler of two @code{defsetf} forms.  Where
-@var{access-fn} is the name of a function which accesses a place,
-this declares @var{update-fn} to be the corresponding store
-function.  From now on,
+Note that the @file{cl.el} version of this macro behaves slightly
+differently.  In particular, its binding is dynamic rather than
+lexical.  @xref{Obsolete Macros}.
+@end defmac
 
-@example
-(setf (@var{access-fn} @var{arg1} @var{arg2} @var{arg3}) @var{value})
-@end example
+@defmac cl-labels (bindings@dots{}) forms@dots{}
+The @code{cl-labels} form is like @code{cl-flet}, except that
+the function bindings can be recursive.  The scoping is lexical,
+but you can only capture functions in closures if
+@code{lexical-binding} is @code{t}.
+@xref{Closures,,,elisp,GNU Emacs Lisp Reference Manual}, and
+@ref{Using Lexical Binding,,,elisp,GNU Emacs Lisp Reference Manual}.
 
-@noindent
-will be expanded to
+Lexical scoping means that all references to the named
+functions must appear physically within the body of the
+@code{cl-labels} form.  References may appear both in the body
+@var{forms} of @code{cl-labels} itself, and in the bodies of
+the functions themselves.  Thus, @code{cl-labels} can define
+local recursive functions, or mutually-recursive sets of functions.
 
-@example
-(@var{update-fn} @var{arg1} @var{arg2} @var{arg3} @var{value})
-@end example
+A ``reference'' to a function name is either a call to that
+function, or a use of its name quoted by @code{quote} or
+@code{function} to be passed on to, say, @code{mapcar}.
+
+Note that the @file{cl.el} version of this macro behaves slightly
+differently.  @xref{Obsolete Macros}.
+@end defmac
+
+@node Macro Bindings
+@subsection Macro Bindings
 
 @noindent
-The @var{update-fn} is required to be either a true function, or
-a macro which evaluates its arguments in a function-like way.  Also,
-the @var{update-fn} is expected to return @var{value} as its result.
-Otherwise, the above expansion would not obey the rules for the way
-@code{setf} is supposed to behave.
+These forms create local macros and ``symbol macros''.
 
-As a special (non-Common-Lisp) extension, a third argument of @code{t}
-to @code{defsetf} says that the @code{update-fn}'s return value is
-not suitable, so that the above @code{setf} should be expanded to
-something more like
+@defmac cl-macrolet (bindings@dots{}) forms@dots{}
+This form is analogous to @code{cl-flet}, but for macros instead of
+functions.  Each @var{binding} is a list of the same form as the
+arguments to @code{cl-defmacro} (i.e., a macro name, argument list,
+and macro-expander forms).  The macro is defined accordingly for
+use within the body of the @code{cl-macrolet}.
+
+Because of the nature of macros, @code{cl-macrolet} is always lexically
+scoped.  The @code{cl-macrolet} binding will
+affect only calls that appear physically within the body
+@var{forms}, possibly after expansion of other macros in the
+body.
+@end defmac
+
+@defmac cl-symbol-macrolet (bindings@dots{}) forms@dots{}
+This form creates @dfn{symbol macros}, which are macros that look
+like variable references rather than function calls.  Each
+@var{binding} is a list @samp{(@var{var} @var{expansion})};
+any reference to @var{var} within the body @var{forms} is
+replaced by @var{expansion}.
 
 @example
-(let ((temp @var{value}))
-  (@var{update-fn} @var{arg1} @var{arg2} @var{arg3} temp)
-  temp)
+(setq bar '(5 . 9))
+(cl-symbol-macrolet ((foo (car bar)))
+  (cl-incf foo))
+bar
+     @result{} (6 . 9)
 @end example
 
-Some examples of the use of @code{defsetf}, drawn from the standard
-suite of setf methods, are:
+A @code{setq} of a symbol macro is treated the same as a @code{setf}.
+I.e., @code{(setq foo 4)} in the above would be equivalent to
+@code{(setf foo 4)}, which in turn expands to @code{(setf (car bar) 4)}.
+
+Likewise, a @code{let} or @code{let*} binding a symbol macro is
+treated like a @code{cl-letf} or @code{cl-letf*}.  This differs from true
+Common Lisp, where the rules of lexical scoping cause a @code{let}
+binding to shadow a @code{symbol-macrolet} binding.  In this package,
+such shadowing does not occur, even when @code{lexical-binding} is
+@c See http://debbugs.gnu.org/12119
+@code{t}.  (This behavior predates the addition of lexical binding to
+Emacs Lisp, and may change in future to respect @code{lexical-binding}.)
+At present in this package, only @code{lexical-let} and
+@code{lexical-let*} will shadow a symbol macro.  @xref{Obsolete
+Lexical Binding}.
+
+There is no analogue of @code{defmacro} for symbol macros; all symbol
+macros are local.  A typical use of @code{cl-symbol-macrolet} is in the
+expansion of another macro:
 
 @example
-(defsetf car setcar)
-(defsetf symbol-value set)
-(defsetf buffer-name rename-buffer t)
+(cl-defmacro my-dolist ((x list) &rest body)
+  (let ((var (cl-gensym)))
+    (list 'cl-loop 'for var 'on list 'do
+          (cl-list* 'cl-symbol-macrolet
+                    (list (list x (list 'car var)))
+                    body))))
+
+(setq mylist '(1 2 3 4))
+(my-dolist (x mylist) (cl-incf x))
+mylist
+     @result{} (2 3 4 5)
 @end example
-@end defspec
-
-@defspec defsetf access-fn arglist (store-var) forms@dots{}
-This is the second, more complex, form of @code{defsetf}.  It is
-rather like @code{defmacro} except for the additional @var{store-var}
-argument.  The @var{forms} should return a Lisp form which stores
-the value of @var{store-var} into the generalized variable formed
-by a call to @var{access-fn} with arguments described by @var{arglist}.
-The @var{forms} may begin with a string which documents the @code{setf}
-method (analogous to the doc string that appears at the front of a
-function).
 
-For example, the simple form of @code{defsetf} is shorthand for
+@noindent
+In this example, the @code{my-dolist} macro is similar to @code{dolist}
+(@pxref{Iteration}) except that the variable @code{x} becomes a true
+reference onto the elements of the list.  The @code{my-dolist} call
+shown here expands to
 
 @example
-(defsetf @var{access-fn} (&rest args) (store)
-  (append '(@var{update-fn}) args (list store)))
+(cl-loop for G1234 on mylist do
+      (cl-symbol-macrolet ((x (car G1234)))
+        (cl-incf x)))
 @end example
 
-The Lisp form that is returned can access the arguments from
-@var{arglist} and @var{store-var} in an unrestricted fashion;
-macros like @code{setf} and @code{incf} which invoke this
-setf-method will insert temporary variables as needed to make
-sure the apparent order of evaluation is preserved.
-
-Another example drawn from the standard package:
+@noindent
+which in turn expands to
 
 @example
-(defsetf nth (n x) (store)
-  (list 'setcar (list 'nthcdr n x) store))
+(cl-loop for G1234 on mylist do (cl-incf (car G1234)))
 @end example
-@end defspec
 
-@defspec define-setf-method access-fn arglist forms@dots{}
-This is the most general way to create new place forms.  When
-a @code{setf} to @var{access-fn} with arguments described by
-@var{arglist} is expanded, the @var{forms} are evaluated and
-must return a list of five items:
+@xref{Loop Facility}, for a description of the @code{cl-loop} macro.
+This package defines a nonstandard @code{in-ref} loop clause that
+works much like @code{my-dolist}.
+@end defmac
 
-@enumerate
-@item
-A list of @dfn{temporary variables}.
+@node Conditionals
+@section Conditionals
 
-@item
-A list of @dfn{value forms} corresponding to the temporary variables
-above.  The temporary variables will be bound to these value forms
-as the first step of any operation on the generalized variable.
+@noindent
+These conditional forms augment Emacs Lisp's simple @code{if},
+@code{and}, @code{or}, and @code{cond} forms.
 
-@item
-A list of exactly one @dfn{store variable} (generally obtained
-from a call to @code{gensym}).
+@defmac cl-case keyform clause@dots{}
+This macro evaluates @var{keyform}, then compares it with the key
+values listed in the various @var{clause}s.  Whichever clause matches
+the key is executed; comparison is done by @code{eql}.  If no clause
+matches, the @code{cl-case} form returns @code{nil}.  The clauses are
+of the form
 
-@item
-A Lisp form which stores the contents of the store variable into
-the generalized variable, assuming the temporaries have been
-bound as described above.
+@example
+(@var{keylist} @var{body-forms}@dots{})
+@end example
 
-@item
-A Lisp form which accesses the contents of the generalized variable,
-assuming the temporaries have been bound.
-@end enumerate
+@noindent
+where @var{keylist} is a list of key values.  If there is exactly
+one value, and it is not a cons cell or the symbol @code{nil} or
+@code{t}, then it can be used by itself as a @var{keylist} without
+being enclosed in a list.  All key values in the @code{cl-case} form
+must be distinct.  The final clauses may use @code{t} in place of
+a @var{keylist} to indicate a default clause that should be taken
+if none of the other clauses match.  (The symbol @code{otherwise}
+is also recognized in place of @code{t}.  To make a clause that
+matches the actual symbol @code{t}, @code{nil}, or @code{otherwise},
+enclose the symbol in a list.)
 
-This is exactly like the Common Lisp macro of the same name,
-except that the method returns a list of five values rather
-than the five values themselves, since Emacs Lisp does not
-support Common Lisp's notion of multiple return values.
+For example, this expression reads a keystroke, then does one of
+four things depending on whether it is an @samp{a}, a @samp{b},
+a @key{RET} or @kbd{C-j}, or anything else.
 
-Once again, the @var{forms} may begin with a documentation string.
+@example
+(cl-case (read-char)
+  (?a (do-a-thing))
+  (?b (do-b-thing))
+  ((?\r ?\n) (do-ret-thing))
+  (t (do-other-thing)))
+@end example
+@end defmac
 
-A setf-method should be maximally conservative with regard to
-temporary variables.  In the setf-methods generated by
-@code{defsetf}, the second return value is simply the list of
-arguments in the place form, and the first return value is a
-list of a corresponding number of temporary variables generated
-by @code{gensym}.  Macros like @code{setf} and @code{incf} which
-use this setf-method will optimize away most temporaries that
-turn out to be unnecessary, so there is little reason for the
-setf-method itself to optimize.
-@end defspec
+@defmac cl-ecase keyform clause@dots{}
+This macro is just like @code{cl-case}, except that if the key does
+not match any of the clauses, an error is signaled rather than
+simply returning @code{nil}.
+@end defmac
 
-@defun get-setf-method place &optional env
-This function returns the setf-method for @var{place}, by
-invoking the definition previously recorded by @code{defsetf}
-or @code{define-setf-method}.  The result is a list of five
-values as described above.  You can use this function to build
-your own @code{incf}-like modify macros.  (Actually, it is
-better to use the internal functions @code{cl-setf-do-modify}
-and @code{cl-setf-do-store}, which are a bit easier to use and
-which also do a number of optimizations; consult the source
-code for the @code{incf} function for a simple example.)
+@defmac cl-typecase keyform clause@dots{}
+This macro is a version of @code{cl-case} that checks for types
+rather than values.  Each @var{clause} is of the form
+@samp{(@var{type} @var{body}@dots{})}.  @xref{Type Predicates},
+for a description of type specifiers.  For example,
 
-The argument @var{env} specifies the ``environment'' to be
-passed on to @code{macroexpand} if @code{get-setf-method} should
-need to expand a macro in @var{place}.  It should come from
-an @code{&environment} argument to the macro or setf-method
-that called @code{get-setf-method}.
+@example
+(cl-typecase x
+  (integer (munch-integer x))
+  (float (munch-float x))
+  (string (munch-integer (string-to-int x)))
+  (t (munch-anything x)))
+@end example
 
-See also the source code for the setf-methods for @code{apply}
-and @code{substring}, each of which works by calling
-@code{get-setf-method} on a simpler case, then massaging
-the result in various ways.
-@end defun
+The type specifier @code{t} matches any type of object; the word
+@code{otherwise} is also allowed.  To make one clause match any of
+several types, use an @code{(or @dots{})} type specifier.
+@end defmac
 
-Modern Common Lisp defines a second, independent way to specify
-the @code{setf} behavior of a function, namely ``@code{setf}
-functions'' whose names are lists @code{(setf @var{name})}
-rather than symbols.  For example, @code{(defun (setf foo) @dots{})}
-defines the function that is used when @code{setf} is applied to
-@code{foo}.  This package does not currently support @code{setf}
-functions.  In particular, it is a compile-time error to use
-@code{setf} on a form which has not already been @code{defsetf}'d
-or otherwise declared; in newer Common Lisps, this would not be
-an error since the function @code{(setf @var{func})} might be
-defined later.
-
-@iftex
-@secno=4
-@end iftex
+@defmac cl-etypecase keyform clause@dots{}
+This macro is just like @code{cl-typecase}, except that if the key does
+not match any of the clauses, an error is signaled rather than
+simply returning @code{nil}.
+@end defmac
 
-@node Variable Bindings
-@section Variable Bindings
+@node Blocks and Exits
+@section Blocks and Exits
 
 @noindent
-These Lisp forms make bindings to variables and function names,
-analogous to Lisp's built-in @code{let} form.
+Common Lisp @dfn{blocks} provide a non-local exit mechanism very
+similar to @code{catch} and @code{throw}, with lexical scoping.
+This package actually implements @code{cl-block}
+in terms of @code{catch}; however, the lexical scoping allows the
+byte-compiler to omit the costly @code{catch} step if the
+body of the block does not actually @code{cl-return-from} the block.
 
-@xref{Modify Macros}, for the @code{letf} and @code{letf*} forms which
-are also related to variable bindings.
+@defmac cl-block name forms@dots{}
+The @var{forms} are evaluated as if by a @code{progn}.  However,
+if any of the @var{forms} execute @code{(cl-return-from @var{name})},
+they will jump out and return directly from the @code{cl-block} form.
+The @code{cl-block} returns the result of the last @var{form} unless
+a @code{cl-return-from} occurs.
 
-@menu
-* Dynamic Bindings::     The @code{progv} form.
-* Lexical Bindings::     @code{lexical-let} and lexical closures.
-* Function Bindings::    @code{flet} and @code{labels}.
-* Macro Bindings::       @code{macrolet} and @code{symbol-macrolet}.
-@end menu
-
-@node Dynamic Bindings
-@subsection Dynamic Bindings
+The @code{cl-block}/@code{cl-return-from} mechanism is quite similar to
+the @code{catch}/@code{throw} mechanism.  The main differences are
+that block @var{name}s are unevaluated symbols, rather than forms
+(such as quoted symbols) that evaluate to a tag at run-time; and
+also that blocks are always lexically scoped.
+In a dynamically scoped @code{catch}, functions called from the
+@code{catch} body can also @code{throw} to the @code{catch}.  This
+is not an option for @code{cl-block}, where
+the @code{cl-return-from} referring to a block name must appear
+physically within the @var{forms} that make up the body of the block.
+They may not appear within other called functions, although they may
+appear within macro expansions or @code{lambda}s in the body.  Block
+names and @code{catch} names form independent name-spaces.
 
-@noindent
-The standard @code{let} form binds variables whose names are known
-at compile-time.  The @code{progv} form provides an easy way to
-bind variables whose names are computed at run-time.
+In true Common Lisp, @code{defun} and @code{defmacro} surround
+the function or expander bodies with implicit blocks with the
+same name as the function or macro.  This does not occur in Emacs
+Lisp, but this package provides @code{cl-defun} and @code{cl-defmacro}
+forms, which do create the implicit block.
 
-@defspec progv symbols values forms@dots{}
-This form establishes @code{let}-style variable bindings on a
-set of variables computed at run-time.  The expressions
-@var{symbols} and @var{values} are evaluated, and must return lists
-of symbols and values, respectively.  The symbols are bound to the
-corresponding values for the duration of the body @var{form}s.
-If @var{values} is shorter than @var{symbols}, the last few symbols
-are made unbound (as if by @code{makunbound}) inside the body.
-If @var{symbols} is shorter than @var{values}, the excess values
-are ignored.
-@end defspec
+The Common Lisp looping constructs defined by this package,
+such as @code{cl-loop} and @code{cl-dolist}, also create implicit blocks
+just as in Common Lisp.
 
-@node Lexical Bindings
-@subsection Lexical Bindings
+Because they are implemented in terms of Emacs Lisp's @code{catch}
+and @code{throw}, blocks have the same overhead as actual
+@code{catch} constructs (roughly two function calls).  However,
+the byte compiler will optimize away the @code{catch}
+if the block does
+not in fact contain any @code{cl-return} or @code{cl-return-from} calls
+that jump to it.  This means that @code{cl-do} loops and @code{cl-defun}
+functions that don't use @code{cl-return} don't pay the overhead to
+support it.
+@end defmac
 
-@noindent
-The @code{CL} package defines the following macro which
-more closely follows the Common Lisp @code{let} form:
+@defmac cl-return-from name [result]
+This macro returns from the block named @var{name}, which must be
+an (unevaluated) symbol.  If a @var{result} form is specified, it
+is evaluated to produce the result returned from the @code{block}.
+Otherwise, @code{nil} is returned.
+@end defmac
 
-@defspec lexical-let (bindings@dots{}) forms@dots{}
-This form is exactly like @code{let} except that the bindings it
-establishes are purely lexical.  Lexical bindings are similar to
-local variables in a language like C:  Only the code physically
-within the body of the @code{lexical-let} (after macro expansion)
-may refer to the bound variables.
+@defmac cl-return [result]
+This macro is exactly like @code{(cl-return-from nil @var{result})}.
+Common Lisp loops like @code{cl-do} and @code{cl-dolist} implicitly enclose
+themselves in @code{nil} blocks.
+@end defmac
 
-@example
-(setq a 5)
-(defun foo (b) (+ a b))
-(let ((a 2)) (foo a))
-     @result{} 4
-(lexical-let ((a 2)) (foo a))
-     @result{} 7
-@end example
+@node Iteration
+@section Iteration
 
 @noindent
-In this example, a regular @code{let} binding of @code{a} actually
-makes a temporary change to the global variable @code{a}, so @code{foo}
-is able to see the binding of @code{a} to 2.  But @code{lexical-let}
-actually creates a distinct local variable @code{a} for use within its
-body, without any effect on the global variable of the same name.
+The macros described here provide more sophisticated, high-level
+looping constructs to complement Emacs Lisp's basic loop forms
+(@pxref{Iteration,,,elisp,GNU Emacs Lisp Reference Manual}).
 
-The most important use of lexical bindings is to create @dfn{closures}.
-A closure is a function object that refers to an outside lexical
-variable.  For example:
+@defmac cl-loop forms@dots{}
+This package supports both the simple, old-style meaning of
+@code{loop} and the extremely powerful and flexible feature known as
+the @dfn{Loop Facility} or @dfn{Loop Macro}.  This more advanced
+facility is discussed in the following section; @pxref{Loop Facility}.
+The simple form of @code{loop} is described here.
+
+If @code{cl-loop} is followed by zero or more Lisp expressions,
+then @code{(cl-loop @var{exprs}@dots{})} simply creates an infinite
+loop executing the expressions over and over.  The loop is
+enclosed in an implicit @code{nil} block.  Thus,
 
 @example
-(defun make-adder (n)
-  (lexical-let ((n n))
-    (function (lambda (m) (+ n m)))))
-(setq add17 (make-adder 17))
-(funcall add17 4)
-     @result{} 21
+(cl-loop (foo)  (if (no-more) (return 72))  (bar))
 @end example
 
 @noindent
-The call @code{(make-adder 17)} returns a function object which adds
-17 to its argument.  If @code{let} had been used instead of
-@code{lexical-let}, the function object would have referred to the
-global @code{n}, which would have been bound to 17 only during the
-call to @code{make-adder} itself.
+is exactly equivalent to
 
 @example
-(defun make-counter ()
-  (lexical-let ((n 0))
-    (function* (lambda (&optional (m 1)) (incf n m)))))
-(setq count-1 (make-counter))
-(funcall count-1 3)
-     @result{} 3
-(funcall count-1 14)
-     @result{} 17
-(setq count-2 (make-counter))
-(funcall count-2 5)
-     @result{} 5
-(funcall count-1 2)
-     @result{} 19
-(funcall count-2)
-     @result{} 6
+(cl-block nil (while t (foo)  (if (no-more) (return 72))  (bar)))
 @end example
 
-@noindent
-Here we see that each call to @code{make-counter} creates a distinct
-local variable @code{n}, which serves as a private counter for the
-function object that is returned.
-
-Closed-over lexical variables persist until the last reference to
-them goes away, just like all other Lisp objects.  For example,
-@code{count-2} refers to a function object which refers to an
-instance of the variable @code{n}; this is the only reference
-to that variable, so after @code{(setq count-2 nil)} the garbage
-collector would be able to delete this instance of @code{n}.
-Of course, if a @code{lexical-let} does not actually create any
-closures, then the lexical variables are free as soon as the
-@code{lexical-let} returns.
+If any of the expressions are plain symbols, the loop is instead
+interpreted as a Loop Macro specification as described later.
+(This is not a restriction in practice, since a plain symbol
+in the above notation would simply access and throw away the
+value of a variable.)
+@end defmac
 
-Many closures are used only during the extent of the bindings they
-refer to; these are known as ``downward funargs'' in Lisp parlance.
-When a closure is used in this way, regular Emacs Lisp dynamic
-bindings suffice and will be more efficient than @code{lexical-let}
-closures:
+@defmac cl-do (spec@dots{}) (end-test [result@dots{}]) forms@dots{}
+This macro creates a general iterative loop.  Each @var{spec} is
+of the form
 
 @example
-(defun add-to-list (x list)
-  (mapcar (lambda (y) (+ x y))) list)
-(add-to-list 7 '(1 2 5))
-     @result{} (8 9 12)
+(@var{var} [@var{init} [@var{step}]])
 @end example
 
-@noindent
-Since this lambda is only used while @code{x} is still bound,
-it is not necessary to make a true closure out of it.
-
-You can use @code{defun} or @code{flet} inside a @code{lexical-let}
-to create a named closure.  If several closures are created in the
-body of a single @code{lexical-let}, they all close over the same
-instance of the lexical variable.
-
-The @code{lexical-let} form is an extension to Common Lisp.  In
-true Common Lisp, all bindings are lexical unless declared otherwise.
-@end defspec
+The loop works as follows:  First, each @var{var} is bound to the
+associated @var{init} value as if by a @code{let} form.  Then, in
+each iteration of the loop, the @var{end-test} is evaluated; if
+true, the loop is finished.  Otherwise, the body @var{forms} are
+evaluated, then each @var{var} is set to the associated @var{step}
+expression (as if by a @code{cl-psetq} form) and the next iteration
+begins.  Once the @var{end-test} becomes true, the @var{result}
+forms are evaluated (with the @var{var}s still bound to their
+values) to produce the result returned by @code{cl-do}.
 
-@defspec lexical-let* (bindings@dots{}) forms@dots{}
-This form is just like @code{lexical-let}, except that the bindings
-are made sequentially in the manner of @code{let*}.
-@end defspec
+The entire @code{cl-do} loop is enclosed in an implicit @code{nil}
+block, so that you can use @code{(cl-return)} to break out of the
+loop at any time.
 
-@node Function Bindings
-@subsection Function Bindings
+If there are no @var{result} forms, the loop returns @code{nil}.
+If a given @var{var} has no @var{step} form, it is bound to its
+@var{init} value but not otherwise modified during the @code{cl-do}
+loop (unless the code explicitly modifies it); this case is just
+a shorthand for putting a @code{(let ((@var{var} @var{init})) @dots{})}
+around the loop.  If @var{init} is also omitted it defaults to
+@code{nil}, and in this case a plain @samp{@var{var}} can be used
+in place of @samp{(@var{var})}, again following the analogy with
+@code{let}.
 
-@noindent
-These forms make @code{let}-like bindings to functions instead
-of variables.
+This example (from Steele) illustrates a loop that applies the
+function @code{f} to successive pairs of values from the lists
+@code{foo} and @code{bar}; it is equivalent to the call
+@code{(cl-mapcar 'f foo bar)}.  Note that this loop has no body
+@var{forms} at all, performing all its work as side effects of
+the rest of the loop.
 
-@defspec flet (bindings@dots{}) forms@dots{}
-This form establishes @code{let}-style bindings on the function
-cells of symbols rather than on the value cells.  Each @var{binding}
-must be a list of the form @samp{(@var{name} @var{arglist}
-@var{forms}@dots{})}, which defines a function exactly as if
-it were a @code{defun*} form.  The function @var{name} is defined
-accordingly for the duration of the body of the @code{flet}; then
-the old function definition, or lack thereof, is restored.
+@example
+(cl-do ((x foo (cdr x))
+        (y bar (cdr y))
+        (z nil (cons (f (car x) (car y)) z)))
+     ((or (null x) (null y))
+      (nreverse z)))
+@end example
+@end defmac
 
-While @code{flet} in Common Lisp establishes a lexical binding of
-@var{name}, Emacs Lisp @code{flet} makes a dynamic binding.  The
-result is that @code{flet} affects indirect calls to a function as
-well as calls directly inside the @code{flet} form itself.
+@defmac cl-do* (spec@dots{}) (end-test [result@dots{}]) forms@dots{}
+This is to @code{cl-do} what @code{let*} is to @code{let}.  In
+particular, the initial values are bound as if by @code{let*}
+rather than @code{let}, and the steps are assigned as if by
+@code{setq} rather than @code{cl-psetq}.
 
-You can use @code{flet} to disable or modify the behavior of a
-function in a temporary fashion.  This will even work on Emacs
-primitives, although note that some calls to primitive functions
-internal to Emacs are made without going through the symbol's
-function cell, and so will not be affected by @code{flet}.  For
-example,
+Here is another way to write the above loop:
 
 @example
-(flet ((message (&rest args) (push args saved-msgs)))
-  (do-something))
+(cl-do* ((xp foo (cdr xp))
+         (yp bar (cdr yp))
+         (x (car xp) (car xp))
+         (y (car yp) (car yp))
+         z)
+  ((or (null xp) (null yp))
+   (nreverse z))
+  (push (f x y) z))
 @end example
+@end defmac
 
-This code attempts to replace the built-in function @code{message}
-with a function that simply saves the messages in a list rather
-than displaying them.  The original definition of @code{message}
-will be restored after @code{do-something} exits.  This code will
-work fine on messages generated by other Lisp code, but messages
-generated directly inside Emacs will not be caught since they make
-direct C-language calls to the message routines rather than going
-through the Lisp @code{message} function.
+@defmac cl-dolist (var list [result]) forms@dots{}
+This is exactly like the standard Emacs Lisp macro @code{dolist},
+but surrounds the loop with an implicit @code{nil} block.
+@end defmac
 
-@c Bug#411.
-Also note that many primitives (e.g. @code{+}) have special byte-compile
-handling.  Attempts to redefine such functions using @code{flet} will
-fail if byte-compiled.  In such cases, use @code{labels} instead.
+@defmac cl-dotimes (var count [result]) forms@dots{}
+This is exactly like the standard Emacs Lisp macro @code{dotimes},
+but surrounds the loop with an implicit @code{nil} block.
+The body is executed with @var{var} bound to the integers
+from zero (inclusive) to @var{count} (exclusive), in turn.  Then
+@c FIXME lispref does not state this part explicitly, could move this there.
+the @code{result} form is evaluated with @var{var} bound to the total
+number of iterations that were done (i.e., @code{(max 0 @var{count})})
+to get the return value for the loop form.
+@end defmac
 
-Functions defined by @code{flet} may use the full Common Lisp
-argument notation supported by @code{defun*}; also, the function
-body is enclosed in an implicit block as if by @code{defun*}.
-@xref{Program Structure}.
-@end defspec
-
-@defspec labels (bindings@dots{}) forms@dots{}
-The @code{labels} form is like @code{flet}, except that it
-makes lexical bindings of the function names rather than
-dynamic bindings.  (In true Common Lisp, both @code{flet} and
-@code{labels} make lexical bindings of slightly different sorts;
-since Emacs Lisp is dynamically bound by default, it seemed
-more appropriate for @code{flet} also to use dynamic binding.
-The @code{labels} form, with its lexical binding, is fully
-compatible with Common Lisp.)
+@defmac cl-do-symbols (var [obarray [result]]) forms@dots{}
+This loop iterates over all interned symbols.  If @var{obarray}
+is specified and is not @code{nil}, it loops over all symbols in
+that obarray.  For each symbol, the body @var{forms} are evaluated
+with @var{var} bound to that symbol.  The symbols are visited in
+an unspecified order.  Afterward the @var{result} form, if any,
+is evaluated (with @var{var} bound to @code{nil}) to get the return
+value.  The loop is surrounded by an implicit @code{nil} block.
+@end defmac
 
-Lexical scoping means that all references to the named
-functions must appear physically within the body of the
-@code{labels} form.  References may appear both in the body
-@var{forms} of @code{labels} itself, and in the bodies of
-the functions themselves.  Thus, @code{labels} can define
-local recursive functions, or mutually-recursive sets of
-functions.
+@defmac cl-do-all-symbols (var [result]) forms@dots{}
+This is identical to @code{cl-do-symbols} except that the @var{obarray}
+argument is omitted; it always iterates over the default obarray.
+@end defmac
 
-A ``reference'' to a function name is either a call to that
-function, or a use of its name quoted by @code{quote} or
-@code{function} to be passed on to, say, @code{mapcar}.
-@end defspec
+@xref{Mapping over Sequences}, for some more functions for
+iterating over vectors or lists.
 
-@node Macro Bindings
-@subsection Macro Bindings
+@node Loop Facility
+@section Loop Facility
 
 @noindent
-These forms create local macros and ``symbol macros.''
+A common complaint with Lisp's traditional looping constructs was
+that they were either too simple and limited, such as @code{dotimes}
+or @code{while}, or too unreadable and obscure, like Common Lisp's
+@code{do} loop.
 
-@defspec macrolet (bindings@dots{}) forms@dots{}
-This form is analogous to @code{flet}, but for macros instead of
-functions.  Each @var{binding} is a list of the same form as the
-arguments to @code{defmacro*} (i.e., a macro name, argument list,
-and macro-expander forms).  The macro is defined accordingly for
-use within the body of the @code{macrolet}.
+To remedy this, Common Lisp added a construct called the ``Loop
+Facility'' or ``@code{loop} macro'', with an easy-to-use but very
+powerful and expressive syntax.
 
-Because of the nature of macros, @code{macrolet} is lexically
-scoped even in Emacs Lisp:  The @code{macrolet} binding will
-affect only calls that appear physically within the body
-@var{forms}, possibly after expansion of other macros in the
-body.
-@end defspec
+@menu
+* Loop Basics::           The @code{cl-loop} macro, basic clause structure.
+* Loop Examples::         Working examples of the @code{cl-loop} macro.
+* For Clauses::           Clauses introduced by @code{for} or @code{as}.
+* Iteration Clauses::     @code{repeat}, @code{while}, @code{thereis}, etc.
+* Accumulation Clauses::  @code{collect}, @code{sum}, @code{maximize}, etc.
+* Other Clauses::         @code{with}, @code{if}, @code{initially}, @code{finally}.
+@end menu
 
-@defspec symbol-macrolet (bindings@dots{}) forms@dots{}
-This form creates @dfn{symbol macros}, which are macros that look
-like variable references rather than function calls.  Each
-@var{binding} is a list @samp{(@var{var} @var{expansion})};
-any reference to @var{var} within the body @var{forms} is
-replaced by @var{expansion}.
+@node Loop Basics
+@subsection Loop Basics
 
-@example
-(setq bar '(5 . 9))
-(symbol-macrolet ((foo (car bar)))
-  (incf foo))
-bar
-     @result{} (6 . 9)
-@end example
+@noindent
+The @code{cl-loop} macro essentially creates a mini-language within
+Lisp that is specially tailored for describing loops.  While this
+language is a little strange-looking by the standards of regular Lisp,
+it turns out to be very easy to learn and well-suited to its purpose.
 
-A @code{setq} of a symbol macro is treated the same as a @code{setf}.
-I.e., @code{(setq foo 4)} in the above would be equivalent to
-@code{(setf foo 4)}, which in turn expands to @code{(setf (car bar) 4)}.
+Since @code{cl-loop} is a macro, all parsing of the loop language
+takes place at byte-compile time; compiled @code{cl-loop}s are just
+as efficient as the equivalent @code{while} loops written longhand.
 
-Likewise, a @code{let} or @code{let*} binding a symbol macro is
-treated like a @code{letf} or @code{letf*}.  This differs from true
-Common Lisp, where the rules of lexical scoping cause a @code{let}
-binding to shadow a @code{symbol-macrolet} binding.  In this package,
-only @code{lexical-let} and @code{lexical-let*} will shadow a symbol
-macro.
+@defmac cl-loop clauses@dots{}
+A loop construct consists of a series of @var{clause}s, each
+introduced by a symbol like @code{for} or @code{do}.  Clauses
+are simply strung together in the argument list of @code{cl-loop},
+with minimal extra parentheses.  The various types of clauses
+specify initializations, such as the binding of temporary
+variables, actions to be taken in the loop, stepping actions,
+and final cleanup.
 
-There is no analogue of @code{defmacro} for symbol macros; all symbol
-macros are local.  A typical use of @code{symbol-macrolet} is in the
-expansion of another macro:
+Common Lisp specifies a certain general order of clauses in a
+loop:
 
 @example
-(defmacro* my-dolist ((x list) &rest body)
-  (let ((var (gensym)))
-    (list 'loop 'for var 'on list 'do
-          (list* 'symbol-macrolet (list (list x (list 'car var)))
-                 body))))
-
-(setq mylist '(1 2 3 4))
-(my-dolist (x mylist) (incf x))
-mylist
-     @result{} (2 3 4 5)
-@end example
-
-@noindent
-In this example, the @code{my-dolist} macro is similar to @code{dolist}
-(@pxref{Iteration}) except that the variable @code{x} becomes a true
-reference onto the elements of the list.  The @code{my-dolist} call
-shown here expands to
-
-@example
-(loop for G1234 on mylist do
-      (symbol-macrolet ((x (car G1234)))
-        (incf x)))
-@end example
-
-@noindent
-which in turn expands to
-
-@example
-(loop for G1234 on mylist do (incf (car G1234)))
-@end example
-
-@xref{Loop Facility}, for a description of the @code{loop} macro.
-This package defines a nonstandard @code{in-ref} loop clause that
-works much like @code{my-dolist}.
-@end defspec
-
-@node Conditionals
-@section Conditionals
-
-@noindent
-These conditional forms augment Emacs Lisp's simple @code{if},
-@code{and}, @code{or}, and @code{cond} forms.
-
-@defspec case keyform clause@dots{}
-This macro evaluates @var{keyform}, then compares it with the key
-values listed in the various @var{clause}s.  Whichever clause matches
-the key is executed; comparison is done by @code{eql}.  If no clause
-matches, the @code{case} form returns @code{nil}.  The clauses are
-of the form
-
-@example
-(@var{keylist} @var{body-forms}@dots{})
-@end example
-
-@noindent
-where @var{keylist} is a list of key values.  If there is exactly
-one value, and it is not a cons cell or the symbol @code{nil} or
-@code{t}, then it can be used by itself as a @var{keylist} without
-being enclosed in a list.  All key values in the @code{case} form
-must be distinct.  The final clauses may use @code{t} in place of
-a @var{keylist} to indicate a default clause that should be taken
-if none of the other clauses match.  (The symbol @code{otherwise}
-is also recognized in place of @code{t}.  To make a clause that
-matches the actual symbol @code{t}, @code{nil}, or @code{otherwise},
-enclose the symbol in a list.)
-
-For example, this expression reads a keystroke, then does one of
-four things depending on whether it is an @samp{a}, a @samp{b},
-a @key{RET} or @kbd{C-j}, or anything else.
-
-@example
-(case (read-char)
-  (?a (do-a-thing))
-  (?b (do-b-thing))
-  ((?\r ?\n) (do-ret-thing))
-  (t (do-other-thing)))
-@end example
-@end defspec
-
-@defspec ecase keyform clause@dots{}
-This macro is just like @code{case}, except that if the key does
-not match any of the clauses, an error is signaled rather than
-simply returning @code{nil}.
-@end defspec
-
-@defspec typecase keyform clause@dots{}
-This macro is a version of @code{case} that checks for types
-rather than values.  Each @var{clause} is of the form
-@samp{(@var{type} @var{body}...)}.  @xref{Type Predicates},
-for a description of type specifiers.  For example,
-
-@example
-(typecase x
-  (integer (munch-integer x))
-  (float (munch-float x))
-  (string (munch-integer (string-to-int x)))
-  (t (munch-anything x)))
-@end example
-
-The type specifier @code{t} matches any type of object; the word
-@code{otherwise} is also allowed.  To make one clause match any of
-several types, use an @code{(or ...)} type specifier.
-@end defspec
-
-@defspec etypecase keyform clause@dots{}
-This macro is just like @code{typecase}, except that if the key does
-not match any of the clauses, an error is signaled rather than
-simply returning @code{nil}.
-@end defspec
-
-@node Blocks and Exits
-@section Blocks and Exits
-
-@noindent
-Common Lisp @dfn{blocks} provide a non-local exit mechanism very
-similar to @code{catch} and @code{throw}, but lexically rather than
-dynamically scoped.  This package actually implements @code{block}
-in terms of @code{catch}; however, the lexical scoping allows the
-optimizing byte-compiler to omit the costly @code{catch} step if the
-body of the block does not actually @code{return-from} the block.
-
-@defspec block name forms@dots{}
-The @var{forms} are evaluated as if by a @code{progn}.  However,
-if any of the @var{forms} execute @code{(return-from @var{name})},
-they will jump out and return directly from the @code{block} form.
-The @code{block} returns the result of the last @var{form} unless
-a @code{return-from} occurs.
-
-The @code{block}/@code{return-from} mechanism is quite similar to
-the @code{catch}/@code{throw} mechanism.  The main differences are
-that block @var{name}s are unevaluated symbols, rather than forms
-(such as quoted symbols) which evaluate to a tag at run-time; and
-also that blocks are lexically scoped whereas @code{catch}/@code{throw}
-are dynamically scoped.  This means that functions called from the
-body of a @code{catch} can also @code{throw} to the @code{catch},
-but the @code{return-from} referring to a block name must appear
-physically within the @var{forms} that make up the body of the block.
-They may not appear within other called functions, although they may
-appear within macro expansions or @code{lambda}s in the body.  Block
-names and @code{catch} names form independent name-spaces.
-
-In true Common Lisp, @code{defun} and @code{defmacro} surround
-the function or expander bodies with implicit blocks with the
-same name as the function or macro.  This does not occur in Emacs
-Lisp, but this package provides @code{defun*} and @code{defmacro*}
-forms which do create the implicit block.
-
-The Common Lisp looping constructs defined by this package,
-such as @code{loop} and @code{dolist}, also create implicit blocks
-just as in Common Lisp.
-
-Because they are implemented in terms of Emacs Lisp @code{catch}
-and @code{throw}, blocks have the same overhead as actual
-@code{catch} constructs (roughly two function calls).  However,
-the optimizing byte compiler will optimize away the @code{catch}
-if the block does
-not in fact contain any @code{return} or @code{return-from} calls
-that jump to it.  This means that @code{do} loops and @code{defun*}
-functions which don't use @code{return} don't pay the overhead to
-support it.
-@end defspec
-
-@defspec return-from name [result]
-This macro returns from the block named @var{name}, which must be
-an (unevaluated) symbol.  If a @var{result} form is specified, it
-is evaluated to produce the result returned from the @code{block}.
-Otherwise, @code{nil} is returned.
-@end defspec
-
-@defspec return [result]
-This macro is exactly like @code{(return-from nil @var{result})}.
-Common Lisp loops like @code{do} and @code{dolist} implicitly enclose
-themselves in @code{nil} blocks.
-@end defspec
-
-@node Iteration
-@section Iteration
-
-@noindent
-The macros described here provide more sophisticated, high-level
-looping constructs to complement Emacs Lisp's basic @code{while}
-loop.
-
-@defspec loop forms@dots{}
-The @code{CL} package supports both the simple, old-style meaning of
-@code{loop} and the extremely powerful and flexible feature known as
-the @dfn{Loop Facility} or @dfn{Loop Macro}.  This more advanced
-facility is discussed in the following section; @pxref{Loop Facility}.
-The simple form of @code{loop} is described here.
-
-If @code{loop} is followed by zero or more Lisp expressions,
-then @code{(loop @var{exprs}@dots{})} simply creates an infinite
-loop executing the expressions over and over.  The loop is
-enclosed in an implicit @code{nil} block.  Thus,
-
-@example
-(loop (foo)  (if (no-more) (return 72))  (bar))
-@end example
-
-@noindent
-is exactly equivalent to
-
-@example
-(block nil (while t (foo)  (if (no-more) (return 72))  (bar)))
-@end example
-
-If any of the expressions are plain symbols, the loop is instead
-interpreted as a Loop Macro specification as described later.
-(This is not a restriction in practice, since a plain symbol
-in the above notation would simply access and throw away the
-value of a variable.)
-@end defspec
-
-@defspec do (spec@dots{}) (end-test [result@dots{}]) forms@dots{}
-This macro creates a general iterative loop.  Each @var{spec} is
-of the form
-
-@example
-(@var{var} [@var{init} [@var{step}]])
-@end example
-
-The loop works as follows:  First, each @var{var} is bound to the
-associated @var{init} value as if by a @code{let} form.  Then, in
-each iteration of the loop, the @var{end-test} is evaluated; if
-true, the loop is finished.  Otherwise, the body @var{forms} are
-evaluated, then each @var{var} is set to the associated @var{step}
-expression (as if by a @code{cl-psetq} form) and the next iteration
-begins.  Once the @var{end-test} becomes true, the @var{result}
-forms are evaluated (with the @var{var}s still bound to their
-values) to produce the result returned by @code{do}.
-
-The entire @code{do} loop is enclosed in an implicit @code{nil}
-block, so that you can use @code{(return)} to break out of the
-loop at any time.
-
-If there are no @var{result} forms, the loop returns @code{nil}.
-If a given @var{var} has no @var{step} form, it is bound to its
-@var{init} value but not otherwise modified during the @code{do}
-loop (unless the code explicitly modifies it); this case is just
-a shorthand for putting a @code{(let ((@var{var} @var{init})) @dots{})}
-around the loop.  If @var{init} is also omitted it defaults to
-@code{nil}, and in this case a plain @samp{@var{var}} can be used
-in place of @samp{(@var{var})}, again following the analogy with
-@code{let}.
-
-This example (from Steele) illustrates a loop which applies the
-function @code{f} to successive pairs of values from the lists
-@code{foo} and @code{bar}; it is equivalent to the call
-@code{(mapcar* 'f foo bar)}.  Note that this loop has no body
-@var{forms} at all, performing all its work as side effects of
-the rest of the loop.
-
-@example
-(do ((x foo (cdr x))
-     (y bar (cdr y))
-     (z nil (cons (f (car x) (car y)) z)))
-  ((or (null x) (null y))
-   (nreverse z)))
-@end example
-@end defspec
-
-@defspec do* (spec@dots{}) (end-test [result@dots{}]) forms@dots{}
-This is to @code{do} what @code{let*} is to @code{let}.  In
-particular, the initial values are bound as if by @code{let*}
-rather than @code{let}, and the steps are assigned as if by
-@code{setq} rather than @code{cl-psetq}.
-
-Here is another way to write the above loop:
-
-@example
-(do* ((xp foo (cdr xp))
-      (yp bar (cdr yp))
-      (x (car xp) (car xp))
-      (y (car yp) (car yp))
-      z)
-  ((or (null xp) (null yp))
-   (nreverse z))
-  (push (f x y) z))
-@end example
-@end defspec
-
-@defspec dolist (var list [result]) forms@dots{}
-This is a more specialized loop which iterates across the elements
-of a list.  @var{list} should evaluate to a list; the body @var{forms}
-are executed with @var{var} bound to each element of the list in
-turn.  Finally, the @var{result} form (or @code{nil}) is evaluated
-with @var{var} bound to @code{nil} to produce the result returned by
-the loop.  Unlike with Emacs's built in @code{dolist}, the loop is
-surrounded by an implicit @code{nil} block.
-@end defspec
-
-@defspec dotimes (var count [result]) forms@dots{}
-This is a more specialized loop which iterates a specified number
-of times.  The body is executed with @var{var} bound to the integers
-from zero (inclusive) to @var{count} (exclusive), in turn.  Then
-the @code{result} form is evaluated with @var{var} bound to the total
-number of iterations that were done (i.e., @code{(max 0 @var{count})})
-to get the return value for the loop form.  Unlike with Emacs's built in
-@code{dolist}, the loop is surrounded by an implicit @code{nil} block.
-@end defspec
-
-@defspec do-symbols (var [obarray [result]]) forms@dots{}
-This loop iterates over all interned symbols.  If @var{obarray}
-is specified and is not @code{nil}, it loops over all symbols in
-that obarray.  For each symbol, the body @var{forms} are evaluated
-with @var{var} bound to that symbol.  The symbols are visited in
-an unspecified order.  Afterward the @var{result} form, if any,
-is evaluated (with @var{var} bound to @code{nil}) to get the return
-value.  The loop is surrounded by an implicit @code{nil} block.
-@end defspec
-
-@defspec do-all-symbols (var [result]) forms@dots{}
-This is identical to @code{do-symbols} except that the @var{obarray}
-argument is omitted; it always iterates over the default obarray.
-@end defspec
-
-@xref{Mapping over Sequences}, for some more functions for
-iterating over vectors or lists.
-
-@node Loop Facility
-@section Loop Facility
-
-@noindent
-A common complaint with Lisp's traditional looping constructs is
-that they are either too simple and limited, such as Common Lisp's
-@code{dotimes} or Emacs Lisp's @code{while}, or too unreadable and
-obscure, like Common Lisp's @code{do} loop.
-
-To remedy this, recent versions of Common Lisp have added a new
-construct called the ``Loop Facility'' or ``@code{loop} macro,''
-with an easy-to-use but very powerful and expressive syntax.
-
-@menu
-* Loop Basics::           @code{loop} macro, basic clause structure.
-* Loop Examples::         Working examples of @code{loop} macro.
-* For Clauses::           Clauses introduced by @code{for} or @code{as}.
-* Iteration Clauses::     @code{repeat}, @code{while}, @code{thereis}, etc.
-* Accumulation Clauses::  @code{collect}, @code{sum}, @code{maximize}, etc.
-* Other Clauses::         @code{with}, @code{if}, @code{initially}, @code{finally}.
-@end menu
-
-@node Loop Basics
-@subsection Loop Basics
-
-@noindent
-The @code{loop} macro essentially creates a mini-language within
-Lisp that is specially tailored for describing loops.  While this
-language is a little strange-looking by the standards of regular Lisp,
-it turns out to be very easy to learn and well-suited to its purpose.
-
-Since @code{loop} is a macro, all parsing of the loop language
-takes place at byte-compile time; compiled @code{loop}s are just
-as efficient as the equivalent @code{while} loops written longhand.
-
-@defspec loop clauses@dots{}
-A loop construct consists of a series of @var{clause}s, each
-introduced by a symbol like @code{for} or @code{do}.  Clauses
-are simply strung together in the argument list of @code{loop},
-with minimal extra parentheses.  The various types of clauses
-specify initializations, such as the binding of temporary
-variables, actions to be taken in the loop, stepping actions,
-and final cleanup.
-
-Common Lisp specifies a certain general order of clauses in a
-loop:
-
-@example
-(loop @var{name-clause}
-      @var{var-clauses}@dots{}
-      @var{action-clauses}@dots{})
+(loop @var{name-clause}
+      @var{var-clauses}@dots{}
+      @var{action-clauses}@dots{})
 @end example
 
 The @var{name-clause} optionally gives a name to the implicit
@@ -2155,7 +1764,7 @@ be modified or iterated throughout the course of the loop.  The
 @var{action-clauses} are things to be done during the loop, such
 as computing, collecting, and returning values.
 
-The Emacs version of the @code{loop} macro is less restrictive about
+The Emacs version of the @code{cl-loop} macro is less restrictive about
 the order of clauses, but things will behave most predictably if
 you put the variable-binding clauses @code{with}, @code{for}, and
 @code{repeat} before the action clauses.  As in Common Lisp,
@@ -2166,39 +1775,39 @@ them to return a value by using an accumulation clause like
 @code{collect}, an end-test clause like @code{always}, or an
 explicit @code{return} clause to jump out of the implicit block.
 (Because the loop body is enclosed in an implicit block, you can
-also use regular Lisp @code{return} or @code{return-from} to
+also use regular Lisp @code{cl-return} or @code{cl-return-from} to
 break out of the loop.)
-@end defspec
+@end defmac
 
-The following sections give some examples of the Loop Macro in
+The following sections give some examples of the loop macro in
 action, and describe the particular loop clauses in great detail.
-Consult the second edition of Steele's @dfn{Common Lisp, the Language},
-for additional discussion and examples of the @code{loop} macro.
+Consult the second edition of Steele for additional discussion
+and examples.
 
 @node Loop Examples
 @subsection Loop Examples
 
 @noindent
 Before listing the full set of clauses that are allowed, let's
-look at a few example loops just to get a feel for the @code{loop}
+look at a few example loops just to get a feel for the @code{cl-loop}
 language.
 
 @example
-(loop for buf in (buffer-list)
-      collect (buffer-file-name buf))
+(cl-loop for buf in (buffer-list)
+         collect (buffer-file-name buf))
 @end example
 
 @noindent
 This loop iterates over all Emacs buffers, using the list
-returned by @code{buffer-list}.  For each buffer @code{buf},
+returned by @code{buffer-list}.  For each buffer @var{buf},
 it calls @code{buffer-file-name} and collects the results into
-a list, which is then returned from the @code{loop} construct.
+a list, which is then returned from the @code{cl-loop} construct.
 The result is a list of the file names of all the buffers in
 Emacs's memory.  The words @code{for}, @code{in}, and @code{collect}
-are reserved words in the @code{loop} language.
+are reserved words in the @code{cl-loop} language.
 
 @example
-(loop repeat 20 do (insert "Yowsa\n"))
+(cl-loop repeat 20 do (insert "Yowsa\n"))
 @end example
 
 @noindent
@@ -2206,7 +1815,7 @@ This loop inserts the phrase ``Yowsa'' twenty times in the
 current buffer.
 
 @example
-(loop until (eobp) do (munch-line) (forward-line 1))
+(cl-loop until (eobp) do (munch-line) (forward-line 1))
 @end example
 
 @noindent
@@ -2215,7 +1824,7 @@ of the buffer.  If point is already at the end of the buffer,
 the loop exits immediately.
 
 @example
-(loop do (munch-line) until (eobp) do (forward-line 1))
+(cl-loop do (munch-line) until (eobp) do (forward-line 1))
 @end example
 
 @noindent
@@ -2223,10 +1832,10 @@ This loop is similar to the above one, except that @code{munch-line}
 is always called at least once.
 
 @example
-(loop for x from 1 to 100
-      for y = (* x x)
-      until (>= y 729)
-      finally return (list x (= y 729)))
+(cl-loop for x from 1 to 100
+         for y = (* x x)
+         until (>= y 729)
+         finally return (list x (= y 729)))
 @end example
 
 @noindent
@@ -2246,7 +1855,7 @@ Note that even though this loop contains three clauses (two
 @code{for}s and an @code{until}) that would have been enough to
 define loops all by themselves, it still creates a single loop
 rather than some sort of triple-nested loop.  You must explicitly
-nest your @code{loop} constructs if you want nested loops.
+nest your @code{cl-loop} constructs if you want nested loops.
 
 @node For Clauses
 @subsection For Clauses
@@ -2272,7 +1881,7 @@ The variable is bound around the loop as if by @code{let}:
 
 @example
 (setq i 'happy)
-(loop for i from 1 to 10 do (do-something-with i))
+(cl-loop for i from 1 to 10 do (do-something-with i))
 i
      @result{} happy
 @end example
@@ -2302,10 +1911,10 @@ which are like @code{upto} and @code{downto} respectively except
 that they are exclusive rather than inclusive limits:
 
 @example
-(loop for x to 10 collect x)
-     @result{} (0 1 2 3 4 5 6 7 8 9 10)
-(loop for x below 10 collect x)
-     @result{} (0 1 2 3 4 5 6 7 8 9)
+(cl-loop for x to 10 collect x)
+        @result{} (0 1 2 3 4 5 6 7 8 9 10)
+(cl-loop for x below 10 collect x)
+        @result{} (0 1 2 3 4 5 6 7 8 9)
 @end example
 
 The @code{by} value is always positive, even for downward-counting
@@ -2320,25 +1929,25 @@ is used to traverse the list instead of @code{cdr}; it must be a
 function taking one argument.  For example:
 
 @example
-(loop for x in '(1 2 3 4 5 6) collect (* x x))
-     @result{} (1 4 9 16 25 36)
-(loop for x in '(1 2 3 4 5 6) by 'cddr collect (* x x))
-     @result{} (1 9 25)
+(cl-loop for x in '(1 2 3 4 5 6) collect (* x x))
+        @result{} (1 4 9 16 25 36)
+(cl-loop for x in '(1 2 3 4 5 6) by 'cddr collect (* x x))
+        @result{} (1 9 25)
 @end example
 
 @item for @var{var} on @var{list} by @var{function}
 This clause iterates @var{var} over all the cons cells of @var{list}.
 
 @example
-(loop for x on '(1 2 3 4) collect x)
-     @result{} ((1 2 3 4) (2 3 4) (3 4) (4))
+(cl-loop for x on '(1 2 3 4) collect x)
+        @result{} ((1 2 3 4) (2 3 4) (3 4) (4))
 @end example
 
 With @code{by}, there is no real reason that the @code{on} expression
 must be a list.  For example:
 
 @example
-(loop for x on first-animal by 'next-animal collect x)
+(cl-loop for x on first-animal by 'next-animal collect x)
 @end example
 
 @noindent
@@ -2352,7 +1961,7 @@ a @code{setf}-able ``reference'' onto the elements of the list
 rather than just a temporary variable.  For example,
 
 @example
-(loop for x in-ref my-list do (incf x))
+(cl-loop for x in-ref my-list do (cl-incf x))
 @end example
 
 @noindent
@@ -2364,8 +1973,8 @@ This clause iterates @var{var} over all the elements of @var{array},
 which may be a vector or a string.
 
 @example
-(loop for x across "aeiou"
-      do (use-vowel (char-to-string x)))
+(cl-loop for x across "aeiou"
+         do (use-vowel (char-to-string x)))
 @end example
 
 @item for @var{var} across-ref @var{array}
@@ -2381,7 +1990,7 @@ at run-time, this is somewhat less efficient than @code{in} or
 the successive indices (starting at 0) of the elements.
 
 This clause type is taken from older versions of the @code{loop} macro,
-and is not present in modern Common Lisp.  The @samp{using (sequence ...)}
+and is not present in modern Common Lisp.  The @samp{using (sequence @dots{})}
 term of the older macros is not supported.
 
 @item for @var{var} being the elements of-ref @var{sequence}
@@ -2397,10 +2006,10 @@ an unspecified order.
 As an example,
 
 @example
-(loop for sym being the symbols
-      when (fboundp sym)
-      when (string-match "^map" (symbol-name sym))
-      collect sym)
+(cl-loop for sym being the symbols
+         when (fboundp sym)
+         when (string-match "^map" (symbol-name sym))
+         collect sym)
 @end example
 
 @noindent
@@ -2411,9 +2020,9 @@ are also recognized but are equivalent to @code{symbols} in Emacs Lisp.
 
 Due to a minor implementation restriction, it will not work to have
 more than one @code{for} clause iterating over symbols, hash tables,
-keymaps, overlays, or intervals in a given @code{loop}.  Fortunately,
+keymaps, overlays, or intervals in a given @code{cl-loop}.  Fortunately,
 it would rarely if ever be useful to do so.  It @emph{is} valid to mix
-one of these types of clauses with other clauses like @code{for ... to}
+one of these types of clauses with other clauses like @code{for @dots{} to}
 or @code{while}.
 
 @item for @var{var} being the hash-keys of @var{hash-table}
@@ -2423,10 +2032,10 @@ This clause iterates over the entries in @var{hash-table} with
 a second variable to the opposite part.
 
 @example
-(loop for k being the hash-keys of h
-            using (hash-values v)
-      do
-      (message "key %S -> value %S" k v))
+(cl-loop for k being the hash-keys of h
+               using (hash-values v)
+         do
+         (message "key %S -> value %S" k v))
 @end example
 
 @item for @var{var} being the key-codes of @var{keymap}
@@ -2438,10 +2047,10 @@ A @code{using} clause can access both the codes and the bindings
 together.
 
 @example
-(loop for c being the key-codes of (current-local-map)
-            using (key-bindings b)
-      do
-      (message "key %S -> binding %S" c b))
+(cl-loop for c being the key-codes of (current-local-map)
+               using (key-bindings b)
+         do
+         (message "key %S -> binding %S" c b))
 @end example
 
 
@@ -2450,7 +2059,7 @@ This clause iterates over all key sequences defined by @var{keymap}
 and its nested keymaps, where @var{var} takes on values which are
 vectors.  The strings or vectors
 are reused for each iteration, so you must copy them if you wish to keep
-them permanently.  You can add a @samp{using (key-bindings ...)}
+them permanently.  You can add a @samp{using (key-bindings @dots{})}
 clause to get the command bindings as well.
 
 @item for @var{var} being the overlays [of @var{buffer}] @dots{}
@@ -2497,8 +2106,8 @@ and successive iterations it will be set by evaluating @var{expr2}
 these two loops are effectively the same:
 
 @example
-(loop for x on my-list by 'cddr do ...)
-(loop for x = my-list then (cddr x) while x do ...)
+(cl-loop for x on my-list by 'cddr do @dots{})
+(cl-loop for x = my-list then (cddr x) while x do @dots{})
 @end example
 
 Note that this type of @code{for} clause does not imply any sort
@@ -2509,7 +2118,7 @@ If you omit the @code{then} term, @var{expr1} is used both for
 the initial setting and for successive settings:
 
 @example
-(loop for x = (random) when (> x 0) return x)
+(cl-loop for x = (random) when (> x 0) return x)
 @end example
 
 @noindent
@@ -2524,10 +2133,10 @@ in which case they are processed in parallel (as if by @code{let}
 and @code{cl-psetq}).
 
 @example
-(loop for x below 5 for y = nil then x collect (list x y))
-     @result{} ((0 nil) (1 1) (2 2) (3 3) (4 4))
-(loop for x below 5 and y = nil then x collect (list x y))
-     @result{} ((0 nil) (1 0) (2 1) (3 2) (4 3))
+(cl-loop for x below 5 for y = nil then x collect (list x y))
+        @result{} ((0 nil) (1 1) (2 2) (3 3) (4 4))
+(cl-loop for x below 5 and y = nil then x collect (list x y))
+        @result{} ((0 nil) (1 0) (2 1) (3 2) (4 3))
 @end example
 
 @noindent
@@ -2537,16 +2146,17 @@ that was just set by the previous clause; in the second loop,
 based on the value of @code{x} left over from the previous time
 through the loop.
 
-Another feature of the @code{loop} macro is @dfn{destructuring},
-similar in concept to the destructuring provided by @code{defmacro}.
+Another feature of the @code{cl-loop} macro is @emph{destructuring},
+similar in concept to the destructuring provided by @code{defmacro}
+(@pxref{Argument Lists}).
 The @var{var} part of any @code{for} clause can be given as a list
 of variables instead of a single variable.  The values produced
 during loop execution must be lists; the values in the lists are
 stored in the corresponding variables.
 
 @example
-(loop for (x y) in '((2 3) (4 5) (6 7)) collect (+ x y))
-     @result{} (5 9 13)
+(cl-loop for (x y) in '((2 3) (4 5) (6 7)) collect (+ x y))
+        @result{} (5 9 13)
 @end example
 
 In loop destructuring, if there are more values than variables
@@ -2558,9 +2168,9 @@ lists of variables like @code{(x . y)} are allowed, so for example
 to process an alist
 
 @example
-(loop for (key . value) in '((a . 1) (b . 2))
-      collect value)
-     @result{} (1 2)
+(cl-loop for (key . value) in '((a . 1) (b . 2))
+         collect value)
+        @result{} (1 2)
 @end example
 
 @node Iteration Clauses
@@ -2577,8 +2187,8 @@ This clause simply counts up to the specified number using an
 internal temporary variable.  The loops
 
 @example
-(loop repeat (1+ n) do ...)
-(loop for temp to n do ...)
+(cl-loop repeat (1+ n) do @dots{})
+(cl-loop for temp to n do @dots{})
 @end example
 
 @noindent
@@ -2593,7 +2203,7 @@ that surrounds the second one:
 
 @example
 (while @var{cond} @var{forms}@dots{})
-(loop while @var{cond} do @var{forms}@dots{})
+(cl-loop while @var{cond} do @var{forms}@dots{})
 @end example
 
 @item until @var{condition}
@@ -2607,7 +2217,7 @@ the @code{finally} clauses are not executed.  If all the conditions
 were non-@code{nil}, the loop returns @code{t}:
 
 @example
-(if (loop for size in size-list always (> size 10))
+(if (cl-loop for size in size-list always (> size 10))
     (some-big-sizes)
   (no-big-sizes))
 @end example
@@ -2684,11 +2294,11 @@ It is valid for several accumulation clauses of the same type to
 accumulate into the same place.  From Steele:
 
 @example
-(loop for name in '(fred sue alice joe june)
-      for kids in '((bob ken) () () (kris sunshine) ())
-      collect name
-      append kids)
-     @result{} (fred bob ken sue alice joe kris sunshine june)
+(cl-loop for name in '(fred sue alice joe june)
+         for kids in '((bob ken) () () (kris sunshine) ())
+         collect name
+         append kids)
+        @result{} (fred bob ken sue alice joe kris sunshine june)
 @end example
 
 @node Other Clauses
@@ -2704,17 +2314,17 @@ otherwise leaves the variable alone during the loop.  The following
 loops are basically equivalent:
 
 @example
-(loop with x = 17 do ...)
-(let ((x 17)) (loop do ...))
-(loop for x = 17 then x do ...)
+(cl-loop with x = 17 do @dots{})
+(let ((x 17)) (cl-loop do @dots{}))
+(cl-loop for x = 17 then x do @dots{})
 @end example
 
 Naturally, the variable @var{var} might be used for some purpose
 in the rest of the loop.  For example:
 
 @example
-(loop for x in my-list  with res = nil  do (push x res)
-      finally return res)
+(cl-loop for x in my-list  with res = nil  do (push x res)
+         finally return res)
 @end example
 
 This loop inserts the elements of @code{my-list} at the front of
@@ -2749,18 +2359,18 @@ by the name @code{it} in the ``then'' part.  For example:
 @example
 (setq funny-numbers '(6 13 -1))
      @result{} (6 13 -1)
-(loop for x below 10
-      if (oddp x)
-        collect x into odds
-        and if (memq x funny-numbers) return (cdr it) end
-      else
-        collect x into evens
-      finally return (vector odds evens))
-     @result{} [(1 3 5 7 9) (0 2 4 6 8)]
+(cl-loop for x below 10
+         if (cl-oddp x)
+           collect x into odds
+           and if (memq x funny-numbers) return (cdr it) end
+         else
+           collect x into evens
+         finally return (vector odds evens))
+        @result{} [(1 3 5 7 9) (0 2 4 6 8)]
 (setq funny-numbers '(6 7 13 -1))
      @result{} (6 7 13 -1)
-(loop <@r{same thing again}>)
-     @result{} (13 -1)
+(cl-loop <@r{same thing again}>)
+        @result{} (13 -1)
 @end example
 
 Note the use of @code{and} to put two clauses into the ``then''
@@ -2785,7 +2395,7 @@ This clause gives a name other than @code{nil} to the implicit
 block surrounding the loop.  The @var{name} is the symbol to be
 used as the block name.
 
-@item initially [do] @var{forms}...
+@item initially [do] @var{forms}@dots{}
 This keyword introduces one or more Lisp forms which will be
 executed before the loop itself begins (but after any variables
 requested by @code{for} or @code{with} have been bound to their
@@ -2793,7 +2403,7 @@ initial values).  @code{initially} clauses can appear anywhere;
 if there are several, they are executed in the order they appear
 in the loop.  The keyword @code{do} is optional.
 
-@item finally [do] @var{forms}...
+@item finally [do] @var{forms}@dots{}
 This introduces Lisp forms which will be executed after the loop
 finishes (say, on request of a @code{for} or @code{while}).
 @code{initially} and @code{finally} clauses may appear anywhere
@@ -2808,7 +2418,7 @@ return @code{nil}.)  Variables bound by @code{for}, @code{with},
 or @code{into} will still contain their final values when @var{form}
 is executed.
 
-@item do @var{forms}...
+@item do @var{forms}@dots{}
 The word @code{do} may be followed by any number of Lisp expressions
 which are executed as an implicit @code{progn} in the body of the
 loop.  Many of the examples in this section illustrate the use of
@@ -2816,29 +2426,28 @@ loop.  Many of the examples in this section illustrate the use of
 
 @item return @var{form}
 This clause causes the loop to return immediately.  The following
-Lisp form is evaluated to give the return value of the @code{loop}
+Lisp form is evaluated to give the return value of the loop
 form.  The @code{finally} clauses, if any, are not executed.
 Of course, @code{return} is generally used inside an @code{if} or
 @code{unless}, as its use in a top-level loop clause would mean
 the loop would never get to ``loop'' more than once.
 
 The clause @samp{return @var{form}} is equivalent to
-@samp{do (return @var{form})} (or @code{return-from} if the loop
+@samp{do (cl-return @var{form})} (or @code{cl-return-from} if the loop
 was named).  The @code{return} clause is implemented a bit more
 efficiently, though.
 @end table
 
-While there is no high-level way to add user extensions to @code{loop}
-(comparable to @code{defsetf} for @code{setf}, say), this package
-does offer two properties called @code{cl-loop-handler} and
-@code{cl-loop-for-handler} which are functions to be called when
-a given symbol is encountered as a top-level loop clause or
-@code{for} clause, respectively.  Consult the source code in
-file @file{cl-macs.el} for details.
+While there is no high-level way to add user extensions to @code{cl-loop},
+this package does offer two properties called @code{cl-loop-handler}
+and @code{cl-loop-for-handler} which are functions to be called when a
+given symbol is encountered as a top-level loop clause or @code{for}
+clause, respectively.  Consult the source code in file
+@file{cl-macs.el} for details.
 
-This package's @code{loop} macro is compatible with that of Common
+This package's @code{cl-loop} macro is compatible with that of Common
 Lisp, except that a few features are not implemented:  @code{loop-finish}
-and data-type specifiers.  Naturally, the @code{for} clauses which
+and data-type specifiers.  Naturally, the @code{for} clauses that
 iterate over keymaps, overlays, intervals, frames, windows, and
 buffers are Emacs-specific extensions.
 
@@ -2851,35 +2460,28 @@ functions, by contrast, always return exactly one result.  This
 package makes no attempt to emulate Common Lisp multiple return
 values; Emacs versions of Common Lisp functions that return more
 than one value either return just the first value (as in
-@code{compiler-macroexpand}) or return a list of values (as in
-@code{get-setf-method}).  This package @emph{does} define placeholders
+@code{cl-compiler-macroexpand}) or return a list of values.
+This package @emph{does} define placeholders
 for the Common Lisp functions that work with multiple values, but
 in Emacs Lisp these functions simply operate on lists instead.
-The @code{values} form, for example, is a synonym for @code{list}
+The @code{cl-values} form, for example, is a synonym for @code{list}
 in Emacs.
 
-@defspec multiple-value-bind (var@dots{}) values-form forms@dots{}
+@defmac cl-multiple-value-bind (var@dots{}) values-form forms@dots{}
 This form evaluates @var{values-form}, which must return a list of
 values.  It then binds the @var{var}s to these respective values,
 as if by @code{let}, and then executes the body @var{forms}.
 If there are more @var{var}s than values, the extra @var{var}s
 are bound to @code{nil}.  If there are fewer @var{var}s than
 values, the excess values are ignored.
-@end defspec
+@end defmac
 
-@defspec multiple-value-setq (var@dots{}) form
+@defmac cl-multiple-value-setq (var@dots{}) form
 This form evaluates @var{form}, which must return a list of values.
 It then sets the @var{var}s to these respective values, as if by
 @code{setq}.  Extra @var{var}s or values are treated the same as
-in @code{multiple-value-bind}.
-@end defspec
-
-The older Quiroz package attempted a more faithful (but still
-imperfect) emulation of Common Lisp multiple values.  The old
-method ``usually'' simulated true multiple values quite well,
-but under certain circumstances would leave spurious return
-values in memory where a later, unrelated @code{multiple-value-bind}
-form would see them.
+in @code{cl-multiple-value-bind}.
+@end defmac
 
 Since a perfect emulation is not feasible in Emacs Lisp, this
 package opts to keep it as simple and predictable as possible.
@@ -2897,22 +2499,22 @@ for @code{defmacro} due to technical difficulties.
 Destructuring is made available to the user by way of the
 following macro:
 
-@defspec destructuring-bind arglist expr forms@dots{}
-This macro expands to code which executes @var{forms}, with
+@defmac cl-destructuring-bind arglist expr forms@dots{}
+This macro expands to code that executes @var{forms}, with
 the variables in @var{arglist} bound to the list of values
 returned by @var{expr}.  The @var{arglist} can include all
-the features allowed for @code{defmacro} argument lists,
+the features allowed for @code{cl-defmacro} argument lists,
 including destructuring.  (The @code{&environment} keyword
 is not allowed.)  The macro expansion will signal an error
 if @var{expr} returns a list of the wrong number of arguments
 or with incorrect keyword arguments.
-@end defspec
+@end defmac
 
 This package also includes the Common Lisp @code{define-compiler-macro}
 facility, which allows you to define compile-time expansions and
 optimizations for your functions.
 
-@defspec define-compiler-macro name arglist forms@dots{}
+@defmac cl-define-compiler-macro name arglist forms@dots{}
 This form is similar to @code{defmacro}, except that it only expands
 calls to @var{name} at compile-time; calls processed by the Lisp
 interpreter are not expanded, nor are they expanded by the
@@ -2930,25 +2532,25 @@ For example, here is a simplified version of a definition that
 appears as a standard part of this package:
 
 @example
-(define-compiler-macro member* (&whole form a list &rest keys)
-  (if (and (null keys)
-           (eq (car-safe a) 'quote)
-           (not (floatp-safe (cadr a))))
-      (list 'memq a list)
-    form))
+(cl-define-compiler-macro cl-member (&whole form a list &rest keys)
+     (if (and (null keys)
+              (eq (car-safe a) 'quote)
+              (not (floatp (cadr a))))
+         (list 'memq a list)
+       form))
 @end example
 
 @noindent
-This definition causes @code{(member* @var{a} @var{list})} to change
+This definition causes @code{(cl-member @var{a} @var{list})} to change
 to a call to the faster @code{memq} in the common case where @var{a}
 is a non-floating-point constant; if @var{a} is anything else, or
 if there are any keyword arguments in the call, then the original
-@code{member*} call is left intact.  (The actual compiler macro
-for @code{member*} optimizes a number of other cases, including
+@code{cl-member} call is left intact.  (The actual compiler macro
+for @code{cl-member} optimizes a number of other cases, including
 common @code{:test} predicates.)
-@end defspec
+@end defmac
 
-@defun compiler-macroexpand form
+@defun cl-compiler-macroexpand form
 This function is analogous to @code{macroexpand}, except that it
 expands compiler macros rather than regular macros.  It returns
 @var{form} unchanged if it is not a call to a function for which
@@ -2958,8 +2560,8 @@ decided to punt by returning its @code{&whole} argument.  Like
 for which no further expansion is possible.
 @end defun
 
-@xref{Macro Bindings}, for descriptions of the @code{macrolet}
-and @code{symbol-macrolet} forms for making ``local'' macro
+@xref{Macro Bindings}, for descriptions of the @code{cl-macrolet}
+and @code{cl-symbol-macrolet} forms for making ``local'' macro
 definitions.
 
 @node Declarations
@@ -2974,61 +2576,64 @@ package defines versions of all the Common Lisp declaration forms:
 @code{declare}, @code{locally}, @code{proclaim}, @code{declaim},
 and @code{the}.
 
-Most of the Common Lisp declarations are not currently useful in
-Emacs Lisp, as the byte-code system provides little opportunity
-to benefit from type information, and @code{special} declarations
-are redundant in a fully dynamically-scoped Lisp.  A few
-declarations are meaningful when the optimizing byte
-compiler is being used, however.  Under the earlier non-optimizing
-compiler, these declarations will effectively be ignored.
-
-@defun proclaim decl-spec
+Most of the Common Lisp declarations are not currently useful in Emacs
+Lisp.  For example, the byte-code system provides little
+opportunity to benefit from type information.
+@ignore
+and @code{special} declarations are redundant in a fully
+dynamically-scoped Lisp.
+@end ignore
+A few declarations are meaningful when byte compiler optimizations
+are enabled, as they are by the default.  Otherwise these
+declarations will effectively be ignored.
+
+@defun cl-proclaim decl-spec
 This function records a ``global'' declaration specified by
-@var{decl-spec}.  Since @code{proclaim} is a function, @var{decl-spec}
+@var{decl-spec}.  Since @code{cl-proclaim} is a function, @var{decl-spec}
 is evaluated and thus should normally be quoted.
 @end defun
 
-@defspec declaim decl-specs@dots{}
-This macro is like @code{proclaim}, except that it takes any number
+@defmac cl-declaim decl-specs@dots{}
+This macro is like @code{cl-proclaim}, except that it takes any number
 of @var{decl-spec} arguments, and the arguments are unevaluated and
-unquoted.  The @code{declaim} macro also puts an @code{(eval-when
-(compile load eval) ...)} around the declarations so that they will
+unquoted.  The @code{cl-declaim} macro also puts @code{(cl-eval-when
+(compile load eval) @dots{})} around the declarations so that they will
 be registered at compile-time as well as at run-time.  (This is vital,
 since normally the declarations are meant to influence the way the
-compiler treats the rest of the file that contains the @code{declaim}
+compiler treats the rest of the file that contains the @code{cl-declaim}
 form.)
-@end defspec
+@end defmac
 
-@defspec declare decl-specs@dots{}
+@defmac cl-declare decl-specs@dots{}
 This macro is used to make declarations within functions and other
 code.  Common Lisp allows declarations in various locations, generally
 at the beginning of any of the many ``implicit @code{progn}s''
 throughout Lisp syntax, such as function bodies, @code{let} bodies,
-etc.  Currently the only declaration understood by @code{declare}
+etc.  Currently the only declaration understood by @code{cl-declare}
 is @code{special}.
-@end defspec
+@end defmac
 
-@defspec locally declarations@dots{} forms@dots{}
-In this package, @code{locally} is no different from @code{progn}.
-@end defspec
+@defmac cl-locally declarations@dots{} forms@dots{}
+In this package, @code{cl-locally} is no different from @code{progn}.
+@end defmac
 
-@defspec the type form
-Type information provided by @code{the} is ignored in this package;
-in other words, @code{(the @var{type} @var{form})} is equivalent
-to @var{form}.  Future versions of the optimizing byte-compiler may
-make use of this information.
+@defmac cl-the type form
+Type information provided by @code{cl-the} is ignored in this package;
+in other words, @code{(cl-the @var{type} @var{form})} is equivalent to
+@var{form}.  Future byte-compiler optimizations may make use of this
+information.
 
 For example, @code{mapcar} can map over both lists and arrays.  It is
 hard for the compiler to expand @code{mapcar} into an in-line loop
 unless it knows whether the sequence will be a list or an array ahead
-of time.  With @code{(mapcar 'car (the vector foo))}, a future
+of time.  With @code{(mapcar 'car (cl-the vector foo))}, a future
 compiler would have enough information to expand the loop in-line.
 For now, Emacs Lisp will treat the above code as exactly equivalent
 to @code{(mapcar 'car foo)}.
-@end defspec
+@end defmac
 
-Each @var{decl-spec} in a @code{proclaim}, @code{declaim}, or
-@code{declare} should be a list beginning with a symbol that says
+Each @var{decl-spec} in a @code{cl-proclaim}, @code{cl-declaim}, or
+@code{cl-declare} should be a list beginning with a symbol that says
 what kind of declaration it is.  This package currently understands
 @code{special}, @code{inline}, @code{notinline}, @code{optimize},
 and @code{warn} declarations.  (The @code{warn} declaration is an
@@ -3037,44 +2642,41 @@ such as @code{type} and @code{ftype}, are silently ignored.
 
 @table @code
 @item special
+@c FIXME ?
 Since all variables in Emacs Lisp are ``special'' (in the Common
 Lisp sense), @code{special} declarations are only advisory.  They
-simply tell the optimizing byte compiler that the specified
+simply tell the byte compiler that the specified
 variables are intentionally being referred to without being
 bound in the body of the function.  The compiler normally emits
 warnings for such references, since they could be typographical
 errors for references to local variables.
 
-The declaration @code{(declare (special @var{var1} @var{var2}))} is
-equivalent to @code{(defvar @var{var1}) (defvar @var{var2})} in the
-optimizing compiler, or to nothing at all in older compilers (which
-do not warn for non-local references).
+The declaration @code{(cl-declare (special @var{var1} @var{var2}))} is
+equivalent to @code{(defvar @var{var1}) (defvar @var{var2})}.
 
 In top-level contexts, it is generally better to write
-@code{(defvar @var{var})} than @code{(declaim (special @var{var}))},
-since @code{defvar} makes your intentions clearer.  But the older
-byte compilers can not handle @code{defvar}s appearing inside of
-functions, while @code{(declare (special @var{var}))} takes care
-to work correctly with all compilers.
+@code{(defvar @var{var})} than @code{(cl-declaim (special @var{var}))},
+since @code{defvar} makes your intentions clearer.
 
 @item inline
 The @code{inline} @var{decl-spec} lists one or more functions
 whose bodies should be expanded ``in-line'' into calling functions
 whenever the compiler is able to arrange for it.  For example,
-the Common Lisp function @code{cadr} is declared @code{inline}
-by this package so that the form @code{(cadr @var{x})} will
-expand directly into @code{(car (cdr @var{x}))} when it is called
-in user functions, for a savings of one (relatively expensive)
-function call.
+the function @code{cl-acons} is declared @code{inline}
+by this package so that the form @code{(cl-acons @var{key} @var{value}
+@var{alist})} will
+expand directly into @code{(cons (cons @var{key} @var{value}) @var{alist})}
+when it is called in user functions, so as to save function calls.
 
 The following declarations are all equivalent.  Note that the
 @code{defsubst} form is a convenient way to define a function
 and declare it inline all at once.
 
 @example
-(declaim (inline foo bar))
-(eval-when (compile load eval) (proclaim '(inline foo bar)))
-(defsubst foo (...) ...)       ; instead of defun
+(cl-declaim (inline foo bar))
+(cl-eval-when (compile load eval)
+  (cl-proclaim '(inline foo bar)))
+(defsubst foo (@dots{}) @dots{})       ; instead of defun
 @end example
 
 @strong{Please note:}  this declaration remains in effect after the
@@ -3086,7 +2688,7 @@ function.
 In Common Lisp, it is possible to use @code{(declare (inline @dots{}))}
 before a particular call to a function to cause just that call to
 be inlined; the current byte compilers provide no way to implement
-this, so @code{(declare (inline @dots{}))} is currently ignored by
+this, so @code{(cl-declare (inline @dots{}))} is currently ignored by
 this package.
 
 @item notinline
@@ -3096,22 +2698,20 @@ declaration.
 
 @item optimize
 This declaration controls how much optimization is performed by
-the compiler.  Naturally, it is ignored by the earlier non-optimizing
-compilers.
+the compiler.
 
 The word @code{optimize} is followed by any number of lists like
 @code{(speed 3)} or @code{(safety 2)}.  Common Lisp defines several
 optimization ``qualities''; this package ignores all but @code{speed}
 and @code{safety}.  The value of a quality should be an integer from
-0 to 3, with 0 meaning ``unimportant'' and 3 meaning ``very important.''
+0 to 3, with 0 meaning ``unimportant'' and 3 meaning ``very important''.
 The default level for both qualities is 1.
 
-In this package, with the optimizing compiler, the
-@code{speed} quality is tied to the @code{byte-compile-optimize}
+In this package, the @code{speed} quality is tied to the @code{byte-optimize}
 flag, which is set to @code{nil} for @code{(speed 0)} and to
 @code{t} for higher settings; and the @code{safety} quality is
 tied to the @code{byte-compile-delete-errors} flag, which is
-set to @code{t} for @code{(safety 3)} and to @code{nil} for all
+set to @code{nil} for @code{(safety 3)} and to @code{t} for all
 lower settings.  (The latter flag controls whether the compiler
 is allowed to optimize out code whose only side-effect could
 be to signal an error, e.g., rewriting @code{(progn foo bar)} to
@@ -3125,23 +2725,23 @@ Emacs itself, Emacs will not crash with a segmentation fault
 just because of an error in a fully-optimized Lisp program.
 
 The @code{optimize} declaration is normally used in a top-level
-@code{proclaim} or @code{declaim} in a file; Common Lisp allows
+@code{cl-proclaim} or @code{cl-declaim} in a file; Common Lisp allows
 it to be used with @code{declare} to set the level of optimization
 locally for a given form, but this will not work correctly with the
-current version of the optimizing compiler.  (The @code{declare}
+current byte-compiler.  (The @code{cl-declare}
 will set the new optimization level, but that level will not
 automatically be unset after the enclosing form is done.)
 
 @item warn
 This declaration controls what sorts of warnings are generated
-by the byte compiler.  Again, only the optimizing compiler
-generates warnings.  The word @code{warn} is followed by any
-number of ``warning qualities,'' similar in form to optimization
+by the byte compiler.  The word @code{warn} is followed by any
+number of ``warning qualities'', similar in form to optimization
 qualities.  The currently supported warning types are
 @code{redefine}, @code{callargs}, @code{unresolved}, and
 @code{free-vars}; in the current system, a value of 0 will
 disable these warnings and any higher value will enable them.
-See the documentation for the optimizing byte compiler for details.
+See the documentation of the variable @code{byte-compile-warnings}
+for more details.
 @end table
 
 @node Symbols
@@ -3152,8 +2752,8 @@ This package defines several symbol-related features that were
 missing from Emacs Lisp.
 
 @menu
-* Property Lists::       @code{get*}, @code{remprop}, @code{getf}, @code{remf}.
-* Creating Symbols::     @code{gensym}, @code{gentemp}.
+* Property Lists::       @code{cl-get}, @code{cl-remprop}, @code{cl-getf}, @code{cl-remf}.
+* Creating Symbols::     @code{cl-gensym}, @code{cl-gentemp}.
 @end menu
 
 @node Property Lists
@@ -3165,18 +2765,18 @@ and @code{put} for operating on properties attached to symbols.
 There are also functions for working with property lists as
 first-class data structures not attached to particular symbols.
 
-@defun get* symbol property &optional default
+@defun cl-get symbol property &optional default
 This function is like @code{get}, except that if the property is
 not found, the @var{default} argument provides the return value.
 (The Emacs Lisp @code{get} function always uses @code{nil} as
-the default; this package's @code{get*} is equivalent to Common
+the default; this package's @code{cl-get} is equivalent to Common
 Lisp's @code{get}.)
 
-The @code{get*} function is @code{setf}-able; when used in this
+The @code{cl-get} function is @code{setf}-able; when used in this
 fashion, the @var{default} argument is allowed but ignored.
 @end defun
 
-@defun remprop symbol property
+@defun cl-remprop symbol property
 This function removes the entry for @var{property} from the property
 list of @var{symbol}.  It returns a true value if the property was
 indeed found and removed, or @code{nil} if there was no such property.
@@ -3184,10 +2784,10 @@ indeed found and removed, or @code{nil} if there was no such property.
 since @code{get} did not allow a @var{default}, it was very difficult
 to distinguish between a missing property and a property whose value
 was @code{nil}; thus, setting a property to @code{nil} was close
-enough to @code{remprop} for most purposes.)
+enough to @code{cl-remprop} for most purposes.)
 @end defun
 
-@defun getf place property &optional default
+@defun cl-getf place property &optional default
 This function scans the list @var{place} as if it were a property
 list, i.e., a list of alternating property names and values.  If
 an even-numbered element of @var{place} is found which is @code{eq}
@@ -3198,10 +2798,10 @@ is given).
 In particular,
 
 @example
-(get sym prop)  @equiv{}  (getf (symbol-plist sym) prop)
+(get sym prop)  @equiv{}  (cl-getf (symbol-plist sym) prop)
 @end example
 
-It is valid to use @code{getf} as a @code{setf} place, in which case
+It is valid to use @code{cl-getf} as a @code{setf} place, in which case
 its @var{place} argument must itself be a valid @code{setf} place.
 The @var{default} argument, if any, is ignored in this context.
 The effect is to change (via @code{setcar}) the value cell in the
@@ -3209,25 +2809,25 @@ list that corresponds to @var{property}, or to cons a new property-value
 pair onto the list if the property is not yet present.
 
 @example
-(put sym prop val)  @equiv{}  (setf (getf (symbol-plist sym) prop) val)
+(put sym prop val) @equiv{} (setf (cl-getf (symbol-plist sym) prop) val)
 @end example
 
-The @code{get} and @code{get*} functions are also @code{setf}-able.
+The @code{get} and @code{cl-get} functions are also @code{setf}-able.
 The fact that @code{default} is ignored can sometimes be useful:
 
 @example
-(incf (get* 'foo 'usage-count 0))
+(cl-incf (cl-get 'foo 'usage-count 0))
 @end example
 
 Here, symbol @code{foo}'s @code{usage-count} property is incremented
 if it exists, or set to 1 (an incremented 0) otherwise.
 
-When not used as a @code{setf} form, @code{getf} is just a regular
+When not used as a @code{setf} form, @code{cl-getf} is just a regular
 function and its @var{place} argument can actually be any Lisp
 expression.
 @end defun
 
-@defspec remf place property
+@defmac cl-remf place property
 This macro removes the property-value pair for @var{property} from
 the property list stored at @var{place}, which is any @code{setf}-able
 place expression.  It returns true if the property was found.  Note
@@ -3235,11 +2835,7 @@ that if @var{property} happens to be first on the list, this will
 effectively do a @code{(setf @var{place} (cddr @var{place}))},
 whereas if it occurs later, this simply uses @code{setcdr} to splice
 out the property and value cells.
-@end defspec
-
-@iftex
-@secno=2
-@end iftex
+@end defmac
 
 @node Creating Symbols
 @section Creating Symbols
@@ -3248,7 +2844,7 @@ out the property and value cells.
 These functions create unique symbols, typically for use as
 temporary variables.
 
-@defun gensym &optional x
+@defun cl-gensym &optional x
 This function creates a new, uninterned symbol (using @code{make-symbol})
 with a unique name.  (The name of an uninterned symbol is relevant
 only if the symbol is printed.)  By default, the name is generated
@@ -3258,52 +2854,45 @@ string is used as a prefix instead of @samp{G}.  Uninterned symbols
 are used in macro expansions for temporary variables, to ensure that
 their names will not conflict with ``real'' variables in the user's
 code.
-@end defun
 
-@defvar *gensym-counter*
-This variable holds the counter used to generate @code{gensym} names.
-It is incremented after each use by @code{gensym}.  In Common Lisp
-this is initialized with 0, but this package initializes it with a
-random (time-dependent) value to avoid trouble when two files that
-each used @code{gensym} in their compilation are loaded together.
-(Uninterned symbols become interned when the compiler writes them
-out to a file and the Emacs loader loads them, so their names have to
-be treated a bit more carefully than in Common Lisp where uninterned
+(Internally, the variable @code{cl--gensym-counter} holds the counter
+used to generate names.  It is incremented after each use.  In Common
+Lisp this is initialized with 0, but this package initializes it with
+a random time-dependent value to avoid trouble when two files that
+each used @code{cl-gensym} in their compilation are loaded together.
+Uninterned symbols become interned when the compiler writes them out
+to a file and the Emacs loader loads them, so their names have to be
+treated a bit more carefully than in Common Lisp where uninterned
 symbols remain uninterned after loading.)
-@end defvar
+@end defun
 
-@defun gentemp &optional x
-This function is like @code{gensym}, except that it produces a new
+@defun cl-gentemp &optional x
+This function is like @code{cl-gensym}, except that it produces a new
 @emph{interned} symbol.  If the symbol that is generated already
 exists, the function keeps incrementing the counter and trying
 again until a new symbol is generated.
 @end defun
 
-The Quiroz @file{cl.el} package also defined a @code{defkeyword}
-form for creating self-quoting keyword symbols.  This package
-automatically creates all keywords that are called for by
-@code{&key} argument specifiers, and discourages the use of
-keywords as data unrelated to keyword arguments, so the
-@code{defkeyword} form has been discontinued.
+This package automatically creates all keywords that are called for by
+@code{&key} argument specifiers, and discourages the use of keywords
+as data unrelated to keyword arguments, so the related function
+@code{defkeyword} (to create self-quoting keyword symbols) is not
+provided.
 
 @node Numbers
 @chapter Numbers
 
 @noindent
 This section defines a few simple Common Lisp operations on numbers
-which were left out of Emacs Lisp.
+that were left out of Emacs Lisp.
 
 @menu
-* Predicates on Numbers::       @code{plusp}, @code{oddp}, @code{floatp-safe}, etc.
-* Numerical Functions::         @code{abs}, @code{floor*}, etc.
-* Random Numbers::              @code{random*}, @code{make-random-state}.
-* Implementation Parameters::   @code{most-positive-float}.
+* Predicates on Numbers::       @code{cl-plusp}, @code{cl-oddp}, etc.
+* Numerical Functions::         @code{cl-floor}, @code{cl-ceiling}, etc.
+* Random Numbers::              @code{cl-random}, @code{cl-make-random-state}.
+* Implementation Parameters::   @code{cl-most-positive-float}, etc.
 @end menu
 
-@iftex
-@secno=1
-@end iftex
-
 @node Predicates on Numbers
 @section Predicates on Numbers
 
@@ -3311,35 +2900,33 @@ which were left out of Emacs Lisp.
 These functions return @code{t} if the specified condition is
 true of the numerical argument, or @code{nil} otherwise.
 
-@defun plusp number
+@defun cl-plusp number
 This predicate tests whether @var{number} is positive.  It is an
 error if the argument is not a number.
 @end defun
 
-@defun minusp number
+@defun cl-minusp number
 This predicate tests whether @var{number} is negative.  It is an
 error if the argument is not a number.
 @end defun
 
-@defun oddp integer
+@defun cl-oddp integer
 This predicate tests whether @var{integer} is odd.  It is an
 error if the argument is not an integer.
 @end defun
 
-@defun evenp integer
+@defun cl-evenp integer
 This predicate tests whether @var{integer} is even.  It is an
 error if the argument is not an integer.
 @end defun
 
-@defun floatp-safe object
+@ignore
+@defun cl-floatp-safe object
 This predicate tests whether @var{object} is a floating-point
 number.  On systems that support floating-point, this is equivalent
 to @code{floatp}.  On other systems, this always returns @code{nil}.
 @end defun
-
-@iftex
-@secno=3
-@end iftex
+@end ignore
 
 @node Numerical Functions
 @section Numerical Functions
@@ -3347,30 +2934,26 @@ to @code{floatp}.  On other systems, this always returns @code{nil}.
 @noindent
 These functions perform various arithmetic operations on numbers.
 
-@defun gcd &rest integers
+@defun cl-gcd &rest integers
 This function returns the Greatest Common Divisor of the arguments.
 For one argument, it returns the absolute value of that argument.
 For zero arguments, it returns zero.
 @end defun
 
-@defun lcm &rest integers
+@defun cl-lcm &rest integers
 This function returns the Least Common Multiple of the arguments.
 For one argument, it returns the absolute value of that argument.
 For zero arguments, it returns one.
 @end defun
 
-@defun isqrt integer
+@defun cl-isqrt integer
 This function computes the ``integer square root'' of its integer
 argument, i.e., the greatest integer less than or equal to the true
 square root of the argument.
 @end defun
 
-@defun floor* number &optional divisor
-This function implements the Common Lisp @code{floor} function.
-It is called @code{floor*} to avoid name conflicts with the
-simpler @code{floor} function built-in to Emacs.
-
-With one argument, @code{floor*} returns a list of two numbers:
+@defun cl-floor number &optional divisor
+With one argument, @code{cl-floor} returns a list of two numbers:
 The argument rounded down (toward minus infinity) to an integer,
 and the ``remainder'' which would have to be added back to the
 first return value to yield the argument again.  If the argument
@@ -3379,37 +2962,37 @@ If the argument is a floating-point number, the first
 result is a Lisp integer and the second is a Lisp float between
 0 (inclusive) and 1 (exclusive).
 
-With two arguments, @code{floor*} divides @var{number} by
+With two arguments, @code{cl-floor} divides @var{number} by
 @var{divisor}, and returns the floor of the quotient and the
 corresponding remainder as a list of two numbers.  If
-@code{(floor* @var{x} @var{y})} returns @code{(@var{q} @var{r})},
+@code{(cl-floor @var{x} @var{y})} returns @code{(@var{q} @var{r})},
 then @code{@var{q}*@var{y} + @var{r} = @var{x}}, with @var{r}
 between 0 (inclusive) and @var{r} (exclusive).  Also, note
-that @code{(floor* @var{x})} is exactly equivalent to
-@code{(floor* @var{x} 1)}.
+that @code{(cl-floor @var{x})} is exactly equivalent to
+@code{(cl-floor @var{x} 1)}.
 
 This function is entirely compatible with Common Lisp's @code{floor}
 function, except that it returns the two results in a list since
 Emacs Lisp does not support multiple-valued functions.
 @end defun
 
-@defun ceiling* number &optional divisor
+@defun cl-ceiling number &optional divisor
 This function implements the Common Lisp @code{ceiling} function,
 which is analogous to @code{floor} except that it rounds the
 argument or quotient of the arguments up toward plus infinity.
 The remainder will be between 0 and minus @var{r}.
 @end defun
 
-@defun truncate* number &optional divisor
+@defun cl-truncate number &optional divisor
 This function implements the Common Lisp @code{truncate} function,
 which is analogous to @code{floor} except that it rounds the
 argument or quotient of the arguments toward zero.  Thus it is
-equivalent to @code{floor*} if the argument or quotient is
-positive, or to @code{ceiling*} otherwise.  The remainder has
+equivalent to @code{cl-floor} if the argument or quotient is
+positive, or to @code{cl-ceiling} otherwise.  The remainder has
 the same sign as @var{number}.
 @end defun
 
-@defun round* number &optional divisor
+@defun cl-round number &optional divisor
 This function implements the Common Lisp @code{round} function,
 which is analogous to @code{floor} except that it rounds the
 argument or quotient of the arguments to the nearest integer.
@@ -3417,26 +3000,16 @@ In the case of a tie (the argument or quotient is exactly
 halfway between two integers), it rounds to the even integer.
 @end defun
 
-@defun mod* number divisor
+@defun cl-mod number divisor
 This function returns the same value as the second return value
-of @code{floor}.
+of @code{cl-floor}.
 @end defun
 
-@defun rem* number divisor
+@defun cl-rem number divisor
 This function returns the same value as the second return value
-of @code{truncate}.
+of @code{cl-truncate}.
 @end defun
 
-These definitions are compatible with those in the Quiroz
-@file{cl.el} package, except that this package appends @samp{*}
-to certain function names to avoid conflicts with existing
-Emacs functions, and that the mechanism for returning
-multiple values is different.
-
-@iftex
-@secno=8
-@end iftex
-
 @node Random Numbers
 @section Random Numbers
 
@@ -3444,35 +3017,30 @@ multiple values is different.
 This package also provides an implementation of the Common Lisp
 random number generator.  It uses its own additive-congruential
 algorithm, which is much more likely to give statistically clean
+@c FIXME?  Still true?
 random numbers than the simple generators supplied by many
 operating systems.
 
-@defun random* number &optional state
+@defun cl-random number &optional state
 This function returns a random nonnegative number less than
 @var{number}, and of the same type (either integer or floating-point).
 The @var{state} argument should be a @code{random-state} object
-which holds the state of the random number generator.  The
+that holds the state of the random number generator.  The
 function modifies this state object as a side effect.  If
-@var{state} is omitted, it defaults to the variable
-@code{*random-state*}, which contains a pre-initialized
-@code{random-state} object.
+@var{state} is omitted, it defaults to the internal variable
+@code{cl--random-state}, which contains a pre-initialized
+default @code{random-state} object.  (Since any number of programs in
+the Emacs process may be accessing @code{cl--random-state} in
+interleaved fashion, the sequence generated from this will be
+irreproducible for all intents and purposes.)
 @end defun
 
-@defvar *random-state*
-This variable contains the system ``default'' @code{random-state}
-object, used for calls to @code{random*} that do not specify an
-alternative state object.  Since any number of programs in the
-Emacs process may be accessing @code{*random-state*} in interleaved
-fashion, the sequence generated from this variable will be
-irreproducible for all intents and purposes.
-@end defvar
-
-@defun make-random-state &optional state
+@defun cl-make-random-state &optional state
 This function creates or copies a @code{random-state} object.
 If @var{state} is omitted or @code{nil}, it returns a new copy of
-@code{*random-state*}.  This is a copy in the sense that future
-sequences of calls to @code{(random* @var{n})} and
-@code{(random* @var{n} @var{s})} (where @var{s} is the new
+@code{cl--random-state}.  This is a copy in the sense that future
+sequences of calls to @code{(cl-random @var{n})} and
+@code{(cl-random @var{n} @var{s})} (where @var{s} is the new
 random-state object) will return identical sequences of random
 numbers.
 
@@ -3487,13 +3055,13 @@ different sequence of random numbers.
 It is valid to print a @code{random-state} object to a buffer or
 file and later read it back with @code{read}.  If a program wishes
 to use a sequence of pseudo-random numbers which can be reproduced
-later for debugging, it can call @code{(make-random-state t)} to
+later for debugging, it can call @code{(cl-make-random-state t)} to
 get a new sequence, then print this sequence to a file.  When the
 program is later rerun, it can read the original run's random-state
 from the file.
 @end defun
 
-@defun random-state-p object
+@defun cl-random-state-p object
 This predicate returns @code{t} if @var{object} is a
 @code{random-state} object, or @code{nil} otherwise.
 @end defun
@@ -3502,23 +3070,24 @@ This predicate returns @code{t} if @var{object} is a
 @section Implementation Parameters
 
 @noindent
-This package defines several useful constants having to with numbers.
+This package defines several useful constants having to do with
+floating-point numbers.
 
-The following parameters have to do with floating-point numbers.
-This package determines their values by exercising the computer's
+It determines their values by exercising the computer's
 floating-point arithmetic in various ways.  Because this operation
 might be slow, the code for initializing them is kept in a separate
 function that must be called before the parameters can be used.
 
 @defun cl-float-limits
 This function makes sure that the Common Lisp floating-point parameters
-like @code{most-positive-float} have been initialized.  Until it is
-called, these parameters will be @code{nil}.  If this version of Emacs
-does not support floats, the parameters will remain @code{nil}.  If the
-parameters have already been initialized, the function returns
+like @code{cl-most-positive-float} have been initialized.  Until it is
+called, these parameters will be @code{nil}.
+@c If this version of Emacs does not support floats, the parameters will
+@c remain @code{nil}.
+If the parameters have already been initialized, the function returns
 immediately.
 
-The algorithm makes assumptions that will be valid for most modern
+The algorithm makes assumptions that will be valid for almost all
 machines, but will fail if the machine's arithmetic is extremely
 unusual, e.g., decimal.
 @end defun
@@ -3530,50 +3099,50 @@ precisions, it has families of constants like
 floating-point precision, so this package omits the precision word
 from the constants' names.
 
-@defvar most-positive-float
+@defvar cl-most-positive-float
 This constant equals the largest value a Lisp float can hold.
 For those systems whose arithmetic supports infinities, this is
 the largest @emph{finite} value.  For IEEE machines, the value
 is approximately @code{1.79e+308}.
 @end defvar
 
-@defvar most-negative-float
-This constant equals the most-negative value a Lisp float can hold.
-(It is assumed to be equal to @code{(- most-positive-float)}.)
+@defvar cl-most-negative-float
+This constant equals the most negative value a Lisp float can hold.
+(It is assumed to be equal to @code{(- cl-most-positive-float)}.)
 @end defvar
 
-@defvar least-positive-float
+@defvar cl-least-positive-float
 This constant equals the smallest Lisp float value greater than zero.
 For IEEE machines, it is about @code{4.94e-324} if denormals are
 supported or @code{2.22e-308} if not.
 @end defvar
 
-@defvar least-positive-normalized-float
+@defvar cl-least-positive-normalized-float
 This constant equals the smallest @emph{normalized} Lisp float greater
 than zero, i.e., the smallest value for which IEEE denormalization
 will not result in a loss of precision.  For IEEE machines, this
 value is about @code{2.22e-308}.  For machines that do not support
 the concept of denormalization and gradual underflow, this constant
-will always equal @code{least-positive-float}.
+will always equal @code{cl-least-positive-float}.
 @end defvar
 
-@defvar least-negative-float
-This constant is the negative counterpart of @code{least-positive-float}.
+@defvar cl-least-negative-float
+This constant is the negative counterpart of @code{cl-least-positive-float}.
 @end defvar
 
-@defvar least-negative-normalized-float
+@defvar cl-least-negative-normalized-float
 This constant is the negative counterpart of
-@code{least-positive-normalized-float}.
+@code{cl-least-positive-normalized-float}.
 @end defvar
 
-@defvar float-epsilon
+@defvar cl-float-epsilon
 This constant is the smallest positive Lisp float that can be added
 to 1.0 to produce a distinct value.  Adding a smaller number to 1.0
 will yield 1.0 again due to roundoff.  For IEEE machines, epsilon
 is about @code{2.22e-16}.
 @end defvar
 
-@defvar float-negative-epsilon
+@defvar cl-float-negative-epsilon
 This is the smallest positive value that can be subtracted from
 1.0 to produce a distinct value.  For IEEE machines, it is about
 @code{1.11e-16}.
@@ -3590,10 +3159,10 @@ Emacs Lisp includes a few of these, notably @code{elt} and
 
 @menu
 * Sequence Basics::          Arguments shared by all sequence functions.
-* Mapping over Sequences::   @code{mapcar*}, @code{mapcan}, @code{map}, @code{every}, etc.
-* Sequence Functions::       @code{subseq}, @code{remove*}, @code{substitute}, etc.
-* Searching Sequences::      @code{find}, @code{position}, @code{count}, @code{search}, etc.
-* Sorting Sequences::        @code{sort*}, @code{stable-sort}, @code{merge}.
+* Mapping over Sequences::   @code{cl-mapcar}, @code{cl-map}, @code{cl-maplist}, etc.
+* Sequence Functions::       @code{cl-subseq}, @code{cl-remove}, @code{cl-substitute}, etc.
+* Searching Sequences::      @code{cl-find}, @code{cl-count}, @code{cl-search}, etc.
+* Sorting Sequences::        @code{cl-sort}, @code{cl-stable-sort}, @code{cl-merge}.
 @end menu
 
 @node Sequence Basics
@@ -3607,8 +3176,8 @@ may appear in any order.
 The @code{:key} argument should be passed either @code{nil}, or a
 function of one argument.  This key function is used as a filter
 through which the elements of the sequence are seen; for example,
-@code{(find x y :key 'car)} is similar to @code{(assoc* x y)}:
-It searches for an element of the list whose @code{car} equals
+@code{(cl-find x y :key 'car)} is similar to @code{(cl-assoc x y)}.
+It searches for an element of the list whose @sc{car} equals
 @code{x}, rather than for an element which equals @code{x} itself.
 If @code{:key} is omitted or @code{nil}, the filter is effectively
 the identity function.
@@ -3625,21 +3194,21 @@ true (non-@code{nil}) to indicate a match; instead, you may use
 @code{:test-not} to give a function which returns @emph{false} to
 indicate a match.  The default test function is @code{eql}.
 
-Many functions which take @var{item} and @code{:test} or @code{:test-not}
+Many functions that take @var{item} and @code{:test} or @code{:test-not}
 arguments also come in @code{-if} and @code{-if-not} varieties,
 where a @var{predicate} function is passed instead of @var{item},
 and sequence elements match if the predicate returns true on them
 (or false in the case of @code{-if-not}).  For example:
 
 @example
-(remove* 0 seq :test '=)  @equiv{}  (remove-if 'zerop seq)
+(cl-remove 0 seq :test '=)  @equiv{}  (cl-remove-if 'zerop seq)
 @end example
 
 @noindent
 to remove all zeros from sequence @code{seq}.
 
 Some operations can work on a subsequence of the argument sequence;
-these function take @code{:start} and @code{:end} arguments which
+these function take @code{:start} and @code{:end} arguments, which
 default to zero and the length of the sequence, respectively.
 Only elements between @var{start} (inclusive) and @var{end}
 (exclusive) are affected by the operation.  The @var{end} argument
@@ -3662,14 +3231,14 @@ are called on various elements.  Therefore, it is a bad idea to depend
 on side effects of these functions.  For example, @code{:from-end}
 may cause the sequence to be scanned actually in reverse, or it may
 be scanned forwards but computing a result ``as if'' it were scanned
-backwards.  (Some functions, like @code{mapcar*} and @code{every},
+backwards.  (Some functions, like @code{cl-mapcar} and @code{cl-every},
 @emph{do} specify exactly the order in which the function is called
 so side effects are perfectly acceptable in those cases.)
 
 Strings may contain ``text properties'' as well
 as character data.  Except as noted, it is undefined whether or
 not text properties are preserved by sequence functions.  For
-example, @code{(remove* ?A @var{str})} may or may not preserve
+example, @code{(cl-remove ?A @var{str})} may or may not preserve
 the properties of the characters copied from @var{str} into the
 result.
 
@@ -3681,7 +3250,7 @@ These functions ``map'' the function you specify over the elements
 of lists or arrays.  They are all variations on the theme of the
 built-in function @code{mapcar}.
 
-@defun mapcar* function seq &rest more-seqs
+@defun cl-mapcar function seq &rest more-seqs
 This function calls @var{function} on successive parallel sets of
 elements from its argument sequences.  Given a single @var{seq}
 argument it is equivalent to @code{mapcar}; given @var{n} sequences,
@@ -3694,86 +3263,89 @@ is always a list.
 
 Common Lisp's @code{mapcar} accepts multiple arguments but works
 only on lists; Emacs Lisp's @code{mapcar} accepts a single sequence
-argument.  This package's @code{mapcar*} works as a compatible
+argument.  This package's @code{cl-mapcar} works as a compatible
 superset of both.
 @end defun
 
-@defun map result-type function seq &rest more-seqs
+@defun cl-map result-type function seq &rest more-seqs
 This function maps @var{function} over the argument sequences,
-just like @code{mapcar*}, but it returns a sequence of type
+just like @code{cl-mapcar}, but it returns a sequence of type
 @var{result-type} rather than a list.  @var{result-type} must
 be one of the following symbols: @code{vector}, @code{string},
 @code{list} (in which case the effect is the same as for
-@code{mapcar*}), or @code{nil} (in which case the results are
-thrown away and @code{map} returns @code{nil}).
+@code{cl-mapcar}), or @code{nil} (in which case the results are
+thrown away and @code{cl-map} returns @code{nil}).
 @end defun
 
-@defun maplist function list &rest more-lists
+@defun cl-maplist function list &rest more-lists
 This function calls @var{function} on each of its argument lists,
-then on the @code{cdr}s of those lists, and so on, until the
+then on the @sc{cdr}s of those lists, and so on, until the
 shortest list runs out.  The results are returned in the form
-of a list.  Thus, @code{maplist} is like @code{mapcar*} except
+of a list.  Thus, @code{cl-maplist} is like @code{cl-mapcar} except
 that it passes in the list pointers themselves rather than the
-@code{car}s of the advancing pointers.
+@sc{car}s of the advancing pointers.
 @end defun
 
 @defun cl-mapc function seq &rest more-seqs
-This function is like @code{mapcar*}, except that the values returned
+This function is like @code{cl-mapcar}, except that the values returned
 by @var{function} are ignored and thrown away rather than being
 collected into a list.  The return value of @code{cl-mapc} is @var{seq},
 the first sequence.  This function is more general than the Emacs
-primitive @code{mapc}.
+primitive @code{mapc}.  (Note that this function is called
+@code{cl-mapc} even in @file{cl.el}, rather than @code{mapc*} as you
+might expect.)
+@c http://debbugs.gnu.org/6575
 @end defun
 
-@defun mapl function list &rest more-lists
-This function is like @code{maplist}, except that it throws away
+@defun cl-mapl function list &rest more-lists
+This function is like @code{cl-maplist}, except that it throws away
 the values returned by @var{function}.
 @end defun
 
-@defun mapcan function seq &rest more-seqs
-This function is like @code{mapcar*}, except that it concatenates
+@defun cl-mapcan function seq &rest more-seqs
+This function is like @code{cl-mapcar}, except that it concatenates
 the return values (which must be lists) using @code{nconc},
 rather than simply collecting them into a list.
 @end defun
 
-@defun mapcon function list &rest more-lists
-This function is like @code{maplist}, except that it concatenates
+@defun cl-mapcon function list &rest more-lists
+This function is like @code{cl-maplist}, except that it concatenates
 the return values using @code{nconc}.
 @end defun
 
-@defun some predicate seq &rest more-seqs
+@defun cl-some predicate seq &rest more-seqs
 This function calls @var{predicate} on each element of @var{seq}
 in turn; if @var{predicate} returns a non-@code{nil} value,
-@code{some} returns that value, otherwise it returns @code{nil}.
+@code{cl-some} returns that value, otherwise it returns @code{nil}.
 Given several sequence arguments, it steps through the sequences
 in parallel until the shortest one runs out, just as in
-@code{mapcar*}.  You can rely on the left-to-right order in which
+@code{cl-mapcar}.  You can rely on the left-to-right order in which
 the elements are visited, and on the fact that mapping stops
 immediately as soon as @var{predicate} returns non-@code{nil}.
 @end defun
 
-@defun every predicate seq &rest more-seqs
+@defun cl-every predicate seq &rest more-seqs
 This function calls @var{predicate} on each element of the sequence(s)
 in turn; it returns @code{nil} as soon as @var{predicate} returns
 @code{nil} for any element, or @code{t} if the predicate was true
 for all elements.
 @end defun
 
-@defun notany predicate seq &rest more-seqs
+@defun cl-notany predicate seq &rest more-seqs
 This function calls @var{predicate} on each element of the sequence(s)
 in turn; it returns @code{nil} as soon as @var{predicate} returns
 a non-@code{nil} value for any element, or @code{t} if the predicate
 was @code{nil} for all elements.
 @end defun
 
-@defun notevery predicate seq &rest more-seqs
+@defun cl-notevery predicate seq &rest more-seqs
 This function calls @var{predicate} on each element of the sequence(s)
 in turn; it returns a non-@code{nil} value as soon as @var{predicate}
 returns @code{nil} for any element, or @code{t} if the predicate was
 true for all elements.
 @end defun
 
-@defun reduce function seq @t{&key :from-end :start :end :initial-value :key}
+@defun cl-reduce function seq @t{&key :from-end :start :end :initial-value :key}
 This function combines the elements of @var{seq} using an associative
 binary operation.  Suppose @var{function} is @code{*} and @var{seq} is
 the list @code{(2 3 4 5)}.  The first two elements of the list are
@@ -3781,19 +3353,19 @@ combined with @code{(* 2 3) = 6}; this is combined with the next
 element, @code{(* 6 4) = 24}, and that is combined with the final
 element: @code{(* 24 5) = 120}.  Note that the @code{*} function happens
 to be self-reducing, so that @code{(* 2 3 4 5)} has the same effect as
-an explicit call to @code{reduce}.
+an explicit call to @code{cl-reduce}.
 
 If @code{:from-end} is true, the reduction is right-associative instead
 of left-associative:
 
 @example
-(reduce '- '(1 2 3 4))
-     @equiv{} (- (- (- 1 2) 3) 4) @result{} -8
-(reduce '- '(1 2 3 4) :from-end t)
-     @equiv{} (- 1 (- 2 (- 3 4))) @result{} -2
+(cl-reduce '- '(1 2 3 4))
+        @equiv{} (- (- (- 1 2) 3) 4) @result{} -8
+(cl-reduce '- '(1 2 3 4) :from-end t)
+        @equiv{} (- 1 (- 2 (- 3 4))) @result{} -2
 @end example
 
-If @code{:key} is specified, it is a function of one argument which
+If @code{:key} is specified, it is a function of one argument, which
 is called on each of the sequence elements in turn.
 
 If @code{:initial-value} is specified, it is effectively added to the
@@ -3807,7 +3379,7 @@ If the sequence is empty (and there is no initial value), then
 @end defun
 
 All of these mapping operations can be expressed conveniently in
-terms of the @code{loop} macro.  In compiled code, @code{loop} will
+terms of the @code{cl-loop} macro.  In compiled code, @code{cl-loop} will
 be faster since it generates the loop as in-line code with no
 function calls.
 
@@ -3818,7 +3390,7 @@ function calls.
 This section describes a number of Common Lisp functions for
 operating on sequences.
 
-@defun subseq sequence start &optional end
+@defun cl-subseq sequence start &optional end
 This function returns a given subsequence of the argument
 @var{sequence}, which may be a list, string, or vector.
 The indices @var{start} and @var{end} must be in range, and
@@ -3830,30 +3402,30 @@ with @var{sequence}.
 As an extension to Common Lisp, @var{start} and/or @var{end}
 may be negative, in which case they represent a distance back
 from the end of the sequence.  This is for compatibility with
-Emacs's @code{substring} function.  Note that @code{subseq} is
+Emacs's @code{substring} function.  Note that @code{cl-subseq} is
 the @emph{only} sequence function that allows negative
 @var{start} and @var{end}.
 
-You can use @code{setf} on a @code{subseq} form to replace a
+You can use @code{setf} on a @code{cl-subseq} form to replace a
 specified range of elements with elements from another sequence.
-The replacement is done as if by @code{replace}, described below.
+The replacement is done as if by @code{cl-replace}, described below.
 @end defun
 
-@defun concatenate result-type &rest seqs
+@defun cl-concatenate result-type &rest seqs
 This function concatenates the argument sequences together to
 form a result sequence of type @var{result-type}, one of the
 symbols @code{vector}, @code{string}, or @code{list}.  The
 arguments are always copied, even in cases such as
-@code{(concatenate 'list '(1 2 3))} where the result is
+@code{(cl-concatenate 'list '(1 2 3))} where the result is
 identical to an argument.
 @end defun
 
-@defun fill seq item @t{&key :start :end}
+@defun cl-fill seq item @t{&key :start :end}
 This function fills the elements of the sequence (or the specified
 part of the sequence) with the value @var{item}.
 @end defun
 
-@defun replace seq1 seq2 @t{&key :start1 :end1 :start2 :end2}
+@defun cl-replace seq1 seq2 @t{&key :start1 :end1 :start2 :end2}
 This function copies part of @var{seq2} into part of @var{seq1}.
 The sequence @var{seq1} is not stretched or resized; the amount
 of data copied is simply the shorter of the source and destination
@@ -3862,12 +3434,12 @@ of data copied is simply the shorter of the source and destination
 If @var{seq1} and @var{seq2} are @code{eq}, then the replacement
 will work correctly even if the regions indicated by the start
 and end arguments overlap.  However, if @var{seq1} and @var{seq2}
-are lists which share storage but are not @code{eq}, and the
+are lists that share storage but are not @code{eq}, and the
 start and end arguments specify overlapping regions, the effect
 is undefined.
 @end defun
 
-@defun remove* item seq @t{&key :test :test-not :key :count :start :end :from-end}
+@defun cl-remove item seq @t{&key :test :test-not :key :count :start :end :from-end}
 This returns a copy of @var{seq} with all elements matching
 @var{item} removed.  The result may share storage with or be
 @code{eq} to @var{seq} in some circumstances, but the original
@@ -3884,25 +3456,25 @@ end of the sequence rather than the beginning (this matters only
 if @var{count} was also specified).
 @end defun
 
-@defun delete* item seq @t{&key :test :test-not :key :count :start :end :from-end}
-This deletes all elements of @var{seq} which match @var{item}.
+@defun cl-delete item seq @t{&key :test :test-not :key :count :start :end :from-end}
+This deletes all elements of @var{seq} that match @var{item}.
 It is a destructive operation.  Since Emacs Lisp does not support
-stretchable strings or vectors, this is the same as @code{remove*}
-for those sequence types.  On lists, @code{remove*} will copy the
+stretchable strings or vectors, this is the same as @code{cl-remove}
+for those sequence types.  On lists, @code{cl-remove} will copy the
 list if necessary to preserve the original list, whereas
-@code{delete*} will splice out parts of the argument list.
+@code{cl-delete} will splice out parts of the argument list.
 Compare @code{append} and @code{nconc}, which are analogous
 non-destructive and destructive list operations in Emacs Lisp.
 @end defun
 
-@findex remove-if
-@findex remove-if-not
-@findex delete-if
-@findex delete-if-not
-The predicate-oriented functions @code{remove-if}, @code{remove-if-not},
-@code{delete-if}, and @code{delete-if-not} are defined similarly.
+@findex cl-remove-if
+@findex cl-remove-if-not
+@findex cl-delete-if
+@findex cl-delete-if-not
+The predicate-oriented functions @code{cl-remove-if}, @code{cl-remove-if-not},
+@code{cl-delete-if}, and @code{cl-delete-if-not} are defined similarly.
 
-@defun remove-duplicates seq @t{&key :test :test-not :key :start :end :from-end}
+@defun cl-remove-duplicates seq @t{&key :test :test-not :key :start :end :from-end}
 This function returns a copy of @var{seq} with duplicate elements
 removed.  Specifically, if two elements from the sequence match
 according to the @code{:test}, @code{:test-not}, and @code{:key}
@@ -3912,40 +3484,41 @@ is true, the leftmost one is retained instead.  If @code{:start} or
 examined or removed.
 @end defun
 
-@defun delete-duplicates seq @t{&key :test :test-not :key :start :end :from-end}
+@defun cl-delete-duplicates seq @t{&key :test :test-not :key :start :end :from-end}
 This function deletes duplicate elements from @var{seq}.  It is
-a destructive version of @code{remove-duplicates}.
+a destructive version of @code{cl-remove-duplicates}.
 @end defun
 
-@defun substitute new old seq @t{&key :test :test-not :key :count :start :end :from-end}
+@defun cl-substitute new old seq @t{&key :test :test-not :key :count :start :end :from-end}
 This function returns a copy of @var{seq}, with all elements
 matching @var{old} replaced with @var{new}.  The @code{:count},
 @code{:start}, @code{:end}, and @code{:from-end} arguments may be
 used to limit the number of substitutions made.
 @end defun
 
-@defun nsubstitute new old seq @t{&key :test :test-not :key :count :start :end :from-end}
-This is a destructive version of @code{substitute}; it performs
+@defun cl-nsubstitute new old seq @t{&key :test :test-not :key :count :start :end :from-end}
+This is a destructive version of @code{cl-substitute}; it performs
 the substitution using @code{setcar} or @code{aset} rather than
 by returning a changed copy of the sequence.
 @end defun
 
-@findex substitute-if
-@findex substitute-if-not
-@findex nsubstitute-if
-@findex nsubstitute-if-not
-The @code{substitute-if}, @code{substitute-if-not}, @code{nsubstitute-if},
-and @code{nsubstitute-if-not} functions are defined similarly.  For
-these, a @var{predicate} is given in place of the @var{old} argument.
+@findex cl-substitute-if
+@findex cl-substitute-if-not
+@findex cl-nsubstitute-if
+@findex cl-nsubstitute-if-not
+The functions @code{cl-substitute-if}, @code{cl-substitute-if-not},
+@code{cl-nsubstitute-if}, and @code{cl-nsubstitute-if-not} are defined
+similarly.  For these, a @var{predicate} is given in place of the
+@var{old} argument.
 
 @node Searching Sequences
 @section Searching Sequences
 
 @noindent
 These functions search for elements or subsequences in a sequence.
-(See also @code{member*} and @code{assoc*}; @pxref{Lists}.)
+(See also @code{cl-member} and @code{cl-assoc}; @pxref{Lists}.)
 
-@defun find item seq @t{&key :test :test-not :key :start :end :from-end}
+@defun cl-find item seq @t{&key :test :test-not :key :start :end :from-end}
 This function searches @var{seq} for an element matching @var{item}.
 If it finds a match, it returns the matching element.  Otherwise,
 it returns @code{nil}.  It returns the leftmost match, unless
@@ -3954,37 +3527,37 @@ match.  The @code{:start} and @code{:end} arguments may be used to
 limit the range of elements that are searched.
 @end defun
 
-@defun position item seq @t{&key :test :test-not :key :start :end :from-end}
-This function is like @code{find}, except that it returns the
+@defun cl-position item seq @t{&key :test :test-not :key :start :end :from-end}
+This function is like @code{cl-find}, except that it returns the
 integer position in the sequence of the matching item rather than
 the item itself.  The position is relative to the start of the
 sequence as a whole, even if @code{:start} is non-zero.  The function
 returns @code{nil} if no matching element was found.
 @end defun
 
-@defun count item seq @t{&key :test :test-not :key :start :end}
+@defun cl-count item seq @t{&key :test :test-not :key :start :end}
 This function returns the number of elements of @var{seq} which
 match @var{item}.  The result is always a nonnegative integer.
 @end defun
 
-@findex find-if
-@findex find-if-not
-@findex position-if
-@findex position-if-not
-@findex count-if
-@findex count-if-not
-The @code{find-if}, @code{find-if-not}, @code{position-if},
-@code{position-if-not}, @code{count-if}, and @code{count-if-not}
+@findex cl-find-if
+@findex cl-find-if-not
+@findex cl-position-if
+@findex cl-position-if-not
+@findex cl-count-if
+@findex cl-count-if-not
+The @code{cl-find-if}, @code{cl-find-if-not}, @code{cl-position-if},
+@code{cl-position-if-not}, @code{cl-count-if}, and @code{cl-count-if-not}
 functions are defined similarly.
 
-@defun mismatch seq1 seq2 @t{&key :test :test-not :key :start1 :end1 :start2 :end2 :from-end}
+@defun cl-mismatch seq1 seq2 @t{&key :test :test-not :key :start1 :end1 :start2 :end2 :from-end}
 This function compares the specified parts of @var{seq1} and
 @var{seq2}.  If they are the same length and the corresponding
 elements match (according to @code{:test}, @code{:test-not},
 and @code{:key}), the function returns @code{nil}.  If there is
 a mismatch, the function returns the index (relative to @var{seq1})
 of the first mismatching element.  This will be the leftmost pair of
-elements which do not match, or the position at which the shorter of
+elements that do not match, or the position at which the shorter of
 the two otherwise-matching sequences runs out.
 
 If @code{:from-end} is true, then the elements are compared from right
@@ -3992,14 +3565,14 @@ to left starting at @code{(1- @var{end1})} and @code{(1- @var{end2})}.
 If the sequences differ, then one plus the index of the rightmost
 difference (relative to @var{seq1}) is returned.
 
-An interesting example is @code{(mismatch str1 str2 :key 'upcase)},
+An interesting example is @code{(cl-mismatch str1 str2 :key 'upcase)},
 which compares two strings case-insensitively.
 @end defun
 
-@defun search seq1 seq2 @t{&key :test :test-not :key :from-end :start1 :end1 :start2 :end2}
+@defun cl-search seq1 seq2 @t{&key :test :test-not :key :from-end :start1 :end1 :start2 :end2}
 This function searches @var{seq2} for a subsequence that matches
 @var{seq1} (or part of it specified by @code{:start1} and
-@code{:end1}.)  Only matches which fall entirely within the region
+@code{:end1}).  Only matches that fall entirely within the region
 defined by @code{:start2} and @code{:end2} will be considered.
 The return value is the index of the leftmost element of the
 leftmost match, relative to the start of @var{seq2}, or @code{nil}
@@ -4010,7 +3583,7 @@ function finds the @emph{rightmost} matching subsequence.
 @node Sorting Sequences
 @section Sorting Sequences
 
-@defun sort* seq predicate @t{&key :key}
+@defun cl-sort seq predicate @t{&key :key}
 This function sorts @var{seq} into increasing order as determined
 by using @var{predicate} to compare pairs of elements.  @var{predicate}
 should return true (non-@code{nil}) if and only if its first argument
@@ -4021,39 +3594,39 @@ numbers into decreasing rather than increasing order.
 
 This function differs from Emacs's built-in @code{sort} in that it
 can operate on any type of sequence, not just lists.  Also, it
-accepts a @code{:key} argument which is used to preprocess data
+accepts a @code{:key} argument, which is used to preprocess data
 fed to the @var{predicate} function.  For example,
 
 @example
-(setq data (sort* data 'string-lessp :key 'downcase))
+(setq data (cl-sort data 'string-lessp :key 'downcase))
 @end example
 
 @noindent
 sorts @var{data}, a sequence of strings, into increasing alphabetical
 order without regard to case.  A @code{:key} function of @code{car}
 would be useful for sorting association lists.  It should only be a
-simple accessor though, it's used heavily in the current
+simple accessor though, since it's used heavily in the current
 implementation.
 
-The @code{sort*} function is destructive; it sorts lists by actually
-rearranging the @code{cdr} pointers in suitable fashion.
+The @code{cl-sort} function is destructive; it sorts lists by actually
+rearranging the @sc{cdr} pointers in suitable fashion.
 @end defun
 
-@defun stable-sort seq predicate @t{&key :key}
+@defun cl-stable-sort seq predicate @t{&key :key}
 This function sorts @var{seq} @dfn{stably}, meaning two elements
 which are equal in terms of @var{predicate} are guaranteed not to
 be rearranged out of their original order by the sort.
 
-In practice, @code{sort*} and @code{stable-sort} are equivalent
+In practice, @code{cl-sort} and @code{cl-stable-sort} are equivalent
 in Emacs Lisp because the underlying @code{sort} function is
 stable by default.  However, this package reserves the right to
-use non-stable methods for @code{sort*} in the future.
+use non-stable methods for @code{cl-sort} in the future.
 @end defun
 
-@defun merge type seq1 seq2 predicate @t{&key :key}
+@defun cl-merge type seq1 seq2 predicate @t{&key :key}
 This function merges two sequences @var{seq1} and @var{seq2} by
 interleaving their elements.  The result sequence, of type @var{type}
-(in the sense of @code{concatenate}), has length equal to the sum
+(in the sense of @code{cl-concatenate}), has length equal to the sum
 of the lengths of the two input sequences.  The sequences may be
 modified destructively.  Order of elements within @var{seq1} and
 @var{seq2} is preserved in the interleaving; elements of the two
@@ -4073,10 +3646,10 @@ a merged sequence which is (stably) sorted according to
 The functions described here operate on lists.
 
 @menu
-* List Functions::                @code{caddr}, @code{first}, @code{list*}, etc.
-* Substitution of Expressions::   @code{subst}, @code{sublis}, etc.
-* Lists as Sets::                 @code{member*}, @code{adjoin}, @code{union}, etc.
-* Association Lists::             @code{assoc*}, @code{rassoc*}, @code{acons}, @code{pairlis}.
+* List Functions::                @code{cl-caddr}, @code{cl-first}, @code{cl-list*}, etc.
+* Substitution of Expressions::   @code{cl-subst}, @code{cl-sublis}, etc.
+* Lists as Sets::                 @code{cl-member}, @code{cl-adjoin}, @code{cl-union}, etc.
+* Association Lists::             @code{cl-assoc}, @code{cl-acons}, @code{cl-pairlis}, etc.
 @end menu
 
 @node List Functions
@@ -4086,107 +3659,89 @@ The functions described here operate on lists.
 This section describes a number of simple operations on lists,
 i.e., chains of cons cells.
 
-@defun caddr x
+@defun cl-caddr x
 This function is equivalent to @code{(car (cdr (cdr @var{x})))}.
-Likewise, this package defines all 28 @code{c@var{xxx}r} functions
+Likewise, this package defines all 24 @code{c@var{xxx}r} functions
 where @var{xxx} is up to four @samp{a}s and/or @samp{d}s.
 All of these functions are @code{setf}-able, and calls to them
 are expanded inline by the byte-compiler for maximum efficiency.
 @end defun
 
-@defun first x
+@defun cl-first x
 This function is a synonym for @code{(car @var{x})}.  Likewise,
-the functions @code{second}, @code{third}, @dots{}, through
-@code{tenth} return the given element of the list @var{x}.
+the functions @code{cl-second}, @code{cl-third}, @dots{}, through
+@code{cl-tenth} return the given element of the list @var{x}.
 @end defun
 
-@defun rest x
+@defun cl-rest x
 This function is a synonym for @code{(cdr @var{x})}.
 @end defun
 
-@defun endp x
+@defun cl-endp x
 Common Lisp defines this function to act like @code{null}, but
 signaling an error if @code{x} is neither a @code{nil} nor a
-cons cell.  This package simply defines @code{endp} as a synonym
+cons cell.  This package simply defines @code{cl-endp} as a synonym
 for @code{null}.
 @end defun
 
-@defun list-length x
+@defun cl-list-length x
 This function returns the length of list @var{x}, exactly like
 @code{(length @var{x})}, except that if @var{x} is a circular
-list (where the cdr-chain forms a loop rather than terminating
+list (where the @sc{cdr}-chain forms a loop rather than terminating
 with @code{nil}), this function returns @code{nil}.  (The regular
-@code{length} function would get stuck if given a circular list.)
+@code{length} function would get stuck if given a circular list.
+See also the @code{safe-length} function.)
 @end defun
 
-@defun list* arg &rest others
+@defun cl-list* arg &rest others
 This function constructs a list of its arguments.  The final
-argument becomes the @code{cdr} of the last cell constructed.
-Thus, @code{(list* @var{a} @var{b} @var{c})} is equivalent to
+argument becomes the @sc{cdr} of the last cell constructed.
+Thus, @code{(cl-list* @var{a} @var{b} @var{c})} is equivalent to
 @code{(cons @var{a} (cons @var{b} @var{c}))}, and
-@code{(list* @var{a} @var{b} nil)} is equivalent to
+@code{(cl-list* @var{a} @var{b} nil)} is equivalent to
 @code{(list @var{a} @var{b})}.
-
-(Note that this function really is called @code{list*} in Common
-Lisp; it is not a name invented for this package like @code{member*}
-or @code{defun*}.)
 @end defun
 
-@defun ldiff list sublist
+@defun cl-ldiff list sublist
 If @var{sublist} is a sublist of @var{list}, i.e., is @code{eq} to
 one of the cons cells of @var{list}, then this function returns
 a copy of the part of @var{list} up to but not including
-@var{sublist}.  For example, @code{(ldiff x (cddr x))} returns
+@var{sublist}.  For example, @code{(cl-ldiff x (cddr x))} returns
 the first two elements of the list @code{x}.  The result is a
 copy; the original @var{list} is not modified.  If @var{sublist}
 is not a sublist of @var{list}, a copy of the entire @var{list}
 is returned.
 @end defun
 
-@defun copy-list list
+@defun cl-copy-list list
 This function returns a copy of the list @var{list}.  It copies
 dotted lists like @code{(1 2 . 3)} correctly.
 @end defun
 
-@defun copy-tree x &optional vecp
-This function returns a copy of the tree of cons cells @var{x}.
-Unlike @code{copy-sequence} (and its alias @code{copy-list}),
-which copies only along the @code{cdr} direction, this function
-copies (recursively) along both the @code{car} and the @code{cdr}
-directions.  If @var{x} is not a cons cell, the function simply
-returns @var{x} unchanged.  If the optional @var{vecp} argument
-is true, this function copies vectors (recursively) as well as
-cons cells.
-@end defun
-
-@defun tree-equal x y @t{&key :test :test-not :key}
+@defun cl-tree-equal x y @t{&key :test :test-not :key}
 This function compares two trees of cons cells.  If @var{x} and
-@var{y} are both cons cells, their @code{car}s and @code{cdr}s are
+@var{y} are both cons cells, their @sc{car}s and @sc{cdr}s are
 compared recursively.  If neither @var{x} nor @var{y} is a cons
 cell, they are compared by @code{eql}, or according to the
 specified test.  The @code{:key} function, if specified, is
 applied to the elements of both trees.  @xref{Sequences}.
 @end defun
 
-@iftex
-@secno=3
-@end iftex
-
 @node Substitution of Expressions
 @section Substitution of Expressions
 
 @noindent
 These functions substitute elements throughout a tree of cons
-cells.  (@xref{Sequence Functions}, for the @code{substitute}
+cells.  (@xref{Sequence Functions}, for the @code{cl-substitute}
 function, which works on just the top-level elements of a list.)
 
-@defun subst new old tree @t{&key :test :test-not :key}
+@defun cl-subst new old tree @t{&key :test :test-not :key}
 This function substitutes occurrences of @var{old} with @var{new}
 in @var{tree}, a tree of cons cells.  It returns a substituted
 tree, which will be a copy except that it may share storage with
 the argument @var{tree} in parts where no substitutions occurred.
 The original @var{tree} is not modified.  This function recurses
-on, and compares against @var{old}, both @code{car}s and @code{cdr}s
+on, and compares against @var{old}, both @sc{car}s and @sc{cdr}s
 of the component cons cells.  If @var{old} is itself a cons cell,
 then matching cells in the tree are substituted as usual without
 recursively substituting in that cell.  Comparisons with @var{old}
@@ -4195,126 +3750,126 @@ The @code{:key} function is applied to the elements of the tree
 but not to @var{old}.
 @end defun
 
-@defun nsubst new old tree @t{&key :test :test-not :key}
-This function is like @code{subst}, except that it works by
+@defun cl-nsubst new old tree @t{&key :test :test-not :key}
+This function is like @code{cl-subst}, except that it works by
 destructive modification (by @code{setcar} or @code{setcdr})
 rather than copying.
 @end defun
 
-@findex subst-if
-@findex subst-if-not
-@findex nsubst-if
-@findex nsubst-if-not
-The @code{subst-if}, @code{subst-if-not}, @code{nsubst-if}, and
-@code{nsubst-if-not} functions are defined similarly.
+@findex cl-subst-if
+@findex cl-subst-if-not
+@findex cl-nsubst-if
+@findex cl-nsubst-if-not
+The @code{cl-subst-if}, @code{cl-subst-if-not}, @code{cl-nsubst-if}, and
+@code{cl-nsubst-if-not} functions are defined similarly.
 
-@defun sublis alist tree @t{&key :test :test-not :key}
-This function is like @code{subst}, except that it takes an
+@defun cl-sublis alist tree @t{&key :test :test-not :key}
+This function is like @code{cl-subst}, except that it takes an
 association list @var{alist} of @var{old}-@var{new} pairs.
 Each element of the tree (after applying the @code{:key}
-function, if any), is compared with the @code{car}s of
+function, if any), is compared with the @sc{car}s of
 @var{alist}; if it matches, it is replaced by the corresponding
-@code{cdr}.
+@sc{cdr}.
 @end defun
 
-@defun nsublis alist tree @t{&key :test :test-not :key}
-This is a destructive version of @code{sublis}.
+@defun cl-nsublis alist tree @t{&key :test :test-not :key}
+This is a destructive version of @code{cl-sublis}.
 @end defun
 
 @node Lists as Sets
 @section Lists as Sets
 
 @noindent
-These functions perform operations on lists which represent sets
+These functions perform operations on lists that represent sets
 of elements.
 
-@defun member* item list @t{&key :test :test-not :key}
+@defun cl-member item list @t{&key :test :test-not :key}
 This function searches @var{list} for an element matching @var{item}.
-If a match is found, it returns the cons cell whose @code{car} was
+If a match is found, it returns the cons cell whose @sc{car} was
 the matching element.  Otherwise, it returns @code{nil}.  Elements
 are compared by @code{eql} by default; you can use the @code{:test},
 @code{:test-not}, and @code{:key} arguments to modify this behavior.
 @xref{Sequences}.
 
-Note that this function's name is suffixed by @samp{*} to avoid
-the incompatible @code{member} function defined in Emacs.
-(That function uses @code{equal} for comparisons; it is equivalent
-to @code{(member* @var{item} @var{list} :test 'equal)}.)
+The standard Emacs lisp function @code{member} uses @code{equal} for
+comparisons; it is equivalent to @code{(cl-member @var{item} @var{list}
+:test 'equal)}.  With no keyword arguments, @code{cl-member} is
+equivalent to @code{memq}.
 @end defun
 
-@findex member-if
-@findex member-if-not
-The @code{member-if} and @code{member-if-not} functions
-analogously search for elements which satisfy a given predicate.
+@findex cl-member-if
+@findex cl-member-if-not
+The @code{cl-member-if} and @code{cl-member-if-not} functions
+analogously search for elements that satisfy a given predicate.
 
-@defun tailp sublist list
+@defun cl-tailp sublist list
 This function returns @code{t} if @var{sublist} is a sublist of
 @var{list}, i.e., if @var{sublist} is @code{eql} to @var{list} or to
-any of its @code{cdr}s.
+any of its @sc{cdr}s.
 @end defun
 
-@defun adjoin item list @t{&key :test :test-not :key}
+@defun cl-adjoin item list @t{&key :test :test-not :key}
 This function conses @var{item} onto the front of @var{list},
 like @code{(cons @var{item} @var{list})}, but only if @var{item}
-is not already present on the list (as determined by @code{member*}).
+is not already present on the list (as determined by @code{cl-member}).
 If a @code{:key} argument is specified, it is applied to
 @var{item} as well as to the elements of @var{list} during
 the search, on the reasoning that @var{item} is ``about'' to
 become part of the list.
 @end defun
 
-@defun union list1 list2 @t{&key :test :test-not :key}
-This function combines two lists which represent sets of items,
+@defun cl-union list1 list2 @t{&key :test :test-not :key}
+This function combines two lists that represent sets of items,
 returning a list that represents the union of those two sets.
-The result list will contain all items which appear in @var{list1}
+The resulting list contains all items that appear in @var{list1}
 or @var{list2}, and no others.  If an item appears in both
-@var{list1} and @var{list2} it will be copied only once.  If
+@var{list1} and @var{list2} it is copied only once.  If
 an item is duplicated in @var{list1} or @var{list2}, it is
 undefined whether or not that duplication will survive in the
 result list.  The order of elements in the result list is also
 undefined.
 @end defun
 
-@defun nunion list1 list2 @t{&key :test :test-not :key}
-This is a destructive version of @code{union}; rather than copying,
+@defun cl-nunion list1 list2 @t{&key :test :test-not :key}
+This is a destructive version of @code{cl-union}; rather than copying,
 it tries to reuse the storage of the argument lists if possible.
 @end defun
 
-@defun intersection list1 list2 @t{&key :test :test-not :key}
+@defun cl-intersection list1 list2 @t{&key :test :test-not :key}
 This function computes the intersection of the sets represented
 by @var{list1} and @var{list2}.  It returns the list of items
-which appear in both @var{list1} and @var{list2}.
+that appear in both @var{list1} and @var{list2}.
 @end defun
 
-@defun nintersection list1 list2 @t{&key :test :test-not :key}
-This is a destructive version of @code{intersection}.  It
+@defun cl-nintersection list1 list2 @t{&key :test :test-not :key}
+This is a destructive version of @code{cl-intersection}.  It
 tries to reuse storage of @var{list1} rather than copying.
 It does @emph{not} reuse the storage of @var{list2}.
 @end defun
 
-@defun set-difference list1 list2 @t{&key :test :test-not :key}
+@defun cl-set-difference list1 list2 @t{&key :test :test-not :key}
 This function computes the ``set difference'' of @var{list1}
 and @var{list2}, i.e., the set of elements that appear in
 @var{list1} but @emph{not} in @var{list2}.
 @end defun
 
-@defun nset-difference list1 list2 @t{&key :test :test-not :key}
-This is a destructive @code{set-difference}, which will try
+@defun cl-nset-difference list1 list2 @t{&key :test :test-not :key}
+This is a destructive @code{cl-set-difference}, which will try
 to reuse @var{list1} if possible.
 @end defun
 
-@defun set-exclusive-or list1 list2 @t{&key :test :test-not :key}
+@defun cl-set-exclusive-or list1 list2 @t{&key :test :test-not :key}
 This function computes the ``set exclusive or'' of @var{list1}
 and @var{list2}, i.e., the set of elements that appear in
 exactly one of @var{list1} and @var{list2}.
 @end defun
 
-@defun nset-exclusive-or list1 list2 @t{&key :test :test-not :key}
-This is a destructive @code{set-exclusive-or}, which will try
+@defun cl-nset-exclusive-or list1 list2 @t{&key :test :test-not :key}
+This is a destructive @code{cl-set-exclusive-or}, which will try
 to reuse @var{list1} and @var{list2} if possible.
 @end defun
 
-@defun subsetp list1 list2 @t{&key :test :test-not :key}
+@defun cl-subsetp list1 list2 @t{&key :test :test-not :key}
 This function checks whether @var{list1} represents a subset
 of @var{list2}, i.e., whether every element of @var{list1}
 also appears in @var{list2}.
@@ -4328,39 +3883,39 @@ An @dfn{association list} is a list representing a mapping from
 one set of values to another; any list whose elements are cons
 cells is an association list.
 
-@defun assoc* item a-list @t{&key :test :test-not :key}
+@defun cl-assoc item a-list @t{&key :test :test-not :key}
 This function searches the association list @var{a-list} for an
-element whose @code{car} matches (in the sense of @code{:test},
+element whose @sc{car} matches (in the sense of @code{:test},
 @code{:test-not}, and @code{:key}, or by comparison with @code{eql})
 a given @var{item}.  It returns the matching element, if any,
-otherwise @code{nil}.  It ignores elements of @var{a-list} which
+otherwise @code{nil}.  It ignores elements of @var{a-list} that
 are not cons cells.  (This corresponds to the behavior of
 @code{assq} and @code{assoc} in Emacs Lisp; Common Lisp's
 @code{assoc} ignores @code{nil}s but considers any other non-cons
 elements of @var{a-list} to be an error.)
 @end defun
 
-@defun rassoc* item a-list @t{&key :test :test-not :key}
-This function searches for an element whose @code{cdr} matches
+@defun cl-rassoc item a-list @t{&key :test :test-not :key}
+This function searches for an element whose @sc{cdr} matches
 @var{item}.  If @var{a-list} represents a mapping, this applies
 the inverse of the mapping to @var{item}.
 @end defun
 
-@findex assoc-if
-@findex assoc-if-not
-@findex rassoc-if
-@findex rassoc-if-not
-The @code{assoc-if}, @code{assoc-if-not}, @code{rassoc-if},
-and @code{rassoc-if-not} functions are defined similarly.
+@findex cl-assoc-if
+@findex cl-assoc-if-not
+@findex cl-rassoc-if
+@findex cl-rassoc-if-not
+The @code{cl-assoc-if}, @code{cl-assoc-if-not}, @code{cl-rassoc-if},
+and @code{cl-rassoc-if-not} functions are defined similarly.
 
 Two simple functions for constructing association lists are:
 
-@defun acons key value alist
+@defun cl-acons key value alist
 This is equivalent to @code{(cons (cons @var{key} @var{value}) @var{alist})}.
 @end defun
 
-@defun pairlis keys values &optional alist
-This is equivalent to @code{(nconc (mapcar* 'cons @var{keys} @var{values})
+@defun cl-pairlis keys values &optional alist
+This is equivalent to @code{(nconc (cl-mapcar 'cons @var{keys} @var{values})
 @var{alist})}.
 @end defun
 
@@ -4382,43 +3937,43 @@ system provides no way to create new distinct types, this package
 implements structures as vectors (or lists upon request) with a
 special ``tag'' symbol to identify them.
 
-@defspec defstruct name slots@dots{}
-The @code{defstruct} form defines a new structure type called
+@defmac cl-defstruct name slots@dots{}
+The @code{cl-defstruct} form defines a new structure type called
 @var{name}, with the specified @var{slots}.  (The @var{slots}
 may begin with a string which documents the structure type.)
 In the simplest case, @var{name} and each of the @var{slots}
 are symbols.  For example,
 
 @example
-(defstruct person name age sex)
+(cl-defstruct person name age sex)
 @end example
 
 @noindent
-defines a struct type called @code{person} which contains three
+defines a struct type called @code{person} that contains three
 slots.  Given a @code{person} object @var{p}, you can access those
 slots by calling @code{(person-name @var{p})}, @code{(person-age @var{p})},
 and @code{(person-sex @var{p})}.  You can also change these slots by
-using @code{setf} on any of these place forms:
+using @code{setf} on any of these place forms, for example:
 
 @example
-(incf (person-age birthday-boy))
+(cl-incf (person-age birthday-boy))
 @end example
 
 You can create a new @code{person} by calling @code{make-person},
 which takes keyword arguments @code{:name}, @code{:age}, and
 @code{:sex} to specify the initial values of these slots in the
 new object.  (Omitting any of these arguments leaves the corresponding
-slot ``undefined,'' according to the Common Lisp standard; in Emacs
+slot ``undefined'', according to the Common Lisp standard; in Emacs
 Lisp, such uninitialized slots are filled with @code{nil}.)
 
 Given a @code{person}, @code{(copy-person @var{p})} makes a new
 object of the same type whose slots are @code{eq} to those of @var{p}.
 
 Given any Lisp object @var{x}, @code{(person-p @var{x})} returns
-true if @var{x} looks like a @code{person}, false otherwise.  (Again,
+true if @var{x} looks like a @code{person}, and false otherwise.  (Again,
 in Common Lisp this predicate would be exact; in Emacs Lisp the
 best it can do is verify that @var{x} is a vector of the correct
-length which starts with the correct tag symbol.)
+length that starts with the correct tag symbol.)
 
 Accessors like @code{person-name} normally check their arguments
 (effectively using @code{person-p}) and signal an error if the
@@ -4455,7 +4010,7 @@ In general, @var{name} is either a name symbol or a list of a name
 symbol followed by any number of @dfn{struct options}; each @var{slot}
 is either a slot symbol or a list of the form @samp{(@var{slot-name}
 @var{default-value} @var{slot-options}@dots{})}.  The @var{default-value}
-is a Lisp form which is evaluated any time an instance of the
+is a Lisp form that is evaluated any time an instance of the
 structure type is created without specifying that slot's value.
 
 Common Lisp defines several slot options, but the only one
@@ -4465,10 +4020,10 @@ the slot's value is determined when the object is created and does
 not change afterward.
 
 @example
-(defstruct person
-  (name nil :read-only t)
-  age
-  (sex 'unknown))
+(cl-defstruct person
+     (name nil :read-only t)
+     age
+     (sex 'unknown))
 @end example
 
 Any slot options other than @code{:read-only} are ignored.
@@ -4480,19 +4035,15 @@ by arguments.  (By contrast, slot options are key-value pairs not
 enclosed in lists.)
 
 @example
-(defstruct (person (:constructor create-person)
-                   (:type list)
-                   :named)
-  name age sex)
+(cl-defstruct (person (:constructor create-person)
+                      (:type list)
+                      :named)
+     name age sex)
 @end example
 
 The following structure options are recognized.
 
 @table @code
-@iftex
-@itemmax=0 in
-@advance@leftskip-.5@tableindent
-@end iftex
 @item :conc-name
 The argument is a symbol whose print name is used as the prefix for
 the names of slot accessor functions.  The default is the name of
@@ -4517,11 +4068,11 @@ The argument names should match the slot names; each slot is
 initialized from the corresponding argument.  Slots whose names
 do not appear in the argument list are initialized based on the
 @var{default-value} in their slot descriptor.  Also, @code{&optional}
-and @code{&key} arguments which don't specify defaults take their
+and @code{&key} arguments that don't specify defaults take their
 defaults from the slot descriptor.  It is valid to include arguments
-which don't correspond to slot names; these are useful if they are
+that don't correspond to slot names; these are useful if they are
 referred to in the defaults for optional, keyword, or @code{&aux}
-arguments which @emph{do} correspond to slots.
+arguments that @emph{do} correspond to slots.
 
 You can specify any number of full-format @code{:constructor}
 options on a structure.  The default constructor is still generated
@@ -4529,21 +4080,22 @@ as well unless you disable it with a simple-format @code{:constructor}
 option.
 
 @example
-(defstruct
- (person
-  (:constructor nil)   ; no default constructor
-  (:constructor new-person (name sex &optional (age 0)))
-  (:constructor new-hound (&key (name "Rover")
-                                (dog-years 0)
-                           &aux (age (* 7 dog-years))
-                                (sex 'canine))))
- name age sex)
+(cl-defstruct
+    (person
+     (:constructor nil)   ; no default constructor
+     (:constructor new-person
+                   (name sex &optional (age 0)))
+     (:constructor new-hound (&key (name "Rover")
+                                   (dog-years 0)
+                              &aux (age (* 7 dog-years))
+                                   (sex 'canine))))
+    name age sex)
 @end example
 
 The first constructor here takes its arguments positionally rather
 than by keyword.  (In official Common Lisp terminology, constructors
 that work By Order of Arguments instead of by keyword are called
-``BOA constructors.''  No, I'm not making this up.)  For example,
+``BOA constructors''.  No, I'm not making this up.)  For example,
 @code{(new-person "Jane" 'female)} generates a person whose slots
 are @code{"Jane"}, 0, and @code{female}, respectively.
 
@@ -4561,7 +4113,7 @@ means not to generate a copier function.  (In this implementation,
 all copier functions are simply synonyms for @code{copy-sequence}.)
 
 @item :predicate
-The argument is an alternate name for the predicate which recognizes
+The argument is an alternate name for the predicate that recognizes
 objects of this type.  The default is @code{@var{name}-p}.  @code{nil}
 means not to generate a predicate function.  (If the @code{:type}
 option is used without the @code{:named} option, no predicate is
@@ -4569,14 +4121,14 @@ ever generated.)
 
 In true Common Lisp, @code{typep} is always able to recognize a
 structure object even if @code{:predicate} was used.  In this
-package, @code{typep} simply looks for a function called
+package, @code{cl-typep} simply looks for a function called
 @code{@var{typename}-p}, so it will work for structure types
 only if they used the default predicate name.
 
 @item :include
 This option implements a very limited form of C++-style inheritance.
 The argument is the name of another structure type previously
-created with @code{defstruct}.  The effect is to cause the new
+created with @code{cl-defstruct}.  The effect is to cause the new
 structure type to inherit all of the included structure's slots
 (plus, of course, any new slots described by this struct's slot
 descriptors).  The new structure is considered a ``specialization''
@@ -4589,12 +4141,12 @@ slot descriptors for slots in the included structure, possibly with
 modified default values.  Borrowing an example from Steele:
 
 @example
-(defstruct person name (age 0) sex)
-     @result{} person
-(defstruct (astronaut (:include person (age 45)))
-  helmet-size
-  (favorite-beverage 'tang))
-     @result{} astronaut
+(cl-defstruct person name (age 0) sex)
+        @result{} person
+(cl-defstruct (astronaut (:include person (age 45)))
+     helmet-size
+     (favorite-beverage 'tang))
+        @result{} astronaut
 
 (setq joe (make-person :name "Joe"))
      @result{} [cl-struct-person "Joe" 0 nil]
@@ -4621,7 +4173,7 @@ work on astronauts just like other people.
 
 @item :print-function
 In full Common Lisp, this option allows you to specify a function
-which is called to print an instance of the structure type.  The
+that is called to print an instance of the structure type.  The
 Emacs Lisp system offers no hooks into the Lisp printer which would
 allow for such a feature, so this package simply ignores
 @code{:print-function}.
@@ -4650,9 +4202,9 @@ use named vectors.  Therefore, @code{:named} is only useful in
 conjunction with @code{:type}.
 
 @example
-(defstruct (person1) name age sex)
-(defstruct (person2 (:type list) :named) name age sex)
-(defstruct (person3 (:type list)) name age sex)
+(cl-defstruct (person1) name age sex)
+(cl-defstruct (person2 (:type list) :named) name age sex)
+(cl-defstruct (person3 (:type list)) name age sex)
 
 (setq p1 (make-person1))
      @result{} [cl-struct-person1 nil nil nil]
@@ -4669,7 +4221,7 @@ conjunction with @code{:type}.
      @result{} error: function person3-p undefined
 @end example
 
-Since unnamed structures don't have tags, @code{defstruct} is not
+Since unnamed structures don't have tags, @code{cl-defstruct} is not
 able to make a useful predicate for recognizing them.  Also,
 accessors like @code{person3-name} will be generated but they
 will not be able to do any type checking.  The @code{person3-name}
@@ -4689,594 +4241,879 @@ the type @code{:include}s another type, then @code{:initial-offset}
 specifies a number of slots to be skipped between the last slot
 of the included type and the first new slot.
 @end table
-@end defspec
+@end defmac
 
-Except as noted, the @code{defstruct} facility of this package is
+Except as noted, the @code{cl-defstruct} facility of this package is
 entirely compatible with that of Common Lisp.
 
-@node Assertions
-@chapter Assertions and Errors
+@node Assertions
+@chapter Assertions and Errors
+
+@noindent
+This section describes two macros that test @dfn{assertions}, i.e.,
+conditions which must be true if the program is operating correctly.
+Assertions never add to the behavior of a Lisp program; they simply
+make ``sanity checks'' to make sure everything is as it should be.
+
+If the optimization property @code{speed} has been set to 3, and
+@code{safety} is less than 3, then the byte-compiler will optimize
+away the following assertions.  Because assertions might be optimized
+away, it is a bad idea for them to include side-effects.
+
+@defmac cl-assert test-form [show-args string args@dots{}]
+This form verifies that @var{test-form} is true (i.e., evaluates to
+a non-@code{nil} value).  If so, it returns @code{nil}.  If the test
+is not satisfied, @code{cl-assert} signals an error.
+
+A default error message will be supplied which includes @var{test-form}.
+You can specify a different error message by including a @var{string}
+argument plus optional extra arguments.  Those arguments are simply
+passed to @code{error} to signal the error.
+
+If the optional second argument @var{show-args} is @code{t} instead
+of @code{nil}, then the error message (with or without @var{string})
+will also include all non-constant arguments of the top-level
+@var{form}.  For example:
+
+@example
+(cl-assert (> x 10) t "x is too small: %d")
+@end example
+
+This usage of @var{show-args} is an extension to Common Lisp.  In
+true Common Lisp, the second argument gives a list of @var{places}
+which can be @code{setf}'d by the user before continuing from the
+error.  Since Emacs Lisp does not support continuable errors, it
+makes no sense to specify @var{places}.
+@end defmac
+
+@defmac cl-check-type form type [string]
+This form verifies that @var{form} evaluates to a value of type
+@var{type}.  If so, it returns @code{nil}.  If not, @code{cl-check-type}
+signals a @code{wrong-type-argument} error.  The default error message
+lists the erroneous value along with @var{type} and @var{form}
+themselves.  If @var{string} is specified, it is included in the
+error message in place of @var{type}.  For example:
+
+@example
+(cl-check-type x (integer 1 *) "a positive integer")
+@end example
+
+@xref{Type Predicates}, for a description of the type specifiers
+that may be used for @var{type}.
+
+Note that in Common Lisp, the first argument to @code{check-type}
+must be a @var{place} suitable for use by @code{setf}, because
+@code{check-type} signals a continuable error that allows the
+user to modify @var{place}.
+@end defmac
+
+@node Efficiency Concerns
+@appendix Efficiency Concerns
+
+@appendixsec Macros
+
+@noindent
+Many of the advanced features of this package, such as @code{cl-defun},
+@code{cl-loop}, etc., are implemented as Lisp macros.  In
+byte-compiled code, these complex notations will be expanded into
+equivalent Lisp code which is simple and efficient.  For example,
+the form
+
+@example
+(cl-incf i n)
+@end example
+
+@noindent
+is expanded at compile-time to the Lisp form
+
+@example
+(setq i (+ i n))
+@end example
+
+@noindent
+which is the most efficient ways of doing this operation
+in Lisp.  Thus, there is no performance penalty for using the more
+readable @code{cl-incf} form in your compiled code.
+
+@emph{Interpreted} code, on the other hand, must expand these macros
+every time they are executed.  For this reason it is strongly
+recommended that code making heavy use of macros be compiled.
+A loop using @code{cl-incf} a hundred times will execute considerably
+faster if compiled, and will also garbage-collect less because the
+macro expansion will not have to be generated, used, and thrown away a
+hundred times.
+
+You can find out how a macro expands by using the
+@code{cl-prettyexpand} function.
+
+@defun cl-prettyexpand form &optional full
+This function takes a single Lisp form as an argument and inserts
+a nicely formatted copy of it in the current buffer (which must be
+in Lisp mode so that indentation works properly).  It also expands
+all Lisp macros that appear in the form.  The easiest way to use
+this function is to go to the @file{*scratch*} buffer and type, say,
+
+@example
+(cl-prettyexpand '(cl-loop for x below 10 collect x))
+@end example
+
+@noindent
+and type @kbd{C-x C-e} immediately after the closing parenthesis;
+an expansion similar to:
+
+@example
+(cl-block nil
+     (let* ((x 0)
+            (G1004 nil))
+       (while (< x 10)
+         (setq G1004 (cons x G1004))
+         (setq x (+ x 1)))
+       (nreverse G1004)))
+@end example
+
+@noindent
+will be inserted into the buffer.  (The @code{cl-block} macro is
+expanded differently in the interpreter and compiler, so
+@code{cl-prettyexpand} just leaves it alone.  The temporary
+variable @code{G1004} was created by @code{cl-gensym}.)
+
+If the optional argument @var{full} is true, then @emph{all}
+macros are expanded, including @code{cl-block}, @code{cl-eval-when},
+and compiler macros.  Expansion is done as if @var{form} were
+a top-level form in a file being compiled.
+
+@c FIXME none of these examples are still applicable.
+@ignore
+For example,
+
+@example
+(cl-prettyexpand '(cl-pushnew 'x list))
+     @print{} (setq list (cl-adjoin 'x list))
+(cl-prettyexpand '(cl-pushnew 'x list) t)
+     @print{} (setq list (if (memq 'x list) list (cons 'x list)))
+(cl-prettyexpand '(caddr (cl-member 'a list)) t)
+     @print{} (car (cdr (cdr (memq 'a list))))
+@end example
+@end ignore
+
+Note that @code{cl-adjoin}, @code{cl-caddr}, and @code{cl-member} all
+have built-in compiler macros to optimize them in common cases.
+@end defun
+
+@appendixsec Error Checking
+
+@noindent
+Common Lisp compliance has in general not been sacrificed for the
+sake of efficiency.  A few exceptions have been made for cases
+where substantial gains were possible at the expense of marginal
+incompatibility.
+
+The Common Lisp standard (as embodied in Steele's book) uses the
+phrase ``it is an error if'' to indicate a situation that is not
+supposed to arise in complying programs; implementations are strongly
+encouraged but not required to signal an error in these situations.
+This package sometimes omits such error checking in the interest of
+compactness and efficiency.  For example, @code{cl-do} variable
+specifiers are supposed to be lists of one, two, or three forms;
+extra forms are ignored by this package rather than signaling a
+syntax error.  The @code{cl-endp} function is simply a synonym for
+@code{null} in this package.  Functions taking keyword arguments
+will accept an odd number of arguments, treating the trailing
+keyword as if it were followed by the value @code{nil}.
+
+Argument lists (as processed by @code{cl-defun} and friends)
+@emph{are} checked rigorously except for the minor point just
+mentioned; in particular, keyword arguments are checked for
+validity, and @code{&allow-other-keys} and @code{:allow-other-keys}
+are fully implemented.  Keyword validity checking is slightly
+time consuming (though not too bad in byte-compiled code);
+you can use @code{&allow-other-keys} to omit this check.  Functions
+defined in this package such as @code{cl-find} and @code{cl-member}
+do check their keyword arguments for validity.
+
+@appendixsec Compiler Optimizations
+
+@noindent
+Changing the value of @code{byte-optimize} from the default @code{t}
+is highly discouraged; many of the Common
+Lisp macros emit
+code that can be improved by optimization.  In particular,
+@code{cl-block}s (whether explicit or implicit in constructs like
+@code{cl-defun} and @code{cl-loop}) carry a fair run-time penalty; the
+byte-compiler removes @code{cl-block}s that are not actually
+referenced by @code{cl-return} or @code{cl-return-from} inside the block.
+
+@node Common Lisp Compatibility
+@appendix Common Lisp Compatibility
+
+@noindent
+The following is a list of all known incompatibilities between this
+package and Common Lisp as documented in Steele (2nd edition).
+
+The word @code{cl-defun} is required instead of @code{defun} in order
+to use extended Common Lisp argument lists in a function.  Likewise,
+@code{cl-defmacro} and @code{cl-function} are versions of those forms
+which understand full-featured argument lists.  The @code{&whole}
+keyword does not work in @code{cl-defmacro} argument lists (except
+inside recursive argument lists).
+
+The @code{equal} predicate does not distinguish
+between IEEE floating-point plus and minus zero.  The @code{cl-equalp}
+predicate has several differences with Common Lisp; @pxref{Predicates}.
+
+The @code{cl-do-all-symbols} form is the same as @code{cl-do-symbols}
+with no @var{obarray} argument.  In Common Lisp, this form would
+iterate over all symbols in all packages.  Since Emacs obarrays
+are not a first-class package mechanism, there is no way for
+@code{cl-do-all-symbols} to locate any but the default obarray.
+
+The @code{cl-loop} macro is complete except that @code{loop-finish}
+and type specifiers are unimplemented.
+
+The multiple-value return facility treats lists as multiple
+values, since Emacs Lisp cannot support multiple return values
+directly.  The macros will be compatible with Common Lisp if
+@code{cl-values} or @code{cl-values-list} is always used to return to
+a @code{cl-multiple-value-bind} or other multiple-value receiver;
+if @code{cl-values} is used without @code{cl-multiple-value-@dots{}}
+or vice-versa the effect will be different from Common Lisp.
+
+Many Common Lisp declarations are ignored, and others match
+the Common Lisp standard in concept but not in detail.  For
+example, local @code{special} declarations, which are purely
+advisory in Emacs Lisp, do not rigorously obey the scoping rules
+set down in Steele's book.
+
+The variable @code{cl--gensym-counter} starts out with a pseudo-random
+value rather than with zero.  This is to cope with the fact that
+generated symbols become interned when they are written to and
+loaded back from a file.
+
+The @code{cl-defstruct} facility is compatible, except that structures
+are of type @code{:type vector :named} by default rather than some
+special, distinct type.  Also, the @code{:type} slot option is ignored.
+
+The second argument of @code{cl-check-type} is treated differently.
+
+@node Porting Common Lisp
+@appendix Porting Common Lisp
+
+@noindent
+This package is meant to be used as an extension to Emacs Lisp,
+not as an Emacs implementation of true Common Lisp.  Some of the
+remaining differences between Emacs Lisp and Common Lisp make it
+difficult to port large Common Lisp applications to Emacs.  For
+one, some of the features in this package are not fully compliant
+with ANSI or Steele; @pxref{Common Lisp Compatibility}.  But there
+are also quite a few features that this package does not provide
+at all.  Here are some major omissions that you will want to watch out
+for when bringing Common Lisp code into Emacs.
+
+@itemize @bullet
+@item
+Case-insensitivity.  Symbols in Common Lisp are case-insensitive
+by default.  Some programs refer to a function or variable as
+@code{foo} in one place and @code{Foo} or @code{FOO} in another.
+Emacs Lisp will treat these as three distinct symbols.
+
+Some Common Lisp code is written entirely in upper case.  While Emacs
+is happy to let the program's own functions and variables use
+this convention, calls to Lisp builtins like @code{if} and
+@code{defun} will have to be changed to lower case.
+
+@item
+Lexical scoping.  In Common Lisp, function arguments and @code{let}
+bindings apply only to references physically within their bodies (or
+within macro expansions in their bodies).  Traditionally, Emacs Lisp
+uses @dfn{dynamic scoping} wherein a binding to a variable is visible
+even inside functions called from the body.
+@xref{Dynamic Binding,,,elisp,GNU Emacs Lisp Reference Manual}.
+Lexical binding is available since Emacs 24.1, so be sure to set
+@code{lexical-binding} to @code{t} if you need to emulate this aspect
+of Common Lisp.  @xref{Lexical Binding,,,elisp,GNU Emacs Lisp Reference Manual}.
+
+Here is an example of a Common Lisp code fragment that would fail in
+Emacs Lisp if @code{lexical-binding} were set to @code{nil}:
+
+@example
+(defun map-odd-elements (func list)
+  (loop for x in list
+        for flag = t then (not flag)
+        collect (if flag x (funcall func x))))
+
+(defun add-odd-elements (list x)
+  (map-odd-elements (lambda (a) (+ a x)) list))
+@end example
+
+@noindent
+With lexical binding, the two functions' usages of @code{x} are
+completely independent.  With dynamic binding, the binding to @code{x}
+made by @code{add-odd-elements} will have been hidden by the binding
+in @code{map-odd-elements} by the time the @code{(+ a x)} function is
+called.
+
+Internally, this package uses lexical binding so that such problems do
+not occur.  @xref{Obsolete Lexical Binding}, for a description of the obsolete
+@code{lexical-let} form that emulates a Common Lisp-style lexical
+binding when dynamic binding is in use.
+
+@item
+Reader macros.  Common Lisp includes a second type of macro that
+works at the level of individual characters.  For example, Common
+Lisp implements the quote notation by a reader macro called @code{'},
+whereas Emacs Lisp's parser just treats quote as a special case.
+Some Lisp packages use reader macros to create special syntaxes
+for themselves, which the Emacs parser is incapable of reading.
+
+@item
+Other syntactic features.  Common Lisp provides a number of
+notations beginning with @code{#} that the Emacs Lisp parser
+won't understand.  For example, @samp{#| @dots{} |#} is an
+alternate comment notation, and @samp{#+lucid (foo)} tells
+the parser to ignore the @code{(foo)} except in Lucid Common
+Lisp.
+
+@item
+Packages.  In Common Lisp, symbols are divided into @dfn{packages}.
+Symbols that are Lisp built-ins are typically stored in one package;
+symbols that are vendor extensions are put in another, and each
+application program would have a package for its own symbols.
+Certain symbols are ``exported'' by a package and others are
+internal; certain packages ``use'' or import the exported symbols
+of other packages.  To access symbols that would not normally be
+visible due to this importing and exporting, Common Lisp provides
+a syntax like @code{package:symbol} or @code{package::symbol}.
+
+Emacs Lisp has a single namespace for all interned symbols, and
+then uses a naming convention of putting a prefix like @code{cl-}
+in front of the name.  Some Emacs packages adopt the Common Lisp-like
+convention of using @code{cl:} or @code{cl::} as the prefix.
+However, the Emacs parser does not understand colons and just
+treats them as part of the symbol name.  Thus, while @code{mapcar}
+and @code{lisp:mapcar} may refer to the same symbol in Common
+Lisp, they are totally distinct in Emacs Lisp.  Common Lisp
+programs that refer to a symbol by the full name sometimes
+and the short name other times will not port cleanly to Emacs.
+
+Emacs Lisp does have a concept of ``obarrays'', which are
+package-like collections of symbols, but this feature is not
+strong enough to be used as a true package mechanism.
+
+@item
+The @code{format} function is quite different between Common
+Lisp and Emacs Lisp.  It takes an additional ``destination''
+argument before the format string.  A destination of @code{nil}
+means to format to a string as in Emacs Lisp; a destination
+of @code{t} means to write to the terminal (similar to
+@code{message} in Emacs).  Also, format control strings are
+utterly different; @code{~} is used instead of @code{%} to
+introduce format codes, and the set of available codes is
+much richer.  There are no notations like @code{\n} for
+string literals; instead, @code{format} is used with the
+``newline'' format code, @code{~%}.  More advanced formatting
+codes provide such features as paragraph filling, case
+conversion, and even loops and conditionals.
+
+While it would have been possible to implement most of Common
+Lisp @code{format} in this package (under the name @code{cl-format},
+of course), it was not deemed worthwhile.  It would have required
+a huge amount of code to implement even a decent subset of
+@code{format}, yet the functionality it would provide over
+Emacs Lisp's @code{format} would rarely be useful.
+
+@item
+Vector constants use square brackets in Emacs Lisp, but
+@code{#(a b c)} notation in Common Lisp.  To further complicate
+matters, Emacs has its own @code{#(} notation for
+something entirely different---strings with properties.
+
+@item
+Characters are distinct from integers in Common Lisp.  The notation
+for character constants is also different: @code{#\A} in Common Lisp
+where Emacs Lisp uses @code{?A}.  Also, @code{string=} and
+@code{string-equal} are synonyms in Emacs Lisp, whereas the latter is
+case-insensitive in Common Lisp.
 
-@noindent
-This section describes two macros that test @dfn{assertions}, i.e.,
-conditions which must be true if the program is operating correctly.
-Assertions never add to the behavior of a Lisp program; they simply
-make ``sanity checks'' to make sure everything is as it should be.
+@item
+Data types.  Some Common Lisp data types do not exist in Emacs
+Lisp.  Rational numbers and complex numbers are not present,
+nor are large integers (all integers are ``fixnums'').  All
+arrays are one-dimensional.  There are no readtables or pathnames;
+streams are a set of existing data types rather than a new data
+type of their own.  Hash tables, random-states, structures, and
+packages (obarrays) are built from Lisp vectors or lists rather
+than being distinct types.
 
-If the optimization property @code{speed} has been set to 3, and
-@code{safety} is less than 3, then the byte-compiler will optimize
-away the following assertions.  Because assertions might be optimized
-away, it is a bad idea for them to include side-effects.
+@item
+The Common Lisp Object System (CLOS) is not implemented,
+nor is the Common Lisp Condition System.  However, the EIEIO package
+(@pxref{Top, , Introduction, eieio, EIEIO}) does implement some
+CLOS functionality.
 
-@defspec assert test-form [show-args string args@dots{}]
-This form verifies that @var{test-form} is true (i.e., evaluates to
-a non-@code{nil} value).  If so, it returns @code{nil}.  If the test
-is not satisfied, @code{assert} signals an error.
+@item
+Common Lisp features that are completely redundant with Emacs
+Lisp features of a different name generally have not been
+implemented.  For example, Common Lisp writes @code{defconstant}
+where Emacs Lisp uses @code{defconst}.  Similarly, @code{make-list}
+takes its arguments in different ways in the two Lisps but does
+exactly the same thing, so this package has not bothered to
+implement a Common Lisp-style @code{make-list}.
 
-A default error message will be supplied which includes @var{test-form}.
-You can specify a different error message by including a @var{string}
-argument plus optional extra arguments.  Those arguments are simply
-passed to @code{error} to signal the error.
+@item
+A few more notable Common Lisp features not included in this
+package:  @code{compiler-let}, @code{tagbody}, @code{prog},
+@code{ldb/dpb}, @code{parse-integer}, @code{cerror}.
 
-If the optional second argument @var{show-args} is @code{t} instead
-of @code{nil}, then the error message (with or without @var{string})
-will also include all non-constant arguments of the top-level
-@var{form}.  For example:
+@item
+Recursion.  While recursion works in Emacs Lisp just like it
+does in Common Lisp, various details of the Emacs Lisp system
+and compiler make recursion much less efficient than it is in
+most Lisps.  Some schools of thought prefer to use recursion
+in Lisp over other techniques; they would sum a list of
+numbers using something like
 
 @example
-(assert (> x 10) t "x is too small: %d")
+(defun sum-list (list)
+  (if list
+      (+ (car list) (sum-list (cdr list)))
+    0))
 @end example
 
-This usage of @var{show-args} is an extension to Common Lisp.  In
-true Common Lisp, the second argument gives a list of @var{places}
-which can be @code{setf}'d by the user before continuing from the
-error.  Since Emacs Lisp does not support continuable errors, it
-makes no sense to specify @var{places}.
-@end defspec
-
-@defspec check-type form type [string]
-This form verifies that @var{form} evaluates to a value of type
-@var{type}.  If so, it returns @code{nil}.  If not, @code{check-type}
-signals a @code{wrong-type-argument} error.  The default error message
-lists the erroneous value along with @var{type} and @var{form}
-themselves.  If @var{string} is specified, it is included in the
-error message in place of @var{type}.  For example:
+@noindent
+where a more iteratively-minded programmer might write one of
+these forms:
 
 @example
-(check-type x (integer 1 *) "a positive integer")
+(let ((total 0)) (dolist (x my-list) (incf total x)) total)
+(loop for x in my-list sum x)
 @end example
 
-@xref{Type Predicates}, for a description of the type specifiers
-that may be used for @var{type}.
-
-Note that in Common Lisp, the first argument to @code{check-type}
-must be a @var{place} suitable for use by @code{setf}, because
-@code{check-type} signals a continuable error that allows the
-user to modify @var{place}.
-@end defspec
+While this would be mainly a stylistic choice in most Common Lisps,
+in Emacs Lisp you should be aware that the iterative forms are
+much faster than recursion.  Also, Lisp programmers will want to
+note that the current Emacs Lisp compiler does not optimize tail
+recursion.
+@end itemize
 
-The following error-related macro is also defined:
+@node Obsolete Features
+@appendix Obsolete Features
 
-@defspec ignore-errors forms@dots{}
-This executes @var{forms} exactly like a @code{progn}, except that
-errors are ignored during the @var{forms}.  More precisely, if
-an error is signaled then @code{ignore-errors} immediately
-aborts execution of the @var{forms} and returns @code{nil}.
-If the @var{forms} complete successfully, @code{ignore-errors}
-returns the result of the last @var{form}.
-@end defspec
+This section describes some features of the package that are obsolete
+and should not be used in new code.  They are either only provided by
+the old @file{cl.el} entry point, not by the newer @file{cl-lib.el};
+or where versions with a @samp{cl-} prefix do exist they do not behave
+in exactly the same way.
 
-@node Efficiency Concerns
-@appendix Efficiency Concerns
+@menu
+* Obsolete Lexical Binding::    An approximation of lexical binding.
+* Obsolete Macros::             Obsolete macros.
+* Obsolete Setf Customization:: Obsolete ways to customize setf.
+@end menu
 
-@appendixsec Macros
+@node Obsolete Lexical Binding
+@appendixsec Obsolete Lexical Binding
 
-@noindent
-Many of the advanced features of this package, such as @code{defun*},
-@code{loop}, and @code{setf}, are implemented as Lisp macros.  In
-byte-compiled code, these complex notations will be expanded into
-equivalent Lisp code which is simple and efficient.  For example,
-the forms
+The following macros are extensions to Common Lisp, where all bindings
+are lexical unless declared otherwise.  These features are likewise
+obsolete since the introduction of true lexical binding in Emacs 24.1.
 
-@example
-(incf i n)
-(push x (car p))
-@end example
+@defmac lexical-let (bindings@dots{}) forms@dots{}
+This form is exactly like @code{let} except that the bindings it
+establishes are purely lexical.
+@end defmac
 
+@c FIXME remove this and refer to elisp manual.
+@c Maybe merge some stuff from here to there?
 @noindent
-are expanded at compile-time to the Lisp forms
+Lexical bindings are similar to local variables in a language like C:
+Only the code physically within the body of the @code{lexical-let}
+(after macro expansion) may refer to the bound variables.
 
 @example
-(setq i (+ i n))
-(setcar p (cons x (car p)))
+(setq a 5)
+(defun foo (b) (+ a b))
+(let ((a 2)) (foo a))
+     @result{} 4
+(lexical-let ((a 2)) (foo a))
+     @result{} 7
 @end example
 
 @noindent
-which are the most efficient ways of doing these respective operations
-in Lisp.  Thus, there is no performance penalty for using the more
-readable @code{incf} and @code{push} forms in your compiled code.
-
-@emph{Interpreted} code, on the other hand, must expand these macros
-every time they are executed.  For this reason it is strongly
-recommended that code making heavy use of macros be compiled.
-(The features labeled ``Special Form'' instead of ``Function'' in
-this manual are macros.)  A loop using @code{incf} a hundred times
-will execute considerably faster if compiled, and will also
-garbage-collect less because the macro expansion will not have
-to be generated, used, and thrown away a hundred times.
-
-You can find out how a macro expands by using the
-@code{cl-prettyexpand} function.
+In this example, a regular @code{let} binding of @code{a} actually
+makes a temporary change to the global variable @code{a}, so @code{foo}
+is able to see the binding of @code{a} to 2.  But @code{lexical-let}
+actually creates a distinct local variable @code{a} for use within its
+body, without any effect on the global variable of the same name.
 
-@defun cl-prettyexpand form &optional full
-This function takes a single Lisp form as an argument and inserts
-a nicely formatted copy of it in the current buffer (which must be
-in Lisp mode so that indentation works properly).  It also expands
-all Lisp macros which appear in the form.  The easiest way to use
-this function is to go to the @code{*scratch*} buffer and type, say,
+The most important use of lexical bindings is to create @dfn{closures}.
+A closure is a function object that refers to an outside lexical
+variable (@pxref{Closures,,,elisp,GNU Emacs Lisp Reference Manual}).
+For example:
 
 @example
-(cl-prettyexpand '(loop for x below 10 collect x))
+(defun make-adder (n)
+  (lexical-let ((n n))
+    (function (lambda (m) (+ n m)))))
+(setq add17 (make-adder 17))
+(funcall add17 4)
+     @result{} 21
 @end example
 
 @noindent
-and type @kbd{C-x C-e} immediately after the closing parenthesis;
-the expansion
+The call @code{(make-adder 17)} returns a function object which adds
+17 to its argument.  If @code{let} had been used instead of
+@code{lexical-let}, the function object would have referred to the
+global @code{n}, which would have been bound to 17 only during the
+call to @code{make-adder} itself.
 
 @example
-(block nil
-  (let* ((x 0)
-         (G1004 nil))
-    (while (< x 10)
-      (setq G1004 (cons x G1004))
-      (setq x (+ x 1)))
-    (nreverse G1004)))
+(defun make-counter ()
+  (lexical-let ((n 0))
+    (cl-function (lambda (&optional (m 1)) (cl-incf n m)))))
+(setq count-1 (make-counter))
+(funcall count-1 3)
+     @result{} 3
+(funcall count-1 14)
+     @result{} 17
+(setq count-2 (make-counter))
+(funcall count-2 5)
+     @result{} 5
+(funcall count-1 2)
+     @result{} 19
+(funcall count-2)
+     @result{} 6
 @end example
 
 @noindent
-will be inserted into the buffer.  (The @code{block} macro is
-expanded differently in the interpreter and compiler, so
-@code{cl-prettyexpand} just leaves it alone.  The temporary
-variable @code{G1004} was created by @code{gensym}.)
+Here we see that each call to @code{make-counter} creates a distinct
+local variable @code{n}, which serves as a private counter for the
+function object that is returned.
 
-If the optional argument @var{full} is true, then @emph{all}
-macros are expanded, including @code{block}, @code{eval-when},
-and compiler macros.  Expansion is done as if @var{form} were
-a top-level form in a file being compiled.  For example,
+Closed-over lexical variables persist until the last reference to
+them goes away, just like all other Lisp objects.  For example,
+@code{count-2} refers to a function object which refers to an
+instance of the variable @code{n}; this is the only reference
+to that variable, so after @code{(setq count-2 nil)} the garbage
+collector would be able to delete this instance of @code{n}.
+Of course, if a @code{lexical-let} does not actually create any
+closures, then the lexical variables are free as soon as the
+@code{lexical-let} returns.
+
+Many closures are used only during the extent of the bindings they
+refer to; these are known as ``downward funargs'' in Lisp parlance.
+When a closure is used in this way, regular Emacs Lisp dynamic
+bindings suffice and will be more efficient than @code{lexical-let}
+closures:
 
 @example
-(cl-prettyexpand '(pushnew 'x list))
-     @print{} (setq list (adjoin 'x list))
-(cl-prettyexpand '(pushnew 'x list) t)
-     @print{} (setq list (if (memq 'x list) list (cons 'x list)))
-(cl-prettyexpand '(caddr (member* 'a list)) t)
-     @print{} (car (cdr (cdr (memq 'a list))))
+(defun add-to-list (x list)
+  (mapcar (lambda (y) (+ x y))) list)
+(add-to-list 7 '(1 2 5))
+     @result{} (8 9 12)
 @end example
 
-Note that @code{adjoin}, @code{caddr}, and @code{member*} all
-have built-in compiler macros to optimize them in common cases.
-@end defun
+@noindent
+Since this lambda is only used while @code{x} is still bound,
+it is not necessary to make a true closure out of it.
 
-@ifinfo
-@example
+You can use @code{defun} or @code{flet} inside a @code{lexical-let}
+to create a named closure.  If several closures are created in the
+body of a single @code{lexical-let}, they all close over the same
+instance of the lexical variable.
 
-@end example
-@end ifinfo
-@appendixsec Error Checking
+@defmac lexical-let* (bindings@dots{}) forms@dots{}
+This form is just like @code{lexical-let}, except that the bindings
+are made sequentially in the manner of @code{let*}.
+@end defmac
 
-@noindent
-Common Lisp compliance has in general not been sacrificed for the
-sake of efficiency.  A few exceptions have been made for cases
-where substantial gains were possible at the expense of marginal
-incompatibility.
+@node Obsolete Macros
+@appendixsec Obsolete Macros
 
-The Common Lisp standard (as embodied in Steele's book) uses the
-phrase ``it is an error if'' to indicate a situation which is not
-supposed to arise in complying programs; implementations are strongly
-encouraged but not required to signal an error in these situations.
-This package sometimes omits such error checking in the interest of
-compactness and efficiency.  For example, @code{do} variable
-specifiers are supposed to be lists of one, two, or three forms;
-extra forms are ignored by this package rather than signaling a
-syntax error.  The @code{endp} function is simply a synonym for
-@code{null} in this package.  Functions taking keyword arguments
-will accept an odd number of arguments, treating the trailing
-keyword as if it were followed by the value @code{nil}.
+The following macros are obsolete, and are replaced by versions with
+a @samp{cl-} prefix that do not behave in exactly the same way.
+Consequently, the @file{cl.el} versions are not simply aliases to the
+@file{cl-lib.el} versions.
 
-Argument lists (as processed by @code{defun*} and friends)
-@emph{are} checked rigorously except for the minor point just
-mentioned; in particular, keyword arguments are checked for
-validity, and @code{&allow-other-keys} and @code{:allow-other-keys}
-are fully implemented.  Keyword validity checking is slightly
-time consuming (though not too bad in byte-compiled code);
-you can use @code{&allow-other-keys} to omit this check.  Functions
-defined in this package such as @code{find} and @code{member*}
-do check their keyword arguments for validity.
+@defmac flet (bindings@dots{}) forms@dots{}
+This macro is replaced by @code{cl-flet} (@pxref{Function Bindings}),
+which behaves the same way as Common Lisp's @code{flet}.
+This @code{flet} takes the same arguments as @code{cl-flet}, but does
+not behave in precisely the same way.
 
-@ifinfo
-@example
+While @code{flet} in Common Lisp establishes a lexical function
+binding, this @code{flet} makes a dynamic binding (it dates from a
+time before Emacs had lexical binding).  The result is
+that @code{flet} affects indirect calls to a function as well as calls
+directly inside the @code{flet} form itself.
 
+This will even work on Emacs primitives, although note that some calls
+to primitive functions internal to Emacs are made without going
+through the symbol's function cell, and so will not be affected by
+@code{flet}.  For example,
+
+@example
+(flet ((message (&rest args) (push args saved-msgs)))
+  (do-something))
 @end example
-@end ifinfo
-@appendixsec Optimizing Compiler
 
-@noindent
-Use of the optimizing Emacs compiler is highly recommended; many of the Common
-Lisp macros emit
-code which can be improved by optimization.  In particular,
-@code{block}s (whether explicit or implicit in constructs like
-@code{defun*} and @code{loop}) carry a fair run-time penalty; the
-optimizing compiler removes @code{block}s which are not actually
-referenced by @code{return} or @code{return-from} inside the block.
+This code attempts to replace the built-in function @code{message}
+with a function that simply saves the messages in a list rather
+than displaying them.  The original definition of @code{message}
+will be restored after @code{do-something} exits.  This code will
+work fine on messages generated by other Lisp code, but messages
+generated directly inside Emacs will not be caught since they make
+direct C-language calls to the message routines rather than going
+through the Lisp @code{message} function.
 
-@node Common Lisp Compatibility
-@appendix Common Lisp Compatibility
+@c Bug#411.
+Note that many primitives (e.g., @code{+}) have special byte-compile
+handling.  Attempts to redefine such functions using @code{flet} will
+fail if byte-compiled.
+@c Or cl-flet.
+@c In such cases, use @code{labels} instead.
+@end defmac
 
-@noindent
-Following is a list of all known incompatibilities between this
-package and Common Lisp as documented in Steele (2nd edition).
+@defmac labels (bindings@dots{}) forms@dots{}
+This macro is replaced by @code{cl-labels} (@pxref{Function Bindings}),
+which behaves the same way as Common Lisp's @code{labels}.
+This @code{labels} takes the same arguments as @code{cl-labels}, but
+does not behave in precisely the same way.
 
-Certain function names, such as @code{member}, @code{assoc}, and
-@code{floor}, were already taken by (incompatible) Emacs Lisp
-functions; this package appends @samp{*} to the names of its
-Common Lisp versions of these functions.
+This version of @code{labels} uses the obsolete @code{lexical-let}
+form (@pxref{Obsolete Lexical Binding}), rather than the true
+lexical binding that @code{cl-labels} uses.
+@end defmac
 
-The word @code{defun*} is required instead of @code{defun} in order
-to use extended Common Lisp argument lists in a function.  Likewise,
-@code{defmacro*} and @code{function*} are versions of those forms
-which understand full-featured argument lists.  The @code{&whole}
-keyword does not work in @code{defmacro} argument lists (except
-inside recursive argument lists).
+@node Obsolete Setf Customization
+@appendixsec Obsolete Ways to Customize Setf
 
-The @code{equal} predicate does not distinguish
-between IEEE floating-point plus and minus zero.  The @code{equalp}
-predicate has several differences with Common Lisp; @pxref{Predicates}.
+Common Lisp defines three macros, @code{define-modify-macro},
+@code{defsetf}, and @code{define-setf-method}, that allow the
+user to extend generalized variables in various ways.
+In Emacs, these are obsolete, replaced by various features of
+@file{gv.el} in Emacs 24.3.
+@xref{Adding Generalized Variables,,,elisp,GNU Emacs Lisp Reference Manual}.
+
+
+@defmac define-modify-macro name arglist function [doc-string]
+This macro defines a ``read-modify-write'' macro similar to
+@code{cl-incf} and @code{cl-decf}.  You can replace this macro
+with @code{gv-letplace}.
 
-The @code{setf} mechanism is entirely compatible, except that
-setf-methods return a list of five values rather than five
-values directly.  Also, the new ``@code{setf} function'' concept
-(typified by @code{(defun (setf foo) @dots{})}) is not implemented.
+The macro @var{name} is defined to take a @var{place} argument
+followed by additional arguments described by @var{arglist}.  The call
 
-The @code{do-all-symbols} form is the same as @code{do-symbols}
-with no @var{obarray} argument.  In Common Lisp, this form would
-iterate over all symbols in all packages.  Since Emacs obarrays
-are not a first-class package mechanism, there is no way for
-@code{do-all-symbols} to locate any but the default obarray.
+@example
+(@var{name} @var{place} @var{args}@dots{})
+@end example
 
-The @code{loop} macro is complete except that @code{loop-finish}
-and type specifiers are unimplemented.
+@noindent
+will be expanded to
 
-The multiple-value return facility treats lists as multiple
-values, since Emacs Lisp cannot support multiple return values
-directly.  The macros will be compatible with Common Lisp if
-@code{values} or @code{values-list} is always used to return to
-a @code{multiple-value-bind} or other multiple-value receiver;
-if @code{values} is used without @code{multiple-value-@dots{}}
-or vice-versa the effect will be different from Common Lisp.
+@example
+(cl-callf @var{func} @var{place} @var{args}@dots{})
+@end example
 
-Many Common Lisp declarations are ignored, and others match
-the Common Lisp standard in concept but not in detail.  For
-example, local @code{special} declarations, which are purely
-advisory in Emacs Lisp, do not rigorously obey the scoping rules
-set down in Steele's book.
+@noindent
+which in turn is roughly equivalent to
 
-The variable @code{*gensym-counter*} starts out with a pseudo-random
-value rather than with zero.  This is to cope with the fact that
-generated symbols become interned when they are written to and
-loaded back from a file.
+@example
+(setf @var{place} (@var{func} @var{place} @var{args}@dots{}))
+@end example
 
-The @code{defstruct} facility is compatible, except that structures
-are of type @code{:type vector :named} by default rather than some
-special, distinct type.  Also, the @code{:type} slot option is ignored.
+For example:
 
-The second argument of @code{check-type} is treated differently.
+@example
+(define-modify-macro incf (&optional (n 1)) +)
+(define-modify-macro concatf (&rest args) concat)
+@end example
 
-@node Old CL Compatibility
-@appendix Old CL Compatibility
+Note that @code{&key} is not allowed in @var{arglist}, but
+@code{&rest} is sufficient to pass keywords on to the function.
 
-@noindent
-Following is a list of all known incompatibilities between this package
-and the older Quiroz @file{cl.el} package.
-
-This package's emulation of multiple return values in functions is
-incompatible with that of the older package.  That package attempted
-to come as close as possible to true Common Lisp multiple return
-values; unfortunately, it could not be 100% reliable and so was prone
-to occasional surprises if used freely.  This package uses a simpler
-method, namely replacing multiple values with lists of values, which
-is more predictable though more noticeably different from Common Lisp.
-
-The @code{defkeyword} form and @code{keywordp} function are not
-implemented in this package.
-
-The @code{member}, @code{floor}, @code{ceiling}, @code{truncate},
-@code{round}, @code{mod}, and @code{rem} functions are suffixed
-by @samp{*} in this package to avoid collision with existing
-functions in Emacs.  The older package simply
-redefined these functions, overwriting the built-in meanings and
-causing serious portability problems.  (Some more
-recent versions of the Quiroz package changed the names to
-@code{cl-member}, etc.; this package defines the latter names as
-aliases for @code{member*}, etc.)
-
-Certain functions in the old package which were buggy or inconsistent
-with the Common Lisp standard are incompatible with the conforming
-versions in this package.  For example, @code{eql} and @code{member}
-were synonyms for @code{eq} and @code{memq} in that package, @code{setf}
-failed to preserve correct order of evaluation of its arguments, etc.
-
-Finally, unlike the older package, this package is careful to
-prefix all of its internal names with @code{cl-}.  Except for a
-few functions which are explicitly defined as additional features
-(such as @code{floatp-safe} and @code{letf}), this package does not
-export any non-@samp{cl-} symbols which are not also part of Common
-Lisp.
+Most of the modify macros defined by Common Lisp do not exactly
+follow the pattern of @code{define-modify-macro}.  For example,
+@code{push} takes its arguments in the wrong order, and @code{pop}
+is completely irregular.
 
-@ifinfo
+The above @code{incf} example could be written using
+@code{gv-letplace} as:
 @example
+(defmacro incf (place &optional n)
+  (gv-letplace (getter setter) place
+    (macroexp-let2 nil v (or n 1)
+      (funcall setter `(+ ,v ,getter)))))
+@end example
+@ignore
+(defmacro concatf (place &rest args)
+  (gv-letplace (getter setter) place
+    (macroexp-let2 nil v (mapconcat 'identity args "")
+      (funcall setter `(concat ,getter ,v)))))
+@end ignore
+@end defmac
+
+@defmac defsetf access-fn update-fn
+This is the simpler of two @code{defsetf} forms, and is
+replaced by @code{gv-define-simple-setter}.
+
+With @var{access-fn} the name of a function that accesses a place,
+this declares @var{update-fn} to be the corresponding store function.
+From now on,
 
+@example
+(setf (@var{access-fn} @var{arg1} @var{arg2} @var{arg3}) @var{value})
 @end example
-@end ifinfo
-@appendixsec The @code{cl-compat} package
 
 @noindent
-The @code{CL} package includes emulations of some features of the
-old @file{cl.el}, in the form of a compatibility package
-@code{cl-compat}.  This file is obsolete and may be removed in future,
-so it should not be used in new code.
-
-The old package defined a number of internal routines without
-@code{cl-} prefixes or other annotations.  Call to these routines
-may have crept into existing Lisp code.  @code{cl-compat}
-provides emulations of the following internal routines:
-@code{pair-with-newsyms}, @code{zip-lists}, @code{unzip-lists},
-@code{reassemble-arglists}, @code{duplicate-symbols-p},
-@code{safe-idiv}.
-
-Some @code{setf} forms translated into calls to internal
-functions that user code might call directly.  The functions
-@code{setnth}, @code{setnthcdr}, and @code{setelt} fall in
-this category; they are defined by @code{cl-compat}, but the
-best fix is to change to use @code{setf} properly.
-
-The @code{cl-compat} file defines the keyword functions
-@code{keywordp}, @code{keyword-of}, and @code{defkeyword},
-which are not defined by the new @code{CL} package because the
-use of keywords as data is discouraged.
-
-The @code{build-klist} mechanism for parsing keyword arguments
-is emulated by @code{cl-compat}; the @code{with-keyword-args}
-macro is not, however, and in any case it's best to change to
-use the more natural keyword argument processing offered by
-@code{defun*}.
-
-Multiple return values are treated differently by the two
-Common Lisp packages.  The old package's method was more
-compatible with true Common Lisp, though it used heuristics
-that caused it to report spurious multiple return values in
-certain cases.  The @code{cl-compat} package defines a set
-of multiple-value macros that are compatible with the old
-CL package; again, they are heuristic in nature, but they
-are guaranteed to work in any case where the old package's
-macros worked.  To avoid name collision with the ``official''
-multiple-value facilities, the ones in @code{cl-compat} have
-capitalized names:  @code{Values}, @code{Values-list},
-@code{Multiple-value-bind}, etc.
-
-The functions @code{cl-floor}, @code{cl-ceiling}, @code{cl-truncate},
-and @code{cl-round} are defined by @code{cl-compat} to use the
-old-style multiple-value mechanism, just as they did in the old
-package.  The newer @code{floor*} and friends return their two
-results in a list rather than as multiple values.  Note that
-older versions of the old package used the unadorned names
-@code{floor}, @code{ceiling}, etc.; @code{cl-compat} cannot use
-these names because they conflict with Emacs built-ins.
+will be expanded to
 
-@node Porting Common Lisp
-@appendix Porting Common Lisp
+@example
+(@var{update-fn} @var{arg1} @var{arg2} @var{arg3} @var{value})
+@end example
 
 @noindent
-This package is meant to be used as an extension to Emacs Lisp,
-not as an Emacs implementation of true Common Lisp.  Some of the
-remaining differences between Emacs Lisp and Common Lisp make it
-difficult to port large Common Lisp applications to Emacs.  For
-one, some of the features in this package are not fully compliant
-with ANSI or Steele; @pxref{Common Lisp Compatibility}.  But there
-are also quite a few features that this package does not provide
-at all.  Here are some major omissions that you will want to watch out
-for when bringing Common Lisp code into Emacs.
+The @var{update-fn} is required to be either a true function, or
+a macro that evaluates its arguments in a function-like way.  Also,
+the @var{update-fn} is expected to return @var{value} as its result.
+Otherwise, the above expansion would not obey the rules for the way
+@code{setf} is supposed to behave.
 
-@itemize @bullet
-@item
-Case-insensitivity.  Symbols in Common Lisp are case-insensitive
-by default.  Some programs refer to a function or variable as
-@code{foo} in one place and @code{Foo} or @code{FOO} in another.
-Emacs Lisp will treat these as three distinct symbols.
+As a special (non-Common-Lisp) extension, a third argument of @code{t}
+to @code{defsetf} says that the return value of @code{update-fn} is
+not suitable, so that the above @code{setf} should be expanded to
+something more like
 
-Some Common Lisp code is written entirely in upper case.  While Emacs
-is happy to let the program's own functions and variables use
-this convention, calls to Lisp builtins like @code{if} and
-@code{defun} will have to be changed to lower case.
+@example
+(let ((temp @var{value}))
+  (@var{update-fn} @var{arg1} @var{arg2} @var{arg3} temp)
+  temp)
+@end example
 
-@item
-Lexical scoping.  In Common Lisp, function arguments and @code{let}
-bindings apply only to references physically within their bodies
-(or within macro expansions in their bodies).  Emacs Lisp, by
-contrast, uses @dfn{dynamic scoping} wherein a binding to a
-variable is visible even inside functions called from the body.
+Some examples are:
 
-Variables in Common Lisp can be made dynamically scoped by
-declaring them @code{special} or using @code{defvar}.  In Emacs
-Lisp it is as if all variables were declared @code{special}.
+@example
+(defsetf car setcar)
+(defsetf buffer-name rename-buffer t)
+@end example
 
-Often you can use code that was written for lexical scoping
-even in a dynamically scoped Lisp, but not always.  Here is
-an example of a Common Lisp code fragment that would fail in
-Emacs Lisp:
+These translate directly to @code{gv-define-simple-setter}:
 
 @example
-(defun map-odd-elements (func list)
-  (loop for x in list
-        for flag = t then (not flag)
-        collect (if flag x (funcall func x))))
-
-(defun add-odd-elements (list x)
-  (map-odd-elements (lambda (a) (+ a x)) list))
+(gv-define-simple-setter car setcar)
+(gv-define-simple-setter buffer-name rename-buffer t)
 @end example
+@end defmac
 
-@noindent
-In Common Lisp, the two functions' usages of @code{x} are completely
-independent.  In Emacs Lisp, the binding to @code{x} made by
-@code{add-odd-elements} will have been hidden by the binding
-in @code{map-odd-elements} by the time the @code{(+ a x)} function
-is called.
+@defmac defsetf access-fn arglist (store-var) forms@dots{}
+This is the second, more complex, form of @code{defsetf}.
+It can be replaced by @code{gv-define-setter}.
 
-(This package avoids such problems in its own mapping functions
-by using names like @code{cl-x} instead of @code{x} internally;
-as long as you don't use the @code{cl-} prefix for your own
-variables no collision can occur.)
+This form of @code{defsetf} is rather like @code{defmacro} except for
+the additional @var{store-var} argument.  The @var{forms} should
+return a Lisp form that stores the value of @var{store-var} into the
+generalized variable formed by a call to @var{access-fn} with
+arguments described by @var{arglist}.  The @var{forms} may begin with
+a string which documents the @code{setf} method (analogous to the doc
+string that appears at the front of a function).
 
-@xref{Lexical Bindings}, for a description of the @code{lexical-let}
-form which establishes a Common Lisp-style lexical binding, and some
-examples of how it differs from Emacs's regular @code{let}.
+For example, the simple form of @code{defsetf} is shorthand for
 
-@item
-Reader macros.  Common Lisp includes a second type of macro that
-works at the level of individual characters.  For example, Common
-Lisp implements the quote notation by a reader macro called @code{'},
-whereas Emacs Lisp's parser just treats quote as a special case.
-Some Lisp packages use reader macros to create special syntaxes
-for themselves, which the Emacs parser is incapable of reading.
+@example
+(defsetf @var{access-fn} (&rest args) (store)
+  (append '(@var{update-fn}) args (list store)))
+@end example
 
-@item
-Other syntactic features.  Common Lisp provides a number of
-notations beginning with @code{#} that the Emacs Lisp parser
-won't understand.  For example, @samp{#| ... |#} is an
-alternate comment notation, and @samp{#+lucid (foo)} tells
-the parser to ignore the @code{(foo)} except in Lucid Common
-Lisp.
+The Lisp form that is returned can access the arguments from
+@var{arglist} and @var{store-var} in an unrestricted fashion;
+macros like @code{cl-incf} that invoke this
+setf-method will insert temporary variables as needed to make
+sure the apparent order of evaluation is preserved.
 
-@item
-Packages.  In Common Lisp, symbols are divided into @dfn{packages}.
-Symbols that are Lisp built-ins are typically stored in one package;
-symbols that are vendor extensions are put in another, and each
-application program would have a package for its own symbols.
-Certain symbols are ``exported'' by a package and others are
-internal; certain packages ``use'' or import the exported symbols
-of other packages.  To access symbols that would not normally be
-visible due to this importing and exporting, Common Lisp provides
-a syntax like @code{package:symbol} or @code{package::symbol}.
+Another standard example:
 
-Emacs Lisp has a single namespace for all interned symbols, and
-then uses a naming convention of putting a prefix like @code{cl-}
-in front of the name.  Some Emacs packages adopt the Common Lisp-like
-convention of using @code{cl:} or @code{cl::} as the prefix.
-However, the Emacs parser does not understand colons and just
-treats them as part of the symbol name.  Thus, while @code{mapcar}
-and @code{lisp:mapcar} may refer to the same symbol in Common
-Lisp, they are totally distinct in Emacs Lisp.  Common Lisp
-programs which refer to a symbol by the full name sometimes
-and the short name other times will not port cleanly to Emacs.
+@example
+(defsetf nth (n x) (store)
+  `(setcar (nthcdr ,n ,x) ,store))
+@end example
 
-Emacs Lisp does have a concept of ``obarrays,'' which are
-package-like collections of symbols, but this feature is not
-strong enough to be used as a true package mechanism.
+You could write this using @code{gv-define-setter} as:
 
-@item
-The @code{format} function is quite different between Common
-Lisp and Emacs Lisp.  It takes an additional ``destination''
-argument before the format string.  A destination of @code{nil}
-means to format to a string as in Emacs Lisp; a destination
-of @code{t} means to write to the terminal (similar to
-@code{message} in Emacs).  Also, format control strings are
-utterly different; @code{~} is used instead of @code{%} to
-introduce format codes, and the set of available codes is
-much richer.  There are no notations like @code{\n} for
-string literals; instead, @code{format} is used with the
-``newline'' format code, @code{~%}.  More advanced formatting
-codes provide such features as paragraph filling, case
-conversion, and even loops and conditionals.
+@example
+(gv-define-setter nth (store n x)
+  `(setcar (nthcdr ,n ,x) ,store))
+@end example
+@end defmac
 
-While it would have been possible to implement most of Common
-Lisp @code{format} in this package (under the name @code{format*},
-of course), it was not deemed worthwhile.  It would have required
-a huge amount of code to implement even a decent subset of
-@code{format*}, yet the functionality it would provide over
-Emacs Lisp's @code{format} would rarely be useful.
+@defmac define-setf-method access-fn arglist forms@dots{}
+This is the most general way to create new place forms.  You can
+replace this by @code{gv-define-setter} or @code{gv-define-expander}.
 
-@item
-Vector constants use square brackets in Emacs Lisp, but
-@code{#(a b c)} notation in Common Lisp.  To further complicate
-matters, Emacs has its own @code{#(} notation for
-something entirely different---strings with properties.
+When a @code{setf} to @var{access-fn} with arguments described by
+@var{arglist} is expanded, the @var{forms} are evaluated and must
+return a list of five items:
 
+@enumerate
 @item
-Characters are distinct from integers in Common Lisp.  The notation
-for character constants is also different: @code{#\A} in Common Lisp
-where Emacs Lisp uses @code{?A}.  Also, @code{string=} and
-@code{string-equal} are synonyms in Emacs Lisp, whereas the latter is
-case-insensitive in Common Lisp.
+A list of @dfn{temporary variables}.
 
 @item
-Data types.  Some Common Lisp data types do not exist in Emacs
-Lisp.  Rational numbers and complex numbers are not present,
-nor are large integers (all integers are ``fixnums'').  All
-arrays are one-dimensional.  There are no readtables or pathnames;
-streams are a set of existing data types rather than a new data
-type of their own.  Hash tables, random-states, structures, and
-packages (obarrays) are built from Lisp vectors or lists rather
-than being distinct types.
+A list of @dfn{value forms} corresponding to the temporary variables
+above.  The temporary variables will be bound to these value forms
+as the first step of any operation on the generalized variable.
 
 @item
-The Common Lisp Object System (CLOS) is not implemented,
-nor is the Common Lisp Condition System.  However, the EIEIO package
-(@pxref{Top, , Introduction, eieio, EIEIO}) does implement some
-CLOS functionality.
+A list of exactly one @dfn{store variable} (generally obtained
+from a call to @code{gensym}).
 
 @item
-Common Lisp features that are completely redundant with Emacs
-Lisp features of a different name generally have not been
-implemented.  For example, Common Lisp writes @code{defconstant}
-where Emacs Lisp uses @code{defconst}.  Similarly, @code{make-list}
-takes its arguments in different ways in the two Lisps but does
-exactly the same thing, so this package has not bothered to
-implement a Common Lisp-style @code{make-list}.
+A Lisp form that stores the contents of the store variable into
+the generalized variable, assuming the temporaries have been
+bound as described above.
 
 @item
-A few more notable Common Lisp features not included in this
-package:  @code{compiler-let}, @code{tagbody}, @code{prog},
-@code{ldb/dpb}, @code{parse-integer}, @code{cerror}.
+A Lisp form that accesses the contents of the generalized variable,
+assuming the temporaries have been bound.
+@end enumerate
 
-@item
-Recursion.  While recursion works in Emacs Lisp just like it
-does in Common Lisp, various details of the Emacs Lisp system
-and compiler make recursion much less efficient than it is in
-most Lisps.  Some schools of thought prefer to use recursion
-in Lisp over other techniques; they would sum a list of
-numbers using something like
+This is exactly like the Common Lisp macro of the same name,
+except that the method returns a list of five values rather
+than the five values themselves, since Emacs Lisp does not
+support Common Lisp's notion of multiple return values.
+(Note that the @code{setf} implementation provided by @file{gv.el}
+does not use this five item format.  Its use here is only for
+backwards compatibility.)
 
-@example
-(defun sum-list (list)
-  (if list
-      (+ (car list) (sum-list (cdr list)))
-    0))
-@end example
+Once again, the @var{forms} may begin with a documentation string.
 
-@noindent
-where a more iteratively-minded programmer might write one of
-these forms:
+A setf-method should be maximally conservative with regard to
+temporary variables.  In the setf-methods generated by
+@code{defsetf}, the second return value is simply the list of
+arguments in the place form, and the first return value is a
+list of a corresponding number of temporary variables generated
+@c FIXME I don't think this is true anymore.
+by @code{cl-gensym}.  Macros like @code{cl-incf} that
+use this setf-method will optimize away most temporaries that
+turn out to be unnecessary, so there is little reason for the
+setf-method itself to optimize.
+@end defmac
 
-@example
-(let ((total 0)) (dolist (x my-list) (incf total x)) total)
-(loop for x in my-list sum x)
-@end example
+@c Removed in Emacs 24.3, not possible to make a compatible replacement.
+@ignore
+@defun get-setf-method place &optional env
+This function returns the setf-method for @var{place}, by
+invoking the definition previously recorded by @code{defsetf}
+or @code{define-setf-method}.  The result is a list of five
+values as described above.  You can use this function to build
+your own @code{cl-incf}-like modify macros.
+
+The argument @var{env} specifies the ``environment'' to be
+passed on to @code{macroexpand} if @code{get-setf-method} should
+need to expand a macro in @var{place}.  It should come from
+an @code{&environment} argument to the macro or setf-method
+that called @code{get-setf-method}.
+@end defun
+@end ignore
 
-While this would be mainly a stylistic choice in most Common Lisps,
-in Emacs Lisp you should be aware that the iterative forms are
-much faster than recursion.  Also, Lisp programmers will want to
-note that the current Emacs Lisp compiler does not optimize tail
-recursion.
-@end itemize
 
 @node GNU Free Documentation License
 @appendix GNU Free Documentation License
@@ -5293,4 +5130,3 @@ recursion.
 @printindex vr
 
 @bye
-