Mercurial > emacs
annotate lispref/intro.texi @ 40171:91eda91380cb
New scaling algorithm for vc-annotate.
From JD Smith <jdsmith@astro.cornell.edu>.
(vc-cvs-annotate-difference): Removed to generic
version in vc.el, with
(vc-cvs-annotate-current-time): Added, as override of default.
(vc-cvs-annotate-time) Added. Taken mostly from the (now removed)
`vc-cvs-annotate-difference'.
author | André Spiegel <spiegel@gnu.org> |
---|---|
date | Mon, 22 Oct 2001 07:57:00 +0000 |
parents | 8bf2f6940b14 |
children | 8154a8684502 |
rev | line source |
---|---|
6453 | 1 @c -*-texinfo-*- |
2 @c This is part of the GNU Emacs Lisp Reference Manual. | |
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | |
4 @c See the file elisp.texi for copying conditions. | |
5 @setfilename ../info/intro | |
6 | |
39994
8bf2f6940b14
(VERSION): Add and use it where the the version
Gerd Moellmann <gerd@gnu.org>
parents:
36986
diff
changeset
|
7 @c Versino of the manual. |
8bf2f6940b14
(VERSION): Add and use it where the the version
Gerd Moellmann <gerd@gnu.org>
parents:
36986
diff
changeset
|
8 @set VERSION 2.8 |
8bf2f6940b14
(VERSION): Add and use it where the the version
Gerd Moellmann <gerd@gnu.org>
parents:
36986
diff
changeset
|
9 |
29256 | 10 @node Introduction, Lisp Data Types, Top, Top |
6453 | 11 @comment node-name, next, previous, up |
12 @chapter Introduction | |
13 | |
14 Most of the GNU Emacs text editor is written in the programming | |
15 language called Emacs Lisp. You can write new code in Emacs Lisp and | |
16 install it as an extension to the editor. However, Emacs Lisp is more | |
17 than a mere ``extension language''; it is a full computer programming | |
18 language in its own right. You can use it as you would any other | |
19 programming language. | |
20 | |
21 Because Emacs Lisp is designed for use in an editor, it has special | |
22 features for scanning and parsing text as well as features for handling | |
23 files, buffers, displays, subprocesses, and so on. Emacs Lisp is | |
24 closely integrated with the editing facilities; thus, editing commands | |
25 are functions that can also conveniently be called from Lisp programs, | |
26 and parameters for customization are ordinary Lisp variables. | |
27 | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
28 This manual attempts to be a full description of Emacs Lisp. For a |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
29 beginner's introduction to Emacs Lisp, see @cite{An Introduction to |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
30 Emacs Lisp Programming}, by Bob Chassell, also published by the Free |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
31 Software Foundation. This manual presumes considerable familiarity with |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
32 the use of Emacs for editing; see @cite{The GNU Emacs Manual} for this |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
33 basic information. |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
34 |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
35 Generally speaking, the earlier chapters describe features of Emacs |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
36 Lisp that have counterparts in many programming languages, and later |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
37 chapters describe features that are peculiar to Emacs Lisp or relate |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
38 specifically to editing. |
6453 | 39 |
39994
8bf2f6940b14
(VERSION): Add and use it where the the version
Gerd Moellmann <gerd@gnu.org>
parents:
36986
diff
changeset
|
40 This is edition @value{VERSION}. |
6453 | 41 |
42 @menu | |
43 * Caveats:: Flaws and a request for help. | |
44 * Lisp History:: Emacs Lisp is descended from Maclisp. | |
45 * Conventions:: How the manual is formatted. | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
46 * Version Info:: Which Emacs version is running? |
6453 | 47 * Acknowledgements:: The authors, editors, and sponsors of this manual. |
48 @end menu | |
49 | |
50 @node Caveats | |
51 @section Caveats | |
52 | |
53 This manual has gone through numerous drafts. It is nearly complete | |
7114 | 54 but not flawless. There are a few topics that are not covered, either |
55 because we consider them secondary (such as most of the individual | |
56 modes) or because they are yet to be written. Because we are not able | |
57 to deal with them completely, we have left out several parts | |
58 intentionally. This includes most information about usage on VMS. | |
6453 | 59 |
60 The manual should be fully correct in what it does cover, and it is | |
61 therefore open to criticism on anything it says---from specific examples | |
62 and descriptive text, to the ordering of chapters and sections. If | |
63 something is confusing, or you find that you have to look at the sources | |
64 or experiment to learn something not covered in the manual, then perhaps | |
65 the manual should be fixed. Please let us know. | |
66 | |
67 @iftex | |
25875 | 68 As you use this manual, we ask that you mark pages with corrections so |
69 you can later look them up and send them to us. If you think of a simple, | |
7114 | 70 real-life example for a function or group of functions, please make an |
6453 | 71 effort to write it up and send it in. Please reference any comments to |
72 the chapter name, section name, and function name, as appropriate, since | |
7114 | 73 page numbers and chapter and section numbers will change and we may have |
74 trouble finding the text you are talking about. Also state the number | |
75 of the edition you are criticizing. | |
6453 | 76 @end iftex |
27193 | 77 @ifnottex |
6453 | 78 |
79 As you use this manual, we ask that you send corrections as soon as you | |
80 find them. If you think of a simple, real life example for a function | |
81 or group of functions, please make an effort to write it up and send it | |
82 in. Please reference any comments to the node name and function or | |
83 variable name, as appropriate. Also state the number of the edition | |
25875 | 84 you are criticizing. |
27193 | 85 @end ifnottex |
6453 | 86 |
87 Please mail comments and corrections to | |
88 | |
89 @example | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
90 bug-lisp-manual@@gnu.org |
6453 | 91 @end example |
92 | |
93 @noindent | |
94 We let mail to this list accumulate unread until someone decides to | |
95 apply the corrections. Months, and sometimes years, go by between | |
96 updates. So please attach no significance to the lack of a reply---your | |
97 mail @emph{will} be acted on in due time. If you want to contact the | |
98 Emacs maintainers more quickly, send mail to | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
99 @code{bug-gnu-emacs@@gnu.org}. |
6453 | 100 |
101 @node Lisp History | |
102 @section Lisp History | |
103 @cindex Lisp history | |
104 | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
105 Lisp (LISt Processing language) was first developed in the late 1950s |
6453 | 106 at the Massachusetts Institute of Technology for research in artificial |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
107 intelligence. The great power of the Lisp language makes it ideal |
6453 | 108 for other purposes as well, such as writing editing commands. |
109 | |
110 @cindex Maclisp | |
111 @cindex Common Lisp | |
112 Dozens of Lisp implementations have been built over the years, each | |
113 with its own idiosyncrasies. Many of them were inspired by Maclisp, | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
114 which was written in the 1960s at MIT's Project MAC. Eventually the |
7114 | 115 implementors of the descendants of Maclisp came together and developed a |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
116 standard for Lisp systems, called Common Lisp. In the meantime, Gerry |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
117 Sussman and Guy Steele at MIT developed a simplified but very powerful |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
118 dialect of Lisp, called Scheme. |
6453 | 119 |
120 GNU Emacs Lisp is largely inspired by Maclisp, and a little by Common | |
121 Lisp. If you know Common Lisp, you will notice many similarities. | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
122 However, many features of Common Lisp have been omitted or |
6453 | 123 simplified in order to reduce the memory requirements of GNU Emacs. |
124 Sometimes the simplifications are so drastic that a Common Lisp user | |
125 might be very confused. We will occasionally point out how GNU Emacs | |
126 Lisp differs from Common Lisp. If you don't know Common Lisp, don't | |
127 worry about it; this manual is self-contained. | |
128 | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
129 @pindex cl |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
130 A certain amount of Common Lisp emulation is available via the |
25751
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
131 @file{cl} library. @xref{Top,, Common Lisp Extension, cl, Common Lisp |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
132 Extensions}. |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
133 |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
134 Emacs Lisp is not at all influenced by Scheme; but the GNU project has |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
135 an implementation of Scheme, called Guile. We use Guile in all new GNU |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
136 software that calls for extensibility. |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
137 |
6453 | 138 @node Conventions |
139 @section Conventions | |
140 | |
141 This section explains the notational conventions that are used in this | |
142 manual. You may want to skip this section and refer back to it later. | |
143 | |
144 @menu | |
145 * Some Terms:: Explanation of terms we use in this manual. | |
146 * nil and t:: How the symbols @code{nil} and @code{t} are used. | |
147 * Evaluation Notation:: The format we use for examples of evaluation. | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
148 * Printing Notation:: The format we use when examples print text. |
6453 | 149 * Error Messages:: The format we use for examples of errors. |
150 * Buffer Text Notation:: The format we use for buffer contents in examples. | |
151 * Format of Descriptions:: Notation for describing functions, variables, etc. | |
152 @end menu | |
153 | |
154 @node Some Terms | |
155 @subsection Some Terms | |
156 | |
157 Throughout this manual, the phrases ``the Lisp reader'' and ``the Lisp | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
158 printer'' refer to those routines in Lisp that convert textual |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
159 representations of Lisp objects into actual Lisp objects, and vice |
6453 | 160 versa. @xref{Printed Representation}, for more details. You, the |
161 person reading this manual, are thought of as ``the programmer'' and are | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
162 addressed as ``you''. ``The user'' is the person who uses Lisp |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
163 programs, including those you write. |
6453 | 164 |
165 @cindex fonts | |
25751
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
166 Examples of Lisp code are formatted like this: @code{(list 1 2 3)}. |
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
167 Names that represent metasyntactic variables, or arguments to a function |
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
168 being described, are formatted like this: @var{first-number}. |
6453 | 169 |
170 @node nil and t | |
171 @subsection @code{nil} and @code{t} | |
172 @cindex @code{nil}, uses of | |
173 @cindex truth value | |
174 @cindex boolean | |
175 @cindex false | |
176 | |
12098 | 177 In Lisp, the symbol @code{nil} has three separate meanings: it |
6453 | 178 is a symbol with the name @samp{nil}; it is the logical truth value |
179 @var{false}; and it is the empty list---the list of zero elements. | |
180 When used as a variable, @code{nil} always has the value @code{nil}. | |
181 | |
182 As far as the Lisp reader is concerned, @samp{()} and @samp{nil} are | |
183 identical: they stand for the same object, the symbol @code{nil}. The | |
184 different ways of writing the symbol are intended entirely for human | |
185 readers. After the Lisp reader has read either @samp{()} or @samp{nil}, | |
186 there is no way to determine which representation was actually written | |
187 by the programmer. | |
188 | |
189 In this manual, we use @code{()} when we wish to emphasize that it | |
190 means the empty list, and we use @code{nil} when we wish to emphasize | |
191 that it means the truth value @var{false}. That is a good convention to use | |
192 in Lisp programs also. | |
193 | |
194 @example | |
195 (cons 'foo ()) ; @r{Emphasize the empty list} | |
196 (not nil) ; @r{Emphasize the truth value @var{false}} | |
197 @end example | |
198 | |
199 @cindex @code{t} and truth | |
200 @cindex true | |
201 In contexts where a truth value is expected, any non-@code{nil} value | |
202 is considered to be @var{true}. However, @code{t} is the preferred way | |
203 to represent the truth value @var{true}. When you need to choose a | |
204 value which represents @var{true}, and there is no other basis for | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
205 choosing, use @code{t}. The symbol @code{t} always has the value |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
206 @code{t}. |
6453 | 207 |
208 In Emacs Lisp, @code{nil} and @code{t} are special symbols that always | |
209 evaluate to themselves. This is so that you do not need to quote them | |
210 to use them as constants in a program. An attempt to change their | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
211 values results in a @code{setting-constant} error. The same is true of |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
212 any symbol whose name starts with a colon (@samp{:}). @xref{Constant |
6453 | 213 Variables}. |
214 | |
215 @node Evaluation Notation | |
216 @subsection Evaluation Notation | |
217 @cindex evaluation notation | |
218 @cindex documentation notation | |
219 | |
220 A Lisp expression that you can evaluate is called a @dfn{form}. | |
221 Evaluating a form always produces a result, which is a Lisp object. In | |
222 the examples in this manual, this is indicated with @samp{@result{}}: | |
223 | |
224 @example | |
225 (car '(1 2)) | |
226 @result{} 1 | |
227 @end example | |
228 | |
229 @noindent | |
230 You can read this as ``@code{(car '(1 2))} evaluates to 1''. | |
231 | |
232 When a form is a macro call, it expands into a new form for Lisp to | |
233 evaluate. We show the result of the expansion with | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
234 @samp{@expansion{}}. We may or may not show the result of the |
6453 | 235 evaluation of the expanded form. |
236 | |
237 @example | |
238 (third '(a b c)) | |
239 @expansion{} (car (cdr (cdr '(a b c)))) | |
240 @result{} c | |
241 @end example | |
242 | |
7114 | 243 Sometimes to help describe one form we show another form that |
6453 | 244 produces identical results. The exact equivalence of two forms is |
245 indicated with @samp{@equiv{}}. | |
246 | |
247 @example | |
248 (make-sparse-keymap) @equiv{} (list 'keymap) | |
249 @end example | |
250 | |
251 @node Printing Notation | |
252 @subsection Printing Notation | |
253 @cindex printing notation | |
254 | |
255 Many of the examples in this manual print text when they are | |
7114 | 256 evaluated. If you execute example code in a Lisp Interaction buffer |
257 (such as the buffer @samp{*scratch*}), the printed text is inserted into | |
258 the buffer. If you execute the example by other means (such as by | |
259 evaluating the function @code{eval-region}), the printed text is | |
26288 | 260 displayed in the echo area. |
6453 | 261 |
262 Examples in this manual indicate printed text with @samp{@print{}}, | |
263 irrespective of where that text goes. The value returned by evaluating | |
264 the form (here @code{bar}) follows on a separate line. | |
265 | |
266 @example | |
267 @group | |
268 (progn (print 'foo) (print 'bar)) | |
269 @print{} foo | |
270 @print{} bar | |
271 @result{} bar | |
272 @end group | |
273 @end example | |
274 | |
275 @node Error Messages | |
276 @subsection Error Messages | |
277 @cindex error message notation | |
278 | |
279 Some examples signal errors. This normally displays an error message | |
280 in the echo area. We show the error message on a line starting with | |
281 @samp{@error{}}. Note that @samp{@error{}} itself does not appear in | |
282 the echo area. | |
283 | |
284 @example | |
285 (+ 23 'x) | |
21007
66d807bdc5b4
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
12282
diff
changeset
|
286 @error{} Wrong type argument: number-or-marker-p, x |
6453 | 287 @end example |
288 | |
289 @node Buffer Text Notation | |
290 @subsection Buffer Text Notation | |
291 @cindex buffer text notation | |
292 | |
25751
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
293 Some examples describe modifications to the contents of a buffer, by |
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
294 showing the ``before'' and ``after'' versions of the text. These |
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
295 examples show the contents of the buffer in question between two lines |
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
296 of dashes containing the buffer name. In addition, @samp{@point{}} |
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
297 indicates the location of point. (The symbol for point, of course, is |
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
298 not part of the text in the buffer; it indicates the place |
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
299 @emph{between} two characters where point is currently located.) |
6453 | 300 |
301 @example | |
302 ---------- Buffer: foo ---------- | |
303 This is the @point{}contents of foo. | |
304 ---------- Buffer: foo ---------- | |
305 | |
306 (insert "changed ") | |
307 @result{} nil | |
308 ---------- Buffer: foo ---------- | |
309 This is the changed @point{}contents of foo. | |
310 ---------- Buffer: foo ---------- | |
311 @end example | |
312 | |
313 @node Format of Descriptions | |
314 @subsection Format of Descriptions | |
315 @cindex description format | |
316 | |
317 Functions, variables, macros, commands, user options, and special | |
318 forms are described in this manual in a uniform format. The first | |
319 line of a description contains the name of the item followed by its | |
320 arguments, if any. | |
27193 | 321 @ifnottex |
6453 | 322 The category---function, variable, or whatever---appears at the |
323 beginning of the line. | |
27193 | 324 @end ifnottex |
6453 | 325 @iftex |
326 The category---function, variable, or whatever---is printed next to the | |
327 right margin. | |
328 @end iftex | |
329 The description follows on succeeding lines, sometimes with examples. | |
330 | |
331 @menu | |
332 * A Sample Function Description:: A description of an imaginary | |
333 function, @code{foo}. | |
334 * A Sample Variable Description:: A description of an imaginary | |
335 variable, | |
336 @code{electric-future-map}. | |
337 @end menu | |
338 | |
339 @node A Sample Function Description | |
340 @subsubsection A Sample Function Description | |
341 @cindex function descriptions | |
342 @cindex command descriptions | |
343 @cindex macro descriptions | |
344 @cindex special form descriptions | |
345 | |
346 In a function description, the name of the function being described | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
347 appears first. It is followed on the same line by a list of argument |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
348 names. These names are also used in the body of the description, to |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
349 stand for the values of the arguments. |
6453 | 350 |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
351 The appearance of the keyword @code{&optional} in the argument list |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
352 indicates that the subsequent arguments may be omitted (omitted |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
353 arguments default to @code{nil}). Do not write @code{&optional} when |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
354 you call the function. |
6453 | 355 |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
356 The keyword @code{&rest} (which must be followed by a single argument |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
357 name) indicates that any number of arguments can follow. The single |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
358 following argument name will have a value, as a variable, which is a |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
359 list of all these remaining arguments. Do not write @code{&rest} when |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
360 you call the function. |
6453 | 361 |
362 Here is a description of an imaginary function @code{foo}: | |
363 | |
364 @defun foo integer1 &optional integer2 &rest integers | |
365 The function @code{foo} subtracts @var{integer1} from @var{integer2}, | |
366 then adds all the rest of the arguments to the result. If @var{integer2} | |
367 is not supplied, then the number 19 is used by default. | |
368 | |
369 @example | |
370 (foo 1 5 3 9) | |
371 @result{} 16 | |
372 (foo 5) | |
373 @result{} 14 | |
374 @end example | |
375 | |
22274
f0cd03a7dac9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22252
diff
changeset
|
376 @need 1500 |
6453 | 377 More generally, |
378 | |
379 @example | |
380 (foo @var{w} @var{x} @var{y}@dots{}) | |
381 @equiv{} | |
382 (+ (- @var{x} @var{w}) @var{y}@dots{}) | |
383 @end example | |
384 @end defun | |
385 | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
386 Any argument whose name contains the name of a type (e.g., |
6453 | 387 @var{integer}, @var{integer1} or @var{buffer}) is expected to be of that |
388 type. A plural of a type (such as @var{buffers}) often means a list of | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
389 objects of that type. Arguments named @var{object} may be of any type. |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
390 (@xref{Lisp Data Types}, for a list of Emacs object types.) Arguments |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
391 with other sorts of names (e.g., @var{new-file}) are discussed |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
392 specifically in the description of the function. In some sections, |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
393 features common to the arguments of several functions are described at |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
394 the beginning. |
6453 | 395 |
396 @xref{Lambda Expressions}, for a more complete description of optional | |
397 and rest arguments. | |
398 | |
399 Command, macro, and special form descriptions have the same format, | |
400 but the word `Function' is replaced by `Command', `Macro', or `Special | |
401 Form', respectively. Commands are simply functions that may be called | |
402 interactively; macros process their arguments differently from functions | |
403 (the arguments are not evaluated), but are presented the same way. | |
404 | |
405 Special form descriptions use a more complex notation to specify | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
406 optional and repeated arguments because they can break the argument |
6453 | 407 list down into separate arguments in more complicated ways. |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
408 @samp{@r{[}@var{optional-arg}@r{]}} means that @var{optional-arg} is |
6453 | 409 optional and @samp{@var{repeated-args}@dots{}} stands for zero or more |
410 arguments. Parentheses are used when several arguments are grouped into | |
411 additional levels of list structure. Here is an example: | |
412 | |
413 @defspec count-loop (@var{var} [@var{from} @var{to} [@var{inc}]]) @var{body}@dots{} | |
414 This imaginary special form implements a loop that executes the | |
415 @var{body} forms and then increments the variable @var{var} on each | |
416 iteration. On the first iteration, the variable has the value | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
417 @var{from}; on subsequent iterations, it is incremented by one (or by |
6453 | 418 @var{inc} if that is given). The loop exits before executing @var{body} |
419 if @var{var} equals @var{to}. Here is an example: | |
420 | |
421 @example | |
422 (count-loop (i 0 10) | |
423 (prin1 i) (princ " ") | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
424 (prin1 (aref vector i)) |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
425 (terpri)) |
6453 | 426 @end example |
427 | |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
428 If @var{from} and @var{to} are omitted, @var{var} is bound to |
6453 | 429 @code{nil} before the loop begins, and the loop exits if @var{var} is |
430 non-@code{nil} at the beginning of an iteration. Here is an example: | |
431 | |
432 @example | |
433 (count-loop (done) | |
434 (if (pending) | |
435 (fixit) | |
436 (setq done t))) | |
437 @end example | |
438 | |
439 In this special form, the arguments @var{from} and @var{to} are | |
440 optional, but must both be present or both absent. If they are present, | |
441 @var{inc} may optionally be specified as well. These arguments are | |
442 grouped with the argument @var{var} into a list, to distinguish them | |
443 from @var{body}, which includes all remaining elements of the form. | |
444 @end defspec | |
445 | |
446 @node A Sample Variable Description | |
447 @subsubsection A Sample Variable Description | |
448 @cindex variable descriptions | |
449 @cindex option descriptions | |
450 | |
451 A @dfn{variable} is a name that can hold a value. Although any | |
452 variable can be set by the user, certain variables that exist | |
453 specifically so that users can change them are called @dfn{user | |
454 options}. Ordinary variables and user options are described using a | |
455 format like that for functions except that there are no arguments. | |
456 | |
457 Here is a description of the imaginary @code{electric-future-map} | |
458 variable.@refill | |
459 | |
460 @defvar electric-future-map | |
461 The value of this variable is a full keymap used by Electric Command | |
462 Future mode. The functions in this map allow you to edit commands you | |
463 have not yet thought about executing. | |
464 @end defvar | |
465 | |
466 User option descriptions have the same format, but `Variable' is | |
467 replaced by `User Option'. | |
468 | |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
469 @node Version Info |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
470 @section Version Information |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
471 |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
472 These facilities provide information about which version of Emacs is |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
473 in use. |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
474 |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
475 @deffn Command emacs-version |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
476 This function returns a string describing the version of Emacs that is |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
477 running. It is useful to include this string in bug reports. |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
478 |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
479 @smallexample |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
480 @group |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
481 (emacs-version) |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
482 @result{} "GNU Emacs 20.3.5 (i486-pc-linux-gnulibc1, X toolkit) |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
483 of Sat Feb 14 1998 on psilocin.gnu.org" |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
484 @end group |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
485 @end smallexample |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
486 |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
487 Called interactively, the function prints the same information in the |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
488 echo area. |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
489 @end deffn |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
490 |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
491 @defvar emacs-build-time |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
492 The value of this variable indicates the time at which Emacs was built |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
493 at the local site. It is a list of three integers, like the value |
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
494 of @code{current-time} (@pxref{Time of Day}). |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
495 |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
496 @example |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
497 @group |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
498 emacs-build-time |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
499 @result{} (13623 62065 344633) |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
500 @end group |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
501 @end example |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
502 @end defvar |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
503 |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
504 @defvar emacs-version |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
505 The value of this variable is the version of Emacs being run. It is a |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
506 string such as @code{"20.3.1"}. The last number in this string is not |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
507 really part of the Emacs release version number; it is incremented each |
36986 | 508 time you build Emacs in any given directory. A value with four numeric |
25751
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
509 components, such as @code{"20.3.9.1"}, indicates an unreleased test |
467b88fab665
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
22366
diff
changeset
|
510 version. |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
511 @end defvar |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
512 |
22138
d4ac295a98b3
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21682
diff
changeset
|
513 The following two variables have existed since Emacs version 19.23: |
21682
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
514 |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
515 @defvar emacs-major-version |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
516 The major version number of Emacs, as an integer. For Emacs version |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
517 20.3, the value is 20. |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
518 @end defvar |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
519 |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
520 @defvar emacs-minor-version |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
521 The minor version number of Emacs, as an integer. For Emacs version |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
522 20.3, the value is 3. |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
523 @end defvar |
90da2489c498
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
21007
diff
changeset
|
524 |
6453 | 525 @node Acknowledgements |
526 @section Acknowledgements | |
527 | |
528 This manual was written by Robert Krawitz, Bil Lewis, Dan LaLiberte, | |
529 Richard M. Stallman and Chris Welty, the volunteers of the GNU manual | |
530 group, in an effort extending over several years. Robert J. Chassell | |
531 helped to review and edit the manual, with the support of the Defense | |
532 Advanced Research Projects Agency, ARPA Order 6082, arranged by Warren | |
25875 | 533 A. Hunt, Jr.@: of Computational Logic, Inc. |
6453 | 534 |
535 Corrections were supplied by Karl Berry, Jim Blandy, Bard Bloom, | |
536 Stephane Boucher, David Boyes, Alan Carroll, Richard Davis, Lawrence | |
537 R. Dodd, Peter Doornbosch, David A. Duff, Chris Eich, Beverly | |
538 Erlebacher, David Eckelkamp, Ralf Fassel, Eirik Fuller, Stephen Gildea, | |
539 Bob Glickstein, Eric Hanchrow, George Hartzell, Nathan Hess, Masayuki | |
540 Ida, Dan Jacobson, Jak Kirman, Bob Knighten, Frederick M. Korz, Joe | |
541 Lammens, Glenn M. Lewis, K. Richard Magill, Brian Marick, Roland | |
542 McGrath, Skip Montanaro, John Gardiner Myers, Thomas A. Peterson, | |
543 Francesco Potorti, Friedrich Pukelsheim, Arnold D. Robbins, Raul | |
25875 | 544 Rockwell, Per Starb@"ack, Shinichirou Sugou, Kimmo Suominen, Edward Tharp, |
6453 | 545 Bill Trost, Rickard Westman, Jean White, Matthew Wilding, Carl Witty, |
546 Dale Worley, Rusty Wright, and David D. Zuhn. |