aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-08-23 23:29:54 +0000
committerGlenn Morris2008-08-23 23:29:54 +0000
commit74f0711b83694482a577a8fa435800dd7505bb85 (patch)
tree24d3c32d767e8db8c4b8c0c42e60e21640e6e839
parentcd9b5d3e5194b2c2da7ed83ab8759a9503cb4ee8 (diff)
downloademacs-74f0711b83694482a577a8fa435800dd7505bb85.tar.gz
emacs-74f0711b83694482a577a8fa435800dd7505bb85.zip
(Fortran): Change description of free form and
fixed form a bit. Mention hideshow and imenu. (Fortran Motion): Mention fortran-end-of-subprogram, fortran-beginning-of-subprogram, fortran-mark-do, fortran-mark-if. (Fortran Indent): Minor re-word. (ForIndent Commands): Mention fortran-fill-paragraph and fortran-fill-statement. (ForIndent Cont): Mention fortran-tab-mode-string. (Fortran Comments): Mention fortran-comment-line-start-skip. (Fortran Columns): Mention font-locking. (Fortran Abbrev): Word syntax not relevant with new-style abbrev.
-rw-r--r--doc/emacs/fortran-xtra.texi116
1 files changed, 74 insertions, 42 deletions
diff --git a/doc/emacs/fortran-xtra.texi b/doc/emacs/fortran-xtra.texi
index 14c2392cba2..7868c83a4d9 100644
--- a/doc/emacs/fortran-xtra.texi
+++ b/doc/emacs/fortran-xtra.texi
@@ -9,11 +9,39 @@
9@cindex Fortran mode 9@cindex Fortran mode
10@cindex mode, Fortran 10@cindex mode, Fortran
11 11
12@cindex Fortran fixed form and free form
13@cindex Fortran 77 and Fortran 90, 95, 2003
14@findex f90-mode
15@findex fortran-mode
16 Fortran mode is meant for editing ``fixed form'' (and also ``tab
17format'') source code (normally Fortran 77). For editing more modern
18``free form'' source code (Fortran 90, 95, 2003), use F90 mode
19(@code{f90-mode}). Emacs normally uses Fortran mode for files with
20extension @samp{.f}, @samp{.F} or @samp{.for}, and F90 mode for the
21extensions @samp{.f90} and @samp{.f95}. Customize
22@code{auto-mode-alist} to add more extensions. GNU Fortran supports
23both free and fixed form. This manual mainly documents Fortran mode,
24but the corresponding F90 mode features are mentioned when revelant.
25
12 Fortran mode provides special motion commands for Fortran statements 26 Fortran mode provides special motion commands for Fortran statements
13and subprograms, and indentation commands that understand Fortran 27and subprograms, and indentation commands that understand Fortran
14conventions of nesting, line numbers and continuation statements. 28conventions of nesting, line numbers and continuation statements.
15Fortran mode has support for Auto Fill mode that breaks long lines into 29Fortran mode has support for Auto Fill mode that breaks long lines into
16proper Fortran continuation lines. 30proper Fortran continuation lines. Fortran mode also supports Hideshow
31minor mode
32@iftex
33(@pxref{Hideshow,,, emacs, the Emacs Manual}),
34@end iftex
35@ifnottex
36(@pxref{Hideshow}),
37@end ifnottex
38and Imenu
39@iftex
40(@pxref{Imenu,,, emacs, the Emacs Manual}).
41@end iftex
42@ifnottex
43(@pxref{Imenu}).
44@end ifnottex
17 45
18 Special commands for comments are provided because Fortran comments 46 Special commands for comments are provided because Fortran comments
19are unlike those of other languages. Built-in abbrevs optionally save 47are unlike those of other languages. Built-in abbrevs optionally save
@@ -28,16 +56,6 @@ command runs the hook @code{fortran-mode-hook}.
28@xref{Hooks}. 56@xref{Hooks}.
29@end ifnottex 57@end ifnottex
30 58
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
35``tab format'') source code. For editing the modern Fortran90/95/2003
36``free format'' source code, use F90 mode (@code{f90-mode}).
37Emacs 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 59@menu
42* Motion: Fortran Motion. Moving point by statements or subprograms. 60* Motion: Fortran Motion. Moving point by statements or subprograms.
43* Indent: Fortran Indent. Indentation commands for Fortran. 61* Indent: Fortran Indent. Indentation commands for Fortran.
@@ -51,9 +69,11 @@ Emacs normally uses Fortran mode for files with extension @samp{.f},
51@subsection Motion Commands 69@subsection Motion Commands
52 70
53 In addition to the normal commands for moving by and operating on 71 In addition to the normal commands for moving by and operating on
54``defuns'' (Fortran subprograms---functions and subroutines, as well as 72``defuns'' (Fortran subprograms---functions and subroutines, using the
55modules for F90 mode), Fortran mode provides special commands to move by 73commands @code{fortran-end-of-subprogram} and
56statements and other program units. 74@code{fortran-beginning-of-subprogram}; as well as modules for F90
75mode), Fortran mode provides special commands to move by statements and
76other program units.
57 77
58@table @kbd 78@table @kbd
59@kindex C-c C-n @r{(Fortran mode)} 79@kindex C-c C-n @r{(Fortran mode)}
@@ -75,7 +95,8 @@ statement in the buffer), move to the start of the buffer.
75@kindex C-c C-e @r{(F90 mode)} 95@kindex C-c C-e @r{(F90 mode)}
76@findex f90-next-block 96@findex f90-next-block
77@item C-c C-e 97@item C-c C-e
78Move point forward to the start of the next code block 98Move point forward to the start of the next code block, or the end of
99the current block, whichever is encountered first.
79(@code{f90-next-block}). A code block is a subroutine, 100(@code{f90-next-block}). A code block is a subroutine,
80@code{if}--@code{endif} statement, and so forth. This command exists 101@code{if}--@code{endif} statement, and so forth. This command exists
81for F90 mode only, not Fortran mode. With a numeric argument, this 102for F90 mode only, not Fortran mode. With a numeric argument, this
@@ -108,13 +129,20 @@ Move to the start of the current code block
108is like @code{fortran-end-of-block}, but moves backwards. 129is like @code{fortran-end-of-block}, but moves backwards.
109@end table 130@end table
110 131
132The commands @code{fortran-end-of-subprogram} and
133@code{fortran-beginning-of-subprogram} move to the end or start of the
134current subprogram, respectively. The commands @code{fortran-mark-do}
135and @code{fortran-mark-if} mark the end of the current @code{do} or
136@code{if} block, and move point to the start.
137
138
111@node Fortran Indent 139@node Fortran Indent
112@subsection Fortran Indentation 140@subsection Fortran Indentation
113 141
114 Special commands and features are needed for indenting Fortran code in 142 Special commands and features are needed for indenting fixed (or tab)
115order to make sure various syntactic entities (line numbers, comment line 143form Fortran code in order to make sure various syntactic entities (line
116indicators and continuation line flags) appear in the columns that are 144numbers, comment line indicators and continuation line flags) appear in
117required for standard, fixed (or tab) format Fortran. 145the required columns.
118 146
119@menu 147@menu
120* Commands: ForIndent Commands. Commands for indenting and filling Fortran. 148* Commands: ForIndent Commands. Commands for indenting and filling Fortran.
@@ -137,7 +165,8 @@ Join this line to the previous line (@code{fortran-join-line}).
137Indent all the lines of the subprogram point is in 165Indent all the lines of the subprogram point is in
138(@code{fortran-indent-subprogram}). 166(@code{fortran-indent-subprogram}).
139@item M-q 167@item M-q
140Fill a comment block or statement. 168Fill a comment block or statement (using @code{fortran-fill-paragraph}
169or @code{fortran-fill-statement}).
141@end table 170@end table
142 171
143@kindex C-M-q @r{(Fortran mode)} 172@kindex C-M-q @r{(Fortran mode)}
@@ -171,15 +200,15 @@ point is in. This removes any excess statement continuations.
171@cindex Fortran continuation lines 200@cindex Fortran continuation lines
172 201
173@vindex fortran-continuation-string 202@vindex fortran-continuation-string
174 Most Fortran77 compilers allow two ways of writing continuation lines. 203 Most Fortran 77 compilers allow two ways of writing continuation lines.
175If the first non-space character on a line is in column 5, then that 204If the first non-space character on a line is in column 5, then that
176line is a continuation of the previous line. We call this @dfn{fixed 205line is a continuation of the previous line. We call this @dfn{fixed
177format}. (In GNU Emacs we always count columns from 0; but note that 206form}. (In GNU Emacs we always count columns from 0; but note that
178the Fortran standard counts from 1.) The variable 207the Fortran standard counts from 1.) The variable
179@code{fortran-continuation-string} specifies what character to put in 208@code{fortran-continuation-string} specifies what character to put in
180column 5. A line that starts with a tab character followed by any digit 209column 5. A line that starts with a tab character followed by any digit
181except @samp{0} is also a continuation line. We call this style of 210except @samp{0} is also a continuation line. We call this style of
182continuation @dfn{tab format}. (Fortran90 introduced ``free format,'' 211continuation @dfn{tab format}. (Fortran 90 introduced ``free form,''
183with another style of continuation lines). 212with another style of continuation lines).
184 213
185@vindex indent-tabs-mode @r{(Fortran mode)} 214@vindex indent-tabs-mode @r{(Fortran mode)}
@@ -192,10 +221,11 @@ automatically from the buffer contents. It does this by scanning up to
192buffer. The first line that begins with either a tab character or six 221buffer. The first line that begins with either a tab character or six
193spaces determines the choice. If the scan fails (for example, if the 222spaces determines the choice. If the scan fails (for example, if the
194buffer is new and therefore empty), the value of 223buffer is new and therefore empty), the value of
195@code{fortran-tab-mode-default} (@code{nil} for fixed format, and 224@code{fortran-tab-mode-default} (@code{nil} for fixed form, and
196non-@code{nil} for tab format) is used. @samp{/t} in the mode line 225non-@code{nil} for tab format) is used. @samp{/t}
197indicates tab format is selected. Fortran mode sets the value of 226(@code{fortran-tab-mode-string}) in the mode line indicates tab format
198@code{indent-tabs-mode} accordingly. 227is selected. Fortran mode sets the value of @code{indent-tabs-mode}
228accordingly.
199 229
200 If the text on a line starts with the Fortran continuation marker 230 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 231@samp{$}, or if it begins with any non-whitespace character in column
@@ -206,7 +236,7 @@ continuation style. When you split a Fortran statement with
206to the continuation style. 236to the continuation style.
207 237
208 The setting of continuation style affects several other aspects of 238 The setting of continuation style affects several other aspects of
209editing in Fortran mode. In fixed format mode, the minimum column 239editing in Fortran mode. In fixed form mode, the minimum column
210number for the body of a statement is 6. Lines inside of Fortran 240number for the body of a statement is 6. Lines inside of Fortran
211blocks that are indented to larger column numbers always use only the 241blocks that are indented to larger column numbers always use only the
212space character for whitespace. In tab format mode, the minimum 242space character for whitespace. In tab format mode, the minimum
@@ -291,7 +321,7 @@ Extra indentation within each level of @samp{structure}, @samp{union},
291Extra indentation for bodies of continuation lines (default 5). 321Extra indentation for bodies of continuation lines (default 5).
292 322
293@item fortran-check-all-num-for-matching-do 323@item fortran-check-all-num-for-matching-do
294In Fortran77, a numbered @samp{do} statement is ended by any statement 324In Fortran 77, a numbered @samp{do} statement is ended by any statement
295with a matching line number. It is common (but not compulsory) to use a 325with 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 326@samp{continue} statement for this purpose. If this variable has a
297non-@code{nil} value, indenting any numbered statement must check for a 327non-@code{nil} value, indenting any numbered statement must check for a
@@ -306,7 +336,7 @@ 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}. 336@samp{do}) statement to show where it is. The default is @code{nil}.
307 337
308@item fortran-minimum-statement-indent-fixed 338@item fortran-minimum-statement-indent-fixed
309Minimum indentation for Fortran statements when using fixed format 339Minimum indentation for Fortran statements when using fixed form
310continuation line style. Statement bodies are never indented less than 340continuation line style. Statement bodies are never indented less than
311this much. The default is 6. 341this much. The default is 6.
312 342
@@ -323,16 +353,19 @@ the following section.
323@subsection Fortran Comments 353@subsection Fortran Comments
324 354
325 The usual Emacs comment commands assume that a comment can follow a 355 The usual Emacs comment commands assume that a comment can follow a
326line of code. In Fortran77, the standard comment syntax requires an 356line of code. In Fortran 77, the standard comment syntax requires an
327entire line to be just a comment. Therefore, Fortran mode replaces the 357entire line to be just a comment. Therefore, Fortran mode replaces the
328standard Emacs comment commands and defines some new variables. 358standard Emacs comment commands and defines some new variables.
329 359
330@vindex fortran-comment-line-start 360@vindex fortran-comment-line-start
331 Fortran mode can also handle the Fortran90 comment syntax where comments 361 Fortran mode can also handle the Fortran 90 comment syntax where
332start with @samp{!} and can follow other text. Because only some Fortran77 362comments start with @samp{!} and can follow other text. Because only
333compilers accept this syntax, Fortran mode will not insert such comments 363some Fortran 77 compilers accept this syntax, Fortran mode will not
334unless you have said in advance to do so. To do this, set the variable 364insert such comments unless you have said in advance to do so. To do
335@code{fortran-comment-line-start} to @samp{"!"}. 365this, set the variable @code{fortran-comment-line-start} to @samp{"!"}.
366If you use an unusual value, you may also need to adjust
367@code{fortran-comment-line-start-skip}.
368
336 369
337@table @kbd 370@table @kbd
338@item M-; 371@item M-;
@@ -373,7 +406,7 @@ Align the text at a fixed column, which is the sum of
373indentation. This is the default. 406indentation. This is the default.
374 407
375The minimum statement indentation is 408The minimum statement indentation is
376@code{fortran-minimum-statement-indent-fixed} for fixed format 409@code{fortran-minimum-statement-indent-fixed} for fixed form
377continuation line style and @code{fortran-minimum-statement-indent-tab} 410continuation line style and @code{fortran-minimum-statement-indent-tab}
378for tab format style. 411for tab format style.
379 412
@@ -461,6 +494,9 @@ In standard Fortran 77, anything beyond column 72 is ignored.
461Most compilers provide an option to change this (for example, 494Most compilers provide an option to change this (for example,
462@samp{-ffixed-line-length-N} in gfortran). Customize the variable 495@samp{-ffixed-line-length-N} in gfortran). Customize the variable
463@code{fortran-line-length} to change the line length in Fortran mode. 496@code{fortran-line-length} to change the line length in Fortran mode.
497Anything beyond this point is font-locked as a comment. (Unless it is
498inside a string: strings that extend beyond @code{fortran-line-length}
499will confuse font-lock.)
464 500
465@table @kbd 501@table @kbd
466@item C-c C-r 502@item C-c C-r
@@ -538,11 +574,7 @@ yourself. To use them, you must turn on Abbrev mode.
538@end ifnottex 574@end ifnottex
539 575
540 The built-in abbrevs are unusual in one way: they all start with a 576 The built-in abbrevs are unusual in one way: they all start with a
541semicolon. You cannot normally use semicolon in an abbrev, but Fortran 577semicolon. For example, one built-in Fortran abbrev is @samp{;c} for
542mode makes this possible by changing the syntax of semicolon to ``word
543constituent.''
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 578@samp{continue}. If you insert @samp{;c} and then insert a punctuation
547character such as a space or a newline, the @samp{;c} expands automatically 579character such as a space or a newline, the @samp{;c} expands automatically
548to @samp{continue}, provided Abbrev mode is enabled.@refill 580to @samp{continue}, provided Abbrev mode is enabled.@refill