Next: , Previous: ForIndent Commands, Up: Fortran Indent


31.12.2.2 Continuation Lines

Most Fortran77 compilers allow two ways of writing continuation lines. If the first non-space character on a line is in column 5, then that line is a continuation of the previous line. We call this fixed format. (In GNU Emacs we always count columns from 0; but note that the Fortran standard counts from 1.) The variable fortran-continuation-string specifies what character to put in column 5. A line that starts with a tab character followed by any digit except ‘0’ is also a continuation line. We call this style of continuation tab format. (Fortran90 introduced “free format”, with another style of continuation lines).

Fortran mode can use either style of continuation line. When you enter Fortran mode, it tries to deduce the proper continuation style automatically from the buffer contents. It does this by scanning up to fortran-analyze-depth (default 100) lines from the start of the buffer. The first line that begins with either a tab character or six spaces determines the choice. If the scan fails (for example, if the buffer is new and therefore empty), the value of fortran-tab-mode-default (nil for fixed format, and non-nil for tab format) is used. ‘/t’ in the mode line indicates tab format is selected. Fortran mode sets the value of indent-tabs-mode accordingly (see Just Spaces).

If the text on a line starts with the Fortran continuation marker ‘$’, or if it begins with any non-whitespace character in column 5, Fortran mode treats it as a continuation line. When you indent a continuation line with <TAB>, it converts the line to the current continuation style. When you split a Fortran statement with C-M-j, the continuation marker on the newline is created according to the continuation style.

The setting of continuation style affects several other aspects of editing in Fortran mode. In fixed format mode, the minimum column number for the body of a statement is 6. Lines inside of Fortran blocks that are indented to larger column numbers always use only the space character for whitespace. In tab format mode, the minimum column number for the statement body is 8, and the whitespace before column 8 must always consist of one tab character.