You are previewing Writing GNU Emacs Extensions.
O'Reilly logo
Writing GNU Emacs Extensions

Book Description

This book introduces Emacs Lisp and tells you how to make the editor do whatever you want, whether it's altering the way text scrolls or inventing a whole new "major mode." Topics progress from simple to complex, from lists, symbols, and keyboard commands to syntax tables, macro templates, and error recovery.

Table of Contents

  1. Writing GNU Emacs Extensions
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Preface
      1. What Is Emacs?
      2. Conventions Used in This Book
        1. Typographic Conventions
        2. Emacs Commands
        3. Examples
      3. Organization of This Book
      4. Obtaining the Example Programs
        1. FTP
      5. Acknowledgments
    4. 1. Customizing Emacs
      1. Backspace and Delete
      2. Lisp
      3. Keys and Strings
        1. The META Key
        2. Binding Keystrokes to Commands
        3. Denoting Keys in Strings
      4. To What Is C-h Bound?
      5. To What Should C-h Be Bound?
      6. Evaluating Lisp Expressions
      7. Apropos
    5. 2. Simple New Commands
      1. Traversing Windows
        1. Defining other-window-backward
        2. Parameterizing other-window-backward
        3. Making the Argument Optional
        4. Condensing the Code
        5. Logical Expressions
        6. The Best other-window-backward
      2. Line-at-a-Time Scrolling
      3. Other Cursor and Text Motion Commands
      4. Clobbering Symbolic Links
        1. Hooks
        2. Anonymous Functions
        3. Handling the Symlink
      5. Advised Buffer Switching
      6. Addendum: Raw Prefix Argument
    6. 3. Cooperating Commands
      1. The Symptom
      2. A Cure
        1. Declaring Variables
        2. Saving and Restoring Point
        3. Window Appearance
        4. Detecting Errors
      3. Generalizing the Solution
        1. Using this-command
        2. Symbol Properties
        3. Markers
        4. Addendum: Efficiency Consideration
    7. 4. Searching and Modifying Buffers
      1. Inserting the Current Time
        1. User Options and Docstrings
        2. More Asterisk Magic
      2. Writestamps
        1. Updating Writestamps
        2. Generalizing Writestamps
        3. Regular Expressions
        4. Regexp Quoting
        5. Limited Searching
        6. More Regexp Power
      3. Modifystamps
        1. Simple Approach #1
        2. Simple Approach #2
        3. Clever Approach
        4. A Subtle Bug
    8. 5. Lisp Files
      1. Creating a Lisp File
      2. Loading the File
        1. Finding Lisp Files
        2. Interactive Loading
        3. Programmatic Loading
          1. Explicit loading
          2. Conditional loading
          3. Autoloading
      3. Compiling the File
      4. eval-after-load
      5. Local Variables Lists
      6. Addendum: Security Consideration
    9. 6. Lists
      1. The Simple View of Lists
      2. List Details
      3. Recursive List Functions
      4. Iterative List Functions
      5. Other Useful List Functions
      6. Destructive List Operations
      7. Circular Lists?!
    10. 7. Minor Mode
      1. Paragraph Filling
      2. Modes
      3. Defining a Minor Mode
      4. Mode Meat
        1. Naïve First Try
        2. Constraining refill
        3. Minor Adjustments
        4. Eliminating Unwanted Filling
        5. Trailing Whitespace
    11. 8. Evaluation and Error Recovery
      1. limited-save-excursion
      2. eval
      3. Macro Functions
      4. Backquote and Unquote
      5. Return Value
      6. Failing Gracefully
      7. Point Marker
    12. 9. A Major Mode
      1. My Quips File
      2. Major Mode Skeleton
      3. Changing the Definition of a Paragraph
      4. Quip Commands
      5. Keymaps
      6. Narrowing
      7. Derived Modes
    13. 10. A Comprehensive Example
      1. New York Times Rules
      2. Data Representation
        1. Vectors
        2. Matrix Package
        3. Crossword Variant of Matrix
        4. Using Cons Cells
        5. One-Letter Words
      3. User Interface
        1. Display
        2. Cursor Positioning
        3. Updating the Display
        4. User Commands
          1. Grid-changing commands
          2. Navigation
      4. Setting Up the Mode
        1. Keybindings
        2. Mouse Commands
        3. Menu Commands
      5. Tracking Unauthorized Changes
      6. Parsing the Buffer
      7. Word Finder
        1. First Try
        2. Second Try
        3. Asynchronous egrep
        4. Choosing Words
        5. Ambiguous Alignment
      8. Last Word
    14. A. Conclusion
    15. B. Lisp Quick Reference
      1. Basics
      2. Data Types
        1. Numbers
        2. Characters
        3. Strings
        4. Symbols
        5. Lists
        6. Vectors
        7. Sequences and Arrays
      3. Control Structures
        1. Variables
        2. Sequencing
        3. Conditionals
        4. Looping
        5. Function Call
        6. Literal Data
      4. Code Objects
        1. Functions
        2. Macro Functions
    16. C. Debugging and Profiling
      1. Evaluation
      2. The Debugger
      3. Edebug
      4. The Profiler
    17. D. Sharing Your Code
      1. Preparing Source Files
      2. Documentation
      3. Copyright
      4. Posting
    18. E. Obtaining and Building Emacs
      1. Availability of Packages
      2. Unpacking, Building, and Installing Emacs
        1. Unpacking
        2. Building and Installing
    19. Index
    20. About the Author
    21. Colophon
    22. SPECIAL OFFER: Upgrade this ebook with O’Reilly