Mercurial > emacs
annotate man/programs.texi @ 34993:2f736da4eaf1
Fix email address of my last entry.
| author | Eli Zaretskii <eliz@gnu.org> |
|---|---|
| date | Tue, 02 Jan 2001 15:39:32 +0000 |
| parents | 1d7bee7283ac |
| children | c760b01b3253 |
| rev | line source |
|---|---|
| 25829 | 1 @c This is part of the Emacs manual. |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
2 @c Copyright (C) 1985,86,87,93,94,95,97,99,2000 Free Software Foundation, Inc. |
| 25829 | 3 @c See file emacs.texi for copying conditions. |
| 4 @node Programs, Building, Text, Top | |
| 5 @chapter Editing Programs | |
| 6 @cindex Lisp editing | |
| 7 @cindex C editing | |
| 8 @cindex program editing | |
| 9 | |
| 10 Emacs has many commands designed to understand the syntax of programming | |
| 11 languages such as Lisp and C. These commands can | |
| 12 | |
| 13 @itemize @bullet | |
| 14 @item | |
| 15 Move over or kill balanced expressions or @dfn{sexps} (@pxref{Lists}). | |
| 16 @item | |
| 17 Move over or mark top-level expressions---@dfn{defuns}, in Lisp; | |
| 18 functions, in C (@pxref{Defuns}). | |
| 19 @item | |
| 20 Show how parentheses balance (@pxref{Matching}). | |
| 21 @item | |
| 22 Insert, kill or align comments (@pxref{Comments}). | |
| 23 @item | |
| 24 Follow the usual indentation conventions of the language | |
| 25 (@pxref{Program Indent}). | |
| 26 @end itemize | |
| 27 | |
| 28 The commands for words, sentences and paragraphs are very useful in | |
| 29 editing code even though their canonical application is for editing | |
| 30 human language text. Most symbols contain words (@pxref{Words}); | |
| 31 sentences can be found in strings and comments (@pxref{Sentences}). | |
| 32 Paragraphs per se don't exist in code, but the paragraph commands are | |
| 33 useful anyway, because programming language major modes define | |
| 34 paragraphs to begin and end at blank lines (@pxref{Paragraphs}). | |
| 35 Judicious use of blank lines to make the program clearer will also | |
| 36 provide useful chunks of text for the paragraph commands to work | |
| 37 on. | |
| 38 | |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
39 @cindex selective display |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
40 @cindex outline |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
41 @cindex folding |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
42 @findex outline-minor-mode |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
43 @cindex outlines |
| 25829 | 44 The selective display feature is useful for looking at the overall |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
45 structure of a function (@pxref{Selective Display}). This feature |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
46 causes only the lines that are indented less than a specified amount to |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
47 appear on the screen. Programming modes often support Outline minor |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
48 mode (@pxref{Outline Mode}). The Foldout package provides |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
49 folding-editor features (@pxref{Foldout}). |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
50 |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
51 The `automatic typing' features may be useful when writing programs. |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
52 @xref{,Autotyping,, autotype, Autotyping}. |
| 25829 | 53 |
| 54 @menu | |
| 55 * Program Modes:: Major modes for editing programs. | |
| 56 * Lists:: Expressions with balanced parentheses. | |
| 57 * List Commands:: The commands for working with list and sexps. | |
| 58 * Defuns:: Each program is made up of separate functions. | |
| 59 There are editing commands to operate on them. | |
| 60 * Program Indent:: Adjusting indentation to show the nesting. | |
| 61 * Matching:: Insertion of a close-delimiter flashes matching open. | |
| 62 * Comments:: Inserting, killing, and aligning comments. | |
| 63 * Balanced Editing:: Inserting two matching parentheses at once, etc. | |
| 64 * Symbol Completion:: Completion on symbol names of your program or language. | |
| 65 * Which Function:: Which Function mode shows which function you are in. | |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
66 * Hideshow:: Displaying blocks selectively. |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
67 * Glasses:: Making identifiersLikeThis more readable. |
| 25829 | 68 * Documentation:: Getting documentation of functions you plan to call. |
| 69 * Change Log:: Maintaining a change history for your program. | |
| 30793 | 70 * Authors:: Maintaining an @file{AUTHORS} file. |
| 25829 | 71 * Tags:: Go direct to any function in your program in one |
| 72 command. Tags remembers which file it is in. | |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
73 * Imenu:: Making buffer indexes as menus. |
| 25829 | 74 * Emerge:: A convenient way of merging two versions of a program. |
| 26264 | 75 * C Modes:: Special commands of C, C++, Objective-C, |
| 25829 | 76 Java, and Pike modes. |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
77 * Fortran:: Fortran mode and its special features. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
78 * Asm Mode:: Asm mode and its special features. |
| 25829 | 79 @end menu |
| 80 | |
| 81 @node Program Modes | |
| 82 @section Major Modes for Programming Languages | |
| 83 | |
| 84 @cindex modes for programming languages | |
| 85 @cindex Perl mode | |
| 86 @cindex Icon mode | |
| 87 @cindex Awk mode | |
| 88 @cindex Makefile mode | |
| 89 @cindex Tcl mode | |
| 90 @cindex CPerl mode | |
| 26106 | 91 @cindex DSSSL mode |
| 92 @cindex Octave mode | |
| 93 @cindex Metafont mode | |
| 94 @cindex Modula2 mode | |
| 95 @cindex Prolog mode | |
| 96 @cindex Simula mode | |
| 97 @cindex VHDL mode | |
| 98 @cindex M4 mode | |
| 99 @cindex Shell-script mode | |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
100 @cindex Delphi mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
101 @cindex PostScript mode |
| 25829 | 102 Emacs also has major modes for the programming languages Lisp, Scheme |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
103 (a variant of Lisp) and the Scheme-based DSSSL expression language, Ada, |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
104 Awk, C, C++, Delphi (Object Pascal), Fortran (free and fixed format), |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
105 Icon, IDLWAVE, |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
106 Java, Metafont (@TeX{}'s companion for font creation), Modula2, |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
107 Objective-C, Octave, Pascal, Perl, Pike, PostScript, Prolog, Simula, |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
108 VHDL, CORBA IDL, and Tcl. |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
109 There is also a major mode for makefiles, called Makefile |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
110 mode. An alternative mode for Perl is called CPerl mode. Modes |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
111 are available for scripts for the common Unix shells, VMS DCL and |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
112 MS-DOS/MS-Windows `BAT' files. In a similar fashion to programming |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
113 languages, modes are provided for editing various sorts of configuration |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
114 files. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
115 |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
116 Separate manuals are available for the modes for Ada (@pxref{Top, , Ada |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
117 Mode, ada-mode, Ada Mode}), C/C++/Objective C/Java/Corba IDL |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
118 (@pxref{Top, , CC Mode, ccmode, CC Mode}) and the IDLWAVE modes |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
119 (@pxref{Top, , IDLWAVE, idlwave, IDLWAVE User Manual}). |
| 25829 | 120 |
| 121 Ideally, a major mode should be implemented for each programming | |
| 122 language that you might want to edit with Emacs; but often the mode for | |
| 123 one language can serve for other syntactically similar languages. The | |
| 124 language modes that exist are those that someone decided to take the | |
| 125 trouble to write. | |
| 126 | |
| 127 There are several forms of Lisp mode, which differ in the way they | |
| 128 interface to Lisp execution. @xref{Executing Lisp}. | |
| 129 | |
| 130 Each of the programming language major modes defines the @key{TAB} key | |
| 131 to run an indentation function that knows the indentation conventions of | |
| 132 that language and updates the current line's indentation accordingly. | |
| 133 For example, in C mode @key{TAB} is bound to @code{c-indent-line}. | |
| 134 @kbd{C-j} is normally defined to do @key{RET} followed by @key{TAB}; | |
| 135 thus, it too indents in a mode-specific fashion. | |
| 136 | |
| 137 @kindex DEL @r{(programming modes)} | |
| 138 @findex backward-delete-char-untabify | |
| 139 In most programming languages, indentation is likely to vary from line to | |
| 140 line. So the major modes for those languages rebind @key{DEL} to treat a | |
| 141 tab as if it were the equivalent number of spaces (using the command | |
| 142 @code{backward-delete-char-untabify}). This makes it possible to rub out | |
| 143 indentation one column at a time without worrying whether it is made up of | |
| 144 spaces or tabs. Use @kbd{C-b C-d} to delete a tab character before point, | |
| 145 in these modes. | |
| 146 | |
| 147 Programming language modes define paragraphs to be separated only by | |
| 148 blank lines, so that the paragraph commands remain useful. Auto Fill mode, | |
| 149 if enabled in a programming language major mode, indents the new lines | |
| 150 which it creates. | |
| 151 | |
| 152 @cindex mode hook | |
| 153 @vindex c-mode-hook | |
| 154 @vindex lisp-mode-hook | |
| 155 @vindex emacs-lisp-mode-hook | |
| 156 @vindex lisp-interaction-mode-hook | |
| 157 @vindex scheme-mode-hook | |
| 158 Turning on a major mode runs a normal hook called the @dfn{mode hook}, | |
| 159 which is the value of a Lisp variable. Each major mode has a mode hook, | |
| 160 and the hook's name is always made from the mode command's name by | |
| 161 adding @samp{-hook}. For example, turning on C mode runs the hook | |
| 162 @code{c-mode-hook}, while turning on Lisp mode runs the hook | |
| 163 @code{lisp-mode-hook}. @xref{Hooks}. | |
| 164 | |
| 165 @node Lists | |
| 166 @section Lists and Sexps | |
| 167 | |
| 168 @cindex Control-Meta | |
| 169 By convention, Emacs keys for dealing with balanced expressions are | |
| 170 usually Control-Meta characters. They tend to be analogous in | |
| 171 function to their Control and Meta equivalents. These commands are | |
| 172 usually thought of as pertaining to expressions in programming | |
| 173 languages, but can be useful with any language in which some sort of | |
| 174 parentheses exist (including human languages). | |
| 175 | |
| 176 @cindex list | |
| 177 @cindex sexp | |
| 178 @cindex expression | |
| 179 These commands fall into two classes. Some deal only with @dfn{lists} | |
| 180 (parenthetical groupings). They see nothing except parentheses, brackets, | |
| 181 braces (whichever ones must balance in the language you are working with), | |
| 182 and escape characters that might be used to quote those. | |
| 183 | |
| 184 The other commands deal with expressions or @dfn{sexps}. The word `sexp' | |
| 185 is derived from @dfn{s-expression}, the ancient term for an expression in | |
| 186 Lisp. But in Emacs, the notion of `sexp' is not limited to Lisp. It | |
| 187 refers to an expression in whatever language your program is written in. | |
| 188 Each programming language has its own major mode, which customizes the | |
| 189 syntax tables so that expressions in that language count as sexps. | |
| 190 | |
| 191 Sexps typically include symbols, numbers, and string constants, as well | |
| 192 as anything contained in parentheses, brackets or braces. | |
| 193 | |
| 194 In languages that use prefix and infix operators, such as C, it is not | |
| 195 possible for all expressions to be sexps. For example, C mode does not | |
| 196 recognize @samp{foo + bar} as a sexp, even though it @emph{is} a C expression; | |
| 197 it recognizes @samp{foo} as one sexp and @samp{bar} as another, with the | |
| 198 @samp{+} as punctuation between them. This is a fundamental ambiguity: | |
| 199 both @samp{foo + bar} and @samp{foo} are legitimate choices for the sexp to | |
| 200 move over if point is at the @samp{f}. Note that @samp{(foo + bar)} is a | |
| 201 single sexp in C mode. | |
| 202 | |
| 203 Some languages have obscure forms of expression syntax that nobody | |
| 204 has bothered to make Emacs understand properly. | |
| 205 | |
| 206 @node List Commands | |
| 207 @section List And Sexp Commands | |
| 208 | |
| 209 @c doublewidecommands | |
| 210 @table @kbd | |
| 211 @item C-M-f | |
| 212 Move forward over a sexp (@code{forward-sexp}). | |
| 213 @item C-M-b | |
| 214 Move backward over a sexp (@code{backward-sexp}). | |
| 215 @item C-M-k | |
| 216 Kill sexp forward (@code{kill-sexp}). | |
| 217 @item C-M-@key{DEL} | |
| 218 Kill sexp backward (@code{backward-kill-sexp}). | |
| 219 @item C-M-u | |
| 220 Move up and backward in list structure (@code{backward-up-list}). | |
| 221 @item C-M-d | |
| 222 Move down and forward in list structure (@code{down-list}). | |
| 223 @item C-M-n | |
| 224 Move forward over a list (@code{forward-list}). | |
| 225 @item C-M-p | |
| 226 Move backward over a list (@code{backward-list}). | |
| 227 @item C-M-t | |
| 228 Transpose expressions (@code{transpose-sexps}). | |
| 229 @item C-M-@@ | |
| 230 Put mark after following expression (@code{mark-sexp}). | |
| 231 @end table | |
| 232 | |
|
34821
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
233 @cindex parentheses, moving across |
|
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
234 @cindex matching parenthesis and braces, moving to |
|
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
235 @cindex braces, moving across |
| 25829 | 236 @kindex C-M-f |
| 237 @kindex C-M-b | |
| 238 @findex forward-sexp | |
| 239 @findex backward-sexp | |
| 240 To move forward over a sexp, use @kbd{C-M-f} (@code{forward-sexp}). If | |
| 241 the first significant character after point is an opening delimiter | |
| 242 (@samp{(} in Lisp; @samp{(}, @samp{[} or @samp{@{} in C), @kbd{C-M-f} | |
| 243 moves past the matching closing delimiter. If the character begins a | |
| 244 symbol, string, or number, @kbd{C-M-f} moves over that. | |
| 245 | |
| 246 The command @kbd{C-M-b} (@code{backward-sexp}) moves backward over a | |
| 247 sexp. The detailed rules are like those above for @kbd{C-M-f}, but with | |
| 248 directions reversed. If there are any prefix characters (single-quote, | |
| 249 backquote and comma, in Lisp) preceding the sexp, @kbd{C-M-b} moves back | |
| 250 over them as well. The sexp commands move across comments as if they | |
| 251 were whitespace in most modes. | |
| 252 | |
| 253 @kbd{C-M-f} or @kbd{C-M-b} with an argument repeats that operation the | |
| 254 specified number of times; with a negative argument, it moves in the | |
| 255 opposite direction. | |
| 256 | |
|
34821
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
257 @cindex deleting parenthesized expressions |
| 25829 | 258 @kindex C-M-k |
| 259 @findex kill-sexp | |
| 260 @kindex C-M-DEL | |
| 261 @findex backward-kill-sexp | |
| 262 Killing a whole sexp can be done with @kbd{C-M-k} (@code{kill-sexp}) | |
| 263 or @kbd{C-M-@key{DEL}} (@code{backward-kill-sexp}). @kbd{C-M-k} kills | |
| 264 the characters that @kbd{C-M-f} would move over, and @kbd{C-M-@key{DEL}} | |
| 265 kills the characters that @kbd{C-M-b} would move over. | |
| 266 | |
| 267 @kindex C-M-n | |
| 268 @kindex C-M-p | |
| 269 @findex forward-list | |
| 270 @findex backward-list | |
| 271 The @dfn{list commands} move over lists, as the sexp commands do, but skip | |
| 272 blithely over any number of other kinds of sexps (symbols, strings, etc.). | |
| 273 They are @kbd{C-M-n} (@code{forward-list}) and @kbd{C-M-p} | |
| 274 (@code{backward-list}). The main reason they are useful is that they | |
| 275 usually ignore comments (since the comments usually do not contain any | |
| 276 lists).@refill | |
| 277 | |
| 278 @kindex C-M-u | |
| 279 @kindex C-M-d | |
| 280 @findex backward-up-list | |
| 281 @findex down-list | |
| 282 @kbd{C-M-n} and @kbd{C-M-p} stay at the same level in parentheses, when | |
| 283 that's possible. To move @emph{up} one (or @var{n}) levels, use @kbd{C-M-u} | |
| 284 (@code{backward-up-list}). | |
| 285 @kbd{C-M-u} moves backward up past one unmatched opening delimiter. A | |
| 286 positive argument serves as a repeat count; a negative argument reverses | |
| 287 direction of motion and also requests repetition, so it moves forward and | |
| 288 up one or more levels.@refill | |
| 289 | |
| 290 To move @emph{down} in list structure, use @kbd{C-M-d} | |
| 291 (@code{down-list}). In Lisp mode, where @samp{(} is the only opening | |
| 292 delimiter, this is nearly the same as searching for a @samp{(}. An | |
| 293 argument specifies the number of levels of parentheses to go down. | |
| 294 | |
|
34821
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
295 @cindex transposition of parenthesized expressions |
| 25829 | 296 @kindex C-M-t |
| 297 @findex transpose-sexps | |
| 298 A somewhat random-sounding command which is nevertheless handy is | |
| 299 @kbd{C-M-t} (@code{transpose-sexps}), which drags the previous sexp | |
| 300 across the next one. An argument serves as a repeat count, and a | |
| 301 negative argument drags backwards (thus canceling out the effect of | |
| 302 @kbd{C-M-t} with a positive argument). An argument of zero, rather than | |
| 303 doing nothing, transposes the sexps ending after point and the mark. | |
| 304 | |
| 305 @kindex C-M-@@ | |
| 306 @findex mark-sexp | |
| 307 To set the region around the next sexp in the buffer, use @kbd{C-M-@@} | |
| 308 (@code{mark-sexp}), which sets mark at the same place that @kbd{C-M-f} | |
| 309 would move to. @kbd{C-M-@@} takes arguments like @kbd{C-M-f}. In | |
| 310 particular, a negative argument is useful for putting the mark at the | |
| 311 beginning of the previous sexp. | |
| 312 | |
| 313 The list and sexp commands' understanding of syntax is completely | |
| 314 controlled by the syntax table. Any character can, for example, be | |
| 315 declared to be an opening delimiter and act like an open parenthesis. | |
| 316 @xref{Syntax}. | |
| 317 | |
| 318 @node Defuns | |
| 319 @section Defuns | |
| 320 @cindex defuns | |
| 321 | |
| 322 In Emacs, a parenthetical grouping at the top level in the buffer is | |
| 323 called a @dfn{defun}. The name derives from the fact that most top-level | |
| 324 lists in a Lisp file are instances of the special form @code{defun}, but | |
| 325 any top-level parenthetical grouping counts as a defun in Emacs parlance | |
| 326 regardless of what its contents are, and regardless of the programming | |
| 327 language in use. For example, in C, the body of a function definition is a | |
| 328 defun. | |
| 329 | |
| 330 @c doublewidecommands | |
| 331 @table @kbd | |
| 332 @item C-M-a | |
| 333 Move to beginning of current or preceding defun | |
| 334 (@code{beginning-of-defun}). | |
| 335 @item C-M-e | |
| 336 Move to end of current or following defun (@code{end-of-defun}). | |
| 337 @item C-M-h | |
| 338 Put region around whole current or following defun (@code{mark-defun}). | |
| 339 @end table | |
| 340 | |
|
34821
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
341 @cindex move to beginning or end of function |
|
1d7bee7283ac
Move the cindex about moving to matching paren into the "List Commands"
Eli Zaretskii <eliz@gnu.org>
parents:
34254
diff
changeset
|
342 @cindex function, move to beginning or end |
| 25829 | 343 @kindex C-M-a |
| 344 @kindex C-M-e | |
| 345 @kindex C-M-h | |
| 346 @findex beginning-of-defun | |
| 347 @findex end-of-defun | |
| 348 @findex mark-defun | |
| 349 The commands to move to the beginning and end of the current defun are | |
| 350 @kbd{C-M-a} (@code{beginning-of-defun}) and @kbd{C-M-e} (@code{end-of-defun}). | |
| 351 | |
| 352 @findex c-mark-function | |
| 353 If you wish to operate on the current defun, use @kbd{C-M-h} | |
| 354 (@code{mark-defun}) which puts point at the beginning and mark at the end | |
| 355 of the current or next defun. For example, this is the easiest way to get | |
| 356 ready to move the defun to a different place in the text. In C mode, | |
| 357 @kbd{C-M-h} runs the function @code{c-mark-function}, which is almost the | |
| 358 same as @code{mark-defun}; the difference is that it backs up over the | |
| 359 argument declarations, function name and returned data type so that the | |
| 360 entire C function is inside the region. @xref{Marking Objects}. | |
| 361 | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
362 @cindex open-parenthesis in leftmost column |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
363 @cindex ( in leftmost column |
| 25829 | 364 Emacs assumes that any open-parenthesis found in the leftmost column |
| 365 is the start of a defun. Therefore, @strong{never put an | |
| 366 open-parenthesis at the left margin in a Lisp file unless it is the | |
| 367 start of a top-level list. Never put an open-brace or other opening | |
| 368 delimiter at the beginning of a line of C code unless it starts the body | |
| 369 of a function.} The most likely problem case is when you want an | |
| 370 opening delimiter at the start of a line inside a string. To avoid | |
| 371 trouble, put an escape character (@samp{\}, in C and Emacs Lisp, | |
| 372 @samp{/} in some other Lisp dialects) before the opening delimiter. It | |
| 373 will not affect the contents of the string. | |
| 374 | |
| 375 In the remotest past, the original Emacs found defuns by moving upward a | |
| 376 level of parentheses until there were no more levels to go up. This always | |
| 377 required scanning all the way back to the beginning of the buffer, even for | |
| 378 a small function. To speed up the operation, Emacs was changed to assume | |
| 379 that any @samp{(} (or other character assigned the syntactic class of | |
| 380 opening-delimiter) at the left margin is the start of a defun. This | |
| 381 heuristic is nearly always right and avoids the costly scan; however, | |
| 382 it mandates the convention described above. | |
| 383 | |
| 384 @node Program Indent | |
| 385 @section Indentation for Programs | |
| 386 @cindex indentation for programs | |
| 387 | |
| 388 The best way to keep a program properly indented is to use Emacs to | |
| 389 reindent it as you change it. Emacs has commands to indent properly | |
| 390 either a single line, a specified number of lines, or all of the lines | |
| 391 inside a single parenthetical grouping. | |
| 392 | |
| 393 @menu | |
| 394 * Basic Indent:: Indenting a single line. | |
| 395 * Multi-line Indent:: Commands to reindent many lines at once. | |
| 396 * Lisp Indent:: Specifying how each Lisp function should be indented. | |
| 397 * C Indent:: Extra features for indenting C and related modes. | |
| 398 * Custom C Indent:: Controlling indentation style for C and related modes. | |
| 399 @end menu | |
| 400 | |
| 401 Emacs also provides a Lisp pretty-printer in the library @code{pp}. | |
| 402 This program reformats a Lisp object with indentation chosen to look nice. | |
| 403 | |
| 404 @node Basic Indent | |
| 405 @subsection Basic Program Indentation Commands | |
| 406 | |
| 407 @c WideCommands | |
| 408 @table @kbd | |
| 409 @item @key{TAB} | |
| 410 Adjust indentation of current line. | |
| 411 @item C-j | |
| 412 Equivalent to @key{RET} followed by @key{TAB} (@code{newline-and-indent}). | |
| 413 @end table | |
| 414 | |
| 415 @kindex TAB @r{(programming modes)} | |
| 416 @findex c-indent-line | |
| 417 @findex lisp-indent-line | |
| 418 The basic indentation command is @key{TAB}, which gives the current line | |
| 419 the correct indentation as determined from the previous lines. The | |
| 420 function that @key{TAB} runs depends on the major mode; it is @code{lisp-indent-line} | |
| 421 in Lisp mode, @code{c-indent-line} in C mode, etc. These functions | |
| 422 understand different syntaxes for different languages, but they all do | |
| 423 about the same thing. @key{TAB} in any programming-language major mode | |
| 424 inserts or deletes whitespace at the beginning of the current line, | |
| 425 independent of where point is in the line. If point is inside the | |
| 426 whitespace at the beginning of the line, @key{TAB} leaves it at the end of | |
| 427 that whitespace; otherwise, @key{TAB} leaves point fixed with respect to | |
| 428 the characters around it. | |
| 429 | |
| 430 Use @kbd{C-q @key{TAB}} to insert a tab at point. | |
| 431 | |
| 432 @kindex C-j | |
| 433 @findex newline-and-indent | |
| 434 When entering lines of new code, use @kbd{C-j} (@code{newline-and-indent}), | |
| 435 which is equivalent to a @key{RET} followed by a @key{TAB}. @kbd{C-j} creates | |
| 436 a blank line and then gives it the appropriate indentation. | |
| 437 | |
| 438 @key{TAB} indents the second and following lines of the body of a | |
| 439 parenthetical grouping each under the preceding one; therefore, if you | |
| 440 alter one line's indentation to be nonstandard, the lines below will | |
| 441 tend to follow it. This behavior is convenient in cases where you have | |
| 442 overridden the standard result of @key{TAB} because you find it | |
| 443 unaesthetic for a particular line. | |
| 444 | |
| 445 Remember that an open-parenthesis, open-brace or other opening delimiter | |
| 446 at the left margin is assumed by Emacs (including the indentation routines) | |
| 447 to be the start of a function. Therefore, you must never have an opening | |
| 448 delimiter in column zero that is not the beginning of a function, not even | |
| 449 inside a string. This restriction is vital for making the indentation | |
| 450 commands fast; you must simply accept it. @xref{Defuns}, for more | |
| 451 information on this. | |
| 452 | |
| 453 @node Multi-line Indent | |
| 454 @subsection Indenting Several Lines | |
| 455 | |
| 456 When you wish to reindent several lines of code which have been altered | |
| 457 or moved to a different level in the list structure, you have several | |
| 458 commands available. | |
| 459 | |
| 460 @table @kbd | |
| 461 @item C-M-q | |
| 462 Reindent all the lines within one list (@code{indent-sexp}). | |
| 463 @item C-u @key{TAB} | |
| 464 Shift an entire list rigidly sideways so that its first line | |
| 465 is properly indented. | |
| 466 @item C-M-\ | |
| 467 Reindent all lines in the region (@code{indent-region}). | |
| 468 @end table | |
| 469 | |
| 470 @kindex C-M-q | |
| 471 @findex indent-sexp | |
| 472 You can reindent the contents of a single list by positioning point | |
| 473 before the beginning of it and typing @kbd{C-M-q} (@code{indent-sexp} in | |
| 474 Lisp mode, @code{c-indent-exp} in C mode; also bound to other suitable | |
| 475 commands in other modes). The indentation of the line the sexp starts on | |
| 476 is not changed; therefore, only the relative indentation within the list, | |
| 477 and not its position, is changed. To correct the position as well, type a | |
| 478 @key{TAB} before the @kbd{C-M-q}. | |
| 479 | |
| 480 @kindex C-u TAB | |
| 481 If the relative indentation within a list is correct but the | |
| 482 indentation of its first line is not, go to that line and type @kbd{C-u | |
| 483 @key{TAB}}. @key{TAB} with a numeric argument reindents the current | |
| 484 line as usual, then reindents by the same amount all the lines in the | |
| 485 grouping starting on the current line. In other words, it reindents the | |
| 486 whole grouping rigidly as a unit. It is clever, though, and does not | |
| 487 alter lines that start inside strings, or C preprocessor lines when in C | |
| 488 mode. | |
| 489 | |
| 490 Another way to specify the range to be reindented is with the region. | |
| 491 The command @kbd{C-M-\} (@code{indent-region}) applies @key{TAB} to | |
| 492 every line whose first character is between point and mark. | |
| 493 | |
| 494 @node Lisp Indent | |
| 495 @subsection Customizing Lisp Indentation | |
| 496 @cindex customizing Lisp indentation | |
| 497 | |
| 498 The indentation pattern for a Lisp expression can depend on the function | |
| 499 called by the expression. For each Lisp function, you can choose among | |
| 500 several predefined patterns of indentation, or define an arbitrary one with | |
| 501 a Lisp program. | |
| 502 | |
| 503 The standard pattern of indentation is as follows: the second line of the | |
| 504 expression is indented under the first argument, if that is on the same | |
| 505 line as the beginning of the expression; otherwise, the second line is | |
| 506 indented underneath the function name. Each following line is indented | |
| 507 under the previous line whose nesting depth is the same. | |
| 508 | |
| 509 @vindex lisp-indent-offset | |
| 510 If the variable @code{lisp-indent-offset} is non-@code{nil}, it overrides | |
| 511 the usual indentation pattern for the second line of an expression, so that | |
| 512 such lines are always indented @code{lisp-indent-offset} more columns than | |
| 513 the containing list. | |
| 514 | |
| 515 @vindex lisp-body-indent | |
| 516 The standard pattern is overridden for certain functions. Functions | |
| 517 whose names start with @code{def} always indent the second line by | |
| 518 @code{lisp-body-indent} extra columns beyond the open-parenthesis | |
| 519 starting the expression. | |
| 520 | |
| 521 The standard pattern can be overridden in various ways for individual | |
| 522 functions, according to the @code{lisp-indent-function} property of the | |
| 523 function name. There are four possibilities for this property: | |
| 524 | |
| 525 @table @asis | |
| 526 @item @code{nil} | |
| 527 This is the same as no property; the standard indentation pattern is used. | |
| 528 @item @code{defun} | |
| 529 The pattern used for function names that start with @code{def} is used for | |
| 530 this function also. | |
| 531 @item a number, @var{number} | |
| 532 The first @var{number} arguments of the function are | |
| 533 @dfn{distinguished} arguments; the rest are considered the @dfn{body} | |
| 534 of the expression. A line in the expression is indented according to | |
| 535 whether the first argument on it is distinguished or not. If the | |
| 536 argument is part of the body, the line is indented @code{lisp-body-indent} | |
| 537 more columns than the open-parenthesis starting the containing | |
| 538 expression. If the argument is distinguished and is either the first | |
| 539 or second argument, it is indented @emph{twice} that many extra columns. | |
| 540 If the argument is distinguished and not the first or second argument, | |
| 541 the standard pattern is followed for that line. | |
| 542 @item a symbol, @var{symbol} | |
| 543 @var{symbol} should be a function name; that function is called to | |
| 544 calculate the indentation of a line within this expression. The | |
| 545 function receives two arguments: | |
| 546 @table @asis | |
| 547 @item @var{state} | |
| 548 The value returned by @code{parse-partial-sexp} (a Lisp primitive for | |
| 549 indentation and nesting computation) when it parses up to the | |
| 550 beginning of this line. | |
| 551 @item @var{pos} | |
| 552 The position at which the line being indented begins. | |
| 553 @end table | |
| 554 @noindent | |
| 555 It should return either a number, which is the number of columns of | |
| 556 indentation for that line, or a list whose car is such a number. The | |
| 557 difference between returning a number and returning a list is that a | |
| 558 number says that all following lines at the same nesting level should | |
| 559 be indented just like this one; a list says that following lines might | |
| 560 call for different indentations. This makes a difference when the | |
| 561 indentation is being computed by @kbd{C-M-q}; if the value is a | |
| 562 number, @kbd{C-M-q} need not recalculate indentation for the following | |
| 563 lines until the end of the list. | |
| 564 @end table | |
| 565 | |
| 566 @node C Indent | |
| 567 @subsection Commands for C Indentation | |
| 568 | |
| 569 Here are the commands for indentation in C mode and related modes: | |
| 570 | |
| 571 @table @code | |
| 572 @item C-c C-q | |
| 573 @kindex C-c C-q @r{(C mode)} | |
| 574 @findex c-indent-defun | |
| 575 Reindent the current top-level function definition or aggregate type | |
| 576 declaration (@code{c-indent-defun}). | |
| 577 | |
| 578 @item C-M-q | |
| 579 @kindex C-M-q @r{(C mode)} | |
| 580 @findex c-indent-exp | |
| 581 Reindent each line in the balanced expression that follows point | |
| 582 (@code{c-indent-exp}). A prefix argument inhibits error checking and | |
| 583 warning messages about invalid syntax. | |
| 584 | |
| 585 @item @key{TAB} | |
| 586 @findex c-indent-command | |
| 587 Reindent the current line, and/or in some cases insert a tab character | |
| 588 (@code{c-indent-command}). | |
| 589 | |
| 590 If @code{c-tab-always-indent} is @code{t}, this command always reindents | |
| 591 the current line and does nothing else. This is the default. | |
| 592 | |
| 593 If that variable is @code{nil}, this command reindents the current line | |
| 594 only if point is at the left margin or in the line's indentation; | |
| 595 otherwise, it inserts a tab (or the equivalent number of spaces, | |
| 596 if @code{indent-tabs-mode} is @code{nil}). | |
| 597 | |
| 598 Any other value (not @code{nil} or @code{t}) means always reindent the | |
| 599 line, and also insert a tab if within a comment, a string, or a | |
| 600 preprocessor directive. | |
| 601 | |
| 602 @item C-u @key{TAB} | |
| 603 Reindent the current line according to its syntax; also rigidly reindent | |
| 604 any other lines of the expression that starts on the current line. | |
| 605 @xref{Multi-line Indent}. | |
| 606 @end table | |
| 607 | |
| 608 To reindent the whole current buffer, type @kbd{C-x h C-M-\}. This | |
| 609 first selects the whole buffer as the region, then reindents that | |
| 610 region. | |
| 611 | |
| 612 To reindent the current block, use @kbd{C-M-u C-M-q}. This moves | |
| 613 to the front of the block and then reindents it all. | |
| 614 | |
| 615 @node Custom C Indent | |
| 616 @subsection Customizing C Indentation | |
| 617 | |
| 618 C mode and related modes use a simple yet flexible mechanism for | |
| 619 customizing indentation. The mechanism works in two steps: first it | |
| 620 classifies the line syntactically according to its contents and context; | |
| 621 second, it associates each kind of syntactic construct with an | |
| 622 indentation offset which you can customize. | |
| 623 | |
| 624 @menu | |
| 625 * Syntactic Analysis:: | |
| 626 * Indentation Calculation:: | |
| 627 * Changing Indent Style:: | |
| 628 * Syntactic Symbols:: | |
| 629 * Variables for C Indent:: | |
| 630 * C Indent Styles:: | |
| 631 @end menu | |
| 632 | |
| 633 @node Syntactic Analysis | |
| 634 @subsubsection Step 1---Syntactic Analysis | |
| 635 @cindex syntactic analysis | |
| 636 | |
| 637 In the first step, the C indentation mechanism looks at the line | |
| 638 before the one you are currently indenting and determines the syntactic | |
| 639 components of the construct on that line. It builds a list of these | |
| 640 syntactic components, each of which contains a @dfn{syntactic symbol} | |
| 641 and sometimes also a buffer position. Some syntactic symbols describe | |
| 642 grammatical elements, for example @code{statement} and | |
| 643 @code{substatement}; others describe locations amidst grammatical | |
| 644 elements, for example @code{class-open} and @code{knr-argdecl}. | |
| 645 | |
| 646 Conceptually, a line of C code is always indented relative to the | |
| 647 indentation of some line higher up in the buffer. This is represented | |
| 648 by the buffer positions in the syntactic component list. | |
| 649 | |
| 650 Here is an example. Suppose we have the following code in a C++ mode | |
| 651 buffer (the line numbers don't actually appear in the buffer): | |
| 652 | |
| 653 @example | |
| 654 1: void swap (int& a, int& b) | |
| 655 2: @{ | |
| 656 3: int tmp = a; | |
| 657 4: a = b; | |
| 658 5: b = tmp; | |
| 659 6: @} | |
| 660 @end example | |
| 661 | |
| 662 If you type @kbd{C-c C-s} (which runs the command | |
| 663 @code{c-show-syntactic-information}) on line 4, it shows the result of | |
| 664 the indentation mechanism for that line: | |
| 665 | |
| 666 @example | |
| 667 ((statement . 32)) | |
| 668 @end example | |
| 669 | |
| 670 This indicates that the line is a statement and it is indented | |
| 671 relative to buffer position 32, which happens to be the @samp{i} in | |
| 672 @code{int} on line 3. If you move the cursor to line 3 and type | |
| 673 @kbd{C-c C-s}, it displays this: | |
| 674 | |
| 675 @example | |
| 676 ((defun-block-intro . 28)) | |
| 677 @end example | |
| 678 | |
| 679 This indicates that the @code{int} line is the first statement in a | |
| 680 block, and is indented relative to buffer position 28, which is the | |
| 681 brace just after the function header. | |
| 682 | |
| 683 @noindent | |
| 684 Here is another example: | |
| 685 | |
| 686 @example | |
| 687 1: int add (int val, int incr, int doit) | |
| 688 2: @{ | |
| 689 3: if (doit) | |
| 690 4: @{ | |
| 691 5: return (val + incr); | |
| 692 6: @} | |
| 693 7: return (val); | |
| 694 8: @} | |
| 695 @end example | |
| 696 | |
| 697 @noindent | |
| 698 Typing @kbd{C-c C-s} on line 4 displays this: | |
| 699 | |
| 700 @example | |
| 701 ((substatement-open . 43)) | |
| 702 @end example | |
| 703 | |
| 704 This says that the brace @emph{opens} a substatement block. By the | |
| 705 way, a @dfn{substatement} indicates the line after an @code{if}, | |
| 706 @code{else}, @code{while}, @code{do}, @code{switch}, @code{for}, | |
| 707 @code{try}, @code{catch}, @code{finally}, or @code{synchronized} | |
| 708 statement. | |
| 709 | |
| 710 @cindex syntactic component | |
| 711 @cindex syntactic symbol | |
| 712 @vindex c-syntactic-context | |
| 713 Within the C indentation commands, after a line has been analyzed | |
| 714 syntactically for indentation, the variable @code{c-syntactic-context} | |
| 715 contains a list that describes the results. Each element in this list | |
| 716 is a @dfn{syntactic component}: a cons cell containing a syntactic | |
| 717 symbol and (optionally) its corresponding buffer position. There may be | |
| 718 several elements in a component list; typically only one element has a | |
| 719 buffer position. | |
| 720 | |
| 721 @node Indentation Calculation | |
| 722 @subsubsection Step 2---Indentation Calculation | |
| 723 @cindex Indentation Calculation | |
| 724 | |
| 725 The C indentation mechanism calculates the indentation for the current | |
| 726 line using the list of syntactic components, @code{c-syntactic-context}, | |
| 727 derived from syntactic analysis. Each component is a cons cell that | |
| 728 contains a syntactic symbol and may also contain a buffer position. | |
| 729 | |
| 730 Each component contributes to the final total indentation of the line | |
| 731 in two ways. First, the syntactic symbol identifies an element of | |
| 732 @code{c-offsets-alist}, which is an association list mapping syntactic | |
| 733 symbols into indentation offsets. Each syntactic symbol's offset adds | |
| 734 to the total indentation. Second, if the component includes a buffer | |
| 735 position, the column number of that position adds to the indentation. | |
| 736 All these offsets and column numbers, added together, give the total | |
| 737 indentation. | |
| 738 | |
| 739 The following examples demonstrate the workings of the C indentation | |
| 740 mechanism: | |
| 741 | |
| 742 @example | |
| 743 1: void swap (int& a, int& b) | |
| 744 2: @{ | |
| 745 3: int tmp = a; | |
| 746 4: a = b; | |
| 747 5: b = tmp; | |
| 748 6: @} | |
| 749 @end example | |
| 750 | |
| 751 Suppose that point is on line 3 and you type @key{TAB} to reindent the | |
| 752 line. As explained above (@pxref{Syntactic Analysis}), the syntactic | |
| 753 component list for that line is: | |
| 754 | |
| 755 @example | |
| 756 ((defun-block-intro . 28)) | |
| 757 @end example | |
| 758 | |
| 759 In this case, the indentation calculation first looks up | |
| 760 @code{defun-block-intro} in the @code{c-offsets-alist} alist. Suppose | |
| 761 that it finds the integer 2; it adds this to the running total | |
| 762 (initialized to zero), yielding a updated total indentation of 2 spaces. | |
| 763 | |
| 764 The next step is to find the column number of buffer position 28. | |
| 765 Since the brace at buffer position 28 is in column zero, this adds 0 to | |
| 766 the running total. Since this line has only one syntactic component, | |
| 767 the total indentation for the line is 2 spaces. | |
| 768 | |
| 769 @example | |
| 770 1: int add (int val, int incr, int doit) | |
| 771 2: @{ | |
| 772 3: if (doit) | |
| 773 4: @{ | |
| 774 5: return(val + incr); | |
| 775 6: @} | |
| 776 7: return(val); | |
| 777 8: @} | |
| 778 @end example | |
| 779 | |
| 780 If you type @key{TAB} on line 4, the same process is performed, but | |
| 781 with different data. The syntactic component list for this line is: | |
| 782 | |
| 783 @example | |
| 784 ((substatement-open . 43)) | |
| 785 @end example | |
| 786 | |
| 787 Here, the indentation calculation's first job is to look up the | |
| 788 symbol @code{substatement-open} in @code{c-offsets-alist}. Let's assume | |
| 789 that the offset for this symbol is 2. At this point the running total | |
| 790 is 2 (0 + 2 = 2). Then it adds the column number of buffer position 43, | |
| 791 which is the @samp{i} in @code{if} on line 3. This character is in | |
| 792 column 2 on that line. Adding this yields a total indentation of 4 | |
| 793 spaces. | |
| 794 | |
| 795 @vindex c-strict-syntax-p | |
| 796 If a syntactic symbol in the analysis of a line does not appear in | |
| 797 @code{c-offsets-alist}, it is ignored; if in addition the variable | |
| 798 @code{c-strict-syntax-p} is non-@code{nil}, it is an error. | |
| 799 | |
| 800 @node Changing Indent Style | |
| 801 @subsubsection Changing Indentation Style | |
| 802 | |
| 803 There are two ways to customize the indentation style for the C-like | |
| 804 modes. First, you can select one of several predefined styles, each of | |
| 805 which specifies offsets for all the syntactic symbols. For more | |
| 806 flexibility, you can customize the handling of individual syntactic | |
| 807 symbols. @xref{Syntactic Symbols}, for a list of all defined syntactic | |
| 808 symbols. | |
| 809 | |
| 810 @table @kbd | |
| 811 @item M-x c-set-style @key{RET} @var{style} @key{RET} | |
| 812 Select predefined indentation style @var{style}. Type @kbd{?} when | |
| 813 entering @var{style} to see a list of supported styles; to find out what | |
| 814 a style looks like, select it and reindent some C code. | |
| 815 | |
| 816 @item C-c C-o @var{symbol} @key{RET} @var{offset} @key{RET} | |
| 817 Set the indentation offset for syntactic symbol @var{symbol} | |
| 818 (@code{c-set-offset}). The second argument @var{offset} specifies the | |
| 819 new indentation offset. | |
| 820 @end table | |
| 821 | |
| 822 The @code{c-offsets-alist} variable controls the amount of | |
| 823 indentation to give to each syntactic symbol. Its value is an | |
| 824 association list, and each element of the list has the form | |
| 825 @code{(@var{syntactic-symbol} . @var{offset})}. By changing the offsets | |
| 826 for various syntactic symbols, you can customize indentation in fine | |
| 827 detail. To change this alist, use @code{c-set-offset} (see below). | |
| 828 | |
| 829 Each offset value in @code{c-offsets-alist} can be an integer, a | |
| 830 function or variable name, a list, or one of the following symbols: @code{+}, | |
| 831 @code{-}, @code{++}, @code{--}, @code{*}, or @code{/}, indicating positive or negative | |
| 832 multiples of the variable @code{c-basic-offset}. Thus, if you want to | |
| 833 change the levels of indentation to be 3 spaces instead of 2 spaces, set | |
| 834 @code{c-basic-offset} to 3. | |
| 835 | |
| 836 Using a function as the offset value provides the ultimate flexibility | |
| 837 in customizing indentation. The function is called with a single | |
| 838 argument containing the @code{cons} of the syntactic symbol and | |
| 839 the buffer position, if any. The function should return an integer | |
| 840 offset. | |
| 26264 | 841 |
| 25829 | 842 If the offset value is a list, its elements are processed according |
| 843 to the rules above until a non-@code{nil} value is found. That value is | |
| 844 then added to the total indentation in the normal manner. The primary | |
| 845 use for this is to combine the results of several functions. | |
| 846 | |
| 847 @kindex C-c C-o @r{(C mode)} | |
| 848 @findex c-set-offset | |
| 849 The command @kbd{C-c C-o} (@code{c-set-offset}) is the easiest way to | |
| 850 set offsets, both interactively or in your @file{~/.emacs} file. First | |
| 851 specify the syntactic symbol, then the offset you want. @xref{Syntactic | |
| 852 Symbols}, for a list of valid syntactic symbols and their meanings. | |
| 853 | |
| 854 @node Syntactic Symbols | |
| 855 @subsubsection Syntactic Symbols | |
| 856 | |
| 857 Here is a table of valid syntactic symbols for indentation in C and | |
| 858 related modes, with their syntactic meanings. Normally, most of these | |
| 859 symbols are assigned offsets in @code{c-offsets-alist}. | |
| 860 | |
| 861 @table @code | |
| 862 @item string | |
| 863 Inside a multi-line string. | |
| 864 | |
| 865 @item c | |
| 866 Inside a multi-line C style block comment. | |
| 867 | |
| 868 @item defun-open | |
| 869 On a brace that opens a function definition. | |
| 870 | |
| 871 @item defun-close | |
| 872 On a brace that closes a function definition. | |
| 873 | |
| 874 @item defun-block-intro | |
| 875 In the first line in a top-level defun. | |
| 876 | |
| 877 @item class-open | |
| 878 On a brace that opens a class definition. | |
| 879 | |
| 880 @item class-close | |
| 881 On a brace that closes a class definition. | |
| 882 | |
| 883 @item inline-open | |
| 884 On a brace that opens an in-class inline method. | |
| 885 | |
| 886 @item inline-close | |
| 887 On a brace that closes an in-class inline method. | |
| 888 | |
| 889 @item extern-lang-open | |
| 890 On a brace that opens an external language block. | |
| 891 | |
| 892 @item extern-lang-close | |
| 893 On a brace that closes an external language block. | |
| 894 | |
| 895 @item func-decl-cont | |
| 896 The region between a function definition's argument list and the defun | |
| 897 opening brace (excluding K&R function definitions). In C, you cannot | |
| 898 put anything but whitespace and comments between them; in C++ and Java, | |
| 899 @code{throws} declarations and other things can appear in this context. | |
| 900 | |
| 901 @item knr-argdecl-intro | |
| 902 On the first line of a K&R C argument declaration. | |
| 903 | |
| 904 @item knr-argdecl | |
| 905 In one of the subsequent lines in a K&R C argument declaration. | |
| 906 | |
| 907 @item topmost-intro | |
| 908 On the first line in a topmost construct definition. | |
| 909 | |
| 910 @item topmost-intro-cont | |
| 911 On the topmost definition continuation lines. | |
| 912 | |
| 913 @item member-init-intro | |
| 914 On the first line in a member initialization list. | |
| 915 | |
| 916 @item member-init-cont | |
| 917 On one of the subsequent member initialization list lines. | |
| 918 | |
| 919 @item inher-intro | |
| 920 On the first line of a multiple inheritance list. | |
| 921 | |
| 922 @item inher-cont | |
| 923 On one of the subsequent multiple inheritance lines. | |
| 924 | |
| 925 @item block-open | |
| 926 On a statement block open brace. | |
| 927 | |
| 928 @item block-close | |
| 929 On a statement block close brace. | |
| 930 | |
| 931 @item brace-list-open | |
| 932 On the opening brace of an @code{enum} or @code{static} array list. | |
| 933 | |
| 934 @item brace-list-close | |
| 935 On the closing brace of an @code{enum} or @code{static} array list. | |
| 936 | |
| 937 @item brace-list-intro | |
| 938 On the first line in an @code{enum} or @code{static} array list. | |
| 939 | |
| 940 @item brace-list-entry | |
| 941 On one of the subsequent lines in an @code{enum} or @code{static} array | |
| 942 list. | |
| 943 | |
| 944 @item brace-entry-open | |
| 945 On one of the subsequent lines in an @code{enum} or @code{static} array | |
| 946 list, when the line begins with an open brace. | |
| 947 | |
| 948 @item statement | |
| 949 On an ordinary statement. | |
| 950 | |
| 951 @item statement-cont | |
| 952 On a continuation line of a statement. | |
| 953 | |
| 954 @item statement-block-intro | |
| 955 On the first line in a new statement block. | |
| 956 | |
| 957 @item statement-case-intro | |
| 958 On the first line in a @code{case} ``block.'' | |
| 959 | |
| 960 @item statement-case-open | |
| 961 On the first line in a @code{case} block starting with brace. | |
| 962 | |
| 963 @item inexpr-statement | |
| 964 On a statement block inside an expression. This is used for a GNU | |
| 965 extension to the C language, and for Pike special functions that take a | |
| 966 statement block as an argument. | |
| 967 | |
| 968 @item inexpr-class | |
| 969 On a class definition inside an expression. This is used for anonymous | |
| 970 classes and anonymous array initializers in Java. | |
| 971 | |
| 972 @item substatement | |
| 973 On the first line after an @code{if}, @code{while}, @code{for}, | |
| 974 @code{do}, or @code{else}. | |
| 975 | |
| 976 @item substatement-open | |
| 977 On the brace that opens a substatement block. | |
| 978 | |
| 979 @item case-label | |
| 980 On a @code{case} or @code{default} label. | |
| 981 | |
| 982 @item access-label | |
| 983 On a C++ @code{private}, @code{protected}, or @code{public} access label. | |
| 984 | |
| 985 @item label | |
| 986 On any ordinary label. | |
| 987 | |
| 988 @item do-while-closure | |
| 989 On the @code{while} that ends a @code{do}-@code{while} construct. | |
| 990 | |
| 991 @item else-clause | |
| 992 On the @code{else} of an @code{if}-@code{else} construct. | |
| 993 | |
| 994 @item catch-clause | |
| 995 On the @code{catch} and @code{finally} lines in | |
| 996 @code{try}@dots{}@code{catch} constructs in C++ and Java. | |
| 997 | |
| 998 @item comment-intro | |
| 999 On a line containing only a comment introduction. | |
| 1000 | |
| 1001 @item arglist-intro | |
| 1002 On the first line in an argument list. | |
| 1003 | |
| 1004 @item arglist-cont | |
| 1005 On one of the subsequent argument list lines when no arguments follow on | |
| 1006 the same line as the arglist opening parenthesis. | |
| 1007 | |
| 1008 @item arglist-cont-nonempty | |
| 1009 On one of the subsequent argument list lines when at least one argument | |
| 1010 follows on the same line as the arglist opening parenthesis. | |
| 1011 | |
| 1012 @item arglist-close | |
| 1013 On the closing parenthesis of an argument list. | |
| 1014 | |
| 1015 @item stream-op | |
| 1016 On one of the lines continuing a stream operator construct. | |
| 1017 | |
| 1018 @item inclass | |
| 1019 On a construct that is nested inside a class definition. The | |
| 1020 indentation is relative to the open brace of the class definition. | |
| 1021 | |
| 1022 @item inextern-lang | |
| 1023 On a construct that is nested inside an external language block. | |
| 1024 | |
| 1025 @item inexpr-statement | |
| 1026 On the first line of statement block inside an expression. This is used | |
| 1027 for the GCC extension to C that uses the syntax @code{(@{ @dots{} @})}. | |
| 1028 It is also used for the special functions that takes a statement block | |
| 1029 as an argument in Pike. | |
| 1030 | |
| 1031 @item inexpr-class | |
| 1032 On the first line of a class definition inside an expression. This is | |
| 1033 used for anonymous classes and anonymous array initializers in Java. | |
| 1034 | |
| 1035 @item cpp-macro | |
| 1036 On the start of a cpp macro. | |
| 1037 | |
| 1038 @item friend | |
| 1039 On a C++ @code{friend} declaration. | |
| 1040 | |
| 1041 @item objc-method-intro | |
| 1042 On the first line of an Objective-C method definition. | |
| 1043 | |
| 1044 @item objc-method-args-cont | |
| 1045 On one of the lines continuing an Objective-C method definition. | |
| 1046 | |
| 1047 @item objc-method-call-cont | |
| 1048 On one of the lines continuing an Objective-C method call. | |
| 1049 | |
| 1050 @item inlambda | |
| 1051 Like @code{inclass}, but used inside lambda (i.e. anonymous) functions. Only | |
| 1052 used in Pike. | |
| 1053 | |
| 1054 @item lambda-intro-cont | |
| 1055 On a line continuing the header of a lambda function, between the | |
| 1056 @code{lambda} keyword and the function body. Only used in Pike. | |
| 1057 @end table | |
| 1058 | |
| 1059 @node Variables for C Indent | |
| 1060 @subsubsection Variables for C Indentation | |
| 1061 | |
| 1062 This section describes additional variables which control the | |
| 1063 indentation behavior of C mode and related mode. | |
| 1064 | |
| 1065 @table @code | |
| 1066 @item c-offsets-alist | |
| 1067 @vindex c-offsets-alist | |
| 1068 Association list of syntactic symbols and their indentation offsets. | |
| 1069 You should not set this directly, only with @code{c-set-offset}. | |
| 1070 @xref{Changing Indent Style}, for details. | |
| 1071 | |
| 1072 @item c-style-alist | |
| 1073 @vindex c-style-alist | |
| 1074 Variable for defining indentation styles; see below. | |
| 1075 | |
| 1076 @item c-basic-offset | |
| 1077 @vindex c-basic-offset | |
| 1078 Amount of basic offset used by @code{+} and @code{-} symbols in | |
| 26264 | 1079 @code{c-offsets-alist}.@refill |
| 25829 | 1080 |
| 1081 @item c-special-indent-hook | |
| 1082 @vindex c-special-indent-hook | |
| 1083 Hook for user-defined special indentation adjustments. This hook is | |
| 1084 called after a line is indented by C mode and related modes. | |
| 1085 @end table | |
| 1086 | |
| 1087 The variable @code{c-style-alist} specifies the predefined indentation | |
| 1088 styles. Each element has form @code{(@var{name} | |
| 1089 @var{variable-setting}@dots{})}, where @var{name} is the name of the | |
| 1090 style. Each @var{variable-setting} has the form @code{(@var{variable} | |
| 1091 . @var{value})}; @var{variable} is one of the customization variables | |
| 1092 used by C mode, and @var{value} is the value for that variable when | |
| 1093 using the selected style. | |
| 1094 | |
| 1095 When @var{variable} is @code{c-offsets-alist}, that is a special case: | |
| 1096 @var{value} is appended to the front of the value of @code{c-offsets-alist} | |
| 1097 instead of replacing that value outright. Therefore, it is not necessary | |
| 1098 for @var{value} to specify each and every syntactic symbol---only those | |
| 1099 for which the style differs from the default. | |
| 1100 | |
| 1101 The indentation of lines containing only comments is also affected by | |
| 1102 the variable @code{c-comment-only-line-offset} (@pxref{Comments in C}). | |
| 1103 | |
| 1104 @node C Indent Styles | |
| 1105 @subsubsection C Indentation Styles | |
| 1106 @cindex c indentation styles | |
| 1107 | |
| 1108 A @dfn{C style} is a collection of indentation style customizations. | |
| 1109 Emacs comes with several predefined indentation styles for C and related | |
| 1110 modes, including @code{gnu}, @code{k&r}, @code{bsd}, @code{stroustrup}, | |
| 1111 @code{linux}, @code{python}, @code{java}, @code{whitesmith}, | |
|
28627
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1112 @code{ellemtel}, @code{cc-mode}, and @code{user}. |
| 25829 | 1113 |
| 1114 @findex c-set-style | |
| 1115 @vindex c-default-style | |
| 1116 To choose the style you want, use the command @kbd{M-x c-set-style}. | |
| 1117 Specify a style name as an argument (case is not significant in C style | |
| 1118 names). The chosen style only affects newly visited buffers, not those | |
| 1119 you are already editing. You can also set the variable | |
| 1120 @code{c-default-style} to specify the style for various major modes. | |
| 1121 Its value should be an alist, in which each element specifies one major | |
| 1122 mode and which indentation style to use for it. For example, | |
| 1123 | |
| 1124 @example | |
| 1125 (setq c-default-style | |
| 1126 '((java-mode . "java") (other . "gnu"))) | |
| 1127 @end example | |
| 1128 | |
| 1129 @noindent | |
| 1130 specifies an explicit choice for Java mode, and the default @samp{gnu} | |
| 1131 style for the other C-like modes. | |
| 1132 | |
|
28627
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1133 The style @code{gnu} defines the formatting recommend by the GNU |
|
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1134 Project; it is the default, so as to encourage the indentation we |
| 30049 | 1135 recommend. If you make changes in variables such as |
| 1136 @code{c-basic-offset} and @code{c-offsets-alist} in your @file{~/.emacs} | |
| 1137 file, they will however take precedence. | |
|
28627
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1138 |
| 25829 | 1139 @findex c-add-style |
| 1140 To define a new C indentation style, call the function | |
| 1141 @code{c-add-style}: | |
| 1142 | |
| 1143 @example | |
| 1144 (c-add-style @var{name} @var{values} @var{use-now}) | |
| 1145 @end example | |
| 1146 | |
| 1147 @noindent | |
| 1148 Here @var{name} is the name of the new style (a string), and | |
| 1149 @var{values} is an alist whose elements have the form | |
| 1150 @code{(@var{variable} . @var{value})}. The variables you specify should | |
| 1151 be among those documented in @ref{Variables for C Indent}. | |
| 1152 | |
|
28627
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1153 If @var{use-now} is non-@code{nil}, @code{c-add-style} selects the new |
|
1f6ba3e73fe9
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
28391
diff
changeset
|
1154 style after defining it. |
| 25829 | 1155 |
| 1156 @node Matching | |
| 1157 @section Automatic Display Of Matching Parentheses | |
| 1158 @cindex matching parentheses | |
| 1159 @cindex parentheses, displaying matches | |
| 1160 | |
| 1161 The Emacs parenthesis-matching feature is designed to show | |
| 1162 automatically how parentheses match in the text. Whenever you type a | |
| 1163 self-inserting character that is a closing delimiter, the cursor moves | |
| 1164 momentarily to the location of the matching opening delimiter, provided | |
| 1165 that is on the screen. If it is not on the screen, some text near it is | |
| 1166 displayed in the echo area. Either way, you can tell what grouping is | |
| 1167 being closed off. | |
| 1168 | |
| 1169 In Lisp, automatic matching applies only to parentheses. In C, it | |
| 1170 applies to braces and brackets too. Emacs knows which characters to regard | |
| 1171 as matching delimiters based on the syntax table, which is set by the major | |
| 1172 mode. @xref{Syntax}. | |
| 1173 | |
| 1174 If the opening delimiter and closing delimiter are mismatched---such as | |
| 1175 in @samp{[x)}---a warning message is displayed in the echo area. The | |
| 1176 correct matches are specified in the syntax table. | |
| 1177 | |
| 1178 @vindex blink-matching-paren | |
| 1179 @vindex blink-matching-paren-distance | |
| 1180 @vindex blink-matching-delay | |
| 1181 Three variables control parenthesis match display. | |
| 1182 @code{blink-matching-paren} turns the feature on or off; @code{nil} | |
| 1183 turns it off, but the default is @code{t} to turn match display on. | |
| 1184 @code{blink-matching-delay} says how many seconds to wait; the default | |
| 1185 is 1, but on some systems it is useful to specify a fraction of a | |
| 1186 second. @code{blink-matching-paren-distance} specifies how many | |
| 1187 characters back to search to find the matching opening delimiter. If | |
| 1188 the match is not found in that far, scanning stops, and nothing is | |
| 1189 displayed. This is to prevent scanning for the matching delimiter from | |
| 1190 wasting lots of time when there is no match. The default is 12,000. | |
| 1191 | |
| 1192 @cindex Show Paren mode | |
|
34122
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1193 @cindex highlighting matching parentheses |
| 25829 | 1194 @findex show-paren-mode |
|
34122
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1195 You can also request a more powerful alternative kind of automatic |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1196 parenthesis matching by enabling Show Paren mode. This mode turns off |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1197 the usual kind of matching parenthesis display and instead uses |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1198 highlighting to show what matches. Whenever point is after a close |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1199 parenthesis, the close parenthesis and its matching open parenthesis are |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1200 both highlighted; otherwise, if point is before an open parenthesis, the |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1201 matching close parenthesis is highlighted. (There is no need to |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1202 highlight the open parenthesis after point because the cursor appears on |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1203 top of that character.) Use the command @kbd{M-x show-paren-mode} to |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1204 enable or disable this mode. |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1205 |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1206 By default, @code{show-paren-mode} uses colors to highlight the |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1207 parentheses. However, if your display doesn't support colors, you can |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1208 customize the faces @code{show-paren-match-face} and |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1209 @code{show-paren-mismatch-face} to use other attributes, such as bold or |
|
c42bb7d4437b
Don't tell that show-paren only works on X. Explain how to customize
Eli Zaretskii <eliz@gnu.org>
parents:
31188
diff
changeset
|
1210 underline. @xref{Face Customization}. |
| 25829 | 1211 |
| 1212 @node Comments | |
| 1213 @section Manipulating Comments | |
| 1214 @cindex comments | |
| 1215 | |
| 1216 Because comments are such an important part of programming, Emacs | |
| 1217 provides special commands for editing and inserting comments. | |
| 1218 | |
| 1219 @menu | |
| 1220 * Comment Commands:: | |
| 1221 * Multi-Line Comments:: | |
| 1222 * Options for Comments:: | |
| 1223 @end menu | |
| 1224 | |
| 1225 @node Comment Commands | |
| 1226 @subsection Comment Commands | |
| 1227 | |
| 1228 @kindex M-; | |
| 1229 @cindex indentation for comments | |
| 1230 @findex indent-for-comment | |
|
31025
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1231 @findex comment-dwim |
| 25829 | 1232 |
| 1233 The comment commands insert, kill and align comments. | |
| 1234 | |
| 1235 @c WideCommands | |
| 1236 @table @kbd | |
| 1237 @item M-; | |
|
31025
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1238 Call the comment command that is appropriate for the context |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1239 (@code{comment-dwim}). |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1240 @item M-x indent-for-comment |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1241 Insert or align comment. |
| 25829 | 1242 @item C-x ; |
| 1243 Set comment column (@code{set-comment-column}). | |
| 1244 @item C-u - C-x ; | |
|
31025
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1245 Kill comment on current line (@code{comment-kill}). |
| 25829 | 1246 @item C-M-j |
| 1247 Like @key{RET} followed by inserting and aligning a comment | |
| 1248 (@code{indent-new-comment-line}). | |
| 1249 @item M-x comment-region | |
| 1250 Add or remove comment delimiters on all the lines in the region. | |
| 1251 @end table | |
| 1252 | |
|
31025
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1253 The command that creates a comment is @kbd{M-x indent-for-comment}. |
| 25829 | 1254 If there is no comment already on the line, a new comment is created, |
| 1255 aligned at a specific column called the @dfn{comment column}. The comment | |
| 1256 is created by inserting the string Emacs thinks comments should start with | |
| 1257 (the value of @code{comment-start}; see below). Point is left after that | |
| 1258 string. If the text of the line extends past the comment column, then the | |
| 1259 indentation is done to a suitable boundary (usually, at least one space is | |
| 1260 inserted). If the major mode has specified a string to terminate comments, | |
| 1261 that is inserted after point, to keep the syntax valid. | |
| 1262 | |
|
31025
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1263 @kbd{M-x indent-for-comment} can also be used to align an existing |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1264 comment. If a line already contains the string that starts comments, |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1265 then @kbd{M-x indent-for-comment} just moves point after it and |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1266 reindents it to the conventional place. Exception: comments starting in |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1267 column 0 are not moved. |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1268 |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1269 @kbd{M-;} (@code{comment-dwim}) conveniently combines |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1270 @code{indent-for-comment} with @code{comment-region} and |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1271 @code{uncomment-region}, described below in @ref{Multi-Line Comments}, |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1272 as appropriate for the current context. If the region is active and the |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1273 Transient Mark mode is on (@pxref{Transient Mark}), @kbd{M-;} invokes |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1274 @code{comment-region}, unless the region consists only of comments, in |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1275 which case it invokes @code{uncomment-region}. Otherwise, if the |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1276 current line is empty, @kbd{M-;} inserts a comment and indents it. If |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1277 the current line is not empty, @kbd{M-;} invokes @code{comment-kill} if |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1278 a numeric argument was given, else it reindents the comment on the |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1279 current line. (The @dfn{dwim} in @code{comment-dwim} is an acronym for |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1280 ``Do What I Mean''.) |
| 25829 | 1281 |
| 1282 Some major modes have special rules for indenting certain kinds of | |
| 1283 comments in certain contexts. For example, in Lisp code, comments which | |
| 1284 start with two semicolons are indented as if they were lines of code, | |
| 1285 instead of at the comment column. Comments which start with three | |
| 1286 semicolons are supposed to start at the left margin. Emacs understands | |
| 1287 these conventions by indenting a double-semicolon comment using @key{TAB}, | |
| 1288 and by not changing the indentation of a triple-semicolon comment at all. | |
| 1289 | |
| 1290 @example | |
| 1291 ;; This function is just an example | |
| 1292 ;;; Here either two or three semicolons are appropriate. | |
| 1293 (defun foo (x) | |
| 1294 ;;; And now, the first part of the function: | |
| 1295 ;; The following line adds one. | |
| 1296 (1+ x)) ; This line adds one. | |
| 1297 @end example | |
| 1298 | |
| 1299 In C code, a comment preceded on its line by nothing but whitespace | |
| 1300 is indented like a line of code. | |
| 1301 | |
| 1302 Even when an existing comment is properly aligned, @kbd{M-;} is still | |
| 1303 useful for moving directly to the start of the comment. | |
| 1304 | |
| 1305 @kindex C-u - C-x ; | |
| 1306 @findex kill-comment | |
|
31025
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1307 @findex comment-kill |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1308 @kbd{C-u - C-x ;} (@code{comment-kill}) kills the comment on the current line, |
| 25829 | 1309 if there is one. The indentation before the start of the comment is killed |
| 1310 as well. If there does not appear to be a comment in the line, nothing is | |
| 1311 done. To reinsert the comment on another line, move to the end of that | |
| 1312 line, do @kbd{C-y}, and then do @kbd{M-;} to realign it. Note that | |
| 1313 @kbd{C-u - C-x ;} is not a distinct key; it is @kbd{C-x ;} (@code{set-comment-column}) | |
| 1314 with a negative argument. That command is programmed so that when it | |
|
31025
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1315 receives a negative argument it calls @code{comment-kill}. However, |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1316 @code{comment-kill} is a valid command which you could bind directly to a |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1317 key if you wanted to. (For compatibility with previous versions, |
|
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1318 @code{kill-comment} is provided as an alias to @code{comment-kill}.) |
| 25829 | 1319 |
| 1320 @node Multi-Line Comments | |
| 1321 @subsection Multiple Lines of Comments | |
| 1322 | |
| 1323 @kindex C-M-j | |
| 1324 @cindex blank lines in programs | |
| 1325 @findex indent-new-comment-line | |
| 1326 If you are typing a comment and wish to continue it on another line, | |
| 1327 you can use the command @kbd{C-M-j} (@code{indent-new-comment-line}). | |
| 1328 This terminates the comment you are typing, creates a new blank line | |
| 1329 afterward, and begins a new comment indented under the old one. When | |
| 1330 Auto Fill mode is on, going past the fill column while typing a comment | |
| 1331 causes the comment to be continued in just this fashion. If point is | |
| 1332 not at the end of the line when @kbd{C-M-j} is typed, the text on | |
| 1333 the rest of the line becomes part of the new comment line. | |
| 1334 | |
| 1335 @findex comment-region | |
| 1336 To turn existing lines into comment lines, use the @kbd{M-x | |
| 1337 comment-region} command. It adds comment delimiters to the lines that start | |
| 1338 in the region, thus commenting them out. With a negative argument, it | |
| 1339 does the opposite---it deletes comment delimiters from the lines in the | |
| 1340 region. | |
| 1341 | |
| 1342 With a positive argument, @code{comment-region} duplicates the last | |
| 1343 character of the comment start sequence it adds; the argument specifies | |
| 1344 how many copies of the character to insert. Thus, in Lisp mode, | |
| 1345 @kbd{C-u 2 M-x comment-region} adds @samp{;;} to each line. Duplicating | |
| 1346 the comment delimiter is a way of calling attention to the comment. It | |
| 1347 can also affect how the comment is indented. In Lisp, for proper | |
| 1348 indentation, you should use an argument of two, if between defuns, and | |
| 1349 three, if within a defun. | |
| 1350 | |
| 1351 @vindex comment-padding | |
| 1352 The variable @code{comment-padding} specifies how many spaces | |
| 1353 @code{comment-region} should insert on each line between the | |
| 1354 comment delimiter and the line's original text. The default is 1. | |
| 1355 | |
| 1356 @node Options for Comments | |
| 1357 @subsection Options Controlling Comments | |
| 1358 | |
| 1359 @vindex comment-column | |
| 1360 @kindex C-x ; | |
| 1361 @findex set-comment-column | |
| 1362 The comment column is stored in the variable @code{comment-column}. You | |
| 1363 can set it to a number explicitly. Alternatively, the command @kbd{C-x ;} | |
| 1364 (@code{set-comment-column}) sets the comment column to the column point is | |
| 1365 at. @kbd{C-u C-x ;} sets the comment column to match the last comment | |
| 1366 before point in the buffer, and then does a @kbd{M-;} to align the | |
| 1367 current line's comment under the previous one. Note that @kbd{C-u - C-x ;} | |
|
31025
45d3aa851fff
Document comment-dwim and the new binding of M-;.
Eli Zaretskii <eliz@gnu.org>
parents:
30968
diff
changeset
|
1368 runs the function @code{comment-kill} as described above. |
| 25829 | 1369 |
| 1370 The variable @code{comment-column} is per-buffer: setting the variable | |
| 1371 in the normal fashion affects only the current buffer, but there is a | |
| 1372 default value which you can change with @code{setq-default}. | |
| 1373 @xref{Locals}. Many major modes initialize this variable for the | |
| 1374 current buffer. | |
| 1375 | |
| 1376 @vindex comment-start-skip | |
| 1377 The comment commands recognize comments based on the regular | |
| 1378 expression that is the value of the variable @code{comment-start-skip}. | |
| 1379 Make sure this regexp does not match the null string. It may match more | |
| 1380 than the comment starting delimiter in the strictest sense of the word; | |
| 1381 for example, in C mode the value of the variable is @code{@t{"/\\*+ | |
| 1382 *"}}, which matches extra stars and spaces after the @samp{/*} itself. | |
| 1383 (Note that @samp{\\} is needed in Lisp syntax to include a @samp{\} in | |
| 1384 the string, which is needed to deny the first star its special meaning | |
| 1385 in regexp syntax. @xref{Regexps}.) | |
| 1386 | |
| 1387 @vindex comment-start | |
| 1388 @vindex comment-end | |
| 1389 When a comment command makes a new comment, it inserts the value of | |
| 1390 @code{comment-start} to begin it. The value of @code{comment-end} is | |
| 1391 inserted after point, so that it will follow the text that you will insert | |
| 1392 into the comment. In C mode, @code{comment-start} has the value | |
| 1393 @w{@code{"/* "}} and @code{comment-end} has the value @w{@code{" */"}}. | |
| 1394 | |
| 1395 @vindex comment-multi-line | |
| 1396 The variable @code{comment-multi-line} controls how @kbd{C-M-j} | |
| 1397 (@code{indent-new-comment-line}) behaves when used inside a comment. If | |
| 1398 @code{comment-multi-line} is @code{nil}, as it normally is, then the | |
| 1399 comment on the starting line is terminated and a new comment is started | |
| 1400 on the new following line. If @code{comment-multi-line} is not | |
| 1401 @code{nil}, then the new following line is set up as part of the same | |
| 1402 comment that was found on the starting line. This is done by not | |
| 1403 inserting a terminator on the old line, and not inserting a starter on | |
| 1404 the new line. In languages where multi-line comments work, the choice | |
| 1405 of value for this variable is a matter of taste. | |
| 1406 | |
| 1407 @vindex comment-indent-function | |
| 1408 The variable @code{comment-indent-function} should contain a function | |
| 1409 that will be called to compute the indentation for a newly inserted | |
| 1410 comment or for aligning an existing comment. It is set differently by | |
| 1411 various major modes. The function is called with no arguments, but with | |
| 1412 point at the beginning of the comment, or at the end of a line if a new | |
| 1413 comment is to be inserted. It should return the column in which the | |
| 1414 comment ought to start. For example, in Lisp mode, the indent hook | |
| 1415 function bases its decision on how many semicolons begin an existing | |
| 1416 comment, and on the code in the preceding lines. | |
| 1417 | |
| 1418 @node Balanced Editing | |
| 1419 @section Editing Without Unbalanced Parentheses | |
| 1420 | |
| 1421 @table @kbd | |
| 1422 @item M-( | |
| 1423 Put parentheses around next sexp(s) (@code{insert-parentheses}). | |
| 1424 @item M-) | |
| 1425 Move past next close parenthesis and reindent | |
| 1426 (@code{move-past-close-and-reindent}). | |
| 1427 @end table | |
| 1428 | |
| 1429 @kindex M-( | |
| 1430 @kindex M-) | |
| 1431 @findex insert-parentheses | |
| 1432 @findex move-past-close-and-reindent | |
| 1433 The commands @kbd{M-(} (@code{insert-parentheses}) and @kbd{M-)} | |
| 1434 (@code{move-past-close-and-reindent}) are designed to facilitate a style | |
| 1435 of editing which keeps parentheses balanced at all times. @kbd{M-(} | |
| 1436 inserts a pair of parentheses, either together as in @samp{()}, or, if | |
| 1437 given an argument, around the next several sexps. It leaves point after | |
| 1438 the open parenthesis. The command @kbd{M-)} moves past the close | |
| 1439 parenthesis, deleting any indentation preceding it, and indenting with | |
| 1440 @kbd{C-j} after it. | |
| 1441 | |
| 1442 For example, instead of typing @kbd{( F O O )}, you can type @kbd{M-( | |
| 1443 F O O}, which has the same effect except for leaving the cursor before | |
| 1444 the close parenthesis. | |
| 1445 | |
| 1446 @vindex parens-require-spaces | |
| 1447 @kbd{M-(} may insert a space before the open parenthesis, depending on | |
| 1448 the syntax class of the preceding character. Set | |
| 1449 @code{parens-require-spaces} to @code{nil} value if you wish to inhibit | |
| 1450 this. | |
| 1451 | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1452 @findex check-parens |
|
31035
64a11267ce9a
check-parens can also find unbalanced quotes in strings.
Eli Zaretskii <eliz@gnu.org>
parents:
31033
diff
changeset
|
1453 @cindex unbalanced parentheses and quotes |
|
64a11267ce9a
check-parens can also find unbalanced quotes in strings.
Eli Zaretskii <eliz@gnu.org>
parents:
31033
diff
changeset
|
1454 You can use @kbd{M-x check-parens} to find any unbalanced parentheses |
|
64a11267ce9a
check-parens can also find unbalanced quotes in strings.
Eli Zaretskii <eliz@gnu.org>
parents:
31033
diff
changeset
|
1455 and unbalanced quotes in strings in a buffer. |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1456 |
| 25829 | 1457 @node Symbol Completion |
| 1458 @section Completion for Symbol Names | |
| 1459 @cindex completion (symbol names) | |
| 1460 | |
| 1461 Usually completion happens in the minibuffer. But one kind of completion | |
| 1462 is available in all buffers: completion for symbol names. | |
| 1463 | |
| 1464 @kindex M-TAB | |
| 1465 The character @kbd{M-@key{TAB}} runs a command to complete the partial | |
| 1466 symbol before point against the set of meaningful symbol names. Any | |
| 1467 additional characters determined by the partial name are inserted at | |
| 1468 point. | |
| 1469 | |
| 1470 If the partial name in the buffer has more than one possible completion | |
| 1471 and they have no additional characters in common, a list of all possible | |
| 1472 completions is displayed in another window. | |
| 1473 | |
| 1474 @cindex completion using tags | |
| 1475 @cindex tags completion | |
| 1476 @cindex Info index completion | |
| 1477 @findex complete-symbol | |
| 1478 In most programming language major modes, @kbd{M-@key{TAB}} runs the | |
| 1479 command @code{complete-symbol}, which provides two kinds of completion. | |
| 1480 Normally it does completion based on a tags table (@pxref{Tags}); with a | |
| 1481 numeric argument (regardless of the value), it does completion based on | |
| 1482 the names listed in the Info file indexes for your language. Thus, to | |
| 1483 complete the name of a symbol defined in your own program, use | |
| 1484 @kbd{M-@key{TAB}} with no argument; to complete the name of a standard | |
| 1485 library function, use @kbd{C-u M-@key{TAB}}. Of course, Info-based | |
| 1486 completion works only if there is an Info file for the standard library | |
| 1487 functions of your language, and only if it is installed at your site. | |
| 1488 | |
| 1489 @cindex Lisp symbol completion | |
| 1490 @cindex completion in Lisp | |
| 1491 @findex lisp-complete-symbol | |
| 1492 In Emacs-Lisp mode, the name space for completion normally consists of | |
| 1493 nontrivial symbols present in Emacs---those that have function | |
| 1494 definitions, values or properties. However, if there is an | |
| 1495 open-parenthesis immediately before the beginning of the partial symbol, | |
| 1496 only symbols with function definitions are considered as completions. | |
| 1497 The command which implements this is @code{lisp-complete-symbol}. | |
| 1498 | |
| 1499 In Text mode and related modes, @kbd{M-@key{TAB}} completes words | |
| 1500 based on the spell-checker's dictionary. @xref{Spelling}. | |
| 1501 | |
| 1502 @node Which Function | |
| 1503 @section Which Function Mode | |
| 1504 | |
| 1505 Which Function mode is a minor mode that displays the current function | |
| 1506 name in the mode line, as you move around in a buffer. | |
| 1507 | |
| 1508 @findex which-function-mode | |
| 1509 @vindex which-func-modes | |
| 1510 To enable (or disable) Which Function mode, use the command @kbd{M-x | |
| 1511 which-function-mode}. This command is global; it applies to all | |
| 1512 buffers, both existing ones and those yet to be created. However, this | |
| 1513 only affects certain major modes, those listed in the value of | |
| 1514 @code{which-func-modes}. (If the value is @code{t}, then Which Function | |
| 1515 mode applies to all major modes that know how to support it---which are | |
| 1516 the major modes that support Imenu.) | |
| 1517 | |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1518 @node Hideshow |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1519 @section Hideshow minor mode |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1520 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1521 @findex hs-minor-mode |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1522 Hideshow minor mode provides selective display of blocks. Use @kbd{M-x |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1523 hs-minor-mode} to toggle the mode or add @code{hs-minor-mode} to the |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1524 hook for major modes with which you want to use it and which support it. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1525 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1526 Blocks are defined dependent on the mode. In C mode or C++ mode, they |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1527 are delimited by braces, while in Lisp-ish modes they are delimited by |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1528 parens. Multi-line comments can also be hidden. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1529 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1530 @findex hs-hide-all |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1531 @findex hs-hide-block |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1532 @findex hs-show-all |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1533 @findex hs-show-block |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1534 @findex hs-show-region |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1535 @findex hs-hide-level |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1536 @findex hs-minor-mode |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1537 @kindex C-c h |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1538 @kindex C-c s |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1539 @kindex C-c H |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1540 @kindex C-c S |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1541 @kindex C-c R |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1542 @kindex C-c L |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1543 @kindex S-mouse-2 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1544 The mode provides the commands @kbd{C-c h} (@kbd{M-x hs-hide-all}), |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1545 @kbd{C-c s} (@kbd{M-x hs-hide-block}), @kbd{C-c H} (@kbd{M-x |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1546 hs-show-all}), @kbd{C-c S} (@kbd{M-x hs-show-block}), @kbd{C-c R} |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1547 (@kbd{M-x hs-show-region}) and @kbd{C-c L} (@kbd{M-x hs-hide-level}) |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1548 with obvious functions and @kbd{S-mouse-2} toggles hiding of a block |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1549 with the mouse. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1550 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1551 @vindex hs-hide-comments-when-hiding-all |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1552 @vindex hs-show-hidden-short-form |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1553 @vindex hs-isearch-open |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1554 @vindex hs-special-modes-alist |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1555 Hideshow is customized by the variables |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1556 @table @code |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1557 @item hs-hide-comments-when-hiding-all |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1558 Specifies whether @kbd{hs-hide-all} should hide comments too. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1559 @item hs-show-hidden-short-form |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1560 Specifies whether or not the last line in a form is omitted (saving |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1561 screen space). |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1562 @item hs-isearch-open |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1563 Specifies what kind of hidden blocks to open in Isearch mode. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1564 @item hs-special-modes-alist |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1565 Initializes Hideshow variables for different modes. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1566 @end table |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1567 |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1568 @node Glasses |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1569 @section Glasses minor mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1570 @cindex Glasses mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1571 @cindex identifiers, unreadable |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1572 @cindex StudlyCaps |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1573 @findex glasses-mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1574 |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1575 Glasses minor mode makes @samp{unreadableIdentifiersLikeThis} readable |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1576 by displaying underscores between all the pairs of lower and upper |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1577 English letters or by emboldening the capitals. The text is not |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1578 altered, only the display, so that you can use this mode on code written |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1579 with such a convention for separating words in identifiers without |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1580 modifying the code. It can be customized under the group |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1581 @samp{glasses}. You can use it by adding @code{glasses-mode} to the |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1582 mode hook of appropriate programming modes. |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1583 |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1584 |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1585 @node Documentation |
| 25829 | 1586 @section Documentation Commands |
| 1587 | |
| 1588 As you edit Lisp code to be run in Emacs, the commands @kbd{C-h f} | |
| 1589 (@code{describe-function}) and @kbd{C-h v} (@code{describe-variable}) can | |
| 1590 be used to print documentation of functions and variables that you want to | |
| 1591 call. These commands use the minibuffer to read the name of a function or | |
| 1592 variable to document, and display the documentation in a window. | |
| 1593 | |
| 1594 For extra convenience, these commands provide default arguments based on | |
| 1595 the code in the neighborhood of point. @kbd{C-h f} sets the default to the | |
| 1596 function called in the innermost list containing point. @kbd{C-h v} uses | |
| 1597 the symbol name around or adjacent to point as its default. | |
| 1598 | |
| 1599 @cindex Eldoc mode | |
| 1600 @findex eldoc-mode | |
| 1601 For Emacs Lisp code, you can also use Eldoc mode. This minor mode | |
| 1602 constantly displays in the echo area the argument list for the function | |
| 1603 being called at point. (In other words, it finds the function call that | |
| 1604 point is contained in, and displays the argument list of that function.) | |
| 1605 Eldoc mode applies in Emacs Lisp and Lisp Interaction modes only. Use | |
| 1606 the command @kbd{M-x eldoc-mode} to enable or disable this feature. | |
| 1607 | |
| 1608 @findex info-lookup-symbol | |
| 1609 @findex info-lookup-file | |
| 1610 @kindex C-h C-i | |
| 1611 For C, Lisp, and other languages, you can use @kbd{C-h C-i} | |
| 1612 (@code{info-lookup-symbol}) to view the Info documentation for a symbol. | |
| 1613 You specify the symbol with the minibuffer; by default, it uses the | |
| 1614 symbol that appears in the buffer at point. The major mode determines | |
| 1615 where to look for documentation for the symbol---which Info files and | |
| 1616 which indices. You can also use @kbd{M-x info-lookup-file} to look for | |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1617 documentation for a file name. Currently the modes supported by |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1618 Info-lookup are: Awk, Autoconf, Bison, C, Emacs Lisp, LaTeX, M4, |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1619 Makefile, Octave, Perl, Scheme and Texinfo. The relevant Info files |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1620 mostly must be obtained separately, typically from the appropriate GNU |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
1621 package. |
| 25829 | 1622 |
| 1623 @findex manual-entry | |
|
28838
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1624 @cindex manual pages |
| 25829 | 1625 You can read the ``man page'' for an operating system command, library |
| 1626 function, or system call, with the @kbd{M-x manual-entry} command. It | |
| 1627 runs the @code{man} program to format the man page, and runs it | |
| 1628 asynchronously if your system permits, so that you can keep on editing | |
| 1629 while the page is being formatted. (MS-DOS and MS-Windows 3 do not | |
| 1630 permit asynchronous subprocesses, so on these systems you cannot edit | |
| 1631 while Emacs waits for @code{man} to exit.) The result goes in a buffer | |
| 1632 named @samp{*Man @var{topic}*}. These buffers use a special major mode, | |
| 1633 Man mode, that facilitates scrolling and examining other manual pages. | |
| 1634 For details, type @kbd{C-h m} while in a man page buffer. | |
| 1635 | |
|
29840
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1636 @cindex sections of manual pages |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1637 Man pages are subdivided into @dfn{sections}, and some man pages have |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1638 identical names, but belong to different sections. To read a man page |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1639 from a certain section, type @kbd{@var{topic}(@var{section})} or |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1640 @kbd{@var{section} @var{topic}} when @kbd{M-x manual-entry} prompts for |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1641 the topic. For example, to read the man page for the C library function |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1642 @code{chmod} (as opposed to a command by the same name), type @kbd{M-x |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1643 manual-entry @key{RET} chmod(2v) @key{RET}} (assuming @code{chmod} is in |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1644 section @code{2v}). |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1645 |
|
29854
ca9f6085d33b
(Documentation): Describe how man pages with
Eli Zaretskii <eliz@gnu.org>
parents:
29840
diff
changeset
|
1646 If you do not specify a section, the results depend on how the |
|
ca9f6085d33b
(Documentation): Describe how man pages with
Eli Zaretskii <eliz@gnu.org>
parents:
29840
diff
changeset
|
1647 @code{man} command works on your system. Some of them display only the |
|
ca9f6085d33b
(Documentation): Describe how man pages with
Eli Zaretskii <eliz@gnu.org>
parents:
29840
diff
changeset
|
1648 first man page they find, others display all the man pages, and you can |
|
ca9f6085d33b
(Documentation): Describe how man pages with
Eli Zaretskii <eliz@gnu.org>
parents:
29840
diff
changeset
|
1649 page between them with the @kbd{M-n} and @kbd{M-p} keys. The mode line |
|
ca9f6085d33b
(Documentation): Describe how man pages with
Eli Zaretskii <eliz@gnu.org>
parents:
29840
diff
changeset
|
1650 shows how many manual pages are available in the Man buffer. |
|
ca9f6085d33b
(Documentation): Describe how man pages with
Eli Zaretskii <eliz@gnu.org>
parents:
29840
diff
changeset
|
1651 |
| 25829 | 1652 @vindex Man-fontify-manpage-flag |
| 1653 For a long man page, setting the faces properly can take substantial | |
| 1654 time. By default, Emacs uses faces in man pages if Emacs can display | |
| 1655 different fonts or colors. You can turn off use of faces in man pages | |
| 1656 by setting the variable @code{Man-fontify-manpage-flag} to @code{nil}. | |
| 1657 | |
| 1658 @findex Man-fontify-manpage | |
| 1659 If you insert the text of a man page into an Emacs buffer in some | |
| 1660 other fashion, you can use the command @kbd{M-x Man-fontify-manpage} to | |
| 1661 perform the same conversions that @kbd{M-x manual-entry} does. | |
| 1662 | |
|
28838
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1663 @findex woman |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1664 @cindex manual pages, on MS-DOS/MS-Windows |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1665 An alternative way of reading manual pages is the @kbd{M-x woman} |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1666 command@footnote{The name of the command, @code{woman}, is an acronym |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1667 for ``w/o (without) man'', since it doesn't use the @code{man} |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1668 program.}. Unlike @kbd{M-x man}, it does not run any external programs |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1669 to format and display the man pages, instead it does that entirely in |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1670 Emacs Lisp. Thus, it is useful on systems such as MS-Windows, where the |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1671 @code{man} program and the programs it runs are not readily available. |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1672 When invoked, @kbd{M-x woman} prompts for a name of a manual page and |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1673 provides completion based on the list of manual pages that are installed |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1674 on your machine; the list of available manual pages is computed |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1675 automatically the first time you invoke @code{woman}. The word at point |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1676 in the current buffer is used to suggest the default name of the manual |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1677 page. |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1678 |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1679 With a numeric argument, @kbd{M-x woman} recomputes the list of the |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1680 manual pages used for completion. This is useful if you add or delete |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1681 manual pages. |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1682 |
|
29840
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1683 If you type a name of a manual page and @kbd{M-x woman} finds that |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1684 several manual pages by the same name exist in different sections, it |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1685 pops up a window with possible candidates asking you to choose one of |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1686 them. |
|
53f07097269e
(Documentation Commands): Explain how to get a man page from
Eli Zaretskii <eliz@gnu.org>
parents:
29107
diff
changeset
|
1687 |
|
28838
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1688 @vindex woman-manpath |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1689 By default, @kbd{M-x woman} looks up the manual pages in directories |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1690 listed by the @code{MANPATH} environment variable. (If @code{MANPATH} |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1691 is not set, @code{woman} uses a suitable default value, which can be |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1692 customized.) More precisely, @code{woman} looks for subdirectories that |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1693 match the shell wildcard @file{man*} in each one of these directories, |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1694 and tries to find the manual pages in those subdirectories. When first |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1695 invoked, @kbd{M-x woman} converts the value of @code{MANPATH} to a list |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1696 of directory names and stores that list in the @code{woman-manpath} |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1697 variable. By changing the value of this variable, you can customize the |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1698 list of directories where @code{woman} looks for manual pages. |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1699 |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1700 @vindex woman-path |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1701 In addition, you can augment the list of directories searched by |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1702 @code{woman} by setting the value of the @code{woman-path} variable. |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1703 This variable should hold a list of specific directories which |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1704 @code{woman} should search, in addition to those in |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1705 @code{woman-manpath}. Unlike @code{woman-manpath}, the directories in |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1706 @code{woman-path} are searched for the manual pages, not for @file{man*} |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1707 subdirectories. |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1708 |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1709 @findex woman-find-file |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1710 Occasionally, you might need to display manual pages that are not in |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1711 any of the directories listed by @code{woman-manpath} and |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1712 @code{woman-path}. The @kbd{M-x woman-find-file} command prompts for a |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1713 name of a manual page file, with completion, and then formats and |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1714 displays that file like @kbd{M-x woman} does. |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1715 |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1716 @vindex woman-dired-keys |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1717 First time you invoke @kbd{M-x woman}, it defines the Dired @kbd{W} |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1718 key to run the @code{woman-find-file} command on the current line's |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1719 file. You can disable this by setting the variable |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1720 @code{woman-dired-keys} to @code{nil}. @xref{Dired}. In addition, the |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1721 Tar-mode @kbd{w} key is bound to @code{woman-find-file} on the current |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1722 line's archive member. |
|
e3d33a77c205
(Documentation): Document woman.el features.
Eli Zaretskii <eliz@gnu.org>
parents:
28627
diff
changeset
|
1723 |
|
30668
9c402b90b24d
(Documentation): Add an xref to woman's own manual.
Eli Zaretskii <eliz@gnu.org>
parents:
30049
diff
changeset
|
1724 For more information about setting up and using @kbd{M-x woman}, see |
|
9c402b90b24d
(Documentation): Add an xref to woman's own manual.
Eli Zaretskii <eliz@gnu.org>
parents:
30049
diff
changeset
|
1725 @ref{Top, WoMan, Browse UN*X Manual Pages WithOut Man, woman, The WoMan |
|
9c402b90b24d
(Documentation): Add an xref to woman's own manual.
Eli Zaretskii <eliz@gnu.org>
parents:
30049
diff
changeset
|
1726 Manual}. |
|
9c402b90b24d
(Documentation): Add an xref to woman's own manual.
Eli Zaretskii <eliz@gnu.org>
parents:
30049
diff
changeset
|
1727 |
| 25829 | 1728 Eventually the GNU project hopes to replace most man pages with |
| 1729 better-organized manuals that you can browse with Info. @xref{Misc | |
| 1730 Help}. Since this process is only partially completed, it is still | |
| 1731 useful to read manual pages. | |
| 1732 | |
| 1733 @node Change Log | |
| 1734 @section Change Logs | |
| 1735 | |
| 1736 @cindex change log | |
| 1737 @kindex C-x 4 a | |
| 1738 @findex add-change-log-entry-other-window | |
| 1739 The Emacs command @kbd{C-x 4 a} adds a new entry to the change log | |
| 1740 file for the file you are editing | |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1741 (@code{add-change-log-entry-other-window}). If that file is actually a |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1742 backup file, it makes an entry appropriate for the file's parent. This |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1743 is useful for making log entries by comparing a version with deleted |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1744 functions. |
| 25829 | 1745 |
| 1746 A change log file contains a chronological record of when and why you | |
| 1747 have changed a program, consisting of a sequence of entries describing | |
| 1748 individual changes. Normally it is kept in a file called | |
| 1749 @file{ChangeLog} in the same directory as the file you are editing, or | |
| 1750 one of its parent directories. A single @file{ChangeLog} file can | |
| 1751 record changes for all the files in its directory and all its | |
| 1752 subdirectories. | |
| 1753 | |
| 1754 A change log entry starts with a header line that contains your name, | |
| 1755 your email address (taken from the variable @code{user-mail-address}), | |
| 1756 and the current date and time. Aside from these header lines, every | |
| 1757 line in the change log starts with a space or a tab. The bulk of the | |
| 1758 entry consists of @dfn{items}, each of which starts with a line starting | |
| 1759 with whitespace and a star. Here are two entries, both dated in May | |
| 1760 1993, each with two items: | |
| 1761 | |
| 1762 @iftex | |
| 1763 @medbreak | |
| 1764 @end iftex | |
| 1765 @smallexample | |
| 1766 1993-05-25 Richard Stallman <rms@@gnu.org> | |
| 1767 | |
| 1768 * man.el: Rename symbols `man-*' to `Man-*'. | |
| 1769 (manual-entry): Make prompt string clearer. | |
| 1770 | |
| 1771 * simple.el (blink-matching-paren-distance): | |
| 1772 Change default to 12,000. | |
| 1773 | |
| 1774 1993-05-24 Richard Stallman <rms@@gnu.org> | |
| 1775 | |
| 1776 * vc.el (minor-mode-map-alist): Don't use it if it's void. | |
| 1777 (vc-cancel-version): Doc fix. | |
| 1778 @end smallexample | |
| 1779 | |
| 1780 One entry can describe several changes; each change should have its | |
| 1781 own item. Normally there should be a blank line between items. When | |
| 1782 items are related (parts of the same change, in different places), group | |
| 1783 them by leaving no blank line between them. The second entry above | |
| 1784 contains two items grouped in this way. | |
| 1785 | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1786 @vindex add-log-keep-changes-together |
| 25829 | 1787 @kbd{C-x 4 a} visits the change log file and creates a new entry |
| 1788 unless the most recent entry is for today's date and your name. It also | |
| 1789 creates a new item for the current file. For many languages, it can | |
| 1790 even guess the name of the function or other object that was changed. | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1791 When the option @code{add-log-keep-changes-together} is set, @kbd{C-x 4 |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1792 a} adds to any existing entry for the file rather than starting a new |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1793 entry. |
| 25829 | 1794 |
|
31052
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1795 @vindex change-log-version-info-enabled |
|
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1796 @vindex change-log-version-number-regexp-list |
|
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1797 @cindex file version in change log entries |
|
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1798 If the value of the variable @code{change-log-version-info-enabled} is |
|
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1799 non-nil, the file's version number is automatically added to change log |
|
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1800 entries. The search for the file's version number is performed based on |
|
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1801 regular expressions from the variable |
| 31188 | 1802 @code{change-log-version-number-regexp-list}, which can be customized |
|
31052
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1803 (versions of files that are under version control systems are known to |
|
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1804 Emacs through the version-control interface). |
|
b05772d7c2ad
Document change-log-version-info-enabled and
Eli Zaretskii <eliz@gnu.org>
parents:
31035
diff
changeset
|
1805 |
| 25829 | 1806 @cindex Change Log mode |
| 1807 @findex change-log-mode | |
| 1808 The change log file is visited in Change Log mode. In this major | |
| 1809 mode, each bunch of grouped items counts as one paragraph, and each | |
| 1810 entry is considered a page. This facilitates editing the entries. | |
| 1811 @kbd{C-j} and auto-fill indent each new line like the previous line; | |
| 1812 this is convenient for entering the contents of an entry. | |
| 1813 | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1814 @findex change-log-merge |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1815 The command @kbd{M-x change-log-merge} can be used to merge other log |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1816 files into a buffer in Change Log Mode, preserving the date ordering |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1817 of entries with either the current or old-style date formats. |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
1818 |
|
30850
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1819 @findex change-log-redate |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1820 @cindex converting change log date style |
|
30968
2dfd4d6a9043
Remove redundant description of change-log-redate.
Eli Zaretskii <eliz@gnu.org>
parents:
30850
diff
changeset
|
1821 Versions of Emacs before 20.1 used a different format for the time of |
|
2dfd4d6a9043
Remove redundant description of change-log-redate.
Eli Zaretskii <eliz@gnu.org>
parents:
30850
diff
changeset
|
1822 the change log entry: |
|
30850
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1823 |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1824 @smallexample |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1825 Fri May 25 11:23:23 1993 Richard Stallman <rms@@gnu.org> |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1826 @end smallexample |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1827 |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1828 @noindent |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1829 The @kbd{M-x change-log-redate} command converts all the old-style date |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1830 entries in the change log file visited in the current buffer to the new |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1831 format, so that all entries are kept in unified format. This is handy |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1832 when the entries are contributed by many different people some of whom |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1833 still use old versions of Emacs. |
|
befd90253848
Document the new change-log-redate command.
Eli Zaretskii <eliz@gnu.org>
parents:
30810
diff
changeset
|
1834 |
| 25829 | 1835 Version control systems are another way to keep track of changes in your |
| 1836 program and keep a change log. @xref{Log Buffer}. | |
| 1837 | |
| 30793 | 1838 @node Authors |
| 1839 @section @file{AUTHORS} files | |
| 1840 @cindex @file{AUTHORS} file | |
| 1841 | |
| 1842 Programs which have many contributors usually include a file named | |
| 1843 @file{AUTHORS} in their distribution, which lists the individual | |
| 1844 contributions. Emacs has a special command for maintaining the | |
| 1845 @file{AUTHORS} file that is part of the Emacs distribution. | |
| 1846 | |
| 1847 @findex authors | |
| 1848 The @kbd{M-x authors} command prompts for the name of the root of the | |
| 1849 Emacs source directory. It then scans @file{ChageLog} files and Lisp | |
| 1850 source files under that directory for information about authors of | |
| 1851 individual packages and people who made changes in source files, and | |
| 1852 puts the information it gleans into a buffer named @samp{*Authors*}. | |
| 1853 You can then edit the contents of that buffer and merge it with the | |
| 1854 exisiting @file{AUTHORS} file. | |
| 1855 | |
| 25829 | 1856 @node Tags |
| 1857 @section Tags Tables | |
| 1858 @cindex tags table | |
| 1859 | |
| 1860 A @dfn{tags table} is a description of how a multi-file program is | |
| 1861 broken up into files. It lists the names of the component files and the | |
| 1862 names and positions of the functions (or other named subunits) in each | |
| 1863 file. Grouping the related files makes it possible to search or replace | |
| 1864 through all the files with one command. Recording the function names | |
| 1865 and positions makes possible the @kbd{M-.} command which finds the | |
| 1866 definition of a function by looking up which of the files it is in. | |
| 1867 | |
| 1868 Tags tables are stored in files called @dfn{tags table files}. The | |
| 1869 conventional name for a tags table file is @file{TAGS}. | |
| 1870 | |
| 1871 Each entry in the tags table records the name of one tag, the name of the | |
| 1872 file that the tag is defined in (implicitly), and the position in that file | |
| 1873 of the tag's definition. | |
| 1874 | |
| 1875 Just what names from the described files are recorded in the tags table | |
| 1876 depends on the programming language of the described file. They | |
| 1877 normally include all functions and subroutines, and may also include | |
| 1878 global variables, data types, and anything else convenient. Each name | |
| 1879 recorded is called a @dfn{tag}. | |
| 1880 | |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1881 @cindex C++ class browser, tags |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1882 @cindex tags, C++ |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1883 @cindex class browser, C++ |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1884 @cindex Ebrowse |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1885 The Ebrowse is a separate facility tailored for C++, with tags and a |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1886 class browser. @xref{,,, ebrowse, Ebrowse User's Manual}. |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
1887 |
| 25829 | 1888 @menu |
| 26264 | 1889 * Tag Syntax:: Tag syntax for various types of code and text files. |
| 25829 | 1890 * Create Tags Table:: Creating a tags table with @code{etags}. |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
1891 * Etags Regexps:: Create arbitrary tags using regular expressions. |
| 25829 | 1892 * Select Tags Table:: How to visit a tags table. |
| 26264 | 1893 * Find Tag:: Commands to find the definition of a specific tag. |
| 25829 | 1894 * Tags Search:: Using a tags table for searching and replacing. |
| 1895 * List Tags:: Listing and finding tags defined in a file. | |
| 1896 @end menu | |
| 1897 | |
| 1898 @node Tag Syntax | |
| 1899 @subsection Source File Tag Syntax | |
| 1900 | |
| 1901 Here is how tag syntax is defined for the most popular languages: | |
| 1902 | |
| 1903 @itemize @bullet | |
| 1904 @item | |
| 1905 In C code, any C function or typedef is a tag, and so are definitions of | |
| 26264 | 1906 @code{struct}, @code{union} and @code{enum}. You can tag function |
|
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
1907 declarations and external variables in addition to function definitions |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
1908 by giving the @samp{--declarations} option to @code{etags}. |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
1909 @code{#define} macro definitions and @code{enum} constants are also |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
1910 tags, unless you specify @samp{--no-defines} when making the tags table. |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
1911 Similarly, global variables are tags, unless you specify |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
1912 @samp{--no-globals}. Use of @samp{--no-globals} and @samp{--no-defines} |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
1913 can make the tags table file much smaller. |
| 25829 | 1914 |
| 1915 @item | |
| 1916 In C++ code, in addition to all the tag constructs of C code, member | |
| 1917 functions are also recognized, and optionally member variables if you | |
| 1918 use the @samp{--members} option. Tags for variables and functions in | |
| 1919 classes are named @samp{@var{class}::@var{variable}} and | |
| 26264 | 1920 @samp{@var{class}::@var{function}}. @code{operator} functions tags are |
| 1921 named, for example @samp{operator+}. | |
| 25829 | 1922 |
| 1923 @item | |
| 1924 In Java code, tags include all the constructs recognized in C++, plus | |
| 26264 | 1925 the @code{interface}, @code{extends} and @code{implements} constructs. |
| 1926 Tags for variables and functions in classes are named | |
| 1927 @samp{@var{class}.@var{variable}} and @samp{@var{class}.@var{function}}. | |
| 25829 | 1928 |
| 1929 @item | |
| 1930 In La@TeX{} text, the argument of any of the commands @code{\chapter}, | |
| 1931 @code{\section}, @code{\subsection}, @code{\subsubsection}, | |
| 1932 @code{\eqno}, @code{\label}, @code{\ref}, @code{\cite}, @code{\bibitem}, | |
| 1933 @code{\part}, @code{\appendix}, @code{\entry}, or @code{\index}, is a | |
| 1934 tag.@refill | |
| 1935 | |
| 1936 Other commands can make tags as well, if you specify them in the | |
| 29107 | 1937 environment variable @env{TEXTAGS} before invoking @code{etags}. The |
| 25829 | 1938 value of this environment variable should be a colon-separated list of |
| 1939 command names. For example, | |
| 1940 | |
| 1941 @example | |
| 1942 TEXTAGS="def:newcommand:newenvironment" | |
| 1943 export TEXTAGS | |
| 1944 @end example | |
| 1945 | |
| 1946 @noindent | |
| 1947 specifies (using Bourne shell syntax) that the commands @samp{\def}, | |
| 1948 @samp{\newcommand} and @samp{\newenvironment} also define tags. | |
| 1949 | |
| 1950 @item | |
| 1951 In Lisp code, any function defined with @code{defun}, any variable | |
| 1952 defined with @code{defvar} or @code{defconst}, and in general the first | |
| 1953 argument of any expression that starts with @samp{(def} in column zero, is | |
| 1954 a tag. | |
| 1955 | |
| 1956 @item | |
| 1957 In Scheme code, tags include anything defined with @code{def} or with a | |
| 1958 construct whose name starts with @samp{def}. They also include variables | |
| 1959 set with @code{set!} at top level in the file. | |
| 1960 @end itemize | |
| 1961 | |
| 1962 Several other languages are also supported: | |
| 1963 | |
| 1964 @itemize @bullet | |
| 26264 | 1965 |
| 1966 @item | |
|
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
1967 In Ada code, functions, procedures, packages, tasks, and types are |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
1968 tags. Use the @samp{--packages-only} option to create tags for packages |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
1969 only. |
| 26264 | 1970 |
| 25829 | 1971 @item |
| 1972 In assembler code, labels appearing at the beginning of a line, | |
| 1973 followed by a colon, are tags. | |
| 1974 | |
| 1975 @item | |
| 1976 In Bison or Yacc input files, each rule defines as a tag the nonterminal | |
| 1977 it constructs. The portions of the file that contain C code are parsed | |
| 1978 as C code. | |
| 1979 | |
| 1980 @item | |
| 1981 In Cobol code, tags are paragraph names; that is, any word starting in | |
| 1982 column 8 and followed by a period. | |
| 1983 | |
| 1984 @item | |
| 1985 In Erlang code, the tags are the functions, records, and macros defined | |
| 1986 in the file. | |
| 1987 | |
| 1988 @item | |
| 1989 In Fortran code, functions, subroutines and blockdata are tags. | |
| 1990 | |
| 1991 @item | |
| 1992 In Objective C code, tags include Objective C definitions for classes, | |
| 1993 class categories, methods, and protocols. | |
| 1994 | |
| 1995 @item | |
| 1996 In Pascal code, the tags are the functions and procedures defined in | |
| 1997 the file. | |
| 1998 | |
| 1999 @item | |
| 26264 | 2000 In Perl code, the tags are the procedures defined by the @code{sub}, |
| 2001 @code{my} and @code{local} keywords. Use @samp{--globals} if you want | |
| 2002 to tag global variables. | |
| 25829 | 2003 |
| 2004 @item | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
2005 In PostScript code, the tags are the functions. |
| 25829 | 2006 |
| 2007 @item | |
| 2008 In Prolog code, a tag name appears at the left margin. | |
| 2009 | |
| 26264 | 2010 @item |
| 2011 In Python code, @code{def} or @code{class} at the beginning of a line | |
| 2012 generate a tag. | |
|
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2013 @end itemize |
| 26264 | 2014 |
| 26462 | 2015 You can also generate tags based on regexp matching (@pxref{Etags |
| 26264 | 2016 Regexps}) to handle other formats and languages. |
| 25829 | 2017 |
| 2018 @node Create Tags Table | |
| 2019 @subsection Creating Tags Tables | |
| 2020 @cindex @code{etags} program | |
| 2021 | |
| 2022 The @code{etags} program is used to create a tags table file. It knows | |
| 2023 the syntax of several languages, as described in | |
| 2024 @iftex | |
| 2025 the previous section. | |
| 2026 @end iftex | |
| 2027 @ifinfo | |
| 2028 @ref{Tag Syntax}. | |
| 2029 @end ifinfo | |
| 2030 Here is how to run @code{etags}: | |
| 2031 | |
| 2032 @example | |
| 2033 etags @var{inputfiles}@dots{} | |
| 2034 @end example | |
| 2035 | |
| 2036 @noindent | |
| 26264 | 2037 The @code{etags} program reads the specified files, and writes a tags |
| 2038 table named @file{TAGS} in the current working directory. You can | |
| 2039 intermix compressed and plain text source file names. @code{etags} | |
| 2040 knows about the most common compression formats, and does the right | |
| 2041 thing. So you can compress all your source files and have @code{etags} | |
| 2042 look for compressed versions of its file name arguments, if it does not | |
| 2043 find uncompressed versions. Under MS-DOS, @code{etags} also looks for | |
| 2044 file names like @samp{mycode.cgz} if it is given @samp{mycode.c} on the | |
| 2045 command line and @samp{mycode.c} does not exist. | |
| 2046 | |
| 2047 @code{etags} recognizes the language used in an input file based on | |
| 2048 its file name and contents. You can specify the language with the | |
| 25829 | 2049 @samp{--language=@var{name}} option, described below. |
| 2050 | |
| 2051 If the tags table data become outdated due to changes in the files | |
| 2052 described in the table, the way to update the tags table is the same way it | |
| 2053 was made in the first place. It is not necessary to do this often. | |
| 2054 | |
| 2055 If the tags table fails to record a tag, or records it for the wrong | |
| 2056 file, then Emacs cannot possibly find its definition. However, if the | |
| 2057 position recorded in the tags table becomes a little bit wrong (due to | |
| 2058 some editing in the file that the tag definition is in), the only | |
| 2059 consequence is a slight delay in finding the tag. Even if the stored | |
| 2060 position is very wrong, Emacs will still find the tag, but it must | |
| 2061 search the entire file for it. | |
| 2062 | |
| 2063 So you should update a tags table when you define new tags that you want | |
| 2064 to have listed, or when you move tag definitions from one file to another, | |
| 2065 or when changes become substantial. Normally there is no need to update | |
| 2066 the tags table after each edit, or even every day. | |
| 2067 | |
| 2068 One tags table can effectively include another. Specify the included | |
| 2069 tags file name with the @samp{--include=@var{file}} option when creating | |
| 2070 the file that is to include it. The latter file then acts as if it | |
| 2071 contained all the files specified in the included file, as well as the | |
| 2072 files it directly contains. | |
| 2073 | |
| 2074 If you specify the source files with relative file names when you run | |
| 2075 @code{etags}, the tags file will contain file names relative to the | |
| 2076 directory where the tags file was initially written. This way, you can | |
| 2077 move an entire directory tree containing both the tags file and the | |
| 2078 source files, and the tags file will still refer correctly to the source | |
| 2079 files. | |
| 2080 | |
| 2081 If you specify absolute file names as arguments to @code{etags}, then | |
| 2082 the tags file will contain absolute file names. This way, the tags file | |
| 2083 will still refer to the same files even if you move it, as long as the | |
| 2084 source files remain in the same place. Absolute file names start with | |
| 2085 @samp{/}, or with @samp{@var{device}:/} on MS-DOS and MS-Windows. | |
| 2086 | |
| 2087 When you want to make a tags table from a great number of files, you | |
| 2088 may have problems listing them on the command line, because some systems | |
| 2089 have a limit on its length. The simplest way to circumvent this limit | |
| 2090 is to tell @code{etags} to read the file names from its standard input, | |
| 2091 by typing a dash in place of the file names, like this: | |
| 2092 | |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2093 @smallexample |
| 25829 | 2094 find . -name "*.[chCH]" -print | etags - |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2095 @end smallexample |
| 25829 | 2096 |
| 2097 Use the option @samp{--language=@var{name}} to specify the language | |
| 2098 explicitly. You can intermix these options with file names; each one | |
| 2099 applies to the file names that follow it. Specify | |
| 2100 @samp{--language=auto} to tell @code{etags} to resume guessing the | |
| 2101 language from the file names and file contents. Specify | |
| 2102 @samp{--language=none} to turn off language-specific processing | |
| 26264 | 2103 entirely; then @code{etags} recognizes tags by regexp matching alone |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2104 (@pxref{Etags Regexps}). |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2105 |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2106 @samp{etags --help} prints the list of the languages @code{etags} |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2107 knows, and the file name rules for guessing the language. It also prints |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2108 a list of all the available @code{etags} options, together with a short |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2109 explanation. |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2110 |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2111 @node Etags Regexps |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2112 @subsection Etags Regexps |
| 25829 | 2113 |
| 2114 The @samp{--regex} option provides a general way of recognizing tags | |
| 2115 based on regexp matching. You can freely intermix it with file names. | |
| 2116 Each @samp{--regex} option adds to the preceding ones, and applies only | |
| 2117 to the following files. The syntax is: | |
| 2118 | |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2119 @smallexample |
| 25829 | 2120 --regex=/@var{tagregexp}[/@var{nameregexp}]/ |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2121 @end smallexample |
| 26264 | 2122 |
| 25829 | 2123 @noindent |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2124 where @var{tagregexp} is used to match the lines to tag. It is always |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2125 anchored, that is, it behaves as if preceded by @samp{^}. If you want |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2126 to account for indentation, just match any initial number of blanks by |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2127 beginning your regular expression with @samp{[ \t]*}. In the regular |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2128 expressions, @samp{\} quotes the next character, and @samp{\t} stands |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2129 for the tab character. Note that @code{etags} does not handle the other |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2130 C escape sequences for special characters. |
| 25829 | 2131 |
| 2132 @cindex interval operator (in regexps) | |
| 2133 The syntax of regular expressions in @code{etags} is the same as in | |
| 2134 Emacs, augmented with the @dfn{interval operator}, which works as in | |
| 2135 @code{grep} and @code{ed}. The syntax of an interval operator is | |
| 2136 @samp{\@{@var{m},@var{n}\@}}, and its meaning is to match the preceding | |
| 2137 expression at least @var{m} times and up to @var{n} times. | |
| 2138 | |
| 2139 You should not match more characters with @var{tagregexp} than that | |
| 2140 needed to recognize what you want to tag. If the match is such that | |
| 26106 | 2141 more characters than needed are unavoidably matched by @var{tagregexp} |
| 2142 (as will usually be the case), you should add a @var{nameregexp}, to | |
| 2143 pick out just the tag. This will enable Emacs to find tags more | |
| 2144 accurately and to do completion on tag names more reliably. You can | |
| 2145 find some examples below. | |
| 2146 | |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2147 The option @samp{--ignore-case-regex} (or @samp{-c}) is like |
| 26106 | 2148 @samp{--regex}, except that the regular expression provided will be |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2149 matched without regard to case, which is appropriate for various |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2150 programming languages. |
| 25829 | 2151 |
| 2152 The @samp{-R} option deletes all the regexps defined with | |
| 2153 @samp{--regex} options. It applies to the file names following it, as | |
| 2154 you can see from the following example: | |
| 2155 | |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2156 @smallexample |
| 25829 | 2157 etags --regex=/@var{reg1}/ voo.doo --regex=/@var{reg2}/ \ |
| 2158 bar.ber -R --lang=lisp los.er | |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2159 @end smallexample |
| 25829 | 2160 |
| 2161 @noindent | |
| 2162 Here @code{etags} chooses the parsing language for @file{voo.doo} and | |
| 2163 @file{bar.ber} according to their contents. @code{etags} also uses | |
| 2164 @var{reg1} to recognize additional tags in @file{voo.doo}, and both | |
| 2165 @var{reg1} and @var{reg2} to recognize additional tags in | |
| 2166 @file{bar.ber}. @code{etags} uses the Lisp tags rules, and no regexp | |
| 2167 matching, to recognize tags in @file{los.er}. | |
| 2168 | |
|
26289
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2169 A regular expression can be bound to a given language, by prepending |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2170 it with @samp{@{lang@}}. When you do this, @code{etags} will use the |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2171 regular expression only for files of that language. @samp{etags --help} |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2172 prints the list of languages recognised by @code{etags}. The following |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2173 example tags the @code{DEFVAR} macros in the Emacs source files. |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2174 @code{etags} applies this regular expression to C files only: |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2175 |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2176 @smallexample |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2177 --regex='@{c@}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/' |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2178 @end smallexample |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2179 |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2180 @noindent |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2181 This feature is particularly useful when storing a list of regular |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2182 expressions in a file. The following option syntax instructs |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2183 @code{etags} to read two files of regular expressions. The regular |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2184 expressions contained in the second file are matched without regard to |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2185 case. |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2186 |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2187 @smallexample |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2188 --regex=@@first-file --ignore-case-regex=@@second-file |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2189 @end smallexample |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2190 |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2191 @noindent |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2192 A regex file contains one regular expressions per line. Empty lines, |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2193 and lines beginning with space or tab are ignored. When the first |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2194 character in a line is @samp{@@}, @code{etags} assumes that the rest of |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2195 the line is the name of a file of regular expressions. This means that |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2196 such files can be nested. All the other lines are taken to be regular |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2197 expressions. For example, one can create a file called |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2198 @samp{emacs.tags} with the following contents (the first line in the |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2199 file is a comment): |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2200 |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2201 @smallexample |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2202 -- This is for GNU Emacs source files |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2203 @{c@}/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/\1/ |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2204 @end smallexample |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2205 |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2206 @noindent |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2207 and then use it like this: |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2208 |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2209 @smallexample |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2210 etags --regex=@@emacs.tags *.[ch] */*.[ch] |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2211 @end smallexample |
|
6651db4a4b1f
Document regexp changes in etags.
Francesco Potort? <pot@gnu.org>
parents:
26264
diff
changeset
|
2212 |
| 25829 | 2213 Here are some more examples. The regexps are quoted to protect them |
| 2214 from shell interpretation. | |
| 2215 | |
| 2216 @itemize @bullet | |
| 2217 | |
| 2218 @item | |
|
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2219 Tag Octave files: |
| 25829 | 2220 |
| 2221 @smallexample | |
|
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2222 etags --language=none \ |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2223 --regex='/[ \t]*function.*=[ \t]*\([^ \t]*\)[ \t]*(/\1/' \ |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2224 --regex='/###key \(.*\)/\1/' \ |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2225 --regex='/[ \t]*global[ \t].*/' \ |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2226 *.m |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2227 @end smallexample |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2228 |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2229 @noindent |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2230 Note that tags are not generated for scripts so that you have to add a |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2231 line by yourself of the form `###key <script-name>' if you want to jump |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2232 to it. |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2233 |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2234 @item |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2235 Tag Tcl files: |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2236 |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2237 @smallexample |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2238 etags --language=none --regex='/proc[ \t]+\([^ \t]+\)/\1/' *.tcl |
| 25829 | 2239 @end smallexample |
| 2240 | |
| 2241 @item | |
|
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2242 Tag VHDL files: |
| 25829 | 2243 |
| 2244 @smallexample | |
|
26292
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2245 --language=none \ |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2246 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/' \ |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2247 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\ |
|
81cd0c225dd9
Last changes for etags (I hope).
Francesco Potort? <pot@gnu.org>
parents:
26289
diff
changeset
|
2248 \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/' |
| 25829 | 2249 @end smallexample |
| 2250 @end itemize | |
| 2251 | |
| 2252 @node Select Tags Table | |
| 2253 @subsection Selecting a Tags Table | |
| 2254 | |
| 2255 @vindex tags-file-name | |
| 2256 @findex visit-tags-table | |
| 2257 Emacs has at any time one @dfn{selected} tags table, and all the commands | |
| 2258 for working with tags tables use the selected one. To select a tags table, | |
| 2259 type @kbd{M-x visit-tags-table}, which reads the tags table file name as an | |
| 2260 argument. The name @file{TAGS} in the default directory is used as the | |
| 2261 default file name. | |
| 2262 | |
| 2263 All this command does is store the file name in the variable | |
| 2264 @code{tags-file-name}. Emacs does not actually read in the tags table | |
| 2265 contents until you try to use them. Setting this variable yourself is just | |
| 2266 as good as using @code{visit-tags-table}. The variable's initial value is | |
| 2267 @code{nil}; that value tells all the commands for working with tags tables | |
| 2268 that they must ask for a tags table file name to use. | |
| 2269 | |
| 2270 Using @code{visit-tags-table} when a tags table is already loaded | |
| 2271 gives you a choice: you can add the new tags table to the current list | |
| 2272 of tags tables, or start a new list. The tags commands use all the tags | |
| 2273 tables in the current list. If you start a new list, the new tags table | |
| 2274 is used @emph{instead} of others. If you add the new table to the | |
| 2275 current list, it is used @emph{as well as} the others. When the tags | |
| 2276 commands scan the list of tags tables, they don't always start at the | |
| 2277 beginning of the list; they start with the first tags table (if any) | |
| 2278 that describes the current file, proceed from there to the end of the | |
| 2279 list, and then scan from the beginning of the list until they have | |
| 2280 covered all the tables in the list. | |
| 2281 | |
| 2282 @vindex tags-table-list | |
| 2283 You can specify a precise list of tags tables by setting the variable | |
| 2284 @code{tags-table-list} to a list of strings, like this: | |
| 2285 | |
| 2286 @c keep this on two lines for formatting in smallbook | |
| 2287 @example | |
| 2288 @group | |
| 2289 (setq tags-table-list | |
| 2290 '("~/emacs" "/usr/local/lib/emacs/src")) | |
| 2291 @end group | |
| 2292 @end example | |
| 2293 | |
| 2294 @noindent | |
| 2295 This tells the tags commands to look at the @file{TAGS} files in your | |
| 2296 @file{~/emacs} directory and in the @file{/usr/local/lib/emacs/src} | |
| 2297 directory. The order depends on which file you are in and which tags | |
| 2298 table mentions that file, as explained above. | |
| 2299 | |
| 2300 Do not set both @code{tags-file-name} and @code{tags-table-list}. | |
| 2301 | |
| 2302 @node Find Tag | |
| 2303 @subsection Finding a Tag | |
| 2304 | |
| 2305 The most important thing that a tags table enables you to do is to find | |
| 2306 the definition of a specific tag. | |
| 2307 | |
| 2308 @table @kbd | |
| 2309 @item M-.@: @var{tag} @key{RET} | |
| 2310 Find first definition of @var{tag} (@code{find-tag}). | |
| 2311 @item C-u M-. | |
| 2312 Find next alternate definition of last tag specified. | |
| 2313 @item C-u - M-. | |
| 2314 Go back to previous tag found. | |
| 2315 @item C-M-. @var{pattern} @key{RET} | |
| 2316 Find a tag whose name matches @var{pattern} (@code{find-tag-regexp}). | |
| 2317 @item C-u C-M-. | |
| 2318 Find the next tag whose name matches the last pattern used. | |
| 2319 @item C-x 4 .@: @var{tag} @key{RET} | |
| 2320 Find first definition of @var{tag}, but display it in another window | |
| 2321 (@code{find-tag-other-window}). | |
| 2322 @item C-x 5 .@: @var{tag} @key{RET} | |
| 2323 Find first definition of @var{tag}, and create a new frame to select the | |
| 2324 buffer (@code{find-tag-other-frame}). | |
| 2325 @item M-* | |
| 2326 Pop back to where you previously invoked @kbd{M-.} and friends. | |
| 2327 @end table | |
| 2328 | |
| 2329 @kindex M-. | |
| 2330 @findex find-tag | |
| 2331 @kbd{M-.}@: (@code{find-tag}) is the command to find the definition of | |
| 2332 a specified tag. It searches through the tags table for that tag, as a | |
| 2333 string, and then uses the tags table info to determine the file that the | |
| 2334 definition is in and the approximate character position in the file of | |
| 2335 the definition. Then @code{find-tag} visits that file, moves point to | |
| 2336 the approximate character position, and searches ever-increasing | |
| 2337 distances away to find the tag definition. | |
| 2338 | |
| 2339 If an empty argument is given (just type @key{RET}), the sexp in the | |
| 2340 buffer before or around point is used as the @var{tag} argument. | |
| 2341 @xref{Lists}, for info on sexps. | |
| 2342 | |
| 2343 You don't need to give @kbd{M-.} the full name of the tag; a part | |
| 2344 will do. This is because @kbd{M-.} finds tags in the table which | |
| 2345 contain @var{tag} as a substring. However, it prefers an exact match | |
| 2346 to a substring match. To find other tags that match the same | |
| 2347 substring, give @code{find-tag} a numeric argument, as in @kbd{C-u | |
| 2348 M-.}; this does not read a tag name, but continues searching the tags | |
| 2349 table's text for another tag containing the same substring last used. | |
| 2350 If you have a real @key{META} key, @kbd{M-0 M-.}@: is an easier | |
| 2351 alternative to @kbd{C-u M-.}. | |
| 2352 | |
| 2353 @kindex C-x 4 . | |
| 2354 @findex find-tag-other-window | |
| 2355 @kindex C-x 5 . | |
| 2356 @findex find-tag-other-frame | |
| 2357 Like most commands that can switch buffers, @code{find-tag} has a | |
| 2358 variant that displays the new buffer in another window, and one that | |
| 2359 makes a new frame for it. The former is @kbd{C-x 4 .}, which invokes | |
| 2360 the command @code{find-tag-other-window}. The latter is @kbd{C-x 5 .}, | |
| 2361 which invokes @code{find-tag-other-frame}. | |
| 2362 | |
| 2363 To move back to places you've found tags recently, use @kbd{C-u - | |
| 2364 M-.}; more generally, @kbd{M-.} with a negative numeric argument. This | |
| 2365 command can take you to another buffer. @kbd{C-x 4 .} with a negative | |
| 2366 argument finds the previous tag location in another window. | |
| 2367 | |
| 2368 @kindex M-* | |
| 2369 @findex pop-tag-mark | |
| 2370 @vindex find-tag-marker-ring-length | |
| 2371 As well as going back to places you've found tags recently, you can go | |
| 2372 back to places @emph{from where} you found them. Use @kbd{M-*}, which | |
| 2373 invokes the command @code{pop-tag-mark}, for this. Typically you would | |
| 2374 find and study the definition of something with @kbd{M-.} and then | |
| 2375 return to where you were with @kbd{M-*}. | |
| 2376 | |
| 2377 Both @kbd{C-u - M-.} and @kbd{M-*} allow you to retrace your steps to | |
| 2378 a depth determined by the variable @code{find-tag-marker-ring-length}. | |
| 2379 | |
| 2380 @findex find-tag-regexp | |
| 2381 @kindex C-M-. | |
| 2382 The command @kbd{C-M-.} (@code{find-tag-regexp}) visits the tags that | |
| 2383 match a specified regular expression. It is just like @kbd{M-.} except | |
| 2384 that it does regexp matching instead of substring matching. | |
| 2385 | |
| 2386 @node Tags Search | |
| 2387 @subsection Searching and Replacing with Tags Tables | |
| 2388 | |
| 2389 The commands in this section visit and search all the files listed in the | |
| 2390 selected tags table, one by one. For these commands, the tags table serves | |
| 2391 only to specify a sequence of files to search. | |
| 2392 | |
| 2393 @table @kbd | |
| 2394 @item M-x tags-search @key{RET} @var{regexp} @key{RET} | |
| 2395 Search for @var{regexp} through the files in the selected tags | |
| 2396 table. | |
| 2397 @item M-x tags-query-replace @key{RET} @var{regexp} @key{RET} @var{replacement} @key{RET} | |
| 2398 Perform a @code{query-replace-regexp} on each file in the selected tags table. | |
| 2399 @item M-, | |
| 2400 Restart one of the commands above, from the current location of point | |
| 2401 (@code{tags-loop-continue}). | |
| 2402 @end table | |
| 2403 | |
| 2404 @findex tags-search | |
| 2405 @kbd{M-x tags-search} reads a regexp using the minibuffer, then | |
| 2406 searches for matches in all the files in the selected tags table, one | |
| 2407 file at a time. It displays the name of the file being searched so you | |
| 2408 can follow its progress. As soon as it finds an occurrence, | |
| 2409 @code{tags-search} returns. | |
| 2410 | |
| 2411 @kindex M-, | |
| 2412 @findex tags-loop-continue | |
| 2413 Having found one match, you probably want to find all the rest. To find | |
| 2414 one more match, type @kbd{M-,} (@code{tags-loop-continue}) to resume the | |
| 2415 @code{tags-search}. This searches the rest of the current buffer, followed | |
| 2416 by the remaining files of the tags table.@refill | |
| 2417 | |
| 2418 @findex tags-query-replace | |
| 2419 @kbd{M-x tags-query-replace} performs a single | |
| 2420 @code{query-replace-regexp} through all the files in the tags table. It | |
| 2421 reads a regexp to search for and a string to replace with, just like | |
| 2422 ordinary @kbd{M-x query-replace-regexp}. It searches much like @kbd{M-x | |
| 2423 tags-search}, but repeatedly, processing matches according to your | |
| 2424 input. @xref{Replace}, for more information on query replace. | |
| 2425 | |
|
31065
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2426 @vindex tags-case-fold-search |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2427 @cindex case-sensitivity, and tags search |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2428 You can control the case-sensitivity of tags search commands by |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2429 customizing the value of the variable @code{tags-case-fold-search}. The |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2430 default is to use the same setting as the value of |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2431 @code{case-fold-search} (@pxref{Search Case}). |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2432 |
| 25829 | 2433 It is possible to get through all the files in the tags table with a |
| 2434 single invocation of @kbd{M-x tags-query-replace}. But often it is | |
| 2435 useful to exit temporarily, which you can do with any input event that | |
| 2436 has no special query replace meaning. You can resume the query replace | |
| 2437 subsequently by typing @kbd{M-,}; this command resumes the last tags | |
| 2438 search or replace command that you did. | |
| 2439 | |
| 2440 The commands in this section carry out much broader searches than the | |
| 2441 @code{find-tag} family. The @code{find-tag} commands search only for | |
| 2442 definitions of tags that match your substring or regexp. The commands | |
| 2443 @code{tags-search} and @code{tags-query-replace} find every occurrence | |
| 2444 of the regexp, as ordinary search commands and replace commands do in | |
| 2445 the current buffer. | |
| 2446 | |
| 2447 These commands create buffers only temporarily for the files that they | |
| 2448 have to search (those which are not already visited in Emacs buffers). | |
| 2449 Buffers in which no match is found are quickly killed; the others | |
| 2450 continue to exist. | |
| 2451 | |
| 2452 It may have struck you that @code{tags-search} is a lot like | |
| 2453 @code{grep}. You can also run @code{grep} itself as an inferior of | |
| 2454 Emacs and have Emacs show you the matching lines one by one. This works | |
| 2455 much like running a compilation; finding the source locations of the | |
| 2456 @code{grep} matches works like finding the compilation errors. | |
| 2457 @xref{Compilation}. | |
| 26264 | 2458 |
| 25829 | 2459 @node List Tags |
| 2460 @subsection Tags Table Inquiries | |
| 2461 | |
| 2462 @table @kbd | |
| 2463 @item M-x list-tags @key{RET} @var{file} @key{RET} | |
| 2464 Display a list of the tags defined in the program file @var{file}. | |
| 2465 @item M-x tags-apropos @key{RET} @var{regexp} @key{RET} | |
| 2466 Display a list of all tags matching @var{regexp}. | |
| 2467 @end table | |
| 2468 | |
| 2469 @findex list-tags | |
| 2470 @kbd{M-x list-tags} reads the name of one of the files described by | |
| 2471 the selected tags table, and displays a list of all the tags defined in | |
| 2472 that file. The ``file name'' argument is really just a string to | |
| 2473 compare against the file names recorded in the tags table; it is read as | |
| 2474 a string rather than as a file name. Therefore, completion and | |
| 2475 defaulting are not available, and you must enter the file name the same | |
| 2476 way it appears in the tags table. Do not include a directory as part of | |
| 2477 the file name unless the file name recorded in the tags table includes a | |
| 2478 directory. | |
| 2479 | |
| 2480 @findex tags-apropos | |
| 2481 @kbd{M-x tags-apropos} is like @code{apropos} for tags | |
| 2482 (@pxref{Apropos}). It reads a regexp, then finds all the tags in the | |
| 2483 selected tags table whose entries match that regexp, and displays the | |
| 2484 tag names found. | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
2485 @vindex tags-apropos-additional-actions |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
2486 You can display additional output with @kbd{M-x tags-apropos} by customizing |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
2487 the variable @code{tags-apropos-additional-actions}. See its |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
2488 documentation for details. |
|
31065
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2489 @vindex tags-apropos-verbose |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2490 Setting the variable @code{tags-apropos-verbose} to a non-nil value |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2491 causes @kbd{M-x tags-apropos} to display the names of the tags files |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2492 together with the tag names. |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2493 @vindex tags-tag-face |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2494 The face @code{tags-tag-face} can be used to customize the appearance of |
|
357e242b7f87
Document tags-case-fold-search, tags-apropos-verbose and tags-tag-face.
Eli Zaretskii <eliz@gnu.org>
parents:
31052
diff
changeset
|
2495 tags in the output of @kbd{M-x tags-apropos}. |
| 25829 | 2496 |
| 2497 You can also perform completion in the buffer on the name space of tag | |
| 2498 names in the current tags tables. @xref{Symbol Completion}. | |
| 2499 | |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2500 @node Imenu |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2501 @section Imenu |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2502 @cindex indexes of buffer contents |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2503 @cindex buffer content indexes |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2504 @cindex tags |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2505 |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
2506 The Imenu facility provides mode-specific indexes of the contents of |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2507 single buffers and provides selection from a menu. Selecting a menu |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2508 item takes you to the indexed point in the buffer, in a similar way to |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2509 the Tags facility. Indexing is typically by names of program routines |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2510 and variables but in Texinfo mode, for instance, node names are indexed. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2511 Most major modes for which it is appropriate have Imenu support. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2512 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2513 @findex imenu |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2514 @findex imenu-add-menu-bar-index |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2515 @kbd{M-x imenu} builds the index if necessary and presents you with an |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2516 electric buffer menu from which to select an entry (with completion). |
| 29084 | 2517 If you bind @code{imenu} to a mouse event (@pxref{Mouse Buttons}) and |
| 2518 invoke it that way, the index will appear as a popup menu; there is no | |
| 2519 such binding by default. You can add an index menubar on the menubar | |
| 2520 with @kbd{imenu-add-menu-bar-index}. | |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2521 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2522 Some major modes provide facilities for invoking Imenu; otherwise you |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2523 could add @code{imenu-add-menu-bar-index} to a major mode's hook to |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2524 generate an index for each buffer created in that mode. (If you do |
| 34254 | 2525 that, it takes some time to generate the index when finding a file, |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2526 depending on the file's size and the complexity of the indexing function |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2527 for that mode.) |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2528 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2529 @vindex imenu-auto-rescan |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2530 The index should be regenerated (via the @samp{*Rescan*} menu item) when |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2531 indexable items are added to or deleted from the buffer. Rescanning is |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2532 done when a menu selction is requested if the option |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2533 @code{imenu-auto-rescan} is set. By default buffer positions are in |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2534 terms of markers, so that changing non-indexable text doesn't require |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2535 rescanning. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2536 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2537 @vindex imenu-sort-function |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2538 The way the menus are sorted can be customized via the option |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2539 @code{imenu-sort-function}. By default names are ordered as they occur |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2540 in the buffer; alphabetic sorting is provided as an alternative. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2541 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2542 Imenu provides the information used by Which Function mode (@pxref{Which |
| 28391 | 2543 Function}). It may also be used by Speedbar (@pxref{Speedbar}). |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2544 |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2545 @node Emerge, C Modes, Imenu, Programs |
| 25829 | 2546 @section Merging Files with Emerge |
| 2547 @cindex Emerge | |
| 2548 @cindex merging files | |
| 2549 | |
| 2550 It's not unusual for programmers to get their signals crossed and modify | |
| 2551 the same program in two different directions. To recover from this | |
| 2552 confusion, you need to merge the two versions. Emerge makes this | |
| 2553 easier. See also @ref{Comparing Files}, for commands to compare | |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
2554 in a more manual fashion, and @ref{,Ediff,, ediff, The Ediff Manual}. |
| 25829 | 2555 |
| 2556 @menu | |
| 2557 * Overview of Emerge:: How to start Emerge. Basic concepts. | |
| 2558 * Submodes of Emerge:: Fast mode vs. Edit mode. | |
| 2559 Skip Prefers mode and Auto Advance mode. | |
| 2560 * State of Difference:: You do the merge by specifying state A or B | |
| 2561 for each difference. | |
| 2562 * Merge Commands:: Commands for selecting a difference, | |
| 2563 changing states of differences, etc. | |
| 2564 * Exiting Emerge:: What to do when you've finished the merge. | |
| 2565 * Combining in Emerge:: How to keep both alternatives for a difference. | |
| 2566 * Fine Points of Emerge:: Misc. | |
| 2567 @end menu | |
| 2568 | |
| 2569 @node Overview of Emerge | |
| 2570 @subsection Overview of Emerge | |
| 2571 | |
| 2572 To start Emerge, run one of these four commands: | |
| 2573 | |
| 2574 @table @kbd | |
| 2575 @item M-x emerge-files | |
| 2576 @findex emerge-files | |
| 2577 Merge two specified files. | |
| 2578 | |
| 2579 @item M-x emerge-files-with-ancestor | |
| 2580 @findex emerge-files-with-ancestor | |
| 2581 Merge two specified files, with reference to a common ancestor. | |
| 2582 | |
| 2583 @item M-x emerge-buffers | |
| 2584 @findex emerge-buffers | |
| 2585 Merge two buffers. | |
| 2586 | |
| 2587 @item M-x emerge-buffers-with-ancestor | |
| 2588 @findex emerge-buffers-with-ancestor | |
| 2589 Merge two buffers with reference to a common ancestor in a third | |
| 2590 buffer. | |
| 2591 @end table | |
| 2592 | |
| 2593 @cindex merge buffer (Emerge) | |
| 2594 @cindex A and B buffers (Emerge) | |
| 2595 The Emerge commands compare two files or buffers, and display the | |
| 2596 comparison in three buffers: one for each input text (the @dfn{A buffer} | |
| 2597 and the @dfn{B buffer}), and one (the @dfn{merge buffer}) where merging | |
| 2598 takes place. The merge buffer shows the full merged text, not just the | |
| 2599 differences. Wherever the two input texts differ, you can choose which | |
| 2600 one of them to include in the merge buffer. | |
| 2601 | |
| 2602 The Emerge commands that take input from existing buffers use only the | |
| 2603 accessible portions of those buffers, if they are narrowed | |
| 2604 (@pxref{Narrowing}). | |
| 2605 | |
| 2606 If a common ancestor version is available, from which the two texts to | |
| 2607 be merged were both derived, Emerge can use it to guess which | |
| 2608 alternative is right. Wherever one current version agrees with the | |
| 2609 ancestor, Emerge presumes that the other current version is a deliberate | |
| 2610 change which should be kept in the merged version. Use the | |
| 2611 @samp{with-ancestor} commands if you want to specify a common ancestor | |
| 2612 text. These commands read three file or buffer names---variant A, | |
| 2613 variant B, and the common ancestor. | |
| 2614 | |
| 2615 After the comparison is done and the buffers are prepared, the | |
| 2616 interactive merging starts. You control the merging by typing special | |
| 2617 @dfn{merge commands} in the merge buffer. The merge buffer shows you a | |
| 2618 full merged text, not just differences. For each run of differences | |
| 2619 between the input texts, you can choose which one of them to keep, or | |
| 2620 edit them both together. | |
| 2621 | |
| 2622 The merge buffer uses a special major mode, Emerge mode, with commands | |
| 2623 for making these choices. But you can also edit the buffer with | |
| 2624 ordinary Emacs commands. | |
| 2625 | |
| 2626 At any given time, the attention of Emerge is focused on one | |
| 2627 particular difference, called the @dfn{selected} difference. This | |
| 2628 difference is marked off in the three buffers like this: | |
| 2629 | |
| 2630 @example | |
| 2631 vvvvvvvvvvvvvvvvvvvv | |
| 2632 @var{text that differs} | |
| 2633 ^^^^^^^^^^^^^^^^^^^^ | |
| 2634 @end example | |
| 2635 | |
| 2636 @noindent | |
| 2637 Emerge numbers all the differences sequentially and the mode | |
| 2638 line always shows the number of the selected difference. | |
| 2639 | |
| 2640 Normally, the merge buffer starts out with the A version of the text. | |
| 2641 But when the A version of a difference agrees with the common ancestor, | |
| 2642 then the B version is initially preferred for that difference. | |
| 2643 | |
| 2644 Emerge leaves the merged text in the merge buffer when you exit. At | |
| 2645 that point, you can save it in a file with @kbd{C-x C-w}. If you give a | |
| 2646 numeric argument to @code{emerge-files} or | |
| 2647 @code{emerge-files-with-ancestor}, it reads the name of the output file | |
| 2648 using the minibuffer. (This is the last file name those commands read.) | |
| 2649 Then exiting from Emerge saves the merged text in the output file. | |
| 2650 | |
| 2651 Normally, Emerge commands save the output buffer in its file when you | |
| 2652 exit. If you abort Emerge with @kbd{C-]}, the Emerge command does not | |
| 2653 save the output buffer, but you can save it yourself if you wish. | |
| 2654 | |
| 2655 @node Submodes of Emerge | |
| 2656 @subsection Submodes of Emerge | |
| 2657 | |
| 2658 You can choose between two modes for giving merge commands: Fast mode | |
| 2659 and Edit mode. In Fast mode, basic merge commands are single | |
| 2660 characters, but ordinary Emacs commands are disabled. This is | |
| 2661 convenient if you use only merge commands. In Edit mode, all merge | |
| 2662 commands start with the prefix key @kbd{C-c C-c}, and the normal Emacs | |
| 2663 commands are also available. This allows editing the merge buffer, but | |
| 2664 slows down Emerge operations. | |
| 2665 | |
| 2666 Use @kbd{e} to switch to Edit mode, and @kbd{C-c C-c f} to switch to | |
| 2667 Fast mode. The mode line indicates Edit and Fast modes with @samp{E} | |
| 2668 and @samp{F}. | |
| 2669 | |
| 2670 Emerge has two additional submodes that affect how particular merge | |
| 2671 commands work: Auto Advance mode and Skip Prefers mode. | |
| 2672 | |
| 2673 If Auto Advance mode is in effect, the @kbd{a} and @kbd{b} commands | |
| 2674 advance to the next difference. This lets you go through the merge | |
| 2675 faster as long as you simply choose one of the alternatives from the | |
| 2676 input. The mode line indicates Auto Advance mode with @samp{A}. | |
| 2677 | |
| 2678 If Skip Prefers mode is in effect, the @kbd{n} and @kbd{p} commands | |
| 2679 skip over differences in states prefer-A and prefer-B (@pxref{State of | |
| 2680 Difference}). Thus you see only differences for which neither version | |
| 2681 is presumed ``correct.'' The mode line indicates Skip Prefers mode with | |
| 2682 @samp{S}. | |
| 2683 | |
| 2684 @findex emerge-auto-advance-mode | |
| 2685 @findex emerge-skip-prefers-mode | |
| 2686 Use the command @kbd{s a} (@code{emerge-auto-advance-mode}) to set or | |
| 2687 clear Auto Advance mode. Use @kbd{s s} | |
| 2688 (@code{emerge-skip-prefers-mode}) to set or clear Skip Prefers mode. | |
| 2689 These commands turn on the mode with a positive argument, turns it off | |
| 2690 with a negative or zero argument, and toggle the mode with no argument. | |
| 2691 | |
| 2692 @node State of Difference | |
| 2693 @subsection State of a Difference | |
| 2694 | |
| 2695 In the merge buffer, a difference is marked with lines of @samp{v} and | |
| 2696 @samp{^} characters. Each difference has one of these seven states: | |
| 2697 | |
| 2698 @table @asis | |
| 2699 @item A | |
| 2700 The difference is showing the A version. The @kbd{a} command always | |
| 2701 produces this state; the mode line indicates it with @samp{A}. | |
| 2702 | |
| 2703 @item B | |
| 2704 The difference is showing the B version. The @kbd{b} command always | |
| 2705 produces this state; the mode line indicates it with @samp{B}. | |
| 2706 | |
| 2707 @item default-A | |
| 2708 @itemx default-B | |
| 2709 The difference is showing the A or the B state by default, because you | |
| 2710 haven't made a choice. All differences start in the default-A state | |
| 2711 (and thus the merge buffer is a copy of the A buffer), except those for | |
| 2712 which one alternative is ``preferred'' (see below). | |
| 2713 | |
| 2714 When you select a difference, its state changes from default-A or | |
| 2715 default-B to plain A or B. Thus, the selected difference never has | |
| 2716 state default-A or default-B, and these states are never displayed in | |
| 2717 the mode line. | |
| 2718 | |
| 2719 The command @kbd{d a} chooses default-A as the default state, and @kbd{d | |
| 2720 b} chooses default-B. This chosen default applies to all differences | |
| 2721 which you haven't ever selected and for which no alternative is preferred. | |
| 2722 If you are moving through the merge sequentially, the differences you | |
| 2723 haven't selected are those following the selected one. Thus, while | |
| 2724 moving sequentially, you can effectively make the A version the default | |
| 2725 for some sections of the merge buffer and the B version the default for | |
| 2726 others by using @kbd{d a} and @kbd{d b} between sections. | |
| 2727 | |
| 2728 @item prefer-A | |
| 2729 @itemx prefer-B | |
| 2730 The difference is showing the A or B state because it is | |
| 2731 @dfn{preferred}. This means that you haven't made an explicit choice, | |
| 2732 but one alternative seems likely to be right because the other | |
| 2733 alternative agrees with the common ancestor. Thus, where the A buffer | |
| 2734 agrees with the common ancestor, the B version is preferred, because | |
| 2735 chances are it is the one that was actually changed. | |
| 2736 | |
| 2737 These two states are displayed in the mode line as @samp{A*} and @samp{B*}. | |
| 2738 | |
| 2739 @item combined | |
| 2740 The difference is showing a combination of the A and B states, as a | |
| 2741 result of the @kbd{x c} or @kbd{x C} commands. | |
| 2742 | |
| 2743 Once a difference is in this state, the @kbd{a} and @kbd{b} commands | |
| 2744 don't do anything to it unless you give them a numeric argument. | |
| 2745 | |
| 2746 The mode line displays this state as @samp{comb}. | |
| 2747 @end table | |
| 2748 | |
| 2749 @node Merge Commands | |
| 2750 @subsection Merge Commands | |
| 2751 | |
| 2752 Here are the Merge commands for Fast mode; in Edit mode, precede them | |
| 2753 with @kbd{C-c C-c}: | |
| 2754 | |
| 2755 @table @kbd | |
| 2756 @item p | |
| 2757 Select the previous difference. | |
| 2758 | |
| 2759 @item n | |
| 2760 Select the next difference. | |
| 2761 | |
| 2762 @item a | |
| 2763 Choose the A version of this difference. | |
| 2764 | |
| 2765 @item b | |
| 2766 Choose the B version of this difference. | |
| 2767 | |
| 2768 @item C-u @var{n} j | |
| 2769 Select difference number @var{n}. | |
| 2770 | |
| 2771 @item . | |
| 2772 Select the difference containing point. You can use this command in the | |
| 2773 merge buffer or in the A or B buffer. | |
| 2774 | |
| 2775 @item q | |
| 2776 Quit---finish the merge. | |
| 2777 | |
| 2778 @item C-] | |
| 2779 Abort---exit merging and do not save the output. | |
| 2780 | |
| 2781 @item f | |
| 2782 Go into Fast mode. (In Edit mode, this is actually @kbd{C-c C-c f}.) | |
| 2783 | |
| 2784 @item e | |
| 2785 Go into Edit mode. | |
| 2786 | |
| 2787 @item l | |
| 2788 Recenter (like @kbd{C-l}) all three windows. | |
| 2789 | |
| 26264 | 2790 @item - |
| 25829 | 2791 Specify part of a prefix numeric argument. |
| 2792 | |
| 2793 @item @var{digit} | |
| 2794 Also specify part of a prefix numeric argument. | |
| 2795 | |
| 2796 @item d a | |
| 2797 Choose the A version as the default from here down in | |
| 2798 the merge buffer. | |
| 2799 | |
| 2800 @item d b | |
| 2801 Choose the B version as the default from here down in | |
| 2802 the merge buffer. | |
| 2803 | |
| 2804 @item c a | |
| 2805 Copy the A version of this difference into the kill ring. | |
| 2806 | |
| 2807 @item c b | |
| 2808 Copy the B version of this difference into the kill ring. | |
| 2809 | |
| 2810 @item i a | |
| 2811 Insert the A version of this difference at point. | |
| 2812 | |
| 2813 @item i b | |
| 2814 Insert the B version of this difference at point. | |
| 2815 | |
| 2816 @item m | |
| 2817 Put point and mark around the difference. | |
| 2818 | |
| 2819 @item ^ | |
| 2820 Scroll all three windows down (like @kbd{M-v}). | |
| 2821 | |
| 2822 @item v | |
| 2823 Scroll all three windows up (like @kbd{C-v}). | |
| 2824 | |
| 2825 @item < | |
| 2826 Scroll all three windows left (like @kbd{C-x <}). | |
| 2827 | |
| 2828 @item > | |
| 2829 Scroll all three windows right (like @kbd{C-x >}). | |
| 2830 | |
| 2831 @item | | |
| 2832 Reset horizontal scroll on all three windows. | |
| 2833 | |
| 2834 @item x 1 | |
| 2835 Shrink the merge window to one line. (Use @kbd{C-u l} to restore it | |
| 2836 to full size.) | |
| 2837 | |
| 2838 @item x c | |
| 2839 Combine the two versions of this difference (@pxref{Combining in | |
| 2840 Emerge}). | |
| 2841 | |
| 2842 @item x f | |
| 2843 Show the names of the files/buffers Emerge is operating on, in a Help | |
| 2844 window. (Use @kbd{C-u l} to restore windows.) | |
| 2845 | |
| 2846 @item x j | |
| 2847 Join this difference with the following one. | |
| 2848 (@kbd{C-u x j} joins this difference with the previous one.) | |
| 2849 | |
| 2850 @item x s | |
| 2851 Split this difference into two differences. Before you use this | |
| 2852 command, position point in each of the three buffers at the place where | |
| 2853 you want to split the difference. | |
| 2854 | |
| 2855 @item x t | |
| 2856 Trim identical lines off the top and bottom of the difference. | |
| 2857 Such lines occur when the A and B versions are | |
| 2858 identical but differ from the ancestor version. | |
| 2859 @end table | |
| 2860 | |
| 2861 @node Exiting Emerge | |
| 2862 @subsection Exiting Emerge | |
| 2863 | |
| 2864 The @kbd{q} command (@code{emerge-quit}) finishes the merge, storing | |
| 2865 the results into the output file if you specified one. It restores the | |
| 2866 A and B buffers to their proper contents, or kills them if they were | |
| 2867 created by Emerge and you haven't changed them. It also disables the | |
| 2868 Emerge commands in the merge buffer, since executing them later could | |
| 2869 damage the contents of the various buffers. | |
| 2870 | |
| 2871 @kbd{C-]} aborts the merge. This means exiting without writing the | |
| 2872 output file. If you didn't specify an output file, then there is no | |
| 2873 real difference between aborting and finishing the merge. | |
| 2874 | |
| 2875 If the Emerge command was called from another Lisp program, then its | |
| 2876 return value is @code{t} for successful completion, or @code{nil} if you | |
| 2877 abort. | |
| 2878 | |
| 2879 @node Combining in Emerge | |
| 2880 @subsection Combining the Two Versions | |
| 2881 | |
| 2882 Sometimes you want to keep @emph{both} alternatives for a particular | |
| 2883 difference. To do this, use @kbd{x c}, which edits the merge buffer | |
| 2884 like this: | |
| 2885 | |
| 2886 @example | |
| 2887 @group | |
| 2888 #ifdef NEW | |
| 2889 @var{version from A buffer} | |
| 2890 #else /* not NEW */ | |
| 2891 @var{version from B buffer} | |
| 2892 #endif /* not NEW */ | |
| 2893 @end group | |
| 2894 @end example | |
| 2895 | |
| 2896 @noindent | |
| 2897 @vindex emerge-combine-versions-template | |
| 2898 While this example shows C preprocessor conditionals delimiting the two | |
| 2899 alternative versions, you can specify the strings to use by setting | |
| 2900 the variable @code{emerge-combine-versions-template} to a string of your | |
| 2901 choice. In the string, @samp{%a} says where to put version A, and | |
| 2902 @samp{%b} says where to put version B. The default setting, which | |
| 2903 produces the results shown above, looks like this: | |
| 2904 | |
| 2905 @example | |
| 2906 @group | |
| 2907 "#ifdef NEW\n%a#else /* not NEW */\n%b#endif /* not NEW */\n" | |
| 2908 @end group | |
| 2909 @end example | |
| 2910 | |
| 2911 @node Fine Points of Emerge | |
| 2912 @subsection Fine Points of Emerge | |
| 2913 | |
| 2914 During the merge, you mustn't try to edit the A and B buffers yourself. | |
| 2915 Emerge modifies them temporarily, but ultimately puts them back the way | |
| 2916 they were. | |
| 2917 | |
| 2918 You can have any number of merges going at once---just don't use any one | |
| 2919 buffer as input to more than one merge at once, since the temporary | |
| 2920 changes made in these buffers would get in each other's way. | |
| 2921 | |
| 2922 Starting Emerge can take a long time because it needs to compare the | |
| 2923 files fully. Emacs can't do anything else until @code{diff} finishes. | |
| 2924 Perhaps in the future someone will change Emerge to do the comparison in | |
| 2925 the background when the input files are large---then you could keep on | |
| 2926 doing other things with Emacs until Emerge is ready to accept | |
| 2927 commands. | |
| 2928 | |
| 2929 @vindex emerge-startup-hook | |
| 2930 After setting up the merge, Emerge runs the hook | |
| 2931 @code{emerge-startup-hook} (@pxref{Hooks}). | |
| 2932 | |
| 2933 @node C Modes | |
| 2934 @section C and Related Modes | |
| 2935 @cindex C mode | |
| 2936 @cindex Java mode | |
| 2937 @cindex Pike mode | |
| 2938 @cindex IDL mode | |
| 2939 @cindex CORBA IDL mode | |
| 2940 @cindex Objective C mode | |
| 2941 @cindex C++ mode | |
| 2942 @cindex mode, Java | |
| 2943 @cindex mode, C | |
| 2944 @cindex mode, Objective C | |
| 2945 @cindex mode, CORBA IDL | |
| 2946 @cindex mode, Pike | |
| 2947 | |
| 2948 This section describes special features available in C, C++, | |
| 2949 Objective-C, Java, CORBA IDL, and Pike modes. When we say ``C mode and | |
| 2950 related modes,'' those are the modes we mean. | |
| 2951 | |
|
28329
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2952 Additional information is available in the separate manual for these |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2953 modes. @xref{Top, CC Mode, ccmode, , CC Mode}. |
|
6e740f27f255
(Programs): Mention outline features.
Dave Love <fx@gnu.org>
parents:
27221
diff
changeset
|
2954 |
| 25829 | 2955 @menu |
| 2956 * Motion in C:: | |
| 2957 * Electric C:: | |
| 2958 * Hungry Delete:: | |
| 2959 * Other C Commands:: | |
| 2960 * Comments in C:: | |
| 2961 @end menu | |
| 2962 | |
| 2963 @node Motion in C | |
| 2964 @subsection C Mode Motion Commands | |
| 2965 | |
| 2966 This section describes commands for moving point, in C mode and | |
| 2967 related modes. | |
| 2968 | |
| 2969 @table @code | |
| 2970 @item C-c C-u | |
| 2971 @kindex C-c C-u @r{(C mode)} | |
| 2972 @findex c-up-conditional | |
| 2973 Move point back to the containing preprocessor conditional, leaving the | |
| 2974 mark behind. A prefix argument acts as a repeat count. With a negative | |
| 2975 argument, move point forward to the end of the containing | |
| 2976 preprocessor conditional. When going backwards, @code{#elif} is treated | |
| 2977 like @code{#else} followed by @code{#if}. When going forwards, | |
| 2978 @code{#elif} is ignored.@refill | |
| 2979 | |
| 2980 @item C-c C-p | |
| 2981 @kindex C-c C-p @r{(C mode)} | |
| 2982 @findex c-backward-conditional | |
| 2983 Move point back over a preprocessor conditional, leaving the mark | |
| 2984 behind. A prefix argument acts as a repeat count. With a negative | |
| 2985 argument, move forward. | |
| 2986 | |
| 2987 @item C-c C-n | |
| 2988 @kindex C-c C-n @r{(C mode)} | |
| 2989 @findex c-forward-conditional | |
| 2990 Move point forward across a preprocessor conditional, leaving the mark | |
| 2991 behind. A prefix argument acts as a repeat count. With a negative | |
| 2992 argument, move backward. | |
| 2993 | |
| 2994 @item M-a | |
| 2995 @kindex ESC a | |
| 2996 @findex c-beginning-of-statement | |
| 2997 Move point to the beginning of the innermost C statement | |
| 2998 (@code{c-beginning-of-statement}). If point is already at the beginning | |
| 2999 of a statement, move to the beginning of the preceding statement. With | |
| 3000 prefix argument @var{n}, move back @var{n} @minus{} 1 statements. | |
| 3001 | |
| 3002 If point is within a string or comment, or next to a comment (only | |
| 3003 whitespace between them), this command moves by sentences instead of | |
| 3004 statements. | |
| 3005 | |
| 3006 When called from a program, this function takes three optional | |
| 3007 arguments: the numeric prefix argument, a buffer position limit | |
| 3008 (don't move back before that place), and a flag that controls whether | |
| 3009 to do sentence motion when inside of a comment. | |
| 3010 | |
| 3011 @item M-e | |
| 3012 @kindex ESC e | |
| 3013 @findex c-end-of-statement | |
| 3014 Move point to the end of the innermost C statement; like @kbd{M-a} | |
| 3015 except that it moves in the other direction (@code{c-end-of-statement}). | |
| 3016 | |
| 3017 @item M-x c-backward-into-nomenclature | |
| 3018 @findex c-backward-into-nomenclature | |
| 3019 Move point backward to beginning of a C++ nomenclature section or word. | |
| 3020 With prefix argument @var{n}, move @var{n} times. If @var{n} is | |
| 3021 negative, move forward. C++ nomenclature means a symbol name in the | |
| 3022 style of NamingSymbolsWithMixedCaseAndNoUnderlines; each capital letter | |
| 3023 begins a section or word. | |
| 3024 | |
| 3025 In the GNU project, we recommend using underscores to separate words | |
| 3026 within an identifier in C or C++, rather than using case distinctions. | |
| 3027 | |
| 3028 @item M-x c-forward-into-nomenclature | |
| 3029 @findex c-forward-into-nomenclature | |
| 3030 Move point forward to end of a C++ nomenclature section or word. | |
| 3031 With prefix argument @var{n}, move @var{n} times. | |
| 3032 @end table | |
| 3033 | |
| 3034 @node Electric C | |
| 3035 @subsection Electric C Characters | |
| 3036 | |
| 3037 In C mode and related modes, certain printing characters are | |
| 3038 ``electric''---in addition to inserting themselves, they also reindent | |
| 3039 the current line and may insert newlines. This feature is controlled by | |
| 3040 the variable @code{c-auto-newline}. The ``electric'' characters are | |
| 3041 @kbd{@{}, @kbd{@}}, @kbd{:}, @kbd{#}, @kbd{;}, @kbd{,}, @kbd{<}, | |
| 3042 @kbd{>}, @kbd{/}, @kbd{*}, @kbd{(}, and @kbd{)}. | |
| 3043 | |
| 3044 Electric characters insert newlines only when the @dfn{auto-newline} | |
| 3045 feature is enabled (indicated by @samp{/a} in the mode line after the | |
| 3046 mode name). This feature is controlled by the variable | |
| 3047 @code{c-auto-newline}. You can turn this feature on or off with the | |
| 3048 command @kbd{C-c C-a}: | |
| 3049 | |
| 3050 @table @kbd | |
| 3051 @item C-c C-a | |
| 3052 @kindex C-c C-a @r{(C mode)} | |
| 3053 @findex c-toggle-auto-state | |
| 3054 Toggle the auto-newline feature (@code{c-toggle-auto-state}). With a | |
| 3055 prefix argument, this command turns the auto-newline feature on if the | |
| 3056 argument is positive, and off if it is negative. | |
| 3057 @end table | |
| 3058 | |
| 3059 The colon character is electric because that is appropriate for a | |
| 3060 single colon. But when you want to insert a double colon in C++, the | |
| 3061 electric behavior of colon is inconvenient. You can insert a double | |
| 3062 colon with no reindentation or newlines by typing @kbd{C-c :}: | |
| 3063 | |
| 3064 @table @kbd | |
| 3065 @item C-c : | |
| 3066 @kindex C-c : @r{(C mode)} | |
| 3067 @findex c-scope-operator | |
| 3068 Insert a double colon scope operator at point, without reindenting the | |
| 3069 line or adding any newlines (@code{c-scope-operator}). | |
| 3070 @end table | |
| 3071 | |
| 3072 The electric @kbd{#} key reindents the line if it appears to be the | |
| 3073 beginning of a preprocessor directive. This happens when the value of | |
| 3074 @code{c-electric-pound-behavior} is @code{(alignleft)}. You can turn | |
| 3075 this feature off by setting @code{c-electric-pound-behavior} to | |
| 3076 @code{nil}. | |
| 3077 | |
| 3078 The variable @code{c-hanging-braces-alist} controls the insertion of | |
| 3079 newlines before and after inserted braces. It is an association list | |
| 3080 with elements of the following form: @code{(@var{syntactic-symbol} | |
| 3081 . @var{nl-list})}. Most of the syntactic symbols that appear in | |
| 3082 @code{c-offsets-alist} are meaningful here as well. | |
| 3083 | |
| 3084 The list @var{nl-list} may contain either of the symbols | |
| 3085 @code{before} or @code{after}, or both; or it may be @code{nil}. When a | |
| 3086 brace is inserted, the syntactic context it defines is looked up in | |
| 3087 @code{c-hanging-braces-alist}; if it is found, the @var{nl-list} is used | |
| 3088 to determine where newlines are inserted: either before the brace, | |
| 3089 after, or both. If not found, the default is to insert a newline both | |
| 3090 before and after braces. | |
| 3091 | |
| 3092 The variable @code{c-hanging-colons-alist} controls the insertion of | |
| 3093 newlines before and after inserted colons. It is an association list | |
| 3094 with elements of the following form: @code{(@var{syntactic-symbol} | |
| 3095 . @var{nl-list})}. The list @var{nl-list} may contain either of the | |
| 3096 symbols @code{before} or @code{after}, or both; or it may be @code{nil}. | |
| 3097 | |
| 3098 When a colon is inserted, the syntactic symbol it defines is looked | |
| 3099 up in this list, and if found, the @var{nl-list} is used to determine | |
| 3100 where newlines are inserted: either before the brace, after, or both. | |
| 3101 If the syntactic symbol is not found in this list, no newlines are | |
| 3102 inserted. | |
| 3103 | |
| 3104 Electric characters can also delete newlines automatically when the | |
| 3105 auto-newline feature is enabled. This feature makes auto-newline more | |
| 3106 acceptable, by deleting the newlines in the most common cases where you | |
| 3107 do not want them. Emacs can recognize several cases in which deleting a | |
| 3108 newline might be desirable; by setting the variable | |
| 3109 @code{c-cleanup-list}, you can specify @emph{which} of these cases that | |
| 3110 should happen. The variable's value is a list of symbols, each | |
| 3111 describing one case for possible deletion of a newline. Here are the | |
| 3112 meaningful symbols, and their meanings: | |
| 3113 | |
| 3114 @table @code | |
| 3115 @item brace-catch-brace | |
| 3116 Clean up @samp{@} catch (@var{condition}) @{} constructs by placing the | |
| 3117 entire construct on a single line. The clean-up occurs when you type | |
| 3118 the @samp{@{}, if there is nothing between the braces aside from | |
| 3119 @code{catch} and @var{condition}. | |
| 3120 | |
| 3121 @item brace-else-brace | |
| 3122 Clean up @samp{@} else @{} constructs by placing the entire construct on | |
| 3123 a single line. The clean-up occurs when you type the @samp{@{} after | |
| 3124 the @code{else}, but only if there is nothing but white space between | |
| 3125 the braces and the @code{else}. | |
| 3126 | |
| 3127 @item brace-elseif-brace | |
| 3128 Clean up @samp{@} else if (@dots{}) @{} constructs by placing the entire | |
| 3129 construct on a single line. The clean-up occurs when you type the | |
| 3130 @samp{@{}, if there is nothing but white space between the @samp{@}} and | |
| 3131 @samp{@{} aside from the keywords and the @code{if}-condition. | |
| 3132 | |
| 3133 @item empty-defun-braces | |
| 3134 Clean up empty defun braces by placing the braces on the same | |
| 3135 line. Clean-up occurs when you type the closing brace. | |
| 3136 | |
| 3137 @item defun-close-semi | |
| 3138 Clean up the semicolon after a @code{struct} or similar type | |
| 3139 declaration, by placing the semicolon on the same line as the closing | |
| 3140 brace. Clean-up occurs when you type the semicolon. | |
| 3141 | |
| 3142 @item list-close-comma | |
| 3143 Clean up commas following braces in array and aggregate | |
| 3144 initializers. Clean-up occurs when you type the comma. | |
| 3145 | |
| 3146 @item scope-operator | |
| 3147 Clean up double colons which may designate a C++ scope operator, by | |
| 3148 placing the colons together. Clean-up occurs when you type the second | |
| 3149 colon, but only when the two colons are separated by nothing but | |
| 3150 whitespace. | |
| 3151 @end table | |
| 3152 | |
| 3153 @node Hungry Delete | |
| 3154 @subsection Hungry Delete Feature in C | |
| 3155 | |
| 3156 When the @dfn{hungry-delete} feature is enabled (indicated by | |
| 3157 @samp{/h} or @samp{/ah} in the mode line after the mode name), a single | |
| 3158 @key{DEL} command deletes all preceding whitespace, not just one space. | |
| 3159 To turn this feature on or off, use @kbd{C-c C-d}: | |
| 3160 | |
| 3161 @table @kbd | |
| 3162 @item C-c C-d | |
| 3163 @kindex C-c C-d @r{(C mode)} | |
| 3164 @findex c-toggle-hungry-state | |
| 3165 Toggle the hungry-delete feature (@code{c-toggle-hungry-state}). With a | |
| 3166 prefix argument, this command turns the hungry-delete feature on if the | |
| 3167 argument is positive, and off if it is negative. | |
| 3168 | |
| 3169 @item C-c C-t | |
| 3170 @kindex C-c C-t @r{(C mode)} | |
| 3171 @findex c-toggle-auto-hungry-state | |
| 3172 Toggle the auto-newline and hungry-delete features, both at once | |
| 3173 (@code{c-toggle-auto-hungry-state}). | |
| 3174 @end table | |
| 3175 | |
| 3176 @vindex c-hungry-delete-key | |
| 3177 The variable @code{c-hungry-delete-key} controls whether the | |
| 3178 hungry-delete feature is enabled. | |
| 3179 | |
| 3180 @node Other C Commands | |
| 3181 @subsection Other Commands for C Mode | |
| 3182 | |
| 3183 @table @kbd | |
| 3184 @item C-M-h | |
| 3185 @findex c-mark-function | |
| 3186 @kindex C-M-h @r{(C mode)} | |
| 3187 Put mark at the end of a function definition, and put point at the | |
| 3188 beginning (@code{c-mark-function}). | |
| 3189 | |
| 3190 @item M-q | |
| 3191 @kindex M-q @r{(C mode)} | |
| 3192 @findex c-fill-paragraph | |
| 3193 Fill a paragraph, handling C and C++ comments (@code{c-fill-paragraph}). | |
| 3194 If any part of the current line is a comment or within a comment, this | |
| 3195 command fills the comment or the paragraph of it that point is in, | |
| 3196 preserving the comment indentation and comment delimiters. | |
| 3197 | |
| 3198 @item C-c C-e | |
| 3199 @cindex macro expansion in C | |
| 3200 @cindex expansion of C macros | |
| 3201 @findex c-macro-expand | |
| 3202 @kindex C-c C-e @r{(C mode)} | |
| 3203 Run the C preprocessor on the text in the region, and show the result, | |
| 3204 which includes the expansion of all the macro calls | |
| 3205 (@code{c-macro-expand}). The buffer text before the region is also | |
| 3206 included in preprocessing, for the sake of macros defined there, but the | |
| 3207 output from this part isn't shown. | |
| 3208 | |
| 3209 When you are debugging C code that uses macros, sometimes it is hard to | |
| 3210 figure out precisely how the macros expand. With this command, you | |
| 3211 don't have to figure it out; you can see the expansions. | |
| 3212 | |
| 3213 @item C-c C-\ | |
| 3214 @findex c-backslash-region | |
| 3215 @kindex C-c C-\ @r{(C mode)} | |
| 3216 Insert or align @samp{\} characters at the ends of the lines of the | |
| 3217 region (@code{c-backslash-region}). This is useful after writing or | |
| 3218 editing a C macro definition. | |
| 3219 | |
| 3220 If a line already ends in @samp{\}, this command adjusts the amount of | |
| 3221 whitespace before it. Otherwise, it inserts a new @samp{\}. However, | |
| 3222 the last line in the region is treated specially; no @samp{\} is | |
| 3223 inserted on that line, and any @samp{\} there is deleted. | |
| 3224 | |
| 3225 @item M-x cpp-highlight-buffer | |
| 3226 @cindex preprocessor highlighting | |
| 3227 @findex cpp-highlight-buffer | |
| 3228 Highlight parts of the text according to its preprocessor conditionals. | |
| 3229 This command displays another buffer named @samp{*CPP Edit*}, which | |
| 3230 serves as a graphic menu for selecting how to display particular kinds | |
| 3231 of conditionals and their contents. After changing various settings, | |
| 3232 click on @samp{[A]pply these settings} (or go to that buffer and type | |
| 3233 @kbd{a}) to rehighlight the C mode buffer accordingly. | |
| 3234 | |
| 3235 @item C-c C-s | |
| 3236 @findex c-show-syntactic-information | |
| 3237 @kindex C-c C-s @r{(C mode)} | |
| 3238 Display the syntactic information about the current source line | |
| 3239 (@code{c-show-syntactic-information}). This is the information that | |
| 3240 directs how the line is indented. | |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3241 |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3242 @item M-x cwarn-mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3243 @itemx M-x global-cwarn-mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3244 @findex cwarn-mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3245 @findex global-cwarn-mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3246 @cindex CWarn mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3247 @cindex suspicious constructions in C, C++ |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3248 CWarn minor mode highlights suspicious C and C++ constructions: |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3249 |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3250 @itemize @bullet{} |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3251 @item |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3252 Assignments inside expressions, including variations like @samp{+=}; |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3253 @item |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3254 Semicolon following immediately after @samp{if}, @samp{for}, and @samp{while} |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3255 (except after a @samp{do @dots{} while} statement); |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3256 @item |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3257 C++ functions with reference parameters. |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3258 @end itemize |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3259 |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3260 @noindent |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3261 You can activate the mode either by customizing @code{global-cwarn-mode} |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3262 or by adding @code{cwarn-mode} to @code{c-mode-common-hook}. It |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3263 requires Font Lock mode to be active. |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3264 |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3265 @item M-x hide-ifdef-mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3266 @findex hide-ifdef-mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3267 @cindex Hide-ifdef mode |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3268 Hide-ifdef minor mode hides selected code within @samp{#if} and |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3269 @samp{#ifdef} preprocessor blocks. You can activate it by adding |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3270 @code{hide-ifdef-mode} to @code{c-mode-common-hook}. See the mode's |
|
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3271 help for more information. |
| 25829 | 3272 @end table |
| 3273 | |
| 3274 @node Comments in C | |
| 3275 @subsection Comments in C Modes | |
| 3276 | |
| 3277 C mode and related modes use a number of variables for controlling | |
| 3278 comment format. | |
| 3279 | |
| 3280 @table @code | |
| 3281 @item c-comment-only-line-offset | |
| 3282 @vindex c-comment-only-line-offset | |
| 3283 Extra offset for line which contains only the start of a comment. It | |
| 3284 can be either an integer or a cons cell of the form | |
| 3285 @code{(@var{non-anchored-offset} . @var{anchored-offset})}, where | |
| 3286 @var{non-anchored-offset} is the amount of offset given to | |
| 3287 non-column-zero anchored comment-only lines, and @var{anchored-offset} | |
| 3288 is the amount of offset to give column-zero anchored comment-only lines. | |
| 3289 Just an integer as value is equivalent to @code{(@var{val} . 0)}. | |
| 3290 | |
| 3291 @item c-comment-start-regexp | |
| 3292 @vindex c-comment-start-regexp | |
| 3293 This buffer-local variable specifies how to recognize the start of a comment. | |
| 3294 | |
| 3295 @item c-hanging-comment-ender-p | |
| 3296 @vindex c-hanging-comment-ender-p | |
| 3297 If this variable is @code{nil}, @code{c-fill-paragraph} leaves the | |
| 3298 comment terminator of a block comment on a line by itself. The default | |
| 3299 value is @code{t}, which puts the comment-end delimiter @samp{*/} at the | |
| 3300 end of the last line of the comment text. | |
| 3301 | |
| 3302 @item c-hanging-comment-starter-p | |
| 3303 @vindex c-hanging-comment-starter-p | |
| 3304 If this variable is @code{nil}, @code{c-fill-paragraph} leaves the | |
| 3305 starting delimiter of a block comment on a line by itself. The default | |
| 3306 value is @code{t}, which puts the comment-start delimiter @samp{/*} at | |
| 3307 the beginning of the first line of the comment text. | |
| 3308 @end table | |
| 3309 | |
|
30810
6c6b0162bae2
Tidy up previous additions. List more languages. Glasses mode.
Dave Love <fx@gnu.org>
parents:
30793
diff
changeset
|
3310 |
| 25829 | 3311 @node Fortran |
| 3312 @section Fortran Mode | |
| 3313 @cindex Fortran mode | |
| 3314 @cindex mode, Fortran | |
| 3315 | |
| 3316 Fortran mode provides special motion commands for Fortran statements and | |
| 3317 subprograms, and indentation commands that understand Fortran conventions | |
| 3318 of nesting, line numbers and continuation statements. Fortran mode has | |
| 3319 its own Auto Fill mode that breaks long lines into proper Fortran | |
| 3320 continuation lines. | |
| 3321 | |
| 3322 Special commands for comments are provided because Fortran comments | |
| 3323 are unlike those of other languages. Built-in abbrevs optionally save | |
| 3324 typing when you insert Fortran keywords. | |
| 3325 | |
| 3326 @findex fortran-mode | |
| 3327 Use @kbd{M-x fortran-mode} to switch to this major mode. This command | |
| 3328 runs the hook @code{fortran-mode-hook} (@pxref{Hooks}). | |
| 3329 | |
| 26106 | 3330 @cindex Fortran77 |
| 3331 @cindex Fortran90 | |
| 3332 @findex f90-mode | |
| 3333 @findex fortran-mode | |
| 3334 Note that Fortan mode described here (obtained with the | |
| 3335 @code{fortran-mode} command) is for editing the old Fortran77 | |
| 3336 idiosyncratic `fixed format' source form. For editing the modern | |
| 3337 Fortran90 `free format' source form (which is supported by the GNU | |
| 3338 Fortran compiler) use @code{f90-mode}. | |
| 3339 | |
| 3340 By default @code{fortran-mode} is invoked on files with extension | |
| 3341 @samp{.f}, @samp{.F} or @samp{.for} and @code{f90-mode} is invoked for | |
| 3342 the extension @samp{.f90}. | |
| 3343 | |
| 25829 | 3344 @menu |
| 3345 * Motion: Fortran Motion. Moving point by statements or subprograms. | |
| 3346 * Indent: Fortran Indent. Indentation commands for Fortran. | |
| 3347 * Comments: Fortran Comments. Inserting and aligning comments. | |
| 3348 * Autofill: Fortran Autofill. Auto fill minor mode for Fortran. | |
| 3349 * Columns: Fortran Columns. Measuring columns for valid Fortran. | |
| 3350 * Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords. | |
| 3351 * Misc: Fortran Misc. Other Fortran mode features. | |
| 3352 @end menu | |
| 3353 | |
| 3354 @node Fortran Motion | |
| 3355 @subsection Motion Commands | |
| 3356 | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3357 In addition to the normal commands for moving by and operating on |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3358 `defuns' (Fortran subprograms---functions |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3359 and subroutines) Fortran mode provides special commands to move by statements. |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3360 |
| 25829 | 3361 @kindex C-c C-p @r{(Fortran mode)} |
| 3362 @kindex C-c C-n @r{(Fortran mode)} | |
| 3363 @findex fortran-previous-statement | |
| 3364 @findex fortran-next-statement | |
| 3365 | |
| 3366 @table @kbd | |
| 3367 @item C-c C-n | |
| 3368 Move to beginning of current or next statement | |
| 3369 (@code{fortran-next-statement}). | |
| 3370 @item C-c C-p | |
| 3371 Move to beginning of current or previous statement | |
| 3372 (@code{fortran-previous-statement}). | |
| 3373 @end table | |
| 3374 | |
| 3375 @node Fortran Indent | |
| 3376 @subsection Fortran Indentation | |
| 3377 | |
| 3378 Special commands and features are needed for indenting Fortran code in | |
| 3379 order to make sure various syntactic entities (line numbers, comment line | |
| 3380 indicators and continuation line flags) appear in the columns that are | |
| 3381 required for standard Fortran. | |
| 3382 | |
| 3383 @menu | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3384 * Commands: ForIndent Commands. Commands for indenting and filling Fortran. |
| 25829 | 3385 * Contline: ForIndent Cont. How continuation lines indent. |
| 3386 * Numbers: ForIndent Num. How line numbers auto-indent. | |
| 3387 * Conv: ForIndent Conv. Conventions you must obey to avoid trouble. | |
| 3388 * Vars: ForIndent Vars. Variables controlling Fortran indent style. | |
| 3389 @end menu | |
| 3390 | |
| 3391 @node ForIndent Commands | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3392 @subsubsection Fortran-Specific Indentation and Filling Commands |
| 25829 | 3393 |
| 3394 @table @kbd | |
| 3395 @item C-M-j | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3396 Break the current line and set up a continuation line |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3397 (@code{fortran-split-line}). |
| 25829 | 3398 @item M-^ |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3399 Join this line to the previous line (@code{fortran-join-line}). |
| 25829 | 3400 @item C-M-q |
| 3401 Indent all the lines of the subprogram point is in | |
| 3402 (@code{fortran-indent-subprogram}). | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3403 @item M-q |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3404 Fill a comment block or statement. |
| 25829 | 3405 @end table |
| 3406 | |
| 3407 @kindex C-M-q @r{(Fortran mode)} | |
| 3408 @findex fortran-indent-subprogram | |
| 3409 The key @kbd{C-M-q} runs @code{fortran-indent-subprogram}, a command | |
| 3410 to reindent all the lines of the Fortran subprogram (function or | |
| 3411 subroutine) containing point. | |
| 3412 | |
| 3413 @kindex C-M-j @r{(Fortran mode)} | |
| 3414 @findex fortran-split-line | |
| 3415 The key @kbd{C-M-j} runs @code{fortran-split-line}, which splits | |
| 3416 a line in the appropriate fashion for Fortran. In a non-comment line, | |
| 3417 the second half becomes a continuation line and is indented | |
| 3418 accordingly. In a comment line, both halves become separate comment | |
| 3419 lines. | |
| 3420 | |
| 3421 @kindex M-^ @r{(Fortran mode)} | |
| 26106 | 3422 @kindex C-c C-d @r{(Fortran mode)} |
| 3423 @findex fortran-join-line | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3424 @kbd{M-^} or @kbd{C-c C-d} runs the command @code{fortran-join-line}, |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3425 which joins a continuation line back to the previous line, roughly as |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3426 the inverse of @code{fortran-split-line}. The point must be on a |
| 26106 | 3427 continuation line when this command is invoked. |
| 3428 | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3429 @kindex M-q @r{(Fortran mode)} |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3430 Fortran mode defines the function for filling paragraphs such that |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3431 @kbd{M-q} fills the comment block or statement around point. Filling a |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3432 statement removes excess statement continuations. |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3433 |
| 25829 | 3434 @node ForIndent Cont |
| 3435 @subsubsection Continuation Lines | |
| 3436 @cindex Fortran continuation lines | |
| 3437 | |
| 3438 @vindex fortran-continuation-string | |
| 3439 Most modern Fortran compilers allow two ways of writing continuation | |
| 3440 lines. If the first non-space character on a line is in column 5, then | |
| 3441 that line is a continuation of the previous line. We call this | |
| 3442 @dfn{fixed format}. (In GNU Emacs we always count columns from 0.) The | |
| 3443 variable @code{fortran-continuation-string} specifies what character to | |
| 3444 put on column 5. A line that starts with a tab character followed by | |
| 3445 any digit except @samp{0} is also a continuation line. We call this | |
| 3446 style of continuation @dfn{tab format}. | |
| 3447 | |
| 3448 @vindex indent-tabs-mode @r{(Fortran mode)} | |
| 3449 Fortran mode can make either style of continuation line, but you | |
| 3450 must specify which one you prefer. The value of the variable | |
| 3451 @code{indent-tabs-mode} controls the choice: @code{nil} for fixed | |
| 3452 format, and non-@code{nil} for tab format. You can tell which style | |
| 3453 is presently in effect by the presence or absence of the string | |
| 3454 @samp{Tab} in the mode line. | |
| 3455 | |
| 3456 If the text on a line starts with the conventional Fortran | |
| 3457 continuation marker @samp{$}, or if it begins with any non-whitespace | |
| 3458 character in column 5, Fortran mode treats it as a continuation line. | |
| 3459 When you indent a continuation line with @key{TAB}, it converts the line | |
| 3460 to the current continuation style. When you split a Fortran statement | |
| 3461 with @kbd{C-M-j}, the continuation marker on the newline is created | |
| 3462 according to the continuation style. | |
| 3463 | |
| 3464 The setting of continuation style affects several other aspects of | |
| 3465 editing in Fortran mode. In fixed format mode, the minimum column | |
| 3466 number for the body of a statement is 6. Lines inside of Fortran | |
| 3467 blocks that are indented to larger column numbers always use only the | |
| 3468 space character for whitespace. In tab format mode, the minimum | |
| 3469 column number for the statement body is 8, and the whitespace before | |
| 3470 column 8 must always consist of one tab character. | |
| 3471 | |
| 3472 @vindex fortran-tab-mode-default | |
| 3473 @vindex fortran-analyze-depth | |
| 3474 When you enter Fortran mode for an existing file, it tries to deduce the | |
| 3475 proper continuation style automatically from the file contents. The first | |
| 3476 line that begins with either a tab character or six spaces determines the | |
| 3477 choice. The variable @code{fortran-analyze-depth} specifies how many lines | |
| 3478 to consider (at the beginning of the file); if none of those lines | |
| 3479 indicates a style, then the variable @code{fortran-tab-mode-default} | |
| 3480 specifies the style. If it is @code{nil}, that specifies fixed format, and | |
| 3481 non-@code{nil} specifies tab format. | |
| 3482 | |
| 3483 @node ForIndent Num | |
| 3484 @subsubsection Line Numbers | |
| 3485 | |
| 3486 If a number is the first non-whitespace in the line, Fortran | |
| 3487 indentation assumes it is a line number and moves it to columns 0 | |
| 3488 through 4. (Columns always count from 0 in GNU Emacs.) | |
| 3489 | |
| 3490 @vindex fortran-line-number-indent | |
| 3491 Line numbers of four digits or less are normally indented one space. | |
| 3492 The variable @code{fortran-line-number-indent} controls this; it | |
| 3493 specifies the maximum indentation a line number can have. Line numbers | |
| 3494 are indented to right-justify them to end in column 4 unless that would | |
| 3495 require more than this maximum indentation. The default value of the | |
| 3496 variable is 1. | |
| 3497 | |
| 3498 @vindex fortran-electric-line-number | |
| 3499 Simply inserting a line number is enough to indent it according to | |
| 3500 these rules. As each digit is inserted, the indentation is recomputed. | |
| 3501 To turn off this feature, set the variable | |
| 3502 @code{fortran-electric-line-number} to @code{nil}. Then inserting line | |
| 3503 numbers is like inserting anything else. | |
| 3504 | |
| 3505 @node ForIndent Conv | |
| 3506 @subsubsection Syntactic Conventions | |
| 3507 | |
| 3508 Fortran mode assumes that you follow certain conventions that simplify | |
| 3509 the task of understanding a Fortran program well enough to indent it | |
| 3510 properly: | |
| 3511 | |
| 3512 @itemize @bullet | |
| 3513 @item | |
| 3514 Two nested @samp{do} loops never share a @samp{continue} statement. | |
| 3515 | |
| 3516 @item | |
| 3517 Fortran keywords such as @samp{if}, @samp{else}, @samp{then}, @samp{do} | |
| 3518 and others are written without embedded whitespace or line breaks. | |
| 3519 | |
| 3520 Fortran compilers generally ignore whitespace outside of string | |
| 3521 constants, but Fortran mode does not recognize these keywords if they | |
| 3522 are not contiguous. Constructs such as @samp{else if} or @samp{end do} | |
| 3523 are acceptable, but the second word should be on the same line as the | |
| 3524 first and not on a continuation line. | |
| 3525 @end itemize | |
| 3526 | |
| 3527 @noindent | |
| 3528 If you fail to follow these conventions, the indentation commands may | |
| 3529 indent some lines unaesthetically. However, a correct Fortran program | |
| 3530 retains its meaning when reindented even if the conventions are not | |
| 3531 followed. | |
| 3532 | |
| 3533 @node ForIndent Vars | |
| 3534 @subsubsection Variables for Fortran Indentation | |
| 3535 | |
| 3536 @vindex fortran-do-indent | |
| 3537 @vindex fortran-if-indent | |
| 3538 @vindex fortran-structure-indent | |
| 3539 @vindex fortran-continuation-indent | |
| 3540 @vindex fortran-check-all-num@dots{} | |
| 3541 @vindex fortran-minimum-statement-indent@dots{} | |
| 3542 Several additional variables control how Fortran indentation works: | |
| 3543 | |
| 3544 @table @code | |
| 3545 @item fortran-do-indent | |
| 3546 Extra indentation within each level of @samp{do} statement (default 3). | |
| 3547 | |
| 3548 @item fortran-if-indent | |
| 3549 Extra indentation within each level of @samp{if} statement (default 3). | |
| 3550 This value is also used for extra indentation within each level of the | |
| 3551 Fortran 90 @samp{where} statement. | |
| 3552 | |
| 3553 @item fortran-structure-indent | |
| 3554 Extra indentation within each level of @samp{structure}, @samp{union}, or | |
| 3555 @samp{map} statements (default 3). | |
| 3556 | |
| 3557 @item fortran-continuation-indent | |
| 3558 Extra indentation for bodies of continuation lines (default 5). | |
| 3559 | |
| 3560 @item fortran-check-all-num-for-matching-do | |
| 3561 If this is @code{nil}, indentation assumes that each @samp{do} statement | |
| 3562 ends on a @samp{continue} statement. Therefore, when computing | |
| 3563 indentation for a statement other than @samp{continue}, it can save time | |
| 3564 by not checking for a @samp{do} statement ending there. If this is | |
| 3565 non-@code{nil}, indenting any numbered statement must check for a | |
| 3566 @samp{do} that ends there. The default is @code{nil}. | |
| 3567 | |
| 3568 @item fortran-blink-matching-if | |
| 3569 If this is @code{t}, indenting an @samp{endif} statement moves the | |
| 3570 cursor momentarily to the matching @samp{if} statement to show where it | |
| 3571 is. The default is @code{nil}. | |
| 3572 | |
| 3573 @item fortran-minimum-statement-indent-fixed | |
| 3574 Minimum indentation for fortran statements when using fixed format | |
| 3575 continuation line style. Statement bodies are never indented less than | |
| 3576 this much. The default is 6. | |
| 3577 | |
| 3578 @item fortran-minimum-statement-indent-tab | |
| 3579 Minimum indentation for fortran statements for tab format continuation line | |
| 3580 style. Statement bodies are never indented less than this much. The | |
| 3581 default is 8. | |
| 3582 @end table | |
| 3583 | |
| 3584 @node Fortran Comments | |
| 3585 @subsection Fortran Comments | |
| 3586 | |
| 3587 The usual Emacs comment commands assume that a comment can follow a line | |
| 3588 of code. In Fortran, the standard comment syntax requires an entire line | |
| 3589 to be just a comment. Therefore, Fortran mode replaces the standard Emacs | |
| 3590 comment commands and defines some new variables. | |
| 3591 | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3592 Fortran mode can also handle the Fortran90 comment syntax where comments |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3593 start with @samp{!} and can follow other text. Because only some Fortran77 |
| 25829 | 3594 compilers accept this syntax, Fortran mode will not insert such comments |
| 3595 unless you have said in advance to do so. To do this, set the variable | |
| 3596 @code{comment-start} to @samp{"!"} (@pxref{Variables}). | |
| 3597 | |
| 3598 @table @kbd | |
| 3599 @item M-; | |
| 3600 Align comment or insert new comment (@code{fortran-comment-indent}). | |
| 3601 | |
| 3602 @item C-x ; | |
| 3603 Applies to nonstandard @samp{!} comments only. | |
| 3604 | |
| 3605 @item C-c ; | |
| 3606 Turn all lines of the region into comments, or (with argument) turn them back | |
| 3607 into real code (@code{fortran-comment-region}). | |
| 3608 @end table | |
| 3609 | |
| 3610 @kbd{M-;} in Fortran mode is redefined as the command | |
| 3611 @code{fortran-comment-indent}. Like the usual @kbd{M-;} command, this | |
| 3612 recognizes any kind of existing comment and aligns its text appropriately; | |
| 3613 if there is no existing comment, a comment is inserted and aligned. But | |
| 3614 inserting and aligning comments are not the same in Fortran mode as in | |
| 3615 other modes. | |
| 3616 | |
| 3617 When a new comment must be inserted, if the current line is blank, a | |
| 3618 full-line comment is inserted. On a non-blank line, a nonstandard @samp{!} | |
| 3619 comment is inserted if you have said you want to use them. Otherwise a | |
| 3620 full-line comment is inserted on a new line before the current line. | |
| 3621 | |
| 3622 Nonstandard @samp{!} comments are aligned like comments in other | |
| 3623 languages, but full-line comments are different. In a standard full-line | |
| 3624 comment, the comment delimiter itself must always appear in column zero. | |
| 3625 What can be aligned is the text within the comment. You can choose from | |
| 3626 three styles of alignment by setting the variable | |
| 3627 @code{fortran-comment-indent-style} to one of these values: | |
| 3628 | |
| 3629 @vindex fortran-comment-indent-style | |
| 3630 @vindex fortran-comment-line-extra-indent | |
| 3631 @table @code | |
| 3632 @item fixed | |
| 3633 Align the text at a fixed column, which is the sum of | |
| 3634 @code{fortran-comment-line-extra-indent} and the minimum statement | |
| 3635 indentation. This is the default. | |
| 3636 | |
| 3637 The minimum statement indentation is | |
| 3638 @code{fortran-minimum-statement-indent-fixed} for fixed format | |
| 3639 continuation line style and @code{fortran-minimum-statement-indent-tab} | |
| 3640 for tab format style. | |
| 3641 | |
| 3642 @item relative | |
| 3643 Align the text as if it were a line of code, but with an additional | |
| 3644 @code{fortran-comment-line-extra-indent} columns of indentation. | |
| 3645 | |
| 3646 @item nil | |
| 3647 Don't move text in full-line comments automatically at all. | |
| 3648 @end table | |
| 3649 | |
| 3650 @vindex fortran-comment-indent-char | |
| 3651 In addition, you can specify the character to be used to indent within | |
| 3652 full-line comments by setting the variable | |
| 3653 @code{fortran-comment-indent-char} to the single-character string you want | |
| 3654 to use. | |
| 3655 | |
| 3656 @vindex comment-line-start | |
| 3657 @vindex comment-line-start-skip | |
| 3658 Fortran mode introduces two variables @code{comment-line-start} and | |
| 3659 @code{comment-line-start-skip}, which play for full-line comments the same | |
| 3660 roles played by @code{comment-start} and @code{comment-start-skip} for | |
| 3661 ordinary text-following comments. Normally these are set properly by | |
| 3662 Fortran mode, so you do not need to change them. | |
| 3663 | |
| 3664 The normal Emacs comment command @kbd{C-x ;} has not been redefined. If | |
| 3665 you use @samp{!} comments, this command can be used with them. Otherwise | |
| 3666 it is useless in Fortran mode. | |
| 3667 | |
| 3668 @kindex C-c ; @r{(Fortran mode)} | |
| 3669 @findex fortran-comment-region | |
| 3670 @vindex fortran-comment-region | |
| 3671 The command @kbd{C-c ;} (@code{fortran-comment-region}) turns all the | |
| 3672 lines of the region into comments by inserting the string @samp{C$$$} at | |
| 3673 the front of each one. With a numeric argument, it turns the region | |
| 3674 back into live code by deleting @samp{C$$$} from the front of each line | |
| 3675 in it. The string used for these comments can be controlled by setting | |
| 3676 the variable @code{fortran-comment-region}. Note that here we have an | |
| 3677 example of a command and a variable with the same name; these two uses | |
| 3678 of the name never conflict because in Lisp and in Emacs it is always | |
| 3679 clear from the context which one is meant. | |
| 3680 | |
| 3681 @node Fortran Autofill | |
| 3682 @subsection Fortran Auto Fill Mode | |
| 3683 | |
| 3684 Fortran Auto Fill mode is a minor mode which automatically splits | |
| 3685 Fortran statements as you insert them when they become too wide. | |
| 3686 Splitting a statement involves making continuation lines using | |
| 3687 @code{fortran-continuation-string} (@pxref{ForIndent Cont}). This | |
| 3688 splitting happens when you type @key{SPC}, @key{RET}, or @key{TAB}, and | |
| 3689 also in the Fortran indentation commands. | |
| 3690 | |
| 3691 @findex fortran-auto-fill-mode | |
| 3692 @kbd{M-x fortran-auto-fill-mode} turns Fortran Auto Fill mode on if it | |
| 3693 was off, or off if it was on. This command works the same as @kbd{M-x | |
| 3694 auto-fill-mode} does for normal Auto Fill mode (@pxref{Filling}). A | |
| 3695 positive numeric argument turns Fortran Auto Fill mode on, and a | |
| 3696 negative argument turns it off. You can see when Fortran Auto Fill mode | |
| 3697 is in effect by the presence of the word @samp{Fill} in the mode line, | |
| 3698 inside the parentheses. Fortran Auto Fill mode is a minor mode, turned | |
| 3699 on or off for each buffer individually. @xref{Minor Modes}. | |
| 3700 | |
| 3701 @vindex fortran-break-before-delimiters | |
| 3702 Fortran Auto Fill mode breaks lines at spaces or delimiters when the | |
| 3703 lines get longer than the desired width (the value of @code{fill-column}). | |
| 3704 The delimiters that Fortran Auto Fill mode may break at are @samp{,}, | |
| 3705 @samp{'}, @samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, and @samp{)}. | |
| 3706 The line break comes after the delimiter if the variable | |
| 3707 @code{fortran-break-before-delimiters} is @code{nil}. Otherwise (and by | |
| 3708 default), the break comes before the delimiter. | |
| 3709 | |
| 3710 By default, Fortran Auto Fill mode is not enabled. If you want this | |
| 3711 feature turned on permanently, add a hook function to | |
| 3712 @code{fortran-mode-hook} to execute @code{(fortran-auto-fill-mode 1)}. | |
| 3713 @xref{Hooks}. | |
| 3714 | |
| 3715 @node Fortran Columns | |
| 3716 @subsection Checking Columns in Fortran | |
| 3717 | |
| 3718 @table @kbd | |
| 3719 @item C-c C-r | |
| 3720 Display a ``column ruler'' momentarily above the current line | |
| 3721 (@code{fortran-column-ruler}). | |
| 3722 @item C-c C-w | |
| 3723 Split the current window horizontally temporarily so that it is 72 | |
| 3724 columns wide. This may help you avoid making lines longer than the | |
| 3725 72-character limit that some Fortran compilers impose | |
| 3726 (@code{fortran-window-create-momentarily}). | |
| 3727 @end table | |
| 3728 | |
| 3729 @kindex C-c C-r @r{(Fortran mode)} | |
| 3730 @findex fortran-column-ruler | |
| 3731 @vindex fortran-column-ruler | |
| 3732 The command @kbd{C-c C-r} (@code{fortran-column-ruler}) shows a column | |
| 3733 ruler momentarily above the current line. The comment ruler is two lines | |
| 3734 of text that show you the locations of columns with special significance in | |
| 3735 Fortran programs. Square brackets show the limits of the columns for line | |
| 3736 numbers, and curly brackets show the limits of the columns for the | |
| 3737 statement body. Column numbers appear above them. | |
| 3738 | |
| 3739 Note that the column numbers count from zero, as always in GNU Emacs. | |
| 3740 As a result, the numbers may be one less than those you are familiar | |
| 3741 with; but the positions they indicate in the line are standard for | |
| 3742 Fortran. | |
| 3743 | |
| 26264 | 3744 The text used to display the column ruler depends on the value of |
| 25829 | 3745 the variable @code{indent-tabs-mode}. If @code{indent-tabs-mode} is |
| 3746 @code{nil}, then the value of the variable | |
| 3747 @code{fortran-column-ruler-fixed} is used as the column ruler. | |
| 3748 Otherwise, the variable @code{fortran-column-ruler-tab} is displayed. | |
| 3749 By changing these variables, you can change the column ruler display. | |
| 3750 | |
| 26106 | 3751 @kindex C-u C-c C-w @r{(Fortran mode)} |
| 25829 | 3752 @findex fortran-window-create |
| 26106 | 3753 For even more help, use @kbd{M-x fortran-window-create}), a |
| 25829 | 3754 command which splits the current window horizontally, making a window 72 |
| 3755 columns wide. By editing in this window you can immediately see when you | |
| 3756 make a line too wide to be correct Fortran. | |
| 3757 | |
| 26106 | 3758 @kindex C-c C-w @r{(Fortran mode)} |
| 3759 @findex fortran-window-create-momentarily | |
| 3760 Also, @kbd{C-c C-w} (@code{fortran-window-create-momentarily}) can be | |
| 3761 used temporarily to split the current window horizontally, making a | |
| 3762 window 72 columns wide to check column widths rather than to edit in | |
| 3763 this mode. The normal width is restored when you type a space. | |
| 3764 | |
| 25829 | 3765 @node Fortran Abbrev |
| 3766 @subsection Fortran Keyword Abbrevs | |
| 3767 | |
| 3768 Fortran mode provides many built-in abbrevs for common keywords and | |
| 3769 declarations. These are the same sort of abbrev that you can define | |
| 3770 yourself. To use them, you must turn on Abbrev mode. @xref{Abbrevs}. | |
| 3771 | |
| 3772 The built-in abbrevs are unusual in one way: they all start with a | |
| 3773 semicolon. You cannot normally use semicolon in an abbrev, but Fortran | |
| 3774 mode makes this possible by changing the syntax of semicolon to ``word | |
| 3775 constituent.'' | |
| 3776 | |
| 3777 For example, one built-in Fortran abbrev is @samp{;c} for | |
| 3778 @samp{continue}. If you insert @samp{;c} and then insert a punctuation | |
| 3779 character such as a space or a newline, the @samp{;c} expands automatically | |
| 3780 to @samp{continue}, provided Abbrev mode is enabled.@refill | |
| 3781 | |
| 3782 Type @samp{;?} or @samp{;C-h} to display a list of all the built-in | |
| 3783 Fortran abbrevs and what they stand for. | |
| 3784 | |
| 3785 @node Fortran Misc | |
| 3786 @subsection Other Fortran Mode Commands | |
| 3787 | |
|
27221
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3788 The command @kbd{fortran-strip-sqeuence-nos} can be used to remove text |
|
4a723a7bc25a
Mention outline-minor-mode, check-parens,
Dave Love <fx@gnu.org>
parents:
26462
diff
changeset
|
3789 past Fortran column 72, which is typically old `sequence numbers'. |
| 25829 | 3790 |
| 3791 @node Asm Mode | |
| 3792 @section Asm Mode | |
| 3793 | |
| 3794 @cindex Asm mode | |
| 26106 | 3795 @cindex Assembler mode |
| 25829 | 3796 Asm mode is a major mode for editing files of assembler code. It |
| 3797 defines these commands: | |
| 3798 | |
| 3799 @table @kbd | |
| 3800 @item @key{TAB} | |
| 3801 @code{tab-to-tab-stop}. | |
| 3802 @item C-j | |
| 3803 Insert a newline and then indent using @code{tab-to-tab-stop}. | |
| 3804 @item : | |
| 3805 Insert a colon and then remove the indentation from before the label | |
| 3806 preceding colon. Then do @code{tab-to-tab-stop}. | |
| 3807 @item ; | |
| 3808 Insert or align a comment. | |
| 3809 @end table | |
| 3810 | |
| 3811 The variable @code{asm-comment-char} specifies which character | |
| 3812 starts comments in assembler syntax. |
