diff options
| author | Glenn Morris | 2008-08-23 23:29:54 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-08-23 23:29:54 +0000 |
| commit | 74f0711b83694482a577a8fa435800dd7505bb85 (patch) | |
| tree | 24d3c32d767e8db8c4b8c0c42e60e21640e6e839 | |
| parent | cd9b5d3e5194b2c2da7ed83ab8759a9503cb4ee8 (diff) | |
| download | emacs-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.texi | 116 |
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 | ||
| 17 | format'') 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 | ||
| 20 | extension @samp{.f}, @samp{.F} or @samp{.for}, and F90 mode for the | ||
| 21 | extensions @samp{.f90} and @samp{.f95}. Customize | ||
| 22 | @code{auto-mode-alist} to add more extensions. GNU Fortran supports | ||
| 23 | both free and fixed form. This manual mainly documents Fortran mode, | ||
| 24 | but 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 |
| 13 | and subprograms, and indentation commands that understand Fortran | 27 | and subprograms, and indentation commands that understand Fortran |
| 14 | conventions of nesting, line numbers and continuation statements. | 28 | conventions of nesting, line numbers and continuation statements. |
| 15 | Fortran mode has support for Auto Fill mode that breaks long lines into | 29 | Fortran mode has support for Auto Fill mode that breaks long lines into |
| 16 | proper Fortran continuation lines. | 30 | proper Fortran continuation lines. Fortran mode also supports Hideshow |
| 31 | minor mode | ||
| 32 | @iftex | ||
| 33 | (@pxref{Hideshow,,, emacs, the Emacs Manual}), | ||
| 34 | @end iftex | ||
| 35 | @ifnottex | ||
| 36 | (@pxref{Hideshow}), | ||
| 37 | @end ifnottex | ||
| 38 | and 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 |
| 19 | are unlike those of other languages. Built-in abbrevs optionally save | 47 | are 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}). | ||
| 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 | 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 |
| 55 | modules for F90 mode), Fortran mode provides special commands to move by | 73 | commands @code{fortran-end-of-subprogram} and |
| 56 | statements and other program units. | 74 | @code{fortran-beginning-of-subprogram}; as well as modules for F90 |
| 75 | mode), Fortran mode provides special commands to move by statements and | ||
| 76 | other 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 |
| 78 | Move point forward to the start of the next code block | 98 | Move point forward to the start of the next code block, or the end of |
| 99 | the 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 |
| 81 | for F90 mode only, not Fortran mode. With a numeric argument, this | 102 | for F90 mode only, not Fortran mode. With a numeric argument, this |
| @@ -108,13 +129,20 @@ Move to the start of the current code block | |||
| 108 | is like @code{fortran-end-of-block}, but moves backwards. | 129 | is like @code{fortran-end-of-block}, but moves backwards. |
| 109 | @end table | 130 | @end table |
| 110 | 131 | ||
| 132 | The commands @code{fortran-end-of-subprogram} and | ||
| 133 | @code{fortran-beginning-of-subprogram} move to the end or start of the | ||
| 134 | current subprogram, respectively. The commands @code{fortran-mark-do} | ||
| 135 | and @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) |
| 115 | order to make sure various syntactic entities (line numbers, comment line | 143 | form Fortran code in order to make sure various syntactic entities (line |
| 116 | indicators and continuation line flags) appear in the columns that are | 144 | numbers, comment line indicators and continuation line flags) appear in |
| 117 | required for standard, fixed (or tab) format Fortran. | 145 | the 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}). | |||
| 137 | Indent all the lines of the subprogram point is in | 165 | Indent 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 |
| 140 | Fill a comment block or statement. | 168 | Fill a comment block or statement (using @code{fortran-fill-paragraph} |
| 169 | or @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. |
| 175 | If the first non-space character on a line is in column 5, then that | 204 | 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 | 205 | 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 | 206 | form}. (In GNU Emacs we always count columns from 0; but note that |
| 178 | the Fortran standard counts from 1.) The variable | 207 | the 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 |
| 180 | column 5. A line that starts with a tab character followed by any digit | 209 | 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 | 210 | except @samp{0} is also a continuation line. We call this style of |
| 182 | continuation @dfn{tab format}. (Fortran90 introduced ``free format,'' | 211 | continuation @dfn{tab format}. (Fortran 90 introduced ``free form,'' |
| 183 | with another style of continuation lines). | 212 | with 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 | |||
| 192 | buffer. The first line that begins with either a tab character or six | 221 | 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 | 222 | spaces determines the choice. If the scan fails (for example, if the |
| 194 | buffer is new and therefore empty), the value of | 223 | buffer 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 |
| 196 | non-@code{nil} for tab format) is used. @samp{/t} in the mode line | 225 | non-@code{nil} for tab format) is used. @samp{/t} |
| 197 | indicates 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. | 227 | is selected. Fortran mode sets the value of @code{indent-tabs-mode} |
| 228 | accordingly. | ||
| 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 | |||
| 206 | to the continuation style. | 236 | to 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 |
| 209 | editing in Fortran mode. In fixed format mode, the minimum column | 239 | editing in Fortran mode. In fixed form mode, the minimum column |
| 210 | number for the body of a statement is 6. Lines inside of Fortran | 240 | 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 | 241 | blocks that are indented to larger column numbers always use only the |
| 212 | space character for whitespace. In tab format mode, the minimum | 242 | space character for whitespace. In tab format mode, the minimum |
| @@ -291,7 +321,7 @@ Extra indentation within each level of @samp{structure}, @samp{union}, | |||
| 291 | Extra indentation for bodies of continuation lines (default 5). | 321 | Extra 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 |
| 294 | In Fortran77, a numbered @samp{do} statement is ended by any statement | 324 | In Fortran 77, 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 | 325 | 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 | 326 | @samp{continue} statement for this purpose. If this variable has a |
| 297 | non-@code{nil} value, indenting any numbered statement must check for a | 327 | non-@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 |
| 309 | Minimum indentation for Fortran statements when using fixed format | 339 | Minimum indentation for Fortran statements when using fixed form |
| 310 | continuation line style. Statement bodies are never indented less than | 340 | continuation line style. Statement bodies are never indented less than |
| 311 | this much. The default is 6. | 341 | this 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 |
| 326 | line of code. In Fortran77, the standard comment syntax requires an | 356 | line of code. In Fortran 77, the standard comment syntax requires an |
| 327 | entire line to be just a comment. Therefore, Fortran mode replaces the | 357 | entire line to be just a comment. Therefore, Fortran mode replaces the |
| 328 | standard Emacs comment commands and defines some new variables. | 358 | standard 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 |
| 332 | start with @samp{!} and can follow other text. Because only some Fortran77 | 362 | comments start with @samp{!} and can follow other text. Because only |
| 333 | compilers accept this syntax, Fortran mode will not insert such comments | 363 | some Fortran 77 compilers accept this syntax, Fortran mode will not |
| 334 | unless you have said in advance to do so. To do this, set the variable | 364 | insert such comments unless you have said in advance to do so. To do |
| 335 | @code{fortran-comment-line-start} to @samp{"!"}. | 365 | this, set the variable @code{fortran-comment-line-start} to @samp{"!"}. |
| 366 | If 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 | |||
| 373 | indentation. This is the default. | 406 | indentation. This is the default. |
| 374 | 407 | ||
| 375 | The minimum statement indentation is | 408 | The minimum statement indentation is |
| 376 | @code{fortran-minimum-statement-indent-fixed} for fixed format | 409 | @code{fortran-minimum-statement-indent-fixed} for fixed form |
| 377 | continuation line style and @code{fortran-minimum-statement-indent-tab} | 410 | continuation line style and @code{fortran-minimum-statement-indent-tab} |
| 378 | for tab format style. | 411 | for tab format style. |
| 379 | 412 | ||
| @@ -461,6 +494,9 @@ In standard Fortran 77, anything beyond column 72 is ignored. | |||
| 461 | Most compilers provide an option to change this (for example, | 494 | Most 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. |
| 497 | Anything beyond this point is font-locked as a comment. (Unless it is | ||
| 498 | inside a string: strings that extend beyond @code{fortran-line-length} | ||
| 499 | will 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 |
| 541 | semicolon. You cannot normally use semicolon in an abbrev, but Fortran | 577 | semicolon. For example, one built-in Fortran abbrev is @samp{;c} for |
| 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 | 578 | @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 | 579 | character such as a space or a newline, the @samp{;c} expands automatically |
| 548 | to @samp{continue}, provided Abbrev mode is enabled.@refill | 580 | to @samp{continue}, provided Abbrev mode is enabled.@refill |