aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorKenichi Handa2012-10-30 20:38:37 +0900
committerKenichi Handa2012-10-30 20:38:37 +0900
commit6ccc848cd85e75d77d6b11a46f5f23f860db9ff5 (patch)
treee10cb69f3bbe6f2d9616d3867f12bf035c70e0f8 /doc
parentaee5b18ec3c7844ca125249914113eeaef04342c (diff)
parentfcc1acdadbeae00d8dcabeb6dccb20da9672af2c (diff)
downloademacs-6ccc848cd85e75d77d6b11a46f5f23f860db9ff5.tar.gz
emacs-6ccc848cd85e75d77d6b11a46f5f23f860db9ff5.zip
merge trun
Diffstat (limited to 'doc')
-rw-r--r--doc/emacs/ChangeLog50
-rw-r--r--doc/emacs/ack.texi5
-rw-r--r--doc/emacs/building.texi7
-rw-r--r--doc/emacs/dired.texi97
-rw-r--r--doc/emacs/emacs.texi1
-rw-r--r--doc/emacs/files.texi5
-rw-r--r--doc/emacs/frames.texi16
-rw-r--r--doc/emacs/mule.texi17
-rw-r--r--doc/emacs/package.texi8
-rw-r--r--doc/emacs/programs.texi13
-rw-r--r--doc/emacs/screen.texi2
-rw-r--r--doc/emacs/search.texi42
-rw-r--r--doc/emacs/text.texi2
-rw-r--r--doc/emacs/windows.texi6
-rw-r--r--doc/lispintro/ChangeLog5
-rw-r--r--doc/lispintro/emacs-lisp-intro.texi14
-rw-r--r--doc/lispref/ChangeLog83
-rw-r--r--doc/lispref/anti.texi5
-rw-r--r--doc/lispref/buffers.texi9
-rw-r--r--doc/lispref/commands.texi11
-rw-r--r--doc/lispref/display.texi4
-rw-r--r--doc/lispref/elisp.texi10
-rw-r--r--doc/lispref/files.texi24
-rw-r--r--doc/lispref/frames.texi31
-rw-r--r--doc/lispref/hooks.texi8
-rw-r--r--doc/lispref/intro.texi4
-rw-r--r--doc/lispref/keymaps.texi173
-rw-r--r--doc/lispref/lists.texi10
-rw-r--r--doc/lispref/loading.texi38
-rw-r--r--doc/lispref/markers.texi5
-rw-r--r--doc/lispref/minibuf.texi29
-rw-r--r--doc/lispref/nonascii.texi8
-rw-r--r--doc/lispref/os.texi2
-rw-r--r--doc/lispref/symbols.texi6
-rw-r--r--doc/lispref/text.texi85
-rw-r--r--doc/lispref/variables.texi103
-rw-r--r--doc/lispref/windows.texi186
-rw-r--r--doc/misc/ChangeLog93
-rw-r--r--doc/misc/cl.texi2627
-rw-r--r--doc/misc/emacs-mime.texi10
-rw-r--r--doc/misc/org.texi37
-rw-r--r--doc/misc/tramp.texi3
42 files changed, 2089 insertions, 1805 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog
index 90beb08233d..ea5621e7ccf 100644
--- a/doc/emacs/ChangeLog
+++ b/doc/emacs/ChangeLog
@@ -1,3 +1,53 @@
12012-10-29 Chong Yidong <cyd@gnu.org>
2
3 * dired.texi (Shell Commands in Dired): Document changes to the
4 dired-do-async-shell-command.
5
62012-10-28 Glenn Morris <rgm@gnu.org>
7
8 * ack.texi (Acknowledgments): Mention gv.el.
9
102012-10-27 Bastien Guerry <bzg@gnu.org>
11
12 * screen.texi (Menu Bar): Fix typo.
13
142012-10-27 Chong Yidong <cyd@gnu.org>
15
16 * frames.texi (Mouse Avoidance): Mention new variable
17 mouse-avoidance-banish-position.
18
19 * programs.texi (Which Function): Which Function mode now works in
20 all major modes by default.
21
22 * mule.texi (Recognize Coding): Remove an unreferenced vindex.
23
24 * files.texi (Misc File Ops): Symbolic links on Windows only work
25 on Vista and later.
26
27 * building.texi (Compilation): Document compilation-always-kill.
28
29 * search.texi (Symbol Search): New node.
30
31 * package.texi (Package Menu): Document the "new" status.
32
33 * windows.texi (Window Choice): Don't refer to the obsolete
34 special-display feature.
35
362012-10-24 Chong Yidong <cyd@gnu.org>
37
38 * mule.texi (Text Coding): set-buffer-file-coding-system can now
39 be invoked from the mode line.
40
41 * dired.texi (Dired Deletion, Marks vs Flags): Document Emacs 24.3
42 changes to the mark and unmark commands.
43 (Comparison in Dired): Document chages to dired-diff. Remove M-=,
44 which is no longer bound to dired-backup-diff.
45
462012-10-23 Bastien Guerry <bzg@gnu.org>
47
48 * text.texi (Org Authoring): Use a comma after @ref to avoid the
49 insertion of a period in the Info output.
50
12012-10-23 Stefan Monnier <monnier@iro.umontreal.ca> 512012-10-23 Stefan Monnier <monnier@iro.umontreal.ca>
2 52
3 * custom.texi (Hooks): Clarify that -hooks is deprecated. 53 * custom.texi (Hooks): Clarify that -hooks is deprecated.
diff --git a/doc/emacs/ack.texi b/doc/emacs/ack.texi
index 8d1e4221a6c..79710f4992b 100644
--- a/doc/emacs/ack.texi
+++ b/doc/emacs/ack.texi
@@ -835,8 +835,9 @@ diffs; @file{css-mode.el} for Cascading Style Sheets;
835client for the ``Music Player Daemon''; @file{smie.el}, a generic 835client for the ``Music Player Daemon''; @file{smie.el}, a generic
836indentation engine; and @file{pcase.el}, implementing ML-style pattern 836indentation engine; and @file{pcase.el}, implementing ML-style pattern
837matching. In Emacs 24, he integrated the lexical binding code, 837matching. In Emacs 24, he integrated the lexical binding code,
838and cleaned up the CL namespace (making it acceptable to use CL 838cleaned up the CL namespace (making it acceptable to use CL
839functions at runtime). 839functions at runtime), and added generalized variables to core Emacs
840Lisp.
840 841
841@item 842@item
842Morioka Tomohiko wrote several packages for MIME support in Gnus and 843Morioka Tomohiko wrote several packages for MIME support in Gnus and
diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index eaee16ac8d5..3a3630138de 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -108,11 +108,14 @@ directory, which is the directory in which the previous compilation
108was started. 108was started.
109 109
110@findex kill-compilation 110@findex kill-compilation
111@vindex compilation-always-kill
111 Starting a new compilation also kills any compilation already 112 Starting a new compilation also kills any compilation already
112running in @file{*compilation*}, as the buffer can only handle one 113running in @file{*compilation*}, as the buffer can only handle one
113compilation at any time. However, @kbd{M-x compile} asks for 114compilation at any time. However, @kbd{M-x compile} asks for
114confirmation before actually killing a compilation that is running. 115confirmation before actually killing a compilation that is running; to
115You can also kill the compilation process with @kbd{M-x 116always automatically kill the compilation without asking, change the
117variable @code{compilation-always-kill} to @code{t}. You can also
118kill a compilation process with the command @kbd{M-x
116kill-compilation}. 119kill-compilation}.
117 120
118 To run two compilations at once, start the first one, then rename 121 To run two compilations at once, start the first one, then rename
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 0dcded78364..c08dc02b04b 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -167,13 +167,14 @@ deletion, then delete the files that were flagged.
167 167
168@table @kbd 168@table @kbd
169@item d 169@item d
170Flag this file for deletion. 170Flag this file for deletion (@code{dired-flag-file-deletion}).
171@item u 171@item u
172Remove deletion flag on this line. 172Remove the deletion flag (@code{dired-unmark}).
173@item @key{DEL} 173@item @key{DEL}
174Move point to previous line and remove the deletion flag on that line. 174Move point to previous line and remove the deletion flag on that line
175(@code{dired-unmark-backward}).
175@item x 176@item x
176Delete the files that are flagged for deletion. 177Delete files flagged for deletion (@code{dired-do-flagged-delete}).
177@end table 178@end table
178 179
179@kindex d @r{(Dired)} 180@kindex d @r{(Dired)}
@@ -182,8 +183,12 @@ Delete the files that are flagged for deletion.
182the file and typing @kbd{d} (@code{dired-flag-file-deletion}). The 183the file and typing @kbd{d} (@code{dired-flag-file-deletion}). The
183deletion flag is visible as a @samp{D} at the beginning of the line. 184deletion flag is visible as a @samp{D} at the beginning of the line.
184This command moves point to the next line, so that repeated @kbd{d} 185This command moves point to the next line, so that repeated @kbd{d}
185commands flag successive files. A numeric argument serves as a repeat 186commands flag successive files. A numeric prefix argument serves as a
186count. 187repeat count; a negative count means to flag preceding files.
188
189 If the region is active, the @kbd{d} command flags all files in the
190region for deletion; in this case, the command does not move point,
191and ignores any prefix argument.
187 192
188@kindex u @r{(Dired deletion)} 193@kindex u @r{(Dired deletion)}
189@kindex DEL @r{(Dired)} 194@kindex DEL @r{(Dired)}
@@ -194,14 +199,17 @@ can remove deletion flags using the commands @kbd{u} and @key{DEL}.
194@kbd{u} (@code{dired-unmark}) works just like @kbd{d}, but removes 199@kbd{u} (@code{dired-unmark}) works just like @kbd{d}, but removes
195flags rather than making flags. @key{DEL} 200flags rather than making flags. @key{DEL}
196(@code{dired-unmark-backward}) moves upward, removing flags; it is 201(@code{dired-unmark-backward}) moves upward, removing flags; it is
197like @kbd{u} with argument @minus{}1. 202like @kbd{u} with argument @minus{}1. A numeric prefix argument to
203either command serves as a repeat count, with a negative count meaning
204to unflag in the opposite direction. If the region is active, these
205commands instead unflag all files in the region, without moving point.
198 206
199@kindex x @r{(Dired)} 207@kindex x @r{(Dired)}
200@findex dired-do-flagged-delete 208@findex dired-do-flagged-delete
201 To delete the flagged files, type @kbd{x} 209 To delete flagged files, type @kbd{x}
202(@code{dired-do-flagged-delete}). This command first displays a list 210(@code{dired-do-flagged-delete}). This command displays a list of all
203of all the file names flagged for deletion, and requests confirmation 211the file names flagged for deletion, and requests confirmation with
204with @kbd{yes}. If you confirm, Dired deletes the flagged files, then 212@kbd{yes}. If you confirm, Dired deletes the flagged files, then
205deletes their lines from the text of the Dired buffer. The Dired 213deletes their lines from the text of the Dired buffer. The Dired
206buffer, with somewhat fewer lines, remains selected. 214buffer, with somewhat fewer lines, remains selected.
207 215
@@ -387,10 +395,11 @@ and unflag files.)
387@kindex m @r{(Dired)} 395@kindex m @r{(Dired)}
388@kindex * m @r{(Dired)} 396@kindex * m @r{(Dired)}
389@findex dired-mark 397@findex dired-mark
390Mark the current file with @samp{*} (@code{dired-mark}). With a numeric 398Mark the current file with @samp{*} (@code{dired-mark}). If the
391argument @var{n}, mark the next @var{n} files starting with the current 399region is active, mark all files in the region instead; otherwise, if
392file. (If @var{n} is negative, mark the previous @minus{}@var{n} 400a numeric argument @var{n} is supplied, mark the next @var{n} files
393files.) 401instead, starting with the current file (if @var{n} is negative, mark
402the previous @minus{}@var{n} files).
394 403
395@item * * 404@item * *
396@kindex * * @r{(Dired)} 405@kindex * * @r{(Dired)}
@@ -426,7 +435,11 @@ and @file{..} (@code{dired-mark-subdir-files}).
426@kindex u @r{(Dired)} 435@kindex u @r{(Dired)}
427@kindex * u @r{(Dired)} 436@kindex * u @r{(Dired)}
428@findex dired-unmark 437@findex dired-unmark
429Remove any mark on this line (@code{dired-unmark}). 438Remove any mark on this line (@code{dired-unmark}). If the region is
439active, unmark all files in the region instead; otherwise, if a
440numeric argument @var{n} is supplied, unmark the next @var{n} files
441instead, starting with the current file (if @var{n} is negative,
442unmark the previous @minus{}@var{n} files).
430 443
431@item @key{DEL} 444@item @key{DEL}
432@itemx * @key{DEL} 445@itemx * @key{DEL}
@@ -434,7 +447,11 @@ Remove any mark on this line (@code{dired-unmark}).
434@findex dired-unmark-backward 447@findex dired-unmark-backward
435@cindex unmarking files (in Dired) 448@cindex unmarking files (in Dired)
436Move point to previous line and remove any mark on that line 449Move point to previous line and remove any mark on that line
437(@code{dired-unmark-backward}). 450(@code{dired-unmark-backward}). If the region is active, unmark all
451files in the region instead; otherwise, if a numeric argument @var{n}
452is supplied, unmark the @var{n} preceding files instead, starting with
453the current file (if @var{n} is negative, unmark the next
454@minus{}@var{n} files).
438 455
439@item * ! 456@item * !
440@itemx U 457@itemx U
@@ -782,15 +799,20 @@ more matches. @xref{Tags Search}.
782@kindex ! @r{(Dired)} 799@kindex ! @r{(Dired)}
783@kindex X @r{(Dired)} 800@kindex X @r{(Dired)}
784The Dired command @kbd{!} (@code{dired-do-shell-command}) reads a 801The Dired command @kbd{!} (@code{dired-do-shell-command}) reads a
785shell command string in the minibuffer and runs that shell command on 802shell command string in the minibuffer, and runs that shell command on
786one or more files. The files that the shell command operates on are 803one or more files. The files that the shell command operates on are
787determined in the usual way for Dired commands (@pxref{Operating on 804determined in the usual way for Dired commands (@pxref{Operating on
788Files}). The command @kbd{X} is a synonym for @kbd{!}. 805Files}). The command @kbd{X} is a synonym for @kbd{!}.
789 806
790 The command @kbd{&} (@code{dired-do-async-shell-command}) does the 807 The command @kbd{&} (@code{dired-do-async-shell-command}) does the
791same, except that it runs the shell command asynchronously. You can 808same, except that it runs the shell command asynchronously. (You can
792also do this with @kbd{!}, by appending a @samp{&} character to the 809also do this with @kbd{!}, by appending a @samp{&} character to the
793end of the shell command. 810end of the shell command.) When the command operates on more than one
811file, it runs multiple parallel copies of the specified shell command,
812one for each file. As an exception, if the specified shell command
813ends in @samp{;} or @samp{;&}, the shell command is run in the
814background on each file sequentially; Emacs waits for each invoked
815shell command to terminate before running the next one.
794 816
795 For both @kbd{!} and @kbd{&}, the working directory for the shell 817 For both @kbd{!} and @kbd{&}, the working directory for the shell
796command is the top-level directory of the Dired buffer. 818command is the top-level directory of the Dired buffer.
@@ -936,32 +958,19 @@ default.
936@cindex file comparison (in Dired) 958@cindex file comparison (in Dired)
937@cindex compare files (in Dired) 959@cindex compare files (in Dired)
938 960
939 Here are two Dired commands that compare specified files using
940@code{diff}. They show the output in a buffer using Diff mode
941(@pxref{Comparing Files}).
942
943@table @kbd
944@item =
945@findex dired-diff 961@findex dired-diff
946@kindex = @r{(Dired)} 962@kindex = @r{(Dired)}
947Compare the current file (the file at point) with another file (the 963 The @kbd{=} (@code{dired-diff}) command compares the current file
948file at the mark) using the @code{diff} program (@code{dired-diff}). 964(the file at point) with another file (read using the minibuffer)
949The file at the mark is the first argument of @code{diff}, and the 965using the @command{diff} program. The file specified with the
950file at point is the second argument. This refers to the ordinary 966minibuffer is the first argument of @command{diff}, and file at point
951Emacs mark, not Dired marks; use @kbd{C-@key{SPC}} 967is the second argument. The output of the @command{diff} program is
952(@code{set-mark-command}) to set the mark at the first file's line 968shown in a buffer using Diff mode (@pxref{Comparing Files}).
953(@pxref{Setting Mark}). 969
954 970 If the region is active, the default for the file read using the
955@findex dired-backup-diff 971minibuffer is the file at the mark (i.e.@: the ordinary Emacs mark,
956@kindex M-= @r{(Dired)} 972not a Dired mark; @pxref{Setting Mark}). Otherwise, if the file at
957@item M-= 973point has a backup file (@pxref{Backup}), that is the default.
958Compare the current file with its latest backup file
959(@code{dired-backup-diff}). If the current file is itself a backup,
960compare it with the file it is a backup of; this way, you can compare
961a file with any one of its backups.
962
963The backup file is the first file given to @code{diff}.
964@end table
965 974
966@node Subdirectories in Dired 975@node Subdirectories in Dired
967@section Subdirectories in Dired 976@section Subdirectories in Dired
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index a2eaaf673e5..e7e0feb9e88 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -373,6 +373,7 @@ Searching and Replacement
373* Incremental Search:: Search happens as you type the string. 373* Incremental Search:: Search happens as you type the string.
374* Nonincremental Search:: Specify entire string and then search. 374* Nonincremental Search:: Specify entire string and then search.
375* Word Search:: Search for sequence of words. 375* Word Search:: Search for sequence of words.
376* Symbol Search:: Search for a source code symbol.
376* Regexp Search:: Search for match for a regexp. 377* Regexp Search:: Search for match for a regexp.
377* Regexps:: Syntax of regular expressions. 378* Regexps:: Syntax of regular expressions.
378* Regexp Backslash:: Regular expression constructs starting with `\'. 379* Regexp Backslash:: Regular expression constructs starting with `\'.
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index e12bb385653..36cd3658e2d 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1564,9 +1564,8 @@ open file @var{linkname} will refer to whatever file is named
1564@var{target} at the time the opening is done, or will get an error if 1564@var{target} at the time the opening is done, or will get an error if
1565the name @var{target} is nonexistent at that time. This command does 1565the name @var{target} is nonexistent at that time. This command does
1566not expand the argument @var{target}, so that it allows you to specify 1566not expand the argument @var{target}, so that it allows you to specify
1567a relative name as the target of the link. Not all systems support 1567a relative name as the target of the link. On MS-Windows, this
1568symbolic links; on systems that don't support them, this command is 1568command works only on MS Windows Vista and later.
1569not defined.
1570 1569
1571@kindex C-x i 1570@kindex C-x i
1572@findex insert-file 1571@findex insert-file
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index e1b849e630e..0ce5c64c0eb 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -1092,17 +1092,19 @@ to various values to move the mouse in several ways:
1092 1092
1093@table @code 1093@table @code
1094@item banish 1094@item banish
1095Move the mouse to the upper-right corner on any key-press; 1095Move the pointer to a corner of the frame on any key-press. You can
1096customize the variable @code{mouse-avoidance-banish-position} to
1097specify where the pointer goes when it is banished.
1096@item exile 1098@item exile
1097Move the mouse to the corner only if the cursor gets too close, 1099Banish the pointer only if the cursor gets too close, and allow it to
1098and allow it to return once the cursor is out of the way; 1100return once the cursor is out of the way.
1099@item jump 1101@item jump
1100If the cursor gets too close to the mouse, displace the mouse 1102If the cursor gets too close to the pointer, displace the pointer by a
1101a random distance & direction; 1103random distance and direction.
1102@item animate 1104@item animate
1103As @code{jump}, but shows steps along the way for illusion of motion; 1105As @code{jump}, but shows steps along the way for illusion of motion.
1104@item cat-and-mouse 1106@item cat-and-mouse
1105The same as @code{animate}; 1107The same as @code{animate}.
1106@item proteus 1108@item proteus
1107As @code{animate}, but changes the shape of the mouse pointer too. 1109As @code{animate}, but changes the shape of the mouse pointer too.
1108@end table 1110@end table
diff --git a/doc/emacs/mule.texi b/doc/emacs/mule.texi
index 1dfae79c788..ff0d43c566a 100644
--- a/doc/emacs/mule.texi
+++ b/doc/emacs/mule.texi
@@ -920,7 +920,6 @@ Unlike the previous two, this variable does not override any
920@samp{-*-coding:-*-} tag. 920@samp{-*-coding:-*-} tag.
921 921
922@c FIXME? This seems somewhat out of place. Move to the Rmail section? 922@c FIXME? This seems somewhat out of place. Move to the Rmail section?
923@vindex rmail-decode-mime-charset
924@vindex rmail-file-coding-system 923@vindex rmail-file-coding-system
925 When you get new mail in Rmail, each message is translated 924 When you get new mail in Rmail, each message is translated
926automatically from the coding system it is written in, as if it were a 925automatically from the coding system it is written in, as if it were a
@@ -1040,12 +1039,16 @@ decoding it using coding system @var{right} instead.
1040@findex set-buffer-file-coding-system 1039@findex set-buffer-file-coding-system
1041 The command @kbd{C-x @key{RET} f} 1040 The command @kbd{C-x @key{RET} f}
1042(@code{set-buffer-file-coding-system}) sets the file coding system for 1041(@code{set-buffer-file-coding-system}) sets the file coding system for
1043the current buffer---in other words, it says which coding system to 1042the current buffer (i.e.@: the coding system to use when saving or
1044use when saving or reverting the visited file. You specify which 1043reverting the file). You specify which coding system using the
1045coding system using the minibuffer. If you specify a coding system 1044minibuffer. You can also invoke this command by clicking with
1046that cannot handle all of the characters in the buffer, Emacs warns 1045@kbd{Mouse-3} on the coding system indicator in the mode line
1047you about the troublesome characters when you actually save the 1046(@pxref{Mode Line}).
1048buffer. 1047
1048 If you specify a coding system that cannot handle all the characters
1049in the buffer, Emacs will warn you about the troublesome characters,
1050and ask you to choose another coding system, when you try to save the
1051buffer (@pxref{Output Coding}).
1049 1052
1050@cindex specify end-of-line conversion 1053@cindex specify end-of-line conversion
1051 You can also use this command to specify the end-of-line conversion 1054 You can also use this command to specify the end-of-line conversion
diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi
index 4435590536f..df87cf9cb23 100644
--- a/doc/emacs/package.texi
+++ b/doc/emacs/package.texi
@@ -62,8 +62,12 @@ The package's status---normally one of @samp{available} (can be
62downloaded from the package archive), @samp{installed}, or 62downloaded from the package archive), @samp{installed}, or
63@samp{built-in} (included in Emacs by default). 63@samp{built-in} (included in Emacs by default).
64 64
65In some instances, the status can be @samp{held}, @samp{disabled}, or 65The status can also be @samp{new}. This is equivalent to
66@samp{obsolete}. @xref{Package Installation}. 66@samp{available}, except that it means the package became newly
67available on the package archive after your last invocation of
68@kbd{M-x list-packages}. In other instances, a package may have the
69status @samp{held}, @samp{disabled}, or @samp{obsolete}.
70@xref{Package Installation}.
67 71
68@item 72@item
69A short description of the package. 73A short description of the package.
diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi
index e5340655770..b5bb33ad666 100644
--- a/doc/emacs/programs.texi
+++ b/doc/emacs/programs.texi
@@ -326,12 +326,13 @@ as you move around in a buffer.
326@findex which-function-mode 326@findex which-function-mode
327@vindex which-func-modes 327@vindex which-func-modes
328 To either enable or disable Which Function mode, use the command 328 To either enable or disable Which Function mode, use the command
329@kbd{M-x which-function-mode}. Although Which Function mode is a 329@kbd{M-x which-function-mode}. Which Function mode is a global minor
330global minor mode, it takes effect only in certain major modes: those 330mode. By default, it takes effect in all major modes major modes that
331listed in the variable @code{which-func-modes}. If the value of 331know how to support it (i.e.@: all the major modes that support
332@code{which-func-modes} is @code{t} rather than a list of modes, then 332Imenu). You can restrict it to a specific list of major modes by
333Which Function mode applies to all major modes that know how to 333changing the value of the variable @code{which-func-modes} from
334support it---in other words, all the major modes that support Imenu. 334@code{t} (which means to support all available major modes) to a list
335of major mode names.
335 336
336@node Program Indent 337@node Program Indent
337@section Indentation for Programs 338@section Indentation for Programs
diff --git a/doc/emacs/screen.texi b/doc/emacs/screen.texi
index 989cf998bfd..2b8edaf9375 100644
--- a/doc/emacs/screen.texi
+++ b/doc/emacs/screen.texi
@@ -314,5 +314,5 @@ the echo area. You can use the up and down arrow keys to move through
314the menu to different items, and then you can type @key{RET} to select 314the menu to different items, and then you can type @key{RET} to select
315the item. Each menu item is also designated by a letter or digit 315the item. Each menu item is also designated by a letter or digit
316(usually the initial of some word in the item's name). This letter or 316(usually the initial of some word in the item's name). This letter or
317digit is separated from the item name by @samp{=>}. You can type the 317digit is separated from the item name by @samp{==>}. You can type the
318item's letter or digit to select the item. 318item's letter or digit to select the item.
diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index 7e46e416219..7dc5855cdfc 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -21,6 +21,7 @@ thing, but search for patterns instead of fixed strings.
21* Incremental Search:: Search happens as you type the string. 21* Incremental Search:: Search happens as you type the string.
22* Nonincremental Search:: Specify entire string and then search. 22* Nonincremental Search:: Specify entire string and then search.
23* Word Search:: Search for sequence of words. 23* Word Search:: Search for sequence of words.
24* Symbol Search:: Search for a source code symbol.
24* Regexp Search:: Search for match for a regexp. 25* Regexp Search:: Search for match for a regexp.
25* Regexps:: Syntax of regular expressions. 26* Regexps:: Syntax of regular expressions.
26* Regexp Backslash:: Regular expression constructs starting with `\'. 27* Regexp Backslash:: Regular expression constructs starting with `\'.
@@ -467,6 +468,47 @@ the search string can match part of a word, so that the matching
467proceeds incrementally as you type. This additional laxity does not 468proceeds incrementally as you type. This additional laxity does not
468apply to the lazy highlight, which always matches whole words. 469apply to the lazy highlight, which always matches whole words.
469 470
471@node Symbol Search
472@section Symbol Search
473@cindex symbol search
474
475 A @dfn{symbol search} is much like an ordinary search, except that
476the boundaries of the search must match the boundaries of a symbol.
477The meaning of @dfn{symbol} in this context depends on the major mode,
478and usually refers to a source code token, such as a Lisp symbol in
479Emacs Lisp mode. For instance, if you perform an incremental symbol
480search for the Lisp symbol @code{forward-word}, it would not match
481@code{isearch-forward-word}. This feature is thus mainly useful for
482searching source code.
483
484@table @kbd
485@item M-s _
486If incremental search is active, toggle symbol search mode
487(@code{isearch-toggle-symbol}); otherwise, begin an incremental
488forward symbol search (@code{isearch-forward-symbol}).
489@item M-s _ @key{RET} @var{symbol} @key{RET}
490Search forward for @var{symbol}, nonincrementally.
491@item M-s _ C-r @key{RET} @var{symbol} @key{RET}
492Search backward for @var{symbol}, nonincrementally.
493@end table
494
495@kindex M-s _
496@findex isearch-forward-symbol
497 To begin a forward incremental symbol search, type @kbd{M-s _}. If
498incremental search is not already active, this runs the command
499@code{isearch-forward-symbol}. If incremental search is already
500active, @kbd{M-s _} switches to a symbol search, preserving the
501direction of the search and the current search string; you can disable
502symbol search by typing @kbd{M-s _} again. In incremental symbol
503search, only the beginning of the search string is required to match
504the beginning of a symbol.
505
506 To begin a nonincremental symbol search, type @kbd{M-s _ @key{RET}}
507for a forward search, or @kbd{M-s _ C-r @key{RET}} or a backward
508search. In nonincremental symbol searches, the beginning and end of
509the search string are required to match the beginning and end of a
510symbol, respectively.
511
470@node Regexp Search 512@node Regexp Search
471@section Regular Expression Search 513@section Regular Expression Search
472@cindex regexp search 514@cindex regexp search
diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi
index f10e78e17ad..6e895d3ac3c 100644
--- a/doc/emacs/text.texi
+++ b/doc/emacs/text.texi
@@ -1399,7 +1399,7 @@ This is an example.
1399#+end_example 1399#+end_example
1400@end example 1400@end example
1401 1401
1402 For further details, see @ref{Exporting,,,org, The Org Manual} and 1402 For further details, @ref{Exporting,,,org, The Org Manual}, and
1403@ref{Publishing,,,org, The Org Manual}. 1403@ref{Publishing,,,org, The Org Manual}.
1404 1404
1405@node TeX Mode 1405@node TeX Mode
diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi
index 04d1353006f..f87da5f3913 100644
--- a/doc/emacs/windows.texi
+++ b/doc/emacs/windows.texi
@@ -384,12 +384,6 @@ Otherwise, if the buffer is already displayed in an existing window,
384are considered, but windows on other frames are also reusable if you 384are considered, but windows on other frames are also reusable if you
385change @code{pop-up-frames} (see below) to @code{t}. 385change @code{pop-up-frames} (see below) to @code{t}.
386 386
387@item
388Otherwise, if you specified that the buffer should be displayed in a
389special frame by customizing @code{special-display-buffer-names} or
390@code{special-display-regexps}, do so. @xref{Choosing Window
391Options,,, elisp, The Emacs Lisp Reference Manual}.
392
393@vindex pop-up-frames 387@vindex pop-up-frames
394@item 388@item
395Otherwise, optionally create a new frame and display the buffer there. 389Otherwise, optionally create a new frame and display the buffer there.
diff --git a/doc/lispintro/ChangeLog b/doc/lispintro/ChangeLog
index 6c524f5a0ae..396e3857c58 100644
--- a/doc/lispintro/ChangeLog
+++ b/doc/lispintro/ChangeLog
@@ -1,3 +1,8 @@
12012-10-24 Paul Eggert <eggert@penguin.cs.ucla.edu>
2
3 * emacs-lisp-intro.texi (Files List):
4 Update manual for new time stamp format (Bug#12706).
5
12012-10-17 Gregor Zattler <grfz@gmx.de> (tiny change) 62012-10-17 Gregor Zattler <grfz@gmx.de> (tiny change)
2 7
3 * emacs-lisp-intro.texi (Narrowing advantages): 8 * emacs-lisp-intro.texi (Narrowing advantages):
diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi
index 70ddb81c776..f885d6c15e8 100644
--- a/doc/lispintro/emacs-lisp-intro.texi
+++ b/doc/lispintro/emacs-lisp-intro.texi
@@ -238,7 +238,7 @@ GNU Press, @hfill @uref{http://www.fsf.org/campaigns/gnu-press/}@*
238a division of the @hfill email: @email{sales@@fsf.org}@* 238a division of the @hfill email: @email{sales@@fsf.org}@*
239Free Software Foundation, Inc. @hfill Tel: +1 (617) 542-5942@* 239Free Software Foundation, Inc. @hfill Tel: +1 (617) 542-5942@*
24051 Franklin Street, Fifth Floor @hfill Fax: +1 (617) 542-2652@* 24051 Franklin Street, Fifth Floor @hfill Fax: +1 (617) 542-2652@*
241Boston, MA 02110-1301 USA 241Boston, MA 02110-1301 USA
242@end iftex 242@end iftex
243 243
244@ifnottex 244@ifnottex
@@ -249,7 +249,7 @@ GNU Press, http://www.fsf.org/campaigns/gnu-press/
249a division of the email: sales@@fsf.org 249a division of the email: sales@@fsf.org
250Free Software Foundation, Inc. Tel: +1 (617) 542-5942 250Free Software Foundation, Inc. Tel: +1 (617) 542-5942
25151 Franklin Street, Fifth Floor Fax: +1 (617) 542-2652 25151 Franklin Street, Fifth Floor Fax: +1 (617) 542-2652
252Boston, MA 02110-1301 USA 252Boston, MA 02110-1301 USA
253@end example 253@end example
254@end ifnottex 254@end ifnottex
255 255
@@ -15680,11 +15680,11 @@ nil
15680100 15680100
15681@end group 15681@end group
15682@group 15682@group
15683(17733 259) 15683(20615 27034 579989 697000)
15684(17491 28834) 15684(17905 55681 0 0)
15685(17596 62124) 15685(20615 26327 734791 805000)
1568613157 1568613188
15687"-rw-rw-r--" 15687"-rw-r--r--"
15688@end group 15688@end group
15689@group 15689@group
15690nil 15690nil
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 26765e7a384..eca39e54203 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,86 @@
12012-10-30 Glenn Morris <rgm@gnu.org>
2
3 * variables.texi (Generalized Variables): Fix typo.
4
52012-10-30 Chong Yidong <cyd@gnu.org>
6
7 * symbols.texi (Symbol Plists): Document function-get.
8
9 * loading.texi (Autoload): Document autoloadp, autoload-do-load.
10
11 * frames.texi (Visibility of Frames): Document tty-top-frame.
12
132012-10-28 Stefan Monnier <monnier@iro.umontreal.ca>
14
15 * keymaps.texi (Format of Keymaps): Document the multiple
16 inheritance format.
17
182012-10-28 Martin Rudalics <rudalics@gmx.at>
19
20 * windows.texi (Basic Windows): Reformulate description of live,
21 internal and valid windows.
22 (Cyclic Window Ordering): Describe new argument of
23 get-lru-window and get-largest-window. Add description of
24 window-in-direction.
25
262012-10-27 Glenn Morris <rgm@gnu.org>
27
28 * variables.texi (Generalized Variables): New section,
29 adapted from misc/cl.texi.
30 * elisp.texi (Top): Add Generalized Variables to menu.
31 * lists.texi (List Elements, List Variables):
32 Mention generalized variables.
33
34 * lists.texi (List Elements): Typo fix.
35
362012-10-27 Chong Yidong <cyd@gnu.org>
37
38 * minibuf.texi (High-Level Completion): Don't mention removed
39 function iswitchb-read-buffer.
40
41 * commands.texi (Event Input Misc): Remove last-input-char.
42 (Command Loop Info): Remove last-command-char.
43
44 * frames.texi (Initial Parameters): Don't mention the obsolete
45 special-display feature.
46
47 * windows.texi (Choosing Window): Don't mention the obsolete
48 special display feature.
49 (Choosing Window Options): Remove obsolete special-display
50 variables, and the functions special-display-p and
51 special-display-popup-frame.
52
53 * display.texi (Fringe Bitmaps): Add exclamation-mark bitmap.
54
55 * hooks.texi (Standard Hooks): Remove obsolete hooks.
56
57 * markers.texi (Information from Markers): Remove obsolete
58 function buffer-has-markers-at.
59
60 * text.texi (Yanking): Document yank-handled-properties.
61
622012-10-24 Paul Eggert <eggert@penguin.cs.ucla.edu>
63
64 Update manual for new time stamp format (Bug#12706).
65 * buffers.texi (Modification Time):
66 * files.texi (Testing Accessibility, File Attributes):
67 * intro.texi (Version Info):
68 * os.texi (Time of Day):
69 Update for new time stamp format (HIGH LOW MICROSEC PICOSEC).
70 These instances were missed the first time around.
71 Problem reported by Glenn Morris in <http://bugs.gnu.org/12706#25>.
72
732012-10-24 Chong Yidong <cyd@gnu.org>
74
75 * minibuf.texi (Text from Minibuffer): Document read-regexp
76 changes.
77
78 * nonascii.texi (Selecting a Representation): Document
79 set-buffer-multibyte changes.
80
81 * keymaps.texi (Toolkit Differences): Node deleted.
82 (Easy Menu): New node.
83
12012-10-23 Stefan Monnier <monnier@iro.umontreal.ca> 842012-10-23 Stefan Monnier <monnier@iro.umontreal.ca>
2 85
3 * hooks.texi (Standard Hooks): Clarify that -hooks is deprecated. 86 * hooks.texi (Standard Hooks): Clarify that -hooks is deprecated.
diff --git a/doc/lispref/anti.texi b/doc/lispref/anti.texi
index f1f4a089f1b..6ece2149733 100644
--- a/doc/lispref/anti.texi
+++ b/doc/lispref/anti.texi
@@ -71,9 +71,8 @@ been removed, including @code{display-buffer-overriding-action} and
71related variables, as well as the @var{action} argument to 71related variables, as well as the @var{action} argument to
72@code{display-buffer} and other functions. The way to 72@code{display-buffer} and other functions. The way to
73programmatically control how Emacs chooses a window to display a 73programmatically control how Emacs chooses a window to display a
74buffer is to bind the right combination of 74buffer is to bind the right combination of @code{pop-up-frames} and
75@code{special-display-regexps}, @code{pop-up-frames}, and other 75other variables.
76variables.
77 76
78@item 77@item
79The standard completion interface has been simplified, eliminating the 78The standard completion interface has been simplified, eliminating the
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index b9666a79f5b..4a556895de7 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -634,7 +634,8 @@ file should not be done.
634@c Emacs 19 feature 634@c Emacs 19 feature
635@defun visited-file-modtime 635@defun visited-file-modtime
636This function returns the current buffer's recorded last file 636This function returns the current buffer's recorded last file
637modification time, as a list of the form @code{(@var{high} @var{low})}. 637modification time, as a list of the form @code{(@var{high} @var{low}
638@var{microsec} @var{picosec})}.
638(This is the same format that @code{file-attributes} uses to return 639(This is the same format that @code{file-attributes} uses to return
639time values; see @ref{File Attributes}.) 640time values; see @ref{File Attributes}.)
640 641
@@ -664,9 +665,8 @@ is not @code{nil}, and otherwise to the last modification time of the
664visited file. 665visited file.
665 666
666If @var{time} is neither @code{nil} nor zero, it should have the form 667If @var{time} is neither @code{nil} nor zero, it should have the form
667@code{(@var{high} . @var{low})} or @code{(@var{high} @var{low})}, in 668@code{(@var{high} @var{low} @var{microsec} @var{picosec})},
668either case containing two integers, each of which holds 16 bits of the 669the format used by @code{current-time} (@pxref{Time of Day}).
669time.
670 670
671This function is useful if the buffer was not read from the file 671This function is useful if the buffer was not read from the file
672normally, or if the file itself has been changed for some known benign 672normally, or if the file itself has been changed for some known benign
@@ -1237,4 +1237,3 @@ This function returns the current gap position in the current buffer.
1237@defun gap-size 1237@defun gap-size
1238This function returns the current gap size of the current buffer. 1238This function returns the current gap size of the current buffer.
1239@end defun 1239@end defun
1240
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index 9ffa2b74857..c42e4b3b6dc 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -186,7 +186,6 @@ buffer: } prompts the user with @samp{Frobnicate buffer: } to enter
186the name of an existing buffer, which becomes the second and final 186the name of an existing buffer, which becomes the second and final
187argument. 187argument.
188 188
189@c Emacs 19 feature
190The prompt string can use @samp{%} to include previous argument values 189The prompt string can use @samp{%} to include previous argument values
191(starting with the first argument) in the prompt. This is done using 190(starting with the first argument) in the prompt. This is done using
192@code{format} (@pxref{Formatting Strings}). For example, here is how 191@code{format} (@pxref{Formatting Strings}). For example, here is how
@@ -205,7 +204,6 @@ If @samp{*} appears at the beginning of the string, then an error is
205signaled if the buffer is read-only. 204signaled if the buffer is read-only.
206 205
207@cindex @samp{@@} in @code{interactive} 206@cindex @samp{@@} in @code{interactive}
208@c Emacs 19 feature
209If @samp{@@} appears at the beginning of the string, and if the key 207If @samp{@@} appears at the beginning of the string, and if the key
210sequence used to invoke the command includes any mouse events, then 208sequence used to invoke the command includes any mouse events, then
211the window associated with the first of those events is selected 209the window associated with the first of those events is selected
@@ -910,7 +908,6 @@ up a menu. It is also used internally by @code{y-or-n-p}
910@end defvar 908@end defvar
911 909
912@defvar last-command-event 910@defvar last-command-event
913@defvarx last-command-char
914This variable is set to the last input event that was read by the 911This variable is set to the last input event that was read by the
915command loop as part of a command. The principal use of this variable 912command loop as part of a command. The principal use of this variable
916is in @code{self-insert-command}, which uses it to decide which 913is in @code{self-insert-command}, which uses it to decide which
@@ -926,11 +923,8 @@ last-command-event
926 923
927@noindent 924@noindent
928The value is 5 because that is the @acronym{ASCII} code for @kbd{C-e}. 925The value is 5 because that is the @acronym{ASCII} code for @kbd{C-e}.
929
930The alias @code{last-command-char} is obsolete.
931@end defvar 926@end defvar
932 927
933@c Emacs 19 feature
934@defvar last-event-frame 928@defvar last-event-frame
935This variable records which frame the last input event was directed to. 929This variable records which frame the last input event was directed to.
936Usually this is the frame that was selected when the event was 930Usually this is the frame that was selected when the event was
@@ -2386,7 +2380,6 @@ mouse on the window's mode line, you get two events, like this:
2386@end example 2380@end example
2387 2381
2388@defvar num-input-keys 2382@defvar num-input-keys
2389@c Emacs 19 feature
2390This variable's value is the number of key sequences processed so far in 2383This variable's value is the number of key sequences processed so far in
2391this Emacs session. This includes key sequences read from the terminal 2384this Emacs session. This includes key sequences read from the terminal
2392and key sequences read from keyboard macros being executed. 2385and key sequences read from keyboard macros being executed.
@@ -2539,7 +2532,6 @@ then continues to wait for a valid input character, or keyboard-quit.
2539@code{keyboard-translate-table} (if applicable), before returning it 2532@code{keyboard-translate-table} (if applicable), before returning it
2540from @code{read-event}. 2533from @code{read-event}.
2541 2534
2542@c Emacs 19 feature
2543@defvar extra-keyboard-modifiers 2535@defvar extra-keyboard-modifiers
2544This variable lets Lisp programs ``press'' the modifier keys on the 2536This variable lets Lisp programs ``press'' the modifier keys on the
2545keyboard. The value is a character. Only the modifiers of the 2537keyboard. The value is a character. Only the modifiers of the
@@ -2755,7 +2747,6 @@ may return @code{t} when no input is available.
2755@end defun 2747@end defun
2756 2748
2757@defvar last-input-event 2749@defvar last-input-event
2758@defvarx last-input-char
2759This variable records the last terminal input event read, whether 2750This variable records the last terminal input event read, whether
2760as part of a command or explicitly by a Lisp program. 2751as part of a command or explicitly by a Lisp program.
2761 2752
@@ -2774,8 +2765,6 @@ this expression) remains the value of @code{last-command-event}.
2774 @result{} 49 2765 @result{} 49
2775@end group 2766@end group
2776@end example 2767@end example
2777
2778The alias @code{last-input-char} is obsolete.
2779@end defvar 2768@end defvar
2780 2769
2781@defmac while-no-input body@dots{} 2770@defmac while-no-input body@dots{}
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 0b5ada43744..68701a47126 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -3550,8 +3550,8 @@ Used to indicate buffer boundaries.
3550@itemx @code{vertical-bar}, @code{horizontal-bar} 3550@itemx @code{vertical-bar}, @code{horizontal-bar}
3551Used for different types of fringe cursors. 3551Used for different types of fringe cursors.
3552 3552
3553@item @code{empty-line}, @code{question-mark}, @code{exclamation-mark} 3553@item @code{empty-line}, @code{exclamation-mark}, @code{question-mark}, @code{exclamation-mark}
3554Unused. 3554Not used by core Emacs features.
3555@end table 3555@end table
3556 3556
3557@noindent 3557@noindent
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index d46cb071bf7..06a2ebfcaf8 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -486,6 +486,7 @@ Variables
486* Variable Aliases:: Variables that are aliases for other variables. 486* Variable Aliases:: Variables that are aliases for other variables.
487* Variables with Restricted Values:: Non-constant variables whose value can 487* Variables with Restricted Values:: Non-constant variables whose value can
488 @emph{not} be an arbitrary Lisp object. 488 @emph{not} be an arbitrary Lisp object.
489* Generalized Variables:: Extending the concept of variables.
489 490
490Scoping Rules for Variable Bindings 491Scoping Rules for Variable Bindings
491 492
@@ -800,17 +801,14 @@ Menu Keymaps
800* Menu Bar:: How to customize the menu bar. 801* Menu Bar:: How to customize the menu bar.
801* Tool Bar:: A tool bar is a row of images. 802* Tool Bar:: A tool bar is a row of images.
802* Modifying Menus:: How to add new items to a menu. 803* Modifying Menus:: How to add new items to a menu.
804* Easy Menu:: A convenience macro for defining menus.
803 805
804Defining Menus 806Defining Menus
805 807
806* Simple Menu Items:: A simple kind of menu key binding, 808* Simple Menu Items:: A simple kind of menu key binding.
807 limited in capabilities. 809* Extended Menu Items:: More complex menu item definitions.
808* Extended Menu Items:: More powerful menu item definitions
809 let you specify keywords to enable
810 various features.
811* Menu Separators:: Drawing a horizontal line through a menu. 810* Menu Separators:: Drawing a horizontal line through a menu.
812* Alias Menu Items:: Using command aliases in menu items. 811* Alias Menu Items:: Using command aliases in menu items.
813* Toolkit Differences:: Not all toolkits provide the same features.
814 812
815Major and Minor Modes 813Major and Minor Modes
816 814
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 285e6406426..a5710c789e9 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -938,7 +938,7 @@ on the 19th, @file{aug-20} was written on the 20th, and the file
938@end example 938@end example
939 939
940You can use @code{file-attributes} to get a file's last modification 940You can use @code{file-attributes} to get a file's last modification
941time as a list of two numbers. @xref{File Attributes}. 941time as a list of four integers. @xref{File Attributes}.
942@end defun 942@end defun
943 943
944@node Kinds of Files 944@node Kinds of Files
@@ -1228,11 +1228,11 @@ so this time will always hold the midnight of the day of last access.
1228 1228
1229@cindex modification time of file 1229@cindex modification time of file
1230@item 1230@item
1231The time of last modification as a list of two integers (as above). 1231The time of last modification as a list of four integers (as above).
1232This is the last time when the file's contents were modified. 1232This is the last time when the file's contents were modified.
1233 1233
1234@item 1234@item
1235The time of last status change as a list of two integers (as above). 1235The time of last status change as a list of four integers (as above).
1236This is the time of the last change to the file's access mode bits, 1236This is the time of the last change to the file's access mode bits,
1237its owner and group, and other information recorded in the filesystem 1237its owner and group, and other information recorded in the filesystem
1238for the file, beyond the file's contents. 1238for the file, beyond the file's contents.
@@ -1275,9 +1275,9 @@ For example, here are the file attributes for @file{files.texi}:
1275@group 1275@group
1276(file-attributes "files.texi" 'string) 1276(file-attributes "files.texi" 'string)
1277 @result{} (nil 1 "lh" "users" 1277 @result{} (nil 1 "lh" "users"
1278 (19145 42977) 1278 (20614 64019 50040 152000)
1279 (19141 59576) 1279 (20000 23 0 0)
1280 (18340 17300) 1280 (20614 64555 902289 872000)
1281 122295 "-rw-rw-rw-" 1281 122295 "-rw-rw-rw-"
1282 nil (5888 2 . 43978) 1282 nil (5888 2 . 43978)
1283 (15479 . 46724)) 1283 (15479 . 46724))
@@ -1301,14 +1301,14 @@ is owned by the user with name "lh".
1301@item "users" 1301@item "users"
1302is in the group with name "users". 1302is in the group with name "users".
1303 1303
1304@item (19145 42977) 1304@item (20614 64019 50040 152000)
1305was last accessed on Oct 5 2009, at 10:01:37. 1305was last accessed on October 23, 2012, at 20:12:03.050040152 UTC.
1306 1306
1307@item (19141 59576) 1307@item (20000 23 0 0)
1308last had its contents modified on Oct 2 2009, at 13:49:12. 1308was last modified on July 15, 2001, at 08:53:43 UTC.
1309 1309
1310@item (18340 17300) 1310@item (20614 64555 902289 872000)
1311last had its status changed on Feb 2 2008, at 12:19:00. 1311last had its status changed on October 23, 2012, at 20:20:59.902289872 UTC.
1312 1312
1313@item 122295 1313@item 122295
1314is 122295 bytes long. (It may not contain 122295 characters, though, 1314is 122295 bytes long. (It may not contain 122295 characters, though,
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index af6f4b4c079..f58d62675e5 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -437,13 +437,11 @@ Emacs frames---the first frame, and subsequent frames. When using the X
437Window System, you can get the same results by means of X resources 437Window System, you can get the same results by means of X resources
438in many cases. 438in many cases.
439 439
440Setting this variable does not affect existing frames. 440Setting this variable does not affect existing frames. Furthermore,
441functions that display a buffer in a separate frame may override the
442default parameters by supplying their own parameters.
441@end defopt 443@end defopt
442 444
443Functions that display a buffer in a separate frame can override the
444default parameters by supplying their own parameters. @xref{Definition
445of special-display-frame-alist}.
446
447If you invoke Emacs with command-line options that specify frame 445If you invoke Emacs with command-line options that specify frame
448appearance, those options take effect by adding elements to either 446appearance, those options take effect by adding elements to either
449@code{initial-frame-alist} or @code{default-frame-alist}. Options 447@code{initial-frame-alist} or @code{default-frame-alist}. Options
@@ -1495,8 +1493,9 @@ This function returns the visibility status of frame @var{frame}. The
1495value is @code{t} if @var{frame} is visible, @code{nil} if it is 1493value is @code{t} if @var{frame} is visible, @code{nil} if it is
1496invisible, and @code{icon} if it is iconified. 1494invisible, and @code{icon} if it is iconified.
1497 1495
1498On a text terminal, all frames are considered visible, whether they 1496On a text terminal, all frames are considered ``visible'' for the
1499are currently being displayed or not. 1497purposes of this function, even though only one frame is displayed.
1498@xref{Raising and Lowering}.
1500@end defun 1499@end defun
1501 1500
1502@deffn Command iconify-frame &optional frame 1501@deffn Command iconify-frame &optional frame
@@ -1552,9 +1551,21 @@ If this is non-@code{nil}, activation of the minibuffer raises the frame
1552that the minibuffer window is in. 1551that the minibuffer window is in.
1553@end defopt 1552@end defopt
1554 1553
1555You can also enable auto-raise (raising automatically when a frame is 1554 On window systems, you can also enable auto-raising (on frame
1556selected) or auto-lower (lowering automatically when it is deselected) 1555selection) or auto-lowering (on frame deselection) using frame
1557for any frame using frame parameters. @xref{Management Parameters}. 1556parameters. @xref{Management Parameters}.
1557
1558@cindex top frame
1559 The concept of raising and lowering frames also applies to text
1560terminal frames. On each text terminal, only the top frame is
1561displayed at any one time.
1562
1563@defun tty-top-frame terminal
1564This function returns the top frame on @var{terminal}. @var{terminal}
1565should be a terminal object, a frame (meaning that frame's terminal),
1566or @code{nil} (meaning the selected frame's terminal). If it does not
1567refer to a text terminal, the return value is @code{nil}.
1568@end defun
1558 1569
1559@node Frame Configurations 1570@node Frame Configurations
1560@section Frame Configurations 1571@section Frame Configurations
diff --git a/doc/lispref/hooks.texi b/doc/lispref/hooks.texi
index a7f01243641..a6ac2c70e84 100644
--- a/doc/lispref/hooks.texi
+++ b/doc/lispref/hooks.texi
@@ -120,14 +120,7 @@ The command loop runs this soon after @code{post-command-hook} (q.v.).
120@item delete-terminal-functions 120@item delete-terminal-functions
121@xref{Multiple Terminals}. 121@xref{Multiple Terminals}.
122 122
123@ignore
124@item disabled-command-function
125@xref{Disabling Commands}.
126@end ignore
127
128@item display-buffer-function
129@itemx pop-up-frame-function 123@itemx pop-up-frame-function
130@itemx special-display-function
131@itemx split-window-preferred-function 124@itemx split-window-preferred-function
132@xref{Choosing Window Options}. 125@xref{Choosing Window Options}.
133 126
@@ -272,7 +265,6 @@ deferred-action-function
272input-method-function 265input-method-function
273load-read-function 266load-read-function
274load-source-file-function 267load-source-file-function
275macro-declaration-function
276read-buffer-function 268read-buffer-function
277ring-bell-function 269ring-bell-function
278select-safe-coding-system-function 270select-safe-coding-system-function
diff --git a/doc/lispref/intro.texi b/doc/lispref/intro.texi
index e61e13662db..4770701b601 100644
--- a/doc/lispref/intro.texi
+++ b/doc/lispref/intro.texi
@@ -493,13 +493,13 @@ giving a prefix argument makes @var{here} non-@code{nil}.
493 493
494@defvar emacs-build-time 494@defvar emacs-build-time
495The value of this variable indicates the time at which Emacs was 495The value of this variable indicates the time at which Emacs was
496built. It is a list of three integers, like the value of 496built. It is a list of four integers, like the value of
497@code{current-time} (@pxref{Time of Day}). 497@code{current-time} (@pxref{Time of Day}).
498 498
499@example 499@example
500@group 500@group
501emacs-build-time 501emacs-build-time
502 @result{} (18846 52016 156039) 502 @result{} (20614 63694 515336 438000)
503@end group 503@end group
504@end example 504@end example
505@end defvar 505@end defvar
diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi
index 9fa6193a804..f658f7e66fb 100644
--- a/doc/lispref/keymaps.texi
+++ b/doc/lispref/keymaps.texi
@@ -210,6 +210,11 @@ Aside from elements that specify bindings for keys, a keymap can also
210have a string as an element. This is called the @dfn{overall prompt 210have a string as an element. This is called the @dfn{overall prompt
211string} and makes it possible to use the keymap as a menu. 211string} and makes it possible to use the keymap as a menu.
212@xref{Defining Menus}. 212@xref{Defining Menus}.
213
214@item (keymap @dots{})
215If an element of a keymap is itself a keymap, it counts as if this inner keymap
216were inlined in the outer keymap. This is used for multiple-inheritance, such
217as in @code{make-composed-keymap}.
213@end table 218@end table
214 219
215When the binding is @code{nil}, it doesn't constitute a definition 220When the binding is @code{nil}, it doesn't constitute a definition
@@ -1963,13 +1968,14 @@ is active for the next input event, that activates the keyboard menu
1963feature. 1968feature.
1964 1969
1965@menu 1970@menu
1966* Defining Menus:: How to make a keymap that defines a menu. 1971* Defining Menus:: How to make a keymap that defines a menu.
1967* Mouse Menus:: How users actuate the menu with the mouse. 1972* Mouse Menus:: How users actuate the menu with the mouse.
1968* Keyboard Menus:: How users actuate the menu with the keyboard. 1973* Keyboard Menus:: How users actuate the menu with the keyboard.
1969* Menu Example:: Making a simple menu. 1974* Menu Example:: Making a simple menu.
1970* Menu Bar:: How to customize the menu bar. 1975* Menu Bar:: How to customize the menu bar.
1971* Tool Bar:: A tool bar is a row of images. 1976* Tool Bar:: A tool bar is a row of images.
1972* Modifying Menus:: How to add new items to a menu. 1977* Modifying Menus:: How to add new items to a menu.
1978* Easy Menu:: A convenience macro for making menus.
1973@end menu 1979@end menu
1974 1980
1975@node Defining Menus 1981@node Defining Menus
@@ -2015,17 +2021,12 @@ an existing menu, you can specify its position in the menu using
2015@code{define-key-after} (@pxref{Modifying Menus}). 2021@code{define-key-after} (@pxref{Modifying Menus}).
2016 2022
2017@menu 2023@menu
2018* Simple Menu Items:: A simple kind of menu key binding, 2024* Simple Menu Items:: A simple kind of menu key binding.
2019 limited in capabilities. 2025* Extended Menu Items:: More complex menu item definitions.
2020* Extended Menu Items:: More powerful menu item definitions
2021 let you specify keywords to enable
2022 various features.
2023* Menu Separators:: Drawing a horizontal line through a menu. 2026* Menu Separators:: Drawing a horizontal line through a menu.
2024* Alias Menu Items:: Using command aliases in menu items. 2027* Alias Menu Items:: Using command aliases in menu items.
2025* Toolkit Differences:: Not all toolkits provide the same features.
2026@end menu 2028@end menu
2027 2029
2028
2029@node Simple Menu Items 2030@node Simple Menu Items
2030@subsubsection Simple Menu Items 2031@subsubsection Simple Menu Items
2031 2032
@@ -2312,28 +2313,6 @@ itself). To request this, give the alias symbol a non-@code{nil}
2312causes menu items for @code{make-read-only} and @code{make-writable} to 2313causes menu items for @code{make-read-only} and @code{make-writable} to
2313show the keyboard bindings for @code{read-only-mode}. 2314show the keyboard bindings for @code{read-only-mode}.
2314 2315
2315@node Toolkit Differences
2316@subsubsection Toolkit Differences
2317
2318The various toolkits with which you can build Emacs do not all support
2319the same set of features for menus. Some code works as expected with
2320one toolkit, but not under another.
2321
2322One example is menu actions or buttons in a top-level menu bar. The
2323following works with the Lucid toolkit or on MS Windows, but not with
2324GTK or Nextstep, where clicking on the item has no effect.
2325
2326@example
2327(defun menu-action-greet ()
2328 (interactive)
2329 (message "Hello Emacs User!"))
2330
2331(defun top-level-menu ()
2332 (interactive)
2333 (define-key lisp-interaction-mode-map [menu-bar m]
2334 '(menu-item "Action Button" menu-action-greet)))
2335@end example
2336
2337@node Mouse Menus 2316@node Mouse Menus
2338@subsection Menus and the Mouse 2317@subsection Menus and the Mouse
2339 2318
@@ -2813,3 +2792,125 @@ menu of Shell mode, after the item @code{break}:
2813 [work] '("Work" . work-command) 'break) 2792 [work] '("Work" . work-command) 'break)
2814@end example 2793@end example
2815@end defun 2794@end defun
2795
2796@node Easy Menu
2797@subsection Easy Menu
2798
2799 The following macro provides a convenient way to define pop-up menus
2800and/or menu bar menus.
2801
2802@defmac easy-menu-define symbol maps doc menu
2803This macro defines a pop-up menu and/or menu bar submenu, whose
2804contents are given by @var{menu}.
2805
2806If @var{symbol} is non-@code{nil}, it should be a symbol; then this
2807macro defines @var{symbol} as a function for popping up the menu
2808(@pxref{Pop-Up Menus}), with @var{doc} as its documentation string.
2809@var{symbol} should not be quoted.
2810
2811Regardless of the value of @var{symbol}, if @var{maps} is a keymap,
2812the menu is added to that keymap, as a top-level menu for the menu bar
2813(@pxref{Menu Bar}). It can also be a list of keymaps, in which case
2814the menu is added separately to each of those keymaps.
2815
2816The first element of @var{menu} must be a string, which serves as the
2817menu label. It may be followed by any number of the following
2818keyword-argument pairs:
2819
2820@table @code
2821@item :filter @var{function}
2822@var{function} must be a function which, if called with one
2823argument---the list of the other menu items---returns the actual items
2824to be displayed in the menu.
2825
2826@item :visible @var{include}
2827@var{include} is an expression; if it evaluates to @code{nil}, the
2828menu is made invisible. @code{:included} is an alias for
2829@code{:visible}.
2830
2831@item :active @var{enable}
2832@var{enable} is an expression; if it evaluates to @code{nil}, the menu
2833is not selectable. @code{:enable} is an alias for @code{:active}.
2834@end table
2835
2836The remaining elements in @var{menu} are menu items.
2837
2838A menu item can be a vector of three elements, @code{[@var{name}
2839@var{callback} @var{enable}]}. @var{name} is the menu item name (a
2840string). @var{callback} is a command to run, or an expression to
2841evaluate, when the item is chosen. @var{enable} is an expression; if
2842it evaluates to @code{nil}, the item is disabled for selection.
2843
2844Alternatively, a menu item may have the form:
2845
2846@smallexample
2847 [ @var{name} @var{callback} [ @var{keyword} @var{arg} ]... ]
2848@end smallexample
2849
2850@noindent
2851where @var{name} and @var{callback} have the same meanings as above,
2852and each optional @var{keyword} and @var{arg} pair should be one of
2853the following:
2854
2855@table @code
2856@item :keys @var{keys}
2857@var{keys} is a keyboard equivalent to the menu item (a string). This
2858is normally not needed, as keyboard equivalents are computed
2859automatically. @var{keys} is expanded with
2860@code{substitute-command-keys} before it is displayed (@pxref{Keys in
2861Documentation}).
2862
2863@item :key-sequence @var{keys}
2864@var{keys} is a hint for speeding up Emacs's first display of the
2865menu. It should be nil if you know that the menu item has no keyboard
2866equivalent; otherwise it should be a string or vector specifying a
2867keyboard equivalent for the menu item.
2868
2869@item :active @var{enable}
2870@var{enable} is an expression; if it evaluates to @code{nil}, the item
2871is make unselectable.. @code{:enable} is an alias for @code{:active}.
2872
2873@item :visible @var{include}
2874@var{include} is an expression; if it evaluates to @code{nil}, the
2875item is made invisible. @code{:included} is an alias for
2876@code{:visible}.
2877
2878@item :label @var{form}
2879@var{form} is an expression that is evaluated to obtain a value which
2880serves as the menu item's label (the default is @var{name}).
2881
2882@item :suffix @var{form}
2883@var{form} is an expression that is dynamically evaluated and whose
2884value is concatenated with the menu entry's label.
2885
2886@item :style @var{style}
2887@var{style} is a symbol describing the type of menu item; it should be
2888@code{toggle} (a checkbox), or @code{radio} (a radio button), or
2889anything else (meaning an ordinary menu item).
2890
2891@item :selected @var{selected}
2892@var{selected} is an expression; the checkbox or radio button is
2893selected whenever the expression's value is non-nil.
2894
2895@item :help @var{help}
2896@var{help} is a string describing the menu item.
2897@end table
2898
2899Alternatively, a menu item can be a string. Then that string appears
2900in the menu as unselectable text. A string consisting of dashes is
2901displayed as a separator (@pxref{Menu Separators}).
2902
2903Alternatively, a menu item can be a list with the same format as
2904@var{menu}. This is a submenu.
2905@end defmac
2906
2907Here is an example of using @code{easy-menu-define} to define a menu
2908similar to the one defined in the example in @ref{Menu Bar}:
2909
2910@example
2911(easy-menu-define words-menu global-map
2912 "Menu for word navigation commands."
2913 '("Words"
2914 ["Forward word" forward-word]
2915 ["Backward word" backward-word]))
2916@end example
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi
index 4a8740a5734..09948caaa13 100644
--- a/doc/lispref/lists.texi
+++ b/doc/lispref/lists.texi
@@ -236,6 +236,10 @@ This is in contrast to @code{cdr}, which signals an error if
236@defmac pop listname 236@defmac pop listname
237This macro is a way of examining the @sc{car} of a list, 237This macro is a way of examining the @sc{car} of a list,
238and taking it off the list, all at once. 238and taking it off the list, all at once.
239@c FIXME I don't think is a particularly good way to do it,
240@c but generalized variables have not been introduced yet.
241(In fact, this macro can act on generalized variables, not just lists.
242@xref{Generalized Variables}.)
239 243
240It operates on the list which is stored in the symbol @var{listname}. 244It operates on the list which is stored in the symbol @var{listname}.
241It removes this element from the list by setting @var{listname} 245It removes this element from the list by setting @var{listname}
@@ -252,7 +256,7 @@ x
252@end example 256@end example
253 257
254@noindent 258@noindent
255For the @code{pop} macro, which removes an element from a list, 259For the @code{push} macro, which adds an element to a list,
256@xref{List Variables}. 260@xref{List Variables}.
257@end defmac 261@end defmac
258 262
@@ -682,6 +686,10 @@ to modify a list which is stored in a variable.
682@defmac push newelt listname 686@defmac push newelt listname
683This macro provides an alternative way to write 687This macro provides an alternative way to write
684@code{(setq @var{listname} (cons @var{newelt} @var{listname}))}. 688@code{(setq @var{listname} (cons @var{newelt} @var{listname}))}.
689@c FIXME I don't think is a particularly good way to do it,
690@c but generalized variables have not been introduced yet.
691(In fact, this macro can act on generalized variables, not just lists.
692@xref{Generalized Variables}.)
685 693
686@example 694@example
687(setq l '(a b)) 695(setq l '(a b))
diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi
index 77a31cfde7a..6a18bea2977 100644
--- a/doc/lispref/loading.texi
+++ b/doc/lispref/loading.texi
@@ -408,9 +408,9 @@ to load automatically from @var{filename}. The string @var{filename}
408specifies the file to load to get the real definition of @var{function}. 408specifies the file to load to get the real definition of @var{function}.
409 409
410If @var{filename} does not contain either a directory name, or the 410If @var{filename} does not contain either a directory name, or the
411suffix @code{.el} or @code{.elc}, then @code{autoload} insists on adding 411suffix @code{.el} or @code{.elc}, this function insists on adding one
412one of these suffixes, and it will not load from a file whose name is 412of these suffixes, and it will not load from a file whose name is just
413just @var{filename} with no added suffix. (The variable 413@var{filename} with no added suffix. (The variable
414@code{load-suffixes} specifies the exact required suffixes.) 414@code{load-suffixes} specifies the exact required suffixes.)
415 415
416The argument @var{docstring} is the documentation string for the 416The argument @var{docstring} is the documentation string for the
@@ -442,10 +442,11 @@ and calls @code{define-key}; not even if the variable name is the same
442symbol @var{function}. 442symbol @var{function}.
443 443
444@cindex function cell in autoload 444@cindex function cell in autoload
445If @var{function} already has a non-void function definition that is not 445if @var{function} already has non-void function definition that is not
446an autoload object, @code{autoload} does nothing and returns @code{nil}. 446an autoload object, this function does nothing and returns @code{nil}.
447If the function cell of @var{function} is void, or is already an autoload 447Otherwise, it constructs an autoload object (@pxref{Autoload Type}),
448object, then it is defined as an autoload object like this: 448and stores it as the function definition for @var{function}. The
449autoload object has this form:
449 450
450@example 451@example
451(autoload @var{filename} @var{docstring} @var{interactive} @var{type}) 452(autoload @var{filename} @var{docstring} @var{interactive} @var{type})
@@ -468,6 +469,16 @@ refers to the documentation string in the
468not a macro or a keymap. 469not a macro or a keymap.
469@end defun 470@end defun
470 471
472@defun autoloadp object
473This function returns non-@code{nil} if @var{object} is an autoload
474object. For example, to check if @code{run-prolog} is defined as an
475autoloaded function, evaluate
476
477@smallexample
478(autoloadp (symbol-function 'run-prolog))
479@end smallexample
480@end defun
481
471@cindex autoload errors 482@cindex autoload errors
472 The autoloaded file usually contains other definitions and may require 483 The autoloaded file usually contains other definitions and may require
473or provide one or more features. If the file is not completely loaded 484or provide one or more features. If the file is not completely loaded
@@ -599,6 +610,19 @@ override that, e.g., in the ``Local Variables'' section of a
599assumed to contain a trailer starting with a formfeed character. 610assumed to contain a trailer starting with a formfeed character.
600@end defvar 611@end defvar
601 612
613 The following function may be used to explicitly load the library
614specified by an autoload object:
615
616@defun autoload-do-load autoload &optional name macro-only
617This function performs the loading specified by @var{autoload}, which
618whould be an autoload object. The optional argument @var{name}, if
619non-@code{nil}, should be a symbol whose function value is
620@var{autoload}; in that case, the return value of this function is the
621symbol's new function value. If the value of the optional argument
622@var{macro-only} is @code{macro}, this function avoids loading a
623function, only a macro.
624@end defun
625
602@node Repeated Loading 626@node Repeated Loading
603@section Repeated Loading 627@section Repeated Loading
604@cindex repeated loading 628@cindex repeated loading
diff --git a/doc/lispref/markers.texi b/doc/lispref/markers.texi
index 80136f2e6f4..fa884269b36 100644
--- a/doc/lispref/markers.texi
+++ b/doc/lispref/markers.texi
@@ -307,11 +307,6 @@ This function returns the buffer that @var{marker} points into, or
307@end example 307@end example
308@end defun 308@end defun
309 309
310@defun buffer-has-markers-at position
311This function returns @code{t} if one or more markers
312point at position @var{position} in the current buffer.
313@end defun
314
315@node Marker Insertion Types 310@node Marker Insertion Types
316@section Marker Insertion Types 311@section Marker Insertion Types
317 312
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 39b4fca3b25..7243f46b882 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -211,22 +211,25 @@ This function works by calling the
211@end smallexample 211@end smallexample
212@end defun 212@end defun
213 213
214@defun read-regexp prompt &optional default 214@defun read-regexp prompt &optional default history
215This function reads a regular expression as a string from the 215This function reads a regular expression as a string from the
216minibuffer and returns it. The argument @var{prompt} is used as in 216minibuffer and returns it. The argument @var{prompt} is used as in
217@code{read-from-minibuffer}. The keymap used is 217@code{read-from-minibuffer}.
218@code{minibuffer-local-map}, and @code{regexp-history} is used as the
219history list (@pxref{Minibuffer History, regexp-history}).
220 218
221The optional argument @var{default} specifies a default value to 219The optional argument @var{default} specifies a default value to
222return if the user enters null input; it should be a string, or 220return if the user enters null input; it should be a string, or
223@code{nil}, which is equivalent to an empty string. 221@code{nil}, which is equivalent to an empty string.
224 222
225In addition, @code{read-regexp} collects a few useful candidates for 223The optional argument @var{history}, if non-@code{nil}, is a symbol
226input and passes them to @code{read-from-minibuffer}, to make them 224specifying a minibuffer history list to use (@pxref{Minibuffer
227available to the user as the ``future minibuffer history list'' 225History}). If it is omitted or @code{nil}, the history list defaults
228(@pxref{Minibuffer History, future list,, emacs, The GNU Emacs 226to @code{regexp-history}.
229Manual}). These candidates are: 227
228@code{read-regexp} also collects a few useful candidates for input and
229passes them to @code{read-from-minibuffer}, to make them available to
230the user as the ``future minibuffer history list'' (@pxref{Minibuffer
231History, future list,, emacs, The GNU Emacs Manual}). These
232candidates are:
230 233
231@itemize @minus 234@itemize @minus
232@item 235@item
@@ -1215,11 +1218,9 @@ Buffer name (default foo): @point{}
1215@end defun 1218@end defun
1216 1219
1217@defopt read-buffer-function 1220@defopt read-buffer-function
1218This variable specifies how to read buffer names. The function is 1221This variable, if non-@code{nil}, specifies a function for reading
1219called with the arguments passed to @code{read-buffer}. For example, 1222buffer names. @code{read-buffer} calls this function instead of doing
1220if you set this variable to @code{iswitchb-read-buffer}, all Emacs 1223its usual work, with the same arguments passed to @code{read-buffer}.
1221commands that call @code{read-buffer} to read a buffer name will
1222actually use the @code{iswitchb} package to read it.
1223@end defopt 1224@end defopt
1224 1225
1225@defopt read-buffer-completion-ignore-case 1226@defopt read-buffer-completion-ignore-case
diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi
index 2f6f516c587..e384d40176e 100644
--- a/doc/lispref/nonascii.texi
+++ b/doc/lispref/nonascii.texi
@@ -241,8 +241,12 @@ representation is in use. It also adjusts various data in the buffer
241(including overlays, text properties and markers) so that they cover the 241(including overlays, text properties and markers) so that they cover the
242same text as they did before. 242same text as they did before.
243 243
244You cannot use @code{set-buffer-multibyte} on an indirect buffer, 244This function signals an error if the buffer is narrowed, since the
245because indirect buffers always inherit the representation of the 245narrowing might have occurred in the middle of multibyte character
246sequences.
247
248This function also signals an error if the buffer is an indirect
249buffer. An indirect buffer always inherits the representation of its
246base buffer. 250base buffer.
247@end defun 251@end defun
248 252
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index d3c3c6fd241..6c5f6e85683 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -1199,7 +1199,7 @@ Similarly, the fourth list element @var{picosec}, if present, gives
1199the number of picoseconds from the start of that microsecond to the 1199the number of picoseconds from the start of that microsecond to the
1200specified time. 1200specified time.
1201 1201
1202 The return value of @code{current-time} represents time using three 1202 The return value of @code{current-time} represents time using four
1203integers, as do the timestamps in the return value of 1203integers, as do the timestamps in the return value of
1204@code{file-attributes} (@pxref{Definition of 1204@code{file-attributes} (@pxref{Definition of
1205file-attributes}). In function arguments, e.g.@: the @var{time-value} 1205file-attributes}). In function arguments, e.g.@: the @var{time-value}
diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi
index d7497ab6f3f..326c6cd4ab2 100644
--- a/doc/lispref/symbols.texi
+++ b/doc/lispref/symbols.texi
@@ -487,6 +487,12 @@ using @code{eq}, so any object is a legitimate property.
487See @code{put} for an example. 487See @code{put} for an example.
488@end defun 488@end defun
489 489
490@defun function-get symbol property
491This function is identical to @code{get}, except that if @var{symbol}
492is the name of a function alias, it looks in the property list of the
493symbol naming the actual function. @xref{Defining Functions}.
494@end defun
495
490@defun put symbol property value 496@defun put symbol property value
491This function puts @var{value} onto @var{symbol}'s property list under 497This function puts @var{value} onto @var{symbol}'s property list under
492the property name @var{property}, replacing any previous property value. 498the property name @var{property}, replacing any previous property value.
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 50b97cd4204..57df02b74a0 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -899,31 +899,34 @@ In Lisp programs, it is better to use @code{kill-new} or
899@node Yanking 899@node Yanking
900@subsection Yanking 900@subsection Yanking
901 901
902 Yanking means inserting text from the kill ring, but it does 902 Yanking means inserting text from the kill ring, but it does not
903not insert the text blindly. Yank commands and some other commands 903insert the text blindly. The @code{yank} command, and related
904use @code{insert-for-yank} to perform special processing on the 904commands, use @code{insert-for-yank} to perform special processing on
905text that they copy into the buffer. 905the text before it is inserted.
906 906
907@defun insert-for-yank string 907@defun insert-for-yank string
908This function normally works like @code{insert} except that it doesn't 908This function works like @code{insert}, except that it processes the
909insert the text properties (@pxref{Text Properties}) in the list 909text in @var{string} according to the @code{yank-handler} text
910variable @code{yank-excluded-properties}. However, if any part of 910property, as well as the variables @code{yank-handled-properties} and
911@var{string} has a non-@code{nil} @code{yank-handler} text property, 911@code{yank-excluded-properties} (see below), before inserting the
912that property can do various special processing on that part of the 912result into the current buffer.
913text being inserted.
914@end defun 913@end defun
915 914
916@defun insert-buffer-substring-as-yank buf &optional start end 915@defun insert-buffer-substring-as-yank buf &optional start end
917This function resembles @code{insert-buffer-substring} except that it 916This function resembles @code{insert-buffer-substring}, except that it
918doesn't insert the text properties in the 917processes the text according to @code{yank-handled-properties} and
919@code{yank-excluded-properties} list. 918@code{yank-excluded-properties}. (It does not handle the
919@code{yank-handler} property, which does not normally occur in buffer
920text anyway.)
920@end defun 921@end defun
921 922
922 You can put a @code{yank-handler} text property on all or part of 923 If you put a @code{yank-handler} text property on all or part of a
923the text to control how it will be inserted if it is yanked. The 924string, that alters how @code{insert-for-yank} inserts the string. If
924@code{insert-for-yank} function looks for that property. The property 925different parts of the string have different @code{yank-handler}
925value must be a list of one to four elements, with the following 926values (comparison being done with @code{eq}), each substring is
926format (where elements after the first may be omitted): 927handled separately. The property value must be a list of one to four
928elements, with the following format (where elements after the first
929may be omitted):
927 930
928@example 931@example
929(@var{function} @var{param} @var{noexclude} @var{undo}) 932(@var{function} @var{param} @var{noexclude} @var{undo})
@@ -933,22 +936,21 @@ format (where elements after the first may be omitted):
933 936
934@table @var 937@table @var
935@item function 938@item function
936When @var{function} is present and non-@code{nil}, it is called instead of 939When @var{function} is non-@code{nil}, it is called instead of
937@code{insert} to insert the string. @var{function} takes one 940@code{insert} to insert the string, with one argument---the string to
938argument---the string to insert. 941insert.
939 942
940@item param 943@item param
941If @var{param} is present and non-@code{nil}, it replaces @var{string} 944If @var{param} is present and non-@code{nil}, it replaces @var{string}
942(or the part of @var{string} being processed) as the object passed to 945(or the substring of @var{string} being processed) as the object
943@var{function} (or @code{insert}); for example, if @var{function} is 946passed to @var{function} (or @code{insert}). For example, if
944@code{yank-rectangle}, @var{param} should be a list of strings to 947@var{function} is @code{yank-rectangle}, @var{param} should be a list
945insert as a rectangle. 948of strings to insert as a rectangle.
946 949
947@item noexclude 950@item noexclude
948If @var{noexclude} is present and non-@code{nil}, the normal removal of the 951If @var{noexclude} is present and non-@code{nil}, that disables the
949yank-excluded-properties is not performed; instead @var{function} is 952normal action of @code{yank-handled-properties} and
950responsible for removing those properties. This may be necessary 953@code{yank-excluded-properties} on the inserted string.
951if @var{function} adjusts point before or after inserting the object.
952 954
953@item undo 955@item undo
954If @var{undo} is present and non-@code{nil}, it is a function that will be 956If @var{undo} is present and non-@code{nil}, it is a function that will be
@@ -959,14 +961,29 @@ the @var{undo} value.
959@end table 961@end table
960 962
961@cindex yanking and text properties 963@cindex yanking and text properties
964@defopt yank-handled-properties
965This variable specifies special text property handling conditions for
966yanked text. It takes effect after the text has been inserted (either
967normally, or via the @code{yank-handler} property), and prior to
968@code{yank-excluded-properties} taking effect.
969
970The value should be an alist of elements @code{(@var{prop}
971. @var{fun})}. Each alist element is handled in order. The inserted
972text is scanned for stretches of text having text properties @code{eq}
973to @var{prop}; for each such stretch, @var{fun} is called with three
974arguments: the value of the property, and the start and end positions
975of the text.
976@end defopt
977
962@defopt yank-excluded-properties 978@defopt yank-excluded-properties
963Yanking discards certain text properties from the yanked text, as 979The value of this variable is the list of properties to remove from
964described above. The value of this variable is the list of properties 980inserted text. Its default value contains properties that might lead
965to discard. Its default value contains properties that might lead to 981to annoying results, such as causing the text to respond to the mouse
966annoying results, such as causing the text to respond to the mouse or 982or specifying key bindings. It takes effect after
967specifying key bindings. 983@code{yank-handled-properties}.
968@end defopt 984@end defopt
969 985
986
970@node Yank Commands 987@node Yank Commands
971@subsection Functions for Yanking 988@subsection Functions for Yanking
972 989
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 1c0abcb8e66..580dd8258df 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -41,6 +41,7 @@ representing the variable.
41* Variable Aliases:: Variables that are aliases for other variables. 41* Variable Aliases:: Variables that are aliases for other variables.
42* Variables with Restricted Values:: Non-constant variables whose value can 42* Variables with Restricted Values:: Non-constant variables whose value can
43 @emph{not} be an arbitrary Lisp object. 43 @emph{not} be an arbitrary Lisp object.
44* Generalized Variables:: Extending the concept of variables.
44@end menu 45@end menu
45 46
46@node Global Variables 47@node Global Variables
@@ -1946,3 +1947,105 @@ Attempting to assign them any other value will result in an error:
1946(setq undo-limit 1000.0) 1947(setq undo-limit 1000.0)
1947@error{} Wrong type argument: integerp, 1000.0 1948@error{} Wrong type argument: integerp, 1000.0
1948@end example 1949@end example
1950
1951@c FIXME? Not sure this is the right place for this section.
1952@node Generalized Variables
1953@section Generalized Variables
1954
1955A @dfn{generalized variable} or @dfn{place form} is one of the many places
1956in Lisp memory where values can be stored. The simplest place form is
1957a regular Lisp variable. But the @sc{car}s and @sc{cdr}s of lists, elements
1958of arrays, properties of symbols, and many other locations are also
1959places where Lisp values are stored.
1960
1961@c FIXME? Not sure this is a useful analogy...
1962Generalized variables are analogous to ``lvalues'' in the C
1963language, where @samp{x = a[i]} gets an element from an array
1964and @samp{a[i] = x} stores an element using the same notation.
1965Just as certain forms like @code{a[i]} can be lvalues in C, there
1966is a set of forms that can be generalized variables in Lisp.
1967
1968The @code{setf} macro is the most basic way to operate on generalized
1969variables. The @code{setf} form is like @code{setq}, except that it
1970accepts arbitrary place forms on the left side rather than just
1971symbols. For example, @code{(setf (car a) b)} sets the car of
1972@code{a} to @code{b}, doing the same operation as @code{(setcar a b)},
1973but without having to remember two separate functions for setting and
1974accessing every type of place.
1975
1976@defmac setf [place form]@dots{}
1977This macro evaluates @var{form} and stores it in @var{place}, which
1978must be a valid generalized variable form. If there are several
1979@var{place} and @var{form} pairs, the assignments are done sequentially
1980just as with @code{setq}. @code{setf} returns the value of the last
1981@var{form}.
1982@end defmac
1983
1984The following Lisp forms will work as generalized variables, and
1985so may appear in the @var{place} argument of @code{setf}:
1986
1987@itemize
1988@item
1989A symbol naming a variable. In other words, @code{(setf x y)} is
1990exactly equivalent to @code{(setq x y)}, and @code{setq} itself is
1991strictly speaking redundant given that @code{setf} exists. Many
1992programmers continue to prefer @code{setq} for setting simple
1993variables, though, purely for stylistic or historical reasons.
1994The macro @code{(setf x y)} actually expands to @code{(setq x y)},
1995so there is no performance penalty for using it in compiled code.
1996
1997@item
1998A call to any of the following standard Lisp functions:
1999
2000@smallexample
2001car cdr nth nthcdr
2002caar cadr cdar cddr
2003aref elt get gethash
2004symbol-function symbol-value symbol-plist
2005@end smallexample
2006
2007@item
2008The following Emacs-specific functions are also @code{setf}-able:
2009
2010@smallexample
2011default-value process-get
2012frame-parameter process-sentinel
2013terminal-parameter window-buffer
2014keymap-parent window-display-table
2015match-data window-dedicated-p
2016overlay-get window-hscroll
2017overlay-start window-parameter
2018overlay-end window-point
2019process-buffer window-start
2020process-filter
2021@end smallexample
2022@end itemize
2023
2024@noindent
2025Using any forms other than these in the @var{place} argument to
2026@code{setf} will signal an error.
2027
2028@c And for cl-lib's cl-getf.
2029Note that for @code{nthcdr}, the list argument of the function must
2030itself be a valid @var{place} form. For example, @code{(setf (nthcdr
20310 foo) 7)} will set @code{foo} itself to 7.
2032@c The use of @code{nthcdr} as a @var{place} form is an extension
2033@c to standard Common Lisp.
2034
2035@c FIXME I don't think is a particularly good way to do it,
2036@c but these macros are introduced before gvs are.
2037The macros @code{push} (@pxref{List Variables}) and @code{pop}
2038(@pxref{List Elements}) can manipulate generalized variables,
2039not just lists. @code{(pop @var{place})} removes and returns the first
2040element of the list stored in @var{place}. It is analogous to
2041@code{(prog1 (car @var{place}) (setf @var{place} (cdr @var{place})))},
2042except that it takes care to evaluate all subforms only once.
2043@code{(push @var{x} @var{place})} inserts @var{x} at the front of
2044the list stored in @var{place}. It is analogous to @code{(setf
2045@var{place} (cons @var{x} @var{place}))}, except for evaluation of the
2046subforms. Note that @code{push} and @code{pop} on an @code{nthcdr}
2047place can be used to insert or delete at any position in a list.
2048
2049The @file{cl-lib} library defines various extensions for generalized
2050variables, including additional @code{setf} places.
2051@xref{Generalized Variables,,, cl, Common Lisp Extensions}.
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index ea48a46359c..d0e149eb165 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -76,30 +76,35 @@ within the area of the frame. When a window is created, resized, or
76deleted, the change in window space is taken from or given to the 76deleted, the change in window space is taken from or given to the
77adjacent windows, so that the total area of the frame is unchanged. 77adjacent windows, so that the total area of the frame is unchanged.
78 78
79@cindex live windows
80@cindex internal windows
81 A @dfn{live window} is one that is actually displaying a buffer in a
82frame. Such a window can be @dfn{deleted}, i.e. removed from the
83frame (@pxref{Deleting Windows}); then it is no longer live, but the
84Lisp object representing it might be still referenced from other Lisp
85objects. A deleted window may be brought back to life by restoring a
86saved window configuration (@pxref{Window Configurations}).
87
88@defun windowp object 79@defun windowp object
89This function returns @code{t} if @var{object} is a window (whether or 80This function returns @code{t} if @var{object} is a window (whether or
90not it is live). Otherwise, it returns @code{nil}. 81not it displays a buffer). Otherwise, it returns @code{nil}.
91@end defun 82@end defun
92 83
84@cindex live windows
85A @dfn{live window} is one that is actually displaying a buffer in a
86frame.
87
93@defun window-live-p object 88@defun window-live-p object
94This function returns @code{t} if @var{object} is a live window and 89This function returns @code{t} if @var{object} is a live window and
95@code{nil} otherwise. A live window is one that displays a buffer. 90@code{nil} otherwise. A live window is one that displays a buffer.
96@end defun 91@end defun
97 92
98 The windows in each frame are organized into a @dfn{window tree}. 93@cindex internal windows
99@xref{Windows and Frames}. The leaf nodes of each window tree are 94The windows in each frame are organized into a @dfn{window tree}.
100live windows---the ones actually displaying buffers. The internal 95@xref{Windows and Frames}. The leaf nodes of each window tree are live
101nodes of the window tree are internal windows, which are not live. 96windows---the ones actually displaying buffers. The internal nodes of
102You can distinguish internal windows from deleted windows with 97the window tree are @dfn{internal windows}, which are not live.
98
99@cindex valid windows
100 A @dfn{valid window} is one that is either live or internal. A valid
101window can be @dfn{deleted}, i.e. removed from its frame
102(@pxref{Deleting Windows}); then it is no longer valid, but the Lisp
103object representing it might be still referenced from other Lisp
104objects. A deleted window may be made valid again by restoring a saved
105window configuration (@pxref{Window Configurations}).
106
107 You can distinguish valid windows from deleted windows with
103@code{window-valid-p}. 108@code{window-valid-p}.
104 109
105@defun window-valid-p object 110@defun window-valid-p object
@@ -1317,31 +1322,37 @@ meaning as for @code{next-window}.
1317criterion, without selecting it: 1322criterion, without selecting it:
1318 1323
1319@cindex least recently used window 1324@cindex least recently used window
1320@defun get-lru-window &optional all-frames dedicated 1325@defun get-lru-window &optional all-frames dedicated not-selected
1321This function returns a live window which is heuristically the ``least 1326This function returns a live window which is heuristically the ``least
1322recently used'' window. The optional argument @var{all-frames} has 1327recently used'' window. The optional argument @var{all-frames} has
1323the same meaning as in @code{next-window}. 1328the same meaning as in @code{next-window}.
1324 1329
1325If any full-width windows are present, only those windows are 1330If any full-width windows are present, only those windows are
1326considered. The selected window is never returned, unless it is the 1331considered. A minibuffer window is never a candidate. A dedicated
1327only candidate. A minibuffer window is never a candidate. A 1332window (@pxref{Dedicated Windows}) is never a candidate unless the
1328dedicated window (@pxref{Dedicated Windows}) is never a candidate 1333optional argument @var{dedicated} is non-@code{nil}. The selected
1329unless the optional argument @var{dedicated} is non-@code{nil}. 1334window is never returned, unless it is the only candidate. However, if
1335the optional argument @var{not-selected} is non-@code{nil}, this
1336function returns @code{nil} in that case.
1330@end defun 1337@end defun
1331 1338
1332@cindex largest window 1339@cindex largest window
1333@defun get-largest-window &optional all-frames dedicated 1340@defun get-largest-window &optional all-frames dedicated not-selected
1334This function returns the window with the largest area (height times 1341This function returns the window with the largest area (height times
1335width). A minibuffer window is never a candidate. A dedicated window 1342width). The optional argument @var{all-frames} specifies the windows to
1343search, and has the same meaning as in @code{next-window}.
1344
1345A minibuffer window is never a candidate. A dedicated window
1336(@pxref{Dedicated Windows}) is never a candidate unless the optional 1346(@pxref{Dedicated Windows}) is never a candidate unless the optional
1337argument @var{dedicated} is non-@code{nil}. 1347argument @var{dedicated} is non-@code{nil}. The selected window is not
1348a candidate if the optional argument @var{not-selected} is
1349non-@code{nil}. If the optional argument @var{not-selected} is
1350non-@code{nil} and the selected window is the only candidate, this
1351function returns @code{nil}.
1338 1352
1339If there are two candidate windows of the same size, this function 1353If there are two candidate windows of the same size, this function
1340prefers the one that comes first in the cyclic ordering of windows, 1354prefers the one that comes first in the cyclic ordering of windows,
1341starting from the selected window. 1355starting from the selected window.
1342
1343The optional argument @var{all-frames} specifies the windows to
1344search, and has the same meaning as in @code{next-window}.
1345@end defun 1356@end defun
1346 1357
1347@cindex window that satisfies a predicate 1358@cindex window that satisfies a predicate
@@ -1359,6 +1370,26 @@ windows to search, and have the same meanings as in
1359@code{next-window}. 1370@code{next-window}.
1360@end defun 1371@end defun
1361 1372
1373@cindex window in direction
1374@defun window-in-direction direction &optional window ignore
1375This function returns the nearest window in direction @var{direction} as
1376seen from the position of @code{window-point} in window @var{window}.
1377The argument @var{direction} must be one of @code{above}, @code{below},
1378@code{left} or @code{right}. The optional argument @var{window} must
1379denote a live window and defaults to the selected one.
1380
1381This function does not return a window whose @code{no-other-window}
1382parameter is non-@code{nil}. If the nearest window's
1383@code{no-other-window} parameter is non-@code{nil}, this function tries
1384to find another window in the indicated direction whose
1385@code{no-other-window} parameter is @code{nil}. If the optional
1386argument @var{ignore} is non-@code{nil}, a window may be returned even
1387if its @code{no-other-window} parameter is non-@code{nil}.
1388
1389If it doesn't find a suitable window, this function returns @code{nil}.
1390@end defun
1391
1392
1362@node Buffers and Windows 1393@node Buffers and Windows
1363@section Buffers and Windows 1394@section Buffers and Windows
1364@cindex examining windows 1395@cindex examining windows
@@ -1632,11 +1663,6 @@ The variable @code{display-buffer-overriding-action}.
1632The user option @code{display-buffer-alist}. 1663The user option @code{display-buffer-alist}.
1633 1664
1634@item 1665@item
1635A special action for handling @code{special-display-buffer-names} and
1636@code{special-display-regexps}, if either of those variables is
1637non-@code{nil}. @xref{Choosing Window Options}.
1638
1639@item
1640The @var{action} argument. 1666The @var{action} argument.
1641 1667
1642@item 1668@item
@@ -1864,91 +1890,6 @@ Parameters}), which is used by the default function in
1864@code{nil}. 1890@code{nil}.
1865@end defopt 1891@end defopt
1866 1892
1867@defopt special-display-buffer-names
1868A list of buffer names identifying buffers that should be displayed
1869specially. If the name of @var{buffer-or-name} is in this list,
1870@code{display-buffer} handles the buffer specially. By default, special
1871display means to give the buffer a dedicated frame.
1872
1873If an element is a list, instead of a string, then the @sc{car} of that
1874list is the buffer name, and the rest of that list says how to create
1875the frame. There are two possibilities for the rest of that list (its
1876@sc{cdr}): It can be an alist, specifying frame parameters, or it can
1877contain a function and arguments to give to it. (The function's first
1878argument is always the buffer to be displayed; the arguments from the
1879list come after that.)
1880
1881For example:
1882
1883@example
1884(("myfile" (minibuffer) (menu-bar-lines . 0)))
1885@end example
1886
1887@noindent
1888specifies to display a buffer named @samp{myfile} in a dedicated frame
1889with specified @code{minibuffer} and @code{menu-bar-lines} parameters.
1890
1891The list of frame parameters can also use the phony frame parameters
1892@code{same-frame} and @code{same-window}. If the specified frame
1893parameters include @code{(same-window . @var{value})} and @var{value}
1894is non-@code{nil}, that means to display the buffer in the current
1895selected window. Otherwise, if they include @code{(same-frame .
1896@var{value})} and @var{value} is non-@code{nil}, that means to display
1897the buffer in a new window in the currently selected frame.
1898@end defopt
1899
1900@defopt special-display-regexps
1901A list of regular expressions specifying buffers that should be
1902displayed specially. If the buffer's name matches any of the regular
1903expressions in this list, @code{display-buffer} handles the buffer
1904specially. By default, special display means to give the buffer a
1905dedicated frame.
1906
1907If an element is a list, instead of a string, then the @sc{car} of the
1908list is the regular expression, and the rest of the list says how to
1909create the frame. See @code{special-display-buffer-names} above.
1910@end defopt
1911
1912@defun special-display-p buffer-name
1913This function returns non-@code{nil} if displaying a buffer
1914named @var{buffer-name} with @code{display-buffer} would
1915create a special frame. The value is @code{t} if it would
1916use the default frame parameters, or else the specified list
1917of frame parameters.
1918@end defun
1919
1920@defopt special-display-function
1921This variable holds the function to call to display a buffer specially.
1922It receives the buffer as an argument, and should return the window in
1923which it is displayed. The default value of this variable is
1924@code{special-display-popup-frame}, see below.
1925@end defopt
1926
1927@defun special-display-popup-frame buffer &optional args
1928This function tries to make @var{buffer} visible in a frame of its own.
1929If @var{buffer} is already displayed in some window, it makes that
1930window's frame visible and raises it. Otherwise, it creates a frame
1931that is dedicated to @var{buffer}. The return value is the window used
1932to display @var{buffer}.
1933
1934If @var{args} is an alist, it specifies frame parameters for the new
1935frame. If @var{args} is a list whose @sc{car} is a symbol, then
1936@code{(car @var{args})} is a function to actually create and
1937set up the frame; it is called with @var{buffer} as first argument, and
1938@code{(cdr @var{args})} as additional arguments.
1939
1940This function always uses an existing window displaying @var{buffer},
1941whether or not it is in a frame of its own; but if you set up the above
1942variables in your init file, before @var{buffer} was created, then
1943presumably the window was previously made by this function.
1944@end defun
1945
1946@defopt special-display-frame-alist
1947@anchor{Definition of special-display-frame-alist}
1948This variable holds frame parameters for
1949@code{special-display-popup-frame} to use when it creates a frame.
1950@end defopt
1951
1952@defopt same-window-buffer-names 1893@defopt same-window-buffer-names
1953A list of buffer names for buffers that should be displayed in the 1894A list of buffer names for buffers that should be displayed in the
1954selected window. If a buffer's name is in this list, 1895selected window. If a buffer's name is in this list,
@@ -1969,19 +1910,6 @@ named @var{buffer-name} with @code{display-buffer} would
1969put it in the selected window. 1910put it in the selected window.
1970@end defun 1911@end defun
1971 1912
1972@c Emacs 19 feature
1973@defopt display-buffer-function
1974This variable is the most flexible way to customize the behavior of
1975@code{display-buffer}. If it is non-@code{nil}, it should be a function
1976that @code{display-buffer} calls to do the work. The function should
1977accept two arguments, the first two arguments that @code{display-buffer}
1978received. It should choose or create a window, display the specified
1979buffer in it, and then return the window.
1980
1981This variable takes precedence over all the other options described
1982above.
1983@end defopt
1984
1985@node Window History 1913@node Window History
1986@section Window History 1914@section Window History
1987@cindex window history 1915@cindex window history
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index cda4f272ca2..941c430ce74 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,96 @@
12012-10-30 Glenn Morris <rgm@gnu.org>
2
3 * cl.texi (Modify Macros): Update for cl-letf changes.
4 (Obsolete Lexical Macros): Say a little more about letf/cl-letf.
5 (Setf Extensions): Partially restore note about cl-getf,
6 mainly moved to lispref/variables.texi.
7 (Property Lists): Fix cl-getf typos.
8 (Mapping over Sequences): Mention cl-mapc naming oddity.
9
102012-10-29 Glenn Morris <rgm@gnu.org>
11
12 * cl.texi (Organization): More details on cl-lib.el versus cl.el.
13 (Setf Extensions): Remove `apply' setf since it seems to be disabled.
14 (Customizing Setf): Move contents to "Obsolete Setf Customization".
15 (Modify Macros, Multiple Values, Other Clauses):
16 Remove mentions of obsolete features.
17 (Obsolete Setf Customization): Don't mention `apply' setf.
18
192012-10-28 Glenn Morris <rgm@gnu.org>
20
21 * cl.texi (Multiple Values, Common Lisp Compatibility):
22 More namespace updates.
23 (Obsolete Features): Copyedits.
24 (Obsolete Lexical Macros, Obsolete Setf Customization):
25 New subsections.
26
27 * cl.texi (Porting Common Lisp, Lexical Bindings):
28 Add some xrefs to the Elisp manual.
29
30 * cl.texi (Lexical Bindings): Move to appendix of obsolete features.
31 (Porting Common Lisp): Emacs Lisp can do true lexical binding now.
32 (Obsolete Features): New appendix. Move Lexical Bindings here.
33
342012-10-27 Glenn Morris <rgm@gnu.org>
35
36 * cl.texi: Use defmac for macros rather than defspec.
37 (Efficiency Concerns): Related copyedit.
38
39 * cl.texi (Control Structure): Update for setf now being in core.
40 (Setf Extensions): Rename from Basic Setf. Move much of the
41 former content to lispref/variables.texi.
42 (Modify Macros): Move pop, push details to lispref/variables.texi.
43 (Customizing Setf): Copyedits for setf etc being in core.
44 (Modify Macros, Efficiency Concerns, Porting Common Lisp):
45 Further namespaces updates.
46
472012-10-26 Bastien Guerry <bzg@gnu.org>
48
49 * org.texi (Installation): Update the link to Org's ELPA. Also
50 don't mention org-install.el anymore as the replacement file
51 org-loaddefs.el is now loaded by org.el.
52
532012-10-25 Michael Albinus <michael.albinus@gmx.de>
54
55 * tramp.texi (Frequently Asked Questions): Mention
56 `tramp-completion-reread-directory-timeout' for performance
57 improvement.
58
592012-10-25 Glenn Morris <rgm@gnu.org>
60
61 * cl.texi: Don't mess with the TeX section number counter.
62 Use Texinfo recommended convention for quotes+punctuation.
63 (Overview, Sequence Functions): Rephrase for better line-breaking.
64 (Time of Evaluation, Type Predicates, Modify Macros, Function Bindings)
65 (Macro Bindings, Conditionals, Iteration, Loop Basics)
66 (Random Numbers, Mapping over Sequences, Structures)
67 (Porting Common Lisp): Further updates for cl-lib namespace.
68 (Modify Macros, Declarations, Macro Bindings, Structures):
69 Break long lines in examples.
70 (Dynamic Bindings): Update for changed progv behavior.
71 (Loop Examples, Efficiency Concerns): Markup fixes.
72 (Structures): Remove TeX margin change.
73 (Declarations): Fix typos.
74
752012-10-24 Glenn Morris <rgm@gnu.org>
76
77 * cl.texi (Overview, Multiple Values, Creating Symbols)
78 (Numerical Functions): Say less/nothing about the original cl.el.
79 (Old CL Compatibility): Remove.
80 (Assertions): Remove ignore-errors (standard Elisp for some time).
81
82 * cl.texi (Basic Setf, Macros, Declarations, Symbols, Numbers)
83 (Sequences, Lists, Structures, Assertions, Efficiency Concerns)
84 (Efficiency Concerns, Efficiency Concerns)
85 (Common Lisp Compatibility, Old CL Compatibility):
86 Further updates for cl-lib namespace.
87
882012-10-24 Paul Eggert <eggert@penguin.cs.ucla.edu>
89
90 Update manual for new time stamp format (Bug#12706).
91 * emacs-mime.texi (time-date): Update for new format.
92 Also, fix bogus time stamp and modernize a bit.
93
12012-10-23 Glenn Morris <rgm@gnu.org> 942012-10-23 Glenn Morris <rgm@gnu.org>
2 95
3 * cl.texi: Include emacsver.texi. Use Emacs version number rather 96 * cl.texi: Include emacsver.texi. Use Emacs version number rather
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 12fd76e2e1c..8cee1cf9639 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -57,7 +57,7 @@ developing GNU and promoting software freedom.''
57* Overview:: Basics, usage, etc. 57* Overview:: Basics, usage, etc.
58* Program Structure:: Arglists, @code{cl-eval-when}, @code{defalias}. 58* Program Structure:: Arglists, @code{cl-eval-when}, @code{defalias}.
59* Predicates:: @code{cl-typep} and @code{cl-equalp}. 59* Predicates:: @code{cl-typep} and @code{cl-equalp}.
60* Control Structure:: @code{setf}, @code{cl-do}, @code{cl-loop}, etc. 60* Control Structure:: @code{cl-do}, @code{cl-loop}, etc.
61* Macros:: Destructuring, @code{cl-define-compiler-macro}. 61* Macros:: Destructuring, @code{cl-define-compiler-macro}.
62* Declarations:: @code{cl-proclaim}, @code{cl-declare}, etc. 62* Declarations:: @code{cl-proclaim}, @code{cl-declare}, etc.
63* Symbols:: Property lists, @code{cl-gensym}. 63* Symbols:: Property lists, @code{cl-gensym}.
@@ -65,12 +65,12 @@ developing GNU and promoting software freedom.''
65* Sequences:: Mapping, functions, searching, sorting. 65* Sequences:: Mapping, functions, searching, sorting.
66* Lists:: @code{cl-caddr}, @code{cl-sublis}, @code{cl-member}, @code{cl-assoc}, etc. 66* Lists:: @code{cl-caddr}, @code{cl-sublis}, @code{cl-member}, @code{cl-assoc}, etc.
67* Structures:: @code{cl-defstruct}. 67* Structures:: @code{cl-defstruct}.
68* Assertions:: @code{cl-check-type}, @code{cl-assert}, @code{ignore-errors}. 68* Assertions:: @code{cl-check-type}, @code{cl-assert}.
69 69
70* Efficiency Concerns:: Hints and techniques. 70* Efficiency Concerns:: Hints and techniques.
71* Common Lisp Compatibility:: All known differences with Steele. 71* Common Lisp Compatibility:: All known differences with Steele.
72* Old CL Compatibility:: All known differences with old cl.el.
73* Porting Common Lisp:: Hints for porting Common Lisp code. 72* Porting Common Lisp:: Hints for porting Common Lisp code.
73* Obsolete Features:: Obsolete features.
74 74
75* GNU Free Documentation License:: The license for this documentation. 75* GNU Free Documentation License:: The license for this documentation.
76* Function Index:: 76* Function Index::
@@ -116,19 +116,16 @@ features.
116 116
117@end itemize 117@end itemize
118 118
119The package described here was originally written by Dave Gillespie, 119This package was originally written by Dave Gillespie,
120@file{daveg@@synaptics.com}, as a total rewrite of an earlier 120@file{daveg@@synaptics.com}, as a total rewrite of an earlier 1986
1211986 @file{cl.el} package by Cesar Quiroz. Most features of the 121@file{cl.el} package by Cesar Quiroz. Care has been taken to ensure
122Quiroz package were retained; any incompatibilities are 122that each function is defined efficiently, concisely, and with minimal
123noted in the descriptions below. Care has been taken in this 123impact on the rest of the Emacs environment. Stefan Monnier added the
124version to ensure that each function is defined efficiently, 124file @file{cl-lib.el} and rationalized the namespace for Emacs 24.3.
125concisely, and with minimal impact on the rest of the Emacs
126environment. Stefan Monnier added the file @file{cl-lib.el} and
127rationalized the namespace for Emacs 24.3.
128 125
129@menu 126@menu
130* Usage:: How to use the CL package. 127* Usage:: How to use the CL package.
131* Organization:: The package's five component files. 128* Organization:: The package's component files.
132* Naming Conventions:: Notes on CL function names. 129* Naming Conventions:: Notes on CL function names.
133@end menu 130@end menu
134 131
@@ -185,25 +182,37 @@ All you have to do is @code{(require 'cl-lib)}, and @file{cl-lib.el}
185will take care of pulling in the other files when they are 182will take care of pulling in the other files when they are
186needed. 183needed.
187 184
188There is another file, @file{cl.el}, which was the main entry point 185There is another file, @file{cl.el}, which was the main entry point to
189to the CL package prior to Emacs 24.3. Nowadays, it is replaced 186the CL package prior to Emacs 24.3. Nowadays, it is replaced by
190by @file{cl-lib.el}. The two provide the same features, but use 187@file{cl-lib.el}. The two provide the same features (in most cases),
191different function names (in fact, @file{cl.el} just defines aliases 188but use different function names (in fact, @file{cl.el} mainly just
192to the @file{cl-lib.el} definitions). In particular, the old @file{cl.el} 189defines aliases to the @file{cl-lib.el} definitions). Where
193does not use a clean namespace. For this reason, Emacs has a policy 190@file{cl-lib.el} defines a function called, for example,
194that packages distributed with Emacs must not load @code{cl} at run time. 191@code{cl-incf}, @file{cl.el} uses the same name but without the
195(It is ok for them to load @code{cl} at @emph{compile} time, with 192@samp{cl-} prefix, e.g. @code{incf} in this example. There are a few
196@code{eval-when-compile}, and use the macros it provides.) There is 193exceptions to this. First, functions such as @code{cl-defun} where
197no such restriction on the use of @code{cl-lib}. New code should use 194the unprefixed version was already used for a standard Emacs Lisp
198@code{cl-lib} rather than @code{cl}. @xref{Naming Conventions}. 195function. In such cases, the @file{cl.el} version adds a @samp{*}
196suffix, e.g. @code{defun*}. Second, there are some obsolete features
197that are only implemented in @file{cl.el}, not in @file{cl-lib.el},
198because they are replaced by other standard Emacs Lisp features.
199Finally, in a very few cases the old @file{cl.el} versions do not
200behave in exactly the same way as the @file{cl-lib.el} versions.
201@xref{Obsolete Features}.
202@c There is also cl-mapc, which was called cl-mapc even before cl-lib.el.
203@c But not autoloaded, so maybe not much used?
204
205Since the old @file{cl.el} does not use a clean namespace, Emacs has a
206policy that packages distributed with Emacs must not load @code{cl} at
207run time. (It is ok for them to load @code{cl} at @emph{compile}
208time, with @code{eval-when-compile}, and use the macros it provides.)
209There is no such restriction on the use of @code{cl-lib}. New code
210should use @code{cl-lib} rather than @code{cl}.
199 211
200There is one more file, @file{cl-compat.el}, which defines some 212There is one more file, @file{cl-compat.el}, which defines some
201routines from the older CL package that are not otherwise 213routines from the older Quiroz CL package that are not otherwise
202present in the new package. This includes internal routines 214present in the new package. This file is obsolete and should not be
203like @code{setelt} and @code{zip-lists}, deprecated features 215used in new code.
204like @code{defkeyword}, and an emulation of the old-style
205multiple-values feature. This file is obsolete and should not be used
206in new code. @xref{Old CL Compatibility}.
207 216
208@node Naming Conventions 217@node Naming Conventions
209@section Naming Conventions 218@section Naming Conventions
@@ -217,7 +226,6 @@ Internal function and variable names in the package are prefixed
217by @code{cl--}. Here is a complete list of functions prefixed by 226by @code{cl--}. Here is a complete list of functions prefixed by
218@code{cl-} that were not taken from Common Lisp: 227@code{cl-} that were not taken from Common Lisp:
219 228
220@c FIXME lexical-let lexical-let*
221@example 229@example
222cl-callf cl-callf2 cl-defsubst 230cl-callf cl-callf2 cl-defsubst
223cl-floatp-safe cl-letf cl-letf* 231cl-floatp-safe cl-letf cl-letf*
@@ -260,10 +268,6 @@ and the @code{cl-eval-when} construct.
260* Time of Evaluation:: The @code{cl-eval-when} construct. 268* Time of Evaluation:: The @code{cl-eval-when} construct.
261@end menu 269@end menu
262 270
263@iftex
264@secno=1
265@end iftex
266
267@node Argument Lists 271@node Argument Lists
268@section Argument Lists 272@section Argument Lists
269 273
@@ -279,14 +283,14 @@ this package to implement Common Lisp argument lists seamlessly.
279Instead, this package defines alternates for several Lisp forms 283Instead, this package defines alternates for several Lisp forms
280which you must use if you need Common Lisp argument lists. 284which you must use if you need Common Lisp argument lists.
281 285
282@defspec cl-defun name arglist body... 286@defmac cl-defun name arglist body...
283This form is identical to the regular @code{defun} form, except 287This form is identical to the regular @code{defun} form, except
284that @var{arglist} is allowed to be a full Common Lisp argument 288that @var{arglist} is allowed to be a full Common Lisp argument
285list. Also, the function body is enclosed in an implicit block 289list. Also, the function body is enclosed in an implicit block
286called @var{name}; @pxref{Blocks and Exits}. 290called @var{name}; @pxref{Blocks and Exits}.
287@end defspec 291@end defmac
288 292
289@defspec cl-defsubst name arglist body... 293@defmac cl-defsubst name arglist body...
290This is just like @code{cl-defun}, except that the function that 294This is just like @code{cl-defun}, except that the function that
291is defined is automatically proclaimed @code{inline}, i.e., 295is defined is automatically proclaimed @code{inline}, i.e.,
292calls to it may be expanded into in-line code by the byte compiler. 296calls to it may be expanded into in-line code by the byte compiler.
@@ -296,9 +300,9 @@ works in all versions of Emacs, and also generates somewhat more
296efficient inline expansions. In particular, @code{cl-defsubst} 300efficient inline expansions. In particular, @code{cl-defsubst}
297arranges for the processing of keyword arguments, default values, 301arranges for the processing of keyword arguments, default values,
298etc., to be done at compile-time whenever possible. 302etc., to be done at compile-time whenever possible.
299@end defspec 303@end defmac
300 304
301@defspec cl-defmacro name arglist body... 305@defmac cl-defmacro name arglist body...
302This is identical to the regular @code{defmacro} form, 306This is identical to the regular @code{defmacro} form,
303except that @var{arglist} is allowed to be a full Common Lisp 307except that @var{arglist} is allowed to be a full Common Lisp
304argument list. The @code{&environment} keyword is supported as 308argument list. The @code{&environment} keyword is supported as
@@ -307,13 +311,13 @@ within destructured lists (see below); top-level @code{&whole}
307cannot be implemented with the current Emacs Lisp interpreter. 311cannot be implemented with the current Emacs Lisp interpreter.
308The macro expander body is enclosed in an implicit block called 312The macro expander body is enclosed in an implicit block called
309@var{name}. 313@var{name}.
310@end defspec 314@end defmac
311 315
312@defspec cl-function symbol-or-lambda 316@defmac cl-function symbol-or-lambda
313This is identical to the regular @code{function} form, 317This is identical to the regular @code{function} form,
314except that if the argument is a @code{lambda} form then that 318except that if the argument is a @code{lambda} form then that
315form may use a full Common Lisp argument list. 319form may use a full Common Lisp argument list.
316@end defspec 320@end defmac
317 321
318Also, all forms (such as @code{cl-flet} and @code{cl-labels}) defined 322Also, all forms (such as @code{cl-flet} and @code{cl-labels}) defined
319in this package that include @var{arglist}s in their syntax allow 323in this package that include @var{arglist}s in their syntax allow
@@ -502,7 +506,7 @@ For example, the compiler effectively evaluates @code{defmacro} forms
502at compile-time so that later parts of the file can refer to the 506at compile-time so that later parts of the file can refer to the
503macros that are defined. 507macros that are defined.
504 508
505@defspec cl-eval-when (situations...) forms... 509@defmac cl-eval-when (situations...) forms...
506This form controls when the body @var{forms} are evaluated. 510This form controls when the body @var{forms} are evaluated.
507The @var{situations} list may contain any set of the symbols 511The @var{situations} list may contain any set of the symbols
508@code{compile}, @code{load}, and @code{eval} (or their long-winded 512@code{compile}, @code{load}, and @code{eval} (or their long-winded
@@ -572,19 +576,19 @@ last four would have been equivalent to the corresponding @code{setq}s.
572Note that @code{(cl-eval-when (load eval) @dots{})} is equivalent 576Note that @code{(cl-eval-when (load eval) @dots{})} is equivalent
573to @code{(progn @dots{})} in all contexts. The compiler treats 577to @code{(progn @dots{})} in all contexts. The compiler treats
574certain top-level forms, like @code{defmacro} (sort-of) and 578certain top-level forms, like @code{defmacro} (sort-of) and
575@code{require}, as if they were wrapped in @code{(eval-when 579@code{require}, as if they were wrapped in @code{(cl-eval-when
576(compile load eval) @dots{})}. 580(compile load eval) @dots{})}.
577@end defspec 581@end defmac
578 582
579Emacs includes two special forms related to @code{cl-eval-when}. 583Emacs includes two special forms related to @code{cl-eval-when}.
580One of these, @code{eval-when-compile}, is not quite equivalent to 584One of these, @code{eval-when-compile}, is not quite equivalent to
581any @code{eval-when} construct and is described below. 585any @code{cl-eval-when} construct and is described below.
582 586
583The other form, @code{(eval-and-compile @dots{})}, is exactly 587The other form, @code{(eval-and-compile @dots{})}, is exactly
584equivalent to @samp{(eval-when (compile load eval) @dots{})} and 588equivalent to @samp{(cl-eval-when (compile load eval) @dots{})} and
585so is not itself defined by this package. 589so is not itself defined by this package.
586 590
587@defspec eval-when-compile forms... 591@defmac eval-when-compile forms...
588The @var{forms} are evaluated at compile-time; at execution time, 592The @var{forms} are evaluated at compile-time; at execution time,
589this form acts like a quoted constant of the resulting value. Used 593this form acts like a quoted constant of the resulting value. Used
590at top-level, @code{eval-when-compile} is just like @samp{eval-when 594at top-level, @code{eval-when-compile} is just like @samp{eval-when
@@ -593,9 +597,9 @@ allows code to be evaluated once at compile-time for efficiency
593or other reasons. 597or other reasons.
594 598
595This form is similar to the @samp{#.} syntax of true Common Lisp. 599This form is similar to the @samp{#.} syntax of true Common Lisp.
596@end defspec 600@end defmac
597 601
598@defspec cl-load-time-value form 602@defmac cl-load-time-value form
599The @var{form} is evaluated at load-time; at execution time, 603The @var{form} is evaluated at load-time; at execution time,
600this form acts like a quoted constant of the resulting value. 604this form acts like a quoted constant of the resulting value.
601 605
@@ -636,7 +640,7 @@ Byte-compiled, the above defun will result in the following code
636 ", and loaded on: " 640 ", and loaded on: "
637 --temp--)) 641 --temp--))
638@end example 642@end example
639@end defspec 643@end defmac
640 644
641@node Predicates 645@node Predicates
642@chapter Predicates 646@chapter Predicates
@@ -653,10 +657,6 @@ facts are true or false.
653@node Type Predicates 657@node Type Predicates
654@section Type Predicates 658@section Type Predicates
655 659
656@noindent
657The @code{CL} package defines a version of the Common Lisp @code{typep}
658predicate.
659
660@defun cl-typep object type 660@defun cl-typep object type
661Check if @var{object} is of type @var{type}, where @var{type} is a 661Check if @var{object} is of type @var{type}, where @var{type} is a
662(quoted) type name of the sort used by Common Lisp. For example, 662(quoted) type name of the sort used by Common Lisp. For example,
@@ -737,7 +737,7 @@ related to @code{cl-typep}.
737@defun cl-coerce object type 737@defun cl-coerce object type
738This function attempts to convert @var{object} to the specified 738This function attempts to convert @var{object} to the specified
739@var{type}. If @var{object} is already of that type as determined by 739@var{type}. If @var{object} is already of that type as determined by
740@code{typep}, it is simply returned. Otherwise, certain types of 740@code{cl-typep}, it is simply returned. Otherwise, certain types of
741conversions will be made: If @var{type} is any sequence type 741conversions will be made: If @var{type} is any sequence type
742(@code{string}, @code{list}, etc.) then @var{object} will be 742(@code{string}, @code{list}, etc.) then @var{object} will be
743converted to that type if possible. If @var{type} is 743converted to that type if possible. If @var{type} is
@@ -748,7 +748,7 @@ floats. In all other circumstances, @code{cl-coerce} signals an
748error. 748error.
749@end defun 749@end defun
750 750
751@defspec cl-deftype name arglist forms... 751@defmac cl-deftype name arglist forms...
752This macro defines a new type called @var{name}. It is similar 752This macro defines a new type called @var{name}. It is similar
753to @code{defmacro} in many ways; when @var{name} is encountered 753to @code{defmacro} in many ways; when @var{name} is encountered
754as a type name, the body @var{forms} are evaluated and should 754as a type name, the body @var{forms} are evaluated and should
@@ -776,7 +776,7 @@ unsigned-byte @equiv{} (integer 0 *)
776The last example shows how the Common Lisp @code{unsigned-byte} 776The last example shows how the Common Lisp @code{unsigned-byte}
777type specifier could be implemented if desired; this package does 777type specifier could be implemented if desired; this package does
778not implement @code{unsigned-byte} by default. 778not implement @code{unsigned-byte} by default.
779@end defspec 779@end defmac
780 780
781The @code{cl-typecase} and @code{cl-check-type} macros also use type 781The @code{cl-typecase} and @code{cl-check-type} macros also use type
782names. @xref{Conditionals}. @xref{Assertions}. The @code{cl-map}, 782names. @xref{Conditionals}. @xref{Assertions}. The @code{cl-map},
@@ -816,23 +816,21 @@ In Emacs, use @code{memq} (or @code{cl-member}) and @code{assq} (or
816 816
817@noindent 817@noindent
818The features described in the following sections implement 818The features described in the following sections implement
819various advanced control structures, including the powerful 819various advanced control structures, including extensions to the
820@c FIXME setf is now in gv.el, not cl. 820standard @code{setf} facility, and a number of looping and conditional
821@code{setf} facility and a number of looping and conditional
822constructs. 821constructs.
823 822
824@c FIXME setf, push are standard now. 823@c FIXME
825@c lexical-let is obsolete; flet is not cl-flet. 824@c flet is not cl-flet.
826@c values is not cl-values.
827@menu 825@menu
828* Assignment:: The @code{cl-psetq} form. 826* Assignment:: The @code{cl-psetq} form.
829* Generalized Variables:: @code{setf}, @code{cl-incf}, @code{push}, etc. 827* Generalized Variables:: Extensions to generalized variables.
830* Variable Bindings:: @code{cl-progv}, @code{lexical-let}, @code{flet}, @code{cl-macrolet}. 828* Variable Bindings:: @code{cl-progv}, @code{flet}, @code{cl-macrolet}.
831* Conditionals:: @code{cl-case}, @code{cl-typecase}. 829* Conditionals:: @code{cl-case}, @code{cl-typecase}.
832* Blocks and Exits:: @code{cl-block}, @code{cl-return}, @code{cl-return-from}. 830* Blocks and Exits:: @code{cl-block}, @code{cl-return}, @code{cl-return-from}.
833* Iteration:: @code{cl-do}, @code{cl-dotimes}, @code{cl-dolist}, @code{cl-do-symbols}. 831* Iteration:: @code{cl-do}, @code{cl-dotimes}, @code{cl-dolist}, @code{cl-do-symbols}.
834* Loop Facility:: The Common Lisp @code{cl-loop} macro. 832* Loop Facility:: The Common Lisp @code{cl-loop} macro.
835* Multiple Values:: @code{values}, @code{cl-multiple-value-bind}, etc. 833* Multiple Values:: @code{cl-values}, @code{cl-multiple-value-bind}, etc.
836@end menu 834@end menu
837 835
838@node Assignment 836@node Assignment
@@ -842,7 +840,7 @@ constructs.
842The @code{cl-psetq} form is just like @code{setq}, except that multiple 840The @code{cl-psetq} form is just like @code{setq}, except that multiple
843assignments are done in parallel rather than sequentially. 841assignments are done in parallel rather than sequentially.
844 842
845@defspec cl-psetq [symbol form]@dots{} 843@defmac cl-psetq [symbol form]@dots{}
846This special form (actually a macro) is used to assign to several 844This special form (actually a macro) is used to assign to several
847variables simultaneously. Given only one @var{symbol} and @var{form}, 845variables simultaneously. Given only one @var{symbol} and @var{form},
848it has the same effect as @code{setq}. Given several @var{symbol} 846it has the same effect as @code{setq}. Given several @var{symbol}
@@ -870,132 +868,79 @@ provides an even more convenient way to swap two variables;
870@pxref{Modify Macros}.) 868@pxref{Modify Macros}.)
871 869
872@code{cl-psetq} always returns @code{nil}. 870@code{cl-psetq} always returns @code{nil}.
873@end defspec 871@end defmac
874 872
875@c FIXME now in gv.el.
876@node Generalized Variables 873@node Generalized Variables
877@section Generalized Variables 874@section Generalized Variables
878 875
879@noindent 876A @dfn{generalized variable} or @dfn{place form} is one of the many
880A ``generalized variable'' or ``place form'' is one of the many places 877places in Lisp memory where values can be stored. The simplest place
881in Lisp memory where values can be stored. The simplest place form is 878form is a regular Lisp variable. But the cars and cdrs of lists,
882a regular Lisp variable. But the cars and cdrs of lists, elements 879elements of arrays, properties of symbols, and many other locations
883of arrays, properties of symbols, and many other locations are also 880are also places where Lisp values are stored. For basic information,
884places where Lisp values are stored. 881@pxref{Generalized Variables,,,elisp,GNU Emacs Lisp Reference Manual}.
885 882This package provides several additional features related to
886The @code{setf} form is like @code{setq}, except that it accepts 883generalized variables.
887arbitrary place forms on the left side rather than just
888symbols. For example, @code{(setf (car a) b)} sets the car of
889@code{a} to @code{b}, doing the same operation as @code{(setcar a b)}
890but without having to remember two separate functions for setting
891and accessing every type of place.
892
893Generalized variables are analogous to ``lvalues'' in the C
894language, where @samp{x = a[i]} gets an element from an array
895and @samp{a[i] = x} stores an element using the same notation.
896Just as certain forms like @code{a[i]} can be lvalues in C, there
897is a set of forms that can be generalized variables in Lisp.
898 884
899@menu 885@menu
900* Basic Setf:: @code{setf} and place forms. 886* Setf Extensions:: Additional @code{setf} places.
901* Modify Macros:: @code{cl-incf}, @code{push}, @code{cl-rotatef}, @code{letf}, @code{cl-callf}, etc. 887* Modify Macros:: @code{cl-incf}, @code{cl-rotatef}, @code{cl-letf}, @code{cl-callf}, etc.
902* Customizing Setf:: @code{define-modify-macro}, @code{defsetf}, @code{define-setf-method}.
903@end menu 888@end menu
904 889
905@node Basic Setf 890@node Setf Extensions
906@subsection Basic Setf 891@subsection Setf Extensions
907
908@noindent
909The @code{setf} macro is the most basic way to operate on generalized
910variables.
911
912@defspec setf [place form]@dots{}
913This macro evaluates @var{form} and stores it in @var{place}, which
914must be a valid generalized variable form. If there are several
915@var{place} and @var{form} pairs, the assignments are done sequentially
916just as with @code{setq}. @code{setf} returns the value of the last
917@var{form}.
918
919The following Lisp forms will work as generalized variables, and
920so may appear in the @var{place} argument of @code{setf}:
921 892
922@itemize @bullet 893Several standard (e.g. @code{car}) and Emacs-specific
923@item 894(e.g. @code{window-point}) Lisp functions are @code{setf}-able by default.
924A symbol naming a variable. In other words, @code{(setf x y)} is 895This package defines @code{setf} handlers for several additional functions:
925exactly equivalent to @code{(setq x y)}, and @code{setq} itself is
926strictly speaking redundant now that @code{setf} exists. Many
927programmers continue to prefer @code{setq} for setting simple
928variables, though, purely for stylistic or historical reasons.
929The macro @code{(setf x y)} actually expands to @code{(setq x y)},
930so there is no performance penalty for using it in compiled code.
931 896
897@itemize
932@item 898@item
933A call to any of the following Lisp functions: 899Functions from @code{CL} itself:
934
935@smallexample 900@smallexample
936car cdr caar .. cddddr 901cl-caaar .. cl-cddddr cl-first .. cl-tenth
937nth rest first .. tenth 902cl-rest cl-get cl-getf cl-subseq
938aref elt nthcdr
939symbol-function symbol-value symbol-plist
940get get* getf
941gethash subseq
942@end smallexample 903@end smallexample
943 904
944@noindent 905@noindent
945Note that for @code{nthcdr} and @code{getf}, the list argument 906Note that for @code{cl-getf} (as for @code{nthcdr}), the list argument
946of the function must itself be a valid @var{place} form. For 907of the function must itself be a valid @var{place} form.
947example, @code{(setf (nthcdr 0 foo) 7)} will set @code{foo} itself
948to 7. Note that @code{push} and @code{pop} on an @code{nthcdr}
949place can be used to insert or delete at any position in a list.
950The use of @code{nthcdr} as a @var{place} form is an extension
951to standard Common Lisp.
952 908
953@item 909@item
954The following Emacs-specific functions are also @code{setf}-able. 910General Emacs Lisp functions:
955
956@smallexample 911@smallexample
957buffer-file-name marker-position 912buffer-file-name getenv
958buffer-modified-p match-data 913buffer-modified-p global-key-binding
959buffer-name mouse-position 914buffer-name local-key-binding
960buffer-string overlay-end 915buffer-string mark
961buffer-substring overlay-get 916buffer-substring mark-marker
962current-buffer overlay-start 917current-buffer marker-position
963current-case-table point 918current-case-table mouse-position
964current-column point-marker 919current-column point
965current-global-map point-max 920current-global-map point-marker
966current-input-mode point-min 921current-input-mode point-max
967current-local-map process-buffer 922current-local-map point-min
968current-window-configuration process-filter 923current-window-configuration read-mouse-position
969default-file-modes process-sentinel 924default-file-modes screen-height
970default-value read-mouse-position 925documentation-property screen-width
971documentation-property screen-height 926face-background selected-window
972extent-data screen-menubar 927face-background-pixmap selected-screen
973extent-end-position screen-width 928face-font selected-frame
974extent-start-position selected-window 929face-foreground standard-case-table
975face-background selected-screen 930face-underline-p syntax-table
976face-background-pixmap selected-frame 931file-modes visited-file-modtime
977face-font standard-case-table 932frame-height window-height
978face-foreground syntax-table 933frame-parameters window-width
979face-underline-p window-buffer 934frame-visible-p x-get-secondary-selection
980file-modes window-dedicated-p 935frame-width x-get-selection
981frame-height window-display-table 936get-register
982frame-parameters window-height
983frame-visible-p window-hscroll
984frame-width window-point
985get-register window-start
986getenv window-width
987global-key-binding x-get-secondary-selection
988keymap-parent x-get-selection
989local-key-binding
990mark
991mark-marker
992@end smallexample 937@end smallexample
993 938
994Most of these have directly corresponding ``set'' functions, like 939Most of these have directly corresponding ``set'' functions, like
995@code{use-local-map} for @code{current-local-map}, or @code{goto-char} 940@code{use-local-map} for @code{current-local-map}, or @code{goto-char}
996for @code{point}. A few, like @code{point-min}, expand to longer 941for @code{point}. A few, like @code{point-min}, expand to longer
997sequences of code when they are @code{setf}'d (@code{(narrow-to-region 942sequences of code when they are used with @code{setf}
998x (point-max))} in this case). 943(@code{(narrow-to-region x (point-max))} in this case).
999 944
1000@item 945@item
1001A call of the form @code{(substring @var{subplace} @var{n} [@var{m}])}, 946A call of the form @code{(substring @var{subplace} @var{n} [@var{m}])},
@@ -1022,6 +967,10 @@ a
1022The generalized variable @code{buffer-substring}, listed above, 967The generalized variable @code{buffer-substring}, listed above,
1023also works in this way by replacing a portion of the current buffer. 968also works in this way by replacing a portion of the current buffer.
1024 969
970@c FIXME? Also `eq'? (see cl-lib.el)
971
972@c Currently commented out in cl.el.
973@ignore
1025@item 974@item
1026A call of the form @code{(apply '@var{func} @dots{})} or 975A call of the form @code{(apply '@var{func} @dots{})} or
1027@code{(apply (function @var{func}) @dots{})}, where @var{func} 976@code{(apply (function @var{func}) @dots{})}, where @var{func}
@@ -1030,6 +979,8 @@ in the sense described in Steele's book; since none of the standard
1030Emacs place functions are suitable in this sense, this feature is 979Emacs place functions are suitable in this sense, this feature is
1031only interesting when used with places you define yourself with 980only interesting when used with places you define yourself with
1032@code{define-setf-method} or the long form of @code{defsetf}. 981@code{define-setf-method} or the long form of @code{defsetf}.
982@xref{Obsolete Setf Customization}.
983@end ignore
1033 984
1034@item 985@item
1035A macro call, in which case the macro is expanded and @code{setf} 986A macro call, in which case the macro is expanded and @code{setf}
@@ -1037,21 +988,21 @@ is applied to the resulting form.
1037 988
1038@item 989@item
1039Any form for which a @code{defsetf} or @code{define-setf-method} 990Any form for which a @code{defsetf} or @code{define-setf-method}
1040has been made. 991has been made. @xref{Obsolete Setf Customization}.
1041@end itemize 992@end itemize
1042 993
1043Using any forms other than these in the @var{place} argument to 994@c FIXME should this be in lispref? It seems self-evident.
1044@code{setf} will signal an error. 995@c Contrast with the cl-incf example later on.
1045 996@c Here it really only serves as a constrast to wrong-order.
1046The @code{setf} macro takes care to evaluate all subforms in 997The @code{setf} macro takes care to evaluate all subforms in
1047the proper left-to-right order; for example, 998the proper left-to-right order; for example,
1048 999
1049@example 1000@example
1050(setf (aref vec (incf i)) i) 1001(setf (aref vec (cl-incf i)) i)
1051@end example 1002@end example
1052 1003
1053@noindent 1004@noindent
1054looks like it will evaluate @code{(incf i)} exactly once, before the 1005looks like it will evaluate @code{(cl-incf i)} exactly once, before the
1055following access to @code{i}; the @code{setf} expander will insert 1006following access to @code{i}; the @code{setf} expander will insert
1056temporary variables as necessary to ensure that it does in fact work 1007temporary variables as necessary to ensure that it does in fact work
1057this way no matter what setf-method is defined for @code{aref}. 1008this way no matter what setf-method is defined for @code{aref}.
@@ -1071,35 +1022,34 @@ will be preserved. Adapting an example from Steele, given
1071the form @code{(setf (wrong-order @var{a} @var{b}) 17)} will 1022the form @code{(setf (wrong-order @var{a} @var{b}) 17)} will
1072evaluate @var{b} first, then @var{a}, just as in an actual call 1023evaluate @var{b} first, then @var{a}, just as in an actual call
1073to @code{wrong-order}. 1024to @code{wrong-order}.
1074@end defspec
1075 1025
1076@node Modify Macros 1026@node Modify Macros
1077@subsection Modify Macros 1027@subsection Modify Macros
1078 1028
1079@noindent 1029@noindent
1080This package defines a number of other macros besides @code{setf} 1030This package defines a number of macros that operate on generalized
1081that operate on generalized variables. Many are interesting and 1031variables. Many are interesting and useful even when the @var{place}
1082useful even when the @var{place} is just a variable name. 1032is just a variable name.
1083 1033
1084@defspec psetf [place form]@dots{} 1034@defmac cl-psetf [place form]@dots{}
1085This macro is to @code{setf} what @code{cl-psetq} is to @code{setq}: 1035This macro is to @code{setf} what @code{cl-psetq} is to @code{setq}:
1086When several @var{place}s and @var{form}s are involved, the 1036When several @var{place}s and @var{form}s are involved, the
1087assignments take place in parallel rather than sequentially. 1037assignments take place in parallel rather than sequentially.
1088Specifically, all subforms are evaluated from left to right, then 1038Specifically, all subforms are evaluated from left to right, then
1089all the assignments are done (in an undefined order). 1039all the assignments are done (in an undefined order).
1090@end defspec 1040@end defmac
1091 1041
1092@defspec incf place &optional x 1042@defmac cl-incf place &optional x
1093This macro increments the number stored in @var{place} by one, or 1043This macro increments the number stored in @var{place} by one, or
1094by @var{x} if specified. The incremented value is returned. For 1044by @var{x} if specified. The incremented value is returned. For
1095example, @code{(incf i)} is equivalent to @code{(setq i (1+ i))}, and 1045example, @code{(cl-incf i)} is equivalent to @code{(setq i (1+ i))}, and
1096@code{(incf (car x) 2)} is equivalent to @code{(setcar x (+ (car x) 2))}. 1046@code{(cl-incf (car x) 2)} is equivalent to @code{(setcar x (+ (car x) 2))}.
1097 1047
1098Once again, care is taken to preserve the ``apparent'' order of 1048As with @code{setf}, care is taken to preserve the ``apparent'' order
1099evaluation. For example, 1049of evaluation. For example,
1100 1050
1101@example 1051@example
1102(incf (aref vec (incf i))) 1052(cl-incf (aref vec (cl-incf i)))
1103@end example 1053@end example
1104 1054
1105@noindent 1055@noindent
@@ -1109,93 +1059,81 @@ does, which means the above form is @emph{not} equivalent to the
1109``obvious'' expansion, 1059``obvious'' expansion,
1110 1060
1111@example 1061@example
1112(setf (aref vec (incf i)) (1+ (aref vec (incf i)))) ; Wrong! 1062(setf (aref vec (cl-incf i))
1063 (1+ (aref vec (cl-incf i)))) ; wrong!
1113@end example 1064@end example
1114 1065
1115@noindent 1066@noindent
1116but rather to something more like 1067but rather to something more like
1117 1068
1118@example 1069@example
1119(let ((temp (incf i))) 1070(let ((temp (cl-incf i)))
1120 (setf (aref vec temp) (1+ (aref vec temp)))) 1071 (setf (aref vec temp) (1+ (aref vec temp))))
1121@end example 1072@end example
1122 1073
1123@noindent 1074@noindent
1124Again, all of this is taken care of automatically by @code{incf} and 1075Again, all of this is taken care of automatically by @code{cl-incf} and
1125the other generalized-variable macros. 1076the other generalized-variable macros.
1126 1077
1127As a more Emacs-specific example of @code{incf}, the expression 1078As a more Emacs-specific example of @code{cl-incf}, the expression
1128@code{(incf (point) @var{n})} is essentially equivalent to 1079@code{(cl-incf (point) @var{n})} is essentially equivalent to
1129@code{(forward-char @var{n})}. 1080@code{(forward-char @var{n})}.
1130@end defspec 1081@end defmac
1131 1082
1132@defspec decf place &optional x 1083@defmac cl-decf place &optional x
1133This macro decrements the number stored in @var{place} by one, or 1084This macro decrements the number stored in @var{place} by one, or
1134by @var{x} if specified. 1085by @var{x} if specified.
1135@end defspec 1086@end defmac
1136
1137@defspec pop place
1138This macro removes and returns the first element of the list stored
1139in @var{place}. It is analogous to @code{(prog1 (car @var{place})
1140(setf @var{place} (cdr @var{place})))}, except that it takes care
1141to evaluate all subforms only once.
1142@end defspec
1143 1087
1144@defspec push x place 1088@defmac cl-pushnew x place @t{&key :test :test-not :key}
1145This macro inserts @var{x} at the front of the list stored in
1146@var{place}. It is analogous to @code{(setf @var{place} (cons
1147@var{x} @var{place}))}, except for evaluation of the subforms.
1148@end defspec
1149
1150@defspec pushnew x place @t{&key :test :test-not :key}
1151This macro inserts @var{x} at the front of the list stored in 1089This macro inserts @var{x} at the front of the list stored in
1152@var{place}, but only if @var{x} was not @code{eql} to any 1090@var{place}, but only if @var{x} was not @code{eql} to any
1153existing element of the list. The optional keyword arguments 1091existing element of the list. The optional keyword arguments
1154are interpreted in the same way as for @code{adjoin}. 1092are interpreted in the same way as for @code{cl-adjoin}.
1155@xref{Lists as Sets}. 1093@xref{Lists as Sets}.
1156@end defspec 1094@end defmac
1157 1095
1158@defspec shiftf place@dots{} newvalue 1096@defmac cl-shiftf place@dots{} newvalue
1159This macro shifts the @var{place}s left by one, shifting in the 1097This macro shifts the @var{place}s left by one, shifting in the
1160value of @var{newvalue} (which may be any Lisp expression, not just 1098value of @var{newvalue} (which may be any Lisp expression, not just
1161a generalized variable), and returning the value shifted out of 1099a generalized variable), and returning the value shifted out of
1162the first @var{place}. Thus, @code{(shiftf @var{a} @var{b} @var{c} 1100the first @var{place}. Thus, @code{(cl-shiftf @var{a} @var{b} @var{c}
1163@var{d})} is equivalent to 1101@var{d})} is equivalent to
1164 1102
1165@example 1103@example
1166(prog1 1104(prog1
1167 @var{a} 1105 @var{a}
1168 (psetf @var{a} @var{b} 1106 (cl-psetf @var{a} @var{b}
1169 @var{b} @var{c} 1107 @var{b} @var{c}
1170 @var{c} @var{d})) 1108 @var{c} @var{d}))
1171@end example 1109@end example
1172 1110
1173@noindent 1111@noindent
1174except that the subforms of @var{a}, @var{b}, and @var{c} are actually 1112except that the subforms of @var{a}, @var{b}, and @var{c} are actually
1175evaluated only once each and in the apparent order. 1113evaluated only once each and in the apparent order.
1176@end defspec 1114@end defmac
1177 1115
1178@defspec rotatef place@dots{} 1116@defmac cl-rotatef place@dots{}
1179This macro rotates the @var{place}s left by one in circular fashion. 1117This macro rotates the @var{place}s left by one in circular fashion.
1180Thus, @code{(rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to 1118Thus, @code{(cl-rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to
1181 1119
1182@example 1120@example
1183(psetf @var{a} @var{b} 1121(cl-psetf @var{a} @var{b}
1184 @var{b} @var{c} 1122 @var{b} @var{c}
1185 @var{c} @var{d} 1123 @var{c} @var{d}
1186 @var{d} @var{a}) 1124 @var{d} @var{a})
1187@end example 1125@end example
1188 1126
1189@noindent 1127@noindent
1190except for the evaluation of subforms. @code{rotatef} always 1128except for the evaluation of subforms. @code{cl-rotatef} always
1191returns @code{nil}. Note that @code{(rotatef @var{a} @var{b})} 1129returns @code{nil}. Note that @code{(cl-rotatef @var{a} @var{b})}
1192conveniently exchanges @var{a} and @var{b}. 1130conveniently exchanges @var{a} and @var{b}.
1193@end defspec 1131@end defmac
1194 1132
1195The following macros were invented for this package; they have no 1133The following macros were invented for this package; they have no
1196analogues in Common Lisp. 1134analogues in Common Lisp.
1197 1135
1198@defspec letf (bindings@dots{}) forms@dots{} 1136@defmac cl-letf (bindings@dots{}) forms@dots{}
1199This macro is analogous to @code{let}, but for generalized variables 1137This macro is analogous to @code{let}, but for generalized variables
1200rather than just symbols. Each @var{binding} should be of the form 1138rather than just symbols. Each @var{binding} should be of the form
1201@code{(@var{place} @var{value})}; the original contents of the 1139@code{(@var{place} @var{value})}; the original contents of the
@@ -1208,294 +1146,91 @@ error.
1208For example, 1146For example,
1209 1147
1210@example 1148@example
1211(letf (((point) (point-min)) 1149(cl-letf (((point) (point-min))
1212 (a 17)) 1150 (a 17))
1213 ...) 1151 ...)
1214@end example 1152@end example
1215 1153
1216@noindent 1154@noindent
1217moves ``point'' in the current buffer to the beginning of the buffer, 1155moves point in the current buffer to the beginning of the buffer,
1218and also binds @code{a} to 17 (as if by a normal @code{let}, since 1156and also binds @code{a} to 17 (as if by a normal @code{let}, since
1219@code{a} is just a regular variable). After the body exits, @code{a} 1157@code{a} is just a regular variable). After the body exits, @code{a}
1220is set back to its original value and point is moved back to its 1158is set back to its original value and point is moved back to its
1221original position. 1159original position.
1222 1160
1223Note that @code{letf} on @code{(point)} is not quite like a 1161Note that @code{cl-letf} on @code{(point)} is not quite like a
1224@code{save-excursion}, as the latter effectively saves a marker 1162@code{save-excursion}, as the latter effectively saves a marker
1225which tracks insertions and deletions in the buffer. Actually, 1163which tracks insertions and deletions in the buffer. Actually,
1226a @code{letf} of @code{(point-marker)} is much closer to this 1164a @code{cl-letf} of @code{(point-marker)} is much closer to this
1227behavior. (@code{point} and @code{point-marker} are equivalent 1165behavior. (@code{point} and @code{point-marker} are equivalent
1228as @code{setf} places; each will accept either an integer or a 1166as @code{setf} places; each will accept either an integer or a
1229marker as the stored value.) 1167marker as the stored value.)
1230 1168
1231Since generalized variables look like lists, @code{let}'s shorthand 1169Since generalized variables look like lists, @code{let}'s shorthand
1232of using @samp{foo} for @samp{(foo nil)} as a @var{binding} would 1170of using @samp{foo} for @samp{(foo nil)} as a @var{binding} would
1233be ambiguous in @code{letf} and is not allowed. 1171be ambiguous in @code{cl-letf} and is not allowed.
1234 1172
1235However, a @var{binding} specifier may be a one-element list 1173However, a @var{binding} specifier may be a one-element list
1236@samp{(@var{place})}, which is similar to @samp{(@var{place} 1174@samp{(@var{place})}, which is similar to @samp{(@var{place}
1237@var{place})}. In other words, the @var{place} is not disturbed 1175@var{place})}. In other words, the @var{place} is not disturbed
1238on entry to the body, and the only effect of the @code{letf} is 1176on entry to the body, and the only effect of the @code{cl-letf} is
1239to restore the original value of @var{place} afterwards. (The 1177to restore the original value of @var{place} afterwards.
1240redundant access-and-store suggested by the @code{(@var{place} 1178@c I suspect this may no longer be true; either way it's
1179@c implementation detail and so not essential to document.
1180@ignore
1181(The redundant access-and-store suggested by the @code{(@var{place}
1241@var{place})} example does not actually occur.) 1182@var{place})} example does not actually occur.)
1242 1183@end ignore
1243In most cases, the @var{place} must have a well-defined value on 1184
1244entry to the @code{letf} form. The only exceptions are plain 1185Note that in this case, and in fact almost every case, @var{place}
1245variables and calls to @code{symbol-value} and @code{symbol-function}. 1186must have a well-defined value outside the @code{cl-letf} body.
1246If the symbol is not bound on entry, it is simply made unbound by 1187There is essentially only one exception to this, which is @var{place}
1247@code{makunbound} or @code{fmakunbound} on exit. 1188a plain variable with a specified @var{value} (such as @code{(a 17)}
1248@end defspec 1189in the above example).
1249 1190@c See http://debbugs.gnu.org/12758
1250@defspec letf* (bindings@dots{}) forms@dots{} 1191@c Some or all of this was true for cl.el, but not for cl-lib.el.
1251This macro is to @code{letf} what @code{let*} is to @code{let}: 1192@ignore
1193The only exceptions are plain variables and calls to
1194@code{symbol-value} and @code{symbol-function}. If the symbol is not
1195bound on entry, it is simply made unbound by @code{makunbound} or
1196@code{fmakunbound} on exit.
1197@end ignore
1198@end defmac
1199
1200@defmac cl-letf* (bindings@dots{}) forms@dots{}
1201This macro is to @code{cl-letf} what @code{let*} is to @code{let}:
1252It does the bindings in sequential rather than parallel order. 1202It does the bindings in sequential rather than parallel order.
1253@end defspec 1203@end defmac
1254 1204
1255@defspec callf @var{function} @var{place} @var{args}@dots{} 1205@defmac cl-callf @var{function} @var{place} @var{args}@dots{}
1256This is the ``generic'' modify macro. It calls @var{function}, 1206This is the ``generic'' modify macro. It calls @var{function},
1257which should be an unquoted function name, macro name, or lambda. 1207which should be an unquoted function name, macro name, or lambda.
1258It passes @var{place} and @var{args} as arguments, and assigns the 1208It passes @var{place} and @var{args} as arguments, and assigns the
1259result back to @var{place}. For example, @code{(incf @var{place} 1209result back to @var{place}. For example, @code{(cl-incf @var{place}
1260@var{n})} is the same as @code{(callf + @var{place} @var{n})}. 1210@var{n})} is the same as @code{(cl-callf + @var{place} @var{n})}.
1261Some more examples: 1211Some more examples:
1262 1212
1263@example 1213@example
1264(callf abs my-number) 1214(cl-callf abs my-number)
1265(callf concat (buffer-name) "<" (int-to-string n) ">") 1215(cl-callf concat (buffer-name) "<" (number-to-string n) ">")
1266(callf union happy-people (list joe bob) :test 'same-person) 1216(cl-callf cl-union happy-people (list joe bob) :test 'same-person)
1267@end example 1217@end example
1268 1218
1269@xref{Customizing Setf}, for @code{define-modify-macro}, a way 1219Note again that @code{cl-callf} is an extension to standard Common Lisp.
1270to create even more concise notations for modify macros. Note 1220@end defmac
1271again that @code{callf} is an extension to standard Common Lisp.
1272@end defspec
1273 1221
1274@defspec callf2 @var{function} @var{arg1} @var{place} @var{args}@dots{} 1222@defmac cl-callf2 @var{function} @var{arg1} @var{place} @var{args}@dots{}
1275This macro is like @code{callf}, except that @var{place} is 1223This macro is like @code{cl-callf}, except that @var{place} is
1276the @emph{second} argument of @var{function} rather than the 1224the @emph{second} argument of @var{function} rather than the
1277first. For example, @code{(push @var{x} @var{place})} is 1225first. For example, @code{(push @var{x} @var{place})} is
1278equivalent to @code{(callf2 cons @var{x} @var{place})}. 1226equivalent to @code{(cl-callf2 cons @var{x} @var{place})}.
1279@end defspec 1227@end defmac
1280 1228
1281The @code{callf} and @code{callf2} macros serve as building 1229The @code{cl-callf} and @code{cl-callf2} macros serve as building
1282blocks for other macros like @code{incf}, @code{pushnew}, and 1230blocks for other macros like @code{cl-incf}, and @code{cl-pushnew}.
1283@code{define-modify-macro}. The @code{letf} and @code{letf*} 1231The @code{cl-letf} and @code{cl-letf*} macros are used in the processing
1284macros are used in the processing of symbol macros; 1232of symbol macros; @pxref{Macro Bindings}.
1285@pxref{Macro Bindings}.
1286 1233
1287@node Customizing Setf
1288@subsection Customizing Setf
1289
1290@noindent
1291Common Lisp defines three macros, @code{define-modify-macro},
1292@code{defsetf}, and @code{define-setf-method}, that allow the
1293user to extend generalized variables in various ways.
1294
1295@defspec define-modify-macro name arglist function [doc-string]
1296This macro defines a ``read-modify-write'' macro similar to
1297@code{incf} and @code{decf}. The macro @var{name} is defined
1298to take a @var{place} argument followed by additional arguments
1299described by @var{arglist}. The call
1300
1301@example
1302(@var{name} @var{place} @var{args}...)
1303@end example
1304
1305@noindent
1306will be expanded to
1307
1308@example
1309(callf @var{func} @var{place} @var{args}...)
1310@end example
1311
1312@noindent
1313which in turn is roughly equivalent to
1314
1315@example
1316(setf @var{place} (@var{func} @var{place} @var{args}...))
1317@end example
1318
1319For example:
1320
1321@example
1322(define-modify-macro incf (&optional (n 1)) +)
1323(define-modify-macro concatf (&rest args) concat)
1324@end example
1325
1326Note that @code{&key} is not allowed in @var{arglist}, but
1327@code{&rest} is sufficient to pass keywords on to the function.
1328
1329Most of the modify macros defined by Common Lisp do not exactly
1330follow the pattern of @code{define-modify-macro}. For example,
1331@code{push} takes its arguments in the wrong order, and @code{pop}
1332is completely irregular. You can define these macros ``by hand''
1333using @code{get-setf-method}, or consult the source file
1334@file{cl-macs.el} to see how to use the internal @code{setf}
1335building blocks.
1336@end defspec
1337
1338@defspec defsetf access-fn update-fn
1339This is the simpler of two @code{defsetf} forms. Where
1340@var{access-fn} is the name of a function which accesses a place,
1341this declares @var{update-fn} to be the corresponding store
1342function. From now on,
1343
1344@example
1345(setf (@var{access-fn} @var{arg1} @var{arg2} @var{arg3}) @var{value})
1346@end example
1347
1348@noindent
1349will be expanded to
1350
1351@example
1352(@var{update-fn} @var{arg1} @var{arg2} @var{arg3} @var{value})
1353@end example
1354
1355@noindent
1356The @var{update-fn} is required to be either a true function, or
1357a macro which evaluates its arguments in a function-like way. Also,
1358the @var{update-fn} is expected to return @var{value} as its result.
1359Otherwise, the above expansion would not obey the rules for the way
1360@code{setf} is supposed to behave.
1361
1362As a special (non-Common-Lisp) extension, a third argument of @code{t}
1363to @code{defsetf} says that the @code{update-fn}'s return value is
1364not suitable, so that the above @code{setf} should be expanded to
1365something more like
1366
1367@example
1368(let ((temp @var{value}))
1369 (@var{update-fn} @var{arg1} @var{arg2} @var{arg3} temp)
1370 temp)
1371@end example
1372
1373Some examples of the use of @code{defsetf}, drawn from the standard
1374suite of setf methods, are:
1375
1376@example
1377(defsetf car setcar)
1378(defsetf symbol-value set)
1379(defsetf buffer-name rename-buffer t)
1380@end example
1381@end defspec
1382
1383@defspec defsetf access-fn arglist (store-var) forms@dots{}
1384This is the second, more complex, form of @code{defsetf}. It is
1385rather like @code{defmacro} except for the additional @var{store-var}
1386argument. The @var{forms} should return a Lisp form which stores
1387the value of @var{store-var} into the generalized variable formed
1388by a call to @var{access-fn} with arguments described by @var{arglist}.
1389The @var{forms} may begin with a string which documents the @code{setf}
1390method (analogous to the doc string that appears at the front of a
1391function).
1392
1393For example, the simple form of @code{defsetf} is shorthand for
1394
1395@example
1396(defsetf @var{access-fn} (&rest args) (store)
1397 (append '(@var{update-fn}) args (list store)))
1398@end example
1399
1400The Lisp form that is returned can access the arguments from
1401@var{arglist} and @var{store-var} in an unrestricted fashion;
1402macros like @code{setf} and @code{incf} which invoke this
1403setf-method will insert temporary variables as needed to make
1404sure the apparent order of evaluation is preserved.
1405
1406Another example drawn from the standard package:
1407
1408@example
1409(defsetf nth (n x) (store)
1410 (list 'setcar (list 'nthcdr n x) store))
1411@end example
1412@end defspec
1413
1414@defspec define-setf-method access-fn arglist forms@dots{}
1415This is the most general way to create new place forms. When
1416a @code{setf} to @var{access-fn} with arguments described by
1417@var{arglist} is expanded, the @var{forms} are evaluated and
1418must return a list of five items:
1419
1420@enumerate
1421@item
1422A list of @dfn{temporary variables}.
1423
1424@item
1425A list of @dfn{value forms} corresponding to the temporary variables
1426above. The temporary variables will be bound to these value forms
1427as the first step of any operation on the generalized variable.
1428
1429@item
1430A list of exactly one @dfn{store variable} (generally obtained
1431from a call to @code{gensym}).
1432
1433@item
1434A Lisp form which stores the contents of the store variable into
1435the generalized variable, assuming the temporaries have been
1436bound as described above.
1437
1438@item
1439A Lisp form which accesses the contents of the generalized variable,
1440assuming the temporaries have been bound.
1441@end enumerate
1442
1443This is exactly like the Common Lisp macro of the same name,
1444except that the method returns a list of five values rather
1445than the five values themselves, since Emacs Lisp does not
1446support Common Lisp's notion of multiple return values.
1447
1448Once again, the @var{forms} may begin with a documentation string.
1449
1450A setf-method should be maximally conservative with regard to
1451temporary variables. In the setf-methods generated by
1452@code{defsetf}, the second return value is simply the list of
1453arguments in the place form, and the first return value is a
1454list of a corresponding number of temporary variables generated
1455by @code{gensym}. Macros like @code{setf} and @code{incf} which
1456use this setf-method will optimize away most temporaries that
1457turn out to be unnecessary, so there is little reason for the
1458setf-method itself to optimize.
1459@end defspec
1460
1461@defun get-setf-method place &optional env
1462This function returns the setf-method for @var{place}, by
1463invoking the definition previously recorded by @code{defsetf}
1464or @code{define-setf-method}. The result is a list of five
1465values as described above. You can use this function to build
1466your own @code{incf}-like modify macros. (Actually, it is
1467better to use the internal functions @code{cl-setf-do-modify}
1468and @code{cl-setf-do-store}, which are a bit easier to use and
1469which also do a number of optimizations; consult the source
1470code for the @code{incf} function for a simple example.)
1471
1472The argument @var{env} specifies the ``environment'' to be
1473passed on to @code{macroexpand} if @code{get-setf-method} should
1474need to expand a macro in @var{place}. It should come from
1475an @code{&environment} argument to the macro or setf-method
1476that called @code{get-setf-method}.
1477
1478See also the source code for the setf-methods for @code{apply}
1479and @code{substring}, each of which works by calling
1480@code{get-setf-method} on a simpler case, then massaging
1481the result in various ways.
1482@end defun
1483
1484Modern Common Lisp defines a second, independent way to specify
1485the @code{setf} behavior of a function, namely ``@code{setf}
1486functions'' whose names are lists @code{(setf @var{name})}
1487rather than symbols. For example, @code{(defun (setf foo) @dots{})}
1488defines the function that is used when @code{setf} is applied to
1489@code{foo}. This package does not currently support @code{setf}
1490functions. In particular, it is a compile-time error to use
1491@code{setf} on a form which has not already been @code{defsetf}'d
1492or otherwise declared; in newer Common Lisps, this would not be
1493an error since the function @code{(setf @var{func})} might be
1494defined later.
1495
1496@iftex
1497@secno=4
1498@end iftex
1499 1234
1500@node Variable Bindings 1235@node Variable Bindings
1501@section Variable Bindings 1236@section Variable Bindings
@@ -1504,14 +1239,13 @@ defined later.
1504These Lisp forms make bindings to variables and function names, 1239These Lisp forms make bindings to variables and function names,
1505analogous to Lisp's built-in @code{let} form. 1240analogous to Lisp's built-in @code{let} form.
1506 1241
1507@xref{Modify Macros}, for the @code{letf} and @code{letf*} forms which 1242@xref{Modify Macros}, for the @code{cl-letf} and @code{cl-letf*} forms which
1508are also related to variable bindings. 1243are also related to variable bindings.
1509 1244
1510@menu 1245@menu
1511* Dynamic Bindings:: The @code{progv} form. 1246* Dynamic Bindings:: The @code{cl-progv} form.
1512* Lexical Bindings:: @code{lexical-let} and lexical closures.
1513* Function Bindings:: @code{flet} and @code{labels}. 1247* Function Bindings:: @code{flet} and @code{labels}.
1514* Macro Bindings:: @code{macrolet} and @code{symbol-macrolet}. 1248* Macro Bindings:: @code{cl-macrolet} and @code{cl-symbol-macrolet}.
1515@end menu 1249@end menu
1516 1250
1517@node Dynamic Bindings 1251@node Dynamic Bindings
@@ -1519,134 +1253,20 @@ are also related to variable bindings.
1519 1253
1520@noindent 1254@noindent
1521The standard @code{let} form binds variables whose names are known 1255The standard @code{let} form binds variables whose names are known
1522at compile-time. The @code{progv} form provides an easy way to 1256at compile-time. The @code{cl-progv} form provides an easy way to
1523bind variables whose names are computed at run-time. 1257bind variables whose names are computed at run-time.
1524 1258
1525@defspec progv symbols values forms@dots{} 1259@defmac cl-progv symbols values forms@dots{}
1526This form establishes @code{let}-style variable bindings on a 1260This form establishes @code{let}-style variable bindings on a
1527set of variables computed at run-time. The expressions 1261set of variables computed at run-time. The expressions
1528@var{symbols} and @var{values} are evaluated, and must return lists 1262@var{symbols} and @var{values} are evaluated, and must return lists
1529of symbols and values, respectively. The symbols are bound to the 1263of symbols and values, respectively. The symbols are bound to the
1530corresponding values for the duration of the body @var{form}s. 1264corresponding values for the duration of the body @var{form}s.
1531If @var{values} is shorter than @var{symbols}, the last few symbols 1265If @var{values} is shorter than @var{symbols}, the last few symbols
1532are made unbound (as if by @code{makunbound}) inside the body. 1266are bound to @code{nil}.
1533If @var{symbols} is shorter than @var{values}, the excess values 1267If @var{symbols} is shorter than @var{values}, the excess values
1534are ignored. 1268are ignored.
1535@end defspec 1269@end defmac
1536
1537@node Lexical Bindings
1538@subsection Lexical Bindings
1539
1540@noindent
1541The @code{CL} package defines the following macro which
1542more closely follows the Common Lisp @code{let} form:
1543
1544@defspec lexical-let (bindings@dots{}) forms@dots{}
1545This form is exactly like @code{let} except that the bindings it
1546establishes are purely lexical. Lexical bindings are similar to
1547local variables in a language like C: Only the code physically
1548within the body of the @code{lexical-let} (after macro expansion)
1549may refer to the bound variables.
1550
1551@example
1552(setq a 5)
1553(defun foo (b) (+ a b))
1554(let ((a 2)) (foo a))
1555 @result{} 4
1556(lexical-let ((a 2)) (foo a))
1557 @result{} 7
1558@end example
1559
1560@noindent
1561In this example, a regular @code{let} binding of @code{a} actually
1562makes a temporary change to the global variable @code{a}, so @code{foo}
1563is able to see the binding of @code{a} to 2. But @code{lexical-let}
1564actually creates a distinct local variable @code{a} for use within its
1565body, without any effect on the global variable of the same name.
1566
1567The most important use of lexical bindings is to create @dfn{closures}.
1568A closure is a function object that refers to an outside lexical
1569variable. For example:
1570
1571@example
1572(defun make-adder (n)
1573 (lexical-let ((n n))
1574 (function (lambda (m) (+ n m)))))
1575(setq add17 (make-adder 17))
1576(funcall add17 4)
1577 @result{} 21
1578@end example
1579
1580@noindent
1581The call @code{(make-adder 17)} returns a function object which adds
158217 to its argument. If @code{let} had been used instead of
1583@code{lexical-let}, the function object would have referred to the
1584global @code{n}, which would have been bound to 17 only during the
1585call to @code{make-adder} itself.
1586
1587@example
1588(defun make-counter ()
1589 (lexical-let ((n 0))
1590 (function* (lambda (&optional (m 1)) (incf n m)))))
1591(setq count-1 (make-counter))
1592(funcall count-1 3)
1593 @result{} 3
1594(funcall count-1 14)
1595 @result{} 17
1596(setq count-2 (make-counter))
1597(funcall count-2 5)
1598 @result{} 5
1599(funcall count-1 2)
1600 @result{} 19
1601(funcall count-2)
1602 @result{} 6
1603@end example
1604
1605@noindent
1606Here we see that each call to @code{make-counter} creates a distinct
1607local variable @code{n}, which serves as a private counter for the
1608function object that is returned.
1609
1610Closed-over lexical variables persist until the last reference to
1611them goes away, just like all other Lisp objects. For example,
1612@code{count-2} refers to a function object which refers to an
1613instance of the variable @code{n}; this is the only reference
1614to that variable, so after @code{(setq count-2 nil)} the garbage
1615collector would be able to delete this instance of @code{n}.
1616Of course, if a @code{lexical-let} does not actually create any
1617closures, then the lexical variables are free as soon as the
1618@code{lexical-let} returns.
1619
1620Many closures are used only during the extent of the bindings they
1621refer to; these are known as ``downward funargs'' in Lisp parlance.
1622When a closure is used in this way, regular Emacs Lisp dynamic
1623bindings suffice and will be more efficient than @code{lexical-let}
1624closures:
1625
1626@example
1627(defun add-to-list (x list)
1628 (mapcar (lambda (y) (+ x y))) list)
1629(add-to-list 7 '(1 2 5))
1630 @result{} (8 9 12)
1631@end example
1632
1633@noindent
1634Since this lambda is only used while @code{x} is still bound,
1635it is not necessary to make a true closure out of it.
1636
1637You can use @code{defun} or @code{flet} inside a @code{lexical-let}
1638to create a named closure. If several closures are created in the
1639body of a single @code{lexical-let}, they all close over the same
1640instance of the lexical variable.
1641
1642The @code{lexical-let} form is an extension to Common Lisp. In
1643true Common Lisp, all bindings are lexical unless declared otherwise.
1644@end defspec
1645
1646@defspec lexical-let* (bindings@dots{}) forms@dots{}
1647This form is just like @code{lexical-let}, except that the bindings
1648are made sequentially in the manner of @code{let*}.
1649@end defspec
1650 1270
1651@node Function Bindings 1271@node Function Bindings
1652@subsection Function Bindings 1272@subsection Function Bindings
@@ -1655,12 +1275,12 @@ are made sequentially in the manner of @code{let*}.
1655These forms make @code{let}-like bindings to functions instead 1275These forms make @code{let}-like bindings to functions instead
1656of variables. 1276of variables.
1657 1277
1658@defspec flet (bindings@dots{}) forms@dots{} 1278@defmac flet (bindings@dots{}) forms@dots{}
1659This form establishes @code{let}-style bindings on the function 1279This form establishes @code{let}-style bindings on the function
1660cells of symbols rather than on the value cells. Each @var{binding} 1280cells of symbols rather than on the value cells. Each @var{binding}
1661must be a list of the form @samp{(@var{name} @var{arglist} 1281must be a list of the form @samp{(@var{name} @var{arglist}
1662@var{forms}@dots{})}, which defines a function exactly as if 1282@var{forms}@dots{})}, which defines a function exactly as if
1663it were a @code{defun*} form. The function @var{name} is defined 1283it were a @code{cl-defun} form. The function @var{name} is defined
1664accordingly for the duration of the body of the @code{flet}; then 1284accordingly for the duration of the body of the @code{flet}; then
1665the old function definition, or lack thereof, is restored. 1285the old function definition, or lack thereof, is restored.
1666 1286
@@ -1696,12 +1316,12 @@ handling. Attempts to redefine such functions using @code{flet} will
1696fail if byte-compiled. In such cases, use @code{labels} instead. 1316fail if byte-compiled. In such cases, use @code{labels} instead.
1697 1317
1698Functions defined by @code{flet} may use the full Common Lisp 1318Functions defined by @code{flet} may use the full Common Lisp
1699argument notation supported by @code{defun*}; also, the function 1319argument notation supported by @code{cl-defun}; also, the function
1700body is enclosed in an implicit block as if by @code{defun*}. 1320body is enclosed in an implicit block as if by @code{cl-defun}.
1701@xref{Program Structure}. 1321@xref{Program Structure}.
1702@end defspec 1322@end defmac
1703 1323
1704@defspec labels (bindings@dots{}) forms@dots{} 1324@defmac labels (bindings@dots{}) forms@dots{}
1705The @code{labels} form is like @code{flet}, except that it 1325The @code{labels} form is like @code{flet}, except that it
1706makes lexical bindings of the function names rather than 1326makes lexical bindings of the function names rather than
1707dynamic bindings. (In true Common Lisp, both @code{flet} and 1327dynamic bindings. (In true Common Lisp, both @code{flet} and
@@ -1722,29 +1342,33 @@ functions.
1722A ``reference'' to a function name is either a call to that 1342A ``reference'' to a function name is either a call to that
1723function, or a use of its name quoted by @code{quote} or 1343function, or a use of its name quoted by @code{quote} or
1724@code{function} to be passed on to, say, @code{mapcar}. 1344@code{function} to be passed on to, say, @code{mapcar}.
1725@end defspec 1345@end defmac
1726 1346
1727@node Macro Bindings 1347@node Macro Bindings
1728@subsection Macro Bindings 1348@subsection Macro Bindings
1729 1349
1730@noindent 1350@noindent
1731These forms create local macros and ``symbol macros.'' 1351These forms create local macros and ``symbol macros''.
1732 1352
1733@defspec macrolet (bindings@dots{}) forms@dots{} 1353@defmac cl-macrolet (bindings@dots{}) forms@dots{}
1734This form is analogous to @code{flet}, but for macros instead of 1354This form is analogous to @code{flet}, but for macros instead of
1735functions. Each @var{binding} is a list of the same form as the 1355functions. Each @var{binding} is a list of the same form as the
1736arguments to @code{defmacro*} (i.e., a macro name, argument list, 1356arguments to @code{cl-defmacro} (i.e., a macro name, argument list,
1737and macro-expander forms). The macro is defined accordingly for 1357and macro-expander forms). The macro is defined accordingly for
1738use within the body of the @code{macrolet}. 1358use within the body of the @code{cl-macrolet}.
1739 1359
1740Because of the nature of macros, @code{macrolet} is lexically 1360@c FIXME this should be modified to say ``even when lexical-binding
1741scoped even in Emacs Lisp: The @code{macrolet} binding will 1361@c is code{nil}'', but is that true? The doc of cl-macrolet just
1362@c refers us to cl-flet, which refers to cl-labels, which says that it
1363@c behaves differently according to whether l-b is true or not.
1364Because of the nature of macros, @code{cl-macrolet} is lexically
1365scoped even in Emacs Lisp: The @code{cl-macrolet} binding will
1742affect only calls that appear physically within the body 1366affect only calls that appear physically within the body
1743@var{forms}, possibly after expansion of other macros in the 1367@var{forms}, possibly after expansion of other macros in the
1744body. 1368body.
1745@end defspec 1369@end defmac
1746 1370
1747@defspec symbol-macrolet (bindings@dots{}) forms@dots{} 1371@defmac cl-symbol-macrolet (bindings@dots{}) forms@dots{}
1748This form creates @dfn{symbol macros}, which are macros that look 1372This form creates @dfn{symbol macros}, which are macros that look
1749like variable references rather than function calls. Each 1373like variable references rather than function calls. Each
1750@var{binding} is a list @samp{(@var{var} @var{expansion})}; 1374@var{binding} is a list @samp{(@var{var} @var{expansion})};
@@ -1753,8 +1377,8 @@ replaced by @var{expansion}.
1753 1377
1754@example 1378@example
1755(setq bar '(5 . 9)) 1379(setq bar '(5 . 9))
1756(symbol-macrolet ((foo (car bar))) 1380(cl-symbol-macrolet ((foo (car bar)))
1757 (incf foo)) 1381 (cl-incf foo))
1758bar 1382bar
1759 @result{} (6 . 9) 1383 @result{} (6 . 9)
1760@end example 1384@end example
@@ -1764,25 +1388,28 @@ I.e., @code{(setq foo 4)} in the above would be equivalent to
1764@code{(setf foo 4)}, which in turn expands to @code{(setf (car bar) 4)}. 1388@code{(setf foo 4)}, which in turn expands to @code{(setf (car bar) 4)}.
1765 1389
1766Likewise, a @code{let} or @code{let*} binding a symbol macro is 1390Likewise, a @code{let} or @code{let*} binding a symbol macro is
1767treated like a @code{letf} or @code{letf*}. This differs from true 1391treated like a @code{cl-letf} or @code{cl-letf*}. This differs from true
1392@c FIXME does it work like this in Emacs with lexical-binding = t?
1768Common Lisp, where the rules of lexical scoping cause a @code{let} 1393Common Lisp, where the rules of lexical scoping cause a @code{let}
1769binding to shadow a @code{symbol-macrolet} binding. In this package, 1394binding to shadow a @code{cl-symbol-macrolet} binding. In this package,
1395@c FIXME obsolete.
1770only @code{lexical-let} and @code{lexical-let*} will shadow a symbol 1396only @code{lexical-let} and @code{lexical-let*} will shadow a symbol
1771macro. 1397macro.
1772 1398
1773There is no analogue of @code{defmacro} for symbol macros; all symbol 1399There is no analogue of @code{defmacro} for symbol macros; all symbol
1774macros are local. A typical use of @code{symbol-macrolet} is in the 1400macros are local. A typical use of @code{cl-symbol-macrolet} is in the
1775expansion of another macro: 1401expansion of another macro:
1776 1402
1777@example 1403@example
1778(defmacro* my-dolist ((x list) &rest body) 1404(cl-defmacro my-dolist ((x list) &rest body)
1779 (let ((var (gensym))) 1405 (let ((var (gensym)))
1780 (list 'loop 'for var 'on list 'do 1406 (list 'cl-loop 'for var 'on list 'do
1781 (list* 'symbol-macrolet (list (list x (list 'car var))) 1407 (cl-list* 'cl-symbol-macrolet
1782 body)))) 1408 (list (list x (list 'car var)))
1409 body))))
1783 1410
1784(setq mylist '(1 2 3 4)) 1411(setq mylist '(1 2 3 4))
1785(my-dolist (x mylist) (incf x)) 1412(my-dolist (x mylist) (cl-incf x))
1786mylist 1413mylist
1787 @result{} (2 3 4 5) 1414 @result{} (2 3 4 5)
1788@end example 1415@end example
@@ -1794,22 +1421,22 @@ reference onto the elements of the list. The @code{my-dolist} call
1794shown here expands to 1421shown here expands to
1795 1422
1796@example 1423@example
1797(loop for G1234 on mylist do 1424(cl-loop for G1234 on mylist do
1798 (symbol-macrolet ((x (car G1234))) 1425 (cl-symbol-macrolet ((x (car G1234)))
1799 (incf x))) 1426 (cl-incf x)))
1800@end example 1427@end example
1801 1428
1802@noindent 1429@noindent
1803which in turn expands to 1430which in turn expands to
1804 1431
1805@example 1432@example
1806(loop for G1234 on mylist do (incf (car G1234))) 1433(cl-loop for G1234 on mylist do (cl-incf (car G1234)))
1807@end example 1434@end example
1808 1435
1809@xref{Loop Facility}, for a description of the @code{loop} macro. 1436@xref{Loop Facility}, for a description of the @code{cl-loop} macro.
1810This package defines a nonstandard @code{in-ref} loop clause that 1437This package defines a nonstandard @code{in-ref} loop clause that
1811works much like @code{my-dolist}. 1438works much like @code{my-dolist}.
1812@end defspec 1439@end defmac
1813 1440
1814@node Conditionals 1441@node Conditionals
1815@section Conditionals 1442@section Conditionals
@@ -1818,11 +1445,11 @@ works much like @code{my-dolist}.
1818These conditional forms augment Emacs Lisp's simple @code{if}, 1445These conditional forms augment Emacs Lisp's simple @code{if},
1819@code{and}, @code{or}, and @code{cond} forms. 1446@code{and}, @code{or}, and @code{cond} forms.
1820 1447
1821@defspec case keyform clause@dots{} 1448@defmac cl-case keyform clause@dots{}
1822This macro evaluates @var{keyform}, then compares it with the key 1449This macro evaluates @var{keyform}, then compares it with the key
1823values listed in the various @var{clause}s. Whichever clause matches 1450values listed in the various @var{clause}s. Whichever clause matches
1824the key is executed; comparison is done by @code{eql}. If no clause 1451the key is executed; comparison is done by @code{eql}. If no clause
1825matches, the @code{case} form returns @code{nil}. The clauses are 1452matches, the @code{cl-case} form returns @code{nil}. The clauses are
1826of the form 1453of the form
1827 1454
1828@example 1455@example
@@ -1833,7 +1460,7 @@ of the form
1833where @var{keylist} is a list of key values. If there is exactly 1460where @var{keylist} is a list of key values. If there is exactly
1834one value, and it is not a cons cell or the symbol @code{nil} or 1461one value, and it is not a cons cell or the symbol @code{nil} or
1835@code{t}, then it can be used by itself as a @var{keylist} without 1462@code{t}, then it can be used by itself as a @var{keylist} without
1836being enclosed in a list. All key values in the @code{case} form 1463being enclosed in a list. All key values in the @code{cl-case} form
1837must be distinct. The final clauses may use @code{t} in place of 1464must be distinct. The final clauses may use @code{t} in place of
1838a @var{keylist} to indicate a default clause that should be taken 1465a @var{keylist} to indicate a default clause that should be taken
1839if none of the other clauses match. (The symbol @code{otherwise} 1466if none of the other clauses match. (The symbol @code{otherwise}
@@ -1846,28 +1473,28 @@ four things depending on whether it is an @samp{a}, a @samp{b},
1846a @key{RET} or @kbd{C-j}, or anything else. 1473a @key{RET} or @kbd{C-j}, or anything else.
1847 1474
1848@example 1475@example
1849(case (read-char) 1476(cl-case (read-char)
1850 (?a (do-a-thing)) 1477 (?a (do-a-thing))
1851 (?b (do-b-thing)) 1478 (?b (do-b-thing))
1852 ((?\r ?\n) (do-ret-thing)) 1479 ((?\r ?\n) (do-ret-thing))
1853 (t (do-other-thing))) 1480 (t (do-other-thing)))
1854@end example 1481@end example
1855@end defspec 1482@end defmac
1856 1483
1857@defspec ecase keyform clause@dots{} 1484@defmac cl-ecase keyform clause@dots{}
1858This macro is just like @code{case}, except that if the key does 1485This macro is just like @code{cl-case}, except that if the key does
1859not match any of the clauses, an error is signaled rather than 1486not match any of the clauses, an error is signaled rather than
1860simply returning @code{nil}. 1487simply returning @code{nil}.
1861@end defspec 1488@end defmac
1862 1489
1863@defspec typecase keyform clause@dots{} 1490@defmac cl-typecase keyform clause@dots{}
1864This macro is a version of @code{case} that checks for types 1491This macro is a version of @code{cl-case} that checks for types
1865rather than values. Each @var{clause} is of the form 1492rather than values. Each @var{clause} is of the form
1866@samp{(@var{type} @var{body}...)}. @xref{Type Predicates}, 1493@samp{(@var{type} @var{body}...)}. @xref{Type Predicates},
1867for a description of type specifiers. For example, 1494for a description of type specifiers. For example,
1868 1495
1869@example 1496@example
1870(typecase x 1497(cl-typecase x
1871 (integer (munch-integer x)) 1498 (integer (munch-integer x))
1872 (float (munch-float x)) 1499 (float (munch-float x))
1873 (string (munch-integer (string-to-int x))) 1500 (string (munch-integer (string-to-int x)))
@@ -1877,13 +1504,13 @@ for a description of type specifiers. For example,
1877The type specifier @code{t} matches any type of object; the word 1504The type specifier @code{t} matches any type of object; the word
1878@code{otherwise} is also allowed. To make one clause match any of 1505@code{otherwise} is also allowed. To make one clause match any of
1879several types, use an @code{(or ...)} type specifier. 1506several types, use an @code{(or ...)} type specifier.
1880@end defspec 1507@end defmac
1881 1508
1882@defspec etypecase keyform clause@dots{} 1509@defmac cl-etypecase keyform clause@dots{}
1883This macro is just like @code{typecase}, except that if the key does 1510This macro is just like @code{cl-typecase}, except that if the key does
1884not match any of the clauses, an error is signaled rather than 1511not match any of the clauses, an error is signaled rather than
1885simply returning @code{nil}. 1512simply returning @code{nil}.
1886@end defspec 1513@end defmac
1887 1514
1888@node Blocks and Exits 1515@node Blocks and Exits
1889@section Blocks and Exits 1516@section Blocks and Exits
@@ -1891,26 +1518,26 @@ simply returning @code{nil}.
1891@noindent 1518@noindent
1892Common Lisp @dfn{blocks} provide a non-local exit mechanism very 1519Common Lisp @dfn{blocks} provide a non-local exit mechanism very
1893similar to @code{catch} and @code{throw}, but lexically rather than 1520similar to @code{catch} and @code{throw}, but lexically rather than
1894dynamically scoped. This package actually implements @code{block} 1521dynamically scoped. This package actually implements @code{cl-block}
1895in terms of @code{catch}; however, the lexical scoping allows the 1522in terms of @code{catch}; however, the lexical scoping allows the
1896optimizing byte-compiler to omit the costly @code{catch} step if the 1523optimizing byte-compiler to omit the costly @code{catch} step if the
1897body of the block does not actually @code{return-from} the block. 1524body of the block does not actually @code{cl-return-from} the block.
1898 1525
1899@defspec block name forms@dots{} 1526@defmac cl-block name forms@dots{}
1900The @var{forms} are evaluated as if by a @code{progn}. However, 1527The @var{forms} are evaluated as if by a @code{progn}. However,
1901if any of the @var{forms} execute @code{(return-from @var{name})}, 1528if any of the @var{forms} execute @code{(cl-return-from @var{name})},
1902they will jump out and return directly from the @code{block} form. 1529they will jump out and return directly from the @code{cl-block} form.
1903The @code{block} returns the result of the last @var{form} unless 1530The @code{cl-block} returns the result of the last @var{form} unless
1904a @code{return-from} occurs. 1531a @code{cl-return-from} occurs.
1905 1532
1906The @code{block}/@code{return-from} mechanism is quite similar to 1533The @code{cl-block}/@code{cl-return-from} mechanism is quite similar to
1907the @code{catch}/@code{throw} mechanism. The main differences are 1534the @code{catch}/@code{throw} mechanism. The main differences are
1908that block @var{name}s are unevaluated symbols, rather than forms 1535that block @var{name}s are unevaluated symbols, rather than forms
1909(such as quoted symbols) which evaluate to a tag at run-time; and 1536(such as quoted symbols) which evaluate to a tag at run-time; and
1910also that blocks are lexically scoped whereas @code{catch}/@code{throw} 1537also that blocks are lexically scoped whereas @code{catch}/@code{throw}
1911are dynamically scoped. This means that functions called from the 1538are dynamically scoped. This means that functions called from the
1912body of a @code{catch} can also @code{throw} to the @code{catch}, 1539body of a @code{catch} can also @code{throw} to the @code{catch},
1913but the @code{return-from} referring to a block name must appear 1540but the @code{cl-return-from} referring to a block name must appear
1914physically within the @var{forms} that make up the body of the block. 1541physically within the @var{forms} that make up the body of the block.
1915They may not appear within other called functions, although they may 1542They may not appear within other called functions, although they may
1916appear within macro expansions or @code{lambda}s in the body. Block 1543appear within macro expansions or @code{lambda}s in the body. Block
@@ -1919,11 +1546,11 @@ names and @code{catch} names form independent name-spaces.
1919In true Common Lisp, @code{defun} and @code{defmacro} surround 1546In true Common Lisp, @code{defun} and @code{defmacro} surround
1920the function or expander bodies with implicit blocks with the 1547the function or expander bodies with implicit blocks with the
1921same name as the function or macro. This does not occur in Emacs 1548same name as the function or macro. This does not occur in Emacs
1922Lisp, but this package provides @code{defun*} and @code{defmacro*} 1549Lisp, but this package provides @code{cl-defun} and @code{cl-defmacro}
1923forms which do create the implicit block. 1550forms which do create the implicit block.
1924 1551
1925The Common Lisp looping constructs defined by this package, 1552The Common Lisp looping constructs defined by this package,
1926such as @code{loop} and @code{dolist}, also create implicit blocks 1553such as @code{cl-loop} and @code{cl-dolist}, also create implicit blocks
1927just as in Common Lisp. 1554just as in Common Lisp.
1928 1555
1929Because they are implemented in terms of Emacs Lisp @code{catch} 1556Because they are implemented in terms of Emacs Lisp @code{catch}
@@ -1931,24 +1558,24 @@ and @code{throw}, blocks have the same overhead as actual
1931@code{catch} constructs (roughly two function calls). However, 1558@code{catch} constructs (roughly two function calls). However,
1932the optimizing byte compiler will optimize away the @code{catch} 1559the optimizing byte compiler will optimize away the @code{catch}
1933if the block does 1560if the block does
1934not in fact contain any @code{return} or @code{return-from} calls 1561not in fact contain any @code{cl-return} or @code{cl-return-from} calls
1935that jump to it. This means that @code{do} loops and @code{defun*} 1562that jump to it. This means that @code{cl-do} loops and @code{cl-defun}
1936functions which don't use @code{return} don't pay the overhead to 1563functions which don't use @code{cl-return} don't pay the overhead to
1937support it. 1564support it.
1938@end defspec 1565@end defmac
1939 1566
1940@defspec return-from name [result] 1567@defmac cl-return-from name [result]
1941This macro returns from the block named @var{name}, which must be 1568This macro returns from the block named @var{name}, which must be
1942an (unevaluated) symbol. If a @var{result} form is specified, it 1569an (unevaluated) symbol. If a @var{result} form is specified, it
1943is evaluated to produce the result returned from the @code{block}. 1570is evaluated to produce the result returned from the @code{block}.
1944Otherwise, @code{nil} is returned. 1571Otherwise, @code{nil} is returned.
1945@end defspec 1572@end defmac
1946 1573
1947@defspec return [result] 1574@defmac cl-return [result]
1948This macro is exactly like @code{(return-from nil @var{result})}. 1575This macro is exactly like @code{(cl-return-from nil @var{result})}.
1949Common Lisp loops like @code{do} and @code{dolist} implicitly enclose 1576Common Lisp loops like @code{cl-do} and @code{cl-dolist} implicitly enclose
1950themselves in @code{nil} blocks. 1577themselves in @code{nil} blocks.
1951@end defspec 1578@end defmac
1952 1579
1953@node Iteration 1580@node Iteration
1954@section Iteration 1581@section Iteration
@@ -1958,27 +1585,27 @@ The macros described here provide more sophisticated, high-level
1958looping constructs to complement Emacs Lisp's basic @code{while} 1585looping constructs to complement Emacs Lisp's basic @code{while}
1959loop. 1586loop.
1960 1587
1961@defspec loop forms@dots{} 1588@defmac cl-loop forms@dots{}
1962The @code{CL} package supports both the simple, old-style meaning of 1589The @code{CL} package supports both the simple, old-style meaning of
1963@code{loop} and the extremely powerful and flexible feature known as 1590@code{loop} and the extremely powerful and flexible feature known as
1964the @dfn{Loop Facility} or @dfn{Loop Macro}. This more advanced 1591the @dfn{Loop Facility} or @dfn{Loop Macro}. This more advanced
1965facility is discussed in the following section; @pxref{Loop Facility}. 1592facility is discussed in the following section; @pxref{Loop Facility}.
1966The simple form of @code{loop} is described here. 1593The simple form of @code{loop} is described here.
1967 1594
1968If @code{loop} is followed by zero or more Lisp expressions, 1595If @code{cl-loop} is followed by zero or more Lisp expressions,
1969then @code{(loop @var{exprs}@dots{})} simply creates an infinite 1596then @code{(cl-loop @var{exprs}@dots{})} simply creates an infinite
1970loop executing the expressions over and over. The loop is 1597loop executing the expressions over and over. The loop is
1971enclosed in an implicit @code{nil} block. Thus, 1598enclosed in an implicit @code{nil} block. Thus,
1972 1599
1973@example 1600@example
1974(loop (foo) (if (no-more) (return 72)) (bar)) 1601(cl-loop (foo) (if (no-more) (return 72)) (bar))
1975@end example 1602@end example
1976 1603
1977@noindent 1604@noindent
1978is exactly equivalent to 1605is exactly equivalent to
1979 1606
1980@example 1607@example
1981(block nil (while t (foo) (if (no-more) (return 72)) (bar))) 1608(cl-block nil (while t (foo) (if (no-more) (return 72)) (bar)))
1982@end example 1609@end example
1983 1610
1984If any of the expressions are plain symbols, the loop is instead 1611If any of the expressions are plain symbols, the loop is instead
@@ -1986,9 +1613,9 @@ interpreted as a Loop Macro specification as described later.
1986(This is not a restriction in practice, since a plain symbol 1613(This is not a restriction in practice, since a plain symbol
1987in the above notation would simply access and throw away the 1614in the above notation would simply access and throw away the
1988value of a variable.) 1615value of a variable.)
1989@end defspec 1616@end defmac
1990 1617
1991@defspec do (spec@dots{}) (end-test [result@dots{}]) forms@dots{} 1618@defmac cl-do (spec@dots{}) (end-test [result@dots{}]) forms@dots{}
1992This macro creates a general iterative loop. Each @var{spec} is 1619This macro creates a general iterative loop. Each @var{spec} is
1993of the form 1620of the form
1994 1621
@@ -2004,15 +1631,15 @@ evaluated, then each @var{var} is set to the associated @var{step}
2004expression (as if by a @code{cl-psetq} form) and the next iteration 1631expression (as if by a @code{cl-psetq} form) and the next iteration
2005begins. Once the @var{end-test} becomes true, the @var{result} 1632begins. Once the @var{end-test} becomes true, the @var{result}
2006forms are evaluated (with the @var{var}s still bound to their 1633forms are evaluated (with the @var{var}s still bound to their
2007values) to produce the result returned by @code{do}. 1634values) to produce the result returned by @code{cl-do}.
2008 1635
2009The entire @code{do} loop is enclosed in an implicit @code{nil} 1636The entire @code{cl-do} loop is enclosed in an implicit @code{nil}
2010block, so that you can use @code{(return)} to break out of the 1637block, so that you can use @code{(cl-return)} to break out of the
2011loop at any time. 1638loop at any time.
2012 1639
2013If there are no @var{result} forms, the loop returns @code{nil}. 1640If there are no @var{result} forms, the loop returns @code{nil}.
2014If a given @var{var} has no @var{step} form, it is bound to its 1641If a given @var{var} has no @var{step} form, it is bound to its
2015@var{init} value but not otherwise modified during the @code{do} 1642@var{init} value but not otherwise modified during the @code{cl-do}
2016loop (unless the code explicitly modifies it); this case is just 1643loop (unless the code explicitly modifies it); this case is just
2017a shorthand for putting a @code{(let ((@var{var} @var{init})) @dots{})} 1644a shorthand for putting a @code{(let ((@var{var} @var{init})) @dots{})}
2018around the loop. If @var{init} is also omitted it defaults to 1645around the loop. If @var{init} is also omitted it defaults to
@@ -2023,21 +1650,21 @@ in place of @samp{(@var{var})}, again following the analogy with
2023This example (from Steele) illustrates a loop which applies the 1650This example (from Steele) illustrates a loop which applies the
2024function @code{f} to successive pairs of values from the lists 1651function @code{f} to successive pairs of values from the lists
2025@code{foo} and @code{bar}; it is equivalent to the call 1652@code{foo} and @code{bar}; it is equivalent to the call
2026@code{(mapcar* 'f foo bar)}. Note that this loop has no body 1653@code{(cl-mapcar 'f foo bar)}. Note that this loop has no body
2027@var{forms} at all, performing all its work as side effects of 1654@var{forms} at all, performing all its work as side effects of
2028the rest of the loop. 1655the rest of the loop.
2029 1656
2030@example 1657@example
2031(do ((x foo (cdr x)) 1658(cl-do ((x foo (cdr x))
2032 (y bar (cdr y)) 1659 (y bar (cdr y))
2033 (z nil (cons (f (car x) (car y)) z))) 1660 (z nil (cons (f (car x) (car y)) z)))
2034 ((or (null x) (null y)) 1661 ((or (null x) (null y))
2035 (nreverse z))) 1662 (nreverse z)))
2036@end example 1663@end example
2037@end defspec 1664@end defmac
2038 1665
2039@defspec do* (spec@dots{}) (end-test [result@dots{}]) forms@dots{} 1666@defmac cl-do* (spec@dots{}) (end-test [result@dots{}]) forms@dots{}
2040This is to @code{do} what @code{let*} is to @code{let}. In 1667This is to @code{cl-do} what @code{let*} is to @code{let}. In
2041particular, the initial values are bound as if by @code{let*} 1668particular, the initial values are bound as if by @code{let*}
2042rather than @code{let}, and the steps are assigned as if by 1669rather than @code{let}, and the steps are assigned as if by
2043@code{setq} rather than @code{cl-psetq}. 1670@code{setq} rather than @code{cl-psetq}.
@@ -2045,18 +1672,18 @@ rather than @code{let}, and the steps are assigned as if by
2045Here is another way to write the above loop: 1672Here is another way to write the above loop:
2046 1673
2047@example 1674@example
2048(do* ((xp foo (cdr xp)) 1675(cl-do* ((xp foo (cdr xp))
2049 (yp bar (cdr yp)) 1676 (yp bar (cdr yp))
2050 (x (car xp) (car xp)) 1677 (x (car xp) (car xp))
2051 (y (car yp) (car yp)) 1678 (y (car yp) (car yp))
2052 z) 1679 z)
2053 ((or (null xp) (null yp)) 1680 ((or (null xp) (null yp))
2054 (nreverse z)) 1681 (nreverse z))
2055 (push (f x y) z)) 1682 (push (f x y) z))
2056@end example 1683@end example
2057@end defspec 1684@end defmac
2058 1685
2059@defspec dolist (var list [result]) forms@dots{} 1686@defmac cl-dolist (var list [result]) forms@dots{}
2060This is a more specialized loop which iterates across the elements 1687This is a more specialized loop which iterates across the elements
2061of a list. @var{list} should evaluate to a list; the body @var{forms} 1688of a list. @var{list} should evaluate to a list; the body @var{forms}
2062are executed with @var{var} bound to each element of the list in 1689are executed with @var{var} bound to each element of the list in
@@ -2064,9 +1691,9 @@ turn. Finally, the @var{result} form (or @code{nil}) is evaluated
2064with @var{var} bound to @code{nil} to produce the result returned by 1691with @var{var} bound to @code{nil} to produce the result returned by
2065the loop. Unlike with Emacs's built in @code{dolist}, the loop is 1692the loop. Unlike with Emacs's built in @code{dolist}, the loop is
2066surrounded by an implicit @code{nil} block. 1693surrounded by an implicit @code{nil} block.
2067@end defspec 1694@end defmac
2068 1695
2069@defspec dotimes (var count [result]) forms@dots{} 1696@defmac cl-dotimes (var count [result]) forms@dots{}
2070This is a more specialized loop which iterates a specified number 1697This is a more specialized loop which iterates a specified number
2071of times. The body is executed with @var{var} bound to the integers 1698of times. The body is executed with @var{var} bound to the integers
2072from zero (inclusive) to @var{count} (exclusive), in turn. Then 1699from zero (inclusive) to @var{count} (exclusive), in turn. Then
@@ -2074,9 +1701,9 @@ the @code{result} form is evaluated with @var{var} bound to the total
2074number of iterations that were done (i.e., @code{(max 0 @var{count})}) 1701number of iterations that were done (i.e., @code{(max 0 @var{count})})
2075to get the return value for the loop form. Unlike with Emacs's built in 1702to get the return value for the loop form. Unlike with Emacs's built in
2076@code{dolist}, the loop is surrounded by an implicit @code{nil} block. 1703@code{dolist}, the loop is surrounded by an implicit @code{nil} block.
2077@end defspec 1704@end defmac
2078 1705
2079@defspec do-symbols (var [obarray [result]]) forms@dots{} 1706@defmac cl-do-symbols (var [obarray [result]]) forms@dots{}
2080This loop iterates over all interned symbols. If @var{obarray} 1707This loop iterates over all interned symbols. If @var{obarray}
2081is specified and is not @code{nil}, it loops over all symbols in 1708is specified and is not @code{nil}, it loops over all symbols in
2082that obarray. For each symbol, the body @var{forms} are evaluated 1709that obarray. For each symbol, the body @var{forms} are evaluated
@@ -2084,12 +1711,12 @@ with @var{var} bound to that symbol. The symbols are visited in
2084an unspecified order. Afterward the @var{result} form, if any, 1711an unspecified order. Afterward the @var{result} form, if any,
2085is evaluated (with @var{var} bound to @code{nil}) to get the return 1712is evaluated (with @var{var} bound to @code{nil}) to get the return
2086value. The loop is surrounded by an implicit @code{nil} block. 1713value. The loop is surrounded by an implicit @code{nil} block.
2087@end defspec 1714@end defmac
2088 1715
2089@defspec do-all-symbols (var [result]) forms@dots{} 1716@defmac cl-do-all-symbols (var [result]) forms@dots{}
2090This is identical to @code{do-symbols} except that the @var{obarray} 1717This is identical to @code{cl-do-symbols} except that the @var{obarray}
2091argument is omitted; it always iterates over the default obarray. 1718argument is omitted; it always iterates over the default obarray.
2092@end defspec 1719@end defmac
2093 1720
2094@xref{Mapping over Sequences}, for some more functions for 1721@xref{Mapping over Sequences}, for some more functions for
2095iterating over vectors or lists. 1722iterating over vectors or lists.
@@ -2104,12 +1731,12 @@ that they are either too simple and limited, such as Common Lisp's
2104obscure, like Common Lisp's @code{do} loop. 1731obscure, like Common Lisp's @code{do} loop.
2105 1732
2106To remedy this, recent versions of Common Lisp have added a new 1733To remedy this, recent versions of Common Lisp have added a new
2107construct called the ``Loop Facility'' or ``@code{loop} macro,'' 1734construct called the ``Loop Facility'' or ``@code{loop} macro'',
2108with an easy-to-use but very powerful and expressive syntax. 1735with an easy-to-use but very powerful and expressive syntax.
2109 1736
2110@menu 1737@menu
2111* Loop Basics:: @code{loop} macro, basic clause structure. 1738* Loop Basics:: @code{cl-loop} macro, basic clause structure.
2112* Loop Examples:: Working examples of @code{loop} macro. 1739* Loop Examples:: Working examples of @code{cl-loop} macro.
2113* For Clauses:: Clauses introduced by @code{for} or @code{as}. 1740* For Clauses:: Clauses introduced by @code{for} or @code{as}.
2114* Iteration Clauses:: @code{repeat}, @code{while}, @code{thereis}, etc. 1741* Iteration Clauses:: @code{repeat}, @code{while}, @code{thereis}, etc.
2115* Accumulation Clauses:: @code{collect}, @code{sum}, @code{maximize}, etc. 1742* Accumulation Clauses:: @code{collect}, @code{sum}, @code{maximize}, etc.
@@ -2120,19 +1747,19 @@ with an easy-to-use but very powerful and expressive syntax.
2120@subsection Loop Basics 1747@subsection Loop Basics
2121 1748
2122@noindent 1749@noindent
2123The @code{loop} macro essentially creates a mini-language within 1750The @code{cl-loop} macro essentially creates a mini-language within
2124Lisp that is specially tailored for describing loops. While this 1751Lisp that is specially tailored for describing loops. While this
2125language is a little strange-looking by the standards of regular Lisp, 1752language is a little strange-looking by the standards of regular Lisp,
2126it turns out to be very easy to learn and well-suited to its purpose. 1753it turns out to be very easy to learn and well-suited to its purpose.
2127 1754
2128Since @code{loop} is a macro, all parsing of the loop language 1755Since @code{cl-loop} is a macro, all parsing of the loop language
2129takes place at byte-compile time; compiled @code{loop}s are just 1756takes place at byte-compile time; compiled @code{cl-loop}s are just
2130as efficient as the equivalent @code{while} loops written longhand. 1757as efficient as the equivalent @code{while} loops written longhand.
2131 1758
2132@defspec loop clauses@dots{} 1759@defmac cl-loop clauses@dots{}
2133A loop construct consists of a series of @var{clause}s, each 1760A loop construct consists of a series of @var{clause}s, each
2134introduced by a symbol like @code{for} or @code{do}. Clauses 1761introduced by a symbol like @code{for} or @code{do}. Clauses
2135are simply strung together in the argument list of @code{loop}, 1762are simply strung together in the argument list of @code{cl-loop},
2136with minimal extra parentheses. The various types of clauses 1763with minimal extra parentheses. The various types of clauses
2137specify initializations, such as the binding of temporary 1764specify initializations, such as the binding of temporary
2138variables, actions to be taken in the loop, stepping actions, 1765variables, actions to be taken in the loop, stepping actions,
@@ -2142,9 +1769,9 @@ Common Lisp specifies a certain general order of clauses in a
2142loop: 1769loop:
2143 1770
2144@example 1771@example
2145(loop @var{name-clause} 1772(cl-loop @var{name-clause}
2146 @var{var-clauses}@dots{} 1773 @var{var-clauses}@dots{}
2147 @var{action-clauses}@dots{}) 1774 @var{action-clauses}@dots{})
2148@end example 1775@end example
2149 1776
2150The @var{name-clause} optionally gives a name to the implicit 1777The @var{name-clause} optionally gives a name to the implicit
@@ -2155,7 +1782,7 @@ be modified or iterated throughout the course of the loop. The
2155@var{action-clauses} are things to be done during the loop, such 1782@var{action-clauses} are things to be done during the loop, such
2156as computing, collecting, and returning values. 1783as computing, collecting, and returning values.
2157 1784
2158The Emacs version of the @code{loop} macro is less restrictive about 1785The Emacs version of the @code{cl-loop} macro is less restrictive about
2159the order of clauses, but things will behave most predictably if 1786the order of clauses, but things will behave most predictably if
2160you put the variable-binding clauses @code{with}, @code{for}, and 1787you put the variable-binding clauses @code{with}, @code{for}, and
2161@code{repeat} before the action clauses. As in Common Lisp, 1788@code{repeat} before the action clauses. As in Common Lisp,
@@ -2166,9 +1793,9 @@ them to return a value by using an accumulation clause like
2166@code{collect}, an end-test clause like @code{always}, or an 1793@code{collect}, an end-test clause like @code{always}, or an
2167explicit @code{return} clause to jump out of the implicit block. 1794explicit @code{return} clause to jump out of the implicit block.
2168(Because the loop body is enclosed in an implicit block, you can 1795(Because the loop body is enclosed in an implicit block, you can
2169also use regular Lisp @code{return} or @code{return-from} to 1796also use regular Lisp @code{cl-return} or @code{cl-return-from} to
2170break out of the loop.) 1797break out of the loop.)
2171@end defspec 1798@end defmac
2172 1799
2173The following sections give some examples of the Loop Macro in 1800The following sections give some examples of the Loop Macro in
2174action, and describe the particular loop clauses in great detail. 1801action, and describe the particular loop clauses in great detail.
@@ -2180,25 +1807,25 @@ for additional discussion and examples of the @code{loop} macro.
2180 1807
2181@noindent 1808@noindent
2182Before listing the full set of clauses that are allowed, let's 1809Before listing the full set of clauses that are allowed, let's
2183look at a few example loops just to get a feel for the @code{loop} 1810look at a few example loops just to get a feel for the @code{cl-loop}
2184language. 1811language.
2185 1812
2186@example 1813@example
2187(loop for buf in (buffer-list) 1814(cl-loop for buf in (buffer-list)
2188 collect (buffer-file-name buf)) 1815 collect (buffer-file-name buf))
2189@end example 1816@end example
2190 1817
2191@noindent 1818@noindent
2192This loop iterates over all Emacs buffers, using the list 1819This loop iterates over all Emacs buffers, using the list
2193returned by @code{buffer-list}. For each buffer @code{buf}, 1820returned by @code{buffer-list}. For each buffer @var{buf},
2194it calls @code{buffer-file-name} and collects the results into 1821it calls @code{buffer-file-name} and collects the results into
2195a list, which is then returned from the @code{loop} construct. 1822a list, which is then returned from the @code{cl-loop} construct.
2196The result is a list of the file names of all the buffers in 1823The result is a list of the file names of all the buffers in
2197Emacs's memory. The words @code{for}, @code{in}, and @code{collect} 1824Emacs's memory. The words @code{for}, @code{in}, and @code{collect}
2198are reserved words in the @code{loop} language. 1825are reserved words in the @code{cl-loop} language.
2199 1826
2200@example 1827@example
2201(loop repeat 20 do (insert "Yowsa\n")) 1828(cl-loop repeat 20 do (insert "Yowsa\n"))
2202@end example 1829@end example
2203 1830
2204@noindent 1831@noindent
@@ -2206,7 +1833,7 @@ This loop inserts the phrase ``Yowsa'' twenty times in the
2206current buffer. 1833current buffer.
2207 1834
2208@example 1835@example
2209(loop until (eobp) do (munch-line) (forward-line 1)) 1836(cl-loop until (eobp) do (munch-line) (forward-line 1))
2210@end example 1837@end example
2211 1838
2212@noindent 1839@noindent
@@ -2215,7 +1842,7 @@ of the buffer. If point is already at the end of the buffer,
2215the loop exits immediately. 1842the loop exits immediately.
2216 1843
2217@example 1844@example
2218(loop do (munch-line) until (eobp) do (forward-line 1)) 1845(cl-loop do (munch-line) until (eobp) do (forward-line 1))
2219@end example 1846@end example
2220 1847
2221@noindent 1848@noindent
@@ -2223,10 +1850,10 @@ This loop is similar to the above one, except that @code{munch-line}
2223is always called at least once. 1850is always called at least once.
2224 1851
2225@example 1852@example
2226(loop for x from 1 to 100 1853(cl-loop for x from 1 to 100
2227 for y = (* x x) 1854 for y = (* x x)
2228 until (>= y 729) 1855 until (>= y 729)
2229 finally return (list x (= y 729))) 1856 finally return (list x (= y 729)))
2230@end example 1857@end example
2231 1858
2232@noindent 1859@noindent
@@ -2246,7 +1873,7 @@ Note that even though this loop contains three clauses (two
2246@code{for}s and an @code{until}) that would have been enough to 1873@code{for}s and an @code{until}) that would have been enough to
2247define loops all by themselves, it still creates a single loop 1874define loops all by themselves, it still creates a single loop
2248rather than some sort of triple-nested loop. You must explicitly 1875rather than some sort of triple-nested loop. You must explicitly
2249nest your @code{loop} constructs if you want nested loops. 1876nest your @code{cl-loop} constructs if you want nested loops.
2250 1877
2251@node For Clauses 1878@node For Clauses
2252@subsection For Clauses 1879@subsection For Clauses
@@ -2272,7 +1899,7 @@ The variable is bound around the loop as if by @code{let}:
2272 1899
2273@example 1900@example
2274(setq i 'happy) 1901(setq i 'happy)
2275(loop for i from 1 to 10 do (do-something-with i)) 1902(cl-loop for i from 1 to 10 do (do-something-with i))
2276i 1903i
2277 @result{} happy 1904 @result{} happy
2278@end example 1905@end example
@@ -2302,10 +1929,10 @@ which are like @code{upto} and @code{downto} respectively except
2302that they are exclusive rather than inclusive limits: 1929that they are exclusive rather than inclusive limits:
2303 1930
2304@example 1931@example
2305(loop for x to 10 collect x) 1932(cl-loop for x to 10 collect x)
2306 @result{} (0 1 2 3 4 5 6 7 8 9 10) 1933 @result{} (0 1 2 3 4 5 6 7 8 9 10)
2307(loop for x below 10 collect x) 1934(cl-loop for x below 10 collect x)
2308 @result{} (0 1 2 3 4 5 6 7 8 9) 1935 @result{} (0 1 2 3 4 5 6 7 8 9)
2309@end example 1936@end example
2310 1937
2311The @code{by} value is always positive, even for downward-counting 1938The @code{by} value is always positive, even for downward-counting
@@ -2320,25 +1947,25 @@ is used to traverse the list instead of @code{cdr}; it must be a
2320function taking one argument. For example: 1947function taking one argument. For example:
2321 1948
2322@example 1949@example
2323(loop for x in '(1 2 3 4 5 6) collect (* x x)) 1950(cl-loop for x in '(1 2 3 4 5 6) collect (* x x))
2324 @result{} (1 4 9 16 25 36) 1951 @result{} (1 4 9 16 25 36)
2325(loop for x in '(1 2 3 4 5 6) by 'cddr collect (* x x)) 1952(cl-loop for x in '(1 2 3 4 5 6) by 'cddr collect (* x x))
2326 @result{} (1 9 25) 1953 @result{} (1 9 25)
2327@end example 1954@end example
2328 1955
2329@item for @var{var} on @var{list} by @var{function} 1956@item for @var{var} on @var{list} by @var{function}
2330This clause iterates @var{var} over all the cons cells of @var{list}. 1957This clause iterates @var{var} over all the cons cells of @var{list}.
2331 1958
2332@example 1959@example
2333(loop for x on '(1 2 3 4) collect x) 1960(cl-loop for x on '(1 2 3 4) collect x)
2334 @result{} ((1 2 3 4) (2 3 4) (3 4) (4)) 1961 @result{} ((1 2 3 4) (2 3 4) (3 4) (4))
2335@end example 1962@end example
2336 1963
2337With @code{by}, there is no real reason that the @code{on} expression 1964With @code{by}, there is no real reason that the @code{on} expression
2338must be a list. For example: 1965must be a list. For example:
2339 1966
2340@example 1967@example
2341(loop for x on first-animal by 'next-animal collect x) 1968(cl-loop for x on first-animal by 'next-animal collect x)
2342@end example 1969@end example
2343 1970
2344@noindent 1971@noindent
@@ -2352,7 +1979,7 @@ a @code{setf}-able ``reference'' onto the elements of the list
2352rather than just a temporary variable. For example, 1979rather than just a temporary variable. For example,
2353 1980
2354@example 1981@example
2355(loop for x in-ref my-list do (incf x)) 1982(cl-loop for x in-ref my-list do (cl-incf x))
2356@end example 1983@end example
2357 1984
2358@noindent 1985@noindent
@@ -2364,8 +1991,8 @@ This clause iterates @var{var} over all the elements of @var{array},
2364which may be a vector or a string. 1991which may be a vector or a string.
2365 1992
2366@example 1993@example
2367(loop for x across "aeiou" 1994(cl-loop for x across "aeiou"
2368 do (use-vowel (char-to-string x))) 1995 do (use-vowel (char-to-string x)))
2369@end example 1996@end example
2370 1997
2371@item for @var{var} across-ref @var{array} 1998@item for @var{var} across-ref @var{array}
@@ -2397,10 +2024,10 @@ an unspecified order.
2397As an example, 2024As an example,
2398 2025
2399@example 2026@example
2400(loop for sym being the symbols 2027(cl-loop for sym being the symbols
2401 when (fboundp sym) 2028 when (fboundp sym)
2402 when (string-match "^map" (symbol-name sym)) 2029 when (string-match "^map" (symbol-name sym))
2403 collect sym) 2030 collect sym)
2404@end example 2031@end example
2405 2032
2406@noindent 2033@noindent
@@ -2411,7 +2038,7 @@ are also recognized but are equivalent to @code{symbols} in Emacs Lisp.
2411 2038
2412Due to a minor implementation restriction, it will not work to have 2039Due to a minor implementation restriction, it will not work to have
2413more than one @code{for} clause iterating over symbols, hash tables, 2040more than one @code{for} clause iterating over symbols, hash tables,
2414keymaps, overlays, or intervals in a given @code{loop}. Fortunately, 2041keymaps, overlays, or intervals in a given @code{cl-loop}. Fortunately,
2415it would rarely if ever be useful to do so. It @emph{is} valid to mix 2042it would rarely if ever be useful to do so. It @emph{is} valid to mix
2416one of these types of clauses with other clauses like @code{for ... to} 2043one of these types of clauses with other clauses like @code{for ... to}
2417or @code{while}. 2044or @code{while}.
@@ -2423,10 +2050,10 @@ This clause iterates over the entries in @var{hash-table} with
2423a second variable to the opposite part. 2050a second variable to the opposite part.
2424 2051
2425@example 2052@example
2426(loop for k being the hash-keys of h 2053(cl-loop for k being the hash-keys of h
2427 using (hash-values v) 2054 using (hash-values v)
2428 do 2055 do
2429 (message "key %S -> value %S" k v)) 2056 (message "key %S -> value %S" k v))
2430@end example 2057@end example
2431 2058
2432@item for @var{var} being the key-codes of @var{keymap} 2059@item for @var{var} being the key-codes of @var{keymap}
@@ -2438,10 +2065,10 @@ A @code{using} clause can access both the codes and the bindings
2438together. 2065together.
2439 2066
2440@example 2067@example
2441(loop for c being the key-codes of (current-local-map) 2068(cl-loop for c being the key-codes of (current-local-map)
2442 using (key-bindings b) 2069 using (key-bindings b)
2443 do 2070 do
2444 (message "key %S -> binding %S" c b)) 2071 (message "key %S -> binding %S" c b))
2445@end example 2072@end example
2446 2073
2447 2074
@@ -2497,8 +2124,8 @@ and successive iterations it will be set by evaluating @var{expr2}
2497these two loops are effectively the same: 2124these two loops are effectively the same:
2498 2125
2499@example 2126@example
2500(loop for x on my-list by 'cddr do ...) 2127(cl-loop for x on my-list by 'cddr do ...)
2501(loop for x = my-list then (cddr x) while x do ...) 2128(cl-loop for x = my-list then (cddr x) while x do ...)
2502@end example 2129@end example
2503 2130
2504Note that this type of @code{for} clause does not imply any sort 2131Note that this type of @code{for} clause does not imply any sort
@@ -2509,7 +2136,7 @@ If you omit the @code{then} term, @var{expr1} is used both for
2509the initial setting and for successive settings: 2136the initial setting and for successive settings:
2510 2137
2511@example 2138@example
2512(loop for x = (random) when (> x 0) return x) 2139(cl-loop for x = (random) when (> x 0) return x)
2513@end example 2140@end example
2514 2141
2515@noindent 2142@noindent
@@ -2524,10 +2151,10 @@ in which case they are processed in parallel (as if by @code{let}
2524and @code{cl-psetq}). 2151and @code{cl-psetq}).
2525 2152
2526@example 2153@example
2527(loop for x below 5 for y = nil then x collect (list x y)) 2154(cl-loop for x below 5 for y = nil then x collect (list x y))
2528 @result{} ((0 nil) (1 1) (2 2) (3 3) (4 4)) 2155 @result{} ((0 nil) (1 1) (2 2) (3 3) (4 4))
2529(loop for x below 5 and y = nil then x collect (list x y)) 2156(cl-loop for x below 5 and y = nil then x collect (list x y))
2530 @result{} ((0 nil) (1 0) (2 1) (3 2) (4 3)) 2157 @result{} ((0 nil) (1 0) (2 1) (3 2) (4 3))
2531@end example 2158@end example
2532 2159
2533@noindent 2160@noindent
@@ -2537,7 +2164,7 @@ that was just set by the previous clause; in the second loop,
2537based on the value of @code{x} left over from the previous time 2164based on the value of @code{x} left over from the previous time
2538through the loop. 2165through the loop.
2539 2166
2540Another feature of the @code{loop} macro is @dfn{destructuring}, 2167Another feature of the @code{cl-loop} macro is @dfn{destructuring},
2541similar in concept to the destructuring provided by @code{defmacro}. 2168similar in concept to the destructuring provided by @code{defmacro}.
2542The @var{var} part of any @code{for} clause can be given as a list 2169The @var{var} part of any @code{for} clause can be given as a list
2543of variables instead of a single variable. The values produced 2170of variables instead of a single variable. The values produced
@@ -2545,8 +2172,8 @@ during loop execution must be lists; the values in the lists are
2545stored in the corresponding variables. 2172stored in the corresponding variables.
2546 2173
2547@example 2174@example
2548(loop for (x y) in '((2 3) (4 5) (6 7)) collect (+ x y)) 2175(cl-loop for (x y) in '((2 3) (4 5) (6 7)) collect (+ x y))
2549 @result{} (5 9 13) 2176 @result{} (5 9 13)
2550@end example 2177@end example
2551 2178
2552In loop destructuring, if there are more values than variables 2179In loop destructuring, if there are more values than variables
@@ -2558,9 +2185,9 @@ lists of variables like @code{(x . y)} are allowed, so for example
2558to process an alist 2185to process an alist
2559 2186
2560@example 2187@example
2561(loop for (key . value) in '((a . 1) (b . 2)) 2188(cl-loop for (key . value) in '((a . 1) (b . 2))
2562 collect value) 2189 collect value)
2563 @result{} (1 2) 2190 @result{} (1 2)
2564@end example 2191@end example
2565 2192
2566@node Iteration Clauses 2193@node Iteration Clauses
@@ -2577,8 +2204,8 @@ This clause simply counts up to the specified number using an
2577internal temporary variable. The loops 2204internal temporary variable. The loops
2578 2205
2579@example 2206@example
2580(loop repeat (1+ n) do ...) 2207(cl-loop repeat (1+ n) do ...)
2581(loop for temp to n do ...) 2208(cl-loop for temp to n do ...)
2582@end example 2209@end example
2583 2210
2584@noindent 2211@noindent
@@ -2593,7 +2220,7 @@ that surrounds the second one:
2593 2220
2594@example 2221@example
2595(while @var{cond} @var{forms}@dots{}) 2222(while @var{cond} @var{forms}@dots{})
2596(loop while @var{cond} do @var{forms}@dots{}) 2223(cl-loop while @var{cond} do @var{forms}@dots{})
2597@end example 2224@end example
2598 2225
2599@item until @var{condition} 2226@item until @var{condition}
@@ -2607,7 +2234,7 @@ the @code{finally} clauses are not executed. If all the conditions
2607were non-@code{nil}, the loop returns @code{t}: 2234were non-@code{nil}, the loop returns @code{t}:
2608 2235
2609@example 2236@example
2610(if (loop for size in size-list always (> size 10)) 2237(if (cl-loop for size in size-list always (> size 10))
2611 (some-big-sizes) 2238 (some-big-sizes)
2612 (no-big-sizes)) 2239 (no-big-sizes))
2613@end example 2240@end example
@@ -2684,11 +2311,11 @@ It is valid for several accumulation clauses of the same type to
2684accumulate into the same place. From Steele: 2311accumulate into the same place. From Steele:
2685 2312
2686@example 2313@example
2687(loop for name in '(fred sue alice joe june) 2314(cl-loop for name in '(fred sue alice joe june)
2688 for kids in '((bob ken) () () (kris sunshine) ()) 2315 for kids in '((bob ken) () () (kris sunshine) ())
2689 collect name 2316 collect name
2690 append kids) 2317 append kids)
2691 @result{} (fred bob ken sue alice joe kris sunshine june) 2318 @result{} (fred bob ken sue alice joe kris sunshine june)
2692@end example 2319@end example
2693 2320
2694@node Other Clauses 2321@node Other Clauses
@@ -2704,17 +2331,17 @@ otherwise leaves the variable alone during the loop. The following
2704loops are basically equivalent: 2331loops are basically equivalent:
2705 2332
2706@example 2333@example
2707(loop with x = 17 do ...) 2334(cl-loop with x = 17 do ...)
2708(let ((x 17)) (loop do ...)) 2335(let ((x 17)) (cl-loop do ...))
2709(loop for x = 17 then x do ...) 2336(cl-loop for x = 17 then x do ...)
2710@end example 2337@end example
2711 2338
2712Naturally, the variable @var{var} might be used for some purpose 2339Naturally, the variable @var{var} might be used for some purpose
2713in the rest of the loop. For example: 2340in the rest of the loop. For example:
2714 2341
2715@example 2342@example
2716(loop for x in my-list with res = nil do (push x res) 2343(cl-loop for x in my-list with res = nil do (push x res)
2717 finally return res) 2344 finally return res)
2718@end example 2345@end example
2719 2346
2720This loop inserts the elements of @code{my-list} at the front of 2347This loop inserts the elements of @code{my-list} at the front of
@@ -2749,18 +2376,18 @@ by the name @code{it} in the ``then'' part. For example:
2749@example 2376@example
2750(setq funny-numbers '(6 13 -1)) 2377(setq funny-numbers '(6 13 -1))
2751 @result{} (6 13 -1) 2378 @result{} (6 13 -1)
2752(loop for x below 10 2379(cl-loop for x below 10
2753 if (oddp x) 2380 if (oddp x)
2754 collect x into odds 2381 collect x into odds
2755 and if (memq x funny-numbers) return (cdr it) end 2382 and if (memq x funny-numbers) return (cdr it) end
2756 else 2383 else
2757 collect x into evens 2384 collect x into evens
2758 finally return (vector odds evens)) 2385 finally return (vector odds evens))
2759 @result{} [(1 3 5 7 9) (0 2 4 6 8)] 2386 @result{} [(1 3 5 7 9) (0 2 4 6 8)]
2760(setq funny-numbers '(6 7 13 -1)) 2387(setq funny-numbers '(6 7 13 -1))
2761 @result{} (6 7 13 -1) 2388 @result{} (6 7 13 -1)
2762(loop <@r{same thing again}>) 2389(cl-loop <@r{same thing again}>)
2763 @result{} (13 -1) 2390 @result{} (13 -1)
2764@end example 2391@end example
2765 2392
2766Note the use of @code{and} to put two clauses into the ``then'' 2393Note the use of @code{and} to put two clauses into the ``then''
@@ -2823,20 +2450,20 @@ Of course, @code{return} is generally used inside an @code{if} or
2823the loop would never get to ``loop'' more than once. 2450the loop would never get to ``loop'' more than once.
2824 2451
2825The clause @samp{return @var{form}} is equivalent to 2452The clause @samp{return @var{form}} is equivalent to
2453@c FIXME cl-do, cl-return?
2826@samp{do (return @var{form})} (or @code{return-from} if the loop 2454@samp{do (return @var{form})} (or @code{return-from} if the loop
2827was named). The @code{return} clause is implemented a bit more 2455was named). The @code{return} clause is implemented a bit more
2828efficiently, though. 2456efficiently, though.
2829@end table 2457@end table
2830 2458
2831While there is no high-level way to add user extensions to @code{loop} 2459While there is no high-level way to add user extensions to @code{cl-loop},
2832(comparable to @code{defsetf} for @code{setf}, say), this package 2460this package does offer two properties called @code{cl-loop-handler}
2833does offer two properties called @code{cl-loop-handler} and 2461and @code{cl-loop-for-handler} which are functions to be called when a
2834@code{cl-loop-for-handler} which are functions to be called when 2462given symbol is encountered as a top-level loop clause or @code{for}
2835a given symbol is encountered as a top-level loop clause or 2463clause, respectively. Consult the source code in file
2836@code{for} clause, respectively. Consult the source code in 2464@file{cl-macs.el} for details.
2837file @file{cl-macs.el} for details.
2838 2465
2839This package's @code{loop} macro is compatible with that of Common 2466This package's @code{cl-loop} macro is compatible with that of Common
2840Lisp, except that a few features are not implemented: @code{loop-finish} 2467Lisp, except that a few features are not implemented: @code{loop-finish}
2841and data-type specifiers. Naturally, the @code{for} clauses which 2468and data-type specifiers. Naturally, the @code{for} clauses which
2842iterate over keymaps, overlays, intervals, frames, windows, and 2469iterate over keymaps, overlays, intervals, frames, windows, and
@@ -2851,35 +2478,28 @@ functions, by contrast, always return exactly one result. This
2851package makes no attempt to emulate Common Lisp multiple return 2478package makes no attempt to emulate Common Lisp multiple return
2852values; Emacs versions of Common Lisp functions that return more 2479values; Emacs versions of Common Lisp functions that return more
2853than one value either return just the first value (as in 2480than one value either return just the first value (as in
2854@code{compiler-macroexpand}) or return a list of values (as in 2481@code{cl-compiler-macroexpand}) or return a list of values.
2855@code{get-setf-method}). This package @emph{does} define placeholders 2482This package @emph{does} define placeholders
2856for the Common Lisp functions that work with multiple values, but 2483for the Common Lisp functions that work with multiple values, but
2857in Emacs Lisp these functions simply operate on lists instead. 2484in Emacs Lisp these functions simply operate on lists instead.
2858The @code{values} form, for example, is a synonym for @code{list} 2485The @code{cl-values} form, for example, is a synonym for @code{list}
2859in Emacs. 2486in Emacs.
2860 2487
2861@defspec multiple-value-bind (var@dots{}) values-form forms@dots{} 2488@defmac cl-multiple-value-bind (var@dots{}) values-form forms@dots{}
2862This form evaluates @var{values-form}, which must return a list of 2489This form evaluates @var{values-form}, which must return a list of
2863values. It then binds the @var{var}s to these respective values, 2490values. It then binds the @var{var}s to these respective values,
2864as if by @code{let}, and then executes the body @var{forms}. 2491as if by @code{let}, and then executes the body @var{forms}.
2865If there are more @var{var}s than values, the extra @var{var}s 2492If there are more @var{var}s than values, the extra @var{var}s
2866are bound to @code{nil}. If there are fewer @var{var}s than 2493are bound to @code{nil}. If there are fewer @var{var}s than
2867values, the excess values are ignored. 2494values, the excess values are ignored.
2868@end defspec 2495@end defmac
2869 2496
2870@defspec multiple-value-setq (var@dots{}) form 2497@defmac cl-multiple-value-setq (var@dots{}) form
2871This form evaluates @var{form}, which must return a list of values. 2498This form evaluates @var{form}, which must return a list of values.
2872It then sets the @var{var}s to these respective values, as if by 2499It then sets the @var{var}s to these respective values, as if by
2873@code{setq}. Extra @var{var}s or values are treated the same as 2500@code{setq}. Extra @var{var}s or values are treated the same as
2874in @code{multiple-value-bind}. 2501in @code{cl-multiple-value-bind}.
2875@end defspec 2502@end defmac
2876
2877The older Quiroz package attempted a more faithful (but still
2878imperfect) emulation of Common Lisp multiple values. The old
2879method ``usually'' simulated true multiple values quite well,
2880but under certain circumstances would leave spurious return
2881values in memory where a later, unrelated @code{multiple-value-bind}
2882form would see them.
2883 2503
2884Since a perfect emulation is not feasible in Emacs Lisp, this 2504Since a perfect emulation is not feasible in Emacs Lisp, this
2885package opts to keep it as simple and predictable as possible. 2505package opts to keep it as simple and predictable as possible.
@@ -2897,7 +2517,7 @@ for @code{defmacro} due to technical difficulties.
2897Destructuring is made available to the user by way of the 2517Destructuring is made available to the user by way of the
2898following macro: 2518following macro:
2899 2519
2900@defspec destructuring-bind arglist expr forms@dots{} 2520@defmac cl-destructuring-bind arglist expr forms@dots{}
2901This macro expands to code which executes @var{forms}, with 2521This macro expands to code which executes @var{forms}, with
2902the variables in @var{arglist} bound to the list of values 2522the variables in @var{arglist} bound to the list of values
2903returned by @var{expr}. The @var{arglist} can include all 2523returned by @var{expr}. The @var{arglist} can include all
@@ -2906,13 +2526,13 @@ including destructuring. (The @code{&environment} keyword
2906is not allowed.) The macro expansion will signal an error 2526is not allowed.) The macro expansion will signal an error
2907if @var{expr} returns a list of the wrong number of arguments 2527if @var{expr} returns a list of the wrong number of arguments
2908or with incorrect keyword arguments. 2528or with incorrect keyword arguments.
2909@end defspec 2529@end defmac
2910 2530
2911This package also includes the Common Lisp @code{define-compiler-macro} 2531This package also includes the Common Lisp @code{cl-define-compiler-macro}
2912facility, which allows you to define compile-time expansions and 2532facility, which allows you to define compile-time expansions and
2913optimizations for your functions. 2533optimizations for your functions.
2914 2534
2915@defspec define-compiler-macro name arglist forms@dots{} 2535@defmac cl-define-compiler-macro name arglist forms@dots{}
2916This form is similar to @code{defmacro}, except that it only expands 2536This form is similar to @code{defmacro}, except that it only expands
2917calls to @var{name} at compile-time; calls processed by the Lisp 2537calls to @var{name} at compile-time; calls processed by the Lisp
2918interpreter are not expanded, nor are they expanded by the 2538interpreter are not expanded, nor are they expanded by the
@@ -2930,25 +2550,25 @@ For example, here is a simplified version of a definition that
2930appears as a standard part of this package: 2550appears as a standard part of this package:
2931 2551
2932@example 2552@example
2933(define-compiler-macro member* (&whole form a list &rest keys) 2553(cl-define-compiler-macro cl-member (&whole form a list &rest keys)
2934 (if (and (null keys) 2554 (if (and (null keys)
2935 (eq (car-safe a) 'quote) 2555 (eq (car-safe a) 'quote)
2936 (not (floatp-safe (cadr a)))) 2556 (not (floatp-safe (cadr a))))
2937 (list 'memq a list) 2557 (list 'memq a list)
2938 form)) 2558 form))
2939@end example 2559@end example
2940 2560
2941@noindent 2561@noindent
2942This definition causes @code{(member* @var{a} @var{list})} to change 2562This definition causes @code{(cl-member @var{a} @var{list})} to change
2943to a call to the faster @code{memq} in the common case where @var{a} 2563to a call to the faster @code{memq} in the common case where @var{a}
2944is a non-floating-point constant; if @var{a} is anything else, or 2564is a non-floating-point constant; if @var{a} is anything else, or
2945if there are any keyword arguments in the call, then the original 2565if there are any keyword arguments in the call, then the original
2946@code{member*} call is left intact. (The actual compiler macro 2566@code{cl-member} call is left intact. (The actual compiler macro
2947for @code{member*} optimizes a number of other cases, including 2567for @code{cl-member} optimizes a number of other cases, including
2948common @code{:test} predicates.) 2568common @code{:test} predicates.)
2949@end defspec 2569@end defmac
2950 2570
2951@defun compiler-macroexpand form 2571@defun cl-compiler-macroexpand form
2952This function is analogous to @code{macroexpand}, except that it 2572This function is analogous to @code{macroexpand}, except that it
2953expands compiler macros rather than regular macros. It returns 2573expands compiler macros rather than regular macros. It returns
2954@var{form} unchanged if it is not a call to a function for which 2574@var{form} unchanged if it is not a call to a function for which
@@ -2958,8 +2578,8 @@ decided to punt by returning its @code{&whole} argument. Like
2958for which no further expansion is possible. 2578for which no further expansion is possible.
2959@end defun 2579@end defun
2960 2580
2961@xref{Macro Bindings}, for descriptions of the @code{macrolet} 2581@xref{Macro Bindings}, for descriptions of the @code{cl-macrolet}
2962and @code{symbol-macrolet} forms for making ``local'' macro 2582and @code{cl-symbol-macrolet} forms for making ``local'' macro
2963definitions. 2583definitions.
2964 2584
2965@node Declarations 2585@node Declarations
@@ -2971,8 +2591,8 @@ mechanism that allows you to give the compiler special hints
2971about the types of data that will be stored in particular variables, 2591about the types of data that will be stored in particular variables,
2972and about the ways those variables and functions will be used. This 2592and about the ways those variables and functions will be used. This
2973package defines versions of all the Common Lisp declaration forms: 2593package defines versions of all the Common Lisp declaration forms:
2974@code{declare}, @code{locally}, @code{proclaim}, @code{declaim}, 2594@code{cl-declare}, @code{cl-locally}, @code{cl-proclaim}, @code{cl-declaim},
2975and @code{the}. 2595and @code{cl-the}.
2976 2596
2977Most of the Common Lisp declarations are not currently useful in 2597Most of the Common Lisp declarations are not currently useful in
2978Emacs Lisp, as the byte-code system provides little opportunity 2598Emacs Lisp, as the byte-code system provides little opportunity
@@ -2982,53 +2602,53 @@ declarations are meaningful when the optimizing byte
2982compiler is being used, however. Under the earlier non-optimizing 2602compiler is being used, however. Under the earlier non-optimizing
2983compiler, these declarations will effectively be ignored. 2603compiler, these declarations will effectively be ignored.
2984 2604
2985@defun proclaim decl-spec 2605@defun cl-proclaim decl-spec
2986This function records a ``global'' declaration specified by 2606This function records a ``global'' declaration specified by
2987@var{decl-spec}. Since @code{proclaim} is a function, @var{decl-spec} 2607@var{decl-spec}. Since @code{cl-proclaim} is a function, @var{decl-spec}
2988is evaluated and thus should normally be quoted. 2608is evaluated and thus should normally be quoted.
2989@end defun 2609@end defun
2990 2610
2991@defspec declaim decl-specs@dots{} 2611@defmac cl-declaim decl-specs@dots{}
2992This macro is like @code{proclaim}, except that it takes any number 2612This macro is like @code{cl-proclaim}, except that it takes any number
2993of @var{decl-spec} arguments, and the arguments are unevaluated and 2613of @var{decl-spec} arguments, and the arguments are unevaluated and
2994unquoted. The @code{declaim} macro also puts an @code{(eval-when 2614unquoted. The @code{cl-declaim} macro also puts an @code{(cl-eval-when
2995(compile load eval) ...)} around the declarations so that they will 2615(compile load eval) ...)} around the declarations so that they will
2996be registered at compile-time as well as at run-time. (This is vital, 2616be registered at compile-time as well as at run-time. (This is vital,
2997since normally the declarations are meant to influence the way the 2617since normally the declarations are meant to influence the way the
2998compiler treats the rest of the file that contains the @code{declaim} 2618compiler treats the rest of the file that contains the @code{cl-declaim}
2999form.) 2619form.)
3000@end defspec 2620@end defmac
3001 2621
3002@defspec declare decl-specs@dots{} 2622@defmac cl-declare decl-specs@dots{}
3003This macro is used to make declarations within functions and other 2623This macro is used to make declarations within functions and other
3004code. Common Lisp allows declarations in various locations, generally 2624code. Common Lisp allows declarations in various locations, generally
3005at the beginning of any of the many ``implicit @code{progn}s'' 2625at the beginning of any of the many ``implicit @code{progn}s''
3006throughout Lisp syntax, such as function bodies, @code{let} bodies, 2626throughout Lisp syntax, such as function bodies, @code{let} bodies,
3007etc. Currently the only declaration understood by @code{declare} 2627etc. Currently the only declaration understood by @code{cl-declare}
3008is @code{special}. 2628is @code{special}.
3009@end defspec 2629@end defmac
3010 2630
3011@defspec locally declarations@dots{} forms@dots{} 2631@defmac cl-locally declarations@dots{} forms@dots{}
3012In this package, @code{locally} is no different from @code{progn}. 2632In this package, @code{cl-locally} is no different from @code{progn}.
3013@end defspec 2633@end defmac
3014 2634
3015@defspec the type form 2635@defmac cl-the type form
3016Type information provided by @code{the} is ignored in this package; 2636Type information provided by @code{cl-the} is ignored in this package;
3017in other words, @code{(the @var{type} @var{form})} is equivalent 2637in other words, @code{(cl-the @var{type} @var{form})} is equivalent
3018to @var{form}. Future versions of the optimizing byte-compiler may 2638to @var{form}. Future versions of the optimizing byte-compiler may
3019make use of this information. 2639make use of this information.
3020 2640
3021For example, @code{mapcar} can map over both lists and arrays. It is 2641For example, @code{mapcar} can map over both lists and arrays. It is
3022hard for the compiler to expand @code{mapcar} into an in-line loop 2642hard for the compiler to expand @code{mapcar} into an in-line loop
3023unless it knows whether the sequence will be a list or an array ahead 2643unless it knows whether the sequence will be a list or an array ahead
3024of time. With @code{(mapcar 'car (the vector foo))}, a future 2644of time. With @code{(mapcar 'car (cl-the vector foo))}, a future
3025compiler would have enough information to expand the loop in-line. 2645compiler would have enough information to expand the loop in-line.
3026For now, Emacs Lisp will treat the above code as exactly equivalent 2646For now, Emacs Lisp will treat the above code as exactly equivalent
3027to @code{(mapcar 'car foo)}. 2647to @code{(mapcar 'car foo)}.
3028@end defspec 2648@end defmac
3029 2649
3030Each @var{decl-spec} in a @code{proclaim}, @code{declaim}, or 2650Each @var{decl-spec} in a @code{cl-proclaim}, @code{cl-declaim}, or
3031@code{declare} should be a list beginning with a symbol that says 2651@code{cl-declare} should be a list beginning with a symbol that says
3032what kind of declaration it is. This package currently understands 2652what kind of declaration it is. This package currently understands
3033@code{special}, @code{inline}, @code{notinline}, @code{optimize}, 2653@code{special}, @code{inline}, @code{notinline}, @code{optimize},
3034and @code{warn} declarations. (The @code{warn} declaration is an 2654and @code{warn} declarations. (The @code{warn} declaration is an
@@ -3045,16 +2665,16 @@ bound in the body of the function. The compiler normally emits
3045warnings for such references, since they could be typographical 2665warnings for such references, since they could be typographical
3046errors for references to local variables. 2666errors for references to local variables.
3047 2667
3048The declaration @code{(declare (special @var{var1} @var{var2}))} is 2668The declaration @code{(cl-declare (special @var{var1} @var{var2}))} is
3049equivalent to @code{(defvar @var{var1}) (defvar @var{var2})} in the 2669equivalent to @code{(defvar @var{var1}) (defvar @var{var2})} in the
3050optimizing compiler, or to nothing at all in older compilers (which 2670optimizing compiler, or to nothing at all in older compilers (which
3051do not warn for non-local references). 2671do not warn for non-local references).
3052 2672
3053In top-level contexts, it is generally better to write 2673In top-level contexts, it is generally better to write
3054@code{(defvar @var{var})} than @code{(declaim (special @var{var}))}, 2674@code{(defvar @var{var})} than @code{(cl-declaim (special @var{var}))},
3055since @code{defvar} makes your intentions clearer. But the older 2675since @code{defvar} makes your intentions clearer. But the older
3056byte compilers can not handle @code{defvar}s appearing inside of 2676byte compilers can not handle @code{defvar}s appearing inside of
3057functions, while @code{(declare (special @var{var}))} takes care 2677functions, while @code{(cl-declare (special @var{var}))} takes care
3058to work correctly with all compilers. 2678to work correctly with all compilers.
3059 2679
3060@item inline 2680@item inline
@@ -3072,8 +2692,9 @@ The following declarations are all equivalent. Note that the
3072and declare it inline all at once. 2692and declare it inline all at once.
3073 2693
3074@example 2694@example
3075(declaim (inline foo bar)) 2695(cl-declaim (inline foo bar))
3076(eval-when (compile load eval) (proclaim '(inline foo bar))) 2696(cl-eval-when (compile load eval)
2697 (cl-proclaim '(inline foo bar)))
3077(defsubst foo (...) ...) ; instead of defun 2698(defsubst foo (...) ...) ; instead of defun
3078@end example 2699@end example
3079 2700
@@ -3083,10 +2704,10 @@ request that a function you have defined should be inlined,
3083but it is impolite to use it to request inlining of an external 2704but it is impolite to use it to request inlining of an external
3084function. 2705function.
3085 2706
3086In Common Lisp, it is possible to use @code{(declare (inline @dots{}))} 2707In Common Lisp, it is possible to use @code{(cl-declare (inline @dots{}))}
3087before a particular call to a function to cause just that call to 2708before a particular call to a function to cause just that call to
3088be inlined; the current byte compilers provide no way to implement 2709be inlined; the current byte compilers provide no way to implement
3089this, so @code{(declare (inline @dots{}))} is currently ignored by 2710this, so @code{(cl-declare (inline @dots{}))} is currently ignored by
3090this package. 2711this package.
3091 2712
3092@item notinline 2713@item notinline
@@ -3103,15 +2724,15 @@ The word @code{optimize} is followed by any number of lists like
3103@code{(speed 3)} or @code{(safety 2)}. Common Lisp defines several 2724@code{(speed 3)} or @code{(safety 2)}. Common Lisp defines several
3104optimization ``qualities''; this package ignores all but @code{speed} 2725optimization ``qualities''; this package ignores all but @code{speed}
3105and @code{safety}. The value of a quality should be an integer from 2726and @code{safety}. The value of a quality should be an integer from
31060 to 3, with 0 meaning ``unimportant'' and 3 meaning ``very important.'' 27270 to 3, with 0 meaning ``unimportant'' and 3 meaning ``very important''.
3107The default level for both qualities is 1. 2728The default level for both qualities is 1.
3108 2729
3109In this package, with the optimizing compiler, the 2730In this package, with the optimizing compiler, the
3110@code{speed} quality is tied to the @code{byte-compile-optimize} 2731@code{speed} quality is tied to the @code{byte-optimize}
3111flag, which is set to @code{nil} for @code{(speed 0)} and to 2732flag, which is set to @code{nil} for @code{(speed 0)} and to
3112@code{t} for higher settings; and the @code{safety} quality is 2733@code{t} for higher settings; and the @code{safety} quality is
3113tied to the @code{byte-compile-delete-errors} flag, which is 2734tied to the @code{byte-compile-delete-errors} flag, which is
3114set to @code{t} for @code{(safety 3)} and to @code{nil} for all 2735set to @code{nil} for @code{(safety 3)} and to @code{t} for all
3115lower settings. (The latter flag controls whether the compiler 2736lower settings. (The latter flag controls whether the compiler
3116is allowed to optimize out code whose only side-effect could 2737is allowed to optimize out code whose only side-effect could
3117be to signal an error, e.g., rewriting @code{(progn foo bar)} to 2738be to signal an error, e.g., rewriting @code{(progn foo bar)} to
@@ -3125,10 +2746,10 @@ Emacs itself, Emacs will not crash with a segmentation fault
3125just because of an error in a fully-optimized Lisp program. 2746just because of an error in a fully-optimized Lisp program.
3126 2747
3127The @code{optimize} declaration is normally used in a top-level 2748The @code{optimize} declaration is normally used in a top-level
3128@code{proclaim} or @code{declaim} in a file; Common Lisp allows 2749@code{cl-proclaim} or @code{cl-declaim} in a file; Common Lisp allows
3129it to be used with @code{declare} to set the level of optimization 2750it to be used with @code{cl-declare} to set the level of optimization
3130locally for a given form, but this will not work correctly with the 2751locally for a given form, but this will not work correctly with the
3131current version of the optimizing compiler. (The @code{declare} 2752current version of the optimizing compiler. (The @code{cl-declare}
3132will set the new optimization level, but that level will not 2753will set the new optimization level, but that level will not
3133automatically be unset after the enclosing form is done.) 2754automatically be unset after the enclosing form is done.)
3134 2755
@@ -3136,7 +2757,7 @@ automatically be unset after the enclosing form is done.)
3136This declaration controls what sorts of warnings are generated 2757This declaration controls what sorts of warnings are generated
3137by the byte compiler. Again, only the optimizing compiler 2758by the byte compiler. Again, only the optimizing compiler
3138generates warnings. The word @code{warn} is followed by any 2759generates warnings. The word @code{warn} is followed by any
3139number of ``warning qualities,'' similar in form to optimization 2760number of ``warning qualities'', similar in form to optimization
3140qualities. The currently supported warning types are 2761qualities. The currently supported warning types are
3141@code{redefine}, @code{callargs}, @code{unresolved}, and 2762@code{redefine}, @code{callargs}, @code{unresolved}, and
3142@code{free-vars}; in the current system, a value of 0 will 2763@code{free-vars}; in the current system, a value of 0 will
@@ -3152,8 +2773,8 @@ This package defines several symbol-related features that were
3152missing from Emacs Lisp. 2773missing from Emacs Lisp.
3153 2774
3154@menu 2775@menu
3155* Property Lists:: @code{get*}, @code{remprop}, @code{getf}, @code{remf}. 2776* Property Lists:: @code{cl-get}, @code{cl-remprop}, @code{cl-getf}, @code{cl-remf}.
3156* Creating Symbols:: @code{gensym}, @code{gentemp}. 2777* Creating Symbols:: @code{cl-gensym}, @code{cl-gentemp}.
3157@end menu 2778@end menu
3158 2779
3159@node Property Lists 2780@node Property Lists
@@ -3165,18 +2786,18 @@ and @code{put} for operating on properties attached to symbols.
3165There are also functions for working with property lists as 2786There are also functions for working with property lists as
3166first-class data structures not attached to particular symbols. 2787first-class data structures not attached to particular symbols.
3167 2788
3168@defun get* symbol property &optional default 2789@defun cl-get symbol property &optional default
3169This function is like @code{get}, except that if the property is 2790This function is like @code{get}, except that if the property is
3170not found, the @var{default} argument provides the return value. 2791not found, the @var{default} argument provides the return value.
3171(The Emacs Lisp @code{get} function always uses @code{nil} as 2792(The Emacs Lisp @code{get} function always uses @code{nil} as
3172the default; this package's @code{get*} is equivalent to Common 2793the default; this package's @code{cl-get} is equivalent to Common
3173Lisp's @code{get}.) 2794Lisp's @code{get}.)
3174 2795
3175The @code{get*} function is @code{setf}-able; when used in this 2796The @code{cl-get} function is @code{setf}-able; when used in this
3176fashion, the @var{default} argument is allowed but ignored. 2797fashion, the @var{default} argument is allowed but ignored.
3177@end defun 2798@end defun
3178 2799
3179@defun remprop symbol property 2800@defun cl-remprop symbol property
3180This function removes the entry for @var{property} from the property 2801This function removes the entry for @var{property} from the property
3181list of @var{symbol}. It returns a true value if the property was 2802list of @var{symbol}. It returns a true value if the property was
3182indeed found and removed, or @code{nil} if there was no such property. 2803indeed found and removed, or @code{nil} if there was no such property.
@@ -3184,10 +2805,10 @@ indeed found and removed, or @code{nil} if there was no such property.
3184since @code{get} did not allow a @var{default}, it was very difficult 2805since @code{get} did not allow a @var{default}, it was very difficult
3185to distinguish between a missing property and a property whose value 2806to distinguish between a missing property and a property whose value
3186was @code{nil}; thus, setting a property to @code{nil} was close 2807was @code{nil}; thus, setting a property to @code{nil} was close
3187enough to @code{remprop} for most purposes.) 2808enough to @code{cl-remprop} for most purposes.)
3188@end defun 2809@end defun
3189 2810
3190@defun getf place property &optional default 2811@defun cl-getf place property &optional default
3191This function scans the list @var{place} as if it were a property 2812This function scans the list @var{place} as if it were a property
3192list, i.e., a list of alternating property names and values. If 2813list, i.e., a list of alternating property names and values. If
3193an even-numbered element of @var{place} is found which is @code{eq} 2814an even-numbered element of @var{place} is found which is @code{eq}
@@ -3198,10 +2819,10 @@ is given).
3198In particular, 2819In particular,
3199 2820
3200@example 2821@example
3201(get sym prop) @equiv{} (getf (symbol-plist sym) prop) 2822(get sym prop) @equiv{} (cl-getf (symbol-plist sym) prop)
3202@end example 2823@end example
3203 2824
3204It is valid to use @code{getf} as a @code{setf} place, in which case 2825It is valid to use @code{cl-getf} as a @code{setf} place, in which case
3205its @var{place} argument must itself be a valid @code{setf} place. 2826its @var{place} argument must itself be a valid @code{setf} place.
3206The @var{default} argument, if any, is ignored in this context. 2827The @var{default} argument, if any, is ignored in this context.
3207The effect is to change (via @code{setcar}) the value cell in the 2828The effect is to change (via @code{setcar}) the value cell in the
@@ -3209,25 +2830,25 @@ list that corresponds to @var{property}, or to cons a new property-value
3209pair onto the list if the property is not yet present. 2830pair onto the list if the property is not yet present.
3210 2831
3211@example 2832@example
3212(put sym prop val) @equiv{} (setf (getf (symbol-plist sym) prop) val) 2833(put sym prop val) @equiv{} (setf (cl-getf (symbol-plist sym) prop) val)
3213@end example 2834@end example
3214 2835
3215The @code{get} and @code{get*} functions are also @code{setf}-able. 2836The @code{get} and @code{cl-get} functions are also @code{setf}-able.
3216The fact that @code{default} is ignored can sometimes be useful: 2837The fact that @code{default} is ignored can sometimes be useful:
3217 2838
3218@example 2839@example
3219(incf (get* 'foo 'usage-count 0)) 2840(cl-incf (cl-get 'foo 'usage-count 0))
3220@end example 2841@end example
3221 2842
3222Here, symbol @code{foo}'s @code{usage-count} property is incremented 2843Here, symbol @code{foo}'s @code{usage-count} property is incremented
3223if it exists, or set to 1 (an incremented 0) otherwise. 2844if it exists, or set to 1 (an incremented 0) otherwise.
3224 2845
3225When not used as a @code{setf} form, @code{getf} is just a regular 2846When not used as a @code{setf} form, @code{cl-getf} is just a regular
3226function and its @var{place} argument can actually be any Lisp 2847function and its @var{place} argument can actually be any Lisp
3227expression. 2848expression.
3228@end defun 2849@end defun
3229 2850
3230@defspec remf place property 2851@defmac cl-remf place property
3231This macro removes the property-value pair for @var{property} from 2852This macro removes the property-value pair for @var{property} from
3232the property list stored at @var{place}, which is any @code{setf}-able 2853the property list stored at @var{place}, which is any @code{setf}-able
3233place expression. It returns true if the property was found. Note 2854place expression. It returns true if the property was found. Note
@@ -3235,11 +2856,7 @@ that if @var{property} happens to be first on the list, this will
3235effectively do a @code{(setf @var{place} (cddr @var{place}))}, 2856effectively do a @code{(setf @var{place} (cddr @var{place}))},
3236whereas if it occurs later, this simply uses @code{setcdr} to splice 2857whereas if it occurs later, this simply uses @code{setcdr} to splice
3237out the property and value cells. 2858out the property and value cells.
3238@end defspec 2859@end defmac
3239
3240@iftex
3241@secno=2
3242@end iftex
3243 2860
3244@node Creating Symbols 2861@node Creating Symbols
3245@section Creating Symbols 2862@section Creating Symbols
@@ -3248,7 +2865,7 @@ out the property and value cells.
3248These functions create unique symbols, typically for use as 2865These functions create unique symbols, typically for use as
3249temporary variables. 2866temporary variables.
3250 2867
3251@defun gensym &optional x 2868@defun cl-gensym &optional x
3252This function creates a new, uninterned symbol (using @code{make-symbol}) 2869This function creates a new, uninterned symbol (using @code{make-symbol})
3253with a unique name. (The name of an uninterned symbol is relevant 2870with a unique name. (The name of an uninterned symbol is relevant
3254only if the symbol is printed.) By default, the name is generated 2871only if the symbol is printed.) By default, the name is generated
@@ -3260,31 +2877,30 @@ their names will not conflict with ``real'' variables in the user's
3260code. 2877code.
3261@end defun 2878@end defun
3262 2879
3263@defvar *gensym-counter* 2880@defvar cl--gensym-counter
3264This variable holds the counter used to generate @code{gensym} names. 2881This variable holds the counter used to generate @code{cl-gensym} names.
3265It is incremented after each use by @code{gensym}. In Common Lisp 2882It is incremented after each use by @code{cl-gensym}. In Common Lisp
3266this is initialized with 0, but this package initializes it with a 2883this is initialized with 0, but this package initializes it with a
3267random (time-dependent) value to avoid trouble when two files that 2884random (time-dependent) value to avoid trouble when two files that
3268each used @code{gensym} in their compilation are loaded together. 2885each used @code{cl-gensym} in their compilation are loaded together.
3269(Uninterned symbols become interned when the compiler writes them 2886(Uninterned symbols become interned when the compiler writes them
3270out to a file and the Emacs loader loads them, so their names have to 2887out to a file and the Emacs loader loads them, so their names have to
3271be treated a bit more carefully than in Common Lisp where uninterned 2888be treated a bit more carefully than in Common Lisp where uninterned
3272symbols remain uninterned after loading.) 2889symbols remain uninterned after loading.)
3273@end defvar 2890@end defvar
3274 2891
3275@defun gentemp &optional x 2892@defun cl-gentemp &optional x
3276This function is like @code{gensym}, except that it produces a new 2893This function is like @code{cl-gensym}, except that it produces a new
3277@emph{interned} symbol. If the symbol that is generated already 2894@emph{interned} symbol. If the symbol that is generated already
3278exists, the function keeps incrementing the counter and trying 2895exists, the function keeps incrementing the counter and trying
3279again until a new symbol is generated. 2896again until a new symbol is generated.
3280@end defun 2897@end defun
3281 2898
3282The Quiroz @file{cl.el} package also defined a @code{defkeyword} 2899This package automatically creates all keywords that are called for by
3283form for creating self-quoting keyword symbols. This package 2900@code{&key} argument specifiers, and discourages the use of keywords
3284automatically creates all keywords that are called for by 2901as data unrelated to keyword arguments, so the related function
3285@code{&key} argument specifiers, and discourages the use of 2902@code{defkeyword} (to create self-quoting keyword symbols) is not
3286keywords as data unrelated to keyword arguments, so the 2903provided.
3287@code{defkeyword} form has been discontinued.
3288 2904
3289@node Numbers 2905@node Numbers
3290@chapter Numbers 2906@chapter Numbers
@@ -3294,16 +2910,12 @@ This section defines a few simple Common Lisp operations on numbers
3294which were left out of Emacs Lisp. 2910which were left out of Emacs Lisp.
3295 2911
3296@menu 2912@menu
3297* Predicates on Numbers:: @code{plusp}, @code{oddp}, @code{floatp-safe}, etc. 2913* Predicates on Numbers:: @code{cl-plusp}, @code{cl-oddp}, @code{cl-floatp-safe}, etc.
3298* Numerical Functions:: @code{abs}, @code{floor*}, etc. 2914* Numerical Functions:: @code{abs}, @code{cl-floor}, etc.
3299* Random Numbers:: @code{random*}, @code{make-random-state}. 2915* Random Numbers:: @code{cl-random}, @code{cl-make-random-state}.
3300* Implementation Parameters:: @code{most-positive-float}. 2916* Implementation Parameters:: @code{cl-most-positive-float}.
3301@end menu 2917@end menu
3302 2918
3303@iftex
3304@secno=1
3305@end iftex
3306
3307@node Predicates on Numbers 2919@node Predicates on Numbers
3308@section Predicates on Numbers 2920@section Predicates on Numbers
3309 2921
@@ -3311,66 +2923,58 @@ which were left out of Emacs Lisp.
3311These functions return @code{t} if the specified condition is 2923These functions return @code{t} if the specified condition is
3312true of the numerical argument, or @code{nil} otherwise. 2924true of the numerical argument, or @code{nil} otherwise.
3313 2925
3314@defun plusp number 2926@defun cl-plusp number
3315This predicate tests whether @var{number} is positive. It is an 2927This predicate tests whether @var{number} is positive. It is an
3316error if the argument is not a number. 2928error if the argument is not a number.
3317@end defun 2929@end defun
3318 2930
3319@defun minusp number 2931@defun cl-minusp number
3320This predicate tests whether @var{number} is negative. It is an 2932This predicate tests whether @var{number} is negative. It is an
3321error if the argument is not a number. 2933error if the argument is not a number.
3322@end defun 2934@end defun
3323 2935
3324@defun oddp integer 2936@defun cl-oddp integer
3325This predicate tests whether @var{integer} is odd. It is an 2937This predicate tests whether @var{integer} is odd. It is an
3326error if the argument is not an integer. 2938error if the argument is not an integer.
3327@end defun 2939@end defun
3328 2940
3329@defun evenp integer 2941@defun cl-evenp integer
3330This predicate tests whether @var{integer} is even. It is an 2942This predicate tests whether @var{integer} is even. It is an
3331error if the argument is not an integer. 2943error if the argument is not an integer.
3332@end defun 2944@end defun
3333 2945
3334@defun floatp-safe object 2946@defun cl-floatp-safe object
3335This predicate tests whether @var{object} is a floating-point 2947This predicate tests whether @var{object} is a floating-point
3336number. On systems that support floating-point, this is equivalent 2948number. On systems that support floating-point, this is equivalent
3337to @code{floatp}. On other systems, this always returns @code{nil}. 2949to @code{floatp}. On other systems, this always returns @code{nil}.
3338@end defun 2950@end defun
3339 2951
3340@iftex
3341@secno=3
3342@end iftex
3343
3344@node Numerical Functions 2952@node Numerical Functions
3345@section Numerical Functions 2953@section Numerical Functions
3346 2954
3347@noindent 2955@noindent
3348These functions perform various arithmetic operations on numbers. 2956These functions perform various arithmetic operations on numbers.
3349 2957
3350@defun gcd &rest integers 2958@defun cl-gcd &rest integers
3351This function returns the Greatest Common Divisor of the arguments. 2959This function returns the Greatest Common Divisor of the arguments.
3352For one argument, it returns the absolute value of that argument. 2960For one argument, it returns the absolute value of that argument.
3353For zero arguments, it returns zero. 2961For zero arguments, it returns zero.
3354@end defun 2962@end defun
3355 2963
3356@defun lcm &rest integers 2964@defun cl-lcm &rest integers
3357This function returns the Least Common Multiple of the arguments. 2965This function returns the Least Common Multiple of the arguments.
3358For one argument, it returns the absolute value of that argument. 2966For one argument, it returns the absolute value of that argument.
3359For zero arguments, it returns one. 2967For zero arguments, it returns one.
3360@end defun 2968@end defun
3361 2969
3362@defun isqrt integer 2970@defun cl-isqrt integer
3363This function computes the ``integer square root'' of its integer 2971This function computes the ``integer square root'' of its integer
3364argument, i.e., the greatest integer less than or equal to the true 2972argument, i.e., the greatest integer less than or equal to the true
3365square root of the argument. 2973square root of the argument.
3366@end defun 2974@end defun
3367 2975
3368@defun floor* number &optional divisor 2976@defun cl-floor number &optional divisor
3369This function implements the Common Lisp @code{floor} function. 2977With one argument, @code{cl-floor} returns a list of two numbers:
3370It is called @code{floor*} to avoid name conflicts with the
3371simpler @code{floor} function built-in to Emacs.
3372
3373With one argument, @code{floor*} returns a list of two numbers:
3374The argument rounded down (toward minus infinity) to an integer, 2978The argument rounded down (toward minus infinity) to an integer,
3375and the ``remainder'' which would have to be added back to the 2979and the ``remainder'' which would have to be added back to the
3376first return value to yield the argument again. If the argument 2980first return value to yield the argument again. If the argument
@@ -3379,37 +2983,37 @@ If the argument is a floating-point number, the first
3379result is a Lisp integer and the second is a Lisp float between 2983result is a Lisp integer and the second is a Lisp float between
33800 (inclusive) and 1 (exclusive). 29840 (inclusive) and 1 (exclusive).
3381 2985
3382With two arguments, @code{floor*} divides @var{number} by 2986With two arguments, @code{cl-floor} divides @var{number} by
3383@var{divisor}, and returns the floor of the quotient and the 2987@var{divisor}, and returns the floor of the quotient and the
3384corresponding remainder as a list of two numbers. If 2988corresponding remainder as a list of two numbers. If
3385@code{(floor* @var{x} @var{y})} returns @code{(@var{q} @var{r})}, 2989@code{(cl-floor @var{x} @var{y})} returns @code{(@var{q} @var{r})},
3386then @code{@var{q}*@var{y} + @var{r} = @var{x}}, with @var{r} 2990then @code{@var{q}*@var{y} + @var{r} = @var{x}}, with @var{r}
3387between 0 (inclusive) and @var{r} (exclusive). Also, note 2991between 0 (inclusive) and @var{r} (exclusive). Also, note
3388that @code{(floor* @var{x})} is exactly equivalent to 2992that @code{(cl-floor @var{x})} is exactly equivalent to
3389@code{(floor* @var{x} 1)}. 2993@code{(cl-floor @var{x} 1)}.
3390 2994
3391This function is entirely compatible with Common Lisp's @code{floor} 2995This function is entirely compatible with Common Lisp's @code{floor}
3392function, except that it returns the two results in a list since 2996function, except that it returns the two results in a list since
3393Emacs Lisp does not support multiple-valued functions. 2997Emacs Lisp does not support multiple-valued functions.
3394@end defun 2998@end defun
3395 2999
3396@defun ceiling* number &optional divisor 3000@defun cl-ceiling number &optional divisor
3397This function implements the Common Lisp @code{ceiling} function, 3001This function implements the Common Lisp @code{ceiling} function,
3398which is analogous to @code{floor} except that it rounds the 3002which is analogous to @code{floor} except that it rounds the
3399argument or quotient of the arguments up toward plus infinity. 3003argument or quotient of the arguments up toward plus infinity.
3400The remainder will be between 0 and minus @var{r}. 3004The remainder will be between 0 and minus @var{r}.
3401@end defun 3005@end defun
3402 3006
3403@defun truncate* number &optional divisor 3007@defun cl-truncate number &optional divisor
3404This function implements the Common Lisp @code{truncate} function, 3008This function implements the Common Lisp @code{truncate} function,
3405which is analogous to @code{floor} except that it rounds the 3009which is analogous to @code{floor} except that it rounds the
3406argument or quotient of the arguments toward zero. Thus it is 3010argument or quotient of the arguments toward zero. Thus it is
3407equivalent to @code{floor*} if the argument or quotient is 3011equivalent to @code{cl-floor} if the argument or quotient is
3408positive, or to @code{ceiling*} otherwise. The remainder has 3012positive, or to @code{cl-ceiling} otherwise. The remainder has
3409the same sign as @var{number}. 3013the same sign as @var{number}.
3410@end defun 3014@end defun
3411 3015
3412@defun round* number &optional divisor 3016@defun cl-round number &optional divisor
3413This function implements the Common Lisp @code{round} function, 3017This function implements the Common Lisp @code{round} function,
3414which is analogous to @code{floor} except that it rounds the 3018which is analogous to @code{floor} except that it rounds the
3415argument or quotient of the arguments to the nearest integer. 3019argument or quotient of the arguments to the nearest integer.
@@ -3417,26 +3021,16 @@ In the case of a tie (the argument or quotient is exactly
3417halfway between two integers), it rounds to the even integer. 3021halfway between two integers), it rounds to the even integer.
3418@end defun 3022@end defun
3419 3023
3420@defun mod* number divisor 3024@defun cl-mod number divisor
3421This function returns the same value as the second return value 3025This function returns the same value as the second return value
3422of @code{floor}. 3026of @code{cl-floor}.
3423@end defun 3027@end defun
3424 3028
3425@defun rem* number divisor 3029@defun cl-rem number divisor
3426This function returns the same value as the second return value 3030This function returns the same value as the second return value
3427of @code{truncate}. 3031of @code{cl-truncate}.
3428@end defun 3032@end defun
3429 3033
3430These definitions are compatible with those in the Quiroz
3431@file{cl.el} package, except that this package appends @samp{*}
3432to certain function names to avoid conflicts with existing
3433Emacs functions, and that the mechanism for returning
3434multiple values is different.
3435
3436@iftex
3437@secno=8
3438@end iftex
3439
3440@node Random Numbers 3034@node Random Numbers
3441@section Random Numbers 3035@section Random Numbers
3442 3036
@@ -3447,32 +3041,32 @@ algorithm, which is much more likely to give statistically clean
3447random numbers than the simple generators supplied by many 3041random numbers than the simple generators supplied by many
3448operating systems. 3042operating systems.
3449 3043
3450@defun random* number &optional state 3044@defun cl-random number &optional state
3451This function returns a random nonnegative number less than 3045This function returns a random nonnegative number less than
3452@var{number}, and of the same type (either integer or floating-point). 3046@var{number}, and of the same type (either integer or floating-point).
3453The @var{state} argument should be a @code{random-state} object 3047The @var{state} argument should be a @code{random-state} object
3454which holds the state of the random number generator. The 3048which holds the state of the random number generator. The
3455function modifies this state object as a side effect. If 3049function modifies this state object as a side effect. If
3456@var{state} is omitted, it defaults to the variable 3050@var{state} is omitted, it defaults to the variable
3457@code{*random-state*}, which contains a pre-initialized 3051@code{cl--random-state}, which contains a pre-initialized
3458@code{random-state} object. 3052@code{random-state} object.
3459@end defun 3053@end defun
3460 3054
3461@defvar *random-state* 3055@defvar cl--random-state
3462This variable contains the system ``default'' @code{random-state} 3056This variable contains the system ``default'' @code{random-state}
3463object, used for calls to @code{random*} that do not specify an 3057object, used for calls to @code{cl-random} that do not specify an
3464alternative state object. Since any number of programs in the 3058alternative state object. Since any number of programs in the
3465Emacs process may be accessing @code{*random-state*} in interleaved 3059Emacs process may be accessing @code{cl--random-state} in interleaved
3466fashion, the sequence generated from this variable will be 3060fashion, the sequence generated from this variable will be
3467irreproducible for all intents and purposes. 3061irreproducible for all intents and purposes.
3468@end defvar 3062@end defvar
3469 3063
3470@defun make-random-state &optional state 3064@defun cl-make-random-state &optional state
3471This function creates or copies a @code{random-state} object. 3065This function creates or copies a @code{random-state} object.
3472If @var{state} is omitted or @code{nil}, it returns a new copy of 3066If @var{state} is omitted or @code{nil}, it returns a new copy of
3473@code{*random-state*}. This is a copy in the sense that future 3067@code{cl--random-state}. This is a copy in the sense that future
3474sequences of calls to @code{(random* @var{n})} and 3068sequences of calls to @code{(cl-random @var{n})} and
3475@code{(random* @var{n} @var{s})} (where @var{s} is the new 3069@code{(cl-random @var{n} @var{s})} (where @var{s} is the new
3476random-state object) will return identical sequences of random 3070random-state object) will return identical sequences of random
3477numbers. 3071numbers.
3478 3072
@@ -3487,13 +3081,13 @@ different sequence of random numbers.
3487It is valid to print a @code{random-state} object to a buffer or 3081It is valid to print a @code{random-state} object to a buffer or
3488file and later read it back with @code{read}. If a program wishes 3082file and later read it back with @code{read}. If a program wishes
3489to use a sequence of pseudo-random numbers which can be reproduced 3083to use a sequence of pseudo-random numbers which can be reproduced
3490later for debugging, it can call @code{(make-random-state t)} to 3084later for debugging, it can call @code{(cl-make-random-state t)} to
3491get a new sequence, then print this sequence to a file. When the 3085get a new sequence, then print this sequence to a file. When the
3492program is later rerun, it can read the original run's random-state 3086program is later rerun, it can read the original run's random-state
3493from the file. 3087from the file.
3494@end defun 3088@end defun
3495 3089
3496@defun random-state-p object 3090@defun cl-random-state-p object
3497This predicate returns @code{t} if @var{object} is a 3091This predicate returns @code{t} if @var{object} is a
3498@code{random-state} object, or @code{nil} otherwise. 3092@code{random-state} object, or @code{nil} otherwise.
3499@end defun 3093@end defun
@@ -3512,7 +3106,7 @@ function that must be called before the parameters can be used.
3512 3106
3513@defun cl-float-limits 3107@defun cl-float-limits
3514This function makes sure that the Common Lisp floating-point parameters 3108This function makes sure that the Common Lisp floating-point parameters
3515like @code{most-positive-float} have been initialized. Until it is 3109like @code{cl-most-positive-float} have been initialized. Until it is
3516called, these parameters will be @code{nil}. If this version of Emacs 3110called, these parameters will be @code{nil}. If this version of Emacs
3517does not support floats, the parameters will remain @code{nil}. If the 3111does not support floats, the parameters will remain @code{nil}. If the
3518parameters have already been initialized, the function returns 3112parameters have already been initialized, the function returns
@@ -3530,50 +3124,50 @@ precisions, it has families of constants like
3530floating-point precision, so this package omits the precision word 3124floating-point precision, so this package omits the precision word
3531from the constants' names. 3125from the constants' names.
3532 3126
3533@defvar most-positive-float 3127@defvar cl-most-positive-float
3534This constant equals the largest value a Lisp float can hold. 3128This constant equals the largest value a Lisp float can hold.
3535For those systems whose arithmetic supports infinities, this is 3129For those systems whose arithmetic supports infinities, this is
3536the largest @emph{finite} value. For IEEE machines, the value 3130the largest @emph{finite} value. For IEEE machines, the value
3537is approximately @code{1.79e+308}. 3131is approximately @code{1.79e+308}.
3538@end defvar 3132@end defvar
3539 3133
3540@defvar most-negative-float 3134@defvar cl-most-negative-float
3541This constant equals the most-negative value a Lisp float can hold. 3135This constant equals the most-negative value a Lisp float can hold.
3542(It is assumed to be equal to @code{(- most-positive-float)}.) 3136(It is assumed to be equal to @code{(- cl-most-positive-float)}.)
3543@end defvar 3137@end defvar
3544 3138
3545@defvar least-positive-float 3139@defvar cl-least-positive-float
3546This constant equals the smallest Lisp float value greater than zero. 3140This constant equals the smallest Lisp float value greater than zero.
3547For IEEE machines, it is about @code{4.94e-324} if denormals are 3141For IEEE machines, it is about @code{4.94e-324} if denormals are
3548supported or @code{2.22e-308} if not. 3142supported or @code{2.22e-308} if not.
3549@end defvar 3143@end defvar
3550 3144
3551@defvar least-positive-normalized-float 3145@defvar cl-least-positive-normalized-float
3552This constant equals the smallest @emph{normalized} Lisp float greater 3146This constant equals the smallest @emph{normalized} Lisp float greater
3553than zero, i.e., the smallest value for which IEEE denormalization 3147than zero, i.e., the smallest value for which IEEE denormalization
3554will not result in a loss of precision. For IEEE machines, this 3148will not result in a loss of precision. For IEEE machines, this
3555value is about @code{2.22e-308}. For machines that do not support 3149value is about @code{2.22e-308}. For machines that do not support
3556the concept of denormalization and gradual underflow, this constant 3150the concept of denormalization and gradual underflow, this constant
3557will always equal @code{least-positive-float}. 3151will always equal @code{cl-least-positive-float}.
3558@end defvar 3152@end defvar
3559 3153
3560@defvar least-negative-float 3154@defvar cl-least-negative-float
3561This constant is the negative counterpart of @code{least-positive-float}. 3155This constant is the negative counterpart of @code{cl-least-positive-float}.
3562@end defvar 3156@end defvar
3563 3157
3564@defvar least-negative-normalized-float 3158@defvar cl-least-negative-normalized-float
3565This constant is the negative counterpart of 3159This constant is the negative counterpart of
3566@code{least-positive-normalized-float}. 3160@code{cl-least-positive-normalized-float}.
3567@end defvar 3161@end defvar
3568 3162
3569@defvar float-epsilon 3163@defvar cl-float-epsilon
3570This constant is the smallest positive Lisp float that can be added 3164This constant is the smallest positive Lisp float that can be added
3571to 1.0 to produce a distinct value. Adding a smaller number to 1.0 3165to 1.0 to produce a distinct value. Adding a smaller number to 1.0
3572will yield 1.0 again due to roundoff. For IEEE machines, epsilon 3166will yield 1.0 again due to roundoff. For IEEE machines, epsilon
3573is about @code{2.22e-16}. 3167is about @code{2.22e-16}.
3574@end defvar 3168@end defvar
3575 3169
3576@defvar float-negative-epsilon 3170@defvar cl-float-negative-epsilon
3577This is the smallest positive value that can be subtracted from 3171This is the smallest positive value that can be subtracted from
35781.0 to produce a distinct value. For IEEE machines, it is about 31721.0 to produce a distinct value. For IEEE machines, it is about
3579@code{1.11e-16}. 3173@code{1.11e-16}.
@@ -3590,10 +3184,10 @@ Emacs Lisp includes a few of these, notably @code{elt} and
3590 3184
3591@menu 3185@menu
3592* Sequence Basics:: Arguments shared by all sequence functions. 3186* Sequence Basics:: Arguments shared by all sequence functions.
3593* Mapping over Sequences:: @code{mapcar*}, @code{mapcan}, @code{map}, @code{every}, etc. 3187* Mapping over Sequences:: @code{cl-mapcar}, @code{cl-mapcan}, @code{cl-map}, @code{cl-every}, etc.
3594* Sequence Functions:: @code{subseq}, @code{remove*}, @code{substitute}, etc. 3188* Sequence Functions:: @code{cl-subseq}, @code{cl-remove}, @code{cl-substitute}, etc.
3595* Searching Sequences:: @code{find}, @code{position}, @code{count}, @code{search}, etc. 3189* Searching Sequences:: @code{cl-find}, @code{cl-position}, @code{cl-count}, @code{cl-search}, etc.
3596* Sorting Sequences:: @code{sort*}, @code{stable-sort}, @code{merge}. 3190* Sorting Sequences:: @code{cl-sort}, @code{cl-stable-sort}, @code{cl-merge}.
3597@end menu 3191@end menu
3598 3192
3599@node Sequence Basics 3193@node Sequence Basics
@@ -3607,7 +3201,7 @@ may appear in any order.
3607The @code{:key} argument should be passed either @code{nil}, or a 3201The @code{:key} argument should be passed either @code{nil}, or a
3608function of one argument. This key function is used as a filter 3202function of one argument. This key function is used as a filter
3609through which the elements of the sequence are seen; for example, 3203through which the elements of the sequence are seen; for example,
3610@code{(find x y :key 'car)} is similar to @code{(assoc* x y)}: 3204@code{(cl-find x y :key 'car)} is similar to @code{(cl-assoc x y)}:
3611It searches for an element of the list whose @code{car} equals 3205It searches for an element of the list whose @code{car} equals
3612@code{x}, rather than for an element which equals @code{x} itself. 3206@code{x}, rather than for an element which equals @code{x} itself.
3613If @code{:key} is omitted or @code{nil}, the filter is effectively 3207If @code{:key} is omitted or @code{nil}, the filter is effectively
@@ -3632,7 +3226,7 @@ and sequence elements match if the predicate returns true on them
3632(or false in the case of @code{-if-not}). For example: 3226(or false in the case of @code{-if-not}). For example:
3633 3227
3634@example 3228@example
3635(remove* 0 seq :test '=) @equiv{} (remove-if 'zerop seq) 3229(cl-remove 0 seq :test '=) @equiv{} (cl-remove-if 'zerop seq)
3636@end example 3230@end example
3637 3231
3638@noindent 3232@noindent
@@ -3662,14 +3256,14 @@ are called on various elements. Therefore, it is a bad idea to depend
3662on side effects of these functions. For example, @code{:from-end} 3256on side effects of these functions. For example, @code{:from-end}
3663may cause the sequence to be scanned actually in reverse, or it may 3257may cause the sequence to be scanned actually in reverse, or it may
3664be scanned forwards but computing a result ``as if'' it were scanned 3258be scanned forwards but computing a result ``as if'' it were scanned
3665backwards. (Some functions, like @code{mapcar*} and @code{every}, 3259backwards. (Some functions, like @code{cl-mapcar} and @code{cl-every},
3666@emph{do} specify exactly the order in which the function is called 3260@emph{do} specify exactly the order in which the function is called
3667so side effects are perfectly acceptable in those cases.) 3261so side effects are perfectly acceptable in those cases.)
3668 3262
3669Strings may contain ``text properties'' as well 3263Strings may contain ``text properties'' as well
3670as character data. Except as noted, it is undefined whether or 3264as character data. Except as noted, it is undefined whether or
3671not text properties are preserved by sequence functions. For 3265not text properties are preserved by sequence functions. For
3672example, @code{(remove* ?A @var{str})} may or may not preserve 3266example, @code{(cl-remove ?A @var{str})} may or may not preserve
3673the properties of the characters copied from @var{str} into the 3267the properties of the characters copied from @var{str} into the
3674result. 3268result.
3675 3269
@@ -3681,7 +3275,7 @@ These functions ``map'' the function you specify over the elements
3681of lists or arrays. They are all variations on the theme of the 3275of lists or arrays. They are all variations on the theme of the
3682built-in function @code{mapcar}. 3276built-in function @code{mapcar}.
3683 3277
3684@defun mapcar* function seq &rest more-seqs 3278@defun cl-mapcar function seq &rest more-seqs
3685This function calls @var{function} on successive parallel sets of 3279This function calls @var{function} on successive parallel sets of
3686elements from its argument sequences. Given a single @var{seq} 3280elements from its argument sequences. Given a single @var{seq}
3687argument it is equivalent to @code{mapcar}; given @var{n} sequences, 3281argument it is equivalent to @code{mapcar}; given @var{n} sequences,
@@ -3694,86 +3288,89 @@ is always a list.
3694 3288
3695Common Lisp's @code{mapcar} accepts multiple arguments but works 3289Common Lisp's @code{mapcar} accepts multiple arguments but works
3696only on lists; Emacs Lisp's @code{mapcar} accepts a single sequence 3290only on lists; Emacs Lisp's @code{mapcar} accepts a single sequence
3697argument. This package's @code{mapcar*} works as a compatible 3291argument. This package's @code{cl-mapcar} works as a compatible
3698superset of both. 3292superset of both.
3699@end defun 3293@end defun
3700 3294
3701@defun map result-type function seq &rest more-seqs 3295@defun cl-map result-type function seq &rest more-seqs
3702This function maps @var{function} over the argument sequences, 3296This function maps @var{function} over the argument sequences,
3703just like @code{mapcar*}, but it returns a sequence of type 3297just like @code{cl-mapcar}, but it returns a sequence of type
3704@var{result-type} rather than a list. @var{result-type} must 3298@var{result-type} rather than a list. @var{result-type} must
3705be one of the following symbols: @code{vector}, @code{string}, 3299be one of the following symbols: @code{vector}, @code{string},
3706@code{list} (in which case the effect is the same as for 3300@code{list} (in which case the effect is the same as for
3707@code{mapcar*}), or @code{nil} (in which case the results are 3301@code{cl-mapcar}), or @code{nil} (in which case the results are
3708thrown away and @code{map} returns @code{nil}). 3302thrown away and @code{cl-map} returns @code{nil}).
3709@end defun 3303@end defun
3710 3304
3711@defun maplist function list &rest more-lists 3305@defun cl-maplist function list &rest more-lists
3712This function calls @var{function} on each of its argument lists, 3306This function calls @var{function} on each of its argument lists,
3713then on the @code{cdr}s of those lists, and so on, until the 3307then on the @code{cdr}s of those lists, and so on, until the
3714shortest list runs out. The results are returned in the form 3308shortest list runs out. The results are returned in the form
3715of a list. Thus, @code{maplist} is like @code{mapcar*} except 3309of a list. Thus, @code{cl-maplist} is like @code{cl-mapcar} except
3716that it passes in the list pointers themselves rather than the 3310that it passes in the list pointers themselves rather than the
3717@code{car}s of the advancing pointers. 3311@code{car}s of the advancing pointers.
3718@end defun 3312@end defun
3719 3313
3720@defun cl-mapc function seq &rest more-seqs 3314@defun cl-mapc function seq &rest more-seqs
3721This function is like @code{mapcar*}, except that the values returned 3315This function is like @code{cl-mapcar}, except that the values returned
3722by @var{function} are ignored and thrown away rather than being 3316by @var{function} are ignored and thrown away rather than being
3723collected into a list. The return value of @code{cl-mapc} is @var{seq}, 3317collected into a list. The return value of @code{cl-mapc} is @var{seq},
3724the first sequence. This function is more general than the Emacs 3318the first sequence. This function is more general than the Emacs
3725primitive @code{mapc}. 3319primitive @code{mapc}. (Note that this function is called
3320@code{cl-mapc} even in @file{cl.el}, rather than @code{map*} as you
3321might expect.)
3322@c http://debbugs.gnu.org/6575
3726@end defun 3323@end defun
3727 3324
3728@defun mapl function list &rest more-lists 3325@defun cl-mapl function list &rest more-lists
3729This function is like @code{maplist}, except that it throws away 3326This function is like @code{cl-maplist}, except that it throws away
3730the values returned by @var{function}. 3327the values returned by @var{function}.
3731@end defun 3328@end defun
3732 3329
3733@defun mapcan function seq &rest more-seqs 3330@defun cl-mapcan function seq &rest more-seqs
3734This function is like @code{mapcar*}, except that it concatenates 3331This function is like @code{cl-mapcar}, except that it concatenates
3735the return values (which must be lists) using @code{nconc}, 3332the return values (which must be lists) using @code{nconc},
3736rather than simply collecting them into a list. 3333rather than simply collecting them into a list.
3737@end defun 3334@end defun
3738 3335
3739@defun mapcon function list &rest more-lists 3336@defun cl-mapcon function list &rest more-lists
3740This function is like @code{maplist}, except that it concatenates 3337This function is like @code{cl-maplist}, except that it concatenates
3741the return values using @code{nconc}. 3338the return values using @code{nconc}.
3742@end defun 3339@end defun
3743 3340
3744@defun some predicate seq &rest more-seqs 3341@defun cl-some predicate seq &rest more-seqs
3745This function calls @var{predicate} on each element of @var{seq} 3342This function calls @var{predicate} on each element of @var{seq}
3746in turn; if @var{predicate} returns a non-@code{nil} value, 3343in turn; if @var{predicate} returns a non-@code{nil} value,
3747@code{some} returns that value, otherwise it returns @code{nil}. 3344@code{some} returns that value, otherwise it returns @code{nil}.
3748Given several sequence arguments, it steps through the sequences 3345Given several sequence arguments, it steps through the sequences
3749in parallel until the shortest one runs out, just as in 3346in parallel until the shortest one runs out, just as in
3750@code{mapcar*}. You can rely on the left-to-right order in which 3347@code{cl-mapcar}. You can rely on the left-to-right order in which
3751the elements are visited, and on the fact that mapping stops 3348the elements are visited, and on the fact that mapping stops
3752immediately as soon as @var{predicate} returns non-@code{nil}. 3349immediately as soon as @var{predicate} returns non-@code{nil}.
3753@end defun 3350@end defun
3754 3351
3755@defun every predicate seq &rest more-seqs 3352@defun cl-every predicate seq &rest more-seqs
3756This function calls @var{predicate} on each element of the sequence(s) 3353This function calls @var{predicate} on each element of the sequence(s)
3757in turn; it returns @code{nil} as soon as @var{predicate} returns 3354in turn; it returns @code{nil} as soon as @var{predicate} returns
3758@code{nil} for any element, or @code{t} if the predicate was true 3355@code{nil} for any element, or @code{t} if the predicate was true
3759for all elements. 3356for all elements.
3760@end defun 3357@end defun
3761 3358
3762@defun notany predicate seq &rest more-seqs 3359@defun cl-notany predicate seq &rest more-seqs
3763This function calls @var{predicate} on each element of the sequence(s) 3360This function calls @var{predicate} on each element of the sequence(s)
3764in turn; it returns @code{nil} as soon as @var{predicate} returns 3361in turn; it returns @code{nil} as soon as @var{predicate} returns
3765a non-@code{nil} value for any element, or @code{t} if the predicate 3362a non-@code{nil} value for any element, or @code{t} if the predicate
3766was @code{nil} for all elements. 3363was @code{nil} for all elements.
3767@end defun 3364@end defun
3768 3365
3769@defun notevery predicate seq &rest more-seqs 3366@defun cl-notevery predicate seq &rest more-seqs
3770This function calls @var{predicate} on each element of the sequence(s) 3367This function calls @var{predicate} on each element of the sequence(s)
3771in turn; it returns a non-@code{nil} value as soon as @var{predicate} 3368in turn; it returns a non-@code{nil} value as soon as @var{predicate}
3772returns @code{nil} for any element, or @code{t} if the predicate was 3369returns @code{nil} for any element, or @code{t} if the predicate was
3773true for all elements. 3370true for all elements.
3774@end defun 3371@end defun
3775 3372
3776@defun reduce function seq @t{&key :from-end :start :end :initial-value :key} 3373@defun cl-reduce function seq @t{&key :from-end :start :end :initial-value :key}
3777This function combines the elements of @var{seq} using an associative 3374This function combines the elements of @var{seq} using an associative
3778binary operation. Suppose @var{function} is @code{*} and @var{seq} is 3375binary operation. Suppose @var{function} is @code{*} and @var{seq} is
3779the list @code{(2 3 4 5)}. The first two elements of the list are 3376the list @code{(2 3 4 5)}. The first two elements of the list are
@@ -3781,16 +3378,16 @@ combined with @code{(* 2 3) = 6}; this is combined with the next
3781element, @code{(* 6 4) = 24}, and that is combined with the final 3378element, @code{(* 6 4) = 24}, and that is combined with the final
3782element: @code{(* 24 5) = 120}. Note that the @code{*} function happens 3379element: @code{(* 24 5) = 120}. Note that the @code{*} function happens
3783to be self-reducing, so that @code{(* 2 3 4 5)} has the same effect as 3380to be self-reducing, so that @code{(* 2 3 4 5)} has the same effect as
3784an explicit call to @code{reduce}. 3381an explicit call to @code{cl-reduce}.
3785 3382
3786If @code{:from-end} is true, the reduction is right-associative instead 3383If @code{:from-end} is true, the reduction is right-associative instead
3787of left-associative: 3384of left-associative:
3788 3385
3789@example 3386@example
3790(reduce '- '(1 2 3 4)) 3387(cl-reduce '- '(1 2 3 4))
3791 @equiv{} (- (- (- 1 2) 3) 4) @result{} -8 3388 @equiv{} (- (- (- 1 2) 3) 4) @result{} -8
3792(reduce '- '(1 2 3 4) :from-end t) 3389(cl-reduce '- '(1 2 3 4) :from-end t)
3793 @equiv{} (- 1 (- 2 (- 3 4))) @result{} -2 3390 @equiv{} (- 1 (- 2 (- 3 4))) @result{} -2
3794@end example 3391@end example
3795 3392
3796If @code{:key} is specified, it is a function of one argument which 3393If @code{:key} is specified, it is a function of one argument which
@@ -3807,7 +3404,7 @@ If the sequence is empty (and there is no initial value), then
3807@end defun 3404@end defun
3808 3405
3809All of these mapping operations can be expressed conveniently in 3406All of these mapping operations can be expressed conveniently in
3810terms of the @code{loop} macro. In compiled code, @code{loop} will 3407terms of the @code{cl-loop} macro. In compiled code, @code{cl-loop} will
3811be faster since it generates the loop as in-line code with no 3408be faster since it generates the loop as in-line code with no
3812function calls. 3409function calls.
3813 3410
@@ -3818,7 +3415,7 @@ function calls.
3818This section describes a number of Common Lisp functions for 3415This section describes a number of Common Lisp functions for
3819operating on sequences. 3416operating on sequences.
3820 3417
3821@defun subseq sequence start &optional end 3418@defun cl-subseq sequence start &optional end
3822This function returns a given subsequence of the argument 3419This function returns a given subsequence of the argument
3823@var{sequence}, which may be a list, string, or vector. 3420@var{sequence}, which may be a list, string, or vector.
3824The indices @var{start} and @var{end} must be in range, and 3421The indices @var{start} and @var{end} must be in range, and
@@ -3830,30 +3427,30 @@ with @var{sequence}.
3830As an extension to Common Lisp, @var{start} and/or @var{end} 3427As an extension to Common Lisp, @var{start} and/or @var{end}
3831may be negative, in which case they represent a distance back 3428may be negative, in which case they represent a distance back
3832from the end of the sequence. This is for compatibility with 3429from the end of the sequence. This is for compatibility with
3833Emacs's @code{substring} function. Note that @code{subseq} is 3430Emacs's @code{substring} function. Note that @code{cl-subseq} is
3834the @emph{only} sequence function that allows negative 3431the @emph{only} sequence function that allows negative
3835@var{start} and @var{end}. 3432@var{start} and @var{end}.
3836 3433
3837You can use @code{setf} on a @code{subseq} form to replace a 3434You can use @code{setf} on a @code{cl-subseq} form to replace a
3838specified range of elements with elements from another sequence. 3435specified range of elements with elements from another sequence.
3839The replacement is done as if by @code{replace}, described below. 3436The replacement is done as if by @code{cl-replace}, described below.
3840@end defun 3437@end defun
3841 3438
3842@defun concatenate result-type &rest seqs 3439@defun cl-concatenate result-type &rest seqs
3843This function concatenates the argument sequences together to 3440This function concatenates the argument sequences together to
3844form a result sequence of type @var{result-type}, one of the 3441form a result sequence of type @var{result-type}, one of the
3845symbols @code{vector}, @code{string}, or @code{list}. The 3442symbols @code{vector}, @code{string}, or @code{list}. The
3846arguments are always copied, even in cases such as 3443arguments are always copied, even in cases such as
3847@code{(concatenate 'list '(1 2 3))} where the result is 3444@code{(cl-concatenate 'list '(1 2 3))} where the result is
3848identical to an argument. 3445identical to an argument.
3849@end defun 3446@end defun
3850 3447
3851@defun fill seq item @t{&key :start :end} 3448@defun cl-fill seq item @t{&key :start :end}
3852This function fills the elements of the sequence (or the specified 3449This function fills the elements of the sequence (or the specified
3853part of the sequence) with the value @var{item}. 3450part of the sequence) with the value @var{item}.
3854@end defun 3451@end defun
3855 3452
3856@defun replace seq1 seq2 @t{&key :start1 :end1 :start2 :end2} 3453@defun cl-replace seq1 seq2 @t{&key :start1 :end1 :start2 :end2}
3857This function copies part of @var{seq2} into part of @var{seq1}. 3454This function copies part of @var{seq2} into part of @var{seq1}.
3858The sequence @var{seq1} is not stretched or resized; the amount 3455The sequence @var{seq1} is not stretched or resized; the amount
3859of data copied is simply the shorter of the source and destination 3456of data copied is simply the shorter of the source and destination
@@ -3867,7 +3464,7 @@ start and end arguments specify overlapping regions, the effect
3867is undefined. 3464is undefined.
3868@end defun 3465@end defun
3869 3466
3870@defun remove* item seq @t{&key :test :test-not :key :count :start :end :from-end} 3467@defun cl-remove item seq @t{&key :test :test-not :key :count :start :end :from-end}
3871This returns a copy of @var{seq} with all elements matching 3468This returns a copy of @var{seq} with all elements matching
3872@var{item} removed. The result may share storage with or be 3469@var{item} removed. The result may share storage with or be
3873@code{eq} to @var{seq} in some circumstances, but the original 3470@code{eq} to @var{seq} in some circumstances, but the original
@@ -3884,25 +3481,25 @@ end of the sequence rather than the beginning (this matters only
3884if @var{count} was also specified). 3481if @var{count} was also specified).
3885@end defun 3482@end defun
3886 3483
3887@defun delete* item seq @t{&key :test :test-not :key :count :start :end :from-end} 3484@defun cl-delete item seq @t{&key :test :test-not :key :count :start :end :from-end}
3888This deletes all elements of @var{seq} which match @var{item}. 3485This deletes all elements of @var{seq} which match @var{item}.
3889It is a destructive operation. Since Emacs Lisp does not support 3486It is a destructive operation. Since Emacs Lisp does not support
3890stretchable strings or vectors, this is the same as @code{remove*} 3487stretchable strings or vectors, this is the same as @code{cl-remove}
3891for those sequence types. On lists, @code{remove*} will copy the 3488for those sequence types. On lists, @code{cl-remove} will copy the
3892list if necessary to preserve the original list, whereas 3489list if necessary to preserve the original list, whereas
3893@code{delete*} will splice out parts of the argument list. 3490@code{cl-delete} will splice out parts of the argument list.
3894Compare @code{append} and @code{nconc}, which are analogous 3491Compare @code{append} and @code{nconc}, which are analogous
3895non-destructive and destructive list operations in Emacs Lisp. 3492non-destructive and destructive list operations in Emacs Lisp.
3896@end defun 3493@end defun
3897 3494
3898@findex remove-if 3495@findex cl-remove-if
3899@findex remove-if-not 3496@findex cl-remove-if-not
3900@findex delete-if 3497@findex cl-delete-if
3901@findex delete-if-not 3498@findex cl-delete-if-not
3902The predicate-oriented functions @code{remove-if}, @code{remove-if-not}, 3499The predicate-oriented functions @code{cl-remove-if}, @code{cl-remove-if-not},
3903@code{delete-if}, and @code{delete-if-not} are defined similarly. 3500@code{cl-delete-if}, and @code{cl-delete-if-not} are defined similarly.
3904 3501
3905@defun remove-duplicates seq @t{&key :test :test-not :key :start :end :from-end} 3502@defun cl-remove-duplicates seq @t{&key :test :test-not :key :start :end :from-end}
3906This function returns a copy of @var{seq} with duplicate elements 3503This function returns a copy of @var{seq} with duplicate elements
3907removed. Specifically, if two elements from the sequence match 3504removed. Specifically, if two elements from the sequence match
3908according to the @code{:test}, @code{:test-not}, and @code{:key} 3505according to the @code{:test}, @code{:test-not}, and @code{:key}
@@ -3912,40 +3509,41 @@ is true, the leftmost one is retained instead. If @code{:start} or
3912examined or removed. 3509examined or removed.
3913@end defun 3510@end defun
3914 3511
3915@defun delete-duplicates seq @t{&key :test :test-not :key :start :end :from-end} 3512@defun cl-delete-duplicates seq @t{&key :test :test-not :key :start :end :from-end}
3916This function deletes duplicate elements from @var{seq}. It is 3513This function deletes duplicate elements from @var{seq}. It is
3917a destructive version of @code{remove-duplicates}. 3514a destructive version of @code{cl-remove-duplicates}.
3918@end defun 3515@end defun
3919 3516
3920@defun substitute new old seq @t{&key :test :test-not :key :count :start :end :from-end} 3517@defun cl-substitute new old seq @t{&key :test :test-not :key :count :start :end :from-end}
3921This function returns a copy of @var{seq}, with all elements 3518This function returns a copy of @var{seq}, with all elements
3922matching @var{old} replaced with @var{new}. The @code{:count}, 3519matching @var{old} replaced with @var{new}. The @code{:count},
3923@code{:start}, @code{:end}, and @code{:from-end} arguments may be 3520@code{:start}, @code{:end}, and @code{:from-end} arguments may be
3924used to limit the number of substitutions made. 3521used to limit the number of substitutions made.
3925@end defun 3522@end defun
3926 3523
3927@defun nsubstitute new old seq @t{&key :test :test-not :key :count :start :end :from-end} 3524@defun cl-nsubstitute new old seq @t{&key :test :test-not :key :count :start :end :from-end}
3928This is a destructive version of @code{substitute}; it performs 3525This is a destructive version of @code{cl-substitute}; it performs
3929the substitution using @code{setcar} or @code{aset} rather than 3526the substitution using @code{setcar} or @code{aset} rather than
3930by returning a changed copy of the sequence. 3527by returning a changed copy of the sequence.
3931@end defun 3528@end defun
3932 3529
3933@findex substitute-if 3530@findex cl-substitute-if
3934@findex substitute-if-not 3531@findex cl-substitute-if-not
3935@findex nsubstitute-if 3532@findex cl-nsubstitute-if
3936@findex nsubstitute-if-not 3533@findex cl-nsubstitute-if-not
3937The @code{substitute-if}, @code{substitute-if-not}, @code{nsubstitute-if}, 3534The functions @code{cl-substitute-if}, @code{cl-substitute-if-not},
3938and @code{nsubstitute-if-not} functions are defined similarly. For 3535@code{cl-nsubstitute-if}, and @code{cl-nsubstitute-if-not} are defined
3939these, a @var{predicate} is given in place of the @var{old} argument. 3536similarly. For these, a @var{predicate} is given in place of the
3537@var{old} argument.
3940 3538
3941@node Searching Sequences 3539@node Searching Sequences
3942@section Searching Sequences 3540@section Searching Sequences
3943 3541
3944@noindent 3542@noindent
3945These functions search for elements or subsequences in a sequence. 3543These functions search for elements or subsequences in a sequence.
3946(See also @code{member*} and @code{assoc*}; @pxref{Lists}.) 3544(See also @code{cl-member} and @code{cl-assoc}; @pxref{Lists}.)
3947 3545
3948@defun find item seq @t{&key :test :test-not :key :start :end :from-end} 3546@defun cl-find item seq @t{&key :test :test-not :key :start :end :from-end}
3949This function searches @var{seq} for an element matching @var{item}. 3547This function searches @var{seq} for an element matching @var{item}.
3950If it finds a match, it returns the matching element. Otherwise, 3548If it finds a match, it returns the matching element. Otherwise,
3951it returns @code{nil}. It returns the leftmost match, unless 3549it returns @code{nil}. It returns the leftmost match, unless
@@ -3954,30 +3552,30 @@ match. The @code{:start} and @code{:end} arguments may be used to
3954limit the range of elements that are searched. 3552limit the range of elements that are searched.
3955@end defun 3553@end defun
3956 3554
3957@defun position item seq @t{&key :test :test-not :key :start :end :from-end} 3555@defun cl-position item seq @t{&key :test :test-not :key :start :end :from-end}
3958This function is like @code{find}, except that it returns the 3556This function is like @code{cl-find}, except that it returns the
3959integer position in the sequence of the matching item rather than 3557integer position in the sequence of the matching item rather than
3960the item itself. The position is relative to the start of the 3558the item itself. The position is relative to the start of the
3961sequence as a whole, even if @code{:start} is non-zero. The function 3559sequence as a whole, even if @code{:start} is non-zero. The function
3962returns @code{nil} if no matching element was found. 3560returns @code{nil} if no matching element was found.
3963@end defun 3561@end defun
3964 3562
3965@defun count item seq @t{&key :test :test-not :key :start :end} 3563@defun cl-count item seq @t{&key :test :test-not :key :start :end}
3966This function returns the number of elements of @var{seq} which 3564This function returns the number of elements of @var{seq} which
3967match @var{item}. The result is always a nonnegative integer. 3565match @var{item}. The result is always a nonnegative integer.
3968@end defun 3566@end defun
3969 3567
3970@findex find-if 3568@findex cl-find-if
3971@findex find-if-not 3569@findex cl-find-if-not
3972@findex position-if 3570@findex cl-position-if
3973@findex position-if-not 3571@findex cl-position-if-not
3974@findex count-if 3572@findex cl-count-if
3975@findex count-if-not 3573@findex cl-count-if-not
3976The @code{find-if}, @code{find-if-not}, @code{position-if}, 3574The @code{cl-find-if}, @code{cl-find-if-not}, @code{cl-position-if},
3977@code{position-if-not}, @code{count-if}, and @code{count-if-not} 3575@code{cl-position-if-not}, @code{cl-count-if}, and @code{cl-count-if-not}
3978functions are defined similarly. 3576functions are defined similarly.
3979 3577
3980@defun mismatch seq1 seq2 @t{&key :test :test-not :key :start1 :end1 :start2 :end2 :from-end} 3578@defun cl-mismatch seq1 seq2 @t{&key :test :test-not :key :start1 :end1 :start2 :end2 :from-end}
3981This function compares the specified parts of @var{seq1} and 3579This function compares the specified parts of @var{seq1} and
3982@var{seq2}. If they are the same length and the corresponding 3580@var{seq2}. If they are the same length and the corresponding
3983elements match (according to @code{:test}, @code{:test-not}, 3581elements match (according to @code{:test}, @code{:test-not},
@@ -3992,11 +3590,11 @@ to left starting at @code{(1- @var{end1})} and @code{(1- @var{end2})}.
3992If the sequences differ, then one plus the index of the rightmost 3590If the sequences differ, then one plus the index of the rightmost
3993difference (relative to @var{seq1}) is returned. 3591difference (relative to @var{seq1}) is returned.
3994 3592
3995An interesting example is @code{(mismatch str1 str2 :key 'upcase)}, 3593An interesting example is @code{(cl-mismatch str1 str2 :key 'upcase)},
3996which compares two strings case-insensitively. 3594which compares two strings case-insensitively.
3997@end defun 3595@end defun
3998 3596
3999@defun search seq1 seq2 @t{&key :test :test-not :key :from-end :start1 :end1 :start2 :end2} 3597@defun cl-search seq1 seq2 @t{&key :test :test-not :key :from-end :start1 :end1 :start2 :end2}
4000This function searches @var{seq2} for a subsequence that matches 3598This function searches @var{seq2} for a subsequence that matches
4001@var{seq1} (or part of it specified by @code{:start1} and 3599@var{seq1} (or part of it specified by @code{:start1} and
4002@code{:end1}.) Only matches which fall entirely within the region 3600@code{:end1}.) Only matches which fall entirely within the region
@@ -4010,7 +3608,7 @@ function finds the @emph{rightmost} matching subsequence.
4010@node Sorting Sequences 3608@node Sorting Sequences
4011@section Sorting Sequences 3609@section Sorting Sequences
4012 3610
4013@defun sort* seq predicate @t{&key :key} 3611@defun clsort seq predicate @t{&key :key}
4014This function sorts @var{seq} into increasing order as determined 3612This function sorts @var{seq} into increasing order as determined
4015by using @var{predicate} to compare pairs of elements. @var{predicate} 3613by using @var{predicate} to compare pairs of elements. @var{predicate}
4016should return true (non-@code{nil}) if and only if its first argument 3614should return true (non-@code{nil}) if and only if its first argument
@@ -4025,7 +3623,7 @@ accepts a @code{:key} argument which is used to preprocess data
4025fed to the @var{predicate} function. For example, 3623fed to the @var{predicate} function. For example,
4026 3624
4027@example 3625@example
4028(setq data (sort* data 'string-lessp :key 'downcase)) 3626(setq data (cl-sort data 'string-lessp :key 'downcase))
4029@end example 3627@end example
4030 3628
4031@noindent 3629@noindent
@@ -4035,25 +3633,25 @@ would be useful for sorting association lists. It should only be a
4035simple accessor though, it's used heavily in the current 3633simple accessor though, it's used heavily in the current
4036implementation. 3634implementation.
4037 3635
4038The @code{sort*} function is destructive; it sorts lists by actually 3636The @code{cl-sort} function is destructive; it sorts lists by actually
4039rearranging the @code{cdr} pointers in suitable fashion. 3637rearranging the @code{cdr} pointers in suitable fashion.
4040@end defun 3638@end defun
4041 3639
4042@defun stable-sort seq predicate @t{&key :key} 3640@defun cl-stable-sort seq predicate @t{&key :key}
4043This function sorts @var{seq} @dfn{stably}, meaning two elements 3641This function sorts @var{seq} @dfn{stably}, meaning two elements
4044which are equal in terms of @var{predicate} are guaranteed not to 3642which are equal in terms of @var{predicate} are guaranteed not to
4045be rearranged out of their original order by the sort. 3643be rearranged out of their original order by the sort.
4046 3644
4047In practice, @code{sort*} and @code{stable-sort} are equivalent 3645In practice, @code{cl-sort} and @code{cl-stable-sort} are equivalent
4048in Emacs Lisp because the underlying @code{sort} function is 3646in Emacs Lisp because the underlying @code{sort} function is
4049stable by default. However, this package reserves the right to 3647stable by default. However, this package reserves the right to
4050use non-stable methods for @code{sort*} in the future. 3648use non-stable methods for @code{cl-sort} in the future.
4051@end defun 3649@end defun
4052 3650
4053@defun merge type seq1 seq2 predicate @t{&key :key} 3651@defun cl-merge type seq1 seq2 predicate @t{&key :key}
4054This function merges two sequences @var{seq1} and @var{seq2} by 3652This function merges two sequences @var{seq1} and @var{seq2} by
4055interleaving their elements. The result sequence, of type @var{type} 3653interleaving their elements. The result sequence, of type @var{type}
4056(in the sense of @code{concatenate}), has length equal to the sum 3654(in the sense of @code{cl-concatenate}), has length equal to the sum
4057of the lengths of the two input sequences. The sequences may be 3655of the lengths of the two input sequences. The sequences may be
4058modified destructively. Order of elements within @var{seq1} and 3656modified destructively. Order of elements within @var{seq1} and
4059@var{seq2} is preserved in the interleaving; elements of the two 3657@var{seq2} is preserved in the interleaving; elements of the two
@@ -4073,10 +3671,10 @@ a merged sequence which is (stably) sorted according to
4073The functions described here operate on lists. 3671The functions described here operate on lists.
4074 3672
4075@menu 3673@menu
4076* List Functions:: @code{caddr}, @code{first}, @code{list*}, etc. 3674* List Functions:: @code{cl-caddr}, @code{cl-first}, @code{cl-list*}, etc.
4077* Substitution of Expressions:: @code{subst}, @code{sublis}, etc. 3675* Substitution of Expressions:: @code{cl-subst}, @code{cl-sublis}, etc.
4078* Lists as Sets:: @code{member*}, @code{adjoin}, @code{union}, etc. 3676* Lists as Sets:: @code{cl-member}, @code{cl-adjoin}, @code{cl-union}, etc.
4079* Association Lists:: @code{assoc*}, @code{rassoc*}, @code{acons}, @code{pairlis}. 3677* Association Lists:: @code{cl-assoc}, @code{cl-rassoc}, @code{cl-acons}, @code{cl-pairlis}.
4080@end menu 3678@end menu
4081 3679
4082@node List Functions 3680@node List Functions
@@ -4086,7 +3684,7 @@ The functions described here operate on lists.
4086This section describes a number of simple operations on lists, 3684This section describes a number of simple operations on lists,
4087i.e., chains of cons cells. 3685i.e., chains of cons cells.
4088 3686
4089@defun caddr x 3687@defun cl-caddr x
4090This function is equivalent to @code{(car (cdr (cdr @var{x})))}. 3688This function is equivalent to @code{(car (cdr (cdr @var{x})))}.
4091Likewise, this package defines all 28 @code{c@var{xxx}r} functions 3689Likewise, this package defines all 28 @code{c@var{xxx}r} functions
4092where @var{xxx} is up to four @samp{a}s and/or @samp{d}s. 3690where @var{xxx} is up to four @samp{a}s and/or @samp{d}s.
@@ -4094,24 +3692,24 @@ All of these functions are @code{setf}-able, and calls to them
4094are expanded inline by the byte-compiler for maximum efficiency. 3692are expanded inline by the byte-compiler for maximum efficiency.
4095@end defun 3693@end defun
4096 3694
4097@defun first x 3695@defun cl-first x
4098This function is a synonym for @code{(car @var{x})}. Likewise, 3696This function is a synonym for @code{(car @var{x})}. Likewise,
4099the functions @code{second}, @code{third}, @dots{}, through 3697the functions @code{cl-second}, @code{cl-third}, @dots{}, through
4100@code{tenth} return the given element of the list @var{x}. 3698@code{cl-tenth} return the given element of the list @var{x}.
4101@end defun 3699@end defun
4102 3700
4103@defun rest x 3701@defun cl-rest x
4104This function is a synonym for @code{(cdr @var{x})}. 3702This function is a synonym for @code{(cdr @var{x})}.
4105@end defun 3703@end defun
4106 3704
4107@defun endp x 3705@defun cl-endp x
4108Common Lisp defines this function to act like @code{null}, but 3706Common Lisp defines this function to act like @code{null}, but
4109signaling an error if @code{x} is neither a @code{nil} nor a 3707signaling an error if @code{x} is neither a @code{nil} nor a
4110cons cell. This package simply defines @code{endp} as a synonym 3708cons cell. This package simply defines @code{cl-endp} as a synonym
4111for @code{null}. 3709for @code{null}.
4112@end defun 3710@end defun
4113 3711
4114@defun list-length x 3712@defun cl-list-length x
4115This function returns the length of list @var{x}, exactly like 3713This function returns the length of list @var{x}, exactly like
4116@code{(length @var{x})}, except that if @var{x} is a circular 3714@code{(length @var{x})}, except that if @var{x} is a circular
4117list (where the cdr-chain forms a loop rather than terminating 3715list (where the cdr-chain forms a loop rather than terminating
@@ -4119,38 +3717,35 @@ with @code{nil}), this function returns @code{nil}. (The regular
4119@code{length} function would get stuck if given a circular list.) 3717@code{length} function would get stuck if given a circular list.)
4120@end defun 3718@end defun
4121 3719
4122@defun list* arg &rest others 3720@defun cl-list* arg &rest others
4123This function constructs a list of its arguments. The final 3721This function constructs a list of its arguments. The final
4124argument becomes the @code{cdr} of the last cell constructed. 3722argument becomes the @code{cdr} of the last cell constructed.
4125Thus, @code{(list* @var{a} @var{b} @var{c})} is equivalent to 3723Thus, @code{(cl-list* @var{a} @var{b} @var{c})} is equivalent to
4126@code{(cons @var{a} (cons @var{b} @var{c}))}, and 3724@code{(cons @var{a} (cons @var{b} @var{c}))}, and
4127@code{(list* @var{a} @var{b} nil)} is equivalent to 3725@code{(cl-list* @var{a} @var{b} nil)} is equivalent to
4128@code{(list @var{a} @var{b})}. 3726@code{(list @var{a} @var{b})}.
4129
4130(Note that this function really is called @code{list*} in Common
4131Lisp; it is not a name invented for this package like @code{member*}
4132or @code{defun*}.)
4133@end defun 3727@end defun
4134 3728
4135@defun ldiff list sublist 3729@defun cl-ldiff list sublist
4136If @var{sublist} is a sublist of @var{list}, i.e., is @code{eq} to 3730If @var{sublist} is a sublist of @var{list}, i.e., is @code{eq} to
4137one of the cons cells of @var{list}, then this function returns 3731one of the cons cells of @var{list}, then this function returns
4138a copy of the part of @var{list} up to but not including 3732a copy of the part of @var{list} up to but not including
4139@var{sublist}. For example, @code{(ldiff x (cddr x))} returns 3733@var{sublist}. For example, @code{(cl-ldiff x (cddr x))} returns
4140the first two elements of the list @code{x}. The result is a 3734the first two elements of the list @code{x}. The result is a
4141copy; the original @var{list} is not modified. If @var{sublist} 3735copy; the original @var{list} is not modified. If @var{sublist}
4142is not a sublist of @var{list}, a copy of the entire @var{list} 3736is not a sublist of @var{list}, a copy of the entire @var{list}
4143is returned. 3737is returned.
4144@end defun 3738@end defun
4145 3739
4146@defun copy-list list 3740@defun cl-copy-list list
4147This function returns a copy of the list @var{list}. It copies 3741This function returns a copy of the list @var{list}. It copies
4148dotted lists like @code{(1 2 . 3)} correctly. 3742dotted lists like @code{(1 2 . 3)} correctly.
4149@end defun 3743@end defun
4150 3744
4151@defun copy-tree x &optional vecp 3745@defun copy-tree x &optional vecp
4152This function returns a copy of the tree of cons cells @var{x}. 3746This function returns a copy of the tree of cons cells @var{x}.
4153Unlike @code{copy-sequence} (and its alias @code{copy-list}), 3747@c FIXME? cl-copy-list is not an alias of copy-sequence.
3748Unlike @code{copy-sequence} (and its alias @code{cl-copy-list}),
4154which copies only along the @code{cdr} direction, this function 3749which copies only along the @code{cdr} direction, this function
4155copies (recursively) along both the @code{car} and the @code{cdr} 3750copies (recursively) along both the @code{car} and the @code{cdr}
4156directions. If @var{x} is not a cons cell, the function simply 3751directions. If @var{x} is not a cons cell, the function simply
@@ -4159,7 +3754,7 @@ is true, this function copies vectors (recursively) as well as
4159cons cells. 3754cons cells.
4160@end defun 3755@end defun
4161 3756
4162@defun tree-equal x y @t{&key :test :test-not :key} 3757@defun cl-tree-equal x y @t{&key :test :test-not :key}
4163This function compares two trees of cons cells. If @var{x} and 3758This function compares two trees of cons cells. If @var{x} and
4164@var{y} are both cons cells, their @code{car}s and @code{cdr}s are 3759@var{y} are both cons cells, their @code{car}s and @code{cdr}s are
4165compared recursively. If neither @var{x} nor @var{y} is a cons 3760compared recursively. If neither @var{x} nor @var{y} is a cons
@@ -4168,19 +3763,15 @@ specified test. The @code{:key} function, if specified, is
4168applied to the elements of both trees. @xref{Sequences}. 3763applied to the elements of both trees. @xref{Sequences}.
4169@end defun 3764@end defun
4170 3765
4171@iftex
4172@secno=3
4173@end iftex
4174
4175@node Substitution of Expressions 3766@node Substitution of Expressions
4176@section Substitution of Expressions 3767@section Substitution of Expressions
4177 3768
4178@noindent 3769@noindent
4179These functions substitute elements throughout a tree of cons 3770These functions substitute elements throughout a tree of cons
4180cells. (@xref{Sequence Functions}, for the @code{substitute} 3771cells. (@xref{Sequence Functions}, for the @code{cl-substitute}
4181function, which works on just the top-level elements of a list.) 3772function, which works on just the top-level elements of a list.)
4182 3773
4183@defun subst new old tree @t{&key :test :test-not :key} 3774@defun cl-subst new old tree @t{&key :test :test-not :key}
4184This function substitutes occurrences of @var{old} with @var{new} 3775This function substitutes occurrences of @var{old} with @var{new}
4185in @var{tree}, a tree of cons cells. It returns a substituted 3776in @var{tree}, a tree of cons cells. It returns a substituted
4186tree, which will be a copy except that it may share storage with 3777tree, which will be a copy except that it may share storage with
@@ -4195,21 +3786,21 @@ The @code{:key} function is applied to the elements of the tree
4195but not to @var{old}. 3786but not to @var{old}.
4196@end defun 3787@end defun
4197 3788
4198@defun nsubst new old tree @t{&key :test :test-not :key} 3789@defun cl-nsubst new old tree @t{&key :test :test-not :key}
4199This function is like @code{subst}, except that it works by 3790This function is like @code{cl-subst}, except that it works by
4200destructive modification (by @code{setcar} or @code{setcdr}) 3791destructive modification (by @code{setcar} or @code{setcdr})
4201rather than copying. 3792rather than copying.
4202@end defun 3793@end defun
4203 3794
4204@findex subst-if 3795@findex cl-subst-if
4205@findex subst-if-not 3796@findex cl-subst-if-not
4206@findex nsubst-if 3797@findex cl-nsubst-if
4207@findex nsubst-if-not 3798@findex cl-nsubst-if-not
4208The @code{subst-if}, @code{subst-if-not}, @code{nsubst-if}, and 3799The @code{cl-subst-if}, @code{cl-subst-if-not}, @code{cl-nsubst-if}, and
4209@code{nsubst-if-not} functions are defined similarly. 3800@code{cl-nsubst-if-not} functions are defined similarly.
4210 3801
4211@defun sublis alist tree @t{&key :test :test-not :key} 3802@defun cl-sublis alist tree @t{&key :test :test-not :key}
4212This function is like @code{subst}, except that it takes an 3803This function is like @code{cl-subst}, except that it takes an
4213association list @var{alist} of @var{old}-@var{new} pairs. 3804association list @var{alist} of @var{old}-@var{new} pairs.
4214Each element of the tree (after applying the @code{:key} 3805Each element of the tree (after applying the @code{:key}
4215function, if any), is compared with the @code{car}s of 3806function, if any), is compared with the @code{car}s of
@@ -4217,8 +3808,8 @@ function, if any), is compared with the @code{car}s of
4217@code{cdr}. 3808@code{cdr}.
4218@end defun 3809@end defun
4219 3810
4220@defun nsublis alist tree @t{&key :test :test-not :key} 3811@defun cl-nsublis alist tree @t{&key :test :test-not :key}
4221This is a destructive version of @code{sublis}. 3812This is a destructive version of @code{cl-sublis}.
4222@end defun 3813@end defun
4223 3814
4224@node Lists as Sets 3815@node Lists as Sets
@@ -4228,7 +3819,7 @@ This is a destructive version of @code{sublis}.
4228These functions perform operations on lists which represent sets 3819These functions perform operations on lists which represent sets
4229of elements. 3820of elements.
4230 3821
4231@defun member* item list @t{&key :test :test-not :key} 3822@defun cl-member item list @t{&key :test :test-not :key}
4232This function searches @var{list} for an element matching @var{item}. 3823This function searches @var{list} for an element matching @var{item}.
4233If a match is found, it returns the cons cell whose @code{car} was 3824If a match is found, it returns the cons cell whose @code{car} was
4234the matching element. Otherwise, it returns @code{nil}. Elements 3825the matching element. Otherwise, it returns @code{nil}. Elements
@@ -4236,34 +3827,33 @@ are compared by @code{eql} by default; you can use the @code{:test},
4236@code{:test-not}, and @code{:key} arguments to modify this behavior. 3827@code{:test-not}, and @code{:key} arguments to modify this behavior.
4237@xref{Sequences}. 3828@xref{Sequences}.
4238 3829
4239Note that this function's name is suffixed by @samp{*} to avoid 3830The standard Emacs lisp function @code{member} uses @code{equal} for
4240the incompatible @code{member} function defined in Emacs. 3831comparisons; it is equivalent to @code{(cl-member @var{item} @var{list}
4241(That function uses @code{equal} for comparisons; it is equivalent 3832:test 'equal)}.
4242to @code{(member* @var{item} @var{list} :test 'equal)}.)
4243@end defun 3833@end defun
4244 3834
4245@findex member-if 3835@findex cl-member-if
4246@findex member-if-not 3836@findex cl-member-if-not
4247The @code{member-if} and @code{member-if-not} functions 3837The @code{cl-member-if} and @code{cl-member-if-not} functions
4248analogously search for elements which satisfy a given predicate. 3838analogously search for elements which satisfy a given predicate.
4249 3839
4250@defun tailp sublist list 3840@defun cl-tailp sublist list
4251This function returns @code{t} if @var{sublist} is a sublist of 3841This function returns @code{t} if @var{sublist} is a sublist of
4252@var{list}, i.e., if @var{sublist} is @code{eql} to @var{list} or to 3842@var{list}, i.e., if @var{sublist} is @code{eql} to @var{list} or to
4253any of its @code{cdr}s. 3843any of its @code{cdr}s.
4254@end defun 3844@end defun
4255 3845
4256@defun adjoin item list @t{&key :test :test-not :key} 3846@defun cl-adjoin item list @t{&key :test :test-not :key}
4257This function conses @var{item} onto the front of @var{list}, 3847This function conses @var{item} onto the front of @var{list},
4258like @code{(cons @var{item} @var{list})}, but only if @var{item} 3848like @code{(cons @var{item} @var{list})}, but only if @var{item}
4259is not already present on the list (as determined by @code{member*}). 3849is not already present on the list (as determined by @code{cl-member}).
4260If a @code{:key} argument is specified, it is applied to 3850If a @code{:key} argument is specified, it is applied to
4261@var{item} as well as to the elements of @var{list} during 3851@var{item} as well as to the elements of @var{list} during
4262the search, on the reasoning that @var{item} is ``about'' to 3852the search, on the reasoning that @var{item} is ``about'' to
4263become part of the list. 3853become part of the list.
4264@end defun 3854@end defun
4265 3855
4266@defun union list1 list2 @t{&key :test :test-not :key} 3856@defun cl-union list1 list2 @t{&key :test :test-not :key}
4267This function combines two lists which represent sets of items, 3857This function combines two lists which represent sets of items,
4268returning a list that represents the union of those two sets. 3858returning a list that represents the union of those two sets.
4269The result list will contain all items which appear in @var{list1} 3859The result list will contain all items which appear in @var{list1}
@@ -4275,46 +3865,46 @@ result list. The order of elements in the result list is also
4275undefined. 3865undefined.
4276@end defun 3866@end defun
4277 3867
4278@defun nunion list1 list2 @t{&key :test :test-not :key} 3868@defun cl-nunion list1 list2 @t{&key :test :test-not :key}
4279This is a destructive version of @code{union}; rather than copying, 3869This is a destructive version of @code{cl-union}; rather than copying,
4280it tries to reuse the storage of the argument lists if possible. 3870it tries to reuse the storage of the argument lists if possible.
4281@end defun 3871@end defun
4282 3872
4283@defun intersection list1 list2 @t{&key :test :test-not :key} 3873@defun cl-intersection list1 list2 @t{&key :test :test-not :key}
4284This function computes the intersection of the sets represented 3874This function computes the intersection of the sets represented
4285by @var{list1} and @var{list2}. It returns the list of items 3875by @var{list1} and @var{list2}. It returns the list of items
4286which appear in both @var{list1} and @var{list2}. 3876which appear in both @var{list1} and @var{list2}.
4287@end defun 3877@end defun
4288 3878
4289@defun nintersection list1 list2 @t{&key :test :test-not :key} 3879@defun cl-nintersection list1 list2 @t{&key :test :test-not :key}
4290This is a destructive version of @code{intersection}. It 3880This is a destructive version of @code{cl-intersection}. It
4291tries to reuse storage of @var{list1} rather than copying. 3881tries to reuse storage of @var{list1} rather than copying.
4292It does @emph{not} reuse the storage of @var{list2}. 3882It does @emph{not} reuse the storage of @var{list2}.
4293@end defun 3883@end defun
4294 3884
4295@defun set-difference list1 list2 @t{&key :test :test-not :key} 3885@defun cl-set-difference list1 list2 @t{&key :test :test-not :key}
4296This function computes the ``set difference'' of @var{list1} 3886This function computes the ``set difference'' of @var{list1}
4297and @var{list2}, i.e., the set of elements that appear in 3887and @var{list2}, i.e., the set of elements that appear in
4298@var{list1} but @emph{not} in @var{list2}. 3888@var{list1} but @emph{not} in @var{list2}.
4299@end defun 3889@end defun
4300 3890
4301@defun nset-difference list1 list2 @t{&key :test :test-not :key} 3891@defun cl-nset-difference list1 list2 @t{&key :test :test-not :key}
4302This is a destructive @code{set-difference}, which will try 3892This is a destructive @code{cl-set-difference}, which will try
4303to reuse @var{list1} if possible. 3893to reuse @var{list1} if possible.
4304@end defun 3894@end defun
4305 3895
4306@defun set-exclusive-or list1 list2 @t{&key :test :test-not :key} 3896@defun cl-set-exclusive-or list1 list2 @t{&key :test :test-not :key}
4307This function computes the ``set exclusive or'' of @var{list1} 3897This function computes the ``set exclusive or'' of @var{list1}
4308and @var{list2}, i.e., the set of elements that appear in 3898and @var{list2}, i.e., the set of elements that appear in
4309exactly one of @var{list1} and @var{list2}. 3899exactly one of @var{list1} and @var{list2}.
4310@end defun 3900@end defun
4311 3901
4312@defun nset-exclusive-or list1 list2 @t{&key :test :test-not :key} 3902@defun cl-nset-exclusive-or list1 list2 @t{&key :test :test-not :key}
4313This is a destructive @code{set-exclusive-or}, which will try 3903This is a destructive @code{cl-set-exclusive-or}, which will try
4314to reuse @var{list1} and @var{list2} if possible. 3904to reuse @var{list1} and @var{list2} if possible.
4315@end defun 3905@end defun
4316 3906
4317@defun subsetp list1 list2 @t{&key :test :test-not :key} 3907@defun cl-subsetp list1 list2 @t{&key :test :test-not :key}
4318This function checks whether @var{list1} represents a subset 3908This function checks whether @var{list1} represents a subset
4319of @var{list2}, i.e., whether every element of @var{list1} 3909of @var{list2}, i.e., whether every element of @var{list1}
4320also appears in @var{list2}. 3910also appears in @var{list2}.
@@ -4328,7 +3918,7 @@ An @dfn{association list} is a list representing a mapping from
4328one set of values to another; any list whose elements are cons 3918one set of values to another; any list whose elements are cons
4329cells is an association list. 3919cells is an association list.
4330 3920
4331@defun assoc* item a-list @t{&key :test :test-not :key} 3921@defun cl-assoc item a-list @t{&key :test :test-not :key}
4332This function searches the association list @var{a-list} for an 3922This function searches the association list @var{a-list} for an
4333element whose @code{car} matches (in the sense of @code{:test}, 3923element whose @code{car} matches (in the sense of @code{:test},
4334@code{:test-not}, and @code{:key}, or by comparison with @code{eql}) 3924@code{:test-not}, and @code{:key}, or by comparison with @code{eql})
@@ -4340,27 +3930,27 @@ are not cons cells. (This corresponds to the behavior of
4340elements of @var{a-list} to be an error.) 3930elements of @var{a-list} to be an error.)
4341@end defun 3931@end defun
4342 3932
4343@defun rassoc* item a-list @t{&key :test :test-not :key} 3933@defun cl-rassoc item a-list @t{&key :test :test-not :key}
4344This function searches for an element whose @code{cdr} matches 3934This function searches for an element whose @code{cdr} matches
4345@var{item}. If @var{a-list} represents a mapping, this applies 3935@var{item}. If @var{a-list} represents a mapping, this applies
4346the inverse of the mapping to @var{item}. 3936the inverse of the mapping to @var{item}.
4347@end defun 3937@end defun
4348 3938
4349@findex assoc-if 3939@findex cl-assoc-if
4350@findex assoc-if-not 3940@findex cl-assoc-if-not
4351@findex rassoc-if 3941@findex cl-rassoc-if
4352@findex rassoc-if-not 3942@findex cl-rassoc-if-not
4353The @code{assoc-if}, @code{assoc-if-not}, @code{rassoc-if}, 3943The @code{cl-assoc-if}, @code{cl-assoc-if-not}, @code{cl-rassoc-if},
4354and @code{rassoc-if-not} functions are defined similarly. 3944and @code{cl-rassoc-if-not} functions are defined similarly.
4355 3945
4356Two simple functions for constructing association lists are: 3946Two simple functions for constructing association lists are:
4357 3947
4358@defun acons key value alist 3948@defun cl-acons key value alist
4359This is equivalent to @code{(cons (cons @var{key} @var{value}) @var{alist})}. 3949This is equivalent to @code{(cons (cons @var{key} @var{value}) @var{alist})}.
4360@end defun 3950@end defun
4361 3951
4362@defun pairlis keys values &optional alist 3952@defun cl-pairlis keys values &optional alist
4363This is equivalent to @code{(nconc (mapcar* 'cons @var{keys} @var{values}) 3953This is equivalent to @code{(nconc (cl-mapcar 'cons @var{keys} @var{values})
4364@var{alist})}. 3954@var{alist})}.
4365@end defun 3955@end defun
4366 3956
@@ -4382,15 +3972,15 @@ system provides no way to create new distinct types, this package
4382implements structures as vectors (or lists upon request) with a 3972implements structures as vectors (or lists upon request) with a
4383special ``tag'' symbol to identify them. 3973special ``tag'' symbol to identify them.
4384 3974
4385@defspec defstruct name slots@dots{} 3975@defmac cl-defstruct name slots@dots{}
4386The @code{defstruct} form defines a new structure type called 3976The @code{cl-defstruct} form defines a new structure type called
4387@var{name}, with the specified @var{slots}. (The @var{slots} 3977@var{name}, with the specified @var{slots}. (The @var{slots}
4388may begin with a string which documents the structure type.) 3978may begin with a string which documents the structure type.)
4389In the simplest case, @var{name} and each of the @var{slots} 3979In the simplest case, @var{name} and each of the @var{slots}
4390are symbols. For example, 3980are symbols. For example,
4391 3981
4392@example 3982@example
4393(defstruct person name age sex) 3983(cl-defstruct person name age sex)
4394@end example 3984@end example
4395 3985
4396@noindent 3986@noindent
@@ -4401,14 +3991,14 @@ and @code{(person-sex @var{p})}. You can also change these slots by
4401using @code{setf} on any of these place forms: 3991using @code{setf} on any of these place forms:
4402 3992
4403@example 3993@example
4404(incf (person-age birthday-boy)) 3994(cl-incf (person-age birthday-boy))
4405@end example 3995@end example
4406 3996
4407You can create a new @code{person} by calling @code{make-person}, 3997You can create a new @code{person} by calling @code{make-person},
4408which takes keyword arguments @code{:name}, @code{:age}, and 3998which takes keyword arguments @code{:name}, @code{:age}, and
4409@code{:sex} to specify the initial values of these slots in the 3999@code{:sex} to specify the initial values of these slots in the
4410new object. (Omitting any of these arguments leaves the corresponding 4000new object. (Omitting any of these arguments leaves the corresponding
4411slot ``undefined,'' according to the Common Lisp standard; in Emacs 4001slot ``undefined'', according to the Common Lisp standard; in Emacs
4412Lisp, such uninitialized slots are filled with @code{nil}.) 4002Lisp, such uninitialized slots are filled with @code{nil}.)
4413 4003
4414Given a @code{person}, @code{(copy-person @var{p})} makes a new 4004Given a @code{person}, @code{(copy-person @var{p})} makes a new
@@ -4465,10 +4055,10 @@ the slot's value is determined when the object is created and does
4465not change afterward. 4055not change afterward.
4466 4056
4467@example 4057@example
4468(defstruct person 4058(cl-defstruct person
4469 (name nil :read-only t) 4059 (name nil :read-only t)
4470 age 4060 age
4471 (sex 'unknown)) 4061 (sex 'unknown))
4472@end example 4062@end example
4473 4063
4474Any slot options other than @code{:read-only} are ignored. 4064Any slot options other than @code{:read-only} are ignored.
@@ -4480,19 +4070,15 @@ by arguments. (By contrast, slot options are key-value pairs not
4480enclosed in lists.) 4070enclosed in lists.)
4481 4071
4482@example 4072@example
4483(defstruct (person (:constructor create-person) 4073(cl-defstruct (person (:constructor create-person)
4484 (:type list) 4074 (:type list)
4485 :named) 4075 :named)
4486 name age sex) 4076 name age sex)
4487@end example 4077@end example
4488 4078
4489The following structure options are recognized. 4079The following structure options are recognized.
4490 4080
4491@table @code 4081@table @code
4492@iftex
4493@itemmax=0 in
4494@advance@leftskip-.5@tableindent
4495@end iftex
4496@item :conc-name 4082@item :conc-name
4497The argument is a symbol whose print name is used as the prefix for 4083The argument is a symbol whose print name is used as the prefix for
4498the names of slot accessor functions. The default is the name of 4084the names of slot accessor functions. The default is the name of
@@ -4529,21 +4115,22 @@ as well unless you disable it with a simple-format @code{:constructor}
4529option. 4115option.
4530 4116
4531@example 4117@example
4532(defstruct 4118(cl-defstruct
4533 (person 4119 (person
4534 (:constructor nil) ; no default constructor 4120 (:constructor nil) ; no default constructor
4535 (:constructor new-person (name sex &optional (age 0))) 4121 (:constructor new-person
4536 (:constructor new-hound (&key (name "Rover") 4122 (name sex &optional (age 0)))
4537 (dog-years 0) 4123 (:constructor new-hound (&key (name "Rover")
4538 &aux (age (* 7 dog-years)) 4124 (dog-years 0)
4539 (sex 'canine)))) 4125 &aux (age (* 7 dog-years))
4540 name age sex) 4126 (sex 'canine))))
4127 name age sex)
4541@end example 4128@end example
4542 4129
4543The first constructor here takes its arguments positionally rather 4130The first constructor here takes its arguments positionally rather
4544than by keyword. (In official Common Lisp terminology, constructors 4131than by keyword. (In official Common Lisp terminology, constructors
4545that work By Order of Arguments instead of by keyword are called 4132that work By Order of Arguments instead of by keyword are called
4546``BOA constructors.'' No, I'm not making this up.) For example, 4133``BOA constructors''. No, I'm not making this up.) For example,
4547@code{(new-person "Jane" 'female)} generates a person whose slots 4134@code{(new-person "Jane" 'female)} generates a person whose slots
4548are @code{"Jane"}, 0, and @code{female}, respectively. 4135are @code{"Jane"}, 0, and @code{female}, respectively.
4549 4136
@@ -4569,14 +4156,14 @@ ever generated.)
4569 4156
4570In true Common Lisp, @code{typep} is always able to recognize a 4157In true Common Lisp, @code{typep} is always able to recognize a
4571structure object even if @code{:predicate} was used. In this 4158structure object even if @code{:predicate} was used. In this
4572package, @code{typep} simply looks for a function called 4159package, @code{cl-typep} simply looks for a function called
4573@code{@var{typename}-p}, so it will work for structure types 4160@code{@var{typename}-p}, so it will work for structure types
4574only if they used the default predicate name. 4161only if they used the default predicate name.
4575 4162
4576@item :include 4163@item :include
4577This option implements a very limited form of C++-style inheritance. 4164This option implements a very limited form of C++-style inheritance.
4578The argument is the name of another structure type previously 4165The argument is the name of another structure type previously
4579created with @code{defstruct}. The effect is to cause the new 4166created with @code{cl-defstruct}. The effect is to cause the new
4580structure type to inherit all of the included structure's slots 4167structure type to inherit all of the included structure's slots
4581(plus, of course, any new slots described by this struct's slot 4168(plus, of course, any new slots described by this struct's slot
4582descriptors). The new structure is considered a ``specialization'' 4169descriptors). The new structure is considered a ``specialization''
@@ -4589,12 +4176,12 @@ slot descriptors for slots in the included structure, possibly with
4589modified default values. Borrowing an example from Steele: 4176modified default values. Borrowing an example from Steele:
4590 4177
4591@example 4178@example
4592(defstruct person name (age 0) sex) 4179(cl-defstruct person name (age 0) sex)
4593 @result{} person 4180 @result{} person
4594(defstruct (astronaut (:include person (age 45))) 4181(cl-defstruct (astronaut (:include person (age 45)))
4595 helmet-size 4182 helmet-size
4596 (favorite-beverage 'tang)) 4183 (favorite-beverage 'tang))
4597 @result{} astronaut 4184 @result{} astronaut
4598 4185
4599(setq joe (make-person :name "Joe")) 4186(setq joe (make-person :name "Joe"))
4600 @result{} [cl-struct-person "Joe" 0 nil] 4187 @result{} [cl-struct-person "Joe" 0 nil]
@@ -4650,9 +4237,9 @@ use named vectors. Therefore, @code{:named} is only useful in
4650conjunction with @code{:type}. 4237conjunction with @code{:type}.
4651 4238
4652@example 4239@example
4653(defstruct (person1) name age sex) 4240(cl-defstruct (person1) name age sex)
4654(defstruct (person2 (:type list) :named) name age sex) 4241(cl-defstruct (person2 (:type list) :named) name age sex)
4655(defstruct (person3 (:type list)) name age sex) 4242(cl-defstruct (person3 (:type list)) name age sex)
4656 4243
4657(setq p1 (make-person1)) 4244(setq p1 (make-person1))
4658 @result{} [cl-struct-person1 nil nil nil] 4245 @result{} [cl-struct-person1 nil nil nil]
@@ -4669,7 +4256,7 @@ conjunction with @code{:type}.
4669 @result{} error: function person3-p undefined 4256 @result{} error: function person3-p undefined
4670@end example 4257@end example
4671 4258
4672Since unnamed structures don't have tags, @code{defstruct} is not 4259Since unnamed structures don't have tags, @code{cl-defstruct} is not
4673able to make a useful predicate for recognizing them. Also, 4260able to make a useful predicate for recognizing them. Also,
4674accessors like @code{person3-name} will be generated but they 4261accessors like @code{person3-name} will be generated but they
4675will not be able to do any type checking. The @code{person3-name} 4262will not be able to do any type checking. The @code{person3-name}
@@ -4689,9 +4276,9 @@ the type @code{:include}s another type, then @code{:initial-offset}
4689specifies a number of slots to be skipped between the last slot 4276specifies a number of slots to be skipped between the last slot
4690of the included type and the first new slot. 4277of the included type and the first new slot.
4691@end table 4278@end table
4692@end defspec 4279@end defmac
4693 4280
4694Except as noted, the @code{defstruct} facility of this package is 4281Except as noted, the @code{cl-defstruct} facility of this package is
4695entirely compatible with that of Common Lisp. 4282entirely compatible with that of Common Lisp.
4696 4283
4697@node Assertions 4284@node Assertions
@@ -4708,10 +4295,10 @@ If the optimization property @code{speed} has been set to 3, and
4708away the following assertions. Because assertions might be optimized 4295away the following assertions. Because assertions might be optimized
4709away, it is a bad idea for them to include side-effects. 4296away, it is a bad idea for them to include side-effects.
4710 4297
4711@defspec assert test-form [show-args string args@dots{}] 4298@defmac cl-assert test-form [show-args string args@dots{}]
4712This form verifies that @var{test-form} is true (i.e., evaluates to 4299This form verifies that @var{test-form} is true (i.e., evaluates to
4713a non-@code{nil} value). If so, it returns @code{nil}. If the test 4300a non-@code{nil} value). If so, it returns @code{nil}. If the test
4714is not satisfied, @code{assert} signals an error. 4301is not satisfied, @code{cl-assert} signals an error.
4715 4302
4716A default error message will be supplied which includes @var{test-form}. 4303A default error message will be supplied which includes @var{test-form}.
4717You can specify a different error message by including a @var{string} 4304You can specify a different error message by including a @var{string}
@@ -4724,7 +4311,7 @@ will also include all non-constant arguments of the top-level
4724@var{form}. For example: 4311@var{form}. For example:
4725 4312
4726@example 4313@example
4727(assert (> x 10) t "x is too small: %d") 4314(cl-assert (> x 10) t "x is too small: %d")
4728@end example 4315@end example
4729 4316
4730This usage of @var{show-args} is an extension to Common Lisp. In 4317This usage of @var{show-args} is an extension to Common Lisp. In
@@ -4732,18 +4319,18 @@ true Common Lisp, the second argument gives a list of @var{places}
4732which can be @code{setf}'d by the user before continuing from the 4319which can be @code{setf}'d by the user before continuing from the
4733error. Since Emacs Lisp does not support continuable errors, it 4320error. Since Emacs Lisp does not support continuable errors, it
4734makes no sense to specify @var{places}. 4321makes no sense to specify @var{places}.
4735@end defspec 4322@end defmac
4736 4323
4737@defspec check-type form type [string] 4324@defmac cl-check-type form type [string]
4738This form verifies that @var{form} evaluates to a value of type 4325This form verifies that @var{form} evaluates to a value of type
4739@var{type}. If so, it returns @code{nil}. If not, @code{check-type} 4326@var{type}. If so, it returns @code{nil}. If not, @code{cl-check-type}
4740signals a @code{wrong-type-argument} error. The default error message 4327signals a @code{wrong-type-argument} error. The default error message
4741lists the erroneous value along with @var{type} and @var{form} 4328lists the erroneous value along with @var{type} and @var{form}
4742themselves. If @var{string} is specified, it is included in the 4329themselves. If @var{string} is specified, it is included in the
4743error message in place of @var{type}. For example: 4330error message in place of @var{type}. For example:
4744 4331
4745@example 4332@example
4746(check-type x (integer 1 *) "a positive integer") 4333(cl-check-type x (integer 1 *) "a positive integer")
4747@end example 4334@end example
4748 4335
4749@xref{Type Predicates}, for a description of the type specifiers 4336@xref{Type Predicates}, for a description of the type specifiers
@@ -4753,18 +4340,7 @@ Note that in Common Lisp, the first argument to @code{check-type}
4753must be a @var{place} suitable for use by @code{setf}, because 4340must be a @var{place} suitable for use by @code{setf}, because
4754@code{check-type} signals a continuable error that allows the 4341@code{check-type} signals a continuable error that allows the
4755user to modify @var{place}. 4342user to modify @var{place}.
4756@end defspec 4343@end defmac
4757
4758The following error-related macro is also defined:
4759
4760@defspec ignore-errors forms@dots{}
4761This executes @var{forms} exactly like a @code{progn}, except that
4762errors are ignored during the @var{forms}. More precisely, if
4763an error is signaled then @code{ignore-errors} immediately
4764aborts execution of the @var{forms} and returns @code{nil}.
4765If the @var{forms} complete successfully, @code{ignore-errors}
4766returns the result of the last @var{form}.
4767@end defspec
4768 4344
4769@node Efficiency Concerns 4345@node Efficiency Concerns
4770@appendix Efficiency Concerns 4346@appendix Efficiency Concerns
@@ -4772,38 +4348,35 @@ returns the result of the last @var{form}.
4772@appendixsec Macros 4348@appendixsec Macros
4773 4349
4774@noindent 4350@noindent
4775Many of the advanced features of this package, such as @code{defun*}, 4351Many of the advanced features of this package, such as @code{cl-defun},
4776@code{loop}, and @code{setf}, are implemented as Lisp macros. In 4352@code{cl-loop}, etc., are implemented as Lisp macros. In
4777byte-compiled code, these complex notations will be expanded into 4353byte-compiled code, these complex notations will be expanded into
4778equivalent Lisp code which is simple and efficient. For example, 4354equivalent Lisp code which is simple and efficient. For example,
4779the forms 4355the form
4780 4356
4781@example 4357@example
4782(incf i n) 4358(cl-incf i n)
4783(push x (car p))
4784@end example 4359@end example
4785 4360
4786@noindent 4361@noindent
4787are expanded at compile-time to the Lisp forms 4362is expanded at compile-time to the Lisp form
4788 4363
4789@example 4364@example
4790(setq i (+ i n)) 4365(setq i (+ i n))
4791(setcar p (cons x (car p)))
4792@end example 4366@end example
4793 4367
4794@noindent 4368@noindent
4795which are the most efficient ways of doing these respective operations 4369which is the most efficient ways of doing this operation
4796in Lisp. Thus, there is no performance penalty for using the more 4370in Lisp. Thus, there is no performance penalty for using the more
4797readable @code{incf} and @code{push} forms in your compiled code. 4371readable @code{cl-incf} form in your compiled code.
4798 4372
4799@emph{Interpreted} code, on the other hand, must expand these macros 4373@emph{Interpreted} code, on the other hand, must expand these macros
4800every time they are executed. For this reason it is strongly 4374every time they are executed. For this reason it is strongly
4801recommended that code making heavy use of macros be compiled. 4375recommended that code making heavy use of macros be compiled.
4802(The features labeled ``Special Form'' instead of ``Function'' in 4376A loop using @code{cl-incf} a hundred times will execute considerably
4803this manual are macros.) A loop using @code{incf} a hundred times 4377faster if compiled, and will also garbage-collect less because the
4804will execute considerably faster if compiled, and will also 4378macro expansion will not have to be generated, used, and thrown away a
4805garbage-collect less because the macro expansion will not have 4379hundred times.
4806to be generated, used, and thrown away a hundred times.
4807 4380
4808You can find out how a macro expands by using the 4381You can find out how a macro expands by using the
4809@code{cl-prettyexpand} function. 4382@code{cl-prettyexpand} function.
@@ -4813,10 +4386,10 @@ This function takes a single Lisp form as an argument and inserts
4813a nicely formatted copy of it in the current buffer (which must be 4386a nicely formatted copy of it in the current buffer (which must be
4814in Lisp mode so that indentation works properly). It also expands 4387in Lisp mode so that indentation works properly). It also expands
4815all Lisp macros which appear in the form. The easiest way to use 4388all Lisp macros which appear in the form. The easiest way to use
4816this function is to go to the @code{*scratch*} buffer and type, say, 4389this function is to go to the @file{*scratch*} buffer and type, say,
4817 4390
4818@example 4391@example
4819(cl-prettyexpand '(loop for x below 10 collect x)) 4392(cl-prettyexpand '(cl-loop for x below 10 collect x))
4820@end example 4393@end example
4821 4394
4822@noindent 4395@noindent
@@ -4824,36 +4397,36 @@ and type @kbd{C-x C-e} immediately after the closing parenthesis;
4824the expansion 4397the expansion
4825 4398
4826@example 4399@example
4827(block nil 4400(cl-block nil
4828 (let* ((x 0) 4401 (let* ((x 0)
4829 (G1004 nil)) 4402 (G1004 nil))
4830 (while (< x 10) 4403 (while (< x 10)
4831 (setq G1004 (cons x G1004)) 4404 (setq G1004 (cons x G1004))
4832 (setq x (+ x 1))) 4405 (setq x (+ x 1)))
4833 (nreverse G1004))) 4406 (nreverse G1004)))
4834@end example 4407@end example
4835 4408
4836@noindent 4409@noindent
4837will be inserted into the buffer. (The @code{block} macro is 4410will be inserted into the buffer. (The @code{cl-block} macro is
4838expanded differently in the interpreter and compiler, so 4411expanded differently in the interpreter and compiler, so
4839@code{cl-prettyexpand} just leaves it alone. The temporary 4412@code{cl-prettyexpand} just leaves it alone. The temporary
4840variable @code{G1004} was created by @code{gensym}.) 4413variable @code{G1004} was created by @code{cl-gensym}.)
4841 4414
4842If the optional argument @var{full} is true, then @emph{all} 4415If the optional argument @var{full} is true, then @emph{all}
4843macros are expanded, including @code{block}, @code{eval-when}, 4416macros are expanded, including @code{cl-block}, @code{cl-eval-when},
4844and compiler macros. Expansion is done as if @var{form} were 4417and compiler macros. Expansion is done as if @var{form} were
4845a top-level form in a file being compiled. For example, 4418a top-level form in a file being compiled. For example,
4846 4419
4847@example 4420@example
4848(cl-prettyexpand '(pushnew 'x list)) 4421(cl-prettyexpand '(cl-pushnew 'x list))
4849 @print{} (setq list (adjoin 'x list)) 4422 @print{} (setq list (cl-adjoin 'x list))
4850(cl-prettyexpand '(pushnew 'x list) t) 4423(cl-prettyexpand '(cl-pushnew 'x list) t)
4851 @print{} (setq list (if (memq 'x list) list (cons 'x list))) 4424 @print{} (setq list (if (memq 'x list) list (cons 'x list)))
4852(cl-prettyexpand '(caddr (member* 'a list)) t) 4425(cl-prettyexpand '(caddr (cl-member 'a list)) t)
4853 @print{} (car (cdr (cdr (memq 'a list)))) 4426 @print{} (car (cdr (cdr (memq 'a list))))
4854@end example 4427@end example
4855 4428
4856Note that @code{adjoin}, @code{caddr}, and @code{member*} all 4429Note that @code{cl-adjoin}, @code{cl-caddr}, and @code{cl-member} all
4857have built-in compiler macros to optimize them in common cases. 4430have built-in compiler macros to optimize them in common cases.
4858@end defun 4431@end defun
4859 4432
@@ -4875,22 +4448,22 @@ phrase ``it is an error if'' to indicate a situation which is not
4875supposed to arise in complying programs; implementations are strongly 4448supposed to arise in complying programs; implementations are strongly
4876encouraged but not required to signal an error in these situations. 4449encouraged but not required to signal an error in these situations.
4877This package sometimes omits such error checking in the interest of 4450This package sometimes omits such error checking in the interest of
4878compactness and efficiency. For example, @code{do} variable 4451compactness and efficiency. For example, @code{cl-do} variable
4879specifiers are supposed to be lists of one, two, or three forms; 4452specifiers are supposed to be lists of one, two, or three forms;
4880extra forms are ignored by this package rather than signaling a 4453extra forms are ignored by this package rather than signaling a
4881syntax error. The @code{endp} function is simply a synonym for 4454syntax error. The @code{cl-endp} function is simply a synonym for
4882@code{null} in this package. Functions taking keyword arguments 4455@code{null} in this package. Functions taking keyword arguments
4883will accept an odd number of arguments, treating the trailing 4456will accept an odd number of arguments, treating the trailing
4884keyword as if it were followed by the value @code{nil}. 4457keyword as if it were followed by the value @code{nil}.
4885 4458
4886Argument lists (as processed by @code{defun*} and friends) 4459Argument lists (as processed by @code{cl-defun} and friends)
4887@emph{are} checked rigorously except for the minor point just 4460@emph{are} checked rigorously except for the minor point just
4888mentioned; in particular, keyword arguments are checked for 4461mentioned; in particular, keyword arguments are checked for
4889validity, and @code{&allow-other-keys} and @code{:allow-other-keys} 4462validity, and @code{&allow-other-keys} and @code{:allow-other-keys}
4890are fully implemented. Keyword validity checking is slightly 4463are fully implemented. Keyword validity checking is slightly
4891time consuming (though not too bad in byte-compiled code); 4464time consuming (though not too bad in byte-compiled code);
4892you can use @code{&allow-other-keys} to omit this check. Functions 4465you can use @code{&allow-other-keys} to omit this check. Functions
4893defined in this package such as @code{find} and @code{member*} 4466defined in this package such as @code{cl-find} and @code{cl-member}
4894do check their keyword arguments for validity. 4467do check their keyword arguments for validity.
4895 4468
4896@ifinfo 4469@ifinfo
@@ -4904,10 +4477,10 @@ do check their keyword arguments for validity.
4904Use of the optimizing Emacs compiler is highly recommended; many of the Common 4477Use of the optimizing Emacs compiler is highly recommended; many of the Common
4905Lisp macros emit 4478Lisp macros emit
4906code which can be improved by optimization. In particular, 4479code which can be improved by optimization. In particular,
4907@code{block}s (whether explicit or implicit in constructs like 4480@code{cl-block}s (whether explicit or implicit in constructs like
4908@code{defun*} and @code{loop}) carry a fair run-time penalty; the 4481@code{cl-defun} and @code{cl-loop}) carry a fair run-time penalty; the
4909optimizing compiler removes @code{block}s which are not actually 4482optimizing compiler removes @code{cl-block}s which are not actually
4910referenced by @code{return} or @code{return-from} inside the block. 4483referenced by @code{cl-return} or @code{cl-return-from} inside the block.
4911 4484
4912@node Common Lisp Compatibility 4485@node Common Lisp Compatibility
4913@appendix Common Lisp Compatibility 4486@appendix Common Lisp Compatibility
@@ -4916,42 +4489,38 @@ referenced by @code{return} or @code{return-from} inside the block.
4916Following is a list of all known incompatibilities between this 4489Following is a list of all known incompatibilities between this
4917package and Common Lisp as documented in Steele (2nd edition). 4490package and Common Lisp as documented in Steele (2nd edition).
4918 4491
4919Certain function names, such as @code{member}, @code{assoc}, and 4492The word @code{cl-defun} is required instead of @code{defun} in order
4920@code{floor}, were already taken by (incompatible) Emacs Lisp
4921functions; this package appends @samp{*} to the names of its
4922Common Lisp versions of these functions.
4923
4924The word @code{defun*} is required instead of @code{defun} in order
4925to use extended Common Lisp argument lists in a function. Likewise, 4493to use extended Common Lisp argument lists in a function. Likewise,
4926@code{defmacro*} and @code{function*} are versions of those forms 4494@code{cl-defmacro} and @code{cl-function} are versions of those forms
4927which understand full-featured argument lists. The @code{&whole} 4495which understand full-featured argument lists. The @code{&whole}
4928keyword does not work in @code{defmacro} argument lists (except 4496keyword does not work in @code{defmacro} argument lists (except
4929inside recursive argument lists). 4497inside recursive argument lists).
4930 4498
4931The @code{equal} predicate does not distinguish 4499The @code{equal} predicate does not distinguish
4932between IEEE floating-point plus and minus zero. The @code{equalp} 4500between IEEE floating-point plus and minus zero. The @code{cl-equalp}
4933predicate has several differences with Common Lisp; @pxref{Predicates}. 4501predicate has several differences with Common Lisp; @pxref{Predicates}.
4934 4502
4503@c FIXME no longer provided by cl.
4935The @code{setf} mechanism is entirely compatible, except that 4504The @code{setf} mechanism is entirely compatible, except that
4936setf-methods return a list of five values rather than five 4505setf-methods return a list of five values rather than five
4937values directly. Also, the new ``@code{setf} function'' concept 4506values directly. Also, the new ``@code{setf} function'' concept
4938(typified by @code{(defun (setf foo) @dots{})}) is not implemented. 4507(typified by @code{(defun (setf foo) @dots{})}) is not implemented.
4939 4508
4940The @code{do-all-symbols} form is the same as @code{do-symbols} 4509The @code{cl-do-all-symbols} form is the same as @code{cl-do-symbols}
4941with no @var{obarray} argument. In Common Lisp, this form would 4510with no @var{obarray} argument. In Common Lisp, this form would
4942iterate over all symbols in all packages. Since Emacs obarrays 4511iterate over all symbols in all packages. Since Emacs obarrays
4943are not a first-class package mechanism, there is no way for 4512are not a first-class package mechanism, there is no way for
4944@code{do-all-symbols} to locate any but the default obarray. 4513@code{cl-do-all-symbols} to locate any but the default obarray.
4945 4514
4946The @code{loop} macro is complete except that @code{loop-finish} 4515The @code{cl-loop} macro is complete except that @code{loop-finish}
4947and type specifiers are unimplemented. 4516and type specifiers are unimplemented.
4948 4517
4949The multiple-value return facility treats lists as multiple 4518The multiple-value return facility treats lists as multiple
4950values, since Emacs Lisp cannot support multiple return values 4519values, since Emacs Lisp cannot support multiple return values
4951directly. The macros will be compatible with Common Lisp if 4520directly. The macros will be compatible with Common Lisp if
4952@code{values} or @code{values-list} is always used to return to 4521@code{cl-values} or @code{cl-values-list} is always used to return to
4953a @code{multiple-value-bind} or other multiple-value receiver; 4522a @code{cl-multiple-value-bind} or other multiple-value receiver;
4954if @code{values} is used without @code{multiple-value-@dots{}} 4523if @code{cl-values} is used without @code{cl-multiple-value-@dots{}}
4955or vice-versa the effect will be different from Common Lisp. 4524or vice-versa the effect will be different from Common Lisp.
4956 4525
4957Many Common Lisp declarations are ignored, and others match 4526Many Common Lisp declarations are ignored, and others match
@@ -4960,117 +4529,16 @@ example, local @code{special} declarations, which are purely
4960advisory in Emacs Lisp, do not rigorously obey the scoping rules 4529advisory in Emacs Lisp, do not rigorously obey the scoping rules
4961set down in Steele's book. 4530set down in Steele's book.
4962 4531
4963The variable @code{*gensym-counter*} starts out with a pseudo-random 4532The variable @code{cl--gensym-counter} starts out with a pseudo-random
4964value rather than with zero. This is to cope with the fact that 4533value rather than with zero. This is to cope with the fact that
4965generated symbols become interned when they are written to and 4534generated symbols become interned when they are written to and
4966loaded back from a file. 4535loaded back from a file.
4967 4536
4968The @code{defstruct} facility is compatible, except that structures 4537The @code{cl-defstruct} facility is compatible, except that structures
4969are of type @code{:type vector :named} by default rather than some 4538are of type @code{:type vector :named} by default rather than some
4970special, distinct type. Also, the @code{:type} slot option is ignored. 4539special, distinct type. Also, the @code{:type} slot option is ignored.
4971 4540
4972The second argument of @code{check-type} is treated differently. 4541The second argument of @code{cl-check-type} is treated differently.
4973
4974@node Old CL Compatibility
4975@appendix Old CL Compatibility
4976
4977@noindent
4978Following is a list of all known incompatibilities between this package
4979and the older Quiroz @file{cl.el} package.
4980
4981This package's emulation of multiple return values in functions is
4982incompatible with that of the older package. That package attempted
4983to come as close as possible to true Common Lisp multiple return
4984values; unfortunately, it could not be 100% reliable and so was prone
4985to occasional surprises if used freely. This package uses a simpler
4986method, namely replacing multiple values with lists of values, which
4987is more predictable though more noticeably different from Common Lisp.
4988
4989The @code{defkeyword} form and @code{keywordp} function are not
4990implemented in this package.
4991
4992The @code{member}, @code{floor}, @code{ceiling}, @code{truncate},
4993@code{round}, @code{mod}, and @code{rem} functions are suffixed
4994by @samp{*} in this package to avoid collision with existing
4995functions in Emacs. The older package simply
4996redefined these functions, overwriting the built-in meanings and
4997causing serious portability problems. (Some more
4998recent versions of the Quiroz package changed the names to
4999@code{cl-member}, etc.; this package defines the latter names as
5000aliases for @code{member*}, etc.)
5001
5002Certain functions in the old package which were buggy or inconsistent
5003with the Common Lisp standard are incompatible with the conforming
5004versions in this package. For example, @code{eql} and @code{member}
5005were synonyms for @code{eq} and @code{memq} in that package, @code{setf}
5006failed to preserve correct order of evaluation of its arguments, etc.
5007
5008Finally, unlike the older package, this package is careful to
5009prefix all of its internal names with @code{cl-}. Except for a
5010few functions which are explicitly defined as additional features
5011(such as @code{floatp-safe} and @code{letf}), this package does not
5012export any non-@samp{cl-} symbols which are not also part of Common
5013Lisp.
5014
5015@ifinfo
5016@example
5017
5018@end example
5019@end ifinfo
5020@appendixsec The @code{cl-compat} package
5021
5022@noindent
5023The @code{CL} package includes emulations of some features of the
5024old @file{cl.el}, in the form of a compatibility package
5025@code{cl-compat}. This file is obsolete and may be removed in future,
5026so it should not be used in new code.
5027
5028The old package defined a number of internal routines without
5029@code{cl-} prefixes or other annotations. Call to these routines
5030may have crept into existing Lisp code. @code{cl-compat}
5031provides emulations of the following internal routines:
5032@code{pair-with-newsyms}, @code{zip-lists}, @code{unzip-lists},
5033@code{reassemble-arglists}, @code{duplicate-symbols-p},
5034@code{safe-idiv}.
5035
5036Some @code{setf} forms translated into calls to internal
5037functions that user code might call directly. The functions
5038@code{setnth}, @code{setnthcdr}, and @code{setelt} fall in
5039this category; they are defined by @code{cl-compat}, but the
5040best fix is to change to use @code{setf} properly.
5041
5042The @code{cl-compat} file defines the keyword functions
5043@code{keywordp}, @code{keyword-of}, and @code{defkeyword},
5044which are not defined by the new @code{CL} package because the
5045use of keywords as data is discouraged.
5046
5047The @code{build-klist} mechanism for parsing keyword arguments
5048is emulated by @code{cl-compat}; the @code{with-keyword-args}
5049macro is not, however, and in any case it's best to change to
5050use the more natural keyword argument processing offered by
5051@code{defun*}.
5052
5053Multiple return values are treated differently by the two
5054Common Lisp packages. The old package's method was more
5055compatible with true Common Lisp, though it used heuristics
5056that caused it to report spurious multiple return values in
5057certain cases. The @code{cl-compat} package defines a set
5058of multiple-value macros that are compatible with the old
5059CL package; again, they are heuristic in nature, but they
5060are guaranteed to work in any case where the old package's
5061macros worked. To avoid name collision with the ``official''
5062multiple-value facilities, the ones in @code{cl-compat} have
5063capitalized names: @code{Values}, @code{Values-list},
5064@code{Multiple-value-bind}, etc.
5065
5066The functions @code{cl-floor}, @code{cl-ceiling}, @code{cl-truncate},
5067and @code{cl-round} are defined by @code{cl-compat} to use the
5068old-style multiple-value mechanism, just as they did in the old
5069package. The newer @code{floor*} and friends return their two
5070results in a list rather than as multiple values. Note that
5071older versions of the old package used the unadorned names
5072@code{floor}, @code{ceiling}, etc.; @code{cl-compat} cannot use
5073these names because they conflict with Emacs built-ins.
5074 4542
5075@node Porting Common Lisp 4543@node Porting Common Lisp
5076@appendix Porting Common Lisp 4544@appendix Porting Common Lisp
@@ -5100,19 +4568,17 @@ this convention, calls to Lisp builtins like @code{if} and
5100 4568
5101@item 4569@item
5102Lexical scoping. In Common Lisp, function arguments and @code{let} 4570Lexical scoping. In Common Lisp, function arguments and @code{let}
5103bindings apply only to references physically within their bodies 4571bindings apply only to references physically within their bodies (or
5104(or within macro expansions in their bodies). Emacs Lisp, by 4572within macro expansions in their bodies). Traditionally, Emacs Lisp
5105contrast, uses @dfn{dynamic scoping} wherein a binding to a 4573uses @dfn{dynamic scoping} wherein a binding to a variable is visible
5106variable is visible even inside functions called from the body. 4574even inside functions called from the body.
5107 4575@xref{Dynamic Binding,,,elisp,GNU Emacs Lisp Reference Manual}.
5108Variables in Common Lisp can be made dynamically scoped by 4576Lexical binding is available since Emacs 24.1, so be sure to set
5109declaring them @code{special} or using @code{defvar}. In Emacs 4577@code{lexical-binding} to @code{t} if you need to emulate this aspect
5110Lisp it is as if all variables were declared @code{special}. 4578of Common Lisp. @xref{Lexical Binding,,,elisp,GNU Emacs Lisp Reference Manual}.
5111 4579
5112Often you can use code that was written for lexical scoping 4580Here is an example of a Common Lisp code fragment that would fail in
5113even in a dynamically scoped Lisp, but not always. Here is 4581Emacs Lisp if @code{lexical-binding} were set to @code{nil}:
5114an example of a Common Lisp code fragment that would fail in
5115Emacs Lisp:
5116 4582
5117@example 4583@example
5118(defun map-odd-elements (func list) 4584(defun map-odd-elements (func list)
@@ -5125,20 +4591,16 @@ Emacs Lisp:
5125@end example 4591@end example
5126 4592
5127@noindent 4593@noindent
5128In Common Lisp, the two functions' usages of @code{x} are completely 4594With lexical binding, the two functions' usages of @code{x} are
5129independent. In Emacs Lisp, the binding to @code{x} made by 4595completely independent. With dynamic binding, the binding to @code{x}
5130@code{add-odd-elements} will have been hidden by the binding 4596made by @code{add-odd-elements} will have been hidden by the binding
5131in @code{map-odd-elements} by the time the @code{(+ a x)} function 4597in @code{map-odd-elements} by the time the @code{(+ a x)} function is
5132is called. 4598called.
5133
5134(This package avoids such problems in its own mapping functions
5135by using names like @code{cl-x} instead of @code{x} internally;
5136as long as you don't use the @code{cl-} prefix for your own
5137variables no collision can occur.)
5138 4599
5139@xref{Lexical Bindings}, for a description of the @code{lexical-let} 4600Internally, this package uses lexical binding so that such problems do
5140form which establishes a Common Lisp-style lexical binding, and some 4601not occur. @xref{Lexical Bindings}, for a description of the obsolete
5141examples of how it differs from Emacs's regular @code{let}. 4602@code{lexical-let} form that emulates a Common Lisp-style lexical
4603binding when dynamic binding is in use.
5142 4604
5143@item 4605@item
5144Reader macros. Common Lisp includes a second type of macro that 4606Reader macros. Common Lisp includes a second type of macro that
@@ -5178,7 +4640,7 @@ Lisp, they are totally distinct in Emacs Lisp. Common Lisp
5178programs which refer to a symbol by the full name sometimes 4640programs which refer to a symbol by the full name sometimes
5179and the short name other times will not port cleanly to Emacs. 4641and the short name other times will not port cleanly to Emacs.
5180 4642
5181Emacs Lisp does have a concept of ``obarrays,'' which are 4643Emacs Lisp does have a concept of ``obarrays'', which are
5182package-like collections of symbols, but this feature is not 4644package-like collections of symbols, but this feature is not
5183strong enough to be used as a true package mechanism. 4645strong enough to be used as a true package mechanism.
5184 4646
@@ -5198,10 +4660,10 @@ codes provide such features as paragraph filling, case
5198conversion, and even loops and conditionals. 4660conversion, and even loops and conditionals.
5199 4661
5200While it would have been possible to implement most of Common 4662While it would have been possible to implement most of Common
5201Lisp @code{format} in this package (under the name @code{format*}, 4663Lisp @code{format} in this package (under the name @code{cl-format},
5202of course), it was not deemed worthwhile. It would have required 4664of course), it was not deemed worthwhile. It would have required
5203a huge amount of code to implement even a decent subset of 4665a huge amount of code to implement even a decent subset of
5204@code{format*}, yet the functionality it would provide over 4666@code{cl-format}, yet the functionality it would provide over
5205Emacs Lisp's @code{format} would rarely be useful. 4667Emacs Lisp's @code{format} would rarely be useful.
5206 4668
5207@item 4669@item
@@ -5267,8 +4729,8 @@ where a more iteratively-minded programmer might write one of
5267these forms: 4729these forms:
5268 4730
5269@example 4731@example
5270(let ((total 0)) (dolist (x my-list) (incf total x)) total) 4732(let ((total 0)) (dolist (x my-list) (cl-incf total x)) total)
5271(loop for x in my-list sum x) 4733(cl-loop for x in my-list sum x)
5272@end example 4734@end example
5273 4735
5274While this would be mainly a stylistic choice in most Common Lisps, 4736While this would be mainly a stylistic choice in most Common Lisps,
@@ -5278,6 +4740,373 @@ note that the current Emacs Lisp compiler does not optimize tail
5278recursion. 4740recursion.
5279@end itemize 4741@end itemize
5280 4742
4743@node Obsolete Features
4744@appendix Obsolete Features
4745
4746This section describes some features of the package that are obsolete
4747and should not be used in new code. They are either only provided by
4748the old @file{cl.el} entry point, not by the newer @file{cl-lib.el};
4749or where versions with a @samp{cl-} prefix do exist they do not behave
4750in exactly the same way.
4751
4752@menu
4753* Lexical Bindings:: An approximation of lexical binding.
4754* Obsolete Lexical Macros:: Obsolete macros using lexical-let.
4755* Obsolete Setf Customization:: Obsolete ways to customize setf.
4756@end menu
4757
4758@node Lexical Bindings
4759@appendixsec Lexical Bindings
4760
4761The following macros are extensions to Common Lisp, where all bindings
4762are lexical unless declared otherwise. These features are likewise
4763obsolete since the introduction of true lexical binding in Emacs 24.1.
4764
4765@defmac lexical-let (bindings@dots{}) forms@dots{}
4766This form is exactly like @code{let} except that the bindings it
4767establishes are purely lexical.
4768@end defmac
4769
4770@c FIXME remove this and refer to elisp manual.
4771@c Maybe merge some stuff from here to there?
4772@noindent
4773Lexical bindings are similar to local variables in a language like C:
4774Only the code physically within the body of the @code{lexical-let}
4775(after macro expansion) may refer to the bound variables.
4776
4777@example
4778(setq a 5)
4779(defun foo (b) (+ a b))
4780(let ((a 2)) (foo a))
4781 @result{} 4
4782(lexical-let ((a 2)) (foo a))
4783 @result{} 7
4784@end example
4785
4786@noindent
4787In this example, a regular @code{let} binding of @code{a} actually
4788makes a temporary change to the global variable @code{a}, so @code{foo}
4789is able to see the binding of @code{a} to 2. But @code{lexical-let}
4790actually creates a distinct local variable @code{a} for use within its
4791body, without any effect on the global variable of the same name.
4792
4793The most important use of lexical bindings is to create @dfn{closures}.
4794A closure is a function object that refers to an outside lexical
4795variable (@pxref{Closures,,,elisp,GNU Emacs Lisp Reference Manual}).
4796For example:
4797
4798@example
4799(defun make-adder (n)
4800 (lexical-let ((n n))
4801 (function (lambda (m) (+ n m)))))
4802(setq add17 (make-adder 17))
4803(funcall add17 4)
4804 @result{} 21
4805@end example
4806
4807@noindent
4808The call @code{(make-adder 17)} returns a function object which adds
480917 to its argument. If @code{let} had been used instead of
4810@code{lexical-let}, the function object would have referred to the
4811global @code{n}, which would have been bound to 17 only during the
4812call to @code{make-adder} itself.
4813
4814@example
4815(defun make-counter ()
4816 (lexical-let ((n 0))
4817 (cl-function (lambda (&optional (m 1)) (cl-incf n m)))))
4818(setq count-1 (make-counter))
4819(funcall count-1 3)
4820 @result{} 3
4821(funcall count-1 14)
4822 @result{} 17
4823(setq count-2 (make-counter))
4824(funcall count-2 5)
4825 @result{} 5
4826(funcall count-1 2)
4827 @result{} 19
4828(funcall count-2)
4829 @result{} 6
4830@end example
4831
4832@noindent
4833Here we see that each call to @code{make-counter} creates a distinct
4834local variable @code{n}, which serves as a private counter for the
4835function object that is returned.
4836
4837Closed-over lexical variables persist until the last reference to
4838them goes away, just like all other Lisp objects. For example,
4839@code{count-2} refers to a function object which refers to an
4840instance of the variable @code{n}; this is the only reference
4841to that variable, so after @code{(setq count-2 nil)} the garbage
4842collector would be able to delete this instance of @code{n}.
4843Of course, if a @code{lexical-let} does not actually create any
4844closures, then the lexical variables are free as soon as the
4845@code{lexical-let} returns.
4846
4847Many closures are used only during the extent of the bindings they
4848refer to; these are known as ``downward funargs'' in Lisp parlance.
4849When a closure is used in this way, regular Emacs Lisp dynamic
4850bindings suffice and will be more efficient than @code{lexical-let}
4851closures:
4852
4853@example
4854(defun add-to-list (x list)
4855 (mapcar (lambda (y) (+ x y))) list)
4856(add-to-list 7 '(1 2 5))
4857 @result{} (8 9 12)
4858@end example
4859
4860@noindent
4861Since this lambda is only used while @code{x} is still bound,
4862it is not necessary to make a true closure out of it.
4863
4864You can use @code{defun} or @code{flet} inside a @code{lexical-let}
4865to create a named closure. If several closures are created in the
4866body of a single @code{lexical-let}, they all close over the same
4867instance of the lexical variable.
4868
4869@defmac lexical-let* (bindings@dots{}) forms@dots{}
4870This form is just like @code{lexical-let}, except that the bindings
4871are made sequentially in the manner of @code{let*}.
4872@end defmac
4873
4874@node Obsolete Lexical Macros
4875@appendixsec Macros Defined Using Lexical-Let
4876
4877The following macros are defined using @code{lexical-let}.
4878They are replaced by versions with a @samp{cl-} prefix that use true
4879lexical binding (and hence rely on @code{lexical-binding} being set to
4880@code{t} in code using them).
4881
4882@defmac flet (bindings@dots{}) forms@dots{}
4883Replaced by @code{cl-flet} (@pxref{Function Bindings})
4884or @code{cl-letf} (@pxref{Modify Macros}).
4885@end defmac
4886
4887@defmac labels (bindings@dots{}) forms@dots{}
4888Replaced by @code{cl-labels} (@pxref{Function Bindings}).
4889@end defmac
4890
4891@defmac letf (bindings@dots{}) forms@dots{}
4892This macro is almost exactly the same as @code{cl-letf}, which
4893replaces it (@pxref{Modify Macros}). The only difference is in
4894details that relate to some deprecated usage of @code{symbol-function}
4895in place forms.
4896@end defmac
4897
4898@node Obsolete Setf Customization
4899@appendixsec Obsolete Ways to Customize Setf
4900
4901Common Lisp defines three macros, @code{define-modify-macro},
4902@code{defsetf}, and @code{define-setf-method}, that allow the
4903user to extend generalized variables in various ways.
4904In Emacs, these are obsolete, replaced by various features of
4905@file{gv.el} in Emacs 24.3.
4906@c FIXME details.
4907
4908@defmac define-modify-macro name arglist function [doc-string]
4909This macro defines a ``read-modify-write'' macro similar to
4910@code{cl-incf} and @code{cl-decf}. The macro @var{name} is defined
4911to take a @var{place} argument followed by additional arguments
4912described by @var{arglist}. The call
4913
4914@example
4915(@var{name} @var{place} @var{args}...)
4916@end example
4917
4918@noindent
4919will be expanded to
4920
4921@example
4922(cl-callf @var{func} @var{place} @var{args}...)
4923@end example
4924
4925@noindent
4926which in turn is roughly equivalent to
4927
4928@example
4929(setf @var{place} (@var{func} @var{place} @var{args}...))
4930@end example
4931
4932For example:
4933
4934@example
4935(define-modify-macro cl-incf (&optional (n 1)) +)
4936(define-modify-macro cl-concatf (&rest args) concat)
4937@end example
4938
4939Note that @code{&key} is not allowed in @var{arglist}, but
4940@code{&rest} is sufficient to pass keywords on to the function.
4941
4942Most of the modify macros defined by Common Lisp do not exactly
4943follow the pattern of @code{define-modify-macro}. For example,
4944@code{push} takes its arguments in the wrong order, and @code{pop}
4945is completely irregular. You can define these macros ``by hand''
4946using @code{get-setf-method}, or consult the source
4947to see how to use the internal @code{setf} building blocks.
4948@end defmac
4949
4950@defmac defsetf access-fn update-fn
4951This is the simpler of two @code{defsetf} forms. Where
4952@var{access-fn} is the name of a function which accesses a place,
4953this declares @var{update-fn} to be the corresponding store
4954function. From now on,
4955
4956@example
4957(setf (@var{access-fn} @var{arg1} @var{arg2} @var{arg3}) @var{value})
4958@end example
4959
4960@noindent
4961will be expanded to
4962
4963@example
4964(@var{update-fn} @var{arg1} @var{arg2} @var{arg3} @var{value})
4965@end example
4966
4967@noindent
4968The @var{update-fn} is required to be either a true function, or
4969a macro which evaluates its arguments in a function-like way. Also,
4970the @var{update-fn} is expected to return @var{value} as its result.
4971Otherwise, the above expansion would not obey the rules for the way
4972@code{setf} is supposed to behave.
4973
4974As a special (non-Common-Lisp) extension, a third argument of @code{t}
4975to @code{defsetf} says that the @code{update-fn}'s return value is
4976not suitable, so that the above @code{setf} should be expanded to
4977something more like
4978
4979@example
4980(let ((temp @var{value}))
4981 (@var{update-fn} @var{arg1} @var{arg2} @var{arg3} temp)
4982 temp)
4983@end example
4984
4985Some examples of the use of @code{defsetf}, drawn from the standard
4986suite of setf methods, are:
4987
4988@example
4989(defsetf car setcar)
4990(defsetf symbol-value set)
4991(defsetf buffer-name rename-buffer t)
4992@end example
4993@end defmac
4994
4995@defmac defsetf access-fn arglist (store-var) forms@dots{}
4996This is the second, more complex, form of @code{defsetf}. It is
4997rather like @code{defmacro} except for the additional @var{store-var}
4998argument. The @var{forms} should return a Lisp form which stores
4999the value of @var{store-var} into the generalized variable formed
5000by a call to @var{access-fn} with arguments described by @var{arglist}.
5001The @var{forms} may begin with a string which documents the @code{setf}
5002method (analogous to the doc string that appears at the front of a
5003function).
5004
5005For example, the simple form of @code{defsetf} is shorthand for
5006
5007@example
5008(defsetf @var{access-fn} (&rest args) (store)
5009 (append '(@var{update-fn}) args (list store)))
5010@end example
5011
5012The Lisp form that is returned can access the arguments from
5013@var{arglist} and @var{store-var} in an unrestricted fashion;
5014macros like @code{setf} and @code{cl-incf} which invoke this
5015setf-method will insert temporary variables as needed to make
5016sure the apparent order of evaluation is preserved.
5017
5018Another example drawn from the standard package:
5019
5020@example
5021(defsetf nth (n x) (store)
5022 (list 'setcar (list 'nthcdr n x) store))
5023@end example
5024@end defmac
5025
5026@defmac define-setf-method access-fn arglist forms@dots{}
5027This is the most general way to create new place forms. When
5028a @code{setf} to @var{access-fn} with arguments described by
5029@var{arglist} is expanded, the @var{forms} are evaluated and
5030must return a list of five items:
5031
5032@enumerate
5033@item
5034A list of @dfn{temporary variables}.
5035
5036@item
5037A list of @dfn{value forms} corresponding to the temporary variables
5038above. The temporary variables will be bound to these value forms
5039as the first step of any operation on the generalized variable.
5040
5041@item
5042A list of exactly one @dfn{store variable} (generally obtained
5043from a call to @code{gensym}).
5044
5045@item
5046A Lisp form which stores the contents of the store variable into
5047the generalized variable, assuming the temporaries have been
5048bound as described above.
5049
5050@item
5051A Lisp form which accesses the contents of the generalized variable,
5052assuming the temporaries have been bound.
5053@end enumerate
5054
5055This is exactly like the Common Lisp macro of the same name,
5056except that the method returns a list of five values rather
5057than the five values themselves, since Emacs Lisp does not
5058support Common Lisp's notion of multiple return values.
5059
5060Once again, the @var{forms} may begin with a documentation string.
5061
5062A setf-method should be maximally conservative with regard to
5063temporary variables. In the setf-methods generated by
5064@code{defsetf}, the second return value is simply the list of
5065arguments in the place form, and the first return value is a
5066list of a corresponding number of temporary variables generated
5067by @code{cl-gensym}. Macros like @code{setf} and @code{cl-incf} which
5068use this setf-method will optimize away most temporaries that
5069turn out to be unnecessary, so there is little reason for the
5070setf-method itself to optimize.
5071@end defmac
5072
5073@defun get-setf-method place &optional env
5074This function returns the setf-method for @var{place}, by
5075invoking the definition previously recorded by @code{defsetf}
5076or @code{define-setf-method}. The result is a list of five
5077values as described above. You can use this function to build
5078your own @code{cl-incf}-like modify macros. (Actually, it is
5079@c FIXME?
5080better to use the internal functions @code{cl-setf-do-modify}
5081and @code{cl-setf-do-store}, which are a bit easier to use and
5082which also do a number of optimizations; consult the source
5083code for the @code{cl-incf} function for a simple example.)
5084
5085The argument @var{env} specifies the ``environment'' to be
5086passed on to @code{macroexpand} if @code{get-setf-method} should
5087need to expand a macro in @var{place}. It should come from
5088an @code{&environment} argument to the macro or setf-method
5089that called @code{get-setf-method}.
5090
5091See also the source code for the setf-method for
5092@c Also @code{apply}, but that is commented out.
5093@code{substring}, which works by calling @code{get-setf-method} on a
5094simpler case, then massaging the result.
5095@end defun
5096
5097Modern Common Lisp defines a second, independent way to specify
5098the @code{setf} behavior of a function, namely ``@code{setf}
5099functions'' whose names are lists @code{(setf @var{name})}
5100rather than symbols. For example, @code{(defun (setf foo) @dots{})}
5101defines the function that is used when @code{setf} is applied to
5102@code{foo}. This package does not currently support @code{setf}
5103functions. In particular, it is a compile-time error to use
5104@code{setf} on a form which has not already been @code{defsetf}'d
5105or otherwise declared; in newer Common Lisps, this would not be
5106an error since the function @code{(setf @var{func})} might be
5107defined later.
5108
5109
5281@node GNU Free Documentation License 5110@node GNU Free Documentation License
5282@appendix GNU Free Documentation License 5111@appendix GNU Free Documentation License
5283@include doclicense.texi 5112@include doclicense.texi
diff --git a/doc/misc/emacs-mime.texi b/doc/misc/emacs-mime.texi
index 896eba2f1bb..e57fcc8adf1 100644
--- a/doc/misc/emacs-mime.texi
+++ b/doc/misc/emacs-mime.texi
@@ -1516,16 +1516,16 @@ Here's a bunch of time/date/second/day examples:
1516@result{} 905595714.0 1516@result{} 905595714.0
1517 1517
1518(seconds-to-time 905595714.0) 1518(seconds-to-time 905595714.0)
1519@result{} (13818 19266 0) 1519@result{} (13818 19266 0 0)
1520 1520
1521(time-to-days '(13818 19266)) 1521(time-to-days '(13818 19266))
1522@result{} 729644 1522@result{} 729644
1523 1523
1524(days-to-time 729644) 1524(days-to-time 729644)
1525@result{} (961933 65536) 1525@result{} (961933 512)
1526 1526
1527(time-since '(13818 19266)) 1527(time-since '(13818 19266))
1528@result{} (0 430) 1528@result{} (6797 9607 984839 247000)
1529 1529
1530(time-less-p '(13818 19266) '(13818 19145)) 1530(time-less-p '(13818 19266) '(13818 19145))
1531@result{} nil 1531@result{} nil
@@ -1546,7 +1546,7 @@ Here's a bunch of time/date/second/day examples:
1546(time-to-number-of-days 1546(time-to-number-of-days
1547 (time-since 1547 (time-since
1548 (date-to-time "Mon, 01 Jan 2001 02:22:26 GMT"))) 1548 (date-to-time "Mon, 01 Jan 2001 02:22:26 GMT")))
1549@result{} 4.146122685185185 1549@result{} 4314.095589286675
1550@end example 1550@end example
1551 1551
1552And finally, we have @code{safe-date-to-time}, which does the same as 1552And finally, we have @code{safe-date-to-time}, which does the same as
@@ -1561,7 +1561,7 @@ An RFC822 (or similar) date string. For instance: @code{"Sat Sep 12
156112:21:54 1998 +0200"}. 156112:21:54 1998 +0200"}.
1562 1562
1563@item time 1563@item time
1564An internal Emacs time. For instance: @code{(13818 26466)}. 1564An internal Emacs time. For instance: @code{(13818 26466 0 0)}.
1565 1565
1566@item seconds 1566@item seconds
1567A floating point representation of the internal Emacs time. For 1567A floating point representation of the internal Emacs time. For
diff --git a/doc/misc/org.texi b/doc/misc/org.texi
index 89c99018460..a69dc0fd81f 100644
--- a/doc/misc/org.texi
+++ b/doc/misc/org.texi
@@ -857,7 +857,7 @@ Theory Ltd.}
857@b{Important:} @i{If you the version of Org that comes with Emacs or as a 857@b{Important:} @i{If you the version of Org that comes with Emacs or as a
858XEmacs package, please skip this section and go directly to @ref{Activation}. 858XEmacs package, please skip this section and go directly to @ref{Activation}.
859If you downloaded Org as an ELPA package, please read the instructions on the 859If you downloaded Org as an ELPA package, please read the instructions on the
860@uref{http://orgmode.org/elpa/, Org ELPA page}. To see what version of Org 860@uref{http://orgmode.org/elpa.html, Org ELPA page}. To see what version of Org
861(if any) is part of your Emacs distribution, type @kbd{M-x org-version} (if 861(if any) is part of your Emacs distribution, type @kbd{M-x org-version} (if
862your Emacs distribution does not come with Org, this function will not be 862your Emacs distribution does not come with Org, this function will not be
863defined).} 863defined).}
@@ -964,13 +964,6 @@ on your system).
964make install-info 964make install-info
965@end example 965@end example
966 966
967Then add the following line to @file{.emacs}. It is needed so that
968Emacs can autoload functions that are located in files not immediately loaded
969when Org mode starts.
970@lisp
971(require 'org-install)
972@end lisp
973
974Do not forget to activate Org as described in the following section. 967Do not forget to activate Org as described in the following section.
975@page 968@page
976 969
@@ -1092,9 +1085,6 @@ shown below.
1092;; add latest org-mode to load path 1085;; add latest org-mode to load path
1093(add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp")) 1086(add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
1094(add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t)) 1087(add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
1095
1096;; activate org
1097(require 'org-install)
1098@end example 1088@end example
1099 1089
1100If an error occurs, a backtrace can be very useful (see below on how to 1090If an error occurs, a backtrace can be very useful (see below on how to
@@ -3785,7 +3775,7 @@ mostly if more than two TODO states are possible (@pxref{TODO
3785extensions}). See also @ref{Conflicts}, for a discussion of the interaction 3775extensions}). See also @ref{Conflicts}, for a discussion of the interaction
3786with @code{shift-selection-mode}. See also the variable 3776with @code{shift-selection-mode}. See also the variable
3787@code{org-treat-S-cursor-todo-selection-as-state-change}. 3777@code{org-treat-S-cursor-todo-selection-as-state-change}.
3788@orgcmd{C-c / t,org-show-todo-key} 3778@orgcmd{C-c / t,org-show-todo-tree}
3789@cindex sparse tree, for TODO 3779@cindex sparse tree, for TODO
3790@vindex org-todo-keywords 3780@vindex org-todo-keywords
3791View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}). Folds the 3781View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}). Folds the
@@ -9386,16 +9376,16 @@ so often, shortcuts are provided using the Easy Templates facility
9386@item C-c ' 9376@item C-c '
9387Edit the source code example at point in its native mode. This works by 9377Edit the source code example at point in its native mode. This works by
9388switching to a temporary buffer with the source code. You need to exit by 9378switching to a temporary buffer with the source code. You need to exit by
9389pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*} 9379pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*},
9390or @samp{#} will get a comma prepended, to keep them from being interpreted 9380@samp{,*}, @samp{#+} and @samp{,#+} will get a comma prepended, to keep them
9391by Org as outline nodes or special comments. These commas will be stripped 9381from being interpreted by Org as outline nodes or special syntax. These
9392for editing with @kbd{C-c '}, and also for export.}. The edited version will 9382commas will be stripped for editing with @kbd{C-c '}, and also for export.}.
9393then replace the old version in the Org buffer. Fixed-width regions 9383The edited version will then replace the old version in the Org buffer.
9394(where each line starts with a colon followed by a space) will be edited 9384Fixed-width regions (where each line starts with a colon followed by a space)
9395using @code{artist-mode}@footnote{You may select a different-mode with the 9385will be edited using @code{artist-mode}@footnote{You may select
9396variable @code{org-edit-fixed-width-region-mode}.} to allow creating ASCII 9386a different-mode with the variable @code{org-edit-fixed-width-region-mode}.}
9397drawings easily. Using this command in an empty line will create a new 9387to allow creating ASCII drawings easily. Using this command in an empty line
9398fixed-width region. 9388will create a new fixed-width region.
9399@kindex C-c l 9389@kindex C-c l
9400@item C-c l 9390@item C-c l
9401Calling @code{org-store-link} while editing a source code example in a 9391Calling @code{org-store-link} while editing a source code example in a
@@ -14523,14 +14513,13 @@ Be sure to adjust the paths to fit your system.
14523# 14513#
14524DIR=`pwd` 14514DIR=`pwd`
14525FILES="" 14515FILES=""
14526ORGINSTALL="~/src/org/lisp/org-install.el"
14527 14516
14528# wrap each argument in the code required to call tangle on it 14517# wrap each argument in the code required to call tangle on it
14529for i in $@@; do 14518for i in $@@; do
14530 FILES="$FILES \"$i\"" 14519 FILES="$FILES \"$i\""
14531done 14520done
14532 14521
14533emacs -Q --batch -l $ORGINSTALL \ 14522emacs -Q --batch \
14534--eval "(progn 14523--eval "(progn
14535(add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\")) 14524(add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\"))
14536(add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\" t)) 14525(add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\" t))
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 46f99acbb87..a983f76ffd3 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -2918,7 +2918,8 @@ information about remote hosts is kept in the file specified in
2918@code{tramp-persistency-file-name}. Keep this file. If you are 2918@code{tramp-persistency-file-name}. Keep this file. If you are
2919confident that files on remote hosts are not changed out of 2919confident that files on remote hosts are not changed out of
2920@value{emacsname}' control, set @code{remote-file-name-inhibit-cache} 2920@value{emacsname}' control, set @code{remote-file-name-inhibit-cache}
2921to @code{nil}. 2921to @code{nil}. Set also @code{tramp-completion-reread-directory-timeout}
2922to @code{nil}, @ref{Filename completion}.
2922 2923
2923Disable version control. If you access remote files which are not 2924Disable version control. If you access remote files which are not
2924under version control, a lot of check operations can be avoided by 2925under version control, a lot of check operations can be avoided by