Go to the first, previous, next, last section, table of contents.


Continuation Lines

Most modern Fortran 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.) The variable fortran-continuation-string specifies what character to put on 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.

Fortran mode can make either style of continuation line, but you must specify which one you prefer. The value of the variable indent-tabs-mode controls the choice: nil for fixed format, and non-nil for tab format. You can tell which style is presently in effect by the presence or absence of the string `Tab' in the mode line.

If the text on a line starts with the conventional 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.

When you enter Fortran mode for an existing file, it tries to deduce the proper continuation style automatically from the file contents. The first line that begins with either a tab character or six spaces determines the choice. The variable fortran-analyze-depth specifies how many lines to consider (at the beginning of the file); if none of those lines indicates a style, then the variable fortran-tab-mode-default specifies the style. If it is nil, that specifies fixed format, and non-nil specifies tab format.


Go to the first, previous, next, last section, table of contents.