1 This is ../info/lispref.info, produced by makeinfo version 4.6 from
4 INFO-DIR-SECTION XEmacs Editor
6 * Lispref: (lispref). XEmacs Lisp Reference Manual.
11 GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
12 Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
13 Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
14 XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
15 GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
16 Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
17 Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
18 Reference Manual (for 19.15 and 20.1, 20.2, 20.3) v3.2, April, May,
19 November 1997 XEmacs Lisp Reference Manual (for 21.0) v3.3, April 1998
21 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
22 Foundation, Inc. Copyright (C) 1994, 1995 Sun Microsystems, Inc.
23 Copyright (C) 1995, 1996 Ben Wing.
25 Permission is granted to make and distribute verbatim copies of this
26 manual provided the copyright notice and this permission notice are
27 preserved on all copies.
29 Permission is granted to copy and distribute modified versions of
30 this manual under the conditions for verbatim copying, provided that the
31 entire resulting derived work is distributed under the terms of a
32 permission notice identical to this one.
34 Permission is granted to copy and distribute translations of this
35 manual into another language, under the above conditions for modified
36 versions, except that this permission notice may be stated in a
37 translation approved by the Foundation.
39 Permission is granted to copy and distribute modified versions of
40 this manual under the conditions for verbatim copying, provided also
41 that the section entitled "GNU General Public License" is included
42 exactly as in the original, and provided that the entire resulting
43 derived work is distributed under the terms of a permission notice
44 identical to this one.
46 Permission is granted to copy and distribute translations of this
47 manual into another language, under the above conditions for modified
48 versions, except that the section entitled "GNU General Public License"
49 may be included in a translation approved by the Free Software
50 Foundation instead of in the original English.
53 File: lispref.info, Node: Top, Next: Copying, Prev: (dir), Up: (dir)
55 This Info file contains the third edition of the XEmacs Lisp
56 Reference Manual, corresponding to XEmacs version 21.0.
60 * Copying:: Conditions for copying and changing XEmacs.
61 * Introduction:: Introduction and conventions used.
63 * Packaging:: Lisp library administrative infrastructure.
65 * Lisp Data Types:: Data types of objects in XEmacs Lisp.
66 * Numbers:: Numbers and arithmetic functions.
67 * Strings and Characters:: Strings, and functions that work on them.
68 * Lists:: Lists, cons cells, and related functions.
69 * Sequences Arrays Vectors:: Lists, strings and vectors are called sequences.
70 Certain functions act on any kind of sequence.
71 The description of vectors is here as well.
72 * Symbols:: Symbols represent names, uniquely.
74 * Evaluation:: How Lisp expressions are evaluated.
75 * Control Structures:: Conditionals, loops, nonlocal exits.
76 * Variables:: Using symbols in programs to stand for values.
77 * Functions:: A function is a Lisp program
78 that can be invoked from other functions.
79 * Macros:: Macros are a way to extend the Lisp language.
80 * Customization:: Writing customization declarations.
82 * Loading:: Reading files of Lisp code into Lisp.
83 * Byte Compilation:: Compilation makes programs run faster.
84 * Debugging:: Tools and tips for debugging Lisp programs.
86 * Read and Print:: Converting Lisp objects to text and back.
87 * Minibuffers:: Using the minibuffer to read input.
88 * Command Loop:: How the editor command loop works,
89 and how you can call its subroutines.
90 * Keymaps:: Defining the bindings from keys to commands.
91 * Menus:: Defining pull-down and pop-up menus.
92 * Dialog Boxes:: Creating dialog boxes.
93 * Toolbar:: Controlling the toolbar.
94 * Gutter:: Controlling the gutter.
95 * Scrollbars:: Controlling the scrollbars.
96 * Drag and Drop:: Generic API to inter-application communication
97 via specific protocols.
98 * Modes:: Defining major and minor modes.
99 * Documentation:: Writing and using documentation strings.
101 * Files:: Accessing files.
102 * Backups and Auto-Saving:: Controlling how backups and auto-save
104 * Buffers:: Creating and using buffer objects.
105 * Windows:: Manipulating windows and displaying buffers.
106 * Frames:: Making multiple X windows.
107 * Consoles and Devices:: Opening frames on multiple TTY's or X displays.
108 * Positions:: Buffer positions and motion functions.
109 * Markers:: Markers represent positions and update
110 automatically when the text is changed.
112 * Text:: Examining and changing text in buffers.
113 * Searching and Matching:: Searching buffers for strings or regexps.
114 * Syntax Tables:: The syntax table controls word and list parsing.
115 * Abbrevs:: How Abbrev mode works, and its data structures.
117 * Extents:: Extents are regions of text with particular
118 display characteristics.
119 * Specifiers:: How faces and glyphs are specified.
120 * Faces and Window-System Objects::
121 A face is a set of display characteristics
122 specifying how text is to be displayed.
123 * Glyphs:: General interface to pixmaps displayed in a
125 * Annotations:: Higher-level interface to glyphs in a buffer.
126 * Display:: Parameters controlling screen usage.
127 The bell. Waiting for input.
129 * Hash Tables:: Fast data structures for mappings.
130 * Range Tables:: Keeping track of ranges of numbers.
131 * Databases:: An interface to standard DBM and DB databases.
133 * Processes:: Running and communicating with subprocesses.
134 * System Interface:: Getting the user id, system type, environment
135 variables, and other such things.
136 * X-Windows:: Functions specific to the X Window System.
137 * ToolTalk Support:: Interfacing with the ToolTalk message service.
138 * LDAP Support:: Interfacing with the Lightweight Directory
140 * PostgreSQL Support:: Interfacing to the PostgreSQL libpq library.
141 * Internationalization:: How Emacs supports different languages and
142 cultural conventions.
143 * MULE:: Specifics of the Asian-language support.
147 * Tips:: Advice for writing Lisp programs.
148 * Building XEmacs and Object Allocation::
149 Behind-the-scenes information about XEmacs.
150 * Standard Errors:: List of all error symbols.
151 * Standard Buffer-Local Variables:: List of variables local in all buffers.
152 * Standard Keymaps:: List of standard keymaps.
153 * Standard Hooks:: List of standard hook variables.
155 * Index:: Index including concepts, functions, variables,
158 --- The Detailed Node Listing ---
160 Here are other nodes that are inferiors of those already listed,
161 mentioned here so you can get to them in one step:
165 * Caveats:: Flaws and a request for help.
166 * Lisp History:: XEmacs Lisp is descended from Maclisp.
167 * Conventions:: How the manual is formatted.
168 * Acknowledgements:: The authors, editors, and sponsors of this manual.
172 * Some Terms:: Explanation of terms we use in this manual.
173 * nil and t:: How the symbols `nil' and `t' are used.
174 * Evaluation Notation:: The format we use for examples of evaluation.
175 * Printing Notation:: The format we use for examples that print output.
176 * Error Messages:: The format we use for examples of errors.
177 * Buffer Text Notation:: The format we use for buffer contents in examples.
178 * Format of Descriptions:: Notation for describing functions, variables, etc.
180 Format of Descriptions
182 * A Sample Function Description::
183 * A Sample Variable Description::
187 * Package Overview:: Lisp Libraries and Packages.
188 * Package Terminology:: Basic stuff.
189 * Building Packages:: Turn packaged source into a tarball.
190 * Local.rules File:: Tell the XEmacs Packaging System about your host.
191 * Creating Packages:: Tell the XEmacs Packaging System about your package.
197 * The Library Maintainer View::
198 * The Package Release Engineer View::
200 The Library Maintainer's View
202 * Infrastructure:: Global Makefiles and common rules.
203 * Control Files:: Package-specific Makefiles and administrative files.
204 * Obtaining:: Obtaining the XEmacs Packaging System and utilities.
208 * package-info.in:: package-info.in
209 * Makefile:: `Makefile'
214 * Printed Representation:: How Lisp objects are represented as text.
215 * Comments:: Comments and their formatting conventions.
216 * Programming Types:: Types found in all Lisp systems.
217 * Editing Types:: Types specific to XEmacs.
218 * Type Predicates:: Tests related to types.
219 * Equality Predicates:: Tests of equality between any two objects.
223 * Integer Type:: Numbers without fractional parts.
224 * Floating Point Type:: Numbers with fractional parts and with a large range.
225 * Character Type:: The representation of letters, numbers and
227 * Sequence Type:: Both lists and arrays are classified as sequences.
228 * Cons Cell Type:: Cons cells, and lists (which are made from cons cells).
229 * Array Type:: Arrays include strings and vectors.
230 * String Type:: An (efficient) array of characters.
231 * Vector Type:: One-dimensional arrays.
232 * Symbol Type:: A multi-use object that refers to a function,
233 variable, property list, or itself.
234 * Function Type:: A piece of executable code you can call from elsewhere.
235 * Macro Type:: A method of expanding an expression into another
236 expression, more fundamental but less pretty.
237 * Primitive Function Type:: A function written in C, callable from Lisp.
238 * Compiled-Function Type:: A function written in Lisp, then compiled.
239 * Autoload Type:: A type used for automatically loading seldom-used
244 * Dotted Pair Notation:: An alternative syntax for lists.
245 * Association List Type:: A specially constructed list.
249 * Buffer Type:: The basic object of editing.
250 * Window Type:: What makes buffers visible.
251 * Window Configuration Type:: Save what the screen looks like.
252 * Marker Type:: A position in a buffer.
253 * Process Type:: A process running on the underlying OS.
254 * Stream Type:: Receive or send characters.
255 * Keymap Type:: What function a keystroke invokes.
256 * Syntax Table Type:: What a character means.
260 * Integer Basics:: Representation and range of integers.
261 * Float Basics:: Representation and range of floating point.
262 * Predicates on Numbers:: Testing for numbers.
263 * Comparison of Numbers:: Equality and inequality predicates.
264 * Arithmetic Operations:: How to add, subtract, multiply and divide.
265 * Bitwise Operations:: Logical and, or, not, shifting.
266 * Numeric Conversions:: Converting float to integer and vice versa.
267 * Math Functions:: Trig, exponential and logarithmic functions.
268 * Random Numbers:: Obtaining random integers, predictable or not.
270 Strings and Characters
272 * String Basics:: Basic properties of strings and characters.
273 * Predicates for Strings:: Testing whether an object is a string or char.
274 * Creating Strings:: Functions to allocate new strings.
275 * Predicates for Characters:: Testing whether an object is a character.
276 * Character Codes:: Each character has an equivalent integer.
277 * Text Comparison:: Comparing characters or strings.
278 * String Conversion:: Converting characters or strings and vice versa.
279 * Modifying Strings:: Changing characters in a string.
280 * String Properties:: Additional information attached to strings.
281 * Formatting Strings:: `format': XEmacs's analog of `printf'.
282 * Character Case:: Case conversion functions.
283 * Char Tables:: Mapping from characters to Lisp objects.
284 * Case Tables:: Customizing case conversion.
288 * Cons Cells:: How lists are made out of cons cells.
289 * Lists as Boxes:: Graphical notation to explain lists.
290 * List-related Predicates:: Is this object a list? Comparing two lists.
291 * List Elements:: Extracting the pieces of a list.
292 * Building Lists:: Creating list structure.
293 * Modifying Lists:: Storing new pieces into an existing list.
294 * Sets And Lists:: A list can represent a finite mathematical set.
295 * Association Lists:: A list can represent a finite relation or mapping.
296 * Property Lists:: A different way to represent a finite mapping.
297 * Weak Lists:: A list with special garbage-collection behavior.
299 Modifying Existing List Structure
301 * Setcar:: Replacing an element in a list.
302 * Setcdr:: Replacing part of the list backbone.
303 This can be used to remove or add elements.
304 * Rearrangement:: Reordering the elements in a list; combining lists.
306 Sequences, Arrays, and Vectors
308 * Sequence Functions:: Functions that accept any kind of sequence.
309 * Arrays:: Characteristics of arrays in XEmacs Lisp.
310 * Array Functions:: Functions specifically for arrays.
311 * Vectors:: Functions specifically for vectors.
315 * Symbol Components:: Symbols have names, values, function definitions
317 * Definitions:: A definition says how a symbol will be used.
318 * Creating Symbols:: How symbols are kept unique.
319 * Symbol Properties:: Each symbol has a property list
320 for recording miscellaneous information.
324 * Intro Eval:: Evaluation in the scheme of things.
325 * Eval:: How to invoke the Lisp interpreter explicitly.
326 * Forms:: How various sorts of objects are evaluated.
327 * Quoting:: Avoiding evaluation (to put constants in
332 * Self-Evaluating Forms:: Forms that evaluate to themselves.
333 * Symbol Forms:: Symbols evaluate as variables.
334 * Classifying Lists:: How to distinguish various sorts of list forms.
335 * Function Forms:: Forms that call functions.
336 * Macro Forms:: Forms that call macros.
337 * Special Forms:: ``Special forms'' are idiosyncratic primitives,
338 most of them extremely important.
339 * Autoloading:: Functions set up to load files
340 containing their real definitions.
344 * Sequencing:: Evaluation in textual order.
345 * Conditionals:: `if', `cond'.
346 * Combining Conditions:: `and', `or', `not'.
347 * Iteration:: `while' loops.
348 * Nonlocal Exits:: Jumping out of a sequence.
352 * Catch and Throw:: Nonlocal exits for the program's own purposes.
353 * Examples of Catch:: Showing how such nonlocal exits can be written.
354 * Errors:: How errors are signaled and handled.
355 * Cleanups:: Arranging to run a cleanup form if an
360 * Signaling Errors:: How to report an error.
361 * Processing of Errors:: What XEmacs does when you report an error.
362 * Handling Errors:: How you can trap errors and continue execution.
363 * Error Symbols:: How errors are classified for trapping them.
367 * Global Variables:: Variable values that exist permanently, everywhere.
368 * Constant Variables:: Certain "variables" have values that never change.
369 * Local Variables:: Variable values that exist only temporarily.
370 * Void Variables:: Symbols that lack values.
371 * Defining Variables:: A definition says a symbol is used as a variable.
372 * Accessing Variables:: Examining values of variables whose names
373 are known only at run time.
374 * Setting Variables:: Storing new values in variables.
375 * Variable Scoping:: How Lisp chooses among local and global values.
376 * Buffer-Local Variables:: Variable values in effect only in one buffer.
378 Scoping Rules for Variable Bindings
380 * Scope:: Scope means where in the program a value
381 is visible. Comparison with other languages.
382 * Extent:: Extent means how long in time a value exists.
383 * Impl of Scope:: Two ways to implement dynamic scoping.
384 * Using Scoping:: How to use dynamic scoping carefully and
387 Buffer-Local Variables
389 * Intro to Buffer-Local:: Introduction and concepts.
390 * Creating Buffer-Local:: Creating and destroying buffer-local bindings.
391 * Default Value:: The default value is seen in buffers
392 that don't have their own local values.
396 * What Is a Function:: Lisp functions vs primitives; terminology.
397 * Lambda Expressions:: How functions are expressed as Lisp objects.
398 * Function Names:: A symbol can serve as the name of a function.
399 * Defining Functions:: Lisp expressions for defining functions.
400 * Calling Functions:: How to use an existing function.
401 * Mapping Functions:: Applying a function to each element of a list, etc.
402 * Anonymous Functions:: Lambda-expressions are functions with no names.
403 * Function Cells:: Accessing or setting the function definition
405 * Related Topics:: Cross-references to specific Lisp primitives
406 that have a special bearing on how
411 * Lambda Components:: The parts of a lambda expression.
412 * Simple Lambda:: A simple example.
413 * Argument List:: Details and special features of argument lists.
414 * Function Documentation:: How to put documentation in a function.
418 * Simple Macro:: A basic example.
419 * Expansion:: How, when and why macros are expanded.
420 * Compiling Macros:: How macros are expanded by the compiler.
421 * Defining Macros:: How to write a macro definition.
422 * Backquote:: Easier construction of list structure.
423 * Problems with Macros:: Don't evaluate the macro arguments too many times.
424 Don't hide the user's variables.
428 * How Programs Do Loading:: The `load' function and others.
429 * Autoload:: Setting up a function to autoload.
430 * Named Features:: Loading a library if it isn't already loaded.
431 * Repeated Loading:: Precautions about loading a file twice.
435 * Speed of Byte-Code:: An example of speedup from byte compilation.
436 * Compilation Functions:: Byte compilation functions.
437 * Docs and Compilation:: Dynamic loading of documentation strings.
438 * Dynamic Loading:: Dynamic loading of individual functions.
439 * Eval During Compile:: Code to be evaluated when you compile.
440 * Compiled-Function Objects:: The data type used for byte-compiled functions.
441 * Disassembly:: Disassembling byte-code; how to read byte-code.
442 * Different Behavior:: When compiled code gives different results.
444 Debugging Lisp Programs
446 * Debugger:: How the XEmacs Lisp debugger is implemented.
447 * Syntax Errors:: How to find syntax errors.
448 * Compilation Errors:: How to find errors that show up in
450 * Edebug:: A source-level XEmacs Lisp debugger.
454 * Error Debugging:: Entering the debugger when an error happens.
455 * Function Debugging:: Entering it when a certain function is called.
456 * Explicit Debug:: Entering it at a certain point in the program.
457 * Using Debugger:: What the debugger does; what you see while in it.
458 * Debugger Commands:: Commands used while in the debugger.
459 * Invoking the Debugger:: How to call the function `debug'.
460 * Internals of Debugger:: Subroutines of the debugger, and global variables.
462 Debugging Invalid Lisp Syntax
464 * Excess Open:: How to find a spurious open paren or missing close.
465 * Excess Close:: How to find a spurious close paren or missing open.
467 Reading and Printing Lisp Objects
469 * Streams Intro:: Overview of streams, reading and printing.
470 * Input Streams:: Various data types that can be used as
472 * Input Functions:: Functions to read Lisp objects from text.
473 * Output Streams:: Various data types that can be used as
475 * Output Functions:: Functions to print Lisp objects as text.
479 * Intro to Minibuffers:: Basic information about minibuffers.
480 * Text from Minibuffer:: How to read a straight text string.
481 * Object from Minibuffer:: How to read a Lisp object or expression.
482 * Completion:: How to invoke and customize completion.
483 * Yes-or-No Queries:: Asking a question with a simple answer.
484 * Minibuffer Misc:: Various customization hooks and variables.
488 * Basic Completion:: Low-level functions for completing strings.
489 (These are too low level to use the minibuffer.)
490 * Minibuffer Completion:: Invoking the minibuffer with completion.
491 * Completion Commands:: Minibuffer commands that do completion.
492 * High-Level Completion:: Convenient special cases of completion
493 (reading buffer name, file name, etc.)
494 * Reading File Names:: Using completion to read file names.
495 * Programmed Completion:: Finding the completions for a given file name.
499 * Command Overview:: How the command loop reads commands.
500 * Defining Commands:: Specifying how a function should read arguments.
501 * Interactive Call:: Calling a command, so that it will read arguments.
502 * Command Loop Info:: Variables set by the command loop for you to examine.
503 * Events:: What input looks like when you read it.
504 * Reading Input:: How to read input events from the keyboard or mouse.
505 * Waiting:: Waiting for user input or elapsed time.
506 * Quitting:: How C-g works. How to catch or defer quitting.
507 * Prefix Command Arguments:: How the commands to set prefix args work.
508 * Recursive Editing:: Entering a recursive edit,
509 and why you usually shouldn't.
510 * Disabling Commands:: How the command loop handles disabled commands.
511 * Command History:: How the command history is set up, and how accessed.
512 * Keyboard Macros:: How keyboard macros are implemented.
516 * Using Interactive:: General rules for `interactive'.
517 * Interactive Codes:: The standard letter-codes for reading arguments
519 * Interactive Examples:: Examples of how to read interactive arguments.
523 * Event Types:: Events come in different types.
524 * Event Contents:: What the contents of each event type are.
525 * Event Predicates:: Querying whether an event is of a
527 * Accessing Mouse Event Positions::
528 Determining where a mouse event occurred,
530 * Accessing Other Event Info:: Accessing non-positional event info.
531 * Working With Events:: Creating, copying, and destroying events.
532 * Converting Events:: Converting between events, keys, and
535 Accessing Mouse Event Positions
537 * Frame-Level Event Position Info::
538 * Window-Level Event Position Info::
539 * Event Text Position Info::
540 * Event Glyph Position Info::
541 * Event Toolbar Position Info::
542 * Other Event Position Info::
546 * Key Sequence Input:: How to read one key sequence.
547 * Reading One Event:: How to read just one event.
548 * Dispatching an Event:: What to do with an event once it has been read.
549 * Quoted Character Input:: Asking the user to specify a character.
550 * Peeking and Discarding:: How to reread or throw away input events.
554 * Keymap Terminology:: Definitions of terms pertaining to keymaps.
555 * Format of Keymaps:: What a keymap looks like as a Lisp object.
556 * Creating Keymaps:: Functions to create and copy keymaps.
557 * Inheritance and Keymaps:: How one keymap can inherit the bindings
559 * Key Sequences:: How to specify key sequences.
560 * Prefix Keys:: Defining a key with a keymap as its definition.
561 * Active Keymaps:: Each buffer has a local keymap
562 to override the standard (global) bindings.
563 Each minor mode can also override them.
564 * Key Lookup:: How extracting elements from keymaps works.
565 * Functions for Key Lookup:: How to request key lookup.
566 * Changing Key Bindings:: Redefining a key in a keymap.
567 * Key Binding Commands:: Interactive interfaces for redefining keys.
568 * Scanning Keymaps:: Looking through all keymaps, for printing help.
569 * Other Keymap Functions:: Miscellaneous keymap functions.
573 * Menu Format:: Format of a menu description.
574 * Menubar Format:: How to specify a menubar.
575 * Menubar:: Functions for controlling the menubar.
576 * Modifying Menus:: Modifying a menu description.
577 * Pop-Up Menus:: Functions for specifying pop-up menus.
578 * Menu Filters:: Filter functions for the default menubar.
579 * Buffers Menu:: The menu that displays the list of buffers.
583 * Dialog Box Format::
584 * Dialog Box Functions::
588 * Toolbar Intro:: An introduction.
589 * Toolbar Descriptor Format:: How to create a toolbar.
590 * Specifying the Toolbar:: Setting a toolbar.
591 * Other Toolbar Variables:: Controlling the size of toolbars.
597 Major and Minor Modes
599 * Major Modes:: Defining major modes.
600 * Minor Modes:: Defining minor modes.
601 * Modeline Format:: Customizing the text that appears in the modeline.
602 * Hooks:: How to use hooks; how to write code that
607 * Major Mode Conventions:: Coding conventions for keymaps, etc.
608 * Example Major Modes:: Text mode and Lisp modes.
609 * Auto Major Mode:: How XEmacs chooses the major mode automatically.
610 * Mode Help:: Finding out how to use a mode.
614 * Minor Mode Conventions:: Tips for writing a minor mode.
615 * Keymaps and Minor Modes:: How a minor mode can have its own keymap.
619 * Modeline Data:: The data structure that controls the modeline.
620 * Modeline Variables:: Variables used in that data structure.
621 * %-Constructs:: Putting information into a modeline.
625 * Documentation Basics:: Good style for doc strings.
626 Where to put them. How XEmacs stores them.
627 * Accessing Documentation:: How Lisp programs can access doc strings.
628 * Keys in Documentation:: Substituting current key bindings.
629 * Describing Characters:: Making printable descriptions of
630 non-printing characters and key sequences.
631 * Help Functions:: Subroutines used by XEmacs help facilities.
635 * Visiting Files:: Reading files into Emacs buffers for editing.
636 * Saving Buffers:: Writing changed buffers back into files.
637 * Reading from Files:: Reading files into other buffers.
638 * Writing to Files:: Writing new files from parts of buffers.
639 * File Locks:: Locking and unlocking files, to prevent
640 simultaneous editing by two people.
641 * Information about Files:: Testing existence, accessibility, size of files.
642 * Contents of Directories:: Getting a list of the files in a directory.
643 * Changing File Attributes:: Renaming files, changing protection, etc.
644 * File Names:: Decomposing and expanding file names.
648 * Visiting Functions:: The usual interface functions for visiting.
649 * Subroutines of Visiting:: Lower-level subroutines that they use.
651 Information about Files
653 * Testing Accessibility:: Is a given file readable? Writable?
654 * Kinds of Files:: Is it a directory? A link?
655 * File Attributes:: How large is it? Any other names? Etc.
659 * File Name Components:: The directory part of a file name, and the rest.
660 * Directory Names:: A directory's name as a directory
661 is different from its name as a file.
662 * Relative File Names:: Some file names are relative to a
664 * File Name Expansion:: Converting relative file names to absolute ones.
665 * Unique File Names:: Generating names for temporary files.
666 * File Name Completion:: Finding the completions for a given file name.
668 Backups and Auto-Saving
670 * Backup Files:: How backup files are made; how their names
672 * Auto-Saving:: How auto-save files are made; how their
674 * Reverting:: `revert-buffer', and how to customize
679 * Making Backups:: How XEmacs makes backup files, and when.
680 * Rename or Copy:: Two alternatives: renaming the old file
682 * Numbered Backups:: Keeping multiple backups for each source file.
683 * Backup Names:: How backup file names are computed; customization.
687 * Buffer Basics:: What is a buffer?
688 * Buffer Names:: Accessing and changing buffer names.
689 * Buffer File Name:: The buffer file name indicates which file
691 * Buffer Modification:: A buffer is "modified" if it needs to be saved.
692 * Modification Time:: Determining whether the visited file was changed
693 ``behind XEmacs's back''.
694 * Read Only Buffers:: Modifying text is not allowed in a
696 * The Buffer List:: How to look at all the existing buffers.
697 * Creating Buffers:: Functions that create buffers.
698 * Killing Buffers:: Buffers exist until explicitly killed.
699 * Current Buffer:: Designating a buffer as current
700 so primitives will access its contents.
704 * Basic Windows:: Basic information on using windows.
705 * Splitting Windows:: Splitting one window into two windows.
706 * Deleting Windows:: Deleting a window gives its space to other windows.
707 * Selecting Windows:: The selected window is the one that you edit in.
708 * Cyclic Window Ordering:: Moving around the existing windows.
709 * Buffers and Windows:: Each window displays the contents of a buffer.
710 * Displaying Buffers:: Higher-lever functions for displaying a buffer
711 and choosing a window for it.
712 * Window Point:: Each window has its own location of point.
713 * Window Start:: The display-start position controls which text
714 is on-screen in the window.
715 * Vertical Scrolling:: Moving text up and down in the window.
716 * Horizontal Scrolling:: Moving text sideways on the window.
717 * Size of Window:: Accessing the size of a window.
718 * Resizing Windows:: Changing the size of a window.
719 * Window Configurations:: Saving and restoring the state of the screen.
723 * Creating Frames:: Creating additional frames.
724 * Frame Properties:: Controlling frame size, position, font, etc.
725 * Frame Titles:: Automatic updating of frame titles.
726 * Deleting Frames:: Frames last until explicitly deleted.
727 * Finding All Frames:: How to examine all existing frames.
728 * Frames and Windows:: A frame contains windows;
729 display of text always works through windows.
730 * Minibuffers and Frames:: How a frame finds the minibuffer to use.
731 * Input Focus:: Specifying the selected frame.
732 * Visibility of Frames:: Frames may be visible or invisible, or icons.
733 * Raising and Lowering:: Raising a frame makes it hide other X windows;
734 lowering it makes the others hide them.
735 * Frame Hooks:: Hooks for customizing frame behavior.
739 * Point:: The special position where editing takes place.
740 * Motion:: Changing point.
741 * Excursions:: Temporary motion and buffer changes.
742 * Narrowing:: Restricting editing to a portion of the buffer.
746 * Character Motion:: Moving in terms of characters.
747 * Word Motion:: Moving in terms of words.
748 * Buffer End Motion:: Moving to the beginning or end of the buffer.
749 * Text Lines:: Moving in terms of lines of text.
750 * Screen Lines:: Moving in terms of lines as displayed.
751 * List Motion:: Moving by parsing lists and sexps.
752 * Skipping Characters:: Skipping characters belonging to a certain set.
756 * Overview of Markers:: The components of a marker, and how it relocates.
757 * Predicates on Markers:: Testing whether an object is a marker.
758 * Creating Markers:: Making empty markers or markers at certain places.
759 * Information from Markers:: Finding the marker's buffer or character
761 * Changing Markers:: Moving the marker to a new buffer or position.
762 * The Mark:: How ``the mark'' is implemented with a marker.
763 * The Region:: How to access ``the region''.
767 * Near Point:: Examining text in the vicinity of point.
768 * Buffer Contents:: Examining text in a general fashion.
769 * Comparing Text:: Comparing substrings of buffers.
770 * Insertion:: Adding new text to a buffer.
771 * Commands for Insertion:: User-level commands to insert text.
772 * Deletion:: Removing text from a buffer.
773 * User-Level Deletion:: User-level commands to delete text.
774 * The Kill Ring:: Where removed text sometimes is saved for later use.
775 * Undo:: Undoing changes to the text of a buffer.
776 * Maintaining Undo:: How to enable and disable undo information.
777 How to control how much information is kept.
778 * Filling:: Functions for explicit filling.
779 * Margins:: How to specify margins for filling commands.
780 * Auto Filling:: How auto-fill mode is implemented to break lines.
781 * Sorting:: Functions for sorting parts of the buffer.
782 * Columns:: Computing horizontal positions, and using them.
783 * Indentation:: Functions to insert or adjust indentation.
784 * Case Changes:: Case conversion of parts of the buffer.
785 * Text Properties:: Assigning Lisp property lists to text characters.
786 * Substitution:: Replacing a given character wherever it appears.
787 * Registers:: How registers are implemented. Accessing the text or
788 position stored in a register.
789 * Transposition:: Swapping two portions of a buffer.
790 * Change Hooks:: Supplying functions to be run when text is changed.
794 * Kill Ring Concepts:: What text looks like in the kill ring.
795 * Kill Functions:: Functions that kill text.
796 * Yank Commands:: Commands that access the kill ring.
797 * Low-Level Kill Ring:: Functions and variables for kill ring access.
798 * Internals of Kill Ring:: Variables that hold kill-ring data.
802 * Primitive Indent:: Functions used to count and insert indentation.
803 * Mode-Specific Indent:: Customize indentation for different modes.
804 * Region Indent:: Indent all the lines in a region.
805 * Relative Indent:: Indent the current line based on previous lines.
806 * Indent Tabs:: Adjustable, typewriter-like tab stops.
807 * Motion by Indent:: Move to first non-blank character.
809 Searching and Matching
811 * String Search:: Search for an exact match.
812 * Regular Expressions:: Describing classes of strings.
813 * Regexp Search:: Searching for a match for a regexp.
814 * Match Data:: Finding out which part of the text matched
815 various parts of a regexp, after regexp search.
816 * Saving Match Data:: Saving and restoring this information.
817 * Standard Regexps:: Useful regexps for finding sentences, pages,...
818 * Searching and Case:: Case-independent or case-significant searching.
822 * Syntax of Regexps:: Rules for writing regular expressions.
823 * Regexp Example:: Illustrates regular expression syntax.
827 * Syntax Descriptors:: How characters are classified.
828 * Syntax Table Functions:: How to create, examine and alter syntax tables.
829 * Parsing Expressions:: Parsing balanced expressions
830 using the syntax table.
831 * Standard Syntax Tables:: Syntax tables used by various major modes.
832 * Syntax Table Internals:: How syntax table information is stored.
836 * Syntax Class Table:: Table of syntax classes.
837 * Syntax Flags:: Additional flags each character can have.
839 Abbrevs And Abbrev Expansion
841 * Abbrev Mode:: Setting up XEmacs for abbreviation.
842 * Tables: Abbrev Tables. Creating and working with abbrev tables.
843 * Defining Abbrevs:: Specifying abbreviations and their expansions.
844 * Files: Abbrev Files. Saving abbrevs in files.
845 * Expansion: Abbrev Expansion. Controlling expansion; expansion subroutines.
846 * Standard Abbrev Tables:: Abbrev tables used by various major modes.
850 * Intro to Extents:: Extents are regions over a buffer or string.
851 * Creating and Modifying Extents::
852 Basic extent functions.
853 * Extent Endpoints:: Accessing and setting the bounds of an extent.
854 * Finding Extents:: Determining which extents are in an object.
855 * Mapping Over Extents:: More sophisticated functions for extent scanning.
856 * Extent Properties:: Extents have built-in and user-definable properties.
857 * Detached Extents:: Extents that are not in a buffer.
858 * Extent Parents:: Inheriting properties from another extent.
859 * Duplicable Extents:: Extents can be marked to be copied into strings.
860 * Extents and Events:: Extents can interact with the keyboard and mouse.
861 * Atomic Extents:: Treating a block of text as a single entity.
865 * Introduction to Specifiers:: Specifiers provide a clean way for
866 display and other properties to vary
867 (under user control) in a wide variety
869 * Specifiers In-Depth:: Gory details about specifier innards.
870 * Specifier Instancing:: Instancing means obtaining the ``value'' of
871 a specifier in a particular context.
872 * Specifier Types:: Specifiers come in different flavors.
873 * Adding Specifications:: Specifications control a specifier's ``value''
874 by giving conditions under which a
875 particular value is valid.
876 * Retrieving Specifications:: Querying a specifier's specifications.
877 * Specifier Instancing Functions::
878 Functions to instance a specifier.
879 * Specifier Examples:: Making all this stuff clearer.
880 * Creating Specifiers:: Creating specifiers for your own use.
881 * Specifier Validation Functions::
882 Validating the components of a specifier.
883 * Other Specification Functions::
884 Other ways of working with specifications.
886 Faces and Window-System Objects
888 * Faces:: Controlling the way text looks.
889 * Fonts:: Controlling the typeface of text.
890 * Colors:: Controlling the color of text and pixmaps.
894 * Merging Faces:: How XEmacs decides which face to use
896 * Basic Face Functions:: How to define and examine faces.
897 * Face Properties:: How to access and modify a face's properties.
898 * Face Convenience Functions:: Convenience functions for accessing
899 particular properties of a face.
900 * Other Face Display Functions:: Other functions pertaining to how a
905 * Font Specifiers:: Specifying how a font will appear.
906 * Font Instances:: What a font specifier gets instanced as.
907 * Font Instance Names:: The name of a font instance.
908 * Font Instance Size:: The size of a font instance.
909 * Font Instance Characteristics:: Display characteristics of font instances.
910 * Font Convenience Functions:: Convenience functions that automatically
911 instance and retrieve the properties
916 * Color Specifiers:: Specifying how a color will appear.
917 * Color Instances:: What a color specifier gets instanced as.
918 * Color Instance Properties:: Properties of color instances.
919 * Color Convenience Functions:: Convenience functions that automatically
920 instance and retrieve the properties
921 of a color specifier.
925 * Glyph Functions:: Functions for working with glyphs.
926 * Images:: Graphical images displayed in a frame.
927 * Glyph Types:: Each glyph has a particular type.
928 * Mouse Pointer:: Controlling the mouse pointer.
929 * Redisplay Glyphs:: Glyphs controlling various redisplay functions.
930 * Subwindows:: Inserting an externally-controlled subwindow
932 * Glyph Examples:: Examples of how to work with glyphs.
936 * Creating Glyphs:: Creating new glyphs.
937 * Glyph Properties:: Accessing and modifying a glyph's properties.
938 * Glyph Convenience Functions::
939 Convenience functions for accessing particular
940 properties of a glyph.
941 * Glyph Dimensions:: Determining the height, width, etc. of a glyph.
945 * Image Specifiers:: Specifying how an image will appear.
946 * Image Instantiator Conversion::
947 Conversion is applied to image instantiators
948 at the time they are added to an
949 image specifier or at the time they
950 are passed to `make-image-instance'.
951 * Image Instances:: What an image specifier gets instanced as.
955 * Image Instance Types:: Each image instances has a particular type.
956 * Image Instance Functions:: Functions for working with image instances.
960 * Annotation Basics:: Introduction to annotations.
961 * Annotation Primitives:: Creating and deleting annotations.
962 * Annotation Properties:: Retrieving and changing the characteristics
964 * Margin Primitives:: Controlling the size of the margins.
965 * Locating Annotations:: Looking for annotations in a buffer.
966 * Annotation Hooks:: Hooks called at certain times during an
967 annotation's lifetime.
971 * Introduction to Hash Tables:: Hash tables are fast data structures for
972 implementing simple tables (i.e. finite
973 mappings from keys to values).
974 * Working With Hash Tables:: Hash table functions.
975 * Weak Hash Tables:: Hash tables with special garbage-collection
980 * Introduction to Range Tables:: Range tables efficiently map ranges of
982 * Working With Range Tables:: Range table functions.
987 * Refresh Screen:: Clearing the screen and redrawing everything on it.
988 * Truncation:: Folding or wrapping long text lines.
989 * The Echo Area:: Where messages are displayed.
990 * Selective Display:: Hiding part of the buffer text.
991 * Overlay Arrow:: Display of an arrow to indicate position.
992 * Temporary Displays:: Displays that go away automatically.
993 * Blinking:: How XEmacs shows the matching open parenthesis.
994 * Usual Display:: The usual conventions for displaying nonprinting chars.
995 * Display Tables:: How to specify other conventions.
996 * Beeping:: Audible signal to the user.
1000 * Subprocess Creation:: Functions that start subprocesses.
1001 * Synchronous Processes:: Details of using synchronous subprocesses.
1002 * Asynchronous Processes:: Starting up an asynchronous subprocess.
1003 * Deleting Processes:: Eliminating an asynchronous subprocess.
1004 * Process Information:: Accessing run-status and other attributes.
1005 * Input to Processes:: Sending input to an asynchronous subprocess.
1006 * Signals to Processes:: Stopping, continuing or interrupting
1007 an asynchronous subprocess.
1008 * Output from Processes:: Collecting output from an asynchronous subprocess.
1009 * Sentinels:: Sentinels run when process run-status changes.
1010 * Network:: Opening network connections.
1012 Receiving Output from Processes
1014 * Process Buffers:: If no filter, output is put in a buffer.
1015 * Filter Functions:: Filter functions accept output from the process.
1016 * Accepting Output:: How to wait until process output arrives.
1018 Operating System Interface
1020 * Starting Up:: Customizing XEmacs start-up processing.
1021 * Getting Out:: How exiting works (permanent or temporary).
1022 * System Environment:: Distinguish the name and kind of system.
1023 * Terminal Input:: Recording terminal input for debugging.
1024 * Terminal Output:: Recording terminal output for debugging.
1025 * Flow Control:: How to turn output flow control on or off.
1026 * Batch Mode:: Running XEmacs without terminal interaction.
1030 * Start-up Summary:: Sequence of actions XEmacs performs at start-up.
1031 * Init File:: Details on reading the init file (`.emacs').
1032 * Terminal-Specific:: How the terminal-specific Lisp file is read.
1033 * Command Line Arguments:: How command line arguments are processed,
1034 and how you can customize them.
1036 Getting out of XEmacs
1038 * Killing XEmacs:: Exiting XEmacs irreversibly.
1039 * Suspending XEmacs:: Exiting XEmacs reversibly.
1043 * X Selections:: Transferring text to and from other X clients.
1044 * X Server:: Information about the X server connected to
1045 a particular device.
1046 * Resources:: Getting resource values from the server.
1047 * Server Data:: Getting info about the X server.
1048 * Grabs:: Restricting access to the server by other apps.
1049 * X Miscellaneous:: Other X-specific functions and variables.
1053 * XEmacs ToolTalk API Summary::
1054 * Sending Messages::
1055 * Receiving Messages::
1059 * Building XEmacs with LDAP support:: How to add LDAP support to XEmacs
1060 * XEmacs LDAP API:: Lisp access to LDAP functions
1061 * Syntax of Search Filters:: A brief summary of RFC 1558
1065 * LDAP Variables:: Lisp variables related to LDAP
1066 * The High-Level LDAP API:: High-level LDAP lisp functions
1067 * The Low-Level LDAP API:: Low-level LDAP lisp primitives
1068 * LDAP Internationalization:: I18n variables and functions
1070 The Low-Level LDAP API
1072 * The LDAP Lisp Object::
1073 * Opening and Closing a LDAP Connection::
1074 * Low-level Operations on a LDAP Server::
1076 LDAP Internationalization
1078 * LDAP Internationalization Variables::
1079 * Encoder/Decoder Functions::
1081 Internationalization
1083 * I18N Levels 1 and 2:: Support for different time, date, and currency formats.
1084 * I18N Level 3:: Support for localized messages.
1085 * I18N Level 4:: Support for Asian languages.
1089 * Internationalization Terminology::
1090 Definition of various internationalization terms.
1091 * Charsets:: Sets of related characters.
1092 * MULE Characters:: Working with characters in XEmacs/MULE.
1093 * Composite Characters:: Making new characters by overstriking other ones.
1094 * ISO 2022:: An international standard for charsets and encodings.
1095 * Coding Systems:: Ways of representing a string of chars using integers.
1096 * CCL:: A special language for writing fast converters.
1097 * Category Tables:: Subdividing charsets into groups.
1101 * Style Tips:: Writing clean and robust programs.
1102 * Compilation Tips:: Making compiled code run fast.
1103 * Documentation Tips:: Writing readable documentation strings.
1104 * Comment Tips:: Conventions for writing comments.
1105 * Library Headers:: Standard headers for library packages.
1107 Building XEmacs and Object Allocation
1109 * Building XEmacs:: How to preload Lisp libraries into XEmacs.
1110 * Pure Storage:: A kludge to make preloaded Lisp functions sharable.
1111 * Garbage Collection:: Reclaiming space for Lisp objects no longer used.
1114 File: lispref.info, Node: Copying, Next: Introduction, Prev: Top, Up: Top
1116 GNU GENERAL PUBLIC LICENSE
1117 **************************
1119 Version 2, June 1991
1120 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
1121 675 Mass Ave, Cambridge, MA 02139, USA
1123 Everyone is permitted to copy and distribute verbatim copies
1124 of this license document, but changing it is not allowed.
1129 The licenses for most software are designed to take away your freedom
1130 to share and change it. By contrast, the GNU General Public License is
1131 intended to guarantee your freedom to share and change free
1132 software--to make sure the software is free for all its users. This
1133 General Public License applies to most of the Free Software
1134 Foundation's software and to any other program whose authors commit to
1135 using it. (Some other Free Software Foundation software is covered by
1136 the GNU Library General Public License instead.) You can apply it to
1139 When we speak of free software, we are referring to freedom, not
1140 price. Our General Public Licenses are designed to make sure that you
1141 have the freedom to distribute copies of free software (and charge for
1142 this service if you wish), that you receive source code or can get it
1143 if you want it, that you can change the software or use pieces of it in
1144 new free programs; and that you know you can do these things.
1146 To protect your rights, we need to make restrictions that forbid
1147 anyone to deny you these rights or to ask you to surrender the rights.
1148 These restrictions translate to certain responsibilities for you if you
1149 distribute copies of the software, or if you modify it.
1151 For example, if you distribute copies of such a program, whether
1152 gratis or for a fee, you must give the recipients all the rights that
1153 you have. You must make sure that they, too, receive or can get the
1154 source code. And you must show them these terms so they know their
1157 We protect your rights with two steps: (1) copyright the software,
1158 and (2) offer you this license which gives you legal permission to copy,
1159 distribute and/or modify the software.
1161 Also, for each author's protection and ours, we want to make certain
1162 that everyone understands that there is no warranty for this free
1163 software. If the software is modified by someone else and passed on, we
1164 want its recipients to know that what they have is not the original, so
1165 that any problems introduced by others will not reflect on the original
1166 authors' reputations.
1168 Finally, any free program is threatened constantly by software
1169 patents. We wish to avoid the danger that redistributors of a free
1170 program will individually obtain patent licenses, in effect making the
1171 program proprietary. To prevent this, we have made it clear that any
1172 patent must be licensed for everyone's free use or not licensed at all.
1174 The precise terms and conditions for copying, distribution and
1175 modification follow.
1177 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
1178 0. This License applies to any program or other work which contains a
1179 notice placed by the copyright holder saying it may be distributed
1180 under the terms of this General Public License. The "Program",
1181 below, refers to any such program or work, and a "work based on
1182 the Program" means either the Program or any derivative work under
1183 copyright law: that is to say, a work containing the Program or a
1184 portion of it, either verbatim or with modifications and/or
1185 translated into another language. (Hereinafter, translation is
1186 included without limitation in the term "modification".) Each
1187 licensee is addressed as "you".
1189 Activities other than copying, distribution and modification are
1190 not covered by this License; they are outside its scope. The act
1191 of running the Program is not restricted, and the output from the
1192 Program is covered only if its contents constitute a work based on
1193 the Program (independent of having been made by running the
1194 Program). Whether that is true depends on what the Program does.
1196 1. You may copy and distribute verbatim copies of the Program's
1197 source code as you receive it, in any medium, provided that you
1198 conspicuously and appropriately publish on each copy an appropriate
1199 copyright notice and disclaimer of warranty; keep intact all the
1200 notices that refer to this License and to the absence of any
1201 warranty; and give any other recipients of the Program a copy of
1202 this License along with the Program.
1204 You may charge a fee for the physical act of transferring a copy,
1205 and you may at your option offer warranty protection in exchange
1208 2. You may modify your copy or copies of the Program or any portion
1209 of it, thus forming a work based on the Program, and copy and
1210 distribute such modifications or work under the terms of Section 1
1211 above, provided that you also meet all of these conditions:
1213 a. You must cause the modified files to carry prominent notices
1214 stating that you changed the files and the date of any change.
1216 b. You must cause any work that you distribute or publish, that
1217 in whole or in part contains or is derived from the Program
1218 or any part thereof, to be licensed as a whole at no charge
1219 to all third parties under the terms of this License.
1221 c. If the modified program normally reads commands interactively
1222 when run, you must cause it, when started running for such
1223 interactive use in the most ordinary way, to print or display
1224 an announcement including an appropriate copyright notice and
1225 a notice that there is no warranty (or else, saying that you
1226 provide a warranty) and that users may redistribute the
1227 program under these conditions, and telling the user how to
1228 view a copy of this License. (Exception: if the Program
1229 itself is interactive but does not normally print such an
1230 announcement, your work based on the Program is not required
1231 to print an announcement.)
1233 These requirements apply to the modified work as a whole. If
1234 identifiable sections of that work are not derived from the
1235 Program, and can be reasonably considered independent and separate
1236 works in themselves, then this License, and its terms, do not
1237 apply to those sections when you distribute them as separate
1238 works. But when you distribute the same sections as part of a
1239 whole which is a work based on the Program, the distribution of
1240 the whole must be on the terms of this License, whose permissions
1241 for other licensees extend to the entire whole, and thus to each
1242 and every part regardless of who wrote it.
1244 Thus, it is not the intent of this section to claim rights or
1245 contest your rights to work written entirely by you; rather, the
1246 intent is to exercise the right to control the distribution of
1247 derivative or collective works based on the Program.
1249 In addition, mere aggregation of another work not based on the
1250 Program with the Program (or with a work based on the Program) on
1251 a volume of a storage or distribution medium does not bring the
1252 other work under the scope of this License.
1254 3. You may copy and distribute the Program (or a work based on it,
1255 under Section 2) in object code or executable form under the terms
1256 of Sections 1 and 2 above provided that you also do one of the
1259 a. Accompany it with the complete corresponding machine-readable
1260 source code, which must be distributed under the terms of
1261 Sections 1 and 2 above on a medium customarily used for
1262 software interchange; or,
1264 b. Accompany it with a written offer, valid for at least three
1265 years, to give any third party, for a charge no more than your
1266 cost of physically performing source distribution, a complete
1267 machine-readable copy of the corresponding source code, to be
1268 distributed under the terms of Sections 1 and 2 above on a
1269 medium customarily used for software interchange; or,
1271 c. Accompany it with the information you received as to the offer
1272 to distribute corresponding source code. (This alternative is
1273 allowed only for noncommercial distribution and only if you
1274 received the program in object code or executable form with
1275 such an offer, in accord with Subsection b above.)
1277 The source code for a work means the preferred form of the work for
1278 making modifications to it. For an executable work, complete
1279 source code means all the source code for all modules it contains,
1280 plus any associated interface definition files, plus the scripts
1281 used to control compilation and installation of the executable.
1282 However, as a special exception, the source code distributed need
1283 not include anything that is normally distributed (in either
1284 source or binary form) with the major components (compiler,
1285 kernel, and so on) of the operating system on which the executable
1286 runs, unless that component itself accompanies the executable.
1288 If distribution of executable or object code is made by offering
1289 access to copy from a designated place, then offering equivalent
1290 access to copy the source code from the same place counts as
1291 distribution of the source code, even though third parties are not
1292 compelled to copy the source along with the object code.
1294 4. You may not copy, modify, sublicense, or distribute the Program
1295 except as expressly provided under this License. Any attempt
1296 otherwise to copy, modify, sublicense or distribute the Program is
1297 void, and will automatically terminate your rights under this
1298 License. However, parties who have received copies, or rights,
1299 from you under this License will not have their licenses
1300 terminated so long as such parties remain in full compliance.
1302 5. You are not required to accept this License, since you have not
1303 signed it. However, nothing else grants you permission to modify
1304 or distribute the Program or its derivative works. These actions
1305 are prohibited by law if you do not accept this License.
1306 Therefore, by modifying or distributing the Program (or any work
1307 based on the Program), you indicate your acceptance of this
1308 License to do so, and all its terms and conditions for copying,
1309 distributing or modifying the Program or works based on it.
1311 6. Each time you redistribute the Program (or any work based on the
1312 Program), the recipient automatically receives a license from the
1313 original licensor to copy, distribute or modify the Program
1314 subject to these terms and conditions. You may not impose any
1315 further restrictions on the recipients' exercise of the rights
1316 granted herein. You are not responsible for enforcing compliance
1317 by third parties to this License.
1319 7. If, as a consequence of a court judgment or allegation of patent
1320 infringement or for any other reason (not limited to patent
1321 issues), conditions are imposed on you (whether by court order,
1322 agreement or otherwise) that contradict the conditions of this
1323 License, they do not excuse you from the conditions of this
1324 License. If you cannot distribute so as to satisfy simultaneously
1325 your obligations under this License and any other pertinent
1326 obligations, then as a consequence you may not distribute the
1327 Program at all. For example, if a patent license would not permit
1328 royalty-free redistribution of the Program by all those who
1329 receive copies directly or indirectly through you, then the only
1330 way you could satisfy both it and this License would be to refrain
1331 entirely from distribution of the Program.
1333 If any portion of this section is held invalid or unenforceable
1334 under any particular circumstance, the balance of the section is
1335 intended to apply and the section as a whole is intended to apply
1336 in other circumstances.
1338 It is not the purpose of this section to induce you to infringe any
1339 patents or other property right claims or to contest validity of
1340 any such claims; this section has the sole purpose of protecting
1341 the integrity of the free software distribution system, which is
1342 implemented by public license practices. Many people have made
1343 generous contributions to the wide range of software distributed
1344 through that system in reliance on consistent application of that
1345 system; it is up to the author/donor to decide if he or she is
1346 willing to distribute software through any other system and a
1347 licensee cannot impose that choice.
1349 This section is intended to make thoroughly clear what is believed
1350 to be a consequence of the rest of this License.
1352 8. If the distribution and/or use of the Program is restricted in
1353 certain countries either by patents or by copyrighted interfaces,
1354 the original copyright holder who places the Program under this
1355 License may add an explicit geographical distribution limitation
1356 excluding those countries, so that distribution is permitted only
1357 in or among countries not thus excluded. In such case, this
1358 License incorporates the limitation as if written in the body of
1361 9. The Free Software Foundation may publish revised and/or new
1362 versions of the General Public License from time to time. Such
1363 new versions will be similar in spirit to the present version, but
1364 may differ in detail to address new problems or concerns.
1366 Each version is given a distinguishing version number. If the
1367 Program specifies a version number of this License which applies
1368 to it and "any later version", you have the option of following
1369 the terms and conditions either of that version or of any later
1370 version published by the Free Software Foundation. If the Program
1371 does not specify a version number of this License, you may choose
1372 any version ever published by the Free Software Foundation.
1374 10. If you wish to incorporate parts of the Program into other free
1375 programs whose distribution conditions are different, write to the
1376 author to ask for permission. For software which is copyrighted
1377 by the Free Software Foundation, write to the Free Software
1378 Foundation; we sometimes make exceptions for this. Our decision
1379 will be guided by the two goals of preserving the free status of
1380 all derivatives of our free software and of promoting the sharing
1381 and reuse of software generally.
1385 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
1386 WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
1387 LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
1388 HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
1389 WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
1390 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
1391 FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
1392 QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
1393 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
1394 SERVICING, REPAIR OR CORRECTION.
1396 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
1397 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
1398 MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
1399 LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
1400 INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
1401 INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
1402 DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
1403 OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
1404 OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
1405 ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
1407 END OF TERMS AND CONDITIONS
1409 How to Apply These Terms to Your New Programs
1410 =============================================
1412 If you develop a new program, and you want it to be of the greatest
1413 possible use to the public, the best way to achieve this is to make it
1414 free software which everyone can redistribute and change under these
1417 To do so, attach the following notices to the program. It is safest
1418 to attach them to the start of each source file to most effectively
1419 convey the exclusion of warranty; and each file should have at least
1420 the "copyright" line and a pointer to where the full notice is found.
1422 ONE LINE TO GIVE THE PROGRAM'S NAME AND AN IDEA OF WHAT IT DOES.
1423 Copyright (C) 19YY NAME OF AUTHOR
1425 This program is free software; you can redistribute it and/or
1426 modify it under the terms of the GNU General Public License
1427 as published by the Free Software Foundation; either version 2
1428 of the License, or (at your option) any later version.
1430 This program is distributed in the hope that it will be useful,
1431 but WITHOUT ANY WARRANTY; without even the implied warranty of
1432 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1433 GNU General Public License for more details.
1435 You should have received a copy of the GNU General Public License
1436 along with this program; if not, write to the Free Software
1437 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1439 Also add information on how to contact you by electronic and paper
1442 If the program is interactive, make it output a short notice like
1443 this when it starts in an interactive mode:
1445 Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
1446 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
1447 type `show w'. This is free software, and you are welcome
1448 to redistribute it under certain conditions; type `show c'
1451 The hypothetical commands `show w' and `show c' should show the
1452 appropriate parts of the General Public License. Of course, the
1453 commands you use may be called something other than `show w' and `show
1454 c'; they could even be mouse-clicks or menu items--whatever suits your
1457 You should also get your employer (if you work as a programmer) or
1458 your school, if any, to sign a "copyright disclaimer" for the program,
1459 if necessary. Here is a sample; alter the names:
1461 Yoyodyne, Inc., hereby disclaims all copyright
1462 interest in the program `Gnomovision'
1463 (which makes passes at compilers) written
1466 SIGNATURE OF TY COON, 1 April 1989
1467 Ty Coon, President of Vice
1469 This General Public License does not permit incorporating your
1470 program into proprietary programs. If your program is a subroutine
1471 library, you may consider it more useful to permit linking proprietary
1472 applications with the library. If this is what you want to do, use the
1473 GNU Library General Public License instead of this License.
1476 File: lispref.info, Node: Introduction, Next: Packaging, Prev: Copying, Up: Top
1481 Most of the XEmacs text editor is written in the programming language
1482 called XEmacs Lisp. You can write new code in XEmacs Lisp and install
1483 it as an extension to the editor. However, XEmacs Lisp is more than a
1484 mere "extension language"; it is a full computer programming language
1485 in its own right. You can use it as you would any other programming
1488 Because XEmacs Lisp is designed for use in an editor, it has special
1489 features for scanning and parsing text as well as features for handling
1490 files, buffers, displays, subprocesses, and so on. XEmacs Lisp is
1491 closely integrated with the editing facilities; thus, editing commands
1492 are functions that can also conveniently be called from Lisp programs,
1493 and parameters for customization are ordinary Lisp variables.
1495 This manual describes XEmacs Lisp, presuming considerable familiarity
1496 with the use of XEmacs for editing. (See `The XEmacs Reference
1497 Manual', for this basic information.) Generally speaking, the earlier
1498 chapters describe features of XEmacs Lisp that have counterparts in many
1499 programming languages, and later chapters describe features that are
1500 peculiar to XEmacs Lisp or relate specifically to editing.
1502 This is edition 3.3.
1506 * Caveats:: Flaws and a request for help.
1507 * Lisp History:: XEmacs Lisp is descended from Maclisp.
1508 * Conventions:: How the manual is formatted.
1509 * Acknowledgements:: The authors, editors, and sponsors of this manual.
1512 File: lispref.info, Node: Caveats, Next: Lisp History, Up: Introduction
1517 This manual has gone through numerous drafts. It is nearly complete
1518 but not flawless. There are a few topics that are not covered, either
1519 because we consider them secondary (such as most of the individual
1520 modes) or because they are yet to be written. Because we are not able
1521 to deal with them completely, we have left out several parts
1524 The manual should be fully correct in what it does cover, and it is
1525 therefore open to criticism on anything it says--from specific examples
1526 and descriptive text, to the ordering of chapters and sections. If
1527 something is confusing, or you find that you have to look at the sources
1528 or experiment to learn something not covered in the manual, then perhaps
1529 the manual should be fixed. Please let us know.
1531 As you use this manual, we ask that you send corrections as soon as
1532 you find them. If you think of a simple, real life example for a
1533 function or group of functions, please make an effort to write it up
1534 and send it in. Please reference any comments to the node name and
1535 function or variable name, as appropriate. Also state the number of
1536 the edition which you are criticizing.
1538 This manual was originally written for FSF Emacs 19 and was updated
1539 by Ben Wing (ben@xemacs.org) for Lucid Emacs 19.10 and later for XEmacs
1540 19.12, 19.13, 19.14, and 20.0. It was further updated by the XEmacs
1541 Development Team for 19.15 and 20.1. Please send comments and
1542 corrections relating to XEmacs-specific portions of this manual to
1545 or post to the newsgroup
1551 File: lispref.info, Node: Lisp History, Next: Conventions, Prev: Caveats, Up: Introduction
1556 Lisp (LISt Processing language) was first developed in the late 1950's
1557 at the Massachusetts Institute of Technology for research in artificial
1558 intelligence. The great power of the Lisp language makes it superior
1559 for other purposes as well, such as writing editing commands.
1561 Dozens of Lisp implementations have been built over the years, each
1562 with its own idiosyncrasies. Many of them were inspired by Maclisp,
1563 which was written in the 1960's at MIT's Project MAC. Eventually the
1564 implementors of the descendants of Maclisp came together and developed a
1565 standard for Lisp systems, called Common Lisp.
1567 XEmacs Lisp is largely inspired by Maclisp, and a little by Common
1568 Lisp. If you know Common Lisp, you will notice many similarities.
1569 However, many of the features of Common Lisp have been omitted or
1570 simplified in order to reduce the memory requirements of XEmacs.
1571 Sometimes the simplifications are so drastic that a Common Lisp user
1572 might be very confused. We will occasionally point out how XEmacs Lisp
1573 differs from Common Lisp. If you don't know Common Lisp, don't worry
1574 about it; this manual is self-contained.
1577 File: lispref.info, Node: Conventions, Next: Acknowledgements, Prev: Lisp History, Up: Introduction
1582 This section explains the notational conventions that are used in this
1583 manual. You may want to skip this section and refer back to it later.
1587 * Some Terms:: Explanation of terms we use in this manual.
1588 * nil and t:: How the symbols `nil' and `t' are used.
1589 * Evaluation Notation:: The format we use for examples of evaluation.
1590 * Printing Notation:: The format we use for examples that print output.
1591 * Error Messages:: The format we use for examples of errors.
1592 * Buffer Text Notation:: The format we use for buffer contents in examples.
1593 * Format of Descriptions:: Notation for describing functions, variables, etc.
1596 File: lispref.info, Node: Some Terms, Next: nil and t, Up: Conventions
1601 Throughout this manual, the phrases "the Lisp reader" and "the Lisp
1602 printer" are used to refer to those routines in Lisp that convert
1603 textual representations of Lisp objects into actual Lisp objects, and
1604 vice versa. *Note Printed Representation::, for more details. You, the
1605 person reading this manual, are thought of as "the programmer" and are
1606 addressed as "you". "The user" is the person who uses Lisp programs,
1607 including those you write.
1609 Examples of Lisp code appear in this font or form: `(list 1 2 3)'.
1610 Names that represent arguments or metasyntactic variables appear in
1611 this font or form: FIRST-NUMBER.
1614 File: lispref.info, Node: nil and t, Next: Evaluation Notation, Prev: Some Terms, Up: Conventions
1619 In Lisp, the symbol `nil' has three separate meanings: it is a symbol
1620 with the name `nil'; it is the logical truth value FALSE; and it is the
1621 empty list--the list of zero elements. When used as a variable, `nil'
1622 always has the value `nil'.
1624 As far as the Lisp reader is concerned, `()' and `nil' are
1625 identical: they stand for the same object, the symbol `nil'. The
1626 different ways of writing the symbol are intended entirely for human
1627 readers. After the Lisp reader has read either `()' or `nil', there is
1628 no way to determine which representation was actually written by the
1631 In this manual, we use `()' when we wish to emphasize that it means
1632 the empty list, and we use `nil' when we wish to emphasize that it
1633 means the truth value FALSE. That is a good convention to use in Lisp
1636 (cons 'foo ()) ; Emphasize the empty list
1637 (not nil) ; Emphasize the truth value FALSE
1639 In contexts where a truth value is expected, any non-`nil' value is
1640 considered to be TRUE. However, `t' is the preferred way to represent
1641 the truth value TRUE. When you need to choose a value which represents
1642 TRUE, and there is no other basis for choosing, use `t'. The symbol
1643 `t' always has value `t'.
1645 In XEmacs Lisp, `nil' and `t' are special symbols that always
1646 evaluate to themselves. This is so that you do not need to quote them
1647 to use them as constants in a program. An attempt to change their
1648 values results in a `setting-constant' error. *Note Accessing
1652 File: lispref.info, Node: Evaluation Notation, Next: Printing Notation, Prev: nil and t, Up: Conventions
1657 A Lisp expression that you can evaluate is called a "form". Evaluating
1658 a form always produces a result, which is a Lisp object. In the
1659 examples in this manual, this is indicated with `=>':
1664 You can read this as "`(car '(1 2))' evaluates to 1".
1666 When a form is a macro call, it expands into a new form for Lisp to
1667 evaluate. We show the result of the expansion with `==>'. We may or
1668 may not show the actual result of the evaluation of the expanded form.
1670 (news-cadr '(a b c))
1671 ==> (car (cdr '(a b c)))
1674 Sometimes to help describe one form we show another form that
1675 produces identical results. The exact equivalence of two forms is
1676 indicated with `=='.
1678 (cons 'a nil) == (list 'a)
1681 File: lispref.info, Node: Printing Notation, Next: Error Messages, Prev: Evaluation Notation, Up: Conventions
1686 Many of the examples in this manual print text when they are evaluated.
1687 If you execute example code in a Lisp Interaction buffer (such as the
1688 buffer `*scratch*'), the printed text is inserted into the buffer. If
1689 you execute the example by other means (such as by evaluating the
1690 function `eval-region'), the printed text is displayed in the echo
1691 area. You should be aware that text displayed in the echo area is
1692 truncated to a single line.
1694 Examples in this manual indicate printed text with `-|',
1695 irrespective of where that text goes. The value returned by evaluating
1696 the form (here `bar') follows on a separate line.
1698 (progn (print 'foo) (print 'bar))
1704 File: lispref.info, Node: Error Messages, Next: Buffer Text Notation, Prev: Printing Notation, Up: Conventions
1709 Some examples signal errors. This normally displays an error message
1710 in the echo area. We show the error message on a line starting with
1711 `error-->'. Note that `error-->' itself does not appear in the echo
1715 error--> Wrong type argument: integer-or-marker-p, x
1718 File: lispref.info, Node: Buffer Text Notation, Next: Format of Descriptions, Prev: Error Messages, Up: Conventions
1720 Buffer Text Notation
1721 --------------------
1723 Some examples show modifications to text in a buffer, with "before" and
1724 "after" versions of the text. These examples show the contents of the
1725 buffer in question between two lines of dashes containing the buffer
1726 name. In addition, `-!-' indicates the location of point. (The symbol
1727 for point, of course, is not part of the text in the buffer; it
1728 indicates the place _between_ two characters where point is located.)
1730 ---------- Buffer: foo ----------
1731 This is the -!-contents of foo.
1732 ---------- Buffer: foo ----------
1736 ---------- Buffer: foo ----------
1737 This is the changed -!-contents of foo.
1738 ---------- Buffer: foo ----------
1741 File: lispref.info, Node: Format of Descriptions, Prev: Buffer Text Notation, Up: Conventions
1743 Format of Descriptions
1744 ----------------------
1746 Functions, variables, macros, commands, user options, and special forms
1747 are described in this manual in a uniform format. The first line of a
1748 description contains the name of the item followed by its arguments, if
1749 any. The category--function, variable, or whatever--appears at the
1750 beginning of the line. The description follows on succeeding lines,
1751 sometimes with examples.
1755 * A Sample Function Description:: A description of an imaginary
1757 * A Sample Variable Description:: A description of an imaginary
1759 `electric-future-map'.
1762 File: lispref.info, Node: A Sample Function Description, Next: A Sample Variable Description, Up: Format of Descriptions
1764 A Sample Function Description
1765 .............................
1767 In a function description, the name of the function being described
1768 appears first. It is followed on the same line by a list of parameters.
1769 The names used for the parameters are also used in the body of the
1772 The appearance of the keyword `&optional' in the parameter list
1773 indicates that the arguments for subsequent parameters may be omitted
1774 (omitted parameters default to `nil'). Do not write `&optional' when
1775 you call the function.
1777 The keyword `&rest' (which will always be followed by a single
1778 parameter) indicates that any number of arguments can follow. The value
1779 of the single following parameter will be a list of all these arguments.
1780 Do not write `&rest' when you call the function.
1782 Here is a description of an imaginary function `foo':
1784 - Function: foo integer1 &optional integer2 &rest integers
1785 The function `foo' subtracts INTEGER1 from INTEGER2, then adds all
1786 the rest of the arguments to the result. If INTEGER2 is not
1787 supplied, then the number 19 is used by default.
1800 Any parameter whose name contains the name of a type (e.g., INTEGER,
1801 INTEGER1 or BUFFER) is expected to be of that type. A plural of a type
1802 (such as BUFFERS) often means a list of objects of that type.
1803 Parameters named OBJECT may be of any type. (*Note Lisp Data Types::,
1804 for a list of XEmacs object types.) Parameters with other sorts of
1805 names (e.g., NEW-FILE) are discussed specifically in the description of
1806 the function. In some sections, features common to parameters of
1807 several functions are described at the beginning.
1809 *Note Lambda Expressions::, for a more complete description of
1810 optional and rest arguments.
1812 Command, macro, and special form descriptions have the same format,
1813 but the word `Function' is replaced by `Command', `Macro', or `Special
1814 Form', respectively. Commands are simply functions that may be called
1815 interactively; macros process their arguments differently from functions
1816 (the arguments are not evaluated), but are presented the same way.
1818 Special form descriptions use a more complex notation to specify
1819 optional and repeated parameters because they can break the argument
1820 list down into separate arguments in more complicated ways.
1821 ``[OPTIONAL-ARG]'' means that OPTIONAL-ARG is optional and
1822 `REPEATED-ARGS...' stands for zero or more arguments. Parentheses are
1823 used when several arguments are grouped into additional levels of list
1824 structure. Here is an example:
1826 - Special Form: count-loop (VAR [FROM TO [INC]]) BODY...
1827 This imaginary special form implements a loop that executes the
1828 BODY forms and then increments the variable VAR on each iteration.
1829 On the first iteration, the variable has the value FROM; on
1830 subsequent iterations, it is incremented by 1 (or by INC if that
1831 is given). The loop exits before executing BODY if VAR equals TO.
1834 (count-loop (i 0 10)
1835 (prin1 i) (princ " ")
1836 (prin1 (aref vector i)) (terpri))
1838 If FROM and TO are omitted, then VAR is bound to `nil' before the
1839 loop begins, and the loop exits if VAR is non-`nil' at the
1840 beginning of an iteration. Here is an example:
1847 In this special form, the arguments FROM and TO are optional, but
1848 must both be present or both absent. If they are present, INC may
1849 optionally be specified as well. These arguments are grouped with
1850 the argument VAR into a list, to distinguish them from BODY, which
1851 includes all remaining elements of the form.
1854 File: lispref.info, Node: A Sample Variable Description, Prev: A Sample Function Description, Up: Format of Descriptions
1856 A Sample Variable Description
1857 .............................
1859 A "variable" is a name that can hold a value. Although any variable
1860 can be set by the user, certain variables that exist specifically so
1861 that users can change them are called "user options". Ordinary
1862 variables and user options are described using a format like that for
1863 functions except that there are no arguments.
1865 Here is a description of the imaginary `electric-future-map'
1868 - Variable: electric-future-map
1869 The value of this variable is a full keymap used by Electric
1870 Command Future mode. The functions in this map allow you to edit
1871 commands you have not yet thought about executing.
1873 User option descriptions have the same format, but `Variable' is
1874 replaced by `User Option'.
1877 File: lispref.info, Node: Acknowledgements, Prev: Conventions, Up: Introduction
1882 This manual was based on the GNU Emacs Lisp Reference Manual, version
1883 2.4, written by Robert Krawitz, Bil Lewis, Dan LaLiberte, Richard M.
1884 Stallman and Chris Welty, the volunteers of the GNU manual group, in an
1885 effort extending over several years. Robert J. Chassell helped to
1886 review and edit the manual, with the support of the Defense Advanced
1887 Research Projects Agency, ARPA Order 6082, arranged by Warren A. Hunt,
1888 Jr. of Computational Logic, Inc.
1890 Ben Wing adapted this manual for XEmacs 19.14 and 20.0, and earlier
1891 for Lucid Emacs 19.10, XEmacs 19.12, and XEmacs 19.13. He is the sole
1892 author of many of the manual sections, in particular the XEmacs-specific
1893 sections: events, faces, extents, glyphs, specifiers, toolbar, menubars,
1894 scrollbars, dialog boxes, devices, consoles, hash tables, range tables,
1895 char tables, databases, and others. The section on annotations was
1896 originally written by Chuck Thompson. Corrections to v3.1 and later
1897 were done by Martin Buchholz, Steve Baur, and Hrvoje Niksic.
1899 Corrections to the original GNU Emacs Lisp Reference Manual were
1900 supplied by Karl Berry, Jim Blandy, Bard Bloom, Stephane Boucher, David
1901 Boyes, Alan Carroll, Richard Davis, Lawrence R. Dodd, Peter Doornbosch,
1902 David A. Duff, Chris Eich, Beverly Erlebacher, David Eckelkamp, Ralf
1903 Fassel, Eirik Fuller, Stephen Gildea, Bob Glickstein, Eric Hanchrow,
1904 George Hartzell, Nathan Hess, Masayuki Ida, Dan Jacobson, Jak Kirman,
1905 Bob Knighten, Frederick M. Korz, Joe Lammens, Glenn M. Lewis, K. Richard
1906 Magill, Brian Marick, Roland McGrath, Skip Montanaro, John Gardiner
1907 Myers, Thomas A. Peterson, Francesco Potorti, Friedrich Pukelsheim,
1908 Arnold D. Robbins, Raul Rockwell, Per Starback, Shinichirou Sugou, Kimmo
1909 Suominen, Edward Tharp, Bill Trost, Rickard Westman, Jean White, Matthew
1910 Wilding, Carl Witty, Dale Worley, Rusty Wright, and David D. Zuhn.
1913 File: lispref.info, Node: Packaging, Next: Lisp Data Types, Prev: Introduction, Up: Top
1915 The XEmacs Packaging System
1916 ***************************
1918 The XEmacs distribution, starting with version 21, comes only with a
1919 very basic set of built-in modes and libraries. Most of the libraries
1920 that were part of the distribution of earlier versions of XEmacs are now
1921 available separately. The user as well as the system administrator can
1922 choose which packages to install; the actual installation process is
1923 easy. This gives an installer the ability to tailor an XEmacs
1924 installation for local needs with safe removal of unnecessary code.
1926 This chapter describes how to package Lisp libraries for use with the
1927 XEmacs Packaging System.
1929 _Please note carefully_ that the term "package" as used in XEmacs
1930 refers to an aggregation of Lisp code and/or data distributed as a
1931 unit. It does not, as it does in many Lisps, refer to a way of
1932 creating separate name spaces. XEmacs has no facility for providing
1933 separate name spaces. (If we ever do get separate name spaces, we'll
1934 probably regret overloading the nomenclature in this way, but it's
1935 become established.)
1940 * Package Overview:: Lisp Libraries and Packages.
1942 Packaging Lisp Libraries:
1943 * Package Terminology:: Basic stuff.
1944 * Building Packages:: Turn packaged source into a tarball.
1945 * Makefile Targets:: Package `Makefile' targets
1946 * Local.rules File:: Tell the XEmacs Packaging System about your host.
1947 * Creating Packages:: Tell the XEmacs Packaging System about your package.
1948 * Documenting Packages:: Explain your package to users and hackers.
1950 Internals and Package Release Engineering:
1954 File: lispref.info, Node: Package Overview, Next: Package Terminology, Up: Packaging
1956 An overview of the XEmacs Packaging System
1957 ******************************************
1959 The XEmacs Packaging System is a system for administering the
1960 installation, upgrade, and removal of Lisp libraries. For the end
1961 user, it provides facilities for determining availability of packages
1962 and which versions at remote sites. It will download and automatically
1963 install a package, ensuring that any old files from previous versions
1964 of the package are removed first. By providing a standard set of
1965 hierarchies for installation, it makes configuration of XEmacs simpler.
1966 Furthermore, packages normally provide ancillary auto-autoloads and
1967 custom-loads libraries, which are automatically detected and loaded by
1968 XEmacs upon startup. This means that once installed, all facilities of
1969 package, including autoloading the library upon invocation of a command
1970 provided by the library and convenient configuration and customization,
1971 are automatically available to the user. There is no need to add
1972 autoloads or keybindings to in the init file, and structured
1973 configuration of the package is available through the Customize system
1974 even before the libraries are loaded.
1976 All of this convenience comes at a cost. The cost of administration
1977 at the package level is negligible compared to the benefits, of course.
1978 However, the requirement that XEmacs find and load auto-autoloads and
1979 custom-loads libraries comes at a fairly large cost in startup time. In
1980 order to reduce this cost, XEmacs imposes fairly strict conditions on
1981 the structure of an installed package.
1983 Meeting these requirements, as well as simply providing the
1984 auto-autoloads and the information about availability and so on does
1985 impose some costs on the library maintainer. The XEmacs Packaging
1986 System also provides structure and utilities to the library maintainer
1987 to make these tasks easier. This manual documents the requirements and
1988 the tools that the XEmacs Packaging System provides to ensure that a
1989 package satisfies them.
1994 * The Library Maintainer View::
1995 * The Package Release Engineer View::
1998 File: lispref.info, Node: The User View, Next: The Library Maintainer View, Up: Package Overview
2003 *N.B.* Much of the discussion in this section undoubtedly belongs
2004 elsewhere, *Note Packages: (xemacs)Packages.
2006 From the user's point of view, an XEmacs binary package is simply a
2007 standard tarball (usually gzipped) containing Lisp sources, compiled
2008 Lisp, documentation, and possibly data files or supporting executables.
2009 The tarball is unpacked using standard tools such as GNU tar and gzip.
2010 The package system does impose certain requirements for automatic
2011 configuration to work.
2013 Here the main consideration is that the tarball "expects" to be
2014 unpacked from the top of a package hierarchy. A "package hierarchy" is
2015 basically an image of a classic Emacs "run-in-place" tree, with `lisp',
2016 `etc', `info', `man', `lib-src', and `pkginfo' subdirectories of the
2017 top. The `pkginfo' subdirectory is for use by the XEmacs Packaging
2018 System administration tools, and currently contains a
2019 `MANIFEST.PACKAGE-NAME' file for each package to ensure that no cruft
2020 remains when a package is removed or updated. The `lisp', `etc', and
2021 `lib-src' subdirectories are further subdivided, with a subdirectory
2022 for each package. The `info' directory obeys the usual conventions.
2023 _I.e._, the `info' directory is flat with a(n) (optional) `dir' file
2024 and one (set of) info file(s) per package. The `man' subdirectory
2025 typically contains documentation sources, separated by package. (It
2026 does not contain `man(1)' pages, as Emacs provides very few of them.)
2028 There are several standard package hierarchies, and administrators
2029 can configure others at build time, while users can configure others at
2030 run time. The standard system hierarchies are all subdirectories of an
2031 XEmacs installation root, typically `/usr/local/lib/xemacs/'. These
2032 are the `xemacs-packages', `mule-packages', `infodock-packages', and
2033 `site-packages' hierarchies. Each has the structure described above,
2034 but the purposes differ. The `xemacs-packages' is the normal place for
2035 installing "official" packages and many third-party libraries.
2036 Unfortunately, it is not yet quite possible to read libraries
2037 containing international characters with a non-Mule XEmacs, so such
2038 libraries are sequestered in the `mule-packages' hierarchy. Some
2039 packages are compatible only with the Infodock development environment,
2040 and they will be installed in the `infodock-packages' hierarchy. The
2041 `site-packages' hierarchy is for packages not distributed by
2042 XEmacs.org, typically locally developed.
2044 Packages are in principle supposed to be XEmacs version-independent,
2045 but if such dependencies are unavoidable, additional standard package
2046 hierarchies may be installed under version directories, _e.g._
2047 `/usr/local/lib/xemacs-21.4.6/'.
2049 Users who do not have sufficient privilege to install packages in the
2050 system hierarchies may install package hierarchies under `~/.xemacs'.
2051 At present only the `xemacs-packages', `mule-packages', and
2052 `site-packages' hierarchies are supported, but it might make sense to
2053 extend this to support `infodock-packages' hierarchies in the future.
2055 The package hierarchies are not searched directly for libraries to be
2056 loaded; this would be very costly. Instead, the hierarchies are ordered
2057 according to certain rules, and searched for package lisp directories at
2058 invocation. These directories are added to the general `load-path'.
2059 As usual, it is `load-path' that is searched at run-time. This
2060 approach is somewhat costly at initialization, but results in a very
2061 "clean" `load-path'.
2063 The order of search can be changed at build time by specifying the
2064 `--package-path' option to `configure', or at run-time by specifying
2065 the `EMACSPACKAGEPATH' environment variable. *Note Packages:
2068 The default order of search is hierarchically determined. First, the
2069 roots are ordered. The "early" roots are the user-specific roots,
2070 typically `~/.xemacs'. The "late" roots are the system roots,
2071 typically `/usr/local/lib/xemacs-21.4.6' and `/usr/local/lib/xemacs',
2072 in that order. All hierarchies for a given root are searched for
2073 package Lisp directories, which are appended to `load-path' in the
2074 order found. Then the search proceeds to the next root, whose results
2075 will be appended to the `load-path' generated by previous roots.
2077 Second, the hierarchies below each root are searched in the order
2078 `site-packages', `infodock-packages', `mule-packages', then
2081 In each hierarchy there should be a `lisp' subdirectory, containing
2082 directories named for the packages. Each package's Lisp libraries thus
2083 are contained in a directory of the form ROOT/HIERARCHY/lisp/PACKAGE/.
2085 With such a complex search algorithm, the possibility of libraries
2086 being shadowed by another library with the same name is quite real.
2087 There are two considerations here. First, every XEmacs package
2088 contains certain libraries with constant names. These are
2091 Lisp code to inform the package administration system about the
2095 Lisp code to set up autoloaded functions and variables that may be
2099 definitions of configuration variables for use with the Customize
2102 They are special-cased, because the way they are used prevents
2103 shadowing from being an issue.
2105 Second, it is possible that multiple copies of some library, or
2106 different libraries with the same name, are installed in various places
2107 in the hierarchies. To detect such shadows, use
2108 `list-load-path-shadows'.
2110 Finally, note that most basic Emacs functionality, including most of
2111 the Lisp API, is implemented in Lisp libraries. Because they use
2112 internal reserved APIs that are subject to change according the needs
2113 of the developers, these libraries are distributed with the XEmacs
2114 binary, and are called "core Lisp libraries". Most core Lisp libraries
2115 are "preloaded" into the Emacs binary and in normal usage are never
2116 explicitly loaded. However, they can be explicitly loaded, and if so
2117 they are searched on `load-path'. Furthermore, functions such as
2118 `locate-library' will also search on the `load-path'. The searching
2119 takes place under somewhat different rules from those used for packaged
2120 Lisp. It is probably easiest to think of the package hierarchy
2121 searching algorithm as receiving a `load-path' initialized to the core
2125 File: lispref.info, Node: The Library Maintainer View, Next: The Package Release Engineer View, Prev: The User View, Up: Package Overview
2127 The Library Maintainer View
2128 ===========================
2130 From the library maintainer's viewpoint, the advantages to the XEmacs
2131 Packaging System stem from the convenience to the user of installation
2132 and upgrade. Since an installed package automatically registers its
2133 entry points via autoload and its configuration variables with the
2134 Customize system, configuration FAQs are reduced. When it's easy to
2135 upgrade, users learn to try `Tools | Packages | Update Installed
2136 Packages' before posting a FAQ whose answer is "long since fixed,
2139 This comes at some cost, as the library maintainer needs to arrange
2140 that the package be installed in a directory structure that satisfies
2141 the requirements of the XEmacs Packaging System. Autoload cookies and
2142 defcustoms must also be added to existing libraries. The XEmacs
2143 Packaging System provides infrastructure to assure that all of these
2144 annoyances need only be dealt with once. The autoload cookies and
2145 defcustoms are beyond the scope of this chapter, but most maintainers
2146 of modern packages are already familiar with these mechanisms.
2148 The XEmacs Packaging System may be divided into the "infrastructure"
2149 common to all packages, and the package-specific "control files". The
2150 infrastructure supports global builds, installation, and generation of
2151 the "sumo" bundles of packages, as well as generation of individual
2152 packages. The package control files describe the structure of the
2153 package's source tree and provide administrative information.
2157 * Infrastructure:: Global Makefiles and common rules.
2158 * Control Files:: Package-specific Makefiles and administrative files.
2159 * Obtaining:: Obtaining the XEmacs Packaging System and required utilities.
2162 File: lispref.info, Node: Infrastructure, Next: Control Files, Up: The Library Maintainer View
2167 In order to get the greatest benefit from the XEmacs Packaging System,
2168 a library maintainer should place the package sources in an appropriate
2169 place in the XEmacs source package hierarchy, and arrange to have the
2170 source package imported into the XEmacs CVS repository. (We realize
2171 that the latter requirement can be quite burdensome. We are working on
2172 ways to remove this requirement, but for the present it remains
2173 necessary.) The library maintainer must also keep sources for any
2174 packages his/her package requires. This requirement is somewhat
2175 burdensome, but unlikely to be relaxed because of the implementation of
2176 compilation of macros in Emacs Lisp. Macros cannot be called by
2177 compiled Lisp (the macro expansion, which is always known at compile
2178 time, is inlined), so the source of the macro must be loaded before
2179 compiling the called function.
2181 The source package hierarchy may be rooted anywhere. The CVS module
2182 is called "packages," so we will refer to the top directory of the
2183 source package hierarchy as "the `packages' directory." The `packages'
2184 directory contains two source subdirectories, `xemacs-packages' and
2185 `mule-packages' (for convenience in segregating the packages which
2186 depend on Mule, as they will cause load-time errors in a non-Mule
2187 XEmacs). Each subdirectory contains many package source directories,
2188 whose internal structure is not specified. That structure is left up
2189 to the convenience of the library maintainers. The requirements on the
2190 top directory of an individual package source tree are given below,
2191 *Note Control Files::.
2193 The `packages' directory contains some auxiliary Lisp libraries used
2194 in the compilation and packaging process. The content of these
2195 libraries is of interest primarily to the packaging engineers, *Note
2196 The Package Release Engineer View::.
2198 Finally, the `packages', `packages/xemacs-packages', and
2199 `packages/mule-packages' directories contain `Makefile's and include
2200 files to control the package creation process. The `Makefile's in
2201 `packages/xemacs-packages' and `packages/mule-packages' simply define
2202 the default sets of known packages and include `../iterate.rules',
2203 which implements recursive building of all target packages.
2205 The `make' infrastructure in `packages' includes
2208 controls building of individual packages, local installation, and
2209 bundling of "sumo" tarballs
2212 controls recursive builds of multiple packages
2214 `meta-iterate.rules'
2215 This is used by higher-level subdirectories that do not directly
2216 contain packages. Subdirectories directly containing packages
2217 should use iterate.rules instead.
2220 provides the rules for building and packaging. Included by all
2221 package `Makefile's.
2224 provides local configuration, such as installation targets and
2225 staging directories, as well as a number of kludges (many now
2226 obsolete) required for building packages on the Windows platform.
2228 `Local.rules.template'
2229 a template for Local.rules, liberally commented
2232 consistency checking for `Local.rules', included by both the
2233 top-level `Makefile' and by `XEmacs.rules'.
2236 a file to `include' in package `Makefile's to be able to get at
2237 variables in `Local.rules' _before_ including `XEmacs.rules'.
2239 `package-compile.el'
2240 compile environment (_e.g._, load-path) setup.
2242 Of these, only `Local.rules' and `package-compile.el' need to be
2243 modified by the library maintainer. The changes to Local.rules affect
2244 only your environment. This should need to be done only once when
2245 first preparing the source environment. The necessary modifications to
2246 `package-compile.el' need to be done for each package and are discussed
2247 in the next section, *Note Control Files::.
2250 File: lispref.info, Node: Control Files, Next: Obtaining, Prev: Infrastructure, Up: The Library Maintainer View
2255 Each package source must contain a number of control files in the
2256 top-level directory. These files in general can be created and then
2257 ignored, except for a few variables that need to be updated when new
2258 versions are released. In most cases even adding, renaming, and
2259 removing library source files can be handled by generic rules.
2261 The package control files include
2264 Must set a few `make' variables used by the administrative
2265 utilities, and defines a couple of package-building targets to
2266 depend on appropriate targets defined generically in
2267 `XEmacs.rules'. It may also provide various variables and rules
2268 to transform the source tree structure into that expected by the
2272 Provides a template for package information to be provided to the
2273 administrative utilities. Static variables that are rarely changed
2274 (such as the package's name) are entered as literals. Some
2275 variables are generated by the build process (build dates and MD5
2276 checksums) and are automatically filled in. Finally, some
2277 variables that change irregularly (dependences and even version
2278 numbers) are set as `make' variables in the `Makefile'.
2281 Not strictly required, but normally a ChangeLog will be added by
2282 the XEmacs package maintainer if different from the upstream
2286 Generated. Simply does a `package-provide' for the package.
2289 Generated. Read when XEmacs is initialized, and provides
2290 autoloads for defuns and other forms in the sources that are
2291 marked with an "autoload cookie" (`;;;###autoload'.
2294 Generated. Read when XEmacs is initialized, and informs the
2295 Customize subsystem how to find the defcustom forms needed to
2296 create Customization forms for the usre configuration variables of
2300 File: lispref.info, Node: Obtaining, Prev: Control Files, Up: The Library Maintainer View
2302 Obtaining the XEmacs Packaging System and Required Utilities
2303 ------------------------------------------------------------
2305 Currently both the infrastructure for creating XEmacs packages and the
2306 package sources themselves are available only by CVS. See
2307 `http://www.xemacs.org/Develop/cvsaccess.html' for more intformation.
2309 The XEmacs Packaging System currently requires GNU `make', and
2310 XEmacs, to build packages.
2313 File: lispref.info, Node: The Package Release Engineer View, Prev: The Library Maintainer View, Up: Package Overview
2315 The Package Release Engineer View
2316 ---------------------------------
2318 The XEmacs Package Release Engineer is responsible for keeping the
2319 system coherent. The changes to `packages/package-compile.el' and
2320 `packages/xemacs-packages/Makefile' required to make the package
2321 available to others, and for building SUMO tarballs, _etc_, are done by
2322 the Package Release Engineer, not individual library maintainers.
2324 The Package Release Engineer also maintains assorted infrastructure
2325 for actually making releases. These are generally available for
2326 inspection in the `xemacs-builds' module in the CVS repository.
2329 File: lispref.info, Node: Package Terminology, Next: Building Packages, Prev: Package Overview, Up: Packaging
2331 Package Terminology:
2332 ====================
2334 Libraries and Packages
2335 ----------------------
2337 A Lisp "library" is a single loadable file containing Lisp code. It
2338 may be in source or byte-compiled form. A Lisp "package" is a set of
2339 one or more libraries, usually related to each other in some way,
2340 bundled with administrative information for convenient distribution.
2345 There are two main flavors of packages.
2348 A regular package is a set of Lisp libraries design to cooperate
2349 with one another. A very complex example is Gnus. One may not in
2350 general safely remove any of the component libraries.
2352 *Single-File Packages*
2353 A single-file package is a collection of thematically related but
2354 otherwise independent Lisp libraries. These libraries are bundled
2355 together for convenience of the maintainers. Usually individual
2356 libraries may be deleted at will without any loss of functionality
2357 of other libraries in the package. However, we would recommend
2358 that you follow this rule of thumb: "When in doubt, don't delete".
2359 If it's really that big a deal, request that the maintainers
2360 split the package into smaller aggregations.
2362 Package Distributions
2363 ---------------------
2365 XEmacs Lisp packages are distributed in two ways. "Binary packages"
2366 are used by system administrators and end users. They are packaged in a
2367 form convenient for direct installation into an XEmacs package
2368 hierarchy. "Source packages" are for developers and include all files
2369 necessary for rebuilding byte-compiled lisp and creating tarballs for
2370 distribution or installation. This is all of the package author's
2371 source code plus all of the files necessary to build distribution
2372 tarballs (Unix Tar format files, gzipped for space savings).
2373 (Occasionally sources that are not relevant to XEmacs are usually
2374 renamed to `file.upstream'.)
2376 Currently, source packages are only available via CVS. See
2377 <http://www.xemacs.org/Develop/cvsaccess.html> for details.
2379 The package distributions are also split according to major features
2380 required in XEmacs to support them. At present there are "generic"
2381 packages, which can be loaded by _any_ XEmacs, and "Mule" packages,
2382 which _require_ Mule support or they will cause errors when loaded.
2383 Note that there is no guarantee that a generic package will have any
2384 useful functionality in a minimally configured XEmacs. As long as any
2385 XEmacs can successfully load the package's libraries (perhaps given
2386 other required Lisp libraries), it will be classified as generic. At
2387 the present time only Mule packages need be treated specially, and even
2388 those only if they contain multibyte characters.
2391 File: lispref.info, Node: Building Packages, Next: Makefile Targets, Prev: Package Terminology, Up: Packaging
2396 Currently, source packages are only available via anonymous CVS. See
2397 <http://www.xemacs.org/Develop/cvsaccess.html> for details of checking
2398 out the `packages' module.
2400 Prerequisites for Building Source Packages
2401 ------------------------------------------
2406 (or a BSD compatible install program).
2409 (3.79 or later preferred).
2412 (4.2 from texinfo-4.2)
2420 `A properly configured `Local.rules' file.'
2421 *Note Local.rules File::.
2423 And of course, XEmacs, 21.0 or higher.
2425 What You Can Do With Source Packages
2426 ====================================
2428 The packages CVS sources are most useful for creating XEmacs package
2429 tarballs for installation into your own XEmacs installations or for
2430 distributing to others.
2432 It should be noted that most of the package `Makefile's do _not_
2433 need to contain _any_ target rules. Everything is handled from the
2434 `XEmacs.rules' file, located in the toplevel directory of the packages
2438 File: lispref.info, Node: Makefile Targets, Next: Local.rules File, Prev: Building Packages, Up: Packaging
2443 The following targets can be used when running `make' to build the
2447 Removes any documentation files that have been processed by TeX.
2450 Does a `mostlyclean', plus removes generated postscript and dvi
2451 files. Also removes any generated .elc files, along with the
2452 normal .elc files in the package and HTML and .info files.
2455 Use this when preparing a distribution. It kills anything that
2459 Does a `distclean' and also removes any backup files (`*~') and
2463 Creates the `package-info' file from the `package-info.in' and
2464 writes an entry in the `package-index' file.
2467 Builds the package, including any Texinfo documentation (info
2468 format), writes an entry into the `package-index' file and builds
2469 a tarball of the package. Also writes an entry into
2470 `setup-packages.ini' which is later used in the creation of
2471 netinstaller's `setup.ini'.
2474 Builds and installs a package
2477 Doesn't build anything, just installs it.
2480 Generate the package's `auto-autoloads.el' file.
2483 Creates the directories needed for installation and copies the
2484 files there. Basically this is an alias for `install-only'.
2487 Builds the HTML versions of the documentation.
2490 Does most of the work. Builds the elcs, infos at a minimum.
2492 The targets that most people would be interested in would be:
2493 -------------------------------------------------------------
2510 File: lispref.info, Node: Local.rules File, Next: Creating Packages, Prev: Makefile Targets, Up: Packaging
2512 The Local.rules File:
2513 =====================
2515 This file in `packages' provides the XEmacs Packaging System with
2516 information about the local configuration and environment. To create
2517 `Local.rules', simply copy `Local.rules.template' from that directory to
2518 `Local.rules' and edit it to suit your needs.
2520 These are the variables in `Local.rules' that you may need to
2524 The name (and path if needed) of the XEmacs binary to use for
2525 building the packages. The default is `xemacs'.
2528 This will enable some, as yet, unimplemented features in XEmacs
2529 21.5 and above. For now leave this blank (the default) regardless
2530 of the XEmacs version you are using.
2532 `BUILD_WITHOUT_MULE'
2533 Set this to `t' if you are using a non-Mule XEmacs. The default is
2534 that this variable is not set (blank) which means to build _with_
2538 Set this to `t' if you are using a native Microsoft Windows build
2539 of XEmacs (not a Cygwin build) to build the packages. *N.B.* To
2540 Windows users, you still need the Cygwin environment to actually
2543 `XEMACS_INSTALLED_PACKAGES_ROOT'
2544 Set this to the root of where you want the packages to be
2545 installed. Under this directory will hang `xemacs-packages' and
2546 `mule-packages'. See NONMULE_INSTALLED_PACKAGES_ROOT and
2547 MULE_INSTALLED_PACKAGES_ROOT. The default for this is
2548 `/usr/local/lib/xemacs'. Which may not be what you want if you are
2549 developing XEmacs. To quote the comments in
2550 `Local.rules.template':
2552 If you are developing XEmacs, you probably don't want to
2553 install the packages under /usr/local, which is where the
2554 stable, released version of XEmacs goes. Instead, we suggest
2555 a layout as described in the base README file of recent
2556 versions of XEmacs. In a nutshell, we suggest you put your
2557 source under /src/xemacs, and under this put the package
2558 sources in package-src/, and the installed packages in
2559 xemacs-packages/ and mule-packages/. If you do everything
2560 this way, you might want to set things as follows:
2562 XEMACS_INSTALLED_PACKAGES_ROOT = ${XEMACS_PACKAGES_BASE}/..
2564 which puts the xemacs-packages/ and mule-packages/
2565 directories as sisters of the package-src/ directory, and you
2566 have to tell configure the location of the installed packages
2567 using `-package-path', something like
2570 -package-path=/src/xemacs/xemacs-packages;/src/xemacs/mule-packages
2573 The default is unset (blank). If you set this to `t' then `make
2574 install' will create a "symlink farm" of the installed packages
2575 under XEMACS_INSTALLED_PACKAGES_ROOT. Obviously, for this to
2576 work, your system has to support symbolic links. This is as close
2577 as you can get to "running in place" for the packages.
2579 `NONMULE_INSTALLED_PACKAGES_ROOT'
2580 This is where the non-Mule packages get installed to. The default
2581 is `${XEMACS_INSTALLED_PACKAGES_ROOT}/xemacs-packages'.
2583 `MULE_INSTALLED_PACKAGES_ROOT'
2584 This is where the Mule packages get installed to. The default is
2585 `${XEMACS_INSTALLED_PACKAGES_ROOT}/mule-packages'.
2588 A whitespace separated list of non-Mule packages to build/install.
2590 NONMULE_PACKAGES = bbdb gnus xemacs-base prog-modes
2592 The value for this variable can also be the symbol
2593 `xemacs-packages', which means to build/install _all_ of the
2594 non-Mule packages. The default is `xemacs-packages'.
2597 A whitespace separated list of Mule packages to build/install.
2599 MULE_PACKAGES = mule-base leim locale
2601 The value for this variable can also be the symbol
2602 `mule-packages', which means to build/install _all_ of the Mule
2603 packages. The default is `mule-packages'.
2606 The name of the package-index file. The default is `package-index'
2607 and you probably don't need to worry about changing it.
2610 The path to a BSD compatible install program. The default is
2614 The path to GNU/tar. The default is `tar'.
2617 The path to the bzip2 compression program. The default is unset
2618 (blank). If this is set `.tar.bz2' archives will be built _in
2619 addition to_ the `.tar.gz' archives.
2622 For things that you _don't_ want to go into the package tarballs.
2623 It takes the same format as GNU/tar's `--exclude' option. The
2631 --exclude '*.orig' \
2636 Set to the XEmacs command line option that forces running in
2637 "vanilla" mode. The default is `-vanilla'. You wouldn't ever
2641 How to put XEmacs into "batch" mode. It also sets a couple of
2642 other things and in the normal course of events you wouldn't need
2643 to alter this from the default which is:
2645 BATCH = $(VANILLA) -batch -eval \
2646 '(setq stack-trace-on-error t \
2647 load-always-display-messages t \
2648 load-ignore-out-of-date-elc-files t \
2649 load-show-full-path-in-messages t)'
2652 The path to `makeinfo'. The default is `makeinfo'
2655 Set this to `t' if you want to install HTML versions of the Texinfo
2656 documentation. The default is unset (blank).
2659 The path to the program that can convert Texinfo source to HTML.
2660 The default is `texi2html'.
2663 The path to the program that can convert Texinfo source to DVI.
2664 The default is `texi2dvi'
2667 The path to the program that can convert DVI to Postscript. The
2671 The path to the program that can convert Texinfo source to PDF
2672 format. The default is `texi2pdf'.
2675 The path to TeX. The default is `tex'
2678 The path to msgfmt. The default is `msgfmt'
2681 The path to your copy command (GNU cp). The default is dependent
2682 on whether or not SYMLINK is set (`t').
2684 If SYMLINK is unset (blank), RCOPY's default is `cp -af'. If
2685 SYMLINK is set (`t'), RCOPY's default is `cp --force --recursive
2688 It should be noted that in most cases the defaults should be fine.
2689 Most people will probably only need to alter:
2691 * XEMACS_INSTALLED_PACKAGES_ROOT
2693 * NONMULE_INSTALLED_PACKAGES_ROOT
2695 * MULE_INSTALLED_PACKAGES_ROOT
2702 File: lispref.info, Node: Creating Packages, Next: Documenting Packages, Prev: Local.rules File, Up: Packaging
2707 Creating a package from an existing Lisp library is not very difficult.
2709 In addition to the Lisp libraries themselves, you need a *Note
2710 package-info.in:: file and a simple *Note Makefile::. The rest is done
2711 by `XEmacs.rules', part of the packaging system infrastructure.
2715 * package-info.in:: package-info.in
2716 * Makefile:: `Makefile'
2719 File: lispref.info, Node: package-info.in, Next: Makefile, Up: Creating Packages
2724 `package-info.in' contains information that gets injected into the
2725 `package-index' file when `make bindist' is run. Here is a real world
2726 example from the xemacs-base package (a description of each field
2727 follows the example):
2730 (standards-version 1.1
2732 author-version AUTHOR_VERSION
2734 build-date BUILD_DATE
2735 maintainer MAINTAINER
2740 description "Fundamental XEmacs support, you almost certainly need this."
2744 provides (add-log advice-preload advice annotations assoc case-table chistory comint-xemacs comint compile debug ebuff-menu echistory edmacro ehelp electric enriched env facemenu ffap helper imenu iso-syntax macros novice outline passwd pp regexp-opt regi ring shell skeleton sort thing time-stamp timezone tq xbm-button xpm-button)
2749 Description of the Fields in `package-info.in':
2750 -----------------------------------------------
2753 The name of the package. In the case of the example it is
2757 Part of the internal package infrastructure, its value should
2758 always be `1.1'. Do not change this.
2761 This is the XEmacs package version number of the package. It is
2762 set from the `Makefile' variable VERSION. This is something that
2763 the XEmacs Package Release Engineer deals with so there is no need
2764 for a package maintainer to touch it. In `package-info.in' just
2765 put the place-marker, `VERSION' here.
2768 This is the package's internal, or `upstream' version number if it
2769 has one. It is set from the `Makefile' variable AUTHOR_VERSION.
2772 This is the date of the last change made to the package. It is
2773 auto-generated at build time, taken from the package's toplevel
2777 The date the package was built. It is auto-generated.
2780 This is the name and email address of the package's maintainer.
2781 It is taken from the `Makefile' variable MAINTAINER.
2784 An unused field, leave as `xemacs'
2787 An unused field, can be any of `high', `medium', or `low'.
2790 The `category' of the package. It is taken from the `Makefile'
2791 variable CATEGORY and can be either `standard' for non-Mule
2792 packages, or `mule' for Mule packages. The is also provision for
2793 `unsupported' in this field which would be for packages that
2794 XEmacs.org do not distribute.
2796 *N.B.* As yet, the XEmacs Packaging System does _not_ support this
2797 type of package. It will in the future.
2800 Unused. Always `nil'
2803 A free form short description of the package.
2806 The file name of the package's binary tarball. It is generated at
2807 build time by `make bindist'.
2810 The MD5 message digest of the package's binary tarball. Generated
2811 at build time by `make bindist'.
2814 The size in bytes of the package's binary tarball. Generated at
2818 A whitespace separated list of _all_ the features the package
2819 provides. Surround the list with parens.
2822 Taken from the `Makefile' variable REQUIRES. It is a list of all
2823 the package's dependencies, including any macros and defstructs
2824 that need to be inlined.
2826 `REQUIRES' cannot be correctly computed from the calls to
2827 `require' in the package's library sources. `REQUIRES' is used to
2828 ensure that all macro and defstruct definitions used by the
2829 package are available at build time. This is not merely a matter
2830 of efficiency, to get the expansions inlined. In fact, it is
2831 _impossible_ to call a macro by name in byte-compiled Emacs Lisp
2832 code. Thus, if the macro expansion is not inlined, the call will
2833 result in an error at run-time! Thus, packages providing
2834 libraries that would be loaded because of autoload definitions
2835 must also be included.
2838 Can either be `regular' for a regular package, or `single-file'
2839 for a single file package.
2841 *N.B.* This doesn't refer to the number of lisp files in a
2842 package. A single-file package can have multiple lisp files in it.
2843 *Note Package Terminology::.
2845 The fields in `package-info.in' that need to be changed directly are:
2855 Everything else is either set from the appropriate `Makefile'
2856 variable, is auto-generated at build time, or is static.
2859 File: lispref.info, Node: Makefile, Prev: package-info.in, Up: Creating Packages
2864 The `Makefile' is quite stylized. The idea is similar to an
2865 `Imakefile' or an `automake' file: the complexity is hidden in generic
2866 rules files, in this case the `XEmacs.rules' include file in the top
2867 directory of the packages hierarchy.
2869 It is important to note that the XEmacs used to compile packages is
2870 the bare minimum: it is called with the `-no-autoloads'. This means
2871 that anything not dumped into XEmacs by default needs to be specified
2872 in the `REQUIRES' variable (for packaged Lisp) or in some cases the
2873 `PRELOADS' (autoloads used in libraries mentioned in `PRELOADS').
2875 There isn't much to an XEmacs Packaging System `Makefile', basically
2876 it just contains a few `Makefile' variables and that's it. See the
2879 Here is a real world example, from the `build' package:
2881 # Makefile for build lisp code
2883 # This file is part of XEmacs.
2885 # XEmacs is free software; you can redistribute it and/or modify it
2886 # under the terms of the GNU General Public License as published by the
2887 # Free Software Foundation; either version 2, or (at your option) any
2890 # XEmacs is distributed in the hope that it will be useful, but WITHOUT
2891 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2892 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2895 # You should have received a copy of the GNU General Public License
2896 # along with XEmacs; see the file COPYING. If not, write to
2897 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
2898 # Boston, MA 02111-1307, USA.
2900 # For the time being, remove MULE_ELCS from the all dependencies if
2901 # building without Mule.
2904 AUTHOR_VERSION = 2.02
2905 MAINTAINER = Adrian Aichner <adrian@xemacs.org>
2908 REQUIRES = xemacs-base pcl-cvs dired w3 prog-modes
2911 ELCS = build.elc build-report.elc
2915 include ../../XEmacs.rules
2917 Most packages don't need any more than what you see above. It is
2918 usually _not_ necessary to specify any special `Makefile' rules.
2919 Everything is handled from the `*.rules' files in the toplevel of the
2920 package source hierarchy.
2922 Of course, with that said, there are always exceptions to the rule.
2923 If you think that your package will need some special `Makefile'
2924 hackery contact the XEmacs developers <xemacs-beta@xemacs.org>. We
2925 distribute over 100 packages so the chances are good that you won't be
2926 the first to need such hackery and it is probably already catered for.
2928 `Makefile' Variables Explained:
2929 -------------------------------
2931 A number of `make' variables are defined by the XEmacs Packaging
2932 System. Some are required, others are optional. Of course your
2933 `Makefile' may define other variables for private use, but you should
2934 be careful not to choose names that conflict with variables defined and
2935 used by the XEmacs Packaging System.
2937 The required variables are described in the table below. The
2938 corresponding field names for `package-info.in', where relevant, are
2939 given in parentheses.
2942 (version) The version of the XEmacs package, a numeric literal (a
2943 decimal fixed-point number with two-places of precision). The
2944 only person who ever needs to touch this is the XEmacs Packages
2948 (author-version) The upstream author's version, an uninterpreted
2952 (maintainer) A literal containing the XEmacs package's maintainer
2953 and his/her email address.
2956 The name of the package, a literal
2959 The type of package, a literal containing either `regular' for
2960 regular packages, or `single-file' for single-file packages. This
2961 should feed the `type' field in `package-info.in', but currently
2964 *N.B.* `single-file' here does _not_ refer to the number of lisp
2965 files in a package. *Note Package Terminology::.
2968 (category) A literal, either `standard' or `mule'. The non-Mule
2969 packages are `standard' and the Mule packages are, you guessed it,
2970 `mule'. This field is used at package installation time as part of
2971 the process of determining where a package should be installed to.
2974 (requires) A list of packages required to correctly build this
2977 Note that the usual form in `package-info.in' already has the
2978 parentheses, so the `make' variable should be set to a
2979 space-separated list of package names _not_ enclosed in
2982 The list is of _packages_, not _libraries_, as would ordinarily be
2983 provided to the Lisp `require' function.
2985 `REQUIRES' cannot be correctly computed from the calls to
2986 `require' in the package's library sources. `REQUIRES' is used to
2987 ensure that all macro and defstruct definitions used by the
2988 package are available at build time. This is not merely a matter
2989 of efficiency, to get the expansions inlined. In fact, it is
2990 _impossible_ to call a macro by name in byte-compiled Emacs Lisp
2991 code. Thus, if the macro expansion is not inlined, the call will
2992 result in an error at run-time! Thus, packages providing
2993 libraries that would be loaded because of autoload definitions
2994 must also be included.
2997 The list of the byte-compiled Lisp files used by the package.
2998 These files and their `.el' versions will be included in the binary
2999 package. This variable determines which libraries will be
3000 byte-compiled. These libraries are also deleted by `make clean'.
3002 Note there is no sanity-checking done on this variable. If you put
3003 `.el' files in here, they will not be compiled and they _will_ be
3004 deleted by `make clean'. You would surely be very distressed if
3005 that happened, so be very careful. If this variable is left
3006 empty, none of your Lisp code will be compiled or packaged. This
3007 would be a less than amusing surprise, too.
3009 We don't consider this a feature, of course. Please do submit
3010 code to do sanity checking to <xemacs-patches@xemacs.org>.
3012 Optional, but commonly used variables are explained below.
3015 A list of extra byte-compiled Lisp files used by the package to be
3016 installed in a subdirectory of the package's lisp directory. The
3017 same care should be taken with this as with ELCS in regard to
3021 The name of the subdirectory for the ELCS_1 files to be installed
3022 to. Be sure to include `$(PACKAGE)/' as part of the name.
3024 ELCS_1_DEST = $(PACKAGE)/extra
3026 Would put the ELCS_1 files for the package, `foo' into
3027 `xemacs-packages/lisp/foo/extra/'.
3029 `EARLY_GENERATED_LISP'
3030 For additional `.el' files that will be generated before any
3031 byte-compiling happens. Use this for `autoload-type' files. You
3032 must write `Makefile' rules to build these files.
3035 For additional `.el' files that will be generated at
3036 byte-compilation time. You must write `Makefile' rules to build
3040 This is used if you need to pass extra command line arguments to
3041 XEmacs to build the package. For instance, a specification for
3042 loading libraries containing macros before compiling the Lisp in
3043 the package. This is spliced directly into the invocation of
3044 XEmacs for byte-compilation, so it must contain the `-l' flag for
3047 PRELOADS=-l ./apackage-macros.el -l ../bpackage/lisp/bpackage-macros.el
3049 Preloads are loaded before `package-compile.el', so the LOAD-PATH
3050 is minimal. Therefore `PRELOADS' must specify a full path to
3051 packaged Lisp. The base LOAD-PATH does include the core Lisp
3052 directory, so core libraries are found.
3055 The subdirectory in the package's source tree where the `.el' files
3056 reside. This is where the `auto-autoloads.el' file will be placed.
3058 *N.B.* There is no need to use this variable if the `.el' files
3059 are in the package's toplevel directory. AUTOLOAD_PATH defaults
3063 Place calls to `package-suppress' here to indicate Lisp libraries
3064 that should only be available to particular versions of XEmacs.
3067 PACKAGE_SUPPRESS = \
3068 (package-suppress 'xemacs-base \"regexp-opt\" '(emacs-version>= 21 5 11)) \
3069 (package-suppress 'xemacs-base \"easy-mmode\" '(emacs-version>= 21 5 11))
3071 *N.B.* This feature has not yet been implemented in XEmacs yet.
3072 It will appear in an upcoming version of XEmacs 21.5.
3075 Set this to `t' if your package's Texinfo source file is located in
3076 the package's toplevel directory _and_ is named `$(PACKAGE).texi'.
3079 Use this to explicitly list Texinfo sources that _aren't_ in the
3080 package's toplevel directory. For example:
3082 EXPLICIT_DOCS = texi/$(PACKAGE).texi
3084 See DOCS_TXI_EXTENSION and DOCS_TEXINFO_EXTENSION if you don't use
3085 the `.texi' file extension on your Texinfo sources.
3088 List here extra Texinfo source files needed to build your
3089 documentation. Whatever is listed here is passed on to `makeinfo'
3093 Use this to specify extra `.html' files to output.
3095 `DOCS_TEXINFO_EXTENSION'
3096 Set this to `t' if your Texinfo source files have a `.texinfo'
3099 `DOCS_TXI_EXTENSION'
3100 Set this to `t' if your Texinfo source files have a `.txi'
3104 Files listed here will be installed to `.../man/$(PACKAGE)/'. For
3105 example, you might want to list TeX files or `.eps' files here.
3108 Other files (such as extra Lisp sources or an upstream `Makefile')
3109 that are normally placed in the installed Lisp directory, but not
3110 byte-compiled. These files are _preserved_ by the `clean' targets.
3113 For files that need to be installed to `lib-src/$(PACKAGE)/'. If
3114 the files listed here need to be built you will have to write
3115 `Makefile' rules to do so.
3118 Any data files, such as pixmaps, READMEs, and ChangeLogs. These
3119 must be paths relative to the root of the package's source tree.
3120 These files will be copied to `$(DATA_DEST)' for installation.
3121 Any directory component of the path for a file will be stripped,
3122 so that the file ends up in `$(DATA_DEST)', not in a subdiredtory.
3125 The directory where the files in DATA_FILES are installed to. It
3126 is a subdirectory of the installed `etc/' directory. Be sure to
3127 prefix this value with `$(PACKAGE)', for example:
3129 DATA_DEST = $(PACKAGE)/foo
3131 Would put files into `.../etc/$(PACKAGE)/foo/'.
3133 `DATA_1_FILES ... DATA_35_FILES'
3134 For data files that need to go into a different directory from
3137 `DATA_1_DEST ... DATA_35_DEST'
3138 The name of the subdirectory for files specified in DATA_N_FILES.
3139 And like DATA_DEST, be sure to prefix `$(PACKAGE)' to the value of
3142 `EXTRA_DEPENDENCIES'
3143 For additional files to build that aren't appropriate to place in
3144 any other `Makefile' variable. You will need to write `Makefile'
3145 rules to build these files.
3147 `package-compile.el'
3148 ====================
3150 The XEmacs Packaging System does not automatically become aware of your
3151 package simply because there is a new subtree. If any package,
3152 including your own, requires any of your files, it must be explicitly
3153 added to the compile environment or loads/requires that search
3154 load-path will fail. The changes that need to be made are
3156 *an entry in `package-directory-map'*
3157 This tells the XEmacs Packaging System which distribution
3158 (currently `xemacs-packages' or `mule-packages') your package is
3159 found in. It then looks in the distribution subdirectory whose
3160 name is the same as the package's.
3162 *an entry in the `cond' in `package-name-to-directory'*
3163 This is optional; it is necessary only if you keep your Lisp code
3164 somewhere other than the top-level directory of the package's
3165 source tree, eg, in `packages/xemacs-packages/PACKAGE/lisp'.
3167 This only needs to be done once, when the package is first added to
3168 the XEmacs Packaging System. (Well, when you randomly change the
3169 subdirectory layout, too.) Your changes to `package-compile.el' must
3170 be cleared and checked in by the XEmacs Package Release Engineer before
3171 your package will build correctly from a fresh checkout.
3173 This is unfortunate; it works pretty well once set up, but can cause
3174 confusion when first building a package in the XEmacs Packaging System
3175 context. In particular, if the `package-directory-map' entry for a
3176 required package, including the package itself, is not found, the
3177 necessary requires will not be executed by `package-compile.el'. If
3178 required functions are executed (under `eval-when-compile'), they won't
3179 be found and the compile will fail. If required function is actually a
3180 macro, the byte compiler will not recognize that, compile a function
3181 call to the macro. This will cause a run-time error because the
3182 byte-code interpreter does not know how to execute macros. (Macros can
3183 always be expanded at compile-time, and this is more efficient.)
3185 If your package keeps some or all Lisp code somewhere other than the
3186 top directory, then an entry in `package-name-to-directory' is also
3187 necessary, or requires will fail, leading to the problems just
3191 File: lispref.info, Node: Documenting Packages, Next: Issues, Prev: Creating Packages, Up: Packaging
3193 Documenting Packages:
3194 =====================
3196 Some random notes on documenting your package.
3198 Do write a Texinfo file. It's not that hard to do basically, and
3199 even using the more advanced features of Texinfo soon become natural.
3200 For a start, just grab the template `Samples/package.texi' from the
3201 XEmacs Packaging System source tree, and drop your current README into
3202 the Top node. At least this way your documentation will be accessible
3203 from the standard Info readers. Next, try to add lots of
3204 cross-referencing and logical markup, and then node structure.
3206 Address both end users and developer issues. You may not be the
3209 If you are maintaining a package that is part of the GNU Emacs
3210 distribution, you'll likely find that you occasionally synchronize your
3211 package with the GNU Emacs sources. When you synch a file,
3212 conventionally you should place a comment just above the standard `;;;
3213 Code' comment that looks like this:
3216 ;; GNU Emacs 21.1, 2002-02-08, Stephen Turnbull <stephen@xemacs.org>
3218 This comment is a status flag; the ChangeLog doesn't really give the
3221 Do maintain a detailed ChangeLog.
3224 File: lispref.info, Node: Issues, Prev: Documenting Packages, Up: Packaging
3232 File: lispref.info, Node: Lisp Data Types, Next: Numbers, Prev: Packaging, Up: Top
3237 A Lisp "object" is a piece of data used and manipulated by Lisp
3238 programs. For our purposes, a "type" or "data type" is a set of
3241 Every object belongs to at least one type. Objects of the same type
3242 have similar structures and may usually be used in the same contexts.
3243 Types can overlap, and objects can belong to two or more types.
3244 Consequently, we can ask whether an object belongs to a particular type,
3245 but not for "the" type of an object.
3247 A few fundamental object types are built into XEmacs. These, from
3248 which all other types are constructed, are called "primitive types".
3249 Each object belongs to one and only one primitive type. These types
3250 include "integer", "character" (starting with XEmacs 20.0), "float",
3251 "cons", "symbol", "string", "vector", "bit-vector", "subr",
3252 "compiled-function", "hash-table", "range-table", "char-table",
3253 "weak-list", and several special types, such as "buffer", that are
3254 related to editing. (*Note Editing Types::.)
3256 Each primitive type has a corresponding Lisp function that checks
3257 whether an object is a member of that type.
3259 Note that Lisp is unlike many other languages in that Lisp objects
3260 are "self-typing": the primitive type of the object is implicit in the
3261 object itself. For example, if an object is a vector, nothing can treat
3262 it as a number; Lisp knows it is a vector, not a number.
3264 In most languages, the programmer must declare the data type of each
3265 variable, and the type is known by the compiler but not represented in
3266 the data. Such type declarations do not exist in XEmacs Lisp. A Lisp
3267 variable can have any type of value, and it remembers whatever value
3268 you store in it, type and all.
3270 This chapter describes the purpose, printed representation, and read
3271 syntax of each of the standard types in Emacs Lisp. Details on how to
3272 use these types can be found in later chapters.
3276 * Printed Representation:: How Lisp objects are represented as text.
3277 * Comments:: Comments and their formatting conventions.
3278 * Primitive Types:: List of all primitive types in XEmacs.
3279 * Programming Types:: Types found in all Lisp systems.
3280 * Editing Types:: Types specific to XEmacs.
3281 * Window-System Types:: Types specific to windowing systems.
3282 * Type Predicates:: Tests related to types.
3283 * Equality Predicates:: Tests of equality between any two objects.
3286 File: lispref.info, Node: Printed Representation, Next: Comments, Up: Lisp Data Types
3288 Printed Representation and Read Syntax
3289 ======================================
3291 The "printed representation" of an object is the format of the output
3292 generated by the Lisp printer (the function `prin1') for that object.
3293 The "read syntax" of an object is the format of the input accepted by
3294 the Lisp reader (the function `read') for that object. Most objects
3295 have more than one possible read syntax. Some types of object have no
3296 read syntax; except for these cases, the printed representation of an
3297 object is also a read syntax for it.
3299 In other languages, an expression is text; it has no other form. In
3300 Lisp, an expression is primarily a Lisp object and only secondarily the
3301 text that is the object's read syntax. Often there is no need to
3302 emphasize this distinction, but you must keep it in the back of your
3303 mind, or you will occasionally be very confused.
3305 Every type has a printed representation. Some types have no read
3306 syntax, since it may not make sense to enter objects of these types
3307 directly in a Lisp program. For example, the buffer type does not have
3308 a read syntax. Objects of these types are printed in "hash notation":
3309 the characters `#<' followed by a descriptive string (typically the
3310 type name followed by the name of the object), and closed with a
3311 matching `>'. Hash notation cannot be read at all, so the Lisp reader
3312 signals the error `invalid-read-syntax' whenever it encounters `#<'.
3315 => #<buffer "objects.texi">
3317 When you evaluate an expression interactively, the Lisp interpreter
3318 first reads the textual representation of it, producing a Lisp object,
3319 and then evaluates that object (*note Evaluation::). However,
3320 evaluation and reading are separate activities. Reading returns the
3321 Lisp object represented by the text that is read; the object may or may
3322 not be evaluated later. *Note Input Functions::, for a description of
3323 `read', the basic function for reading objects.
3326 File: lispref.info, Node: Comments, Next: Primitive Types, Prev: Printed Representation, Up: Lisp Data Types
3331 A "comment" is text that is written in a program only for the sake of
3332 humans that read the program, and that has no effect on the meaning of
3333 the program. In Lisp, a semicolon (`;') starts a comment if it is not
3334 within a string or character constant. The comment continues to the
3335 end of line. The Lisp reader discards comments; they do not become
3336 part of the Lisp objects which represent the program within the Lisp
3339 The `#@COUNT' construct, which skips the next COUNT characters, is
3340 useful for program-generated comments containing binary data. The
3341 XEmacs Lisp byte compiler uses this in its output files (*note Byte
3342 Compilation::). It isn't meant for source files, however.
3344 *Note Comment Tips::, for conventions for formatting comments.
3347 File: lispref.info, Node: Primitive Types, Next: Programming Types, Prev: Comments, Up: Lisp Data Types
3352 For reference, here is a list of all the primitive types that may exist
3353 in XEmacs. Note that some of these types may not exist in some XEmacs
3354 executables; that depends on the options that XEmacs was configured
3431 * window-configuration
3435 In addition, the following special types are created internally but
3436 will never be seen by Lisp code. You may encounter them, however, if
3437 you are debugging XEmacs. The printed representation of these objects
3438 begins `#<INTERNAL EMACS BUG', which indicates to the Lisp programmer
3439 that he has found an internal bug in XEmacs if he ever encounters any
3460 * symbol-value-buffer-local
3462 * symbol-value-forward
3464 * symbol-value-lisp-magic
3466 * symbol-value-varalias
3471 File: lispref.info, Node: Programming Types, Next: Editing Types, Prev: Primitive Types, Up: Lisp Data Types
3476 There are two general categories of types in XEmacs Lisp: those having
3477 to do with Lisp programming, and those having to do with editing. The
3478 former exist in many Lisp implementations, in one form or another. The
3479 latter are unique to XEmacs Lisp.
3483 * Integer Type:: Numbers without fractional parts.
3484 * Floating Point Type:: Numbers with fractional parts and with a large range.
3485 * Character Type:: The representation of letters, numbers and
3487 * Symbol Type:: A multi-use object that refers to a function,
3488 variable, or property list, and has a unique identity.
3489 * Sequence Type:: Both lists and arrays are classified as sequences.
3490 * Cons Cell Type:: Cons cells, and lists (which are made from cons cells).
3491 * Array Type:: Arrays include strings and vectors.
3492 * String Type:: An (efficient) array of characters.
3493 * Vector Type:: One-dimensional arrays.
3494 * Bit Vector Type:: An (efficient) array of bits.
3495 * Function Type:: A piece of executable code you can call from elsewhere.
3496 * Macro Type:: A method of expanding an expression into another
3497 expression, more fundamental but less pretty.
3498 * Primitive Function Type:: A function written in C, callable from Lisp.
3499 * Compiled-Function Type:: A function written in Lisp, then compiled.
3500 * Autoload Type:: A type used for automatically loading seldom-used
3502 * Char Table Type:: A mapping from characters to Lisp objects.
3503 * Hash Table Type:: A fast mapping between Lisp objects.
3504 * Range Table Type:: A mapping from ranges of integers to Lisp objects.
3505 * Weak List Type:: A list with special garbage-collection properties.
3508 File: lispref.info, Node: Integer Type, Next: Floating Point Type, Up: Programming Types
3513 The range of values for integers in XEmacs Lisp is -134217728 to
3514 134217727 (28 bits; i.e., -2**27 to 2**27 - 1) on most machines. (Some
3515 machines, in particular 64-bit machines such as the DEC Alpha, may
3516 provide a wider range.) It is important to note that the XEmacs Lisp
3517 arithmetic functions do not check for overflow. Thus `(1+ 134217727)'
3518 is -134217728 on most machines. (However, you _will_ get an error if
3519 you attempt to read an out-of-range number using the Lisp reader.)
3521 The read syntax for integers is a sequence of (base ten) digits with
3522 an optional sign at the beginning. (The printed representation produced
3523 by the Lisp interpreter never has a leading `+'.)
3525 -1 ; The integer -1.
3527 +1 ; Also the integer 1.
3528 268435457 ; Causes an error on a 28-bit implementation.
3530 *Note Numbers::, for more information.
3533 File: lispref.info, Node: Floating Point Type, Next: Character Type, Prev: Integer Type, Up: Programming Types
3538 XEmacs supports floating point numbers. The precise range of floating
3539 point numbers is machine-specific.
3541 The printed representation for floating point numbers requires either
3542 a decimal point (with at least one digit following), an exponent, or
3543 both. For example, `1500.0', `15e2', `15.0e2', `1.5e3', and `.15e4'
3544 are five ways of writing a floating point number whose value is 1500.
3545 They are all equivalent.
3547 *Note Numbers::, for more information.
3550 File: lispref.info, Node: Character Type, Next: Symbol Type, Prev: Floating Point Type, Up: Programming Types
3555 In XEmacs version 19, and in all versions of FSF GNU Emacs, a
3556 "character" in XEmacs Lisp is nothing more than an integer. This is
3557 yet another holdover from XEmacs Lisp's derivation from vintage-1980
3558 Lisps; modern versions of Lisp consider this equivalence a bad idea,
3559 and have separate character types. In XEmacs version 20, the modern
3560 convention is followed, and characters are their own primitive types.
3561 (This change was necessary in order for MULE, i.e. Asian-language,
3562 support to be correctly implemented.)
3564 Even in XEmacs version 20, remnants of the equivalence between
3565 characters and integers still exist; this is termed the "char-int
3566 confoundance disease". In particular, many functions such as `eq',
3567 `equal', and `memq' have equivalent functions (`old-eq', `old-equal',
3568 `old-memq', etc.) that pretend like characters are integers are the
3569 same. Byte code compiled under any version 19 Emacs will have all such
3570 functions mapped to their `old-' equivalents when the byte code is read
3571 into XEmacs 20. This is to preserve compatibility--Emacs 19 converts
3572 all constant characters to the equivalent integer during
3573 byte-compilation, and thus there is no other way to preserve byte-code
3574 compatibility even if the code has specifically been written with the
3575 distinction between characters and integers in mind.
3577 Every character has an equivalent integer, called the "character
3578 code". For example, the character `A' is represented as the
3579 integer 65, following the standard ASCII representation of characters.
3580 If XEmacs was not compiled with MULE support, the range of this integer
3581 will always be 0 to 255--eight bits, or one byte. (Integers outside
3582 this range are accepted but silently truncated; however, you should
3583 most decidedly _not_ rely on this, because it will not work under
3584 XEmacs with MULE support.) When MULE support is present, the range of
3585 character codes is much larger. (Currently, 19 bits are used.)
3587 FSF GNU Emacs uses kludgy character codes above 255 to represent
3588 keyboard input of ASCII characters in combination with certain
3589 modifiers. XEmacs does not use this (a more general mechanism is used
3590 that does not distinguish between ASCII keys and other keys), so you
3591 will never find character codes above 255 in a non-MULE XEmacs.
3593 Individual characters are not often used in programs. It is far more
3594 common to work with _strings_, which are sequences composed of
3595 characters. *Note String Type::.
3597 The read syntax for characters begins with a question mark, followed
3598 by the character (if it's printable) or some symbolic representation of
3599 it. In XEmacs 20, where characters are their own type, this is also the
3600 print representation. In XEmacs 19, however, where characters are
3601 really integers, the printed representation of a character is a decimal
3602 number. This is also a possible read syntax for a character, but
3603 writing characters that way in Lisp programs is a very bad idea. You
3604 should _always_ use the special read syntax formats that XEmacs Lisp
3605 provides for characters.
3607 The usual read syntax for alphanumeric characters is a question mark
3608 followed by the character; thus, `?A' for the character `A', `?B' for
3609 the character `B', and `?a' for the character `a'.
3619 You can use the same syntax for punctuation characters, but it is
3620 often a good idea to add a `\' so that the Emacs commands for editing
3621 Lisp code don't get confused. For example, `?\ ' is the way to write
3622 the space character. If the character is `\', you _must_ use a second
3623 `\' to quote it: `?\\'. XEmacs 20 always prints punctuation characters
3624 with a `\' in front of them, to avoid confusion.
3626 You can express the characters Control-g, backspace, tab, newline,
3627 vertical tab, formfeed, return, and escape as `?\a', `?\b', `?\t',
3628 `?\n', `?\v', `?\f', `?\r', `?\e', respectively. Their character codes
3629 are 7, 8, 9, 10, 11, 12, 13, and 27 in decimal. Thus,
3634 ?\b => ?\^H ; backspace, <BS>, `C-h'
3636 ?\t => ?\t ; tab, <TAB>, `C-i'
3638 ?\n => ?\n ; newline, <LFD>, `C-j'
3639 ?\v => ?\^K ; vertical tab, `C-k'
3640 ?\f => ?\^L ; formfeed character, `C-l'
3641 ?\r => ?\r ; carriage return, <RET>, `C-m'
3642 ?\e => ?\^[ ; escape character, <ESC>, `C-['
3643 ?\\ => ?\\ ; backslash character, `\'
3646 ?\b => 8 ; backspace, <BS>, `C-h'
3647 ?\t => 9 ; tab, <TAB>, `C-i'
3648 ?\n => 10 ; newline, <LFD>, `C-j'
3649 ?\v => 11 ; vertical tab, `C-k'
3650 ?\f => 12 ; formfeed character, `C-l'
3651 ?\r => 13 ; carriage return, <RET>, `C-m'
3652 ?\e => 27 ; escape character, <ESC>, `C-['
3653 ?\\ => 92 ; backslash character, `\'
3655 These sequences which start with backslash are also known as "escape
3656 sequences", because backslash plays the role of an escape character;
3657 this usage has nothing to do with the character <ESC>.
3659 Control characters may be represented using yet another read syntax.
3660 This consists of a question mark followed by a backslash, caret, and the
3661 corresponding non-control character, in either upper or lower case. For
3662 example, both `?\^I' and `?\^i' are valid read syntax for the character
3663 `C-i', the character whose value is 9.
3665 Instead of the `^', you can use `C-'; thus, `?\C-i' is equivalent to
3666 `?\^I' and to `?\^i':
3669 ?\^I => ?\t ?\C-I => ?\t
3670 (char-int ?\^I) => 9
3672 ?\^I => 9 ?\C-I => 9
3674 There is also a character read syntax beginning with `\M-'. This
3675 sets the high bit of the character code (same as adding 128 to the
3676 character code). For example, `?\M-A' stands for the character with
3677 character code 193, or 128 plus 65. You should _not_ use this syntax
3678 in your programs. It is a holdover of yet another confoundance disease
3679 from earlier Emacsen. (This was used to represent keyboard input with
3680 the <META> key set, thus the `M'; however, it conflicts with the
3681 legitimate ISO-8859-1 interpretation of the character code. For
3682 example, character code 193 is a lowercase `a' with an acute accent, in
3685 Finally, the most general read syntax consists of a question mark
3686 followed by a backslash and the character code in octal (up to three
3687 octal digits); thus, `?\101' for the character `A', `?\001' for the
3688 character `C-a', and `?\002' for the character `C-b'. Although this
3689 syntax can represent any ASCII character, it is preferred only when the
3690 precise octal value is more important than the ASCII representation.
3693 ?\012 => ?\n ?\n => ?\n ?\C-j => ?\n
3694 ?\101 => ?A ?A => ?A
3696 ?\012 => 10 ?\n => 10 ?\C-j => 10
3697 ?\101 => 65 ?A => 65
3699 A backslash is allowed, and harmless, preceding any character without
3700 a special escape meaning; thus, `?\+' is equivalent to `?+'. There is
3701 no reason to add a backslash before most characters. However, you
3702 should add a backslash before any of the characters `()\|;'`"#.,' to
3703 avoid confusing the Emacs commands for editing Lisp code. Also add a
3704 backslash before whitespace characters such as space, tab, newline and
3705 formfeed. However, it is cleaner to use one of the easily readable
3706 escape sequences, such as `\t', instead of an actual whitespace
3707 character such as a tab.
3710 File: lispref.info, Node: Symbol Type, Next: Sequence Type, Prev: Character Type, Up: Programming Types
3715 A "symbol" in XEmacs Lisp is an object with a name. The symbol name
3716 serves as the printed representation of the symbol. In ordinary use,
3717 the name is unique--no two symbols have the same name.
3719 A symbol can serve as a variable, as a function name, or to hold a
3720 property list. Or it may serve only to be distinct from all other Lisp
3721 objects, so that its presence in a data structure may be recognized
3722 reliably. In a given context, usually only one of these uses is
3723 intended. But you can use one symbol in all of these ways,
3726 A symbol name can contain any characters whatever. Most symbol names
3727 are written with letters, digits, and the punctuation characters
3728 `-+=*/'. Such names require no special punctuation; the characters of
3729 the name suffice as long as the name does not look like a number. (If
3730 it does, write a `\' at the beginning of the name to force
3731 interpretation as a symbol.) The characters `_~!@$%^&:<>{}' are less
3732 often used but also require no special punctuation. Any other
3733 characters may be included in a symbol's name by escaping them with a
3734 backslash. In contrast to its use in strings, however, a backslash in
3735 the name of a symbol simply quotes the single character that follows the
3736 backslash. For example, in a string, `\t' represents a tab character;
3737 in the name of a symbol, however, `\t' merely quotes the letter `t'.
3738 To have a symbol with a tab character in its name, you must actually
3739 use a tab (preceded with a backslash). But it's rare to do such a
3742 Common Lisp note: In Common Lisp, lower case letters are always
3743 "folded" to upper case, unless they are explicitly escaped. In
3744 Emacs Lisp, upper case and lower case letters are distinct.
3746 Here are several examples of symbol names. Note that the `+' in the
3747 fifth example is escaped to prevent it from being read as a number.
3748 This is not necessary in the sixth example because the rest of the name
3749 makes it invalid as a number.
3751 foo ; A symbol named `foo'.
3752 FOO ; A symbol named `FOO', different from `foo'.
3753 char-to-string ; A symbol named `char-to-string'.
3754 1+ ; A symbol named `1+'
3755 ; (not `+1', which is an integer).
3756 \+1 ; A symbol named `+1'
3757 ; (not a very readable name).
3758 \(*\ 1\ 2\) ; A symbol named `(* 1 2)' (a worse name).
3759 +-*/_~!@$%^&=:<>{} ; A symbol named `+-*/_~!@$%^&=:<>{}'.
3760 ; These characters need not be escaped.
3763 File: lispref.info, Node: Sequence Type, Next: Cons Cell Type, Prev: Symbol Type, Up: Programming Types
3768 A "sequence" is a Lisp object that represents an ordered set of
3769 elements. There are two kinds of sequence in XEmacs Lisp, lists and
3770 arrays. Thus, an object of type list or of type array is also
3771 considered a sequence.
3773 Arrays are further subdivided into strings, vectors, and bit vectors.
3774 Vectors can hold elements of any type, but string elements must be
3775 characters, and bit vector elements must be either 0 or 1. However, the
3776 characters in a string can have extents (*note Extents::) and text
3777 properties (*note Text Properties::) like characters in a buffer;
3778 vectors do not support extents or text properties even when their
3779 elements happen to be characters.
3781 Lists, strings, vectors, and bit vectors are different, but they have
3782 important similarities. For example, all have a length L, and all have
3783 elements which can be indexed from zero to L minus one. Also, several
3784 functions, called sequence functions, accept any kind of sequence. For
3785 example, the function `elt' can be used to extract an element of a
3786 sequence, given its index. *Note Sequences Arrays Vectors::.
3788 It is impossible to read the same sequence twice, since sequences are
3789 always created anew upon reading. If you read the read syntax for a
3790 sequence twice, you get two sequences with equal contents. There is one
3791 exception: the empty list `()' always stands for the same object, `nil'.
3794 File: lispref.info, Node: Cons Cell Type, Next: Array Type, Prev: Sequence Type, Up: Programming Types
3796 Cons Cell and List Types
3797 ------------------------
3799 A "cons cell" is an object comprising two pointers named the CAR and
3800 the CDR. Each of them can point to any Lisp object.
3802 A "list" is a series of cons cells, linked together so that the CDR
3803 of each cons cell points either to another cons cell or to the empty
3804 list. *Note Lists::, for functions that work on lists. Because most
3805 cons cells are used as part of lists, the phrase "list structure" has
3806 come to refer to any structure made out of cons cells.
3808 The names CAR and CDR have only historical meaning now. The
3809 original Lisp implementation ran on an IBM 704 computer which divided
3810 words into two parts, called the "address" part and the "decrement";
3811 CAR was an instruction to extract the contents of the address part of a
3812 register, and CDR an instruction to extract the contents of the
3813 decrement. By contrast, "cons cells" are named for the function `cons'
3814 that creates them, which in turn is named for its purpose, the
3815 construction of cells.
3817 Because cons cells are so central to Lisp, we also have a word for
3818 "an object which is not a cons cell". These objects are called "atoms".
3820 The read syntax and printed representation for lists are identical,
3821 and consist of a left parenthesis, an arbitrary number of elements, and
3822 a right parenthesis.
3824 Upon reading, each object inside the parentheses becomes an element
3825 of the list. That is, a cons cell is made for each element. The CAR
3826 of the cons cell points to the element, and its CDR points to the next
3827 cons cell of the list, which holds the next element in the list. The
3828 CDR of the last cons cell is set to point to `nil'.
3830 A list can be illustrated by a diagram in which the cons cells are
3831 shown as pairs of boxes. (The Lisp reader cannot read such an
3832 illustration; unlike the textual notation, which can be understood by
3833 both humans and computers, the box illustrations can be understood only
3834 by humans.) The following represents the three-element list `(rose
3837 ___ ___ ___ ___ ___ ___
3838 |___|___|--> |___|___|--> |___|___|--> nil
3841 --> rose --> violet --> buttercup
3843 In this diagram, each box represents a slot that can refer to any
3844 Lisp object. Each pair of boxes represents a cons cell. Each arrow is
3845 a reference to a Lisp object, either an atom or another cons cell.
3847 In this example, the first box, the CAR of the first cons cell,
3848 refers to or "contains" `rose' (a symbol). The second box, the CDR of
3849 the first cons cell, refers to the next pair of boxes, the second cons
3850 cell. The CAR of the second cons cell refers to `violet' and the CDR
3851 refers to the third cons cell. The CDR of the third (and last) cons
3852 cell refers to `nil'.
3854 Here is another diagram of the same list, `(rose violet buttercup)',
3855 sketched in a different manner:
3857 --------------- ---------------- -------------------
3858 | car | cdr | | car | cdr | | car | cdr |
3859 | rose | o-------->| violet | o-------->| buttercup | nil |
3861 --------------- ---------------- -------------------
3863 A list with no elements in it is the "empty list"; it is identical
3864 to the symbol `nil'. In other words, `nil' is both a symbol and a list.
3866 Here are examples of lists written in Lisp syntax:
3868 (A 2 "A") ; A list of three elements.
3869 () ; A list of no elements (the empty list).
3870 nil ; A list of no elements (the empty list).
3871 ("A ()") ; A list of one element: the string `"A ()"'.
3872 (A ()) ; A list of two elements: `A' and the empty list.
3873 (A nil) ; Equivalent to the previous.
3874 ((A B C)) ; A list of one element
3875 ; (which is a list of three elements).
3877 Here is the list `(A ())', or equivalently `(A nil)', depicted with
3881 |___|___|--> |___|___|--> nil
3888 * Dotted Pair Notation:: An alternative syntax for lists.
3889 * Association List Type:: A specially constructed list.
3892 File: lispref.info, Node: Dotted Pair Notation, Next: Association List Type, Up: Cons Cell Type
3894 Dotted Pair Notation
3895 ....................
3897 "Dotted pair notation" is an alternative syntax for cons cells that
3898 represents the CAR and CDR explicitly. In this syntax, `(A . B)'
3899 stands for a cons cell whose CAR is the object A, and whose CDR is the
3900 object B. Dotted pair notation is therefore more general than list
3901 syntax. In the dotted pair notation, the list `(1 2 3)' is written as
3902 `(1 . (2 . (3 . nil)))'. For `nil'-terminated lists, the two
3903 notations produce the same result, but list notation is usually clearer
3904 and more convenient when it is applicable. When printing a list, the
3905 dotted pair notation is only used if the CDR of a cell is not a list.
3907 Here's how box notation can illustrate dotted pairs. This example
3908 shows the pair `(rose . violet)':
3916 Dotted pair notation can be combined with list notation to represent
3917 a chain of cons cells with a non-`nil' final CDR. For example, `(rose
3918 violet . buttercup)' is equivalent to `(rose . (violet . buttercup))'.
3919 The object looks like this:
3922 |___|___|--> |___|___|--> buttercup
3927 These diagrams make it evident why `(rose . violet . buttercup)' is
3928 invalid syntax; it would require a cons cell that has three parts
3931 The list `(rose violet)' is equivalent to `(rose . (violet))' and
3935 |___|___|--> |___|___|--> nil
3940 Similarly, the three-element list `(rose violet buttercup)' is
3941 equivalent to `(rose . (violet . (buttercup)))'. It looks like this:
3943 ___ ___ ___ ___ ___ ___
3944 |___|___|--> |___|___|--> |___|___|--> nil
3947 --> rose --> violet --> buttercup
3950 File: lispref.info, Node: Association List Type, Prev: Dotted Pair Notation, Up: Cons Cell Type
3952 Association List Type
3953 .....................
3955 An "association list" or "alist" is a specially-constructed list whose
3956 elements are cons cells. In each element, the CAR is considered a
3957 "key", and the CDR is considered an "associated value". (In some
3958 cases, the associated value is stored in the CAR of the CDR.)
3959 Association lists are often used as stacks, since it is easy to add or
3960 remove associations at the front of the list.
3964 (setq alist-of-colors
3965 '((rose . red) (lily . white) (buttercup . yellow)))
3967 sets the variable `alist-of-colors' to an alist of three elements. In
3968 the first element, `rose' is the key and `red' is the value.
3970 *Note Association Lists::, for a further explanation of alists and
3971 for functions that work on alists.
3974 File: lispref.info, Node: Array Type, Next: String Type, Prev: Cons Cell Type, Up: Programming Types
3979 An "array" is composed of an arbitrary number of slots for referring to
3980 other Lisp objects, arranged in a contiguous block of memory.
3981 Accessing any element of an array takes the same amount of time. In
3982 contrast, accessing an element of a list requires time proportional to
3983 the position of the element in the list. (Elements at the end of a
3984 list take longer to access than elements at the beginning of a list.)
3986 XEmacs defines three types of array, strings, vectors, and bit
3987 vectors. A string is an array of characters, a vector is an array of
3988 arbitrary objects, and a bit vector is an array of 1's and 0's. All are
3989 one-dimensional. (Most other programming languages support
3990 multidimensional arrays, but they are not essential; you can get the
3991 same effect with an array of arrays.) Each type of array has its own
3992 read syntax; see *Note String Type::, *Note Vector Type::, and *Note
3995 An array may have any length up to the largest integer; but once
3996 created, it has a fixed size. The first element of an array has index
3997 zero, the second element has index 1, and so on. This is called
3998 "zero-origin" indexing. For example, an array of four elements has
3999 indices 0, 1, 2, and 3.
4001 The array type is contained in the sequence type and contains the
4002 string type, the vector type, and the bit vector type.
4005 File: lispref.info, Node: String Type, Next: Vector Type, Prev: Array Type, Up: Programming Types
4010 A "string" is an array of characters. Strings are used for many
4011 purposes in XEmacs, as can be expected in a text editor; for example, as
4012 the names of Lisp symbols, as messages for the user, and to represent
4013 text extracted from buffers. Strings in Lisp are constants: evaluation
4014 of a string returns the same string.
4016 The read syntax for strings is a double-quote, an arbitrary number of
4017 characters, and another double-quote, `"like this"'. The Lisp reader
4018 accepts the same formats for reading the characters of a string as it
4019 does for reading single characters (without the question mark that
4020 begins a character literal). You can enter a nonprinting character such
4021 as tab or `C-a' using the convenient escape sequences, like this: `"\t,
4022 \C-a"'. You can include a double-quote in a string by preceding it
4023 with a backslash; thus, `"\""' is a string containing just a single
4024 double-quote character. (*Note Character Type::, for a description of
4025 the read syntax for characters.)
4027 The printed representation of a string consists of a double-quote,
4028 the characters it contains, and another double-quote. However, you must
4029 escape any backslash or double-quote characters in the string with a
4030 backslash, like this: `"this \" is an embedded quote"'.
4032 The newline character is not special in the read syntax for strings;
4033 if you write a new line between the double-quotes, it becomes a
4034 character in the string. But an escaped newline--one that is preceded
4035 by `\'--does not become part of the string; i.e., the Lisp reader
4036 ignores an escaped newline while reading a string.
4038 "It is useful to include newlines
4039 in documentation strings,
4040 but the newline is \
4041 ignored if escaped."
4042 => "It is useful to include newlines
4043 in documentation strings,
4044 but the newline is ignored if escaped."
4046 A string can hold extents and properties of the text it contains, in
4047 addition to the characters themselves. This enables programs that copy
4048 text between strings and buffers to preserve the extents and properties
4049 with no special effort. *Note Extents::, *Note Text Properties::.
4051 Note that FSF GNU Emacs has a special read and print syntax for
4052 strings with text properties, but XEmacs does not currently implement
4053 this. It was judged better not to include this in XEmacs because it
4054 entails that `equal' return `nil' when passed a string with text
4055 properties and the equivalent string without text properties, which is
4056 often counter-intuitive.
4058 *Note Strings and Characters::, for functions that work on strings.
4061 File: lispref.info, Node: Vector Type, Next: Bit Vector Type, Prev: String Type, Up: Programming Types
4066 A "vector" is a one-dimensional array of elements of any type. It
4067 takes a constant amount of time to access any element of a vector. (In
4068 a list, the access time of an element is proportional to the distance of
4069 the element from the beginning of the list.)
4071 The printed representation of a vector consists of a left square
4072 bracket, the elements, and a right square bracket. This is also the
4073 read syntax. Like numbers and strings, vectors are considered constants
4076 [1 "two" (three)] ; A vector of three elements.
4077 => [1 "two" (three)]
4079 *Note Vectors::, for functions that work with vectors.
4082 File: lispref.info, Node: Bit Vector Type, Next: Function Type, Prev: Vector Type, Up: Programming Types
4087 A "bit vector" is a one-dimensional array of 1's and 0's. It takes a
4088 constant amount of time to access any element of a bit vector, as for
4089 vectors. Bit vectors have an extremely compact internal representation
4090 (one machine bit per element), which makes them ideal for keeping track
4091 of unordered sets, large collections of boolean values, etc.
4093 The printed representation of a bit vector consists of `#*' followed
4094 by the bits in the vector. This is also the read syntax. Like
4095 numbers, strings, and vectors, bit vectors are considered constants for
4098 #*00101000 ; A bit vector of eight elements.
4101 *Note Bit Vectors::, for functions that work with bit vectors.
4104 File: lispref.info, Node: Function Type, Next: Macro Type, Prev: Bit Vector Type, Up: Programming Types
4109 Just as functions in other programming languages are executable, "Lisp
4110 function" objects are pieces of executable code. However, functions in
4111 Lisp are primarily Lisp objects, and only secondarily the text which
4112 represents them. These Lisp objects are lambda expressions: lists
4113 whose first element is the symbol `lambda' (*note Lambda Expressions::).
4115 In most programming languages, it is impossible to have a function
4116 without a name. In Lisp, a function has no intrinsic name. A lambda
4117 expression is also called an "anonymous function" (*note Anonymous
4118 Functions::). A named function in Lisp is actually a symbol with a
4119 valid function in its function cell (*note Defining Functions::).
4121 Most of the time, functions are called when their names are written
4122 in Lisp expressions in Lisp programs. However, you can construct or
4123 obtain a function object at run time and then call it with the primitive
4124 functions `funcall' and `apply'. *Note Calling Functions::.
4127 File: lispref.info, Node: Macro Type, Next: Primitive Function Type, Prev: Function Type, Up: Programming Types
4132 A "Lisp macro" is a user-defined construct that extends the Lisp
4133 language. It is represented as an object much like a function, but with
4134 different parameter-passing semantics. A Lisp macro has the form of a
4135 list whose first element is the symbol `macro' and whose CDR is a Lisp
4136 function object, including the `lambda' symbol.
4138 Lisp macro objects are usually defined with the built-in `defmacro'
4139 function, but any list that begins with `macro' is a macro as far as
4140 XEmacs is concerned. *Note Macros::, for an explanation of how to
4144 File: lispref.info, Node: Primitive Function Type, Next: Compiled-Function Type, Prev: Macro Type, Up: Programming Types
4146 Primitive Function Type
4147 -----------------------
4149 A "primitive function" is a function callable from Lisp but written in
4150 the C programming language. Primitive functions are also called
4151 "subrs" or "built-in functions". (The word "subr" is derived from
4152 "subroutine".) Most primitive functions evaluate all their arguments
4153 when they are called. A primitive function that does not evaluate all
4154 its arguments is called a "special form" (*note Special Forms::).
4156 It does not matter to the caller of a function whether the function
4157 is primitive. However, this does matter if you try to substitute a
4158 function written in Lisp for a primitive of the same name. The reason
4159 is that the primitive function may be called directly from C code.
4160 Calls to the redefined function from Lisp will use the new definition,
4161 but calls from C code may still use the built-in definition.
4163 The term "function" refers to all Emacs functions, whether written
4164 in Lisp or C. *Note Function Type::, for information about the
4165 functions written in Lisp.
4167 Primitive functions have no read syntax and print in hash notation
4168 with the name of the subroutine.
4170 (symbol-function 'car) ; Access the function cell
4173 (subrp (symbol-function 'car)) ; Is this a primitive function?
4177 File: lispref.info, Node: Compiled-Function Type, Next: Autoload Type, Prev: Primitive Function Type, Up: Programming Types
4179 Compiled-Function Type
4180 ----------------------
4182 The byte compiler produces "compiled-function objects". The evaluator
4183 handles this data type specially when it appears as a function to be
4184 called. *Note Byte Compilation::, for information about the byte
4187 The printed representation for a compiled-function object is normally
4188 `#<compiled-function...>'. If `print-readably' is true, however, it is
4192 File: lispref.info, Node: Autoload Type, Next: Char Table Type, Prev: Compiled-Function Type, Up: Programming Types
4197 An "autoload object" is a list whose first element is the symbol
4198 `autoload'. It is stored as the function definition of a symbol as a
4199 placeholder for the real definition; it says that the real definition
4200 is found in a file of Lisp code that should be loaded when necessary.
4201 The autoload object contains the name of the file, plus some other
4202 information about the real definition.
4204 After the file has been loaded, the symbol should have a new function
4205 definition that is not an autoload object. The new definition is then
4206 called as if it had been there to begin with. From the user's point of
4207 view, the function call works as expected, using the function definition
4210 An autoload object is usually created with the function `autoload',
4211 which stores the object in the function cell of a symbol. *Note
4212 Autoload::, for more details.
4215 File: lispref.info, Node: Char Table Type, Next: Hash Table Type, Prev: Autoload Type, Up: Programming Types
4220 (not yet documented)
4223 File: lispref.info, Node: Hash Table Type, Next: Range Table Type, Prev: Char Table Type, Up: Programming Types
4228 A "hash table" is a table providing an arbitrary mapping from one Lisp
4229 object to another, using an internal indexing method called "hashing".
4230 Hash tables are very fast (much more efficient that using an
4231 association list, when there are a large number of elements in the
4234 Hash tables have a special read syntax beginning with
4235 `#s(hash-table' (this is an example of "structure" read syntax. This
4236 notation is also used for printing when `print-readably' is `t'.
4238 Otherwise they print in hash notation (The "hash" in "hash notation"
4239 has nothing to do with the "hash" in "hash table"), giving the number
4240 of elements, total space allocated for elements, and a unique number
4241 assigned at the time the hash table was created. (Hash tables
4242 automatically resize as necessary so there is no danger of running out
4243 of space for elements.)
4245 (make-hash-table :size 50)
4246 => #<hash-table 0/107 0x313a>
4248 *Note Hash Tables::, for information on how to create and work with
4252 File: lispref.info, Node: Range Table Type, Next: Weak List Type, Prev: Hash Table Type, Up: Programming Types
4257 A "range table" is a table that maps from ranges of integers to
4258 arbitrary Lisp objects. Range tables automatically combine overlapping
4259 ranges that map to the same Lisp object, and operations are provided
4260 for mapping over all of the ranges in a range table.
4262 Range tables have a special read syntax beginning with
4263 `#s(range-table' (this is an example of "structure" read syntax, which
4264 is also used for char tables and faces).
4266 (setq x (make-range-table))
4267 (put-range-table 20 50 'foo x)
4268 (put-range-table 100 200 "bar" x)
4270 => #s(range-table data ((20 50) foo (100 200) "bar"))
4272 *Note Range Tables::, for information on how to create and work with
4276 File: lispref.info, Node: Weak List Type, Prev: Range Table Type, Up: Programming Types
4281 (not yet documented)
4284 File: lispref.info, Node: Editing Types, Next: Window-System Types, Prev: Programming Types, Up: Lisp Data Types
4289 The types in the previous section are common to many Lisp dialects.
4290 XEmacs Lisp provides several additional data types for purposes
4291 connected with editing.
4295 * Buffer Type:: The basic object of editing.
4296 * Marker Type:: A position in a buffer.
4297 * Extent Type:: A range in a buffer or string, maybe with properties.
4298 * Window Type:: Buffers are displayed in windows.
4299 * Frame Type:: Windows subdivide frames.
4300 * Device Type:: Devices group all frames on a display.
4301 * Console Type:: Consoles group all devices with the same keyboard.
4302 * Window Configuration Type:: Recording the way a frame is subdivided.
4303 * Event Type:: An interesting occurrence in the system.
4304 * Process Type:: A process running on the underlying OS.
4305 * Stream Type:: Receive or send characters.
4306 * Keymap Type:: What function a keystroke invokes.
4307 * Syntax Table Type:: What a character means.
4308 * Display Table Type:: How display tables are represented.
4309 * Database Type:: A connection to an external DBM or DB database.
4310 * Charset Type:: A character set (e.g. all Kanji characters),
4312 * Coding System Type:: An object encapsulating a way of converting between
4313 different textual encodings, under XEmacs/MULE.
4314 * ToolTalk Message Type:: A message, in the ToolTalk IPC protocol.
4315 * ToolTalk Pattern Type:: A pattern, in the ToolTalk IPC protocol.
4318 File: lispref.info, Node: Buffer Type, Next: Marker Type, Up: Editing Types
4323 A "buffer" is an object that holds text that can be edited (*note
4324 Buffers::). Most buffers hold the contents of a disk file (*note
4325 Files::) so they can be edited, but some are used for other purposes.
4326 Most buffers are also meant to be seen by the user, and therefore
4327 displayed, at some time, in a window (*note Windows::). But a buffer
4328 need not be displayed in any window.
4330 The contents of a buffer are much like a string, but buffers are not
4331 used like strings in XEmacs Lisp, and the available operations are
4332 different. For example, insertion of text into a buffer is very
4333 efficient, whereas "inserting" text into a string requires
4334 concatenating substrings, and the result is an entirely new string
4337 Each buffer has a designated position called "point" (*note
4338 Positions::). At any time, one buffer is the "current buffer". Most
4339 editing commands act on the contents of the current buffer in the
4340 neighborhood of point. Many of the standard Emacs functions manipulate
4341 or test the characters in the current buffer; a whole chapter in this
4342 manual is devoted to describing these functions (*note Text::).
4344 Several other data structures are associated with each buffer:
4346 * a local syntax table (*note Syntax Tables::);
4348 * a local keymap (*note Keymaps::);
4350 * a local variable binding list (*note Buffer-Local Variables::);
4352 * a list of extents (*note Extents::);
4354 * and various other related properties.
4356 The local keymap and variable list contain entries that individually
4357 override global bindings or values. These are used to customize the
4358 behavior of programs in different buffers, without actually changing the
4361 A buffer may be "indirect", which means it shares the text of
4362 another buffer. *Note Indirect Buffers::.
4364 Buffers have no read syntax. They print in hash notation, showing
4368 => #<buffer "objects.texi">
4371 File: lispref.info, Node: Marker Type, Next: Extent Type, Prev: Buffer Type, Up: Editing Types
4376 A "marker" denotes a position in a specific buffer. Markers therefore
4377 have two components: one for the buffer, and one for the position.
4378 Changes in the buffer's text automatically relocate the position value
4379 as necessary to ensure that the marker always points between the same
4380 two characters in the buffer.
4382 Markers have no read syntax. They print in hash notation, giving the
4383 current character position and the name of the buffer.
4386 => #<marker at 50661 in objects.texi>
4388 *Note Markers::, for information on how to test, create, copy, and
4392 File: lispref.info, Node: Extent Type, Next: Window Type, Prev: Marker Type, Up: Editing Types
4397 An "extent" specifies temporary alteration of the display appearance of
4398 a part of a buffer (or string). It contains markers delimiting a range
4399 of the buffer, plus a property list (a list whose elements are
4400 alternating property names and values). Extents are used to present
4401 parts of the buffer temporarily in a different display style. They
4402 have no read syntax, and print in hash notation, giving the buffer name
4403 and range of positions.
4405 Extents can exist over strings as well as buffers; the primary use
4406 of this is to preserve extent and text property information as text is
4407 copied from one buffer to another or between different parts of a
4410 Extents have no read syntax. They print in hash notation, giving the
4411 range of text they cover, the name of the buffer or string they are in,
4412 the address in core, and a summary of some of the properties attached to
4416 => #<extent [51742, 51748) font-lock text-prop 0x90121e0 in buffer objects.texi>
4418 *Note Extents::, for how to create and use extents.
4420 Extents are used to implement text properties. *Note Text
4424 File: lispref.info, Node: Window Type, Next: Frame Type, Prev: Extent Type, Up: Editing Types
4429 A "window" describes the portion of the frame that XEmacs uses to
4430 display a buffer. (In standard window-system usage, a "window" is what
4431 XEmacs calls a "frame"; XEmacs confusingly uses the term "window" to
4432 refer to what is called a "pane" in standard window-system usage.)
4433 Every window has one associated buffer, whose contents appear in the
4434 window. By contrast, a given buffer may appear in one window, no
4435 window, or several windows.
4437 Though many windows may exist simultaneously, at any time one window
4438 is designated the "selected window". This is the window where the
4439 cursor is (usually) displayed when XEmacs is ready for a command. The
4440 selected window usually displays the current buffer, but this is not
4441 necessarily the case.
4443 Windows are grouped on the screen into frames; each window belongs to
4444 one and only one frame. *Note Frame Type::.
4446 Windows have no read syntax. They print in hash notation, giving the
4447 name of the buffer being displayed and a unique number assigned at the
4448 time the window was created. (This number can be useful because the
4449 buffer displayed in any given window can change frequently.)
4452 => #<window on "objects.texi" 0x266c>
4454 *Note Windows::, for a description of the functions that work on
4458 File: lispref.info, Node: Frame Type, Next: Device Type, Prev: Window Type, Up: Editing Types
4463 A FRAME is a rectangle on the screen (a "window" in standard
4464 window-system terminology) that contains one or more non-overlapping
4465 Emacs windows ("panes" in standard window-system terminology). A frame
4466 initially contains a single main window (plus perhaps a minibuffer
4467 window) which you can subdivide vertically or horizontally into smaller
4470 Frames have no read syntax. They print in hash notation, giving the
4471 frame's type, name as used for resourcing, and a unique number assigned
4472 at the time the frame was created.
4475 => #<x-frame "emacs" 0x9db>
4477 *Note Frames::, for a description of the functions that work on
4481 File: lispref.info, Node: Device Type, Next: Console Type, Prev: Frame Type, Up: Editing Types
4486 A "device" represents a single display on which frames exist.
4487 Normally, there is only one device object, but there may be more than
4488 one if XEmacs is being run on a multi-headed display (e.g. an X server
4489 with attached color and mono screens) or if XEmacs is simultaneously
4490 driving frames attached to different consoles, e.g. an X display and a
4493 Devices do not have a read syntax. They print in hash notation,
4494 giving the device's type, connection name, and a unique number assigned
4495 at the time the device was created.
4498 => #<x-device on ":0.0" 0x5b9>
4500 *Note Consoles and Devices::, for a description of several functions
4504 File: lispref.info, Node: Console Type, Next: Window Configuration Type, Prev: Device Type, Up: Editing Types
4509 A "console" represents a single keyboard to which devices (i.e.
4510 displays on which frames exist) are connected. Normally, there is only
4511 one console object, but there may be more than one if XEmacs is
4512 simultaneously driving frames attached to different X servers and/or
4513 TTY connections. (XEmacs is capable of driving multiple X and TTY
4514 connections at the same time, and provides a robust mechanism for
4515 handling the differing display capabilities of such heterogeneous
4516 environments. A buffer with embedded glyphs and multiple fonts and
4517 colors, for example, will display reasonably if it simultaneously
4518 appears on a frame on a color X display, a frame on a mono X display,
4519 and a frame on a TTY connection.)
4521 Consoles do not have a read syntax. They print in hash notation,
4522 giving the console's type, connection name, and a unique number assigned
4523 at the time the console was created.
4526 => #<x-console on "localhost:0" 0x5b7>
4528 *Note Consoles and Devices::, for a description of several functions
4529 related to consoles.
4532 File: lispref.info, Node: Window Configuration Type, Next: Event Type, Prev: Console Type, Up: Editing Types
4534 Window Configuration Type
4535 -------------------------
4537 A "window configuration" stores information about the positions, sizes,
4538 and contents of the windows in a frame, so you can recreate the same
4539 arrangement of windows later.
4541 Window configurations do not have a read syntax. They print in hash
4542 notation, giving a unique number assigned at the time the window
4543 configuration was created.
4545 (current-window-configuration)
4546 => #<window-configuration 0x2db4>
4548 *Note Window Configurations::, for a description of several functions
4549 related to window configurations.
4552 File: lispref.info, Node: Event Type, Next: Process Type, Prev: Window Configuration Type, Up: Editing Types
4557 (not yet documented)
4560 File: lispref.info, Node: Process Type, Next: Stream Type, Prev: Event Type, Up: Editing Types
4565 The word "process" usually means a running program. XEmacs itself runs
4566 in a process of this sort. However, in XEmacs Lisp, a process is a
4567 Lisp object that designates a subprocess created by the XEmacs process.
4568 Programs such as shells, GDB, ftp, and compilers, running in
4569 subprocesses of XEmacs, extend the capabilities of XEmacs.
4571 An Emacs subprocess takes textual input from Emacs and returns
4572 textual output to Emacs for further manipulation. Emacs can also send
4573 signals to the subprocess.
4575 Process objects have no read syntax. They print in hash notation,
4576 giving the name of the process, its associated process ID, and the
4577 current state of the process:
4580 => (#<process "shell" pid 2909 state:run>)
4582 *Note Processes::, for information about functions that create,
4583 delete, return information about, send input or signals to, and receive
4584 output from processes.
4587 File: lispref.info, Node: Stream Type, Next: Keymap Type, Prev: Process Type, Up: Editing Types
4592 A "stream" is an object that can be used as a source or sink for
4593 characters--either to supply characters for input or to accept them as
4594 output. Many different types can be used this way: markers, buffers,
4595 strings, and functions. Most often, input streams (character sources)
4596 obtain characters from the keyboard, a buffer, or a file, and output
4597 streams (character sinks) send characters to a buffer, such as a
4598 `*Help*' buffer, or to the echo area.
4600 The object `nil', in addition to its other meanings, may be used as
4601 a stream. It stands for the value of the variable `standard-input' or
4602 `standard-output'. Also, the object `t' as a stream specifies input
4603 using the minibuffer (*note Minibuffers::) or output in the echo area
4604 (*note The Echo Area::).
4606 Streams have no special printed representation or read syntax, and
4607 print as whatever primitive type they are.
4609 *Note Read and Print::, for a description of functions related to
4610 streams, including parsing and printing functions.
4613 File: lispref.info, Node: Keymap Type, Next: Syntax Table Type, Prev: Stream Type, Up: Editing Types
4618 A "keymap" maps keys typed by the user to commands. This mapping
4619 controls how the user's command input is executed.
4621 NOTE: In XEmacs, a keymap is a separate primitive type. In FSF GNU
4622 Emacs, a keymap is actually a list whose CAR is the symbol `keymap'.
4624 *Note Keymaps::, for information about creating keymaps, handling
4625 prefix keys, local as well as global keymaps, and changing key bindings.
4628 File: lispref.info, Node: Syntax Table Type, Next: Display Table Type, Prev: Keymap Type, Up: Editing Types
4633 Under XEmacs 20, a "syntax table" is a particular type of char table.
4634 Under XEmacs 19, a syntax table a vector of 256 integers. In both
4635 cases, each element defines how one character is interpreted when it
4636 appears in a buffer. For example, in C mode (*note Major Modes::), the
4637 `+' character is punctuation, but in Lisp mode it is a valid character
4638 in a symbol. These modes specify different interpretations by changing
4639 the syntax table entry for `+'.
4641 Syntax tables are used only for scanning text in buffers, not for
4642 reading Lisp expressions. The table the Lisp interpreter uses to read
4643 expressions is built into the XEmacs source code and cannot be changed;
4644 thus, to change the list delimiters to be `{' and `}' instead of `('
4645 and `)' would be impossible.
4647 *Note Syntax Tables::, for details about syntax classes and how to
4648 make and modify syntax tables.
4651 File: lispref.info, Node: Display Table Type, Next: Database Type, Prev: Syntax Table Type, Up: Editing Types
4656 A "display table" specifies how to display each character code. Each
4657 buffer and each window can have its own display table. A display table
4658 is actually a vector of length 256, although in XEmacs 20 this may
4659 change to be a particular type of char table. *Note Display Tables::.
4662 File: lispref.info, Node: Database Type, Next: Charset Type, Prev: Display Table Type, Up: Editing Types
4667 (not yet documented)
4670 File: lispref.info, Node: Charset Type, Next: Coding System Type, Prev: Database Type, Up: Editing Types
4675 (not yet documented)
4678 File: lispref.info, Node: Coding System Type, Next: ToolTalk Message Type, Prev: Charset Type, Up: Editing Types
4683 (not yet documented)
4686 File: lispref.info, Node: ToolTalk Message Type, Next: ToolTalk Pattern Type, Prev: Coding System Type, Up: Editing Types
4688 ToolTalk Message Type
4689 ---------------------
4691 (not yet documented)
4694 File: lispref.info, Node: ToolTalk Pattern Type, Prev: ToolTalk Message Type, Up: Editing Types
4696 ToolTalk Pattern Type
4697 ---------------------
4699 (not yet documented)
4702 File: lispref.info, Node: Window-System Types, Next: Type Predicates, Prev: Editing Types, Up: Lisp Data Types
4707 XEmacs also has some types that represent objects such as faces
4708 (collections of display characters), fonts, and pixmaps that are
4709 commonly found in windowing systems.
4713 * Face Type:: A collection of display characteristics.
4714 * Glyph Type:: An image appearing in a buffer or elsewhere.
4715 * Specifier Type:: A way of controlling display characteristics on
4716 a per-buffer, -frame, -window, or -device level.
4717 * Font Instance Type:: The way a font appears on a particular device.
4718 * Color Instance Type:: The way a color appears on a particular device.
4719 * Image Instance Type:: The way an image appears on a particular device.
4720 * Toolbar Button Type:: An object representing a button in a toolbar.
4721 * Subwindow Type:: An externally-controlled window-system window
4722 appearing in a buffer.
4723 * X Resource Type:: A miscellaneous X resource, if Epoch support was
4724 compiled into XEmacs.
4727 File: lispref.info, Node: Face Type, Next: Glyph Type, Up: Window-System Types
4732 (not yet documented)
4735 File: lispref.info, Node: Glyph Type, Next: Specifier Type, Prev: Face Type, Up: Window-System Types
4740 (not yet documented)
4743 File: lispref.info, Node: Specifier Type, Next: Font Instance Type, Prev: Glyph Type, Up: Window-System Types
4748 (not yet documented)
4751 File: lispref.info, Node: Font Instance Type, Next: Color Instance Type, Prev: Specifier Type, Up: Window-System Types
4756 (not yet documented)
4759 File: lispref.info, Node: Color Instance Type, Next: Image Instance Type, Prev: Font Instance Type, Up: Window-System Types
4764 (not yet documented)
4767 File: lispref.info, Node: Image Instance Type, Next: Toolbar Button Type, Prev: Color Instance Type, Up: Window-System Types
4772 (not yet documented)
4775 File: lispref.info, Node: Toolbar Button Type, Next: Subwindow Type, Prev: Image Instance Type, Up: Window-System Types
4780 (not yet documented)
4783 File: lispref.info, Node: Subwindow Type, Next: X Resource Type, Prev: Toolbar Button Type, Up: Window-System Types
4788 (not yet documented)
4791 File: lispref.info, Node: X Resource Type, Prev: Subwindow Type, Up: Window-System Types
4796 (not yet documented)
4799 File: lispref.info, Node: Type Predicates, Next: Equality Predicates, Prev: Window-System Types, Up: Lisp Data Types
4804 The XEmacs Lisp interpreter itself does not perform type checking on
4805 the actual arguments passed to functions when they are called. It could
4806 not do so, since function arguments in Lisp do not have declared data
4807 types, as they do in other programming languages. It is therefore up to
4808 the individual function to test whether each actual argument belongs to
4809 a type that the function can use.
4811 All built-in functions do check the types of their actual arguments
4812 when appropriate, and signal a `wrong-type-argument' error if an
4813 argument is of the wrong type. For example, here is what happens if you
4814 pass an argument to `+' that it cannot handle:
4817 error--> Wrong type argument: integer-or-marker-p, a
4819 If you want your program to handle different types differently, you
4820 must do explicit type checking. The most common way to check the type
4821 of an object is to call a "type predicate" function. Emacs has a type
4822 predicate for each type, as well as some predicates for combinations of
4825 A type predicate function takes one argument; it returns `t' if the
4826 argument belongs to the appropriate type, and `nil' otherwise.
4827 Following a general Lisp convention for predicate functions, most type
4828 predicates' names end with `p'.
4830 Here is an example which uses the predicates `listp' to check for a
4831 list and `symbolp' to check for a symbol.
4835 ;; If X is a symbol, put it on LIST.
4836 (setq list (cons x list)))
4838 ;; If X is a list, add its elements to LIST.
4839 (setq list (append x list)))
4841 ;; We only handle symbols and lists.
4842 (error "Invalid argument %s in add-on" x))))
4844 Here is a table of predefined type predicates, in alphabetical order,
4845 with references to further information.
4848 *Note annotationp: Annotation Primitives.
4851 *Note arrayp: Array Functions.
4854 *Note atom: List-related Predicates.
4857 *Note bit-vector-p: Bit Vector Functions.
4860 *Note bitp: Bit Vector Functions.
4862 `boolean-specifier-p'
4863 *Note boolean-specifier-p: Specifier Types.
4866 *Note buffer-glyph-p: Glyph Types.
4869 *Note buffer-live-p: Killing Buffers.
4872 *Note bufferp: Buffer Basics.
4875 *Note button-event-p: Event Predicates.
4877 `button-press-event-p'
4878 *Note button-press-event-p: Event Predicates.
4880 `button-release-event-p'
4881 *Note button-release-event-p: Event Predicates.
4884 *Note case-table-p: Case Tables.
4887 *Note char-int-p: Character Codes.
4889 `char-or-char-int-p'
4890 *Note char-or-char-int-p: Character Codes.
4893 *Note char-or-string-p: Predicates for Strings.
4896 *Note char-table-p: Char Tables.
4899 *Note characterp: Predicates for Characters.
4902 *Note color-instance-p: Colors.
4904 `color-pixmap-image-instance-p'
4905 *Note color-pixmap-image-instance-p: Image Instance Types.
4908 *Note color-specifier-p: Specifier Types.
4911 *Note commandp: Interactive Call.
4913 `compiled-function-p'
4914 *Note compiled-function-p: Compiled-Function Type.
4917 *Note console-live-p: Connecting to a Console or Device.
4920 *Note consolep: Consoles and Devices.
4923 *Note consp: List-related Predicates.
4926 *Note database-live-p: Connecting to a Database.
4929 *Note databasep: Databases.
4932 *Note device-live-p: Connecting to a Console or Device.
4935 *Note device-or-frame-p: Basic Device Functions.
4938 *Note devicep: Consoles and Devices.
4941 *Note eval-event-p: Event Predicates.
4944 *Note event-live-p: Event Predicates.
4947 *Note eventp: Events.
4950 *Note extent-live-p: Creating and Modifying Extents.
4953 *Note extentp: Extents.
4955 `face-boolean-specifier-p'
4956 *Note face-boolean-specifier-p: Specifier Types.
4959 *Note facep: Basic Face Functions.
4962 *Note floatp: Predicates on Numbers.
4965 *Note font-instance-p: Fonts.
4968 *Note font-specifier-p: Specifier Types.
4971 *Note frame-live-p: Deleting Frames.
4974 *Note framep: Frames.
4977 (not yet documented)
4979 `generic-specifier-p'
4980 *Note generic-specifier-p: Specifier Types.
4983 *Note glyphp: Glyphs.
4986 *Note hash-table-p: Hash Tables.
4989 *Note icon-glyph-p: Glyph Types.
4992 *Note image-instance-p: Images.
4995 *Note image-specifier-p: Specifier Types.
4997 `integer-char-or-marker-p'
4998 *Note integer-char-or-marker-p: Predicates on Markers.
5001 *Note integer-or-char-p: Predicates for Characters.
5003 `integer-or-marker-p'
5004 *Note integer-or-marker-p: Predicates on Markers.
5006 `integer-specifier-p'
5007 *Note integer-specifier-p: Specifier Types.
5010 *Note integerp: Predicates on Numbers.
5013 (not yet documented)
5016 *Note key-press-event-p: Event Predicates.
5019 *Note keymapp: Creating Keymaps.
5022 (not yet documented)
5025 *Note listp: List-related Predicates.
5028 *Note markerp: Predicates on Markers.
5031 *Note misc-user-event-p: Event Predicates.
5033 `mono-pixmap-image-instance-p'
5034 *Note mono-pixmap-image-instance-p: Image Instance Types.
5037 *Note motion-event-p: Event Predicates.
5040 *Note mouse-event-p: Event Predicates.
5042 `natnum-specifier-p'
5043 *Note natnum-specifier-p: Specifier Types.
5046 *Note natnump: Predicates on Numbers.
5049 *Note nlistp: List-related Predicates.
5051 `nothing-image-instance-p'
5052 *Note nothing-image-instance-p: Image Instance Types.
5054 `number-char-or-marker-p'
5055 *Note number-char-or-marker-p: Predicates on Markers.
5057 `number-or-marker-p'
5058 *Note number-or-marker-p: Predicates on Markers.
5061 *Note numberp: Predicates on Numbers.
5064 *Note pointer-glyph-p: Glyph Types.
5066 `pointer-image-instance-p'
5067 *Note pointer-image-instance-p: Image Instance Types.
5070 *Note process-event-p: Event Predicates.
5073 *Note processp: Processes.
5076 *Note range-table-p: Range Tables.
5079 (not yet documented)
5082 *Note sequencep: Sequence Functions.
5085 *Note specifierp: Specifiers.
5088 *Note stringp: Predicates for Strings.
5091 *Note subrp: Function Cells.
5093 `subwindow-image-instance-p'
5094 *Note subwindow-image-instance-p: Image Instance Types.
5097 *Note subwindowp: Subwindows.
5100 *Note symbolp: Symbols.
5103 *Note syntax-table-p: Syntax Tables.
5105 `text-image-instance-p'
5106 *Note text-image-instance-p: Image Instance Types.
5109 *Note timeout-event-p: Event Predicates.
5112 *Note toolbar-button-p: Toolbar.
5114 `toolbar-specifier-p'
5115 *Note toolbar-specifier-p: Toolbar.
5118 *Note user-variable-p: Defining Variables.
5121 *Note vectorp: Vectors.
5124 *Note weak-list-p: Weak Lists.
5126 `window-configuration-p'
5127 *Note window-configuration-p: Window Configurations.
5130 *Note window-live-p: Deleting Windows.
5133 *Note windowp: Basic Windows.
5135 The most general way to check the type of an object is to call the
5136 function `type-of'. Recall that each object belongs to one and only
5137 one primitive type; `type-of' tells you which one (*note Lisp Data
5138 Types::). But `type-of' knows nothing about non-primitive types. In
5139 most cases, it is more convenient to use type predicates than `type-of'.
5141 - Function: type-of object
5142 This function returns a symbol naming the primitive type of
5143 OBJECT. The value is one of `bit-vector', `buffer', `char-table',
5144 `character', `charset', `coding-system', `cons', `color-instance',
5145 `compiled-function', `console', `database', `device', `event',
5146 `extent', `face', `float', `font-instance', `frame', `glyph',
5147 `hash-table', `image-instance', `integer', `keymap', `marker',
5148 `process', `range-table', `specifier', `string', `subr',
5149 `subwindow', `symbol', `toolbar-button', `tooltalk-message',
5150 `tooltalk-pattern', `vector', `weak-list', `window',
5151 `window-configuration', or `x-resource'.
5157 (type-of '()) ; `()' is `nil'.
5163 File: lispref.info, Node: Equality Predicates, Prev: Type Predicates, Up: Lisp Data Types
5168 Here we describe two functions that test for equality between any two
5169 objects. Other functions test equality between objects of specific
5170 types, e.g., strings. For these predicates, see the appropriate chapter
5171 describing the data type.
5173 - Function: eq object1 object2
5174 This function returns `t' if OBJECT1 and OBJECT2 are the same
5175 object, `nil' otherwise. The "same object" means that a change in
5176 one will be reflected by the same change in the other.
5178 `eq' returns `t' if OBJECT1 and OBJECT2 are integers with the same
5179 value. Also, since symbol names are normally unique, if the
5180 arguments are symbols with the same name, they are `eq'. For
5181 other types (e.g., lists, vectors, strings), two arguments with
5182 the same contents or elements are not necessarily `eq' to each
5183 other: they are `eq' only if they are the same object.
5185 (The `make-symbol' function returns an uninterned symbol that is
5186 not interned in the standard `obarray'. When uninterned symbols
5187 are in use, symbol names are no longer unique. Distinct symbols
5188 with the same name are not `eq'. *Note Creating Symbols::.)
5190 NOTE: Under XEmacs 19, characters are really just integers, and
5191 thus characters and integers are `eq'. Under XEmacs 20, it was
5192 necessary to preserve remnants of this in function such as `old-eq'
5193 in order to maintain byte-code compatibility. Byte code compiled
5194 under any Emacs 19 will automatically have calls to `eq' mapped to
5195 `old-eq' when executed under XEmacs 20.
5206 (eq '(1 (2 (3))) '(1 (2 (3))))
5209 (setq foo '(1 (2 (3))))
5213 (eq foo '(1 (2 (3))))
5216 (eq [(1 2) 3] [(1 2) 3])
5219 (eq (point-marker) (point-marker))
5223 - Function: old-eq object1 object2
5224 This function exists under XEmacs 20 and is exactly like `eq'
5225 except that it suffers from the char-int confoundance disease. In
5226 other words, it returns `t' if given a character and the
5227 equivalent integer, even though the objects are of different types!
5228 You should _not_ ever call this function explicitly in your code.
5229 However, be aware that all calls to `eq' in byte code compiled
5230 under version 19 map to `old-eq' in XEmacs 20. (Likewise for
5231 `old-equal', `old-memq', `old-member', `old-assq' and
5234 ;; Remember, this does not apply under XEmacs 19.
5240 => t ; Eek, we've been infected.
5242 => nil ; We are still healthy.
5244 - Function: equal object1 object2
5245 This function returns `t' if OBJECT1 and OBJECT2 have equal
5246 components, `nil' otherwise. Whereas `eq' tests if its arguments
5247 are the same object, `equal' looks inside nonidentical arguments
5248 to see if their elements are the same. So, if two objects are
5249 `eq', they are `equal', but the converse is not always true.
5257 (equal "asdf" "asdf")
5262 (equal '(1 (2 (3))) '(1 (2 (3))))
5264 (eq '(1 (2 (3))) '(1 (2 (3))))
5267 (equal [(1 2) 3] [(1 2) 3])
5269 (eq [(1 2) 3] [(1 2) 3])
5272 (equal (point-marker) (point-marker))
5275 (eq (point-marker) (point-marker))
5278 Comparison of strings is case-sensitive.
5280 Note that in FSF GNU Emacs, comparison of strings takes into
5281 account their text properties, and you have to use `string-equal'
5282 if you want only the strings themselves compared. This difference
5283 does not exist in XEmacs; `equal' and `string-equal' always return
5284 the same value on the same strings.
5286 (equal "asdf" "ASDF")
5289 Two distinct buffers are never `equal', even if their contents are
5292 The test for equality is implemented recursively, and circular lists
5293 may therefore cause infinite recursion (leading to an error).
5296 File: lispref.info, Node: Numbers, Next: Strings and Characters, Prev: Lisp Data Types, Up: Top
5301 XEmacs supports two numeric data types: "integers" and "floating point
5302 numbers". Integers are whole numbers such as -3, 0, #b0111, #xFEED,
5303 #o744. Their values are exact. The number prefixes `#b', `#o', and
5304 `#x' are supported to represent numbers in binary, octal, and
5305 hexadecimal notation (or radix). Floating point numbers are numbers
5306 with fractional parts, such as -4.5, 0.0, or 2.71828. They can also be
5307 expressed in exponential notation: 1.5e2 equals 150; in this example,
5308 `e2' stands for ten to the second power, and is multiplied by 1.5.
5309 Floating point values are not exact; they have a fixed, limited amount
5314 * Integer Basics:: Representation and range of integers.
5315 * Float Basics:: Representation and range of floating point.
5316 * Predicates on Numbers:: Testing for numbers.
5317 * Comparison of Numbers:: Equality and inequality predicates.
5318 * Numeric Conversions:: Converting float to integer and vice versa.
5319 * Arithmetic Operations:: How to add, subtract, multiply and divide.
5320 * Rounding Operations:: Explicitly rounding floating point numbers.
5321 * Bitwise Operations:: Logical and, or, not, shifting.
5322 * Math Functions:: Trig, exponential and logarithmic functions.
5323 * Random Numbers:: Obtaining random integers, predictable or not.
5326 File: lispref.info, Node: Integer Basics, Next: Float Basics, Up: Numbers
5331 The range of values for an integer depends on the machine. The minimum
5332 range is -134217728 to 134217727 (28 bits; i.e., -2**27 to 2**27 - 1),
5333 but some machines may provide a wider range. Many examples in this
5334 chapter assume an integer has 28 bits.
5336 The Lisp reader reads an integer as a sequence of digits with
5337 optional initial sign and optional final period.
5341 +1 ; Also the integer 1.
5342 -1 ; The integer -1.
5343 268435457 ; Also the integer 1, due to overflow.
5347 To understand how various functions work on integers, especially the
5348 bitwise operators (*note Bitwise Operations::), it is often helpful to
5349 view the numbers in their binary form.
5351 In 28-bit binary, the decimal integer 5 looks like this:
5353 0000 0000 0000 0000 0000 0000 0101
5355 (We have inserted spaces between groups of 4 bits, and two spaces
5356 between groups of 8 bits, to make the binary integer easier to read.)
5358 The integer -1 looks like this:
5360 1111 1111 1111 1111 1111 1111 1111
5362 -1 is represented as 28 ones. (This is called "two's complement"
5365 The negative integer, -5, is creating by subtracting 4 from -1. In
5366 binary, the decimal integer 4 is 100. Consequently, -5 looks like this:
5368 1111 1111 1111 1111 1111 1111 1011
5370 In this implementation, the largest 28-bit binary integer is the
5371 decimal integer 134,217,727. In binary, it looks like this:
5373 0111 1111 1111 1111 1111 1111 1111
5375 Since the arithmetic functions do not check whether integers go
5376 outside their range, when you add 1 to 134,217,727, the value is the
5377 negative integer -134,217,728:
5381 => 1000 0000 0000 0000 0000 0000 0000
5383 Many of the following functions accept markers for arguments as well
5384 as integers. (*Note Markers::.) More precisely, the actual arguments
5385 to such functions may be either integers or markers, which is why we
5386 often give these arguments the name INT-OR-MARKER. When the argument
5387 value is a marker, its position value is used and its buffer is ignored.
5390 File: lispref.info, Node: Float Basics, Next: Predicates on Numbers, Prev: Integer Basics, Up: Numbers
5392 Floating Point Basics
5393 =====================
5395 XEmacs supports floating point numbers. The precise range of floating
5396 point numbers is machine-specific; it is the same as the range of the C
5397 data type `double' on the machine in question.
5399 The printed representation for floating point numbers requires either
5400 a decimal point (with at least one digit following), an exponent, or
5401 both. For example, `1500.0', `15e2', `15.0e2', `1.5e3', and `.15e4'
5402 are five ways of writing a floating point number whose value is 1500.
5403 They are all equivalent. You can also use a minus sign to write
5404 negative floating point numbers, as in `-1.0'.
5406 Most modern computers support the IEEE floating point standard, which
5407 provides for positive infinity and negative infinity as floating point
5408 values. It also provides for a class of values called NaN or
5409 "not-a-number"; numerical functions return such values in cases where
5410 there is no correct answer. For example, `(sqrt -1.0)' returns a NaN.
5411 For practical purposes, there's no significant difference between
5412 different NaN values in XEmacs Lisp, and there's no rule for precisely
5413 which NaN value should be used in a particular case, so this manual
5414 doesn't try to distinguish them. XEmacs Lisp has no read syntax for
5415 NaNs or infinities; perhaps we should create a syntax in the future.
5417 You can use `logb' to extract the binary exponent of a floating
5418 point number (or estimate the logarithm of an integer):
5420 - Function: logb number
5421 This function returns the binary exponent of NUMBER. More
5422 precisely, the value is the logarithm of NUMBER base 2, rounded
5426 File: lispref.info, Node: Predicates on Numbers, Next: Comparison of Numbers, Prev: Float Basics, Up: Numbers
5428 Type Predicates for Numbers
5429 ===========================
5431 The functions in this section test whether the argument is a number or
5432 whether it is a certain sort of number. The functions `integerp' and
5433 `floatp' can take any type of Lisp object as argument (the predicates
5434 would not be of much use otherwise); but the `zerop' predicate requires
5435 a number as its argument. See also `integer-or-marker-p',
5436 `integer-char-or-marker-p', `number-or-marker-p' and
5437 `number-char-or-marker-p', in *Note Predicates on Markers::.
5439 - Function: floatp object
5440 This predicate tests whether its argument is a floating point
5441 number and returns `t' if so, `nil' otherwise.
5443 `floatp' does not exist in Emacs versions 18 and earlier.
5445 - Function: integerp object
5446 This predicate tests whether its argument is an integer, and
5447 returns `t' if so, `nil' otherwise.
5449 - Function: numberp object
5450 This predicate tests whether its argument is a number (either
5451 integer or floating point), and returns `t' if so, `nil' otherwise.
5453 - Function: natnump object
5454 The `natnump' predicate (whose name comes from the phrase
5455 "natural-number-p") tests to see whether its argument is a
5456 nonnegative integer, and returns `t' if so, `nil' otherwise. 0 is
5457 considered non-negative.
5459 - Function: zerop number
5460 This predicate tests whether its argument is zero, and returns `t'
5461 if so, `nil' otherwise. The argument must be a number.
5463 These two forms are equivalent: `(zerop x)' == `(= x 0)'.
5466 File: lispref.info, Node: Comparison of Numbers, Next: Numeric Conversions, Prev: Predicates on Numbers, Up: Numbers
5468 Comparison of Numbers
5469 =====================
5471 To test numbers for numerical equality, you should normally use `=',
5472 not `eq'. There can be many distinct floating point number objects
5473 with the same numeric value. If you use `eq' to compare them, then you
5474 test whether two values are the same _object_. By contrast, `='
5475 compares only the numeric values of the objects.
5477 At present, each integer value has a unique Lisp object in XEmacs
5478 Lisp. Therefore, `eq' is equivalent to `=' where integers are
5479 concerned. It is sometimes convenient to use `eq' for comparing an
5480 unknown value with an integer, because `eq' does not report an error if
5481 the unknown value is not a number--it accepts arguments of any type.
5482 By contrast, `=' signals an error if the arguments are not numbers or
5483 markers. However, it is a good idea to use `=' if you can, even for
5484 comparing integers, just in case we change the representation of
5485 integers in a future XEmacs version.
5487 There is another wrinkle: because floating point arithmetic is not
5488 exact, it is often a bad idea to check for equality of two floating
5489 point values. Usually it is better to test for approximate equality.
5490 Here's a function to do this:
5492 (defconst fuzz-factor 1.0e-6)
5493 (defun approx-equal (x y)
5494 (or (and (= x 0) (= y 0))
5496 (max (abs x) (abs y)))
5499 Common Lisp note: Comparing numbers in Common Lisp always requires
5500 `=' because Common Lisp implements multi-word integers, and two
5501 distinct integer objects can have the same numeric value. XEmacs
5502 Lisp can have just one integer object for any given value because
5503 it has a limited range of integer values.
5505 In addition to numbers, all of the following functions also accept
5506 characters and markers as arguments, and treat them as their number
5509 - Function: = number &rest more-numbers
5510 This function returns `t' if all of its arguments are numerically
5511 equal, `nil' otherwise.
5522 - Function: /= number &rest more-numbers
5523 This function returns `t' if no two arguments are numerically
5524 equal, `nil' otherwise.
5533 - Function: < number &rest more-numbers
5534 This function returns `t' if the sequence of its arguments is
5535 monotonically increasing, `nil' otherwise.
5544 - Function: <= number &rest more-numbers
5545 This function returns `t' if the sequence of its arguments is
5546 monotonically nondecreasing, `nil' otherwise.
5555 - Function: > number &rest more-numbers
5556 This function returns `t' if the sequence of its arguments is
5557 monotonically decreasing, `nil' otherwise.
5559 - Function: >= number &rest more-numbers
5560 This function returns `t' if the sequence of its arguments is
5561 monotonically nonincreasing, `nil' otherwise.
5563 - Function: max number &rest more-numbers
5564 This function returns the largest of its arguments.
5573 - Function: min number &rest more-numbers
5574 This function returns the smallest of its arguments.
5580 File: lispref.info, Node: Numeric Conversions, Next: Arithmetic Operations, Prev: Comparison of Numbers, Up: Numbers
5585 To convert an integer to floating point, use the function `float'.
5587 - Function: float number
5588 This returns NUMBER converted to floating point. If NUMBER is
5589 already a floating point number, `float' returns it unchanged.
5591 There are four functions to convert floating point numbers to
5592 integers; they differ in how they round. These functions accept
5593 integer arguments also, and return such arguments unchanged.
5595 - Function: truncate number
5596 This returns NUMBER, converted to an integer by rounding towards
5599 - Function: floor number &optional divisor
5600 This returns NUMBER, converted to an integer by rounding downward
5601 (towards negative infinity).
5603 If DIVISOR is specified, NUMBER is divided by DIVISOR before the
5604 floor is taken; this is the division operation that corresponds to
5605 `mod'. An `arith-error' results if DIVISOR is 0.
5607 - Function: ceiling number
5608 This returns NUMBER, converted to an integer by rounding upward
5609 (towards positive infinity).
5611 - Function: round number
5612 This returns NUMBER, converted to an integer by rounding towards
5613 the nearest integer. Rounding a value equidistant between two
5614 integers may choose the integer closer to zero, or it may prefer
5615 an even integer, depending on your machine.
5618 File: lispref.info, Node: Arithmetic Operations, Next: Rounding Operations, Prev: Numeric Conversions, Up: Numbers
5620 Arithmetic Operations
5621 =====================
5623 XEmacs Lisp provides the traditional four arithmetic operations:
5624 addition, subtraction, multiplication, and division. Remainder and
5625 modulus functions supplement the division functions. The functions to
5626 add or subtract 1 are provided because they are traditional in Lisp and
5629 All of these functions except `%' return a floating point value if
5630 any argument is floating.
5632 It is important to note that in XEmacs Lisp, arithmetic functions do
5633 not check for overflow. Thus `(1+ 134217727)' may evaluate to
5634 -134217728, depending on your hardware.
5636 - Function: 1+ number
5637 This function returns NUMBER plus one. NUMBER may be a number,
5638 character or marker. Markers and characters are converted to
5648 This function is not analogous to the C operator `++'--it does not
5649 increment a variable. It just computes a sum. Thus, if we
5655 If you want to increment the variable, you must use `setq', like
5661 Now that the `cl' package is always available from lisp code, a
5662 more convenient and natural way to increment a variable is
5665 - Function: 1- number
5666 This function returns NUMBER minus one. NUMBER may be a number,
5667 character or marker. Markers and characters are converted to
5670 - Function: abs number
5671 This returns the absolute value of NUMBER.
5673 - Function: + &rest numbers
5674 This function adds its arguments together. When given no
5675 arguments, `+' returns 0.
5677 If any of the arguments are characters or markers, they are first
5678 converted to integers.
5687 - Function: - &optional number &rest other-numbers
5688 The `-' function serves two purposes: negation and subtraction.
5689 When `-' has a single argument, the value is the negative of the
5690 argument. When there are multiple arguments, `-' subtracts each of
5691 the OTHER-NUMBERS from NUMBER, cumulatively. If there are no
5692 arguments, an error is signaled.
5694 If any of the arguments are characters or markers, they are first
5695 converted to integers.
5704 - Function: * &rest numbers
5705 This function multiplies its arguments together, and returns the
5706 product. When given no arguments, `*' returns 1.
5708 If any of the arguments are characters or markers, they are first
5709 converted to integers.
5718 - Function: / dividend &rest divisors
5719 The `/' function serves two purposes: inversion and division. When
5720 `/' has a single argument, the value is the inverse of the
5721 argument. When there are multiple arguments, `/' divides DIVIDEND
5722 by each of the DIVISORS, cumulatively, returning the quotient. If
5723 there are no arguments, an error is signaled.
5725 If none of the arguments are floats, then the result is an integer.
5726 This means the result has to be rounded. On most machines, the
5727 result is rounded towards zero after each division, but some
5728 machines may round differently with negative arguments. This is
5729 because the Lisp function `/' is implemented using the C division
5730 operator, which also permits machine-dependent rounding. As a
5731 practical matter, all known machines round in the standard fashion.
5733 If any of the arguments are characters or markers, they are first
5734 converted to integers.
5736 If you divide by 0, an `arith-error' error is signaled. (*Note
5746 => 0.3333333333333333
5750 The result of `(/ -17 6)' could in principle be -3 on some
5753 - Function: % dividend divisor
5754 This function returns the integer remainder after division of
5755 DIVIDEND by DIVISOR. The arguments must be integers or markers.
5757 For negative arguments, the remainder is in principle
5758 machine-dependent since the quotient is; but in practice, all
5759 known machines behave alike.
5761 An `arith-error' results if DIVISOR is 0.
5772 For any two integers DIVIDEND and DIVISOR,
5774 (+ (% DIVIDEND DIVISOR)
5775 (* (/ DIVIDEND DIVISOR) DIVISOR))
5777 always equals DIVIDEND.
5779 - Function: mod dividend divisor
5780 This function returns the value of DIVIDEND modulo DIVISOR; in
5781 other words, the remainder after division of DIVIDEND by DIVISOR,
5782 but with the same sign as DIVISOR. The arguments must be numbers
5785 Unlike `%', `mod' returns a well-defined result for negative
5786 arguments. It also permits floating point arguments; it rounds the
5787 quotient downward (towards minus infinity) to an integer, and uses
5788 that quotient to compute the remainder.
5790 An `arith-error' results if DIVISOR is 0.
5803 For any two numbers DIVIDEND and DIVISOR,
5805 (+ (mod DIVIDEND DIVISOR)
5806 (* (floor DIVIDEND DIVISOR) DIVISOR))
5808 always equals DIVIDEND, subject to rounding error if either
5809 argument is floating point. For `floor', see *Note Numeric
5813 File: lispref.info, Node: Rounding Operations, Next: Bitwise Operations, Prev: Arithmetic Operations, Up: Numbers
5818 The functions `ffloor', `fceiling', `fround' and `ftruncate' take a
5819 floating point argument and return a floating point result whose value
5820 is a nearby integer. `ffloor' returns the nearest integer below;
5821 `fceiling', the nearest integer above; `ftruncate', the nearest integer
5822 in the direction towards zero; `fround', the nearest integer.
5824 - Function: ffloor number
5825 This function rounds NUMBER to the next lower integral value, and
5826 returns that value as a floating point number.
5828 - Function: fceiling number
5829 This function rounds NUMBER to the next higher integral value, and
5830 returns that value as a floating point number.
5832 - Function: ftruncate number
5833 This function rounds NUMBER towards zero to an integral value, and
5834 returns that value as a floating point number.
5836 - Function: fround number
5837 This function rounds NUMBER to the nearest integral value, and
5838 returns that value as a floating point number.
5841 File: lispref.info, Node: Bitwise Operations, Next: Math Functions, Prev: Rounding Operations, Up: Numbers
5843 Bitwise Operations on Integers
5844 ==============================
5846 In a computer, an integer is represented as a binary number, a sequence
5847 of "bits" (digits which are either zero or one). A bitwise operation
5848 acts on the individual bits of such a sequence. For example,
5849 "shifting" moves the whole sequence left or right one or more places,
5850 reproducing the same pattern "moved over".
5852 The bitwise operations in XEmacs Lisp apply only to integers.
5854 - Function: lsh integer1 count
5855 `lsh', which is an abbreviation for "logical shift", shifts the
5856 bits in INTEGER1 to the left COUNT places, or to the right if
5857 COUNT is negative, bringing zeros into the vacated bits. If COUNT
5858 is negative, `lsh' shifts zeros into the leftmost
5859 (most-significant) bit, producing a positive result even if
5860 INTEGER1 is negative. Contrast this with `ash', below.
5862 Here are two examples of `lsh', shifting a pattern of bits one
5863 place to the left. We show only the low-order eight bits of the
5864 binary pattern; the rest are all zero.
5868 ;; Decimal 5 becomes decimal 10.
5869 00000101 => 00001010
5873 ;; Decimal 7 becomes decimal 14.
5874 00000111 => 00001110
5876 As the examples illustrate, shifting the pattern of bits one place
5877 to the left produces a number that is twice the value of the
5880 Shifting a pattern of bits two places to the left produces results
5881 like this (with 8-bit binary numbers):
5885 ;; Decimal 3 becomes decimal 12.
5886 00000011 => 00001100
5888 On the other hand, shifting one place to the right looks like this:
5892 ;; Decimal 6 becomes decimal 3.
5893 00000110 => 00000011
5897 ;; Decimal 5 becomes decimal 2.
5898 00000101 => 00000010
5900 As the example illustrates, shifting one place to the right
5901 divides the value of a positive integer by two, rounding downward.
5903 The function `lsh', like all XEmacs Lisp arithmetic functions, does
5904 not check for overflow, so shifting left can discard significant
5905 bits and change the sign of the number. For example, left shifting
5906 134,217,727 produces -2 on a 28-bit machine:
5908 (lsh 134217727 1) ; left shift
5911 In binary, in the 28-bit implementation, the argument looks like
5914 ;; Decimal 134,217,727
5915 0111 1111 1111 1111 1111 1111 1111
5917 which becomes the following when left shifted:
5920 1111 1111 1111 1111 1111 1111 1110
5922 - Function: ash integer1 count
5923 `ash' ("arithmetic shift") shifts the bits in INTEGER1 to the left
5924 COUNT places, or to the right if COUNT is negative.
5926 `ash' gives the same results as `lsh' except when INTEGER1 and
5927 COUNT are both negative. In that case, `ash' puts ones in the
5928 empty bit positions on the left, while `lsh' puts zeros in those
5931 Thus, with `ash', shifting the pattern of bits one place to the
5932 right looks like this:
5935 ;; Decimal -6 becomes decimal -3.
5936 1111 1111 1111 1111 1111 1111 1010
5938 1111 1111 1111 1111 1111 1111 1101
5940 In contrast, shifting the pattern of bits one place to the right
5941 with `lsh' looks like this:
5943 (lsh -6 -1) => 134217725
5944 ;; Decimal -6 becomes decimal 134,217,725.
5945 1111 1111 1111 1111 1111 1111 1010
5947 0111 1111 1111 1111 1111 1111 1101
5949 Here are other examples:
5951 ; 28-bit binary values
5953 (lsh 5 2) ; 5 = 0000 0000 0000 0000 0000 0000 0101
5954 => 20 ; = 0000 0000 0000 0000 0000 0001 0100
5957 (lsh -5 2) ; -5 = 1111 1111 1111 1111 1111 1111 1011
5958 => -20 ; = 1111 1111 1111 1111 1111 1110 1100
5961 (lsh 5 -2) ; 5 = 0000 0000 0000 0000 0000 0000 0101
5962 => 1 ; = 0000 0000 0000 0000 0000 0000 0001
5965 (lsh -5 -2) ; -5 = 1111 1111 1111 1111 1111 1111 1011
5966 => 4194302 ; = 0011 1111 1111 1111 1111 1111 1110
5967 (ash -5 -2) ; -5 = 1111 1111 1111 1111 1111 1111 1011
5968 => -2 ; = 1111 1111 1111 1111 1111 1111 1110
5970 - Function: logand &rest ints-or-markers
5971 This function returns the "logical and" of the arguments: the Nth
5972 bit is set in the result if, and only if, the Nth bit is set in
5973 all the arguments. ("Set" means that the value of the bit is 1
5976 For example, using 4-bit binary numbers, the "logical and" of 13
5977 and 12 is 12: 1101 combined with 1100 produces 1100. In both the
5978 binary numbers, the leftmost two bits are set (i.e., they are
5979 1's), so the leftmost two bits of the returned value are set.
5980 However, for the rightmost two bits, each is zero in at least one
5981 of the arguments, so the rightmost two bits of the returned value
5989 If `logand' is not passed any argument, it returns a value of -1.
5990 This number is an identity element for `logand' because its binary
5991 representation consists entirely of ones. If `logand' is passed
5992 just one argument, it returns that argument.
5994 ; 28-bit binary values
5996 (logand 14 13) ; 14 = 0000 0000 0000 0000 0000 0000 1110
5997 ; 13 = 0000 0000 0000 0000 0000 0000 1101
5998 => 12 ; 12 = 0000 0000 0000 0000 0000 0000 1100
6000 (logand 14 13 4) ; 14 = 0000 0000 0000 0000 0000 0000 1110
6001 ; 13 = 0000 0000 0000 0000 0000 0000 1101
6002 ; 4 = 0000 0000 0000 0000 0000 0000 0100
6003 => 4 ; 4 = 0000 0000 0000 0000 0000 0000 0100
6006 => -1 ; -1 = 1111 1111 1111 1111 1111 1111 1111
6008 - Function: logior &rest ints-or-markers
6009 This function returns the "inclusive or" of its arguments: the Nth
6010 bit is set in the result if, and only if, the Nth bit is set in at
6011 least one of the arguments. If there are no arguments, the result
6012 is zero, which is an identity element for this operation. If
6013 `logior' is passed just one argument, it returns that argument.
6015 ; 28-bit binary values
6017 (logior 12 5) ; 12 = 0000 0000 0000 0000 0000 0000 1100
6018 ; 5 = 0000 0000 0000 0000 0000 0000 0101
6019 => 13 ; 13 = 0000 0000 0000 0000 0000 0000 1101
6021 (logior 12 5 7) ; 12 = 0000 0000 0000 0000 0000 0000 1100
6022 ; 5 = 0000 0000 0000 0000 0000 0000 0101
6023 ; 7 = 0000 0000 0000 0000 0000 0000 0111
6024 => 15 ; 15 = 0000 0000 0000 0000 0000 0000 1111
6026 - Function: logxor &rest ints-or-markers
6027 This function returns the "exclusive or" of its arguments: the Nth
6028 bit is set in the result if, and only if, the Nth bit is set in an
6029 odd number of the arguments. If there are no arguments, the
6030 result is 0, which is an identity element for this operation. If
6031 `logxor' is passed just one argument, it returns that argument.
6033 ; 28-bit binary values
6035 (logxor 12 5) ; 12 = 0000 0000 0000 0000 0000 0000 1100
6036 ; 5 = 0000 0000 0000 0000 0000 0000 0101
6037 => 9 ; 9 = 0000 0000 0000 0000 0000 0000 1001
6039 (logxor 12 5 7) ; 12 = 0000 0000 0000 0000 0000 0000 1100
6040 ; 5 = 0000 0000 0000 0000 0000 0000 0101
6041 ; 7 = 0000 0000 0000 0000 0000 0000 0111
6042 => 14 ; 14 = 0000 0000 0000 0000 0000 0000 1110
6044 - Function: lognot integer
6045 This function returns the logical complement of its argument: the
6046 Nth bit is one in the result if, and only if, the Nth bit is zero
6047 in INTEGER, and vice-versa.
6051 ;; 5 = 0000 0000 0000 0000 0000 0000 0101
6053 ;; -6 = 1111 1111 1111 1111 1111 1111 1010
6056 File: lispref.info, Node: Math Functions, Next: Random Numbers, Prev: Bitwise Operations, Up: Numbers
6058 Standard Mathematical Functions
6059 ===============================
6061 These mathematical functions are available if floating point is
6062 supported (which is the normal state of affairs). They allow integers
6063 as well as floating point numbers as arguments.
6065 - Function: sin number
6066 - Function: cos number
6067 - Function: tan number
6068 These are the ordinary trigonometric functions, with argument
6069 measured in radians.
6071 - Function: asin number
6072 The value of `(asin NUMBER)' is a number between -pi/2 and pi/2
6073 (inclusive) whose sine is NUMBER; if, however, NUMBER is out of
6074 range (outside [-1, 1]), then the result is a NaN.
6076 - Function: acos number
6077 The value of `(acos NUMBER)' is a number between 0 and pi
6078 (inclusive) whose cosine is NUMBER; if, however, NUMBER is out of
6079 range (outside [-1, 1]), then the result is a NaN.
6081 - Function: atan number &optional number2
6082 The value of `(atan NUMBER)' is a number between -pi/2 and pi/2
6083 (exclusive) whose tangent is NUMBER.
6085 If optional argument NUMBER2 is supplied, the function returns
6086 `atan2(NUMBER,NUMBER2)'.
6088 - Function: sinh number
6089 - Function: cosh number
6090 - Function: tanh number
6091 These are the ordinary hyperbolic trigonometric functions.
6093 - Function: asinh number
6094 - Function: acosh number
6095 - Function: atanh number
6096 These are the inverse hyperbolic trigonometric functions.
6098 - Function: exp number
6099 This is the exponential function; it returns e to the power
6100 NUMBER. e is a fundamental mathematical constant also called the
6101 base of natural logarithms.
6103 - Function: log number &optional base
6104 This function returns the logarithm of NUMBER, with base BASE. If
6105 you don't specify BASE, the base `e' is used. If NUMBER is
6106 negative, the result is a NaN.
6108 - Function: log10 number
6109 This function returns the logarithm of NUMBER, with base 10. If
6110 NUMBER is negative, the result is a NaN. `(log10 X)' == `(log X
6111 10)', at least approximately.
6113 - Function: expt x y
6114 This function returns X raised to power Y. If both arguments are
6115 integers and Y is positive, the result is an integer; in this
6116 case, it is truncated to fit the range of possible integer values.
6118 - Function: sqrt number
6119 This returns the square root of NUMBER. If NUMBER is negative,
6122 - Function: cube-root number
6123 This returns the cube root of NUMBER.
6126 File: lispref.info, Node: Random Numbers, Prev: Math Functions, Up: Numbers
6131 A deterministic computer program cannot generate true random numbers.
6132 For most purposes, "pseudo-random numbers" suffice. A series of
6133 pseudo-random numbers is generated in a deterministic fashion. The
6134 numbers are not truly random, but they have certain properties that
6135 mimic a random series. For example, all possible values occur equally
6136 often in a pseudo-random series.
6138 In XEmacs, pseudo-random numbers are generated from a "seed" number.
6139 Starting from any given seed, the `random' function always generates
6140 the same sequence of numbers. XEmacs always starts with the same seed
6141 value, so the sequence of values of `random' is actually the same in
6142 each XEmacs run! For example, in one operating system, the first call
6143 to `(random)' after you start XEmacs always returns -1457731, and the
6144 second one always returns -7692030. This repeatability is helpful for
6147 If you want truly unpredictable random numbers, execute `(random
6148 t)'. This chooses a new seed based on the current time of day and on
6149 XEmacs's process ID number.
6151 - Function: random &optional limit
6152 This function returns a pseudo-random integer. Repeated calls
6153 return a series of pseudo-random integers.
6155 If LIMIT is a positive integer, the value is chosen to be
6156 nonnegative and less than LIMIT.
6158 If LIMIT is `t', it means to choose a new seed based on the
6159 current time of day and on XEmacs's process ID number.
6161 On some machines, any integer representable in Lisp may be the
6162 result of `random'. On other machines, the result can never be
6163 larger than a certain maximum or less than a certain (negative)
6167 File: lispref.info, Node: Strings and Characters, Next: Lists, Prev: Numbers, Up: Top
6169 Strings and Characters
6170 **********************
6172 A string in XEmacs Lisp is an array that contains an ordered sequence
6173 of characters. Strings are used as names of symbols, buffers, and
6174 files, to send messages to users, to hold text being copied between
6175 buffers, and for many other purposes. Because strings are so important,
6176 XEmacs Lisp has many functions expressly for manipulating them. XEmacs
6177 Lisp programs use strings more often than individual characters.
6181 * String Basics:: Basic properties of strings and characters.
6182 * Predicates for Strings:: Testing whether an object is a string or char.
6183 * Creating Strings:: Functions to allocate new strings.
6184 * Predicates for Characters:: Testing whether an object is a character.
6185 * Character Codes:: Each character has an equivalent integer.
6186 * Text Comparison:: Comparing characters or strings.
6187 * String Conversion:: Converting characters or strings and vice versa.
6188 * Modifying Strings:: Changing characters in a string.
6189 * String Properties:: Additional information attached to strings.
6190 * Formatting Strings:: `format': XEmacs's analog of `printf'.
6191 * Character Case:: Case conversion functions.
6192 * Case Tables:: Customizing case conversion.
6193 * Char Tables:: Mapping from characters to Lisp objects.
6196 File: lispref.info, Node: String Basics, Next: Predicates for Strings, Up: Strings and Characters
6198 String and Character Basics
6199 ===========================
6201 Strings in XEmacs Lisp are arrays that contain an ordered sequence of
6202 characters. Characters are their own primitive object type in XEmacs
6203 20. However, in XEmacs 19, characters are represented in XEmacs Lisp as
6204 integers; whether an integer was intended as a character or not is
6205 determined only by how it is used. *Note Character Type::.
6207 The length of a string (like any array) is fixed and independent of
6208 the string contents, and cannot be altered. Strings in Lisp are _not_
6209 terminated by a distinguished character code. (By contrast, strings in
6210 C are terminated by a character with ASCII code 0.) This means that
6211 any character, including the null character (ASCII code 0), is a valid
6212 element of a string.
6214 Since strings are considered arrays, you can operate on them with the
6215 general array functions. (*Note Sequences Arrays Vectors::.) For
6216 example, you can access or change individual characters in a string
6217 using the functions `aref' and `aset' (*note Array Functions::).
6219 Strings use an efficient representation for storing the characters
6220 in them, and thus take up much less memory than a vector of the same
6223 Sometimes you will see strings used to hold key sequences. This
6224 exists for backward compatibility with Emacs 18, but should _not_ be
6225 used in new code, since many key chords can't be represented at all and
6226 others (in particular meta key chords) are confused with accented
6229 Strings are useful for holding regular expressions. You can also
6230 match regular expressions against strings (*note Regexp Search::). The
6231 functions `match-string' (*note Simple Match Data::) and
6232 `replace-match' (*note Replacing Match::) are useful for decomposing
6233 and modifying strings based on regular expression matching.
6235 Like a buffer, a string can contain extents in it. These extents are
6236 created when a function such as `buffer-substring' is called on a
6237 region with duplicable extents in it. When the string is inserted into
6238 a buffer, the extents are inserted along with it. *Note Duplicable
6241 *Note Text::, for information about functions that display strings or
6242 copy them into buffers. *Note Character Type::, and *Note String
6243 Type::, for information about the syntax of characters and strings.
6246 File: lispref.info, Node: Predicates for Strings, Next: Creating Strings, Prev: String Basics, Up: Strings and Characters
6248 The Predicates for Strings
6249 ==========================
6251 For more information about general sequence and array predicates, see
6252 *Note Sequences Arrays Vectors::, and *Note Arrays::.
6254 - Function: stringp object
6255 This function returns `t' if OBJECT is a string, `nil' otherwise.
6257 - Function: char-or-string-p object
6258 This function returns `t' if OBJECT is a string or a character,
6261 In XEmacs addition, this function also returns `t' if OBJECT is an
6262 integer that can be represented as a character. This is because
6263 of compatibility with previous XEmacs and should not be depended
6267 File: lispref.info, Node: Creating Strings, Next: Predicates for Characters, Prev: Predicates for Strings, Up: Strings and Characters
6272 The following functions create strings, either from scratch, or by
6273 putting strings together, or by taking them apart.
6275 - Function: string &rest characters
6276 This function returns a new string made up of CHARACTERS.
6278 (string ?X ?E ?m ?a ?c ?s)
6283 Analogous functions operating on other data types include `list',
6284 `cons' (*note Building Lists::), `vector' (*note Vectors::) and
6285 `bit-vector' (*note Bit Vectors::). This function has not been
6286 available in XEmacs prior to 21.0 and FSF Emacs prior to 20.3.
6288 - Function: make-string length character
6289 This function returns a new string consisting entirely of LENGTH
6290 successive copies of CHARACTER. LENGTH must be a non-negative
6298 Other functions to compare with this one include `char-to-string'
6299 (*note String Conversion::), `make-vector' (*note Vectors::), and
6300 `make-list' (*note Building Lists::).
6302 - Function: substring string start &optional end
6303 This function returns a new string which consists of those
6304 characters from STRING in the range from (and including) the
6305 character at the index START up to (but excluding) the character
6306 at the index END. The first character is at index zero.
6308 (substring "abcdefg" 0 3)
6311 Here the index for `a' is 0, the index for `b' is 1, and the index
6312 for `c' is 2. Thus, three letters, `abc', are copied from the
6313 string `"abcdefg"'. The index 3 marks the character position up
6314 to which the substring is copied. The character whose index is 3
6315 is actually the fourth character in the string.
6317 A negative number counts from the end of the string, so that -1
6318 signifies the index of the last character of the string. For
6321 (substring "abcdefg" -3 -1)
6324 In this example, the index for `e' is -3, the index for `f' is -2,
6325 and the index for `g' is -1. Therefore, `e' and `f' are included,
6326 and `g' is excluded.
6328 When `nil' is used as an index, it stands for the length of the
6331 (substring "abcdefg" -3 nil)
6334 Omitting the argument END is equivalent to specifying `nil'. It
6335 follows that `(substring STRING 0)' returns a copy of all of
6338 (substring "abcdefg" 0)
6341 But we recommend `copy-sequence' for this purpose (*note Sequence
6344 If the characters copied from STRING have duplicable extents or
6345 text properties, those are copied into the new string also. *Note
6346 Duplicable Extents::.
6348 A `wrong-type-argument' error is signaled if either START or END
6349 is not an integer or `nil'. An `args-out-of-range' error is
6350 signaled if START indicates a character following END, or if
6351 either integer is out of range for STRING.
6353 Contrast this function with `buffer-substring' (*note Buffer
6354 Contents::), which returns a string containing a portion of the
6355 text in the current buffer. The beginning of a string is at index
6356 0, but the beginning of a buffer is at index 1.
6358 - Function: concat &rest sequences
6359 This function returns a new string consisting of the characters in
6360 the arguments passed to it (along with their text properties, if
6361 any). The arguments may be strings, lists of numbers, or vectors
6362 of numbers; they are not themselves changed. If `concat' receives
6363 no arguments, it returns an empty string.
6365 (concat "abc" "-def")
6367 (concat "abc" (list 120 (+ 256 121)) [122])
6369 ;; `nil' is an empty sequence.
6370 (concat "abc" nil "-def")
6372 (concat "The " "quick brown " "fox.")
6373 => "The quick brown fox."
6377 The second example above shows how characters stored in strings are
6378 taken modulo 256. In other words, each character in the string is
6381 The `concat' function always constructs a new string that is not
6382 `eq' to any existing string.
6384 When an argument is an integer (not a sequence of integers), it is
6385 converted to a string of digits making up the decimal printed
6386 representation of the integer. *Don't use this feature; we plan
6387 to eliminate it. If you already use this feature, change your
6388 programs now!* The proper way to convert an integer to a decimal
6389 number in this way is with `format' (*note Formatting Strings::) or
6390 `number-to-string' (*note String Conversion::).
6397 For information about other concatenation functions, see the
6398 description of `mapconcat' in *Note Mapping Functions::, `vconcat'
6399 in *Note Vectors::, `bvconcat' in *Note Bit Vectors::, and `append'
6400 in *Note Building Lists::.
6403 File: lispref.info, Node: Predicates for Characters, Next: Character Codes, Prev: Creating Strings, Up: Strings and Characters
6405 The Predicates for Characters
6406 =============================
6408 - Function: characterp object
6409 This function returns `t' if OBJECT is a character.
6411 Some functions that work on integers (e.g. the comparison functions
6412 <, <=, =, /=, etc. and the arithmetic functions +, -, *, etc.)
6413 accept characters and implicitly convert them into integers. In
6414 general, functions that work on characters also accept char-ints
6415 and implicitly convert them into characters. WARNING: Neither of
6416 these behaviors is very desirable, and they are maintained for
6417 backward compatibility with old E-Lisp programs that confounded
6418 characters and integers willy-nilly. These behaviors may change
6419 in the future; therefore, do not rely on them. Instead, convert
6420 the characters explicitly using `char-int'.
6422 - Function: integer-or-char-p object
6423 This function returns `t' if OBJECT is an integer or character.
6426 File: lispref.info, Node: Character Codes, Next: Text Comparison, Prev: Predicates for Characters, Up: Strings and Characters
6431 - Function: char-int character
6432 This function converts a character into an equivalent integer.
6433 The resulting integer will always be non-negative. The integers in
6434 the range 0 - 255 map to characters as follows:
6446 Right half of ISO-8859-1
6448 If support for MULE does not exist, these are the only valid
6449 character values. When MULE support exists, the values assigned to
6450 other characters may vary depending on the particular version of
6451 XEmacs, the order in which character sets were loaded, etc., and
6452 you should not depend on them.
6454 - Function: int-char integer
6455 This function converts an integer into the equivalent character.
6456 Not all integers correspond to valid characters; use `char-int-p'
6457 to determine whether this is the case. If the integer cannot be
6458 converted, `nil' is returned.
6460 - Function: char-int-p object
6461 This function returns `t' if OBJECT is an integer that can be
6462 converted into a character.
6464 - Function: char-or-char-int-p object
6465 This function returns `t' if OBJECT is a character or an integer
6466 that can be converted into one.
6469 File: lispref.info, Node: Text Comparison, Next: String Conversion, Prev: Character Codes, Up: Strings and Characters
6471 Comparison of Characters and Strings
6472 ====================================
6474 - Function: char-equal character1 character2 &optional buffer
6475 This function returns `t' if the arguments represent the same
6476 character, `nil' otherwise. This function ignores differences in
6477 case if the value of `case-fold-search' is non-`nil' in BUFFER,
6478 which defaults to the current buffer.
6482 (let ((case-fold-search t))
6485 (let ((case-fold-search nil))
6489 - Function: char= character1 character2
6490 This function returns `t' if the arguments represent the same
6491 character, `nil' otherwise. Case is significant.
6497 (let ((case-fold-search t))
6500 (let ((case-fold-search nil))
6504 - Function: string= string1 string2
6505 This function returns `t' if the characters of the two strings
6506 match exactly; case is significant.
6508 (string= "abc" "abc")
6510 (string= "abc" "ABC")
6512 (string= "ab" "ABC")
6516 - Function: string-equal string1 string2
6517 `string-equal' is another name for `string='.
6519 - Function: string< string1 string2
6520 This function compares two strings a character at a time. First it
6521 scans both the strings at once to find the first pair of
6522 corresponding characters that do not match. If the lesser
6523 character of those two is the character from STRING1, then STRING1
6524 is less, and this function returns `t'. If the lesser character
6525 is the one from STRING2, then STRING1 is greater, and this
6526 function returns `nil'. If the two strings match entirely, the
6529 Pairs of characters are compared by their ASCII codes. Keep in
6530 mind that lower case letters have higher numeric values in the
6531 ASCII character set than their upper case counterparts; numbers and
6532 many punctuation characters have a lower numeric value than upper
6535 (string< "abc" "abd")
6537 (string< "abd" "abc")
6539 (string< "123" "abc")
6542 When the strings have different lengths, and they match up to the
6543 length of STRING1, then the result is `t'. If they match up to
6544 the length of STRING2, the result is `nil'. A string of no
6545 characters is less than any other string.
6549 (string< "ab" "abc")
6553 (string< "abc" "ab")
6558 - Function: string-lessp string1 string2
6559 `string-lessp' is another name for `string<'.
6561 See also `compare-buffer-substrings' in *Note Comparing Text::, for
6562 a way to compare text in buffers. The function `string-match', which
6563 matches a regular expression against a string, can be used for a kind
6564 of string comparison; see *Note Regexp Search::.
6567 File: lispref.info, Node: String Conversion, Next: Modifying Strings, Prev: Text Comparison, Up: Strings and Characters
6569 Conversion of Characters and Strings
6570 ====================================
6572 This section describes functions for conversions between characters,
6573 strings and integers. `format' and `prin1-to-string' (*note Output
6574 Functions::) can also convert Lisp objects into strings.
6575 `read-from-string' (*note Input Functions::) can "convert" a string
6576 representation of a Lisp object into an object.
6578 *Note Documentation::, for functions that produce textual
6579 descriptions of text characters and general input events
6580 (`single-key-description' and `text-char-description'). These
6581 functions are used primarily for making help messages.
6583 - Function: char-to-string character
6584 This function returns a new string with a length of one character.
6585 The value of CHARACTER, modulo 256, is used to initialize the
6586 element of the string.
6588 This function is similar to `make-string' with an integer argument
6589 of 1. (*Note Creating Strings::.) This conversion can also be
6590 done with `format' using the `%c' format specification. (*Note
6591 Formatting Strings::.)
6595 (char-to-string (+ 256 ?x))
6600 - Function: string-to-char string
6601 This function returns the first character in STRING. If the
6602 string is empty, the function returns 0. (Under XEmacs 19, the
6603 value is also 0 when the first character of STRING is the null
6604 character, ASCII code 0.)
6606 (string-to-char "ABC")
6607 => ?A ;; Under XEmacs 20.
6608 => 65 ;; Under XEmacs 19.
6609 (string-to-char "xyz")
6610 => ?x ;; Under XEmacs 20.
6611 => 120 ;; Under XEmacs 19.
6614 (string-to-char "\000")
6615 => ?\^ ;; Under XEmacs 20.
6616 => 0 ;; Under XEmacs 20.
6618 This function may be eliminated in the future if it does not seem
6619 useful enough to retain.
6621 - Function: number-to-string number
6622 This function returns a string consisting of the printed
6623 representation of NUMBER, which may be an integer or a floating
6624 point number. The value starts with a sign if the argument is
6627 (number-to-string 256)
6629 (number-to-string -23)
6631 (number-to-string -23.5)
6634 `int-to-string' is a semi-obsolete alias for this function.
6636 See also the function `format' in *Note Formatting Strings::.
6638 - Function: string-to-number string &optional base
6639 This function returns the numeric value represented by STRING,
6640 read in BASE. It skips spaces and tabs at the beginning of
6641 STRING, then reads as much of STRING as it can interpret as a
6642 number. (On some systems it ignores other whitespace at the
6643 beginning, not just spaces and tabs.) If the first character
6644 after the ignored whitespace is not a digit or a minus sign, this
6647 If BASE is not specified, it defaults to ten. With BASE other
6648 than ten, only integers can be read.
6650 (string-to-number "256")
6652 (string-to-number "25 is a perfect square.")
6654 (string-to-number "X256")
6656 (string-to-number "-4.5")
6658 (string-to-number "ffff" 16)
6661 `string-to-int' is an obsolete alias for this function.
6664 File: lispref.info, Node: Modifying Strings, Next: String Properties, Prev: String Conversion, Up: Strings and Characters
6669 You can modify a string using the general array-modifying primitives.
6670 *Note Arrays::. The function `aset' modifies a single character; the
6671 function `fillarray' sets all characters in the string to a specified
6674 Each string has a tick counter that starts out at zero (when the
6675 string is created) and is incremented each time a change is made to that
6678 - Function: string-modified-tick string
6679 This function returns the tick counter for `string'.
6682 File: lispref.info, Node: String Properties, Next: Formatting Strings, Prev: Modifying Strings, Up: Strings and Characters
6687 Just as with symbols, extents, faces, and glyphs, you can attach
6688 additional information to strings in the form of "string properties".
6689 These differ from text properties, which are logically attached to
6690 particular characters in the string.
6692 To attach a property to a string, use `put'. To retrieve a property
6693 from a string, use `get'. You can also use `remprop' to remove a
6694 property from a string and `object-plist' to retrieve a list of all the
6695 properties in a string.
6698 File: lispref.info, Node: Formatting Strings, Next: Character Case, Prev: String Properties, Up: Strings and Characters
6703 "Formatting" means constructing a string by substitution of computed
6704 values at various places in a constant string. This string controls
6705 how the other values are printed as well as where they appear; it is
6706 called a "format string".
6708 Formatting is often useful for computing messages to be displayed.
6709 In fact, the functions `message' and `error' provide the same
6710 formatting feature described here; they differ from `format' only in
6711 how they use the result of formatting.
6713 - Function: format string &rest objects
6714 This function returns a new string that is made by copying STRING
6715 and then replacing any format specification in the copy with
6716 encodings of the corresponding OBJECTS. The arguments OBJECTS are
6717 the computed values to be formatted.
6719 A format specification is a sequence of characters beginning with a
6720 `%'. Thus, if there is a `%d' in STRING, the `format' function
6721 replaces it with the printed representation of one of the values to be
6722 formatted (one of the arguments OBJECTS). For example:
6724 (format "The value of fill-column is %d." fill-column)
6725 => "The value of fill-column is 72."
6727 If STRING contains more than one format specification, the format
6728 specifications correspond with successive values from OBJECTS. Thus,
6729 the first format specification in STRING uses the first such value, the
6730 second format specification uses the second such value, and so on. Any
6731 extra format specifications (those for which there are no corresponding
6732 values) cause unpredictable behavior. Any extra values to be formatted
6735 Certain format specifications require values of particular types.
6736 However, no error is signaled if the value actually supplied fails to
6737 have the expected type. Instead, the output is likely to be
6740 Here is a table of valid format specifications:
6743 Replace the specification with the printed representation of the
6744 object, made without quoting. Thus, strings are represented by
6745 their contents alone, with no `"' characters, and symbols appear
6746 without `\' characters. This is equivalent to printing the object
6749 If there is no corresponding object, the empty string is used.
6752 Replace the specification with the printed representation of the
6753 object, made with quoting. Thus, strings are enclosed in `"'
6754 characters, and `\' characters appear where necessary before
6755 special characters. This is equivalent to printing the object
6758 If there is no corresponding object, the empty string is used.
6761 Replace the specification with the base-eight representation of an
6766 Replace the specification with the base-ten representation of an
6770 Replace the specification with the base-sixteen representation of
6771 an integer, using lowercase letters.
6774 Replace the specification with the base-sixteen representation of
6775 an integer, using uppercase letters.
6778 Replace the specification with the character which is the value
6782 Replace the specification with the exponential notation for a
6783 floating point number (e.g. `7.85200e+03').
6786 Replace the specification with the decimal-point notation for a
6787 floating point number.
6790 Replace the specification with notation for a floating point
6791 number, using a "pretty format". Either exponential notation or
6792 decimal-point notation will be used (usually whichever is
6793 shorter), and trailing zeroes are removed from the fractional part.
6796 A single `%' is placed in the string. This format specification is
6797 unusual in that it does not use a value. For example, `(format "%%
6798 %d" 30)' returns `"% 30"'.
6800 Any other format character results in an `Invalid format operation'
6803 Here are several examples:
6805 (format "The name of this buffer is %s." (buffer-name))
6806 => "The name of this buffer is strings.texi."
6808 (format "The buffer object prints as %s." (current-buffer))
6809 => "The buffer object prints as #<buffer strings.texi>."
6811 (format "The octal value of %d is %o,
6812 and the hex value is %x." 18 18 18)
6813 => "The octal value of 18 is 22,
6814 and the hex value is 12."
6816 There are many additional flags and specifications that can occur
6817 between the `%' and the format character, in the following order:
6819 1. An optional repositioning specification, which is a positive
6820 integer followed by a `$'.
6822 2. Zero or more of the optional flag characters `-', `+', ` ', `0',
6825 3. An asterisk (`*', meaning that the field width is now assumed to
6826 have been specified as an argument.
6828 4. An optional minimum field width.
6830 5. An optional precision, preceded by a `.' character.
6832 A "repositioning" specification changes which argument to `format'
6833 is used by the current and all following format specifications.
6834 Normally the first specification uses the first argument, the second
6835 specification uses the second argument, etc. Using a repositioning
6836 specification, you can change this. By placing a number N followed by
6837 a `$' between the `%' and the format character, you cause the
6838 specification to use the Nth argument. The next specification will use
6839 the N+1'th argument, etc.
6843 (format "Can't find file `%s' in directory `%s'."
6844 "ignatius.c" "loyola/")
6845 => "Can't find file `ignatius.c' in directory `loyola/'."
6847 (format "In directory `%2$s', the file `%1$s' was not found."
6848 "ignatius.c" "loyola/")
6849 => "In directory `loyola/', the file `ignatius.c' was not found."
6852 "The numbers %d and %d are %1$x and %x in hex and %1$o and %o in octal."
6854 => "The numbers 37 and 12 are 25 and c in hex and 45 and 14 in octal."
6856 As you can see, this lets you reprocess arguments more than once or
6857 reword a format specification (thereby moving the arguments around)
6858 without having to actually reorder the arguments. This is especially
6859 useful in translating messages from one language to another: Different
6860 languages use different word orders, and this sometimes entails changing
6861 the order of the arguments. By using repositioning specifications,
6862 this can be accomplished without having to embed knowledge of particular
6863 languages into the location in the program's code where the message is
6866 All the specification characters allow an optional numeric prefix
6867 between the `%' and the character, and following any repositioning
6868 specification or flag. The optional numeric prefix defines the minimum
6869 width for the object. If the printed representation of the object
6870 contains fewer characters than this, then it is padded. The padding is
6871 normally on the left, but will be on the right if the `-' flag
6872 character is given. The padding character is normally a space, but if
6873 the `0' flag character is given, zeros are used for padding.
6875 (format "%06d is padded on the left with zeros" 123)
6876 => "000123 is padded on the left with zeros"
6878 (format "%-6d is padded on the right" 123)
6879 => "123 is padded on the right"
6881 `format' never truncates an object's printed representation, no
6882 matter what width you specify. Thus, you can use a numeric prefix to
6883 specify a minimum spacing between columns with no risk of losing
6886 In the following three examples, `%7s' specifies a minimum width of
6887 7. In the first case, the string inserted in place of `%7s' has only 3
6888 letters, so 4 blank spaces are inserted for padding. In the second
6889 case, the string `"specification"' is 13 letters wide but is not
6890 truncated. In the third case, the padding is on the right.
6892 (format "The word `%7s' actually has %d letters in it."
6893 "foo" (length "foo"))
6894 => "The word ` foo' actually has 3 letters in it."
6896 (format "The word `%7s' actually has %d letters in it."
6897 "specification" (length "specification"))
6898 => "The word `specification' actually has 13 letters in it."
6900 (format "The word `%-7s' actually has %d letters in it."
6901 "foo" (length "foo"))
6902 => "The word `foo ' actually has 3 letters in it."
6904 After any minimum field width, a precision may be specified by
6905 preceding it with a `.' character. The precision specifies the minimum
6906 number of digits to appear in `%d', `%i', `%o', `%x', and `%X'
6907 conversions (the number is padded on the left with zeroes as
6908 necessary); the number of digits printed after the decimal point for
6909 `%f', `%e', and `%E' conversions; the number of significant digits
6910 printed in `%g' and `%G' conversions; and the maximum number of
6911 non-padding characters printed in `%s' and `%S' conversions. The
6912 default precision for floating-point conversions is six.
6914 The other flag characters have the following meanings:
6916 * The ` ' flag means prefix non-negative numbers with a space.
6918 * The `+' flag means prefix non-negative numbers with a plus sign.
6920 * The `#' flag means print numbers in an alternate, more verbose
6921 format: octal numbers begin with zero; hex numbers begin with a
6922 `0x' or `0X'; a decimal point is printed in `%f', `%e', and `%E'
6923 conversions even if no numbers are printed after it; and trailing
6924 zeroes are not omitted in `%g' and `%G' conversions.
6927 File: lispref.info, Node: Character Case, Next: Case Tables, Prev: Formatting Strings, Up: Strings and Characters
6932 The character case functions change the case of single characters or of
6933 the contents of strings. The functions convert only alphabetic
6934 characters (the letters `A' through `Z' and `a' through `z'); other
6935 characters are not altered. The functions do not modify the strings
6936 that are passed to them as arguments.
6938 The examples below use the characters `X' and `x' which have ASCII
6939 codes 88 and 120 respectively.
6941 - Function: downcase string-or-char &optional buffer
6942 This function converts a character or a string to lower case.
6944 When the argument to `downcase' is a string, the function creates
6945 and returns a new string in which each letter in the argument that
6946 is upper case is converted to lower case. When the argument to
6947 `downcase' is a character, `downcase' returns the corresponding
6948 lower case character. (This value is actually an integer under
6949 XEmacs 19.) If the original character is lower case, or is not a
6950 letter, then the value equals the original character.
6952 Optional second arg BUFFER specifies which buffer's case tables to
6953 use, and defaults to the current buffer.
6955 (downcase "The cat in the hat")
6956 => "the cat in the hat"
6959 => ?x ;; Under XEmacs 20.
6960 => 120 ;; Under XEmacs 19.
6962 - Function: upcase string-or-char &optional buffer
6963 This function converts a character or a string to upper case.
6965 When the argument to `upcase' is a string, the function creates
6966 and returns a new string in which each letter in the argument that
6967 is lower case is converted to upper case.
6969 When the argument to `upcase' is a character, `upcase' returns the
6970 corresponding upper case character. (This value is actually an
6971 integer under XEmacs 19.) If the original character is upper
6972 case, or is not a letter, then the value equals the original
6975 Optional second arg BUFFER specifies which buffer's case tables to
6976 use, and defaults to the current buffer.
6978 (upcase "The cat in the hat")
6979 => "THE CAT IN THE HAT"
6982 => ?X ;; Under XEmacs 20.
6983 => 88 ;; Under XEmacs 19.
6985 - Function: capitalize string-or-char &optional buffer
6986 This function capitalizes strings or characters. If
6987 STRING-OR-CHAR is a string, the function creates and returns a new
6988 string, whose contents are a copy of STRING-OR-CHAR in which each
6989 word has been capitalized. This means that the first character of
6990 each word is converted to upper case, and the rest are converted
6993 The definition of a word is any sequence of consecutive characters
6994 that are assigned to the word constituent syntax class in the
6995 current syntax table (*note Syntax Class Table::).
6997 When the argument to `capitalize' is a character, `capitalize' has
6998 the same result as `upcase'.
7000 Optional second arg BUFFER specifies which buffer's case tables to
7001 use, and defaults to the current buffer.
7003 (capitalize "The cat in the hat")
7004 => "The Cat In The Hat"
7006 (capitalize "THE 77TH-HATTED CAT")
7007 => "The 77th-Hatted Cat"
7010 => ?X ;; Under XEmacs 20.
7011 => 88 ;; Under XEmacs 19.
7014 File: lispref.info, Node: Case Tables, Next: Char Tables, Prev: Character Case, Up: Strings and Characters
7019 You can customize case conversion by installing a special "case table".
7020 A case table specifies the mapping between upper case and lower case
7021 letters. It affects both the string and character case conversion
7022 functions (see the previous section) and those that apply to text in the
7023 buffer (*note Case Changes::). You need a case table if you are using a
7024 language which has letters other than the standard ASCII letters.
7026 A case table is a list of this form:
7028 (DOWNCASE UPCASE CANONICALIZE EQUIVALENCES)
7030 where each element is either `nil' or a string of length 256. The
7031 element DOWNCASE says how to map each character to its lower-case
7032 equivalent. The element UPCASE maps each character to its upper-case
7033 equivalent. If lower and upper case characters are in one-to-one
7034 correspondence, use `nil' for UPCASE; then XEmacs deduces the upcase
7035 table from DOWNCASE.
7037 For some languages, upper and lower case letters are not in
7038 one-to-one correspondence. There may be two different lower case
7039 letters with the same upper case equivalent. In these cases, you need
7040 to specify the maps for both directions.
7042 The element CANONICALIZE maps each character to a canonical
7043 equivalent; any two characters that are related by case-conversion have
7044 the same canonical equivalent character.
7046 The element EQUIVALENCES is a map that cyclicly permutes each
7047 equivalence class (of characters with the same canonical equivalent).
7048 (For ordinary ASCII, this would map `a' into `A' and `A' into `a', and
7049 likewise for each set of equivalent characters.)
7051 When you construct a case table, you can provide `nil' for
7052 CANONICALIZE; then Emacs fills in this string from UPCASE and DOWNCASE.
7053 You can also provide `nil' for EQUIVALENCES; then Emacs fills in this
7054 string from CANONICALIZE. In a case table that is actually in use,
7055 those components are non-`nil'. Do not try to specify EQUIVALENCES
7056 without also specifying CANONICALIZE.
7058 Each buffer has a case table. XEmacs also has a "standard case
7059 table" which is copied into each buffer when you create the buffer.
7060 Changing the standard case table doesn't affect any existing buffers.
7062 Here are the functions for working with case tables:
7064 - Function: case-table-p object
7065 This predicate returns non-`nil' if OBJECT is a valid case table.
7067 - Function: set-standard-case-table case-table
7068 This function makes CASE-TABLE the standard case table, so that it
7069 will apply to any buffers created subsequently.
7071 - Function: standard-case-table
7072 This returns the standard case table.
7074 - Function: current-case-table &optional buffer
7075 This function returns the case table of BUFFER, which defaults to
7078 - Function: set-case-table case-table
7079 This sets the current buffer's case table to CASE-TABLE.
7081 The following three functions are convenient subroutines for packages
7082 that define non-ASCII character sets. They modify a string
7083 DOWNCASE-TABLE provided as an argument; this should be a string to be
7084 used as the DOWNCASE part of a case table. They also modify the
7085 standard syntax table. *Note Syntax Tables::.
7087 - Function: set-case-syntax-pair uc lc downcase-table
7088 This function specifies a pair of corresponding letters, one upper
7089 case and one lower case.
7091 - Function: set-case-syntax-delims l r downcase-table
7092 This function makes characters L and R a matching pair of
7093 case-invariant delimiters.
7095 - Function: set-case-syntax char syntax downcase-table
7096 This function makes CHAR case-invariant, with syntax SYNTAX.
7098 - Command: describe-buffer-case-table
7099 This command displays a description of the contents of the current
7100 buffer's case table.
7102 You can load the library `iso-syntax' to set up the standard syntax
7103 table and define a case table for the 8-bit ISO Latin 1 character set.
7106 File: lispref.info, Node: Char Tables, Prev: Case Tables, Up: Strings and Characters
7111 A char table is a table that maps characters (or ranges of characters)
7112 to values. Char tables are specialized for characters, only allowing
7113 particular sorts of ranges to be assigned values. Although this loses
7114 in generality, it makes for extremely fast (constant-time) lookups, and
7115 thus is feasible for applications that do an extremely large number of
7116 lookups (e.g. scanning a buffer for a character in a particular syntax,
7117 where a lookup in the syntax table must occur once per character).
7119 Note that char tables as a primitive type, and all of the functions
7120 in this section, exist only in XEmacs 20. In XEmacs 19, char tables are
7121 generally implemented using a vector of 256 elements.
7123 When MULE support exists, the types of ranges that can be assigned
7130 * a single row in a two-octet charset
7132 * a single character
7134 When MULE support is not present, the types of ranges that can be
7139 * a single character
7141 - Function: char-table-p object
7142 This function returns non-`nil' if OBJECT is a char table.
7146 * Char Table Types:: Char tables have different uses.
7147 * Working With Char Tables:: Creating and working with char tables.
7150 File: lispref.info, Node: Char Table Types, Next: Working With Char Tables, Up: Char Tables
7155 Each char table type is used for a different purpose and allows
7156 different sorts of values. The different char table types are
7159 Used for category tables, which specify the regexp categories that
7160 a character is in. The valid values are `nil' or a bit vector of
7161 95 elements. Higher-level Lisp functions are provided for working
7162 with category tables. Currently categories and category tables
7163 only exist when MULE support is present.
7166 A generalized char table, for mapping from one character to
7167 another. Used for case tables, syntax matching tables,
7168 `keyboard-translate-table', etc. The valid values are characters.
7171 An even more generalized char table, for mapping from a character
7175 Used for display tables, which specify how a particular character
7176 is to appear when displayed. #### Not yet implemented.
7179 Used for syntax tables, which specify the syntax of a particular
7180 character. Higher-level Lisp functions are provided for working
7181 with syntax tables. The valid values are integers.
7183 - Function: char-table-type char-table
7184 This function returns the type of char table CHAR-TABLE.
7186 - Function: char-table-type-list
7187 This function returns a list of the recognized char table types.
7189 - Function: valid-char-table-type-p type
7190 This function returns `t' if TYPE if a recognized char table type.
7193 File: lispref.info, Node: Working With Char Tables, Prev: Char Table Types, Up: Char Tables
7195 Working With Char Tables
7196 ------------------------
7198 - Function: make-char-table type
7199 This function makes a new, empty char table of type TYPE. TYPE
7200 should be a symbol, one of `char', `category', `display',
7201 `generic', or `syntax'.
7203 - Function: put-char-table range value char-table
7204 This function sets the value for chars in RANGE to be VALUE in
7207 RANGE specifies one or more characters to be affected and should be
7208 one of the following:
7210 * `t' (all characters are affected)
7212 * A charset (only allowed when MULE support is present)
7214 * A vector of two elements: a two-octet charset and a row number
7215 (only allowed when MULE support is present)
7217 * A single character
7219 VALUE must be a value appropriate for the type of CHAR-TABLE.
7221 - Function: get-char-table character char-table
7222 This function finds the value for CHARACTER in CHAR-TABLE.
7224 - Function: get-range-char-table range char-table &optional multi
7225 This function finds the value for a range in CHAR-TABLE. If there
7226 is more than one value, MULTI is returned (defaults to `nil').
7228 - Function: reset-char-table char-table
7229 This function resets CHAR-TABLE to its default state.
7231 - Function: map-char-table function char-table &optional range
7232 This function maps FUNCTION over entries in CHAR-TABLE, calling it
7233 with two args, each key and value in the table.
7235 RANGE specifies a subrange to map over and is in the same format
7236 as the RANGE argument to `put-range-table'. If omitted or `t', it
7237 defaults to the entire table.
7239 - Function: valid-char-table-value-p value char-table-type
7240 This function returns non-`nil' if VALUE is a valid value for
7243 - Function: check-valid-char-table-value value char-table-type
7244 This function signals an error if VALUE is not a valid value for
7248 File: lispref.info, Node: Lists, Next: Sequences Arrays Vectors, Prev: Strings and Characters, Up: Top
7253 A "list" represents a sequence of zero or more elements (which may be
7254 any Lisp objects). The important difference between lists and vectors
7255 is that two or more lists can share part of their structure; in
7256 addition, you can insert or delete elements in a list without copying
7261 * Cons Cells:: How lists are made out of cons cells.
7262 * Lists as Boxes:: Graphical notation to explain lists.
7263 * List-related Predicates:: Is this object a list? Comparing two lists.
7264 * List Elements:: Extracting the pieces of a list.
7265 * Building Lists:: Creating list structure.
7266 * Modifying Lists:: Storing new pieces into an existing list.
7267 * Sets And Lists:: A list can represent a finite mathematical set.
7268 * Association Lists:: A list can represent a finite relation or mapping.
7269 * Property Lists:: A different way to represent a finite mapping.
7270 * Weak Lists:: A list with special garbage-collection behavior.
7273 File: lispref.info, Node: Cons Cells, Next: Lists as Boxes, Up: Lists
7275 Lists and Cons Cells
7276 ====================
7278 Lists in Lisp are not a primitive data type; they are built up from
7279 "cons cells". A cons cell is a data object that represents an ordered
7280 pair. It records two Lisp objects, one labeled as the CAR, and the
7281 other labeled as the CDR. These names are traditional; see *Note Cons
7282 Cell Type::. CDR is pronounced "could-er."
7284 A list is a series of cons cells chained together, one cons cell per
7285 element of the list. By convention, the CARs of the cons cells are the
7286 elements of the list, and the CDRs are used to chain the list: the CDR
7287 of each cons cell is the following cons cell. The CDR of the last cons
7288 cell is `nil'. This asymmetry between the CAR and the CDR is entirely
7289 a matter of convention; at the level of cons cells, the CAR and CDR
7290 slots have the same characteristics.
7292 Because most cons cells are used as part of lists, the phrase "list
7293 structure" has come to mean any structure made out of cons cells.
7295 The symbol `nil' is considered a list as well as a symbol; it is the
7296 list with no elements. For convenience, the symbol `nil' is considered
7297 to have `nil' as its CDR (and also as its CAR).
7299 The CDR of any nonempty list L is a list containing all the elements
7300 of L except the first.
7303 File: lispref.info, Node: Lists as Boxes, Next: List-related Predicates, Prev: Cons Cells, Up: Lists
7305 Lists as Linked Pairs of Boxes
7306 ==============================
7308 A cons cell can be illustrated as a pair of boxes. The first box
7309 represents the CAR and the second box represents the CDR. Here is an
7310 illustration of the two-element list, `(tulip lily)', made from two
7313 --------------- ---------------
7314 | car | cdr | | car | cdr |
7315 | tulip | o---------->| lily | nil |
7317 --------------- ---------------
7319 Each pair of boxes represents a cons cell. Each box "refers to",
7320 "points to" or "contains" a Lisp object. (These terms are synonymous.)
7321 The first box, which is the CAR of the first cons cell, contains the
7322 symbol `tulip'. The arrow from the CDR of the first cons cell to the
7323 second cons cell indicates that the CDR of the first cons cell points
7324 to the second cons cell.
7326 The same list can be illustrated in a different sort of box notation
7330 |___|___|--> |___|___|--> nil
7335 Here is a more complex illustration, showing the three-element list,
7336 `((pine needles) oak maple)', the first element of which is a
7339 ___ ___ ___ ___ ___ ___
7340 |___|___|--> |___|___|--> |___|___|--> nil
7346 --> |___|___|--> |___|___|--> nil
7349 --> pine --> needles
7351 The same list represented in the first box notation looks like this:
7353 -------------- -------------- --------------
7354 | car | cdr | | car | cdr | | car | cdr |
7355 | o | o------->| oak | o------->| maple | nil |
7357 -- | --------- -------------- --------------
7360 | -------------- ----------------
7361 | | car | cdr | | car | cdr |
7362 ------>| pine | o------->| needles | nil |
7364 -------------- ----------------
7366 *Note Cons Cell Type::, for the read and print syntax of cons cells
7367 and lists, and for more "box and arrow" illustrations of lists.
7370 File: lispref.info, Node: List-related Predicates, Next: List Elements, Prev: Lists as Boxes, Up: Lists
7375 The following predicates test whether a Lisp object is an atom, is a
7376 cons cell or is a list, or whether it is the distinguished object
7377 `nil'. (Many of these predicates can be defined in terms of the
7378 others, but they are used so often that it is worth having all of them.)
7380 - Function: consp object
7381 This function returns `t' if OBJECT is a cons cell, `nil'
7382 otherwise. `nil' is not a cons cell, although it _is_ a list.
7384 - Function: atom object
7385 This function returns `t' if OBJECT is an atom, `nil' otherwise.
7386 All objects except cons cells are atoms. The symbol `nil' is an
7387 atom and is also a list; it is the only Lisp object that is both.
7389 (atom OBJECT) == (not (consp OBJECT))
7391 - Function: listp object
7392 This function returns `t' if OBJECT is a cons cell or `nil'.
7393 Otherwise, it returns `nil'.
7400 - Function: nlistp object
7401 This function is the opposite of `listp': it returns `t' if OBJECT
7402 is not a list. Otherwise, it returns `nil'.
7404 (listp OBJECT) == (not (nlistp OBJECT))
7406 - Function: null object
7407 This function returns `t' if OBJECT is `nil', and returns `nil'
7408 otherwise. This function is identical to `not', but as a matter
7409 of clarity we use `null' when OBJECT is considered a list and
7410 `not' when it is considered a truth value (see `not' in *Note
7411 Combining Conditions::).