GNU Emacs Lisp Reference Manual
GNU Emacs Version 19, for Unix Users, Second Edition, June 1993, Further Revised, August 1993
and the GNU Manual Group
GNU GENERAL PUBLIC LICENSE
Preamble
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
How to Apply These Terms to Your New Programs
Introduction
Caveats
Lisp History
Conventions
Some Terms
nil
and
t
Evaluation Notation
Printing Notation
Error Messages
Buffer Text Notation
Format of Descriptions
A Sample Function Description
A Sample Variable Description
Acknowledgements
Lisp Data Types
Printed Representation and Read Syntax
Comments
Programming Types
Integer Type
Floating Point Type
Character Type
Sequence Types
List Type
Dotted Pair Notation
Association List Type
Array Type
String Type
Vector Type
Symbol Type
Lisp Function Type
Lisp Macro Type
Primitive Function Type
Byte-Code Function Type
Autoload Type
Editing Types
Buffer Type
Window Type
Frame Type
Window Configuration Type
Marker Type
Process Type
Stream Type
Keymap Type
Syntax Table Type
Display Table Type
Overlay Type
Type Predicates
Equality Predicates
Numbers
Integer Basics
Floating Point Basics
Type Predicates for Numbers
Comparison of Numbers
Numeric Conversions
Arithmetic Operations
Bitwise Operations on Integers
Transcendental Functions
Random Numbers
Strings and Characters
Introduction to Strings and Characters
The Predicates for Strings
Creating Strings
Comparison of Characters and Strings
Conversion of Characters and Strings
Formatting Strings
Character Case
The Case Table
Lists
Lists and Cons Cells
Lists as Linked Pairs of Boxes
Predicates on Lists
Accessing Elements of Lists
Building Cons Cells and Lists
Modifying Existing List Structure
Altering List Elements with
setcar
Altering the CDR of a List
Functions that Rearrange Lists
Using Lists as Sets
Association Lists
Sequences, Arrays, and Vectors
Sequences
Arrays
Functions that Operate on Arrays
Vectors
Symbols
Symbol Components
Defining Symbols
Creating and Interning Symbols
Property Lists
Evaluation
Eval
Kinds of Forms
Self-Evaluating Forms
Symbol Forms
Classification of List Forms
Symbol Function Indirection
Evaluation of Function Forms
Lisp Macro Evaluation
Special Forms
Autoloading
Quoting
Control Structures
Sequencing
Conditionals
Constructs for Combining Conditions
Iteration
Nonlocal Exits
Explicit Nonlocal Exits:
catch
and
throw
Examples of
catch
and
throw
Errors
How to Signal an Error
How Emacs Processes Errors
Writing Code to Handle Errors
Error Symbols and Condition Names
Cleaning Up from Nonlocal Exits
Variables
Global Variables
Variables that Never Change
Local Variables
When a Variable is "Void"
Defining Global Variables
Accessing Variable Values
How to Alter a Variable Value
Scoping Rules for Variable Bindings
Scope
Extent
Implementation of Dynamic Scoping
Proper Use of Dynamic Scoping
Buffer-Local Variables
Introduction to Buffer-Local Variables
Creating and Destroying Buffer-local Bindings
The Default Value of a Buffer-Local Variable
Functions
What Is a Function?
Lambda Expressions
Components of a Lambda Expression
A Simple Lambda-Expression Example
Advanced Features of Argument Lists
Documentation Strings of Functions
Naming a Function
Defining Named Functions
Calling Functions
Mapping Functions
Anonymous Functions
Accessing Function Cell Contents
Inline Functions
Other Topics Related to Functions
Macros
A Simple Example of a Macro
Expansion of a Macro Call
Macros and Byte Compilation
Defining Macros
Backquote
Common Problems Using Macros
Evaluating Macro Arguments Too Many Times
Local Variables in Macro Expansions
Evaluating Macro Arguments in Expansion
How Many Times is the Macro Expanded?
Loading
How Programs Do Loading
Autoload
Repeated Loading
Features
Unloading
Hooks for Loading
Byte Compilation
The Compilation Functions
Evaluation During Compilation
Byte-Code Objects
Disassembled Byte-Code
Debugging Lisp Programs
The Lisp Debugger
Entering the Debugger on an Error
Debugging Infinite Loops
Entering the Debugger on a Function Call
Explicit Entry to the Debugger
Using the Debugger
Debugger Commands
Invoking the Debugger
Internals of the Debugger
Debugging Invalid Lisp Syntax
Excess Open Parentheses
Excess Close Parentheses
Debugging Problems in Compilation
Edebug
Using Edebug
Preparing Functions for Edebug
Edebug Modes
Stepping
Miscellaneous
Breakpoints
Views
Evaluation
Evaluation List Buffer
Printing
The Outside Context
Just Checking
Outside Window Configuration
Recursive Edit
Side Effects
Macro Calls
Edebug Options
Reading and Printing Lisp Objects
Introduction to Reading and Printing
Input Streams
Input Functions
Output Streams
Output Functions
Variables Affecting Output
Minibuffers
Introduction to Minibuffers
Reading Text Strings with the Minibuffer
Reading Lisp Objects with the Minibuffer
Minibuffer History
Completion
Basic Completion Functions
Programmed Completion
Completion and the Minibuffer
Minibuffer Commands That Do Completion
High-Level Completion Functions
Reading File Names
Lisp Symbol Completion
Yes-or-No Queries
Asking Multiple Y-or-N Queries
Minibuffer Miscellany
Command Loop
Command Loop Overview
Defining Commands
Using
interactive
Code Characters for
interactive
Examples of Using
interactive
Interactive Call
Information from the Command Loop
Input Events
Keyboard Events
Function Keys
Click Events
Drag Events
Button-Down Events
Repeat Events
Motion Events
Focus Events
Event Examples
Classifying Events
Accessing Events
Putting Keyboard Events in Strings
Reading Input
Key Sequence Input
Reading One Event
Quoted Character Input
Peeking and Discarding
Waiting for Elapsed Time or Input
Quitting
Prefix Command Arguments
Recursive Editing
Disabling Commands
Command History
Keyboard Macros
Keymaps
Keymap Terminology
Format of Keymaps
Creating Keymaps
Inheritance and Keymaps
Prefix Keys
Menu Keymaps
Defining Menus
Menus and the Mouse
Menus and the Keyboard
Menu Example
The Menu Bar
Modifying Menus
Active Keymaps
Key Lookup
Functions for Key Lookup
Changing Key Bindings
Commands for Binding Keys
Scanning Keymaps
Major and Minor Modes
Major Modes
Major Mode Conventions
Major Mode Examples
How Emacs Chooses a Major Mode
Getting Help about a Major Mode
Minor Modes
Conventions for Writing Minor Modes
Keymaps and Minor Modes
Mode Line Format
The Data Structure of the Mode Line
Variables Used in the Mode Line
%
-Constructs in the Mode Line
Hooks
Documentation
Documentation Basics
Access to Documentation Strings
Substituting Key Bindings in Documentation
Describing Characters for Help Messages
Help Functions
Files
Visiting Files
Functions for Visiting Files
Subroutines of Visiting
Saving Buffers
Reading from Files
Writing to Files
File Locks
Information about Files
Testing Accessibility
Distinguishing Kinds of Files
Truenames
Other Information about Files
Contents of Directories
Creating and Deleting Directories
Changing File Names and Attributes
File Names
File Name Components
Directory Names
Absolute and Relative File Names
Functions that Expand Filenames
Generating Unique File Names
File Name Completion
Making Certain File Names "Magic"
Backups and Auto-Saving
Backup Files
Making Backup Files
Backup by Renaming or by Copying?
Making and Deleting Numbered Backup Files
Naming Backup Files
Auto-Saving
Reverting
Buffers
Buffer Basics
Buffer Names
Buffer File Name
Buffer Modification
Comparison of Modification Time
Read-Only Buffers
The Buffer List
Creating Buffers
Killing Buffers
The Current Buffer
Windows
Basic Concepts of Emacs Windows
Splitting Windows
Deleting Windows
Selecting Windows
Cycling Ordering of Windows
Buffers and Windows
Displaying Buffers in Windows
Choosing a Window
Window Point
The Window Start Position
Vertical Scrolling
Horizontal Scrolling
The Size of a Window
Changing the Size of a Window
Coordinates and Windows
Window Configurations
Frames
Creating Frames
Frame Parameters
Access to Frame Parameters
Initial Frame Parameters
X Window Frame Parameters
Frame Size And Position
Deleting Frames
Finding All Frames
Frames and Windows
Minibuffers and Frames
Input Focus
Visibility of Frames
Raising and Lowering Frames
Frame Configurations
Mouse Tracking
Mouse Position
Pop-Up Menus
X Selections
X Server
X Connections
Resources
Data about the X Server
Positions
Point
Motion
Motion by Characters
Motion by Words
Motion to an End of the Buffer
Motion by Text Lines
Motion by Screen Lines
The User-Level Vertical Motion Commands
Moving over Balanced Expressions
Skipping Characters
Excursions
Narrowing
Markers
Overview of Markers
Predicates on Markers
Functions That Create Markers
Information from Markers
Changing Markers
The Mark
The Region
Text
Examining Text Near Point
Examining Buffer Contents
Comparing Text
Insertion
User-Level Insertion Commands
Deletion of Text
User-Level Deletion Commands
The Kill Ring
Kill Ring Concepts
Functions for Killing
Functions for Yanking
Low Level Kill Ring
Internals of the Kill Ring
Undo
Maintaining Undo Lists
Filling
Auto Filling
Sorting Text
Indentation
Indentation Primitives
Indentation Controlled by Major Mode
Indenting an Entire Region
Indentation Relative to Previous Lines
Adjustable "Tab Stops"
Indentation-Based Motion Commands
Counting Columns
Case Changes
Text Properties
Examining Text Properties
Changing Text Properties
Property Search Functions
Special Properties
Stickiness of Text Properties
Why Text Properties are not Intervals
Substituting for a Character Code
Underlining
Registers
Change Hooks
Searching and Matching
Searching for Strings
Regular Expressions
Syntax of Regular Expressions
Complex Regexp Example
Regular Expression Searching
Replacement
The Match Data
Simple Match Data Access
Replacing the Text That Matched
Accessing the Entire Match Data
Saving and Restoring the Match Data
Standard Regular Expressions Used in Editing
Searching and Case
Syntax Tables
Syntax Descriptors
Table of Syntax Classes
Syntax Flags
Syntax Table Functions
Motion and Syntax
Parsing Balanced Expressions
Some Standard Syntax Tables
Syntax Table Internals
Abbrevs And Abbrev Expansion
Setting Up Abbrev Mode
Abbrev Tables
Defining Abbrevs
Saving Abbrevs in Files
Looking Up and Expanding Abbreviations
Standard Abbrev Tables
Processes
Functions that Create Subprocesses
Creating a Synchronous Process
Creating an Asynchronous Process
Deleting Processes
Process Information
Sending Input to Processes
Sending Signals to Processes
Receiving Output from Processes
Process Buffers
Process Filter Functions
Accepting Output from Processes
Sentinels: Detecting Process Status Changes
Transaction Queues
TCP
Operating System Interface
Starting Up Emacs
Summary: Sequence of Actions at Start Up
The Init File:
`.emacs'
Terminal-Specific Initialization
Command Line Arguments
Getting out of Emacs
Killing Emacs
Suspending Emacs
Operating System Environment
User Identification
Time of Day
Timers
Terminal Input
Input Modes
Translating Input Events
Recording Input
Terminal Output
Flow Control
Batch Mode
Emacs Display
Refreshing the Screen
Screen Size
Truncation
The Echo Area
Selective Display
Overlay Arrow
Temporary Displays
Overlays
Overlay Properties
Managing Overlays
Faces
Merging Faces for Display
Functions for Working with Faces
Blinking
Inverse Video
Usual Display Conventions
Display Tables
Display Table Format
Active Display Table
Glyphs
ISO Latin 1
Beeping
Window Systems
Customizing the Calendar and Diary
Customizing the Calendar
Customizing the Holidays
Date Display Format
Time Display Format
Daylight Savings Time
Customizing the Diary
Hebrew- and Islamic-Date Diary Entries
Fancy Diary Display
Included Diary Files
Sexp Entries and the Fancy Diary Display
Customizing Appointment Reminders
Tips and Standards
Writing Clean Lisp Programs
Tips for Making Compiled Code Fast
Tips for Documentation Strings
Tips on Writing Comments
Conventional Headers for Emacs Libraries
GNU Emacs Internals
Building Emacs
Pure Storage
Garbage Collection
Writing Emacs Primitives
Object Internals
Buffer Internals
Window Internals
Process Internals
Standard Errors
Buffer-Local Variables
Standard Keymaps
Standard Hooks
Emacs 18 Antinews
Old Features in the Lisp Language
Compilation Features
Floating Point Numbers
Changes in Basic Editing Functions
Text Properties
Features for Files
Making Certain File Names "Magic"
Frames
X Window System Features
Window Actions that Were No Longer Useful
Display Features
Working with Input Events
Menus
Changes in Minibuffer Features
New Features for Defining Commands
Removed Features for Reading Input
Removed Syntax Table Features
The Case Table
Features for Dealing with Buffers
Local Variables Features
Features for Subprocesses
Dealing with Times And Time Delays
Features not Available for Lisp Debuggers
Memory Allocation Changes
Hook Changes