1. Trang chủ
  2. » Công Nghệ Thông Tin

GNU Emacs Lisp Reference Manual

964 1.3K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • 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

    • Version Information

    • Acknowledgements

  • Lisp Data Types

    • Printed Representation and Read Syntax

    • Comments

    • Programming Types

      • Integer Type

      • Floating Point Type

      • Character Type

        • Basic Char Syntax

        • General Escape Syntax

        • Control-Character Syntax

        • Meta-Character Syntax

        • Other Character Modifier Bits

      • Symbol Type

      • Sequence Types

      • Cons Cell and List Types

        • Drawing Lists as Box Diagrams

        • Dotted Pair Notation

        • Association List Type

      • Array Type

      • String Type

        • Syntax for Strings

        • Non-ASCII Characters in Strings

        • Nonprinting Characters in Strings

        • Text Properties in Strings

      • Vector Type

      • Char-Table Type

      • Bool-Vector Type

      • Hash Table Type

      • Function Type

      • Macro Type

      • Primitive Function Type

      • Byte-Code Function Type

      • Autoload Type

    • Editing Types

      • Buffer Type

      • Marker Type

      • Window Type

      • Frame Type

      • Window Configuration Type

      • Frame Configuration Type

      • Process Type

      • Stream Type

      • Keymap Type

      • Overlay Type

    • Read Syntax for Circular Objects

    • Type Predicates

    • Equality Predicates

  • Numbers

    • Integer Basics

    • Floating Point Basics

    • Type Predicates for Numbers

    • Comparison of Numbers

    • Numeric Conversions

    • Arithmetic Operations

    • Rounding Operations

    • Bitwise Operations on Integers

    • Standard Mathematical Functions

    • Random Numbers

  • Strings and Characters

    • String and Character Basics

    • The Predicates for Strings

    • Creating Strings

    • Modifying Strings

    • Comparison of Characters and Strings

    • Conversion of Characters and Strings

    • Formatting Strings

    • Case Conversion in Lisp

    • The Case Table

  • Lists

    • Lists and Cons Cells

    • Predicates on Lists

    • Accessing Elements of Lists

    • Building Cons Cells and Lists

    • Modifying List Variables

    • 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

    • Managing a Fixed-Size Ring of Objects

  • Sequences, Arrays, and Vectors

    • Sequences

    • Arrays

    • Functions that Operate on Arrays

    • Vectors

    • Functions for Vectors

    • Char-Tables

    • Bool-vectors

  • Hash Tables

    • Creating Hash Tables

    • Hash Table Access

    • Defining Hash Comparisons

    • Other Hash Table Functions

  • Symbols

    • Symbol Components

    • Defining Symbols

    • Creating and Interning Symbols

    • Property Lists

      • Property Lists and Association Lists

      • Property List Functions for Symbols

      • Property Lists Outside Symbols

  • Evaluation

    • 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

    • Eval

  • 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

    • Tips for Defining Variables Robustly

    • 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 Deleting Buffer-Local Bindings

      • The Default Value of a Buffer-Local Variable

    • Frame-Local Variables

    • Possible Future Local Variables

    • File Local Variables

    • Variable Aliases

    • Variables with Restricted Values

  • Functions

    • What Is a Function?

    • Lambda Expressions

      • Components of a Lambda Expression

      • A Simple Lambda-Expression Example

      • Other Features of Argument Lists

      • Documentation Strings of Functions

    • Naming a Function

    • Defining Functions

    • Calling Functions

    • Mapping Functions

    • Anonymous Functions

    • Accessing Function Cell Contents

    • Declaring Functions Obsolete

    • Inline Functions

    • Determining whether a Function is Safe to Call

    • 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

      • Wrong Time

      • Evaluating Macro Arguments Repeatedly

      • Local Variables in Macro Expansions

      • Evaluating Macro Arguments in Expansion

      • How Many Times is the Macro Expanded?

    • Indenting Macros

  • Writing Customization Definitions

    • Common Item Keywords

    • Defining Customization Groups

    • Defining Customization Variables

    • Customization Types

      • Simple Types

      • Composite Types

      • Splicing into Lists

      • Type Keywords

      • Defining New Types

  • Loading

    • How Programs Do Loading

    • Load Suffixes

    • Library Search

    • Loading Non-ASCII Characters

    • Autoload

    • Repeated Loading

    • Features

    • Which File Defined a Certain Symbol

    • Unloading

    • Hooks for Loading

  • Byte Compilation

    • Performance of Byte-Compiled Code

    • The Compilation Functions

    • Documentation Strings and Compilation

    • Dynamic Loading of Individual Functions

    • Evaluation During Compilation

    • Compiler Errors

    • Byte-Code Function Objects

    • Disassembled Byte-Code

  • Advising Emacs Lisp Functions

    • A Simple Advice Example

    • Defining Advice

    • Around-Advice

    • Computed Advice

    • Activation of Advice

    • Enabling and Disabling Advice

    • Preactivation

    • Argument Access in Advice

    • Advising Primitives

    • The Combined Definition

  • 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

    • Edebug

      • Using Edebug

      • Instrumenting for Edebug

      • Edebug Execution Modes

      • Jumping

      • Miscellaneous Edebug Commands

      • Breaks

        • Edebug Breakpoints

        • Global Break Condition

        • Source Breakpoints

      • Trapping Errors

      • Edebug Views

      • Evaluation

      • Evaluation List Buffer

      • Printing in Edebug

      • Trace Buffer

      • Coverage Testing

      • The Outside Context

        • Checking Whether to Stop

        • Edebug Display Update

        • Edebug Recursive Edit

      • Edebug and Macros

        • Instrumenting Macro Calls

        • Specification List

        • Backtracking in Specifications

        • Specification Examples

      • Edebug Options

    • Debugging Invalid Lisp Syntax

      • Excess Open Parentheses

      • Excess Close Parentheses

    • Test Coverage

    • Debugging Problems in Compilation

  • 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

    • Initial Input

    • Completion

      • Basic Completion Functions

      • Completion and the Minibuffer

      • Minibuffer Commands that Do Completion

      • High-Level Completion Functions

      • Reading File Names

      • Programmed Completion

    • Yes-or-No Queries

    • Asking Multiple Y-or-N Questions

    • Reading a Password

    • Minibuffer Commands

    • Minibuffer Windows

    • Minibuffer Contents

    • Recursive Minibuffers

    • 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

    • Adjusting Point After Commands

    • Input Events

      • Keyboard Events

      • Function Keys

      • Mouse Events

      • Click Events

      • Drag Events

      • Button-Down Events

      • Repeat Events

      • Motion Events

      • Focus Events

      • Miscellaneous System Events

      • Event Examples

      • Classifying Events

      • Accessing Events

      • Putting Keyboard Events in Strings

    • Reading Input

      • Key Sequence Input

      • Reading One Event

      • Modifying and Translating Input Events

      • Invoking the Input Method

      • Quoted Character Input

      • Miscellaneous Event Input Features

    • Special Events

    • Waiting for Elapsed Time or Input

    • Quitting

    • Prefix Command Arguments

    • Recursive Editing

    • Disabling Commands

    • Command History

    • Keyboard Macros

  • Keymaps

    • Key Sequences

    • Keymap Basics

    • Format of Keymaps

    • Creating Keymaps

    • Inheritance and Keymaps

    • Prefix Keys

    • Active Keymaps

    • Searching the Active Keymaps

    • Controlling the Active Keymaps

    • Key Lookup

    • Functions for Key Lookup

    • Changing Key Bindings

    • Remapping Commands

    • Keymaps for Translating Sequences of Events

    • Commands for Binding Keys

    • Scanning Keymaps

    • Menu Keymaps

      • Defining Menus

        • Simple Menu Items

        • Extended Menu Items

        • Menu Separators

        • Alias Menu Items

      • Menus and the Mouse

      • Menus and the Keyboard

      • Menu Example

      • The Menu Bar

      • Tool bars

      • Modifying Menus

  • Major and Minor Modes

    • Hooks

    • Major Modes

      • Major Mode Basics

      • Major Mode Conventions

      • How Emacs Chooses a Major Mode

      • Getting Help about a Major Mode

      • Defining Derived Modes

      • Generic Modes

      • Mode Hooks

      • Major Mode Examples

    • Minor Modes

      • Conventions for Writing Minor Modes

      • Keymaps and Minor Modes

      • Defining Minor Modes

    • Mode-Line Format

      • Mode Line Basics

      • The Data Structure of the Mode Line

      • The Top Level of Mode Line Control

      • Variables Used in the Mode Line

      • %-Constructs in the Mode Line

      • Properties in the Mode Line

      • Window Header Lines

      • Emulating Mode-Line Formatting

    • Imenu

    • Font Lock Mode

      • Font Lock Basics

      • Search-based Fontification

      • Customizing Search-Based Fontification

      • Other Font Lock Variables

      • Levels of Font Lock

      • Precalculated Fontification

      • Faces for Font Lock

      • Syntactic Font Lock

      • Setting Syntax Properties

      • Multiline Font Lock Constructs

        • Font Lock Multiline

        • Region to Fontify after a Buffer Change

    • Desktop Save Mode

  • 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

      • How to Locate Files in Standard Places

    • Changing File Names and Attributes

    • File Names

      • File Name Components

      • Absolute and Relative File Names

      • Directory Names

      • Functions that Expand Filenames

      • Generating Unique File Names

      • File Name Completion

      • Standard File Names

    • Contents of Directories

    • Creating and Deleting Directories

    • Making Certain File Names ``Magic''

    • File Format Conversion

  • 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

    • The Current Buffer

    • Buffer Names

    • Buffer File Name

    • Buffer Modification

    • Buffer Modification Time

    • Read-Only Buffers

    • The Buffer List

    • Creating Buffers

    • Killing Buffers

    • Indirect Buffers

    • The Buffer Gap

  • Windows

    • Basic Concepts of Emacs Windows

    • Splitting Windows

    • Deleting Windows

    • Selecting Windows

    • Cyclic Ordering of Windows

    • Buffers and Windows

    • Displaying Buffers in Windows

    • Choosing a Window for Display

    • Windows and Point

    • The Window Start Position

    • Textual Scrolling

    • Vertical Fractional Scrolling

    • Horizontal Scrolling

    • The Size of a Window

    • Changing the Size of a Window

    • Coordinates and Windows

    • The Window Tree

    • Window Configurations

    • Hooks for Window Scrolling and Changes

  • Frames

    • Creating Frames

    • Multiple Displays

    • Frame Parameters

      • Access to Frame Parameters

      • Initial Frame Parameters

      • Window Frame Parameters

        • Basic Parameters

        • Position Parameters

        • Size Parameters

        • Layout Parameters

        • Buffer Parameters

        • Window Management Parameters

        • Cursor Parameters

        • Color Parameters

      • Frame Size And Position

      • Geometry

    • Frame Titles

    • 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

    • Dialog Boxes

    • Pointer Shape

    • Window System Selections

    • Drag and Drop

    • Color Names

    • Text Terminal Colors

    • X Resources

    • Display Feature Testing

  • Positions

    • Point

    • Motion

      • Motion by Characters

      • Motion by Words

      • Motion to an End of the Buffer

      • Motion by Text Lines

      • Motion by Screen Lines

      • Moving over Balanced Expressions

      • Skipping Characters

    • Excursions

    • Narrowing

  • Markers

    • Overview of Markers

    • Predicates on Markers

    • Functions that Create Markers

    • Information from Markers

    • Marker Insertion Types

    • Moving Marker Positions

    • The Mark

    • The Region

  • Text

    • Examining Text Near Point

    • Examining Buffer Contents

    • Comparing Text

    • Inserting Text

    • User-Level Insertion Commands

    • Deleting Text

    • User-Level Deletion Commands

    • The Kill Ring

      • Kill Ring Concepts

      • Functions for Killing

      • Yanking

      • Functions for Yanking

      • Low-Level Kill Ring

      • Internals of the Kill Ring

    • Undo

    • Maintaining Undo Lists

    • Filling

    • Margins for Filling

    • Adaptive Fill Mode

    • Auto Filling

    • Sorting Text

    • Counting Columns

    • Indentation

      • Indentation Primitives

      • Indentation Controlled by Major Mode

      • Indenting an Entire Region

      • Indentation Relative to Previous Lines

      • Adjustable ``Tab Stops''

      • Indentation-Based Motion Commands

    • Case Changes

    • Text Properties

      • Examining Text Properties

      • Changing Text Properties

      • Text Property Search Functions

      • Properties with Special Meanings

      • Formatted Text Properties

      • Stickiness of Text Properties

      • Saving Text Properties in Files

      • Lazy Computation of Text Properties

      • Defining Clickable Text

      • Links and Mouse-1

      • Defining and Using Fields

      • Why Text Properties are not Intervals

    • Substituting for a Character Code

    • Registers

    • Transposition of Text

    • Base 64 Encoding

    • MD5 Checksum

    • Atomic Change Groups

    • Change Hooks

  • Non-ASCII Characters

    • Text Representations

    • Converting Text Representations

    • Selecting a Representation

    • Character Codes

    • Character Sets

    • Characters and Bytes

    • Splitting Characters

    • Scanning for Character Sets

    • Translation of Characters

    • Coding Systems

      • Basic Concepts of Coding Systems

      • Encoding and I/O

      • Coding Systems in Lisp

      • User-Chosen Coding Systems

      • Default Coding Systems

      • Specifying a Coding System for One Operation

      • Explicit Encoding and Decoding

      • Terminal I/O Encoding

      • MS-DOS File Types

    • Input Methods

    • Locales

  • Searching and Matching

    • Searching for Strings

    • Searching and Case

    • Regular Expressions

      • Syntax of Regular Expressions

        • Special Characters in Regular Expressions

        • Character Classes

        • Backslash Constructs in Regular Expressions

      • Complex Regexp Example

      • Regular Expression Functions

    • Regular Expression Searching

    • POSIX Regular Expression Searching

    • The Match Data

      • Replacing the Text that Matched

      • Simple Match Data Access

      • Accessing the Entire Match Data

      • Saving and Restoring the Match Data

    • Search and Replace

    • Standard Regular Expressions Used in Editing

  • Syntax Tables

    • Syntax Table Concepts

    • Syntax Descriptors

      • Table of Syntax Classes

      • Syntax Flags

    • Syntax Table Functions

    • Syntax Properties

    • Motion and Syntax

    • Parsing Expressions

      • Motion Commands Based on Parsing

      • Finding the Parse State for a Position

      • Parser State

      • Low-Level Parsing

      • Parameters to Control Parsing

    • Some Standard Syntax Tables

    • Syntax Table Internals

    • Categories

  • 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

    • Shell Arguments

    • 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

      • Decoding Process Output

      • Accepting Output from Processes

    • Sentinels: Detecting Process Status Changes

    • Querying Before Exit

    • Transaction Queues

    • Network Connections

    • Network Servers

    • Datagrams

    • Low-Level Network Access

      • make-network-process

      • Network Options

      • Testing Availability of Network Features

    • Misc Network Facilities

    • Packing and Unpacking Byte Arrays

      • Describing Data Layout

      • Functions to Unpack and Pack Bytes

      • Examples of Byte Unpacking and Packing

  • Emacs Display

    • Refreshing the Screen

    • Forcing Redisplay

    • Truncation

    • The Echo Area

      • Displaying Messages in the Echo Area

      • Reporting Operation Progress

      • Logging Messages in *Messages*

      • Echo Area Customization

    • Reporting Warnings

      • Warning Basics

      • Warning Variables

      • Warning Options

    • Invisible Text

    • Selective Display

    • Temporary Displays

    • Overlays

      • Managing Overlays

      • Overlay Properties

      • Searching for Overlays

    • Width

    • Line Height

    • Faces

      • Defining Faces

      • Face Attributes

      • Face Attribute Functions

      • Displaying Faces

      • Font Selection

      • Functions for Working with Faces

      • Automatic Face Assignment

      • Looking Up Fonts

      • Fontsets

    • Fringes

      • Fringe Size and Position

      • Fringe Indicators

      • Fringe Cursors

      • Fringe Bitmaps

      • Customizing Fringe Bitmaps

      • The Overlay Arrow

    • Scroll Bars

    • The display Property

      • Specified Spaces

      • Pixel Specification for Spaces

      • Other Display Specifications

      • Displaying in the Margins

    • Images

      • Image Descriptors

      • XBM Images

      • XPM Images

      • GIF Images

      • PostScript Images

      • Other Image Types

      • Defining Images

      • Showing Images

      • Image Cache

    • Buttons

      • Button Properties

      • Button Types

      • Making Buttons

      • Manipulating Buttons

      • Button Buffer Commands

    • Abstract Display

      • Abstract Display Functions

      • Abstract Display Example

    • Blinking Parentheses

    • Usual Display Conventions

    • Display Tables

      • Display Table Format

      • Active Display Table

      • Glyphs

    • Beeping

    • Window Systems

  • Operating System Interface

    • Starting Up Emacs

      • Summary: Sequence of Actions at Startup

      • 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

    • Time Conversion

    • Parsing and Formatting Times

    • Processor Run time

    • Time Calculations

    • Timers for Delayed Execution

    • Idle Timers

    • Terminal Input

      • Input Modes

      • Recording Input

    • Terminal Output

    • Sound Output

    • Operating on X11 Keysyms

    • Batch Mode

    • Session Management

  • Emacs 21 Antinews

    • Old Lisp Features in Emacs 21

  • GNU Free Documentation License

    • ADDENDUM: How to use this License for your documents

  • GNU General Public License

    • Preamble

    • Terms and Conditions for Copying, Distribution and Modification

    • How to Apply These Terms to Your New Programs

  • Tips and Conventions

    • Emacs Lisp Coding Conventions

    • Key Binding Conventions

    • Emacs Programming Tips

    • Tips for Making Compiled Code Fast

    • Tips for Avoiding Compiler Warnings

    • Tips for Documentation Strings

    • Tips on Writing Comments

    • Conventional Headers for Emacs Libraries

  • GNU Emacs Internals

    • Building Emacs

    • Pure Storage

    • Garbage Collection

    • Memory Usage

    • Writing Emacs Primitives

    • Object Internals

      • Buffer Internals

      • Window Internals

      • Process Internals

  • Standard Errors

  • Buffer-Local Variables

  • Standard Keymaps

  • Standard Hooks

  • Index

Nội dung

GNU Emacs Lisp Reference Manual For Emacs Version 22.1 Revision 2.9, April 2007 by Bil Lewis, Dan LaLiberte, Richard Stallman and the GNU Manual Group This is edition 2.9 of the GNU Emacs Lisp Reference Manual, corresponding to Emacs version 22.1. Copyright c  1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being “GNU General Public License,” with the Front-Cover texts being “A GNU Manual,” and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled “GNU Free Documentation License.” (a) The FSF’s Back-Cover Text is: “You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.” Published by the Free Software Foundation 51 Franklin St, Fifth Floor Boston, MA 02110-1301 USA ISBN 1-882114-74-4 Cover art by Etienne Suvasa. i Short Contents 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 Lisp Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 4 Strings and Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 5 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 6 Sequences, Arrays, and Vectors . . . . . . . . . . . . . . . . . . . . . . . . . 87 7 Hash Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 8 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 9 Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 10 Control Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 11 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 12 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 13 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 14 Writing Customization Definitions . . . . . . . . . . . . . . . . . . . . . . 185 15 Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 16 Byte Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 17 Advising Emacs Lisp Functions . . . . . . . . . . . . . . . . . . . . . . . . 226 18 Debugging Lisp Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 19 Reading and Printing Lisp Objects . . . . . . . . . . . . . . . . . . . . . 268 20 Minibuffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 21 Command Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 22 Keymaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 23 Major and Minor Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 24 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 25 Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 26 Backups and Auto-Saving . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 27 Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 28 Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 29 Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529 30 Positions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559 31 Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572 32 Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581 33 Non-ASCII Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640 34 Searching and Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661 35 Syntax Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684 ii 36 Abbrevs and Abbrev Expansion. . . . . . . . . . . . . . . . . . . . . . . . 699 37 Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705 38 Emacs Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739 39 Operating System Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . 812 A Emacs 21 Antinews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838 B GNU Free Documentation License . . . . . . . . . . . . . . . . . . . . . . 843 C GNU General Public License . . . . . . . . . . . . . . . . . . . . . . . . . . 850 D Tips and Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 856 E GNU Emacs Internals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 870 F Standard Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 891 G Buffer-Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 895 H Standard Keymaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 899 I Standard Hooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 903 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 908 iii Table of Contents 1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Caveats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Lisp History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3.1 Some Terms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3.2 nil and t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3.3 Evaluation Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3.4 Printing Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3.5 Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.6 Buffer Text Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.7 Format of Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.7.1 A Sample Function Description . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.7.2 A Sample Variable Description. . . . . . . . . . . . . . . . . . . . . . . . 6 1.4 Version Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.5 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2 Lisp Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.1 Printed Representation and Read Syntax . . . . . . . . . . . . . . . . . . . . . . . 8 2.2 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.3 Programming Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.3.1 Integer Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.3.2 Floating Point Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.3.3 Character Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.3.3.1 Basic Char Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.3.3.2 General Escape Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.3.3.3 Control-Character Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.3.3.4 Meta-Character Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.3.3.5 Other Character Modifier Bits . . . . . . . . . . . . . . . . . . . . . . . 13 2.3.4 Symbol Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.3.5 Sequence Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.3.6 Cons Cell and List Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.3.6.1 Drawing Lists as Box Diagrams . . . . . . . . . . . . . . . . . . . . . . 15 2.3.6.2 Dotted Pair Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.3.6.3 Association List Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.3.7 Array Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.3.8 String Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.3.8.1 Syntax for Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.3.8.2 Non-ASCII Characters in Strings . . . . . . . . . . . . . . . . . . . . . 19 2.3.8.3 Nonprinting Characters in Strings . . . . . . . . . . . . . . . . . . . 19 2.3.8.4 Text Properties in Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.3.9 Vector Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.3.10 Char-Table Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.3.11 Bool-Vector Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 iv 2.3.12 Hash Table Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.3.13 Function Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.3.14 Macro Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.3.15 Primitive Function Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.3.16 Byte-Code Function Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.3.17 Autoload Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.4 Editing Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.4.1 Buffer Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.4.2 Marker Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.4.3 Window Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.4.4 Frame Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.4.5 Window Configuration Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.4.6 Frame Configuration Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.4.7 Process Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.4.8 Stream Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.4.9 Keymap Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.4.10 Overlay Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.5 Read Syntax for Circular Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2.6 Type Predicates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 2.7 Equality Predicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3.1 Integer Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3.2 Floating Point Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 3.3 Type Predicates for Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 3.4 Comparison of Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 3.5 Numeric Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 3.6 Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 3.7 Rounding Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.8 Bitwise Operations on Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 3.9 Standard Mathematical Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 3.10 Random Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 4 Strings and Characters. . . . . . . . . . . . . . . . . . . . . . . . 47 4.1 String and Character Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 4.2 The Predicates for Strings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4.3 Creating Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4.4 Modifying Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 4.5 Comparison of Characters and Strings . . . . . . . . . . . . . . . . . . . . . . . . . 52 4.6 Conversion of Characters and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . 54 4.7 Formatting Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 4.8 Case Conversion in Lisp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 4.9 The Case Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 v 5 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.1 Lists and Cons Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.2 Predicates on Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.3 Accessing Elements of Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.4 Building Cons Cells and Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 5.5 Modifying List Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 5.6 Modifying Existing List Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.6.1 Altering List Elements with setcar . . . . . . . . . . . . . . . . . . . . . . 73 5.6.2 Altering the CDR of a List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 5.6.3 Functions that Rearrange Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 5.7 Using Lists as Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.8 Association Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.9 Managing a Fixed-Size Ring of Objects . . . . . . . . . . . . . . . . . . . . . . . . 84 6 Sequences, Arrays, and Vectors . . . . . . . . . . . . . . 87 6.1 Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 6.2 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 6.3 Functions that Operate on Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 6.4 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 6.5 Functions for Vectors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 6.6 Char-Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 6.7 Bool-vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 7 Hash Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 7.1 Creating Hash Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 7.2 Hash Table Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 7.3 Defining Hash Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 7.4 Other Hash Table Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 8 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 8.1 Symbol Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 8.2 Defining Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 8.3 Creating and Interning Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 8.4 Property Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 8.4.1 Property Lists and Association Lists. . . . . . . . . . . . . . . . . . . . . 107 8.4.2 Property List Functions for Symbols . . . . . . . . . . . . . . . . . . . . . 108 8.4.3 Property Lists Outside Symbols . . . . . . . . . . . . . . . . . . . . . . . . . 108 vi 9 Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 9.1 Kinds of Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 9.1.1 Self-Evaluating Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 9.1.2 Symbol Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 9.1.3 Classification of List Forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 9.1.4 Symbol Function Indirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 9.1.5 Evaluation of Function Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 9.1.6 Lisp Macro Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 9.1.7 Special Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 9.1.8 Autoloading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 9.2 Quoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 9.3 Eval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 10 Control Structures . . . . . . . . . . . . . . . . . . . . . . . . . . 119 10.1 Sequencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 10.2 Conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 10.3 Constructs for Combining Conditions . . . . . . . . . . . . . . . . . . . . . . . 122 10.4 Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 10.5 Nonlocal Exits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 10.5.1 Explicit Nonlocal Exits: catch and throw . . . . . . . . . . . . . . 125 10.5.2 Examples of catch and throw . . . . . . . . . . . . . . . . . . . . . . . . . . 126 10.5.3 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 10.5.3.1 How to Signal an Error. . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 10.5.3.2 How Emacs Processes Errors . . . . . . . . . . . . . . . . . . . . . . 129 10.5.3.3 Writing Code to Handle Errors . . . . . . . . . . . . . . . . . . . . 129 10.5.3.4 Error Symbols and Condition Names . . . . . . . . . . . . . . 132 10.5.4 Cleaning Up from Nonlocal Exits. . . . . . . . . . . . . . . . . . . . . . . 133 11 Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 11.1 Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 11.2 Variables that Never Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 11.3 Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 11.4 When a Variable is “Void” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 11.5 Defining Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 11.6 Tips for Defining Variables Robustly . . . . . . . . . . . . . . . . . . . . . . . . 141 11.7 Accessing Variable Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 11.8 How to Alter a Variable Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 11.9 Scoping Rules for Variable Bindings . . . . . . . . . . . . . . . . . . . . . . . . . 145 11.9.1 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 11.9.2 Extent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 11.9.3 Implementation of Dynamic Scoping . . . . . . . . . . . . . . . . . . . 146 11.9.4 Proper Use of Dynamic Scoping . . . . . . . . . . . . . . . . . . . . . . . . 147 11.10 Buffer-Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 11.10.1 Introduction to Buffer-Local Variables. . . . . . . . . . . . . . . . . 148 11.10.2 Creating and Deleting Buffer-Local Bindings . . . . . . . . . . 149 11.10.3 The Default Value of a Buffer-Local Variable . . . . . . . . . . 152 11.11 Frame-Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 vii 11.12 Possible Future Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 11.13 File Local Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 11.14 Variable Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 11.15 Variables with Restricted Values . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 12 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 12.1 What Is a Function? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 12.2 Lambda Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 12.2.1 Components of a Lambda Expression . . . . . . . . . . . . . . . . . . . 162 12.2.2 A Simple Lambda-Expression Example . . . . . . . . . . . . . . . . . 162 12.2.3 Other Features of Argument Lists . . . . . . . . . . . . . . . . . . . . . . 163 12.2.4 Documentation Strings of Functions . . . . . . . . . . . . . . . . . . . . 164 12.3 Naming a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 12.4 Defining Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 12.5 Calling Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 12.6 Mapping Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 12.7 Anonymous Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 12.8 Accessing Function Cell Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 12.9 Declaring Functions Obsolete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 12.10 Inline Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 12.11 Determining whether a Function is Safe to Call . . . . . . . . . . . . 174 12.12 Other Topics Related to Functions . . . . . . . . . . . . . . . . . . . . . . . . . 174 13 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 13.1 A Simple Example of a Macro. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 13.2 Expansion of a Macro Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 13.3 Macros and Byte Compilation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 13.4 Defining Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 13.5 Backquote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 13.6 Common Problems Using Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 13.6.1 Wrong Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 13.6.2 Evaluating Macro Arguments Repeatedly. . . . . . . . . . . . . . . 180 13.6.3 Local Variables in Macro Expansions . . . . . . . . . . . . . . . . . . . 182 13.6.4 Evaluating Macro Arguments in Expansion . . . . . . . . . . . . . 182 13.6.5 How Many Times is the Macro Expanded? . . . . . . . . . . . . . 183 13.7 Indenting Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 14 Writing Customization Definitions . . . . . . . . 185 14.1 Common Item Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 14.2 Defining Customization Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 14.3 Defining Customization Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 14.4 Customization Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 14.4.1 Simple Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 14.4.2 Composite Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 14.4.3 Splicing into Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 14.4.4 Type Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 14.4.5 Defining New Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 viii 15 Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 15.1 How Programs Do Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 15.2 Load Suffixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 15.3 Library Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 15.4 Loading Non-ASCII Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 15.5 Autoload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 15.6 Repeated Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 15.7 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 15.8 Which File Defined a Certain Symbol . . . . . . . . . . . . . . . . . . . . . . . 211 15.9 Unloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 15.10 Hooks for Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 16 Byte Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 16.1 Performance of Byte-Compiled Code . . . . . . . . . . . . . . . . . . . . . . . . 214 16.2 The Compilation Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 16.3 Documentation Strings and Compilation . . . . . . . . . . . . . . . . . . . . 217 16.4 Dynamic Loading of Individual Functions . . . . . . . . . . . . . . . . . . . 218 16.5 Evaluation During Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 16.6 Compiler Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 16.7 Byte-Code Function Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 16.8 Disassembled Byte-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 17 Advising Emacs Lisp Functions. . . . . . . . . . . . 226 17.1 A Simple Advice Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 17.2 Defining Advice. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 17.3 Around-Advice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 17.4 Computed Advice. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 17.5 Activation of Advice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 17.6 Enabling and Disabling Advice. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 17.7 Preactivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 17.8 Argument Access in Advice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 17.9 Advising Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 17.10 The Combined Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 18 Debugging Lisp Programs . . . . . . . . . . . . . . . . . . 237 18.1 The Lisp Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 18.1.1 Entering the Debugger on an Error . . . . . . . . . . . . . . . . . . . . . 237 18.1.2 Debugging Infinite Loops. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 18.1.3 Entering the Debugger on a Function Call . . . . . . . . . . . . . . 239 18.1.4 Explicit Entry to the Debugger . . . . . . . . . . . . . . . . . . . . . . . . . 240 18.1.5 Using the Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 18.1.6 Debugger Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 18.1.7 Invoking the Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 18.1.8 Internals of the Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 18.2 Edebug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 18.2.1 Using Edebug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 18.2.2 Instrumenting for Edebug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 [...]... manual presumes considerable familiarity with the use of Emacs for editing; see The GNU Emacs Manual for this basic information Generally speaking, the earlier chapters describe features of Emacs Lisp that have counterparts in many programming languages, and later chapters describe features that are peculiar to Emacs Lisp or relate specifically to editing This is edition 2.9 of the GNU Emacs Lisp Reference. .. displays, subprocesses, and so on Emacs Lisp is closely integrated with the editing facilities; thus, editing commands are functions that can also conveniently be called from Lisp programs, and parameters for customization are ordinary Lisp variables This manual attempts to be a full description of Emacs Lisp For a beginner’s introduction to Emacs Lisp, see An Introduction to Emacs Lisp Programming, by Bob... called Common Lisp In the meantime, Gerry Sussman and Guy Steele at MIT developed a simplified but very powerful dialect of Lisp, called Scheme GNU Emacs Lisp is largely inspired by Maclisp, and a little by Common Lisp If you know Common Lisp, you will notice many similarities However, many features of Common Lisp have been omitted or simplified in order to reduce the memory requirements of GNU Emacs Sometimes... so drastic that a Common Lisp user might be very confused We will occasionally point out how GNU Emacs Lisp differs from Common Lisp If you don’t know Common Lisp, don’t worry about it; this manual is self-contained A certain amount of Common Lisp emulation is available via the ‘cl’ library See Info file ‘cl’, node ‘Top’ Emacs Lisp is not at all influenced by Scheme; but the GNU project has an implementation... Introduction Most of the GNU Emacs text editor is written in the programming language called Emacs Lisp You can write new code in Emacs Lisp and install it as an extension to the editor However, Emacs Lisp is more than a mere “extension language”; it is a full computer programming language in its own right You can use it as you would any other programming language Because Emacs Lisp is designed for use... bug -lisp- manual @gnu. org We let mail to this list accumulate unread until someone decides to apply the corrections Months, and sometimes years, go by between updates So please attach no significance to the lack of a reply—your mail will be acted on in due time If you want to contact the Emacs maintainers more quickly, send mail to bug -gnu- emacs @gnu. org Chapter 1: Introduction 2 1.2 Lisp History Lisp. .. all new GNU software that calls for extensibility 1.3 Conventions This section explains the notational conventions that are used in this manual You may want to skip this section and refer back to it later 1.3.1 Some Terms Throughout this manual, the phrases “the Lisp reader” and “the Lisp printer” refer to those routines in Lisp that convert textual representations of Lisp objects into actual Lisp objects,... These facilities provide information about which version of Emacs is in use emacs- version &optional here [Command] This function returns a string describing the version of Emacs that is running It is useful to include this string in bug reports (emacs- version) ⇒ "GNU Emacs 20.3.5 (i486-pc-linux-gnulibc1, X toolkit) of Sat Feb 14 1998 on psilocin .gnu. org" If here is non-nil, it inserts the text in the buffer... exist in Emacs Lisp A Lisp variable can have any type of value, and it remembers whatever value you store in it, type and all (Actually, a small number of Emacs Lisp variables can only take on values of a certain type See Section 11.15 [Variables with Restricted Values], page 158.) This chapter describes the purpose, printed representation, and read syntax of each of the standard types in GNU Emacs Lisp. .. comments 2.3 Programming Types There are two general categories of types in Emacs Lisp: those having to do with Lisp programming, and those having to do with editing The former exist in many Lisp implementations, in one form or another The latter are unique to Emacs Lisp 2.3.1 Integer Type The range of values for integers in Emacs Lisp is −268435456 to 268435455 (29 bits; i.e., −228 to 228 − 1) on most

Ngày đăng: 04/04/2014, 21:27