annotate man/xemacs/programs.texi @ 359:8e84bee8ddd0 r21-1-9

Import from CVS: tag r21-1-9
author cvs
date Mon, 13 Aug 2007 10:57:55 +0200
parents 43dd3413c7c7
children 972bbb6d6ca2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 @node Programs, Running, Text, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 @chapter Editing Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 @cindex Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 @cindex C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 Emacs has many commands designed to understand the syntax of programming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 languages such as Lisp and C. These commands can:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 Move over or kill balanced expressions or @dfn{sexps} (@pxref{Lists}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 Move over or mark top-level balanced expressions (@dfn{defuns}, in Lisp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 functions, in C).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 Show how parentheses balance (@pxref{Matching}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Insert, kill, or align comments (@pxref{Comments}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 Follow the usual indentation conventions of the language
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 (@pxref{Grinding}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 The commands available for words, sentences, and paragraphs are useful in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 editing code even though their canonical application is for editing human
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 language text. Most symbols contain words (@pxref{Words}); sentences can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 be found in strings and comments (@pxref{Sentences}). Paragraphs per se
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 are not present in code, but the paragraph commands are useful anyway,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 because Lisp mode and C mode define paragraphs to begin and end at blank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 lines (@pxref{Paragraphs}). Judicious use of blank lines to make the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 program clearer also provides interesting chunks of text for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 paragraph commands to work on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 The selective display feature is useful for looking at the overall
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 structure of a function (@pxref{Selective Display}). This feature causes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 only the lines that are indented less than a specified amount to appear
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 on the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 * Program Modes:: Major modes for editing programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 * Lists:: Expressions with balanced parentheses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 There are editing commands to operate on them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 * Defuns:: Each program is made up of separate functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 There are editing commands to operate on them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 * Grinding:: Adjusting indentation to show the nesting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 * Matching:: Insertion of a close-delimiter flashes matching open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 * Comments:: Inserting, illing and aligning comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 * Balanced Editing:: Inserting two matching parentheses at once, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 * Lisp Completion:: Completion on symbol names in Lisp code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 * Documentation:: Getting documentation of functions you plan to call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 * Change Log:: Maintaining a change history for your program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 * Tags:: Go direct to any function in your program in one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 command. Tags remembers which file it is in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 * Fortran:: Fortran mode and its special features.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 * Asm Mode:: Asm mode and its special features.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 @node Program Modes, Lists, Programs, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 @section Major Modes for Programming Languages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 @cindex Lisp mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 @cindex C mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 @cindex Scheme mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 Emacs has several major modes for the programming languages Lisp, Scheme (a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 variant of Lisp), C, Fortran, and Muddle. Ideally, a major mode should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 implemented for each programming language you might want to edit with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Emacs; but often the mode for one language can serve for other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 syntactically similar languages. The language modes that exist are those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 that someone decided to take the trouble to write.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 There are several variants of Lisp mode, which differ in the way they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 interface to Lisp execution. @xref{Lisp Modes}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 Each of the programming language modes defines the @key{TAB} key to run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 an indentation function that knows the indentation conventions of that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 language and updates the current line's indentation accordingly. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 example, in C mode @key{TAB} is bound to @code{c-indent-line}. @key{LFD}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 is normally defined to do @key{RET} followed by @key{TAB}; thus it, too,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 indents in a mode-specific fashion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 @kindex DEL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 @findex backward-delete-char-untabify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 In most programming languages, indentation is likely to vary from line to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 line. So the major modes for those languages rebind @key{DEL} to treat a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 tab as if it were the equivalent number of spaces (using the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 @code{backward-delete-char-untabify}). This makes it possible to rub out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 indentation one column at a time without worrying whether it is made up of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 spaces or tabs. In these modes, use @kbd{C-b C-d} to delete a tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 character before point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 Programming language modes define paragraphs to be separated only by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 blank lines, so that the paragraph commands remain useful. Auto Fill mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 if enabled in a programming language major mode, indents the new lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 which it creates.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 @cindex mode hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 @vindex c-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 @vindex lisp-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 @vindex emacs-lisp-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 @vindex lisp-interaction-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 @vindex scheme-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 @vindex muddle-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 Turning on a major mode calls a user-supplied function called the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 @dfn{mode hook}, which is the value of a Lisp variable. For example,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 turning on C mode calls the value of the variable @code{c-mode-hook} if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 that value exists and is non-@code{nil}. Mode hook variables for other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 programming language modes include @code{lisp-mode-hook},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 @code{emacs-lisp-mode-hook}, @code{lisp-interaction-mode-hook},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 @code{scheme-mode-hook}, and @code{muddle-mode-hook}. The mode hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 function receives no arguments.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 @node Lists, Defuns, Program Modes, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 @section Lists and Sexps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 @cindex Control-Meta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 By convention, Emacs keys for dealing with balanced expressions are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 usually @kbd{Control-Meta-} characters. They tend to be analogous in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 function to their @kbd{Control-} and @kbd{Meta-} equivalents. These commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 are usually thought of as pertaining to expressions in programming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 languages, but can be useful with any language in which some sort of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 parentheses exist (including English).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 @cindex list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 @cindex sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 @cindex expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 The commands fall into two classes. Some commands deal only with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 @dfn{lists} (parenthetical groupings). They see nothing except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 parentheses, brackets, braces (depending on what must balance in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 language you are working with), and escape characters that might be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 to quote those.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 The other commands deal with expressions or @dfn{sexps}. The word `sexp'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 is derived from @dfn{s-expression}, the term for a symbolic expression in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Lisp. In Emacs, the notion of `sexp' is not limited to Lisp. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 refers to an expression in the language your program is written in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 Each programming language has its own major mode, which customizes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 syntax tables so that expressions in that language count as sexps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 Sexps typically include symbols, numbers, and string constants, as well
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 as anything contained in parentheses, brackets, or braces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 In languages that use prefix and infix operators, such as C, it is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 possible for all expressions to be sexps. For example, C mode does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 recognize @samp{foo + bar} as an sexp, even though it @i{is} a C expression;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 it recognizes @samp{foo} as one sexp and @samp{bar} as another, with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 @samp{+} as punctuation between them. This is a fundamental ambiguity:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 both @samp{foo + bar} and @samp{foo} are legitimate choices for the sexp to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 move over if point is at the @samp{f}. Note that @samp{(foo + bar)} is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 sexp in C mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 Some languages have obscure forms of syntax for expressions that nobody
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 has bothered to make Emacs understand properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 @c doublewidecommands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 @item C-M-f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 Move forward over an sexp (@code{forward-sexp}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 @item C-M-b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 Move backward over an sexp (@code{backward-sexp}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 @item C-M-k
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 Kill sexp forward (@code{kill-sexp}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 @item C-M-u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 Move up and backward in list structure (@code{backward-up-list}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 @item C-M-d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 Move down and forward in list structure (@code{down-list}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 @item C-M-n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 Move forward over a list (@code{forward-list}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 @item C-M-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 Move backward over a list (@code{backward-list}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 @item C-M-t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 Transpose expressions (@code{transpose-sexps}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 @item C-M-@@
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 Put mark after following expression (@code{mark-sexp}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 @kindex C-M-f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 @kindex C-M-b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 @findex forward-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 @findex backward-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 To move forward over an sexp, use @kbd{C-M-f} (@code{forward-sexp}). If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 the first significant character after point is an opening delimiter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (@samp{(} in Lisp; @samp{(}, @samp{[}, or @samp{@{} in C), @kbd{C-M-f}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 moves past the matching closing delimiter. If the character begins a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 symbol, string, or number, @kbd{C-M-f} moves over that. If the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 after point is a closing delimiter, @kbd{C-M-f} just moves past it. (This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 last is not really moving across an sexp; it is an exception which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 included in the definition of @kbd{C-M-f} because it is as useful a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 behavior as anyone can think of for that situation.)@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 The command @kbd{C-M-b} (@code{backward-sexp}) moves backward over a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 sexp. The detailed rules are like those above for @kbd{C-M-f}, but with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 directions reversed. If there are any prefix characters (single quote,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 back quote, and comma, in Lisp) preceding the sexp, @kbd{C-M-b} moves back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 over them as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 @kbd{C-M-f} or @kbd{C-M-b} with an argument repeats that operation the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 specified number of times; with a negative argument, it moves in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 opposite direction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 In languages such as C where the comment-terminator can be recognized,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 the sexp commands move across comments as if they were whitespace. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 Lisp and other languages where comments run until the end of a line, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 is very difficult to ignore comments when parsing backwards; therefore,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 in such languages the sexp commands treat the text of comments as if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 were code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 @kindex C-M-k
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 @findex kill-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 Killing an sexp at a time can be done with @kbd{C-M-k} (@code{kill-sexp}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 @kbd{C-M-k} kills the characters that @kbd{C-M-f} would move over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 @kindex C-M-n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 @kindex C-M-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 @findex forward-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 @findex backward-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 The @dfn{list commands}, @kbd{C-M-n} (@code{forward-list}) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 @kbd{C-M-p} (@code{backward-list}), move over lists like the sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 commands but skip over any number of other kinds of sexps (symbols,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 strings, etc). In some situations, these commands are useful because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 they usually ignore comments, since the comments usually do not contain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 any lists.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 @kindex C-M-u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 @kindex C-M-d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 @findex backward-up-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 @findex down-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 @kbd{C-M-n} and @kbd{C-M-p} stay at the same level in parentheses, when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 that is possible. To move @i{up} one (or @var{n}) levels, use @kbd{C-M-u}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (@code{backward-up-list}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 @kbd{C-M-u} moves backward up past one unmatched opening delimiter. A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 positive argument serves as a repeat count; a negative argument reverses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 direction of motion and also requests repetition, so it moves forward and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 up one or more levels.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 To move @i{down} in list structure, use @kbd{C-M-d}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (@code{down-list}). In Lisp mode, where @samp{(} is the only opening
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 delimiter, this is nearly the same as searching for a @samp{(}. An
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 argument specifies the number of levels of parentheses to go down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 @cindex transposition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 @kindex C-M-t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 @findex transpose-sexps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 @kbd{C-M-t} (@code{transpose-sexps}) drags the previous sexp across
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 the next one. An argument serves as a repeat count, and a negative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 argument drags backwards (thus canceling out the effect of @kbd{C-M-t} with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 a positive argument). An argument of zero, rather than doing nothing,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 transposes the sexps ending after point and the mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 @kindex C-M-@@
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 @findex mark-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 To make the region be the next sexp in the buffer, use @kbd{C-M-@@}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (@code{mark-sexp}) which sets the mark at the same place that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 @kbd{C-M-f} would move to. @kbd{C-M-@@} takes arguments like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 @kbd{C-M-f}. In particular, a negative argument is useful for putting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 the mark at the beginning of the previous sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 The list and sexp commands' understanding of syntax is completely
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 controlled by the syntax table. Any character can, for example, be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 declared to be an opening delimiter and act like an open parenthesis.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 @xref{Syntax}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 @node Defuns, Grinding, Lists, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 @section Defuns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 @cindex defuns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 In Emacs, a parenthetical grouping at the top level in the buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 called a @dfn{defun}. The name derives from the fact that most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 top-level lists in Lisp are instances of the special form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 @code{defun}, but Emacs calls any top-level parenthetical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 grouping counts a defun regardless of its contents or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 the programming language. For example, in C, the body of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 function definition is a defun.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 @c doublewidecommands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 @item C-M-a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 Move to beginning of current or preceding defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (@code{beginning-of-defun}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 @item C-M-e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 Move to end of current or following defun (@code{end-of-defun}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 @item C-M-h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 Put region around whole current or following defun (@code{mark-defun}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 @kindex C-M-a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 @kindex C-M-e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 @kindex C-M-h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 @findex beginning-of-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 @findex end-of-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 @findex mark-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 The commands to move to the beginning and end of the current defun are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 @kbd{C-M-a} (@code{beginning-of-defun}) and @kbd{C-M-e} (@code{end-of-defun}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 To operate on the current defun, use @kbd{C-M-h} (@code{mark-defun})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 which puts point at the beginning and the mark at the end of the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 or next defun. This is the easiest way to prepare for moving the defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 to a different place. In C mode, @kbd{C-M-h} runs the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 @code{mark-c-function}, which is almost the same as @code{mark-defun},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 but which backs up over the argument declarations, function name, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 returned data type so that the entire C function is inside the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 @findex compile-defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 To compile and evaluate the current defun, use @kbd{M-x compile-defun}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 This function prints the results in the minibuffer. If you include an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 argument, it inserts the value in the current buffer after the defun.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 Emacs assumes that any open-parenthesis found in the leftmost column is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 the start of a defun. Therefore, @i{never put an open-parenthesis at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 left margin in a Lisp file unless it is the start of a top level list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 Never put an open-brace or other opening delimiter at the beginning of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 line of C code unless it starts the body of a function.} The most likely
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 problem case is when you want an opening delimiter at the start of a line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 inside a string. To avoid trouble, put an escape character (@samp{\} in C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 and Emacs Lisp, @samp{/} in some other Lisp dialects) before the opening
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 delimiter. It will not affect the contents of the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 The original Emacs found defuns by moving upward a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 level of parentheses until there were no more levels to go up. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 required scanning back to the beginning of the buffer for every
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 function. To speed this up, Emacs was changed to assume
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 that any @samp{(} (or other character assigned the syntactic class of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 opening-delimiter) at the left margin is the start of a defun. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 heuristic is nearly always right; however, it mandates the convention
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 described above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 @node Grinding, Matching, Defuns, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 @section Indentation for Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 @cindex indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 @cindex grinding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 The best way to keep a program properly indented (``ground'') is to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 use Emacs to re-indent it as you change the program. Emacs has commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 to indent properly either a single line, a specified number of lines, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 all of the lines inside a single parenthetical grouping.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 * Basic Indent::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 * Multi-line Indent:: Commands to reindent many lines at once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 * Lisp Indent:: Specifying how each Lisp function should be indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 * C Indent:: Choosing an indentation style for C code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 @node Basic Indent, Multi-line Indent, Grinding, Grinding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 @subsection Basic Program Indentation Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 @c WideCommands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 @item @key{TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 Adjust indentation of current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 @item @key{LFD}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 Equivalent to @key{RET} followed by @key{TAB} (@code{newline-and-indent}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 @kindex TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 @findex c-indent-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 @findex lisp-indent-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 The basic indentation command is @key{TAB}, which gives the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 line the correct indentation as determined from the previous lines. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 function that @key{TAB} runs depends on the major mode; it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 @code{lisp-indent-line} in Lisp mode, @code{c-indent-line} in C mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 etc. These functions understand different syntaxes for different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 languages, but they all do about the same thing. @key{TAB} in any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 programming language major mode inserts or deletes whitespace at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 beginning of the current line, independent of where point is in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 line. If point is inside the whitespace at the beginning of the line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 @key{TAB} leaves it at the end of that whitespace; otherwise, @key{TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 leaves point fixed with respect to the characters around it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 Use @kbd{C-q @key{TAB}} to insert a tab at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 @kindex LFD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 @findex newline-and-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 When entering a large amount of new code, use @key{LFD}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (@code{newline-and-indent}), which is equivalent to a @key{RET} followed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 by a @key{TAB}. @key{LFD} creates a blank line, then gives it the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 appropriate indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 @key{TAB} indents the second and following lines of the body of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 parenthetical grouping each under the preceding one; therefore, if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 alter one line's indentation to be nonstandard, the lines below tend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 to follow it. This is the right behavior in cases where the standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 result of @key{TAB} does not look good.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 Remember that Emacs assumes that an open-parenthesis, open-brace, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 other opening delimiter at the left margin (including the indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 routines) is the start of a function. You should therefore never have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 an opening delimiter in column zero that is not the beginning of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 function, not even inside a string. This restriction is vital for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 making the indentation commands fast. @xref{Defuns}, for more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 information on this behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 @node Multi-line Indent, Lisp Indent, Basic Indent, Grinding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 @subsection Indenting Several Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 Several commands are available to re-indent several lines of code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 which have been altered or moved to a different level in a list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 structure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 @item C-M-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 Re-indent all the lines within one list (@code{indent-sexp}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 @item C-u @key{TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 Shift an entire list rigidly sideways so that its first line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 is properly indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 @item C-M-\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 Re-indent all lines in the region (@code{indent-region}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 @kindex C-M-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 @findex indent-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 @findex indent-c-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 To re-indent the contents of a single list, position point before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 beginning of it and type @kbd{C-M-q}. This key is bound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 @code{indent-sexp} in Lisp mode, @code{indent-c-exp} in C mode, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 bound to other suitable functions in other modes. The indentation of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 the line the sexp starts on is not changed; therefore, only the relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 indentation within the list, and not its position, is changed. To
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 correct the position as well, type a @key{TAB} before @kbd{C-M-q}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 @kindex C-u TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 If the relative indentation within a list is correct but the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 indentation of its beginning is not, go to the line on which the list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 begins and type @kbd{C-u @key{TAB}}. When you give @key{TAB} a numeric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 argument, it moves all the lines in the group, starting on the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 line, sideways the same amount that the current line moves. The command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 does not move lines that start inside strings, or C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 preprocessor lines when in C mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 @kindex C-M-\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 @findex indent-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 Another way to specify a range to be re-indented is with point and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 mark. The command @kbd{C-M-\} (@code{indent-region}) applies @key{TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 to every line whose first character is between point and mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 @node Lisp Indent, C Indent, Multi-line Indent, Grinding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 @subsection Customizing Lisp Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 @cindex customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 The indentation pattern for a Lisp expression can depend on the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 called by the expression. For each Lisp function, you can choose among
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 several predefined patterns of indentation, or define an arbitrary one with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 a Lisp program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 The standard pattern of indentation is as follows: the second line of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 expression is indented under the first argument, if that is on the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 line as the beginning of the expression; otherwise, the second line is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 indented underneath the function name. Each following line is indented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 under the previous line whose nesting depth is the same.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 @vindex lisp-indent-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 If the variable @code{lisp-indent-offset} is non-@code{nil}, it overrides
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 the usual indentation pattern for the second line of an expression, so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 such lines are always indented @code{lisp-indent-offset} more columns than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 the containing list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 @vindex lisp-body-indention
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 Certain functions override the standard pattern. Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 whose names start with @code{def} always indent the second line by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 @code{lisp-body-indention} extra columns beyond the open-parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 starting the expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 Individual functions can override the standard pattern in various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ways, according to the @code{lisp-indent-function} property of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 function name. (Note: @code{lisp-indent-function} was formerly called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 @code{lisp-indent-hook}). There are four possibilities for this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 property:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 @item @code{nil}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 This is the same as no property; the standard indentation pattern is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 @item @code{defun}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 The pattern used for function names that start with @code{def} is used for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 this function also.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 @item a number, @var{number}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 The first @var{number} arguments of the function are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 @dfn{distinguished} arguments; the rest are considered the @dfn{body}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 of the expression. A line in the expression is indented according to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 whether the first argument on it is distinguished or not. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 argument is part of the body, the line is indented @code{lisp-body-indent}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 more columns than the open-parenthesis starting the containing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 expression. If the argument is distinguished and is either the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 or second argument, it is indented @i{twice} that many extra columns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 If the argument is distinguished and not the first or second argument,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 the standard pattern is followed for that line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 @item a symbol, @var{symbol}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 @var{symbol} should be a function name; that function is called to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 calculate the indentation of a line within this expression. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 function receives two arguments:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 @item @var{state}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 The value returned by @code{parse-partial-sexp} (a Lisp primitive for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 indentation and nesting computation) when it parses up to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 beginning of this line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 @item @var{pos}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 The position at which the line being indented begins.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 It should return either a number, which is the number of columns of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 indentation for that line, or a list whose first element is such a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 number. The difference between returning a number and returning a list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 is that a number says that all following lines at the same nesting level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 should be indented just like this one; a list says that following lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 might call for different indentations. This makes a difference when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 indentation is computed by @kbd{C-M-q}; if the value is a number,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 @kbd{C-M-q} need not recalculate indentation for the following lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 until the end of the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 @node C Indent,, Lisp Indent, Grinding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 @subsection Customizing C Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 Two variables control which commands perform C indentation and when.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 @vindex c-auto-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 If @code{c-auto-newline} is non-@code{nil}, newlines are inserted both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 before and after braces that you insert and after colons and semicolons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 Correct C indentation is done on all the lines that are made this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 @vindex c-tab-always-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 If @code{c-tab-always-indent} is non-@code{nil}, the @key{TAB} command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 in C mode does indentation only if point is at the left margin or within
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 the line's indentation. If there is non-whitespace to the left of point,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 @key{TAB} just inserts a tab character in the buffer. Normally,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 this variable is @code{nil}, and @key{TAB} always reindents the current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 C does not have anything analogous to particular function names for which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 special forms of indentation are desirable. However, it has a different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 need for customization facilities: many different styles of C indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 are in common use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 There are six variables you can set to control the style that Emacs C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 mode will use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 @item c-indent-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 Indentation of C statements within surrounding block. The surrounding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 block's indentation is the indentation of the line on which the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 open-brace appears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 @item c-continued-statement-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 Extra indentation given to a substatement, such as the then-clause of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 an @code{if} or body of a @code{while}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 @item c-brace-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 Extra indentation for lines that start with an open brace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 @item c-brace-imaginary-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 An open brace following other text is treated as if it were this far
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 to the right of the start of its line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 @item c-argdecl-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 Indentation level of declarations of C function arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 @item c-label-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 Extra indentation for a line that is a label, case, or default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 @vindex c-indent-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 The variable @code{c-indent-level} controls the indentation for C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 statements with respect to the surrounding block. In the example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 foo ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 the difference in indentation between the lines is @code{c-indent-level}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 Its standard value is 2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 If the open-brace beginning the compound statement is not at the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 of its line, the @code{c-indent-level} is added to the indentation of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 line, not the column of the open-brace. For example,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 if (losing) @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 do_this ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 One popular indentation style is that which results from setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 @code{c-indent-level} to 8 and putting open-braces at the end of a line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 in this way. Another popular style prefers to put the open-brace on a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 separate line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 @vindex c-brace-imaginary-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 In fact, the value of the variable @code{c-brace-imaginary-offset} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 also added to the indentation of such a statement. Normally this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 is zero. Think of this variable as the imaginary position of the open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 brace, relative to the first non-blank character on the line. By setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 the variable to 4 and @code{c-indent-level} to 0, you can get this style:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 if (x == y) @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 do_it ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 @}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 When @code{c-indent-level} is zero, the statements inside most braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 line up exactly under the open brace. An exception are braces in column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 zero, like those surrounding a function's body. The statements inside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 those braces are not placed at column zero. Instead,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 @code{c-brace-offset} and @code{c-continued-statement-offset} (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 below) are added to produce a typical offset between brace levels, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 the statements are indented that far.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 @vindex c-continued-statement-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 @code{c-continued-statement-offset} controls the extra indentation for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 a line that starts within a statement (but not within parentheses or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 brackets). These lines are usually statements inside other statements,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 like the then-clauses of @code{if} statements and the bodies of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 @code{while} statements. The @code{c-continued-statement-offset}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 parameter determines the difference in indentation between the two lines in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 if (x == y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 do_it ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 The default value for @code{c-continued-statement-offset} is 2. Some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 popular indentation styles correspond to a value of zero for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 @code{c-continued-statement-offset}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 @vindex c-brace-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 @code{c-brace-offset} is the extra indentation given to a line that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 starts with an open-brace. Its standard value is zero;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 compare:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 if (x == y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 with:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 if (x == y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 do_it ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 If you set @code{c-brace-offset} to 4, the first example becomes:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 if (x == y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 @vindex c-argdecl-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 @code{c-argdecl-indent} controls the indentation of declarations of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 arguments of a C function. It is absolute: argument declarations receive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 exactly @code{c-argdecl-indent} spaces. The standard value is 5 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 results in code like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 index (string, char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 char *string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 int char;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 @vindex c-label-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 @code{c-label-offset} is the extra indentation given to a line that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 contains a label, a case statement, or a @code{default:} statement. Its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 standard value is @minus{}2 and results in code like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 case 'x':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 If @code{c-label-offset} were zero, the same code would be indented as:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 @{
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 case 'x':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 This example assumes that the other variables above also have their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 default values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 Using the indentation style produced by the default settings of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 variables just discussed and putting open braces on separate lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 produces clear and readable files. For an example, look at any of the C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 source files of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 @node Matching, Comments, Grinding, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 @section Automatic Display of Matching Parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 @cindex matching parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 @cindex parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 The Emacs parenthesis-matching feature shows you automatically how
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 parentheses match in the text. Whenever a self-inserting character that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 is a closing delimiter is typed, the cursor moves momentarily to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 location of the matching opening delimiter, provided that is visible on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 the screen. If it is not on the screen, some text starting with that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 opening delimiter is displayed in the echo area. Either way, you see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 the grouping you are closing off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 In Lisp, automatic matching applies only to parentheses. In C, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 also applies to braces and brackets. Emacs knows which characters to regard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 as matching delimiters based on the syntax table set by the major
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 mode. @xref{Syntax}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 If the opening delimiter and closing delimiter are mismatched---as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 in @samp{[x)}---the echo area displays a warning message. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 correct matches are specified in the syntax table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 @vindex blink-matching-paren
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 @vindex blink-matching-paren-distance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 Two variables control parenthesis matching displays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 @code{blink-matching-paren} turns the feature on or off. The default is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 @code{t} (match display is on); @code{nil} turns it off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 @code{blink-matching-paren-distance} specifies how many characters back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 Emacs searches to find a matching opening delimiter. If the match is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 not found in the specified region, scanning stops, and nothing is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 displayed. This prevents wasting lots of time scanning when there is no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 match. The default is 4000.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 @node Comments, Balanced Editing, Matching, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 @section Manipulating Comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 @cindex comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 @kindex M-;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 @cindex indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 @findex indent-for-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 The comment commands insert, kill and align comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 @c WideCommands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 @item M-;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 Insert or align comment (@code{indent-for-comment}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 @item C-x ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 Set comment column (@code{set-comment-column}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 @item C-u - C-x ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 Kill comment on current line (@code{kill-comment}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 @item M-@key{LFD}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 Like @key{RET} followed by inserting and aligning a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (@code{indent-new-comment-line}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 The command that creates a comment is @kbd{Meta-;}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (@code{indent-for-comment}). If there is no comment already on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 line, a new comment is created and aligned at a specific column called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 the @dfn{comment column}. Emacs creates the comment by inserting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 string at the value of @code{comment-start}; see below. Point is left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 after that string. If the text of the line extends past the comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 column, indentation is done to a suitable boundary (usually, at least
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 one space is inserted). If the major mode has specified a string to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 terminate comments, that string is inserted after point, to keep the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 syntax valid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 You can also use @kbd{Meta-;} to align an existing comment. If a line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 already contains the string that starts comments, @kbd{M-;} just moves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 point after it and re-indents it to the conventional place. Exception:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 comments starting in column 0 are not moved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 Some major modes have special rules for indenting certain kinds of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 comments in certain contexts. For example, in Lisp code, comments which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 start with two semicolons are indented as if they were lines of code,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 instead of at the comment column. Comments which start with three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 semicolons are supposed to start at the left margin. Emacs understands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 these conventions by indenting a double-semicolon comment using @key{TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 and by not changing the indentation of a triple-semicolon comment at all.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 ;; This function is just an example.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 ;;; Here either two or three semicolons are appropriate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (defun foo (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 ;;; And now, the first part of the function:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 ;; The following line adds one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (1+ x)) ; This line adds one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 In C code, a comment preceded on its line by nothing but whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 is indented like a line of code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 Even when an existing comment is properly aligned, @kbd{M-;} is still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 useful for moving directly to the start of the comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 @kindex C-u - C-x ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 @findex kill-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 @kbd{C-u - C-x ;} (@code{kill-comment}) kills the comment on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 current line, if there is one. The indentation before the start of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 comment is killed as well. If there does not appear to be a comment in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 the line, nothing happens. To reinsert the comment on another line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 move to the end of that line, type first @kbd{C-y}, and then @kbd{M-;}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 to realign the comment. Note that @kbd{C-u - C-x ;} is not a distinct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 key; it is @kbd{C-x ;} (@code{set-comment-column}) with a negative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 argument. That command is programmed to call @code{kill-comment} when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 called with a negative argument. However, @code{kill-comment} is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 valid command which you could bind directly to a key if you wanted to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 @subsection Multiple Lines of Comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 @kindex M-LFD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 @cindex blank lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 @cindex Auto Fill mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 @findex indent-new-comment-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 If you are typing a comment and want to continue it on another line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 use the command @kbd{Meta-@key{LFD}} (@code{indent-new-comment-line}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 which terminates the comment you are typing, creates a new blank line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 afterward, and begins a new comment indented under the old one. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 Auto Fill mode is on and you go past the fill column while typing, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 comment is continued in just this fashion. If point is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 not at the end of the line when you type @kbd{M-@key{LFD}}, the text on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 the rest of the line becomes part of the new comment line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 @subsection Options Controlling Comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 @vindex comment-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 @kindex C-x ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 @findex set-comment-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 The comment column is stored in the variable @code{comment-column}. You
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 can explicitly set it to a number. Alternatively, the command @kbd{C-x ;}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (@code{set-comment-column}) sets the comment column to the column point is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 at. @kbd{C-u C-x ;} sets the comment column to match the last comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 before point in the buffer, and then calls @kbd{Meta-;} to align the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 current line's comment under the previous one. Note that @kbd{C-u - C-x ;}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 runs the function @code{kill-comment} as described above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 @code{comment-column} is a per-buffer variable; altering the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 affects only the current buffer. You can also change the default value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 @xref{Locals}. Many major modes initialize this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 for the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 @vindex comment-start-skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 The comment commands recognize comments based on the regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 that is the value of the variable @code{comment-start-skip}. This regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 should not match the null string. It may match more than the comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 starting delimiter in the strictest sense of the word; for example, in C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 mode the value of the variable is @code{@t{"/\\*+ *"}}, which matches extra
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 stars and spaces after the @samp{/*} itself. (Note that @samp{\\} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 needed in Lisp syntax to include a @samp{\} in the string, which is needed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 to deny the first star its special meaning in regexp syntax. @xref{Regexps}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 @vindex comment-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 @vindex comment-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 When a comment command makes a new comment, it inserts the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 @code{comment-start} to begin it. The value of @code{comment-end} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 inserted after point and will follow the text you will insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 into the comment. In C mode, @code{comment-start} has the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 @w{@code{"/* "}} and @code{comment-end} has the value @w{@code{" */"}}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 @vindex comment-multi-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 @code{comment-multi-line} controls how @kbd{M-@key{LFD}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (@code{indent-new-comment-line}) behaves when used inside a comment. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 @code{comment-multi-line} is @code{nil}, as it normally is, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 @kbd{M-@key{LFD}} terminates the comment on the starting line and starts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 a new comment on the new following line. If @code{comment-multi-line}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 is not @code{nil}, then @kbd{M-@key{LFD}} sets up the new following line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 as part of the same comment that was found on the starting line. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 is done by not inserting a terminator on the old line and not inserting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 a starter on the new line. In languages where multi-line comments are legal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 the value you choose for this variable is a matter of taste.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 @vindex comment-indent-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 The variable @code{comment-indent-hook} should contain a function that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 is called to compute the indentation for a newly inserted comment or for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 aligning an existing comment. Major modes set this variable differently.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 The function is called with no arguments, but with point at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 beginning of the comment, or at the end of a line if a new comment is to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 be inserted. The function should return the column in which the comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ought to start. For example, in Lisp mode, the indent hook function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 bases its decision on the number of semicolons that begin an existing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 comment and on the code in the preceding lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 @node Balanced Editing, Lisp Completion, Comments, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 @section Editing Without Unbalanced Parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 @item M-(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 Put parentheses around next sexp(s) (@code{insert-parentheses}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 @item M-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 Move past next close parenthesis and re-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (@code{move-over-close-and-reindent}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 @kindex M-(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 @kindex M-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 @findex insert-parentheses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 @findex move-over-close-and-reindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 The commands @kbd{M-(} (@code{insert-parentheses}) and @kbd{M-)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (@code{move-over-close-@*and-reindent}) are designed to facilitate a style of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 editing which keeps parentheses balanced at all times. @kbd{M-(} inserts a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 pair of parentheses, either together as in @samp{()}, or, if given an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 argument, around the next several sexps, and leaves point after the open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 parenthesis. Instead of typing @kbd{( F O O )}, you can type @kbd{M-( F O
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 O}, which has the same effect except for leaving the cursor before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 close parenthesis. You can then type @kbd{M-)}, which moves past the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 close parenthesis, deletes any indentation preceding it (in this example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 there is none), and indents with @key{LFD} after it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 @node Lisp Completion, Documentation, Balanced Editing, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 @section Completion for Lisp Symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 @cindex completion (symbol names)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 Completion usually happens in the minibuffer. An exception is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 completion for Lisp symbol names, which is available in all buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 @kindex M-TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 @findex lisp-complete-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 The command @kbd{M-@key{TAB}} (@code{lisp-complete-symbol}) takes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 partial Lisp symbol before point to be an abbreviation, and compares it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 against all non-trivial Lisp symbols currently known to Emacs. Any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 additional characters that they all have in common are inserted at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 Non-trivial symbols are those that have function definitions, values, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 If there is an open-parenthesis immediately before the beginning of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 the partial symbol, only symbols with function definitions are considered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 as completions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 If the partial name in the buffer has more than one possible completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 and they have no additional characters in common, a list of all possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 completions is displayed in another window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 @node Documentation, Change Log, Lisp Completion, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 @section Documentation Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 @kindex C-h f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 @findex describe-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 @kindex C-h v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 @findex describe-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 As you edit Lisp code to be run in Emacs, you can use the commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 @kbd{C-h f} (@code{describe-function}) and @kbd{C-h v}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (@code{describe-variable}) to print documentation of functions and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 variables you want to call. These commands use the minibuffer to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 read the name of a function or variable to document, and display the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 documentation in a window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 For extra convenience, these commands provide default arguments based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 the code in the neighborhood of point. @kbd{C-h f} sets the default to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 function called in the innermost list containing point. @kbd{C-h v} uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 the symbol name around or adjacent to point as its default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 @findex manual-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 The @kbd{M-x manual-entry} command gives you access to documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 on Unix commands, system calls, and libraries. The command reads a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 topic as an argument, and displays the Unix manual page for that topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 @code{manual-entry} always searches all 8 sections of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 manual and concatenates all the entries it finds. For example,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 the topic @samp{termcap} finds the description of the termcap library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 from section 3, followed by the description of the termcap data base
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 from section 5.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 @node Change Log, Tags, Documentation, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 @section Change Logs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 @cindex change log
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 @findex add-change-log-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 The Emacs command @kbd{M-x add-change-log-entry} helps you keep a record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 of when and why you have changed a program. It assumes that you have a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 file in which you write a chronological sequence of entries describing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 individual changes. The default is to store the change entries in a file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 called @file{ChangeLog} in the same directory as the file you are editing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 The same @file{ChangeLog} file therefore records changes for all the files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 in a directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 A change log entry starts with a header line that contains your name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 and the current date. Except for these header lines, every line in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 change log starts with a tab. One entry can describe several changes;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 each change starts with a line starting with a tab and a star. @kbd{M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 add-change-log-entry} visits the change log file and creates a new entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 unless the most recent entry is for today's date and your name. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 either case, it adds a new line to start the description of another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 change just after the header line of the entry. When @kbd{M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 add-change-log-entry} is finished, all is prepared for you to edit in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 the description of what you changed and how. You must then save the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 change log file yourself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 The change log file is always visited in Indented Text mode, which means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 that @key{LFD} and auto-filling indent each new line like the previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 line. This is convenient for entering the contents of an entry, which must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 be indented. @xref{Text Mode}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 Here is an example of the formatting conventions used in the change log
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 for Emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 @smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 Wed Jun 26 19:29:32 1985 Richard M. Stallman (rms at mit-prep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 * xdisp.c (try_window_id):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 If C-k is done at end of next-to-last line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 this fn updates window_end_vpos and cannot leave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 window_end_pos nonnegative (it is zero, in fact).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 If display is preempted before lines are output,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 this is inconsistent. Fix by setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 blank_end_of_window to nonzero.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 Tue Jun 25 05:25:33 1985 Richard M. Stallman (rms at mit-prep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 * cmds.c (Fnewline):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 Call the auto fill hook if appropriate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 * xdisp.c (try_window_id):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 If point is found by compute_motion after xp, record that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 permanently. If display_text_line sets point position wrong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (case where line is killed, point is at eob and that line is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 not displayed), set it again in final compute_motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 @end smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 @node Tags, Fortran, Change Log, Programs
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1007 @section Tags Tables
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1008 @cindex tags table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1010 A @dfn{tags table} is a description of how a multi-file program is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 broken up into files. It lists the names of the component files and the
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1012 names and positions of the functions (or other named subunits) in each
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1013 file. Grouping the related files makes it possible to search or replace
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1014 through all the files with one command. Recording the function names
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1015 and positions makes possible the @kbd{M-.} command which finds the
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1016 definition of a function by looking up which of the files it is in.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1018 Tags tables are stored in files called @dfn{tags table files}. The
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1019 conventional name for a tags table file is @file{TAGS}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1021 Each entry in the tags table records the name of one tag, the name of the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 file that the tag is defined in (implicitly), and the position in that file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 of the tag's definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1025 Just what names from the described files are recorded in the tags table
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1026 depends on the programming language of the described file. They
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1027 normally include all functions and subroutines, and may also include
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1028 global variables, data types, and anything else convenient. Each name
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1029 recorded is called a @dfn{tag}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 @menu
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1032 * Tag Syntax:: Tag syntax for various types of code and text files.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1033 * Create Tags Table:: Creating a tags table with @code{etags}.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1034 * Select Tags Table:: How to visit a tags table.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1035 * Find Tag:: Commands to find the definition of a specific tag.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1036 * Tags Search:: Using a tags table for searching and replacing.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1037 * List Tags:: Listing and finding tags defined in a file.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1040 @node Tag Syntax
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 @subsection Source File Tag Syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1043 Here is how tag syntax is defined for the most popular languages:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1044
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1045 @itemize @bullet
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1046 @item
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1047 In C code, any C function or typedef is a tag, and so are definitions of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1048 @code{struct}, @code{union} and @code{enum}. @code{#define} macro
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1049 definitions and @code{enum} constants are also tags, unless you specify
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1050 @samp{--no-defines} when making the tags table. Similarly, global
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1051 variables are tags, unless you specify @samp{--no-globals}. Use of
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1052 @samp{--no-globals} and @samp{--no-defines} can make the tags table file
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1053 much smaller.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1054
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1055 @item
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1056 In C++ code, in addition to all the tag constructs of C code, member
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1057 functions are also recognized, and optionally member variables if you
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1058 use the @samp{--members} option. Tags for variables and functions in
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1059 classes are named @samp{@var{class}::@var{variable}} and
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1060 @samp{@var{class}::@var{function}}.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1062 @item
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1063 In Java code, tags include all the constructs recognized in C++, plus
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1064 the @code{extends} and @code{implements} constructs. Tags for variables
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1065 and functions in classes are named @samp{@var{class}.@var{variable}} and
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1066 @samp{@var{class}.@var{function}}.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1067
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1068 @item
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1069 In La@TeX{} text, the argument of any of the commands @code{\chapter},
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1070 @code{\section}, @code{\subsection}, @code{\subsubsection},
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1071 @code{\eqno}, @code{\label}, @code{\ref}, @code{\cite}, @code{\bibitem},
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1072 @code{\part}, @code{\appendix}, @code{\entry}, or @code{\index}, is a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1073 tag.@refill
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1075 Other commands can make tags as well, if you specify them in the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1076 environment variable @code{TEXTAGS} before invoking @code{etags}. The
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1077 value of this environment variable should be a colon-separated list of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1078 commands names. For example,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1079
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1080 @example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1081 TEXTAGS="def:newcommand:newenvironment"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1082 export TEXTAGS
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1083 @end example
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1085 @noindent
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1086 specifies (using Bourne shell syntax) that the commands @samp{\def},
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1087 @samp{\newcommand} and @samp{\newenvironment} also define tags.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1088
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1089 @item
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1090 In Lisp code, any function defined with @code{defun}, any variable
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1091 defined with @code{defvar} or @code{defconst}, and in general the first
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1092 argument of any expression that starts with @samp{(def} in column zero, is
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1093 a tag.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1094
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1095 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1096 In Scheme code, tags include anything defined with @code{def} or with a
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1097 construct whose name starts with @samp{def}. They also include variables
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1098 set with @code{set!} at top level in the file.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1099 @end itemize
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1100
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1101 Several other languages are also supported:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1102
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1103 @itemize @bullet
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1104 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1105 In assembler code, labels appearing at the beginning of a line,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1106 followed by a colon, are tags.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1107
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1108 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1109 In Bison or Yacc input files, each rule defines as a tag the nonterminal
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1110 it constructs. The portions of the file that contain C code are parsed
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1111 as C code.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1112
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1113 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1114 In Cobol code, paragraphs names are the tags, i.e. any word starting in
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1115 column 8 and followed by a full stop.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1116
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1117 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1118 In Erlang code, the tags are the functions, records, and macros defined
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1119 in the file.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1120
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1121 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1122 In Fortran code, functions and subroutines are tags.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1123
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1124 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1125 In Objective C code, tags include Objective C definitions for classes,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1126 class categories, methods and protocols.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1127
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1128 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1129 In Pascal code, the tags are the functions and procedures defined in
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1130 the file.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1131
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1132 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1133 In Perl code, the tags are the procedures defined by the @code{sub}
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1134 keyword.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1135
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1136 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1137 In Postscript code, the tags are the functions.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1138
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1139 @item
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1140 In Prolog code, a tag name appears at the left margin.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1141 @end itemize
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1142
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1143 You can also generate tags based on regexp matching (@pxref{Create
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1144 Tags Table}) to handle other formats and languages.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1145
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1146 @node Create Tags Table
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1147 @subsection Creating Tags Tables
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1148 @cindex @code{etags} program
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1150 The @code{etags} program is used to create a tags table file. It knows
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1151 the syntax of several languages, as described in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1152 @iftex
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1153 the previous section.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1154 @end iftex
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1155 @ifinfo
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1156 @ref{Tag Syntax}.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1157 @end ifinfo
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1158 Here is how to run @code{etags}:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 etags @var{inputfiles}@dots{}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 @end example
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1163
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 @noindent
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1165 The @code{etags} program reads the specified files, and writes a tags table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 named @file{TAGS} in the current working directory. @code{etags}
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1167 recognizes the language used in an input file based on its file name and
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1168 contents. You can specify the language with the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1169 @samp{--language=@var{name}} option, described below.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1170
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1171 If the tags table data become outdated due to changes in the files
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1172 described in the table, the way to update the tags table is the same way it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1173 was made in the first place. It is not necessary to do this often.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1174
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1175 If the tags table fails to record a tag, or records it for the wrong
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1176 file, then Emacs cannot possibly find its definition. However, if the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1177 position recorded in the tags table becomes a little bit wrong (due to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1178 some editing in the file that the tag definition is in), the only
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1179 consequence is a slight delay in finding the tag. Even if the stored
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1180 position is very wrong, Emacs will still find the tag, but it must
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1181 search the entire file for it.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1182
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1183 So you should update a tags table when you define new tags that you want
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1184 to have listed, or when you move tag definitions from one file to another,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1185 or when changes become substantial. Normally there is no need to update
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1186 the tags table after each edit, or even every day.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1187
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1188 One tags table can effectively include another. Specify the included
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1189 tags file name with the @samp{--include=@var{file}} option when creating
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1190 the file that is to include it. The latter file then acts as if it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1191 contained all the files specified in the included file, as well as the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1192 files it directly contains.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1193
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1194 If you specify the source files with relative file names when you run
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1195 @code{etags}, the tags file will contain file names relative to the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1196 directory where the tags file was initially written. This way, you can
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1197 move an entire directory tree containing both the tags file and the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1198 source files, and the tags file will still refer correctly to the source
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1199 files.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1201 If you specify absolute file names as arguments to @code{etags}, then
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1202 the tags file will contain absolute file names. This way, the tags file
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1203 will still refer to the same files even if you move it, as long as the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1204 source files remain in the same place. Absolute file names start with
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1205 @samp{/}, or with @samp{@var{device}:/} on MS-DOS and Windows.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1206
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1207 When you want to make a tags table from a great number of files, you
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1208 may have problems listing them on the command line, because some systems
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1209 have a limit on its length. The simplest way to circumvent this limit
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1210 is to tell @code{etags} to read the file names from its standard input,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1211 by typing a dash in place of the file names, like this:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1212
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1213 @example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1214 find . -name "*.[chCH]" -print | etags -
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1215 @end example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1216
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1217 Use the option @samp{--language=@var{name}} to specify the language
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1218 explicitly. You can intermix these options with file names; each one
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1219 applies to the file names that follow it. Specify
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1220 @samp{--language=auto} to tell @code{etags} to resume guessing the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1221 language from the file names and file contents. Specify
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1222 @samp{--language=none} to turn off language-specific processing
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1223 entirely; then @code{etags} recognizes tags by regexp matching alone.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1224 @samp{etags --help} prints the list of the languages @code{etags} knows,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1225 and the file name rules for guessing the language.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1226
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1227 The @samp{--regex} option provides a general way of recognizing tags
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1228 based on regexp matching. You can freely intermix it with file names.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1229 Each @samp{--regex} option adds to the preceding ones, and applies only
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1230 to the following files. The syntax is:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1231
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1232 @example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1233 --regex=/@var{tagregexp}[/@var{nameregexp}]/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1234 @end example
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1236 @noindent
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1237 where @var{tagregexp} is used to match the lines to tag. It is always
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1238 anchored, that is, it behaves as if preceded by @samp{^}. If you want
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1239 to account for indentation, just match any initial number of blanks by
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1240 beginning your regular expression with @samp{[ \t]*}. In the regular
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1241 expressions, @samp{\} quotes the next character, and @samp{\t} stands
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1242 for the tab character. Note that @code{etags} does not handle the other
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1243 C escape sequences for special characters.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1244
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1245 @cindex interval operator (in regexps)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1246 The syntax of regular expressions in @code{etags} is the same as in
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1247 Emacs, augmented with the @dfn{interval operator}, which works as in
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1248 @code{grep} and @code{ed}. The syntax of an interval operator is
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1249 @samp{\@{@var{m},@var{n}\@}}, and its meaning is to match the preceding
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1250 expression at least @var{m} times and up to @var{n} times.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1251
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1252 You should not match more characters with @var{tagregexp} than that
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1253 needed to recognize what you want to tag. If the match is such that
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1254 more characters than needed are unavoidably matched by @var{tagregexp},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1255 you may find useful to add a @var{nameregexp}, in order to narrow the tag
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 70
diff changeset
1256 scope. You can find some examples below.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1257
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1258 The @samp{-R} option deletes all the regexps defined with
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1259 @samp{--regex} options. It applies to the file names following it, as
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1260 you can see from the following example:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1261
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1262 @example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1263 etags --regex=/@var{reg1}/ voo.doo --regex=/@var{reg2}/ \
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1264 bar.ber -R --lang=lisp los.er
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1265 @end example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1266
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1267 @noindent
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1268 Here @code{etags} chooses the parsing language for @file{voo.doo} and
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1269 @file{bar.ber} according to their contents. @code{etags} also uses
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1270 @var{reg1} to recognize additional tags in @file{voo.doo}, and both
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1271 @var{reg1} and @var{reg2} to recognize additional tags in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1272 @file{bar.ber}. @code{etags} uses the Lisp tags rules, and no regexp
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1273 matching, to recognize tags in @file{los.er}.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1274
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1275 Here are some more examples. The regexps are quoted to protect them
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1276 from shell interpretation.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1277
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1278 @noindent
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1279 Tag the @code{DEFVAR} macros in the emacs source files:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1281 @example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1282 --regex='/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1283 @end example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1284
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1285 @noindent
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1286 Tag VHDL files (this example is a single long line, broken here for
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1287 formatting reasons):
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1288
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1289 @example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1290 --language=none
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1291 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1292 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1293 \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1294 @end example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1295
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1296 @noindent
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1297 Tag TCL files (this last example shows the usage of a @var{nameregexp}):
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1298
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1299 @example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1300 --lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1301 @end example
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1302
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1303 For a list of the other available @code{etags} options, execute
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1304 @code{etags --help}.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1305
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1306 @node Select Tags Table, Find Tag, Create Tags Table, Tags
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1307 @subsection Selecting a Tags Table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 @vindex tag-table-alist
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1310 At any time Emacs has one @dfn{selected} tags table, and all the commands
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1311 for working with tags tables use the selected one. To select a tags table,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 use the variable @code{tag-table-alist}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 The value of @code{tag-table-alist} is a list that determines which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 @code{TAGS} files should be active for a given buffer. This is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 really an association list, in that all elements are checked. The car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 of each element of this list is a pattern against which the buffers file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 name is compared; if it matches, then the cdr of the list should be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 name of the tags table to use. If more than one element of this list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 matches the buffers file name, all of the associated tags tables are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 used. Earlier ones are searched first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 If the car of elements of this list are strings, they are treated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 as regular-expressions against which the file is compared (like the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 @code{auto-mode-alist}). If they are not strings, they are evaluated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 If they evaluate to non-@code{nil}, the current buffer is considered to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 If the cdr of the elements of this list are strings, they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 assumed to name a tags file. If they name a directory, the string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 @file{tags} is appended to them to get the file name. If they are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 strings, they are evaluated and must return an appropriate string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 For example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (setq tag-table-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 '(("/usr/src/public/perl/" . "/usr/src/public/perl/perl-3.0/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 ("\\.el$" . "/usr/local/emacs/src/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 ("/jbw/gnu/" . "/usr15/degree/stud/jbw/gnu/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 ("" . "/usr/local/emacs/src/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1345 The example defines the tags table alist in the following way:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 Anything in the directory @file{/usr/src/public/perl/}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 should use the @file{TAGS} file @file{/usr/src/public/perl/perl-3.0/TAGS}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 Files ending in @file{.el} should use the @file{TAGS} file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 @file{/usr/local/emacs/src/TAGS}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 Anything in or below the directory @file{/jbw/gnu/} should use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 @file{TAGS} file @file{/usr15/degree/stud/jbw/gnu/TAGS}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 If you had a file called @file{/usr/jbw/foo.el}, it would use both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 @file{TAGS} files, @* @file{/usr/local/emacs/src/TAGS} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 @file{/usr15/degree/stud/jbw/gnu/TAGS} (in that order), because it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 matches both patterns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 If the buffer-local variable @code{buffer-tag-table} is set, it names a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 tags table that is searched before all others when @code{find-tag} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 executed from this buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 If there is a file called @file{TAGS} in the same directory as the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 in question, then that tags file will always be used as well (after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 @code{buffer-tag-table} but before the tables specified by this list).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 If the variable @code{tags-file-name} is set, the @file{TAGS} file it names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 will apply to all buffers (for backwards compatibility.) It is searched
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 @vindex tags-always-build-completion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 If the value of the variable @code{tags-always-build-completion-table}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 is @code{t}, the tags file will always be added to the completion table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 without asking first, regardless of the size of the tags file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 @vindex tags-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 @findex visit-tags-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 The function @kbd{M-x visit-tags-table}, is largely made obsolete by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 the variable @code{tag-table-alist}, tells tags commands to use the tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 table file @var{file} first. The @var{file} should be the name of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 file created with the @code{etags} program. A directory name is also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 acceptable; it means the file @file{TAGS} in that directory. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 function only stores the file name you provide in the variable
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1389 @code{tags-file-name}. Emacs does not actually read in the tags table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 contents until you try to use them. You can set the variable explicitly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 instead of using @code{visit-tags-table}. The value of the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 @code{tags-file-name} is the name of the tags table used by all buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 This is for backward compatibility, and is largely supplanted by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 variable @code{tag-table-alist}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1396 @node Find Tag, Tags Search, Select Tags Table, Tags
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 @subsection Finding a Tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1399 The most important thing that a tags table enables you to do is to find
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 the definition of a specific tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 @item M-.@: @var{tag &optional other-window}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 Find first definition of @var{tag} (@code{find-tag}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 @item C-u M-.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 Find next alternate definition of last tag specified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 @item C-x 4 . @var{tag}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 Find first definition of @var{tag}, but display it in another window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (@code{find-tag-other-window}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 @kindex M-.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 @findex find-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 @kbd{M-.}@: (@code{find-tag}) is the command to find the definition of
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1415 a specified tag. It searches through the tags table for that tag, as a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1416 string, then uses the tags table information to determine the file in
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 which the definition is used and the approximate character position of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 the definition in the file. Then @code{find-tag} visits the file,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 moves point to the approximate character position, and starts searching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 ever-increasing distances away for the text that should appear at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 the beginning of the definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 If an empty argument is given (by typing @key{RET}), the sexp in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 buffer before or around point is used as the name of the tag to find.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 @xref{Lists}, for information on sexps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 The argument to @code{find-tag} need not be the whole tag name; it can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 be a substring of a tag name. However, there can be many tag names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 containing the substring you specify. Since @code{find-tag} works by
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1430 searching the text of the tags table, it finds the first tag in the table
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 that the specified substring appears in. To find other tags that match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 the substring, give @code{find-tag} a numeric argument, as in @kbd{C-u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 M-.}. This does not read a tag name, but continues searching the tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 table's text for another tag containing the same substring last used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 If your keyboard has a real @key{META} key, @kbd{M-0 M-.}@: is an easier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 alternative to @kbd{C-u M-.}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 If the optional second argument @var{other-window} is non-@code{nil}, it uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 another window to display the tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 Multiple active tags tables and completion are supported.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 Variables of note include the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 @vindex tag-table-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 @vindex tags-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 @vindex tags-build-completion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 @vindex buffer-tag-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 @vindex make-tags-files-invisible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 @vindex tag-mark-stack-max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 @item tag-table-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 Controls which tables apply to which buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 @item tags-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 Stores a default tags table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 @item tags-build-completion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 Controls completion behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 @item buffer-tag-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 Specifies a buffer-local table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 @item make-tags-files-invisible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 Sets whether tags tables should be very hidden.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 @item tag-mark-stack-max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 Specifies how many tags-based hops to remember.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 @kindex C-x 4 .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 @findex find-tag-other-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 Like most commands that can switch buffers, @code{find-tag} has another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 similar command that displays the new buffer in another window. @kbd{C-x 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 .}@: invokes the function @code{find-tag-other-window}. (This key sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 ends with a period.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1473 Emacs comes with a tags table file @file{TAGS} (in the directory
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 containing Lisp libraries) that includes all the Lisp libraries and all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 the C sources of Emacs. By specifying this file with @code{visit-tags-table}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 and then using @kbd{M-.}@: you can quickly look at the source of any Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1479 @node Tags Search, List Tags, Find Tag, Tags
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1480 @subsection Searching and Replacing with Tags Tables
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 The commands in this section visit and search all the files listed in the
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1483 selected tags table, one by one. For these commands, the tags table serves
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 only to specify a sequence of files to search. A related command is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 @kbd{M-x grep} (@pxref{Compilation}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 @table @kbd
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1488 @item M-x tags-search @key{RET} @var{regexp} @key{RET}
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1489 Search for @var{regexp} through the files in the selected tags
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 table.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1491 @item M-x tags-query-replace @key{RET} @var{regexp} @key{RET} @var{replacement} @key{RET}
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1492 Perform a @code{query-replace-regexp} on each file in the selected tags table.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 @item M-,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 Restart one of the commands above, from the current location of point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (@code{tags-loop-continue}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 @findex tags-search
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1499 @kbd{M-x tags-search} reads a regexp using the minibuffer, then
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1500 searches for matches in all the files in the selected tags table, one
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1501 file at a time. It displays the name of the file being searched so you
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1502 can follow its progress. As soon as it finds an occurrence,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 @code{tags-search} returns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 @kindex M-,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 @findex tags-loop-continue
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1507 Having found one match, you probably want to find all the rest. To find
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1508 one more match, type @kbd{M-,} (@code{tags-loop-continue}) to resume the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1509 @code{tags-search}. This searches the rest of the current buffer, followed
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1510 by the remaining files of the tags table.@refill
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 @findex tags-query-replace
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1513 @kbd{M-x tags-query-replace} performs a single
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1514 @code{query-replace-regexp} through all the files in the tags table. It
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1515 reads a regexp to search for and a string to replace with, just like
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1516 ordinary @kbd{M-x query-replace-regexp}. It searches much like @kbd{M-x
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1517 tags-search}, but repeatedly, processing matches according to your
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1518 input. @xref{Replace}, for more information on query replace.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1519
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1520 It is possible to get through all the files in the tags table with a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1521 single invocation of @kbd{M-x tags-query-replace}. But often it is
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1522 useful to exit temporarily, which you can do with any input event that
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1523 has no special query replace meaning. You can resume the query replace
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1524 subsequently by typing @kbd{M-,}; this command resumes the last tags
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1525 search or replace command that you did.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1527 The commands in this section carry out much broader searches than the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1528 @code{find-tag} family. The @code{find-tag} commands search only for
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1529 definitions of tags that match your substring or regexp. The commands
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1530 @code{tags-search} and @code{tags-query-replace} find every occurrence
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1531 of the regexp, as ordinary search commands and replace commands do in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1532 the current buffer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1534 These commands create buffers only temporarily for the files that they
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1535 have to search (those which are not already visited in Emacs buffers).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1536 Buffers in which no match is found are quickly killed; the others
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1537 continue to exist.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1538
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1539 It may have struck you that @code{tags-search} is a lot like
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1540 @code{grep}. You can also run @code{grep} itself as an inferior of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1541 Emacs and have Emacs show you the matching lines one by one. This works
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1542 much like running a compilation; finding the source locations of the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1543 @code{grep} matches works like finding the compilation errors.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 @xref{Compilation}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1546 If you wish to process all the files in a selected tags table, but
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 @kbd{M-x tags-search} and @kbd{M-x tags-query-replace} are not giving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 you the desired result, you can use @kbd{M-x next-file}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 @item C-u M-x next-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 With a numeric argument, regardless of its value, visit the first
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1553 file in the tags table and prepare to advance sequentially by files.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 @item M-x next-file
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1555 Visit the next file in the selected tags table.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1558 @node List Tags,, Tags Search, Tags
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1559 @subsection Tags Table Inquiries
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 @item M-x list-tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 Display a list of the tags defined in a specific program file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 @item M-x tags-apropos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 Display a list of all tags matching a specified regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 @findex list-tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 @kbd{M-x list-tags} reads the name of one of the files described by the
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1570 selected tags table, and displays a list of all the tags defined in that
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 file. The ``file name'' argument is really just a string to compare
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1572 against the names recorded in the tags table; it is read as a string rather
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 than a file name. Therefore, completion and defaulting are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 available, and you must enter the string the same way it appears in the tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 table. Do not include a directory as part of the file name unless the file
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1576 name recorded in the tags table contains that directory.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 @findex tags-apropos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 @kbd{M-x tags-apropos} is like @code{apropos} for tags. It reads a regexp,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
1580 then finds all the tags in the selected tags table whose entries match that
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 regexp, and displays the tag names found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 @node Fortran, Asm Mode, Tags, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 @section Fortran Mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 @cindex Fortran mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 Fortran mode provides special motion commands for Fortran statements and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 subprograms, and indentation commands that understand Fortran conventions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 of nesting, line numbers, and continuation statements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 Special commands for comments are provided because Fortran comments are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 unlike those of other languages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 Built-in abbrevs optionally save typing when you insert Fortran keywords.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 @findex fortran-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 Use @kbd{M-x fortran-mode} to switch to this major mode. Doing so calls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 the value of @code{fortran-mode-hook} as a function of no arguments if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 that variable has a non-@code{nil} value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 * Motion: Fortran Motion. Moving point by statements or subprograms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 * Indent: Fortran Indent. Indentation commands for Fortran.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 * Comments: Fortran Comments. Inserting and aligning comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 * Columns: Fortran Columns. Measuring columns for valid Fortran.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 * Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 Fortran mode was contributed by Michael Prange.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 @node Fortran Motion, Fortran Indent, Fortran, Fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 @subsection Motion Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 Fortran mode provides special commands to move by subprograms (functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 and subroutines) and by statements. There is also a command to put the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 region around one subprogram, which is convenient for killing it or moving it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 @kindex C-M-a (Fortran mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 @kindex C-M-e (Fortran mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 @kindex C-M-h (Fortran mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 @kindex C-c C-p (Fortran mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 @kindex C-c C-n (Fortran mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 @findex beginning-of-fortran-subprogram
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 @findex end-of-fortran-subprogram
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 @findex mark-fortran-subprogram
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 @findex fortran-previous-statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 @findex fortran-next-statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 @item C-M-a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 Move to beginning of subprogram@*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (@code{beginning-of-fortran-subprogram}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 @item C-M-e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 Move to end of subprogram (@code{end-of-fortran-subprogram}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 @item C-M-h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 Put point at beginning of subprogram and mark at end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (@code{mark-fortran-subprogram}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 @item C-c C-n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 Move to beginning of current or next statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (@code{fortran-next-@*statement}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 @item C-c C-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 Move to beginning of current or previous statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (@code{fortran-@*previous-statement}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 @node Fortran Indent, Fortran Comments, Fortran Motion, Fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 @subsection Fortran Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 Special commands and features are available for indenting Fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 code. They make sure various syntactic entities (line numbers, comment line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 indicators, and continuation line flags) appear in the columns that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 required for standard Fortran.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 * Commands: ForIndent Commands. Commands for indenting Fortran.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 * Numbers: ForIndent Num. How line numbers auto-indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 * Conv: ForIndent Conv. Conventions you must obey to avoid trouble.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 * Vars: ForIndent Vars. Variables controlling Fortran indent style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 @node ForIndent Commands, ForIndent Num, Fortran Indent, Fortran Indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 @subsubsection Fortran Indentation Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 @item @key{TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 Indent the current line (@code{fortran-indent-line}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 @item M-@key{LFD}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 Break the current line and set up a continuation line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 @item C-M-q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 Indent all the lines of the subprogram point is in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (@code{fortran-indent-subprogram}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 @findex fortran-indent-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 @key{TAB} is redefined by Fortran mode to reindent the current line for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 Fortran (@code{fortran-indent-line}). Line numbers and continuation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 markers are indented to their required columns, and the body of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 statement is independently indented, based on its nesting in the program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 @kindex C-M-q (Fortran mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 @findex fortran-indent-subprogram
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 The key @kbd{C-M-q} is redefined as @code{fortran-indent-subprogram}, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 command that reindents all the lines of the Fortran subprogram (function or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 subroutine) containing point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 @kindex M-LFD (Fortran mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 @findex fortran-split-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 The key @kbd{M-@key{LFD}} is redefined as @code{fortran-split-line}, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 command to split a line in the appropriate fashion for Fortran. In a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 non-comment line, the second half becomes a continuation line and is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 indented accordingly. In a comment line, both halves become separate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 comment lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 @node ForIndent Num, ForIndent Conv, ForIndent Commands, Fortran Indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 @subsubsection Line Numbers and Continuation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 If a number is the first non-whitespace in the line, it is assumed to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 a line number and is moved to columns 0 through 4. (Columns are always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 counted from 0 in XEmacs.) If the text on the line starts with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 conventional Fortran continuation marker @samp{$}, it is moved to column 5.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 If the text begins with any non whitespace character in column 5, it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 assumed to be an unconventional continuation marker and remains in column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 5.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 @vindex fortran-line-number-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 Line numbers of four digits or less are normally indented one space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 This amount is controlled by the variable @code{fortran-line-number-indent},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 which is the maximum indentation a line number can have. Line numbers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 are indented to right-justify them to end in column 4 unless that would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 require more than the maximum indentation. The default value of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 variable is 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 @vindex fortran-electric-line-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 Simply inserting a line number is enough to indent it according to these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 rules. As each digit is inserted, the indentation is recomputed. To turn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 off this feature, set the variable @code{fortran-electric-line-number} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 @code{nil}. Then inserting line numbers is like inserting anything else.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 @node ForIndent Conv, ForIndent Vars, ForIndent Num, Fortran Indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 @subsubsection Syntactic Conventions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 Fortran mode assumes that you follow certain conventions that simplify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 the task of understanding a Fortran program well enough to indent it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 properly:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 @vindex fortran-continuation-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 Two nested @samp{do} loops never share a @samp{continue} statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 The same character appears in column 5 of all continuation lines. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 is the value of the variable @code{fortran-continuation-char}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 By default, this character is @samp{$}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 If you fail to follow these conventions, the indentation commands may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 indent some lines unaesthetically. However, a correct Fortran program will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 retain its meaning when reindented even if the conventions are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 followed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 @node ForIndent Vars,, ForIndent Conv, Fortran Indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 @subsubsection Variables for Fortran Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 @vindex fortran-do-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 @vindex fortran-if-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 @vindex fortran-continuation-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 @vindex fortran-check-all-num-for-matching-do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 @vindex fortran-minimum-statement-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 Several additional variables control how Fortran indentation works.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 @item fortran-do-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 Extra indentation within each level of @samp{do} statement (the default is 3).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 @item fortran-if-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 Extra indentation within each level of @samp{if} statement (the default is 3).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 @item fortran-continuation-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 Extra indentation for bodies of continuation lines (the default is 5).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 @item fortran-check-all-num-for-matching-do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 If this is @code{nil}, indentation assumes that each @samp{do}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 statement ends on a @samp{continue} statement. Therefore, when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 computing indentation for a statement other than @samp{continue}, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 can save time by not checking for a @samp{do} statement ending there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 If this is non-@code{nil}, indenting any numbered statement must check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 for a @samp{do} that ends there. The default is @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 @item fortran-minimum-statement-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 Minimum indentation for Fortran statements. For standard Fortran,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 this is 6. Statement bodies are always indented at least this much.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 @node Fortran Comments, Fortran Columns, Fortran Indent, Fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 @subsection Comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 The usual Emacs comment commands assume that a comment can follow a line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 of code. In Fortran, the standard comment syntax requires an entire line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 to be just a comment. Therefore, Fortran mode replaces the standard Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 comment commands and defines some new variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 Fortran mode can also handle a non-standard comment syntax where comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 start with @samp{!} and can follow other text. Because only some Fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 compilers accept this syntax, Fortran mode will not insert such comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 unless you have specified to do so in advance by setting the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 @code{comment-start} to @samp{"!"} (@pxref{Variables}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 @item M-;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 Align comment or insert new comment (@code{fortran-comment-indent}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 @item C-x ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 Applies to nonstandard @samp{!} comments only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 @item C-c ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 Turn all lines of the region into comments, or (with arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 turn them back into real code (@code{fortran-comment-region}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 @kbd{M-;} in Fortran mode is redefined as the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 @code{fortran-comment-indent}. Like the usual @kbd{M-;} command,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 it recognizes an existing comment and aligns its text appropriately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 If there is no existing comment, a comment is inserted and aligned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 Inserting and aligning comments is not the same in Fortran mode as in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 other modes. When a new comment must be inserted, a full-line comment is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 inserted if the current line is blank. On a non-blank line, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 non-standard @samp{!} comment is inserted if you previously specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 you wanted to use them. Otherwise a full-line comment is inserted on a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 new line before the current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 Non-standard @samp{!} comments are aligned like comments in other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 languages, but full-line comments are aligned differently. In a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 standard full-line comment, the comment delimiter itself must always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 appear in column zero. What can be aligned is the text within the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 comment. You can choose from three styles of alignment by setting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 variable @code{fortran-comment-indent-style} to one of these values:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 @vindex fortran-comment-indent-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 @vindex fortran-comment-line-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 @item fixed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 The text is aligned at a fixed column, which is the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 @code{fortran-comment-line-column}. This is the default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 @item relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 The text is aligned as if it were a line of code, but with an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 additional @code{fortran-comment-line-column} columns of indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 @item nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 Text in full-line columns is not moved automatically.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 @vindex fortran-comment-indent-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 You can also specify the character to be used to indent within
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 full-line comments by setting the variable @code{fortran-comment-indent-char}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 to the character you want to use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 @vindex comment-line-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 @vindex comment-line-start-skip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 Fortran mode introduces two variables @code{comment-line-start} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 @code{comment-line-start-skip}, which do for full-line comments what
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 @code{comment-start} and @code{comment-start-skip} do for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 ordinary text-following comments. Normally these are set properly by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 Fortran mode, so you do not need to change them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 The normal Emacs comment command @kbd{C-x ;} has not been redefined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 It can therefore be used if you use @samp{!} comments, but is useless in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 Fortran mode otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 @kindex C-c ; (Fortran mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 @findex fortran-comment-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 @vindex fortran-comment-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 The command @kbd{C-c ;} (@code{fortran-comment-region}) turns all the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 lines of the region into comments by inserting the string @samp{C$$$} at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 the front of each one. With a numeric arg, the region is turned back into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 live code by deleting @samp{C$$$} from the front of each line. You can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 control the string used for the comments by setting the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 @code{fortran-comment-region}. Note that here we have an example of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 command and a variable with the same name; the two uses of the name never
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 conflict because in Lisp and in Emacs it is always clear from the context
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 which one is referred to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 @node Fortran Columns, Fortran Abbrev, Fortran Comments, Fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 @subsection Columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 @item C-c C-r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 Displays a ``column ruler'' momentarily above the current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (@code{fortran-column-ruler}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 @item C-c C-w
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 Splits the current window horizontally so that it is 72 columns wide.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 This may help you avoid going over that limit (@code{fortran-window-create}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 @kindex C-c C-r (Fortran mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 @findex fortran-column-ruler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 The command @kbd{C-c C-r} (@code{fortran-column-ruler}) shows a column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 ruler above the current line. The comment ruler consists of two lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 of text that show you the locations of columns with special significance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 in Fortran programs. Square brackets show the limits of the columns for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 line numbers, and curly brackets show the limits of the columns for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 statement body. Column numbers appear above them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 Note that the column numbers count from zero, as always in XEmacs. As
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 a result, the numbers may not be those you are familiar with; but the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 actual positions in the line are standard Fortran.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 The text used to display the column ruler is the value of the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 @code{fortran-comment-ruler}. By changing this variable, you can change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 the display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 @kindex C-c C-w (Fortran mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 @findex fortran-window-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 For even more help, use @kbd{C-c C-w} (@code{fortran-window-create}), a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 command which splits the current window horizontally, resulting in a window 72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 columns wide. When you edit in this window, you can immediately see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 when a line gets too wide to be correct Fortran.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 @node Fortran Abbrev,, Fortran Columns, Fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 @subsection Fortran Keyword Abbrevs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 Fortran mode provides many built-in abbrevs for common keywords and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 declarations. These are the same sort of abbrevs that you can define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 yourself. To use them, you must turn on Abbrev mode. @pxref{Abbrevs}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 The built-in abbrevs are unusual in one way: they all start with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 semicolon. You cannot normally use semicolon in an abbrev, but Fortran
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 mode makes this possible by changing the syntax of semicolon to ``word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 constituent''.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 For example, one built-in Fortran abbrev is @samp{;c} for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 @samp{continue}. If you insert @samp{;c} and then insert a punctuation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 character such as a space or a newline, the @samp{;c} changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 automatically to @samp{continue}, provided Abbrev mode is enabled.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 Type @samp{;?} or @samp{;C-h} to display a list of all built-in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 Fortran abbrevs and what they stand for.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 @node Asm Mode,, Fortran, Programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 @section Asm Mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 @cindex Asm mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 Asm mode is a major mode for editing files of assembler code. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 defines these commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 @item @key{TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 @code{tab-to-tab-stop}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 @item @key{LFD}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 Insert a newline and then indent using @code{tab-to-tab-stop}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 @item :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 Insert a colon and then remove the indentation from before the label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 preceding colon. Then do @code{tab-to-tab-stop}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 @item ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 Insert or align a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 The variable @code{asm-comment-char} specifies which character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 starts comments in assembler syntax.