Mercurial > emacs
annotate doc/emacs/fortran-xtra.texi @ 97590:4b2311c2836f
(Fortran Comments): Replace fortran-indent-comment with comment-dwim.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Thu, 21 Aug 2008 05:44:41 +0000 |
parents | a32c3ff6e2b1 |
children | 02243cbabf8e |
rev | line source |
---|---|
84241 | 1 @c This is part of the Emacs manual. |
87903 | 2 @c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
84241 | 3 @c See file emacs.texi for copying conditions. |
4 @c | |
5 @c This file is included either in emacs-xtra.texi (when producing the | |
6 @c printed version) or in the main Emacs manual (for the on-line version). | |
7 @node Fortran | |
8 @section Fortran Mode | |
9 @cindex Fortran mode | |
10 @cindex mode, Fortran | |
11 | |
12 Fortran mode provides special motion commands for Fortran statements | |
13 and subprograms, and indentation commands that understand Fortran | |
14 conventions of nesting, line numbers and continuation statements. | |
15 Fortran mode has support for Auto Fill mode that breaks long lines into | |
16 proper Fortran continuation lines. | |
17 | |
18 Special commands for comments are provided because Fortran comments | |
19 are unlike those of other languages. Built-in abbrevs optionally save | |
20 typing when you insert Fortran keywords. | |
21 | |
22 Use @kbd{M-x fortran-mode} to switch to this major mode. This | |
23 command runs the hook @code{fortran-mode-hook}. | |
24 @iftex | |
25 @xref{Hooks,,, emacs, the Emacs Manual}. | |
26 @end iftex | |
27 @ifnottex | |
28 @xref{Hooks}. | |
29 @end ifnottex | |
30 | |
31 @cindex Fortran77 and Fortran90 | |
32 @findex f90-mode | |
33 @findex fortran-mode | |
34 Fortran mode is meant for editing Fortran77 ``fixed format'' (and also | |
85628
fd350eead344
(Fortran): F90 mode handles F2003.
Glenn Morris <rgm@gnu.org>
parents:
84241
diff
changeset
|
35 ``tab format'') source code. For editing the modern Fortran90/95/2003 |
fd350eead344
(Fortran): F90 mode handles F2003.
Glenn Morris <rgm@gnu.org>
parents:
84241
diff
changeset
|
36 ``free format'' source code, use F90 mode (@code{f90-mode}). |
84241 | 37 Emacs normally uses Fortran mode for files with extension @samp{.f}, |
38 @samp{.F} or @samp{.for}, and F90 mode for the extension @samp{.f90} and | |
39 @samp{.f95}. GNU Fortran supports both kinds of format. | |
40 | |
41 @menu | |
42 * Motion: Fortran Motion. Moving point by statements or subprograms. | |
43 * Indent: Fortran Indent. Indentation commands for Fortran. | |
44 * Comments: Fortran Comments. Inserting and aligning comments. | |
45 * Autofill: Fortran Autofill. Auto fill support for Fortran. | |
46 * Columns: Fortran Columns. Measuring columns for valid Fortran. | |
47 * Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords. | |
48 @end menu | |
49 | |
50 @node Fortran Motion | |
51 @subsection Motion Commands | |
52 | |
53 In addition to the normal commands for moving by and operating on | |
54 ``defuns'' (Fortran subprograms---functions and subroutines, as well as | |
55 modules for F90 mode), Fortran mode provides special commands to move by | |
56 statements and other program units. | |
57 | |
58 @table @kbd | |
59 @kindex C-c C-n @r{(Fortran mode)} | |
60 @findex fortran-next-statement | |
61 @findex f90-next-statement | |
62 @item C-c C-n | |
63 Move to the beginning of the next statement | |
64 (@code{fortran-next-statement}/@code{f90-next-statement}). | |
65 | |
66 @kindex C-c C-p @r{(Fortran mode)} | |
67 @findex fortran-previous-statement | |
68 @findex f90-previous-statement | |
69 @item C-c C-p | |
70 Move to the beginning of the previous statement | |
71 (@code{fortran-previous-statement}/@code{f90-previous-statement}). | |
72 If there is no previous statement (i.e. if called from the first | |
73 statement in the buffer), move to the start of the buffer. | |
74 | |
75 @kindex C-c C-e @r{(F90 mode)} | |
76 @findex f90-next-block | |
77 @item C-c C-e | |
78 Move point forward to the start of the next code block | |
79 (@code{f90-next-block}). A code block is a subroutine, | |
80 @code{if}--@code{endif} statement, and so forth. This command exists | |
81 for F90 mode only, not Fortran mode. With a numeric argument, this | |
82 moves forward that many blocks. | |
83 | |
84 @kindex C-c C-a @r{(F90 mode)} | |
85 @findex f90-previous-block | |
86 @item C-c C-a | |
87 Move point backward to the previous code block | |
88 (@code{f90-previous-block}). This is like @code{f90-next-block}, but | |
89 moves backwards. | |
90 | |
91 @kindex C-M-n @r{(Fortran mode)} | |
92 @findex fortran-end-of-block | |
93 @findex f90-end-of-block | |
94 @item C-M-n | |
95 Move to the end of the current code block | |
96 (@code{fortran-end-of-block}/@code{f90-end-of-block}). With a numeric | |
97 argument, move forward that number of blocks. The mark is set before | |
98 moving point. The F90 mode version of this command checks for | |
99 consistency of block types and labels (if present), but it does not | |
100 check the outermost block since that may be incomplete. | |
101 | |
102 @kindex C-M-p @r{(Fortran mode)} | |
103 @findex fortran-beginning-of-block | |
104 @findex f90-beginning-of-block | |
105 @item C-M-p | |
106 Move to the start of the current code block | |
107 (@code{fortran-beginning-of-block}/@code{f90-beginning-of-block}). This | |
108 is like @code{fortran-end-of-block}, but moves backwards. | |
109 @end table | |
110 | |
111 @node Fortran Indent | |
112 @subsection Fortran Indentation | |
113 | |
114 Special commands and features are needed for indenting Fortran code in | |
115 order to make sure various syntactic entities (line numbers, comment line | |
116 indicators and continuation line flags) appear in the columns that are | |
117 required for standard, fixed (or tab) format Fortran. | |
118 | |
119 @menu | |
120 * Commands: ForIndent Commands. Commands for indenting and filling Fortran. | |
121 * Contline: ForIndent Cont. How continuation lines indent. | |
122 * Numbers: ForIndent Num. How line numbers auto-indent. | |
123 * Conv: ForIndent Conv. Conventions you must obey to avoid trouble. | |
124 * Vars: ForIndent Vars. Variables controlling Fortran indent style. | |
125 @end menu | |
126 | |
127 @node ForIndent Commands | |
128 @subsubsection Fortran Indentation and Filling Commands | |
129 | |
130 @table @kbd | |
131 @item C-M-j | |
132 Break the current line at point and set up a continuation line | |
133 (@code{fortran-split-line}). | |
134 @item M-^ | |
135 Join this line to the previous line (@code{fortran-join-line}). | |
136 @item C-M-q | |
137 Indent all the lines of the subprogram point is in | |
138 (@code{fortran-indent-subprogram}). | |
139 @item M-q | |
140 Fill a comment block or statement. | |
141 @end table | |
142 | |
143 @kindex C-M-q @r{(Fortran mode)} | |
144 @findex fortran-indent-subprogram | |
145 The key @kbd{C-M-q} runs @code{fortran-indent-subprogram}, a command | |
146 to reindent all the lines of the Fortran subprogram (function or | |
147 subroutine) containing point. | |
148 | |
149 @kindex C-M-j @r{(Fortran mode)} | |
150 @findex fortran-split-line | |
151 The key @kbd{C-M-j} runs @code{fortran-split-line}, which splits | |
152 a line in the appropriate fashion for Fortran. In a non-comment line, | |
153 the second half becomes a continuation line and is indented | |
154 accordingly. In a comment line, both halves become separate comment | |
155 lines. | |
156 | |
157 @kindex M-^ @r{(Fortran mode)} | |
158 @kindex C-c C-d @r{(Fortran mode)} | |
159 @findex fortran-join-line | |
160 @kbd{M-^} or @kbd{C-c C-d} runs the command @code{fortran-join-line}, | |
161 which joins a continuation line back to the previous line, roughly as | |
162 the inverse of @code{fortran-split-line}. The point must be on a | |
163 continuation line when this command is invoked. | |
164 | |
165 @kindex M-q @r{(Fortran mode)} | |
166 @kbd{M-q} in Fortran mode fills the comment block or statement that | |
167 point is in. This removes any excess statement continuations. | |
168 | |
169 @node ForIndent Cont | |
170 @subsubsection Continuation Lines | |
171 @cindex Fortran continuation lines | |
172 | |
173 @vindex fortran-continuation-string | |
174 Most Fortran77 compilers allow two ways of writing continuation lines. | |
175 If the first non-space character on a line is in column 5, then that | |
176 line is a continuation of the previous line. We call this @dfn{fixed | |
177 format}. (In GNU Emacs we always count columns from 0; but note that | |
178 the Fortran standard counts from 1.) The variable | |
179 @code{fortran-continuation-string} specifies what character to put in | |
180 column 5. A line that starts with a tab character followed by any digit | |
181 except @samp{0} is also a continuation line. We call this style of | |
182 continuation @dfn{tab format}. (Fortran90 introduced ``free format,'' | |
183 with another style of continuation lines). | |
184 | |
185 @vindex indent-tabs-mode @r{(Fortran mode)} | |
186 @vindex fortran-analyze-depth | |
187 @vindex fortran-tab-mode-default | |
188 Fortran mode can use either style of continuation line. When you | |
189 enter Fortran mode, it tries to deduce the proper continuation style | |
190 automatically from the buffer contents. It does this by scanning up to | |
191 @code{fortran-analyze-depth} (default 100) lines from the start of the | |
192 buffer. The first line that begins with either a tab character or six | |
193 spaces determines the choice. If the scan fails (for example, if the | |
194 buffer is new and therefore empty), the value of | |
195 @code{fortran-tab-mode-default} (@code{nil} for fixed format, and | |
196 non-@code{nil} for tab format) is used. @samp{/t} in the mode line | |
197 indicates tab format is selected. Fortran mode sets the value of | |
198 @code{indent-tabs-mode} accordingly. | |
199 | |
200 If the text on a line starts with the Fortran continuation marker | |
201 @samp{$}, or if it begins with any non-whitespace character in column | |
202 5, Fortran mode treats it as a continuation line. When you indent a | |
203 continuation line with @key{TAB}, it converts the line to the current | |
204 continuation style. When you split a Fortran statement with | |
205 @kbd{C-M-j}, the continuation marker on the newline is created according | |
206 to the continuation style. | |
207 | |
208 The setting of continuation style affects several other aspects of | |
209 editing in Fortran mode. In fixed format mode, the minimum column | |
210 number for the body of a statement is 6. Lines inside of Fortran | |
211 blocks that are indented to larger column numbers always use only the | |
212 space character for whitespace. In tab format mode, the minimum | |
213 column number for the statement body is 8, and the whitespace before | |
214 column 8 must always consist of one tab character. | |
215 | |
216 @node ForIndent Num | |
217 @subsubsection Line Numbers | |
218 | |
219 If a number is the first non-whitespace in the line, Fortran | |
220 indentation assumes it is a line number and moves it to columns 0 | |
221 through 4. (Columns always count from 0 in GNU Emacs.) | |
222 | |
223 @vindex fortran-line-number-indent | |
224 Line numbers of four digits or less are normally indented one space. | |
225 The variable @code{fortran-line-number-indent} controls this; it | |
226 specifies the maximum indentation a line number can have. The default | |
227 value of the variable is 1. Fortran mode tries to prevent line number | |
228 digits passing column 4, reducing the indentation below the specified | |
229 maximum if necessary. If @code{fortran-line-number-indent} has the | |
230 value 5, line numbers are right-justified to end in column 4. | |
231 | |
232 @vindex fortran-electric-line-number | |
233 Simply inserting a line number is enough to indent it according to | |
234 these rules. As each digit is inserted, the indentation is recomputed. | |
235 To turn off this feature, set the variable | |
236 @code{fortran-electric-line-number} to @code{nil}. | |
237 | |
238 | |
239 @node ForIndent Conv | |
240 @subsubsection Syntactic Conventions | |
241 | |
242 Fortran mode assumes that you follow certain conventions that simplify | |
243 the task of understanding a Fortran program well enough to indent it | |
244 properly: | |
245 | |
246 @itemize @bullet | |
247 @item | |
248 Two nested @samp{do} loops never share a @samp{continue} statement. | |
249 | |
250 @item | |
251 Fortran keywords such as @samp{if}, @samp{else}, @samp{then}, @samp{do} | |
252 and others are written without embedded whitespace or line breaks. | |
253 | |
254 Fortran compilers generally ignore whitespace outside of string | |
255 constants, but Fortran mode does not recognize these keywords if they | |
256 are not contiguous. Constructs such as @samp{else if} or @samp{end do} | |
257 are acceptable, but the second word should be on the same line as the | |
258 first and not on a continuation line. | |
259 @end itemize | |
260 | |
261 @noindent | |
262 If you fail to follow these conventions, the indentation commands may | |
263 indent some lines unaesthetically. However, a correct Fortran program | |
264 retains its meaning when reindented even if the conventions are not | |
265 followed. | |
266 | |
267 @node ForIndent Vars | |
268 @subsubsection Variables for Fortran Indentation | |
269 | |
270 @vindex fortran-do-indent | |
271 @vindex fortran-if-indent | |
272 @vindex fortran-structure-indent | |
273 @vindex fortran-continuation-indent | |
274 @vindex fortran-check-all-num@dots{} | |
275 @vindex fortran-minimum-statement-indent@dots{} | |
276 Several additional variables control how Fortran indentation works: | |
277 | |
278 @table @code | |
279 @item fortran-do-indent | |
280 Extra indentation within each level of @samp{do} statement (default 3). | |
281 | |
282 @item fortran-if-indent | |
283 Extra indentation within each level of @samp{if}, @samp{select case}, or | |
284 @samp{where} statements (default 3). | |
285 | |
286 @item fortran-structure-indent | |
287 Extra indentation within each level of @samp{structure}, @samp{union}, | |
288 @samp{map}, or @samp{interface} statements (default 3). | |
289 | |
290 @item fortran-continuation-indent | |
291 Extra indentation for bodies of continuation lines (default 5). | |
292 | |
293 @item fortran-check-all-num-for-matching-do | |
294 In Fortran77, a numbered @samp{do} statement is ended by any statement | |
295 with a matching line number. It is common (but not compulsory) to use a | |
296 @samp{continue} statement for this purpose. If this variable has a | |
297 non-@code{nil} value, indenting any numbered statement must check for a | |
298 @samp{do} that ends there. If you always end @samp{do} statements with | |
299 a @samp{continue} line (or if you use the more modern @samp{enddo}), | |
300 then you can speed up indentation by setting this variable to | |
301 @code{nil}. The default is @code{nil}. | |
302 | |
303 @item fortran-blink-matching-if | |
304 If this is @code{t}, indenting an @samp{endif} (or @samp{enddo} | |
305 statement moves the cursor momentarily to the matching @samp{if} (or | |
306 @samp{do}) statement to show where it is. The default is @code{nil}. | |
307 | |
308 @item fortran-minimum-statement-indent-fixed | |
309 Minimum indentation for Fortran statements when using fixed format | |
310 continuation line style. Statement bodies are never indented less than | |
311 this much. The default is 6. | |
312 | |
313 @item fortran-minimum-statement-indent-tab | |
314 Minimum indentation for Fortran statements for tab format continuation line | |
315 style. Statement bodies are never indented less than this much. The | |
316 default is 8. | |
317 @end table | |
318 | |
319 The variables controlling the indentation of comments are described in | |
320 the following section. | |
321 | |
322 @node Fortran Comments | |
323 @subsection Fortran Comments | |
324 | |
325 The usual Emacs comment commands assume that a comment can follow a | |
326 line of code. In Fortran77, the standard comment syntax requires an | |
327 entire line to be just a comment. Therefore, Fortran mode replaces the | |
328 standard Emacs comment commands and defines some new variables. | |
329 | |
330 @vindex fortran-comment-line-start | |
331 Fortran mode can also handle the Fortran90 comment syntax where comments | |
332 start with @samp{!} and can follow other text. Because only some Fortran77 | |
333 compilers accept this syntax, Fortran mode will not insert such comments | |
334 unless you have said in advance to do so. To do this, set the variable | |
335 @code{fortran-comment-line-start} to @samp{"!"}. | |
336 | |
337 @table @kbd | |
338 @item M-; | |
97590
4b2311c2836f
(Fortran Comments): Replace fortran-indent-comment with comment-dwim.
Glenn Morris <rgm@gnu.org>
parents:
97588
diff
changeset
|
339 Align comment or insert new comment (@code{comment-dwim}). |
84241 | 340 |
341 @item C-x ; | |
342 Applies to nonstandard @samp{!} comments only. | |
343 | |
344 @item C-c ; | |
345 Turn all lines of the region into comments, or (with argument) turn them back | |
346 into real code (@code{fortran-comment-region}). | |
347 @end table | |
348 | |
97590
4b2311c2836f
(Fortran Comments): Replace fortran-indent-comment with comment-dwim.
Glenn Morris <rgm@gnu.org>
parents:
97588
diff
changeset
|
349 @kbd{M-;} in Fortran mode runs the standard @code{comment-dwim}. |
4b2311c2836f
(Fortran Comments): Replace fortran-indent-comment with comment-dwim.
Glenn Morris <rgm@gnu.org>
parents:
97588
diff
changeset
|
350 This recognizes any kind of existing comment and aligns its text |
4b2311c2836f
(Fortran Comments): Replace fortran-indent-comment with comment-dwim.
Glenn Morris <rgm@gnu.org>
parents:
97588
diff
changeset
|
351 appropriately; if there is no existing comment, a comment is inserted |
4b2311c2836f
(Fortran Comments): Replace fortran-indent-comment with comment-dwim.
Glenn Morris <rgm@gnu.org>
parents:
97588
diff
changeset
|
352 and aligned. Inserting and aligning comments are not the same in |
4b2311c2836f
(Fortran Comments): Replace fortran-indent-comment with comment-dwim.
Glenn Morris <rgm@gnu.org>
parents:
97588
diff
changeset
|
353 Fortran mode as in other modes. |
84241 | 354 |
355 When a new comment must be inserted, if the current line is blank, a | |
356 full-line comment is inserted. On a non-blank line, a nonstandard @samp{!} | |
357 comment is inserted if you have said you want to use them. Otherwise a | |
358 full-line comment is inserted on a new line before the current line. | |
359 | |
360 Nonstandard @samp{!} comments are aligned like comments in other | |
361 languages, but full-line comments are different. In a standard full-line | |
362 comment, the comment delimiter itself must always appear in column zero. | |
363 What can be aligned is the text within the comment. You can choose from | |
364 three styles of alignment by setting the variable | |
365 @code{fortran-comment-indent-style} to one of these values: | |
366 | |
367 @vindex fortran-comment-indent-style | |
368 @vindex fortran-comment-line-extra-indent | |
369 @table @code | |
370 @item fixed | |
371 Align the text at a fixed column, which is the sum of | |
372 @code{fortran-comment-line-extra-indent} and the minimum statement | |
373 indentation. This is the default. | |
374 | |
375 The minimum statement indentation is | |
376 @code{fortran-minimum-statement-indent-fixed} for fixed format | |
377 continuation line style and @code{fortran-minimum-statement-indent-tab} | |
378 for tab format style. | |
379 | |
380 @item relative | |
381 Align the text as if it were a line of code, but with an additional | |
382 @code{fortran-comment-line-extra-indent} columns of indentation. | |
383 | |
384 @item nil | |
385 Don't move text in full-line comments automatically. | |
386 @end table | |
387 | |
388 @vindex fortran-comment-indent-char | |
389 In addition, you can specify the character to be used to indent within | |
390 full-line comments by setting the variable | |
391 @code{fortran-comment-indent-char} to the single-character string you want | |
392 to use. | |
393 | |
394 @vindex fortran-directive-re | |
395 Compiler directive lines, or preprocessor lines, have much the same | |
396 appearance as comment lines. It is important, though, that such lines | |
397 never be indented at all, no matter what the value of | |
398 @code{fortran-comment-indent-style}. The variable | |
399 @code{fortran-directive-re} is a regular expression that specifies which | |
400 lines are directives. Matching lines are never indented, and receive | |
401 distinctive font-locking. | |
402 | |
403 The normal Emacs comment command @kbd{C-x ;} has not been redefined. If | |
404 you use @samp{!} comments, this command can be used with them. Otherwise | |
405 it is useless in Fortran mode. | |
406 | |
407 @kindex C-c ; @r{(Fortran mode)} | |
408 @findex fortran-comment-region | |
409 @vindex fortran-comment-region | |
410 The command @kbd{C-c ;} (@code{fortran-comment-region}) turns all the | |
411 lines of the region into comments by inserting the string @samp{C$$$} at | |
412 the front of each one. With a numeric argument, it turns the region | |
413 back into live code by deleting @samp{C$$$} from the front of each line | |
414 in it. The string used for these comments can be controlled by setting | |
415 the variable @code{fortran-comment-region}. Note that here we have an | |
416 example of a command and a variable with the same name; these two uses | |
417 of the name never conflict because in Lisp and in Emacs it is always | |
418 clear from the context which one is meant. | |
419 | |
420 @node Fortran Autofill | |
421 @subsection Auto Fill in Fortran Mode | |
422 | |
423 Fortran mode has specialized support for Auto Fill mode, which is a | |
424 minor mode that automatically splits statements as you insert them | |
425 when they become too wide. Splitting a statement involves making | |
426 continuation lines using @code{fortran-continuation-string} | |
427 (@pxref{ForIndent Cont}). This splitting happens when you type | |
428 @key{SPC}, @key{RET}, or @key{TAB}, and also in the Fortran | |
429 indentation commands. You activate Auto Fill in Fortran mode in the | |
430 normal way. | |
431 @iftex | |
432 @xref{Auto Fill,,, emacs, the Emacs Manual}. | |
433 @end iftex | |
434 @ifnottex | |
435 @xref{Auto Fill}. | |
436 @end ifnottex | |
437 | |
438 @vindex fortran-break-before-delimiters | |
439 Auto Fill breaks lines at spaces or delimiters when the lines get | |
440 longer than the desired width (the value of @code{fill-column}). The | |
441 delimiters (besides whitespace) that Auto Fill can break at are | |
442 @samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, @samp{<}, @samp{>}, | |
443 and @samp{,}. The line break comes after the delimiter if the | |
444 variable @code{fortran-break-before-delimiters} is @code{nil}. | |
445 Otherwise (and by default), the break comes before the delimiter. | |
446 | |
447 To enable Auto Fill in all Fortran buffers, add | |
448 @code{turn-on-auto-fill} to @code{fortran-mode-hook}. | |
449 @iftex | |
450 @xref{Hooks,,, emacs, the Emacs Manual}. | |
451 @end iftex | |
452 @ifnottex | |
453 @xref{Hooks}. | |
454 @end ifnottex | |
455 | |
456 @node Fortran Columns | |
457 @subsection Checking Columns in Fortran | |
458 | |
97588
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
459 @vindex fortran-line-length |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
460 In standard Fortran 77, anything beyond column 72 is ignored. |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
461 Most compilers provide an option to change this (for example, |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
462 @samp{-ffixed-line-length-N} in gfortran). Customize the variable |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
463 @code{fortran-line-length} to change the line length in Fortran mode. |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
464 |
84241 | 465 @table @kbd |
466 @item C-c C-r | |
467 Display a ``column ruler'' momentarily above the current line | |
468 (@code{fortran-column-ruler}). | |
469 @item C-c C-w | |
97588
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
470 Split the current window horizontally temporarily so that it is |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
471 @code{fortran-line-length} columns wide |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
472 (@code{fortran-window-create-momentarily}). This may help you avoid |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
473 making lines longer than the character limit imposed by your Fortran |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
474 compiler. |
84241 | 475 @item C-u C-c C-w |
97588
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
476 Split the current window horizontally so that it is |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
477 @code{fortran-line-length} columns wide (@code{fortran-window-create}). |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
478 You can then continue editing. |
84241 | 479 @item M-x fortran-strip-sequence-nos |
97588
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
480 Delete all text in column @code{fortran-line-length} and beyond. |
84241 | 481 @end table |
482 | |
483 @kindex C-c C-r @r{(Fortran mode)} | |
484 @findex fortran-column-ruler | |
485 The command @kbd{C-c C-r} (@code{fortran-column-ruler}) shows a column | |
486 ruler momentarily above the current line. The comment ruler is two lines | |
487 of text that show you the locations of columns with special significance in | |
488 Fortran programs. Square brackets show the limits of the columns for line | |
489 numbers, and curly brackets show the limits of the columns for the | |
490 statement body. Column numbers appear above them. | |
491 | |
492 Note that the column numbers count from zero, as always in GNU Emacs. | |
493 As a result, the numbers may be one less than those you are familiar | |
494 with; but the positions they indicate in the line are standard for | |
495 Fortran. | |
496 | |
497 @vindex fortran-column-ruler-fixed | |
498 @vindex fortran-column-ruler-tabs | |
499 The text used to display the column ruler depends on the value of the | |
500 variable @code{indent-tabs-mode}. If @code{indent-tabs-mode} is | |
501 @code{nil}, then the value of the variable | |
502 @code{fortran-column-ruler-fixed} is used as the column ruler. | |
503 Otherwise, the value of the variable @code{fortran-column-ruler-tab} is | |
504 displayed. By changing these variables, you can change the column ruler | |
505 display. | |
506 | |
507 @kindex C-c C-w @r{(Fortran mode)} | |
508 @findex fortran-window-create-momentarily | |
509 @kbd{C-c C-w} (@code{fortran-window-create-momentarily}) temporarily | |
97588
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
510 splits the current window horizontally, making a window |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
511 @code{fortran-line-length} columns wide, so you can see any lines that |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
512 are too long. Type a space to restore the normal width. |
84241 | 513 |
514 @kindex C-u C-c C-w @r{(Fortran mode)} | |
515 @findex fortran-window-create | |
516 You can also split the window horizontally and continue editing with | |
517 the split in place. To do this, use @kbd{C-u C-c C-w} (@code{M-x | |
518 fortran-window-create}). By editing in this window you can | |
519 immediately see when you make a line too wide to be correct Fortran. | |
520 | |
521 @findex fortran-strip-sequence-nos | |
522 The command @kbd{M-x fortran-strip-sequence-nos} deletes all text in | |
97588
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
523 column @code{fortran-line-length} and beyond, on all lines in the |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
524 current buffer. This is the easiest way to get rid of old sequence |
a32c3ff6e2b1
(Fortran Columns): Document `fortran-line-length'.
Glenn Morris <rgm@gnu.org>
parents:
87903
diff
changeset
|
525 numbers. |
84241 | 526 |
527 @node Fortran Abbrev | |
528 @subsection Fortran Keyword Abbrevs | |
529 | |
530 Fortran mode provides many built-in abbrevs for common keywords and | |
531 declarations. These are the same sort of abbrev that you can define | |
532 yourself. To use them, you must turn on Abbrev mode. | |
533 @iftex | |
534 @xref{Abbrevs,,, emacs, the Emacs Manual}. | |
535 @end iftex | |
536 @ifnottex | |
537 @xref{Abbrevs}. | |
538 @end ifnottex | |
539 | |
540 The built-in abbrevs are unusual in one way: they all start with a | |
541 semicolon. You cannot normally use semicolon in an abbrev, but Fortran | |
542 mode makes this possible by changing the syntax of semicolon to ``word | |
543 constituent.'' | |
544 | |
545 For example, one built-in Fortran abbrev is @samp{;c} for | |
546 @samp{continue}. If you insert @samp{;c} and then insert a punctuation | |
547 character such as a space or a newline, the @samp{;c} expands automatically | |
548 to @samp{continue}, provided Abbrev mode is enabled.@refill | |
549 | |
550 Type @samp{;?} or @samp{;C-h} to display a list of all the built-in | |
551 Fortran abbrevs and what they stand for. | |
552 | |
553 @ignore | |
554 arch-tag: 23ed7c36-1517-4646-9235-2d5ade5f06f6 | |
555 @end ignore |