Chapter 24. Editing Programs

Table of Contents
24.1. Major Modes for Programming Languages
24.2. Lists and Sexps
24.3. List And Sexp Commands
24.4. Defuns
24.5. Indentation for Programs
24.5.1. Basic Program Indentation Commands
24.5.2. Indenting Several Lines
24.5.3. Customizing Lisp Indentation
24.5.4. Commands for C Indentation
24.5.5. Customizing C Indentation
24.6. Automatic Display Of Matching Parentheses
24.7. Manipulating Comments
24.7.1. Comment Commands
24.7.2. Multiple Lines of Comments
24.7.3. Options Controlling Comments
24.8. Editing Without Unbalanced Parentheses
24.9. Completion for Symbol Names
24.10. Which Function Mode
24.11. Hideshow minor mode
24.12. Glasses minor mode
24.13. Documentation Commands
24.14. Change Logs
24.15. AUTHORS files
24.16. Tags Tables
24.16.1. Source File Tag Syntax
24.16.2. Creating Tags Tables
24.16.3. Etags Regexps
24.16.4. Selecting a Tags Table
24.16.5. Finding a Tag
24.16.6. Searching and Replacing with Tags Tables
24.16.7. Tags Table Inquiries
24.17. Imenu
24.18. Merging Files with Emerge
24.18.1. Overview of Emerge
24.18.2. Submodes of Emerge
24.18.3. State of a Difference
24.18.4. Merge Commands
24.18.5. Exiting Emerge
24.18.6. Combining the Two Versions
24.18.7. Fine Points of Emerge
24.19. C and Related Modes
24.19.1. C Mode Motion Commands
24.19.2. Electric C Characters
24.19.3. Hungry Delete Feature in C
24.19.4. Other Commands for C Mode
24.19.5. Comments in C Modes
24.20. Fortran Mode
24.20.1. Motion Commands
24.20.2. Fortran Indentation
24.20.3. Fortran Comments
24.20.4. Fortran Auto Fill Mode
24.20.5. Checking Columns in Fortran
24.20.6. Fortran Keyword Abbrevs
24.21. Asm Mode

Emacs has many commands designed to understand the syntax of programming languages such as Lisp and C. These commands can

The commands for words, sentences and paragraphs are very useful in editing code even though their canonical application is for editing human language text. Most symbols contain words (Section 23.1); sentences can be found in strings and comments (Section 23.2). Paragraphs per se don't exist in code, but the paragraph commands are useful anyway, because programming language major modes define paragraphs to begin and end at blank lines (Section 23.3). Judicious use of blank lines to make the program clearer will also provide useful chunks of text for the paragraph commands to work on.

The selective display feature is useful for looking at the overall structure of a function (Section 13.9). This feature hides the lines that are indented more than a specified amount. Programming modes often support Outline minor mode (Section 23.8). The Foldout package provides folding-editor features ().

The "automatic typing" features may be useful for writing programs. .