|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T i
Length: 27733 (0x6c55) Types: TextFile Names: »intro.texinfo«
└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89 └─⟦c06c473ab⟧ »./UNRELEASED/lispref.tar.Z« └─⟦1b57a2ffe⟧ └─⟦this⟧ »intro.texinfo«
@setfilename ../info/intro @node License, Introduction, Top, Top @comment node-name, next, previous, up @unnumbered GNU GENERAL PUBLIC LICENSE @center Version 1, February 1989 @display Copyright @copyright{} 1989 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @end display @unnumberedsec Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software---to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. @iftex @unnumberedsec TERMS AND CONDITIONS @end iftex @ifinfo @center TERMS AND CONDITIONS @end ifinfo @enumerate @item This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The ``Program'', below, refers to any such program or work, and a ``work based on the Program'' means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as ``you''. @item You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. @item You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: @itemize @bullet @item cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and @item cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). @item If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. @item You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. @end itemize Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. @item You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: @itemize @bullet @item accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, @item accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, @item accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) @end itemize Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. @item You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. @item By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. @item Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. @item The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and ``any later version'', you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. @item If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. @iftex @heading NO WARRANTY @end iftex @ifinfo @center NO WARRANTY @end ifinfo @item BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. @item IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. @end enumerate @iftex @heading END OF TERMS AND CONDITIONS @end iftex @ifinfo @center END OF TERMS AND CONDITIONS @end ifinfo @page @unnumberedsec Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the ``copyright'' line and a pointer to where the full notice is found. @smallexample @var{one line to give the program's name and a brief idea of what it does.} Copyright (C) 19@var{yy} @var{name of author} This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @end smallexample Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: @smallexample Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @end smallexample The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items---whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a ``copyright disclaimer'' for the program, if necessary. Here a sample; alter the names: @example Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. @var{signature of Ty Coon}, 1 April 1989 Ty Coon, President of Vice @end example That's all there is to it! @node Introduction, Types of Lisp Object, License, Top @chapter Introduction The greater part of the GNU Emacs text editor is written in the programming language called Emacs Lisp. You can write new code in Emacs Lisp and install it as an extension to the editor. At the same time, Emacs Lisp is more than a mere `extension language'; it is a full computer programming language in its own right. You can use it as you would any other programming language. Because Emacs Lisp is designed for use in an editor, it has special features for handling different kinds of text---plain text, marked-up manuscripts, source code, mail, and the like---as well as for handling files, buffers, displays, subprocesses, and so on. This manual describes Emacs Lisp. Generally speaking, the first part of the manual describes those features of Emacs Lisp that are shared by all programming languages, and the latter part describes those features that are special. @menu * Caveats:: Flaws and a request for help. * Lisp History:: Emacs Lisp is descended from MacLisp. * Conventions:: How the manual is formatted. @end menu @node Caveats, Lisp History, Introduction, Introduction @section Caveats This manual has gone through numerous drafts. It is nearly complete but not flawless. There are a few sections which are not included, either because we consider them secondary (such as most of the individual modes) or because they are yet to be written. Because we are not able to deal with them completely, we have left out several parts intentionally. This includes most references to VMS and all the Suntool and X related items. The manual should, however, be fully correct in what it does say; and it is therefore open to criticism on anything it does include---from specific examples and descriptive text, to the ordering of chapters and sections. If something is confusing, or you find that you have to look at the sources or experiment to learn something not covered in the manual, then perhaps the manual should be fixed. Please let us know. @iftex As you use the manual, we ask that you mark pages with corrections so you can later look them up and send them in. If you think of a simple, real life example for a function or group of functions, please make an effort to write it up and send it in. Please reference any comments to the chapter name, section name, and function name, as appropriate, since page numbers and chapter and section numbers will change. @end iftex @ifinfo As you use this manual in Info, we ask that you send corrections as soon as you find them. If you think of a simple, real life example for a function or group of functions, please make an effort to write it up and send it in. Please reference any comments to the node name and function or variable name, as appropriate. @end ifinfo Mail comments and corrections to lisp-manual-bugs@@prep.ai.mit.edu. @noindent @example --Bil Lewis 31-Oct-87 --Dan LaLiberte 01-Apr-89 @end example @node Lisp History, Conventions, Caveats, Introduction @section Lisp History @cindex Lisp history Lisp (LISt Processing Language) was first developed in the late 1950s at the Massachusetts Institute of Technology for research in artificial intelligence. The great power of the Lisp language makes it superior for other purposes as well, such as writing editor commands. @cindex MacLisp @cindex Common Lisp Dozens of Lisp implementations have been built over the years, each with its own idiosyncrasies. Many of them were inspired by MacLisp, which was written in the 1960's at MIT's Project MAC. Eventually the implementors of the descendents of MacLisp came together and developed a standard for Lisp systems, called Common Lisp. GNU Emacs Lisp is largely inspired by MacLisp, and a little by Common Lisp. If you know Common Lisp, you will notice many similarities. But many of the features of Common Lisp have been omitted or simplified in order to reduce the memory requirements of GNU Emacs. Sometimes the simplifications are so drastic that a Common Lisp user might be very confused. We will occasionally point out how GNU Emacs Lisp differs from Common Lisp. If you don't know Common Lisp, don't worry about it; this manual is self-contained. @node Conventions, , Lisp History, Introduction @section Conventions This section explains the notational conventions that are used in this manual. You may want to skip this section and refer back to it later. @menu * Some Terms:: * nil and t:: * Evaluation Notation:: * Printing Notation:: * Error Messages:: * Buffer Text Notation:: * Format of Descriptions:: @end menu @node Some Terms, nil and t, Conventions, Conventions @subsection Some Terms Throughout this manual, the phrases ``the Lisp reader'' and ``the Lisp printer'' are used to refer to those routines in Lisp that read expressions and print text. @xref{Print Representation and Read Syntax}, for more details. You, the person reading this manual, are assumed to be ``the programmer'' and you may be referred to as ``you''. ``The user'' is the person who uses the code that you write. @node nil and t, Evaluation Notation, Some Terms, Conventions @subsection nil and t @cindex truth value @cindex boolean @vindex nil @vindex t In GNU Emacs Lisp, the symbol @code{nil} is overloaded with three meanings: it is a symbol with the name @samp{nil}; it is the logical truth value @dfn{false}; and it is the empty list---the list of zero elements. As far as the Lisp reader is concerned, @samp{()} and @code{nil} are identical. The Lisp reader interprets them the same way. The different ways of writing them are intented entirely for the human reader. After the Lisp reader has read either @samp{()} or @samp{nil}, there is no way to determine which representation was actually written by the programmer. Throughout this manual, we use @code{()} when we wish to emphasize that it means the empty list, and we use @code{nil} when we wish to emphasize that it means the truth value false. @example (cons 'foo ()) ; @r{Emphasize the empty list} (not nil) ; @r{Emphasize the truth value false} @end example The symbol @code{t} always has only one meaning, the value @code{t}. It is the preferred way to represent the truth value @dfn{true}, although any non-@code{nil} value is considered to be true as well. In Emacs Lisp, @code{nil} and @code{t} are special symbols that always evaluate to themselves. An attempt to change their values results in a @code{setting-constant} error. @node Evaluation Notation, Printing Notation, nil and t, Conventions @subsection Evaluation Notation @cindex evaluation notation @cindex documentation notation When you evaluate a piece of Lisp code, it produces a result. In the examples in this manual, this will be indicated with @samp{@result{}}: @example (car '(1 2)) @result{} 1 @end example @noindent You can read this as ``@code{(car '(1 2))} evaluates to 1''. When a form is a macro call, it expands into a new form for Lisp to evaluate. We show the result of the expansion with @samp{@expansion{}}. We may or may not show the actual result of the evaluation of the expanded form. @example (third '(a b c)) @expansion{} (car (cdr (cdr '(a b c)))) @result{} c @end example In some instances, when we describe one form, we show another form which produces identical results. The exact equivalency of two forms is indicated with @samp{@equiv{}}. @example (make-sparse-keymap) @equiv{} (list 'keymap) @end example @node Printing Notation, Error Messages, Evaluation Notation, Conventions @subsection Printing Notation @cindex printing notation Many of the examples in this manual print text when they are evaluated. If you execute the code from an example in a Lisp Interaction buffer (such as the buffer @samp{*scratch*}), the printed text is inserted into the buffer. If the example is executed by other means (such as by evaluating the function @code{eval-region}), then the text is printed in the echo area. You should be aware that text printed in the echo area will not all be visible if more than one line is required. In examples that print text after the code is evaluated, the printed text is indicated with @samp{@print{}}, irrespective of how the form is executed. The value returned by evaluating the form will follow on the next line (here @code{bar}). @group @example (progn (print 'foo) (print 'bar)) @result{} foo @result{} bar @print{} bar @end example @end group @node Error Messages, Buffer Text Notation, Printing Notation, Conventions @subsection Error Messages @cindex error message notation Some of the examples cause errors to be signaled. In those cases, the error messages (which always appear in the echo area) is shown on a line starting with @samp{@error{}}. Note that @samp{@error{}} itself does not appear in the echo area. @example (+ 23 'x) @error{} Wrong type argument: integer-or-marker-p, x @end example @node Buffer Text Notation, Format of Descriptions, Error Messages, Conventions @subsection Buffer Text Notation @cindex buffer text notation Some examples show modifications to text in a buffer, often with `before' and `after' versions. In such cases, the entire contents of the buffer in question are included between two lines of dashes containing the buffer name. In addition, the location of point is shown as @samp{@point{}}. (The symbol for point, of course, is not in the actual buffer; it indicates the place @emph{between} two characters where point is located.) @example ---------- Buffer: foo ---------- This is the @point{}contents of foo. ---------- Buffer: foo ---------- (insert " changed ") @result{} nil ---------- Buffer: foo ---------- This is the changed @point{}contents of foo. ---------- Buffer: foo ---------- @end example @node Format of Descriptions, , Buffer Text Notation, Conventions @subsection Format of Descriptions @cindex descriptions Functions, variables, macros, commands, user options, and special forms are all described in this manual in a uniform format. The first line of the description contains the name of the item followed by its arguments, if appropriate. The category---function, variable, or whatever---is printed on the right hand end of the line. The description follows on succeeding lines, sometimes with examples. For example, @defun inc integer The function @code{inc} adds 1 to its argument, @var{integer}. @example (inc 3) @result{} 4 (inc 7) @result{} 8 @end example @end defun @cindex function descriptions @cindex command descriptions @cindex macro descriptions @cindex special form descriptions Commands are simply functions that may be called interactively. Macros and special forms process their arguments in a different way from functions, but otherwise appear the same. @cindex variable descriptions @cindex option descriptions Although all variables and constants are modifiable, @dfn{options} are variables that exist so that users can change them. (The word `constant' describes the intended permanence of a particular value; however Emacs is flexible and you can change the value of a constant, such as the regular expression describing the end of a sentence. @xref{Global Variables}.) Variables and constants are describing using the same format as functions. @cindex examples @cindex fonts Examples of code appear in this font or form: @code{(list 1 2 3)}. Names that represent arguments appear in this font or form: @var{parameter-1}. @menu * A Sample Function Description:: * A Sample Variable Description:: @end menu @node A Sample Function Description, A Sample Variable Description, Format of Descriptions, Format of Descriptions @subsubsection A Sample Function Description In a function description, the name of the function being described appears first. It is followed on the same line by a list of parameters. The names used for the parameters are also used in the body of the description. Command, macro, and special form descriptions have the same form, but at the end of the first line, `Function' is replaced by `Command', `Macro', or `Special Form', respectively.@refill In function and macro descriptions, the appearance of the keyword @code{&optional} in the parameter list indicates that the arguments for the parameters following it may be left out (in which case the parameters default to @code{nil} if the description does not specifically mention a different value). The keyword @code{&rest} (which will always be followed by a single parameter) indicates that any number of arguments can follow the required and optional ones. The additional arguments will be made into a list to which the last parameter will be bound. Here is a description of the imaginary @code{foo} function: @defun foo integer1 &optional integer2 &rest integers The function @code{foo} subtracts @var{integer1} from @var{integer2}, then adds all the rest of the arguments to the result. If @var{integer2} is not supplied, then the number 19 is used by default. @example (foo 1 5 3 9) @result{} 16 (foo 5) @result{} 14 @end example More generally, @example (foo @var{w} @var{x} @var{y} @var{z}) @equiv{} (+ (- @var{x} @var{w}) @var{y} @var{z}) @end example @end defun Special form descriptions use a different notation to specify optional and repeated parameters because the possibilities are quite a bit more complex. @samp{@code{[@var{optional-arg}]}} means that @var{optional-arg} is optional and @samp{@var{repeated-args}@dots{}} means that @var{repeated-args} may be repeated zero or more times. @xref{Lambda Expressions}, for an example of the use of this notation and for a more complete description of the optional and rest arguments.@refill Any parameter whose name contains the name of a type (e.g., @var{integer}, @var{integer1}, @var{buffers}) is expected to be of that type. Parameters with other names (e.g., @var{name}) are discussed specifically. Parameters named @var{object} may be of any type. (@xref{Types of Lisp Object}, for a list of Emacs object types.) In some sections, features common to a set of parameters are described first. @node A Sample Variable Description, , A Sample Function Description, Format of Descriptions @subsubsection A Sample Variable Description Here is a description of the imaginary @code{electric-future-map} variable. Option and constant descriptions have the same form, but `Variable' on the right edge of the page is replaced by `User Option' or `Constant'.@refill @defvar electric-future-map The value of this variable is a full keymap used by electric command future mode. The functions in this map will allow you to edit commands you have not yet thought about executing. @end defvar