26.14.5 Checking Columns in Fortran
In standard Fortran 77, anything beyond column 72 is ignored. Most compilers provide an option to change this (for example, ā-ffixed-line-length-N
ā in gfortran). Customize the variable fortran-line-length
to change the line length in Fortran mode. Anything beyond this point is font-locked as a comment. (Unless it is inside a string: strings that extend beyond fortran-line-length
will confuse font-lock.)
C-c C-r
ā
Display a column ruler momentarily above the current line (fortran-column-ruler
).
C-c C-w
ā
Split the current window horizontally temporarily so that it is fortran-line-length
columns wide (fortran-window-create-momentarily
). This may help you avoid making lines longer than the limit imposed by your Fortran compiler.
C-u C-c C-w
ā
Split the current window horizontally so that it is fortran-line-length
columns wide (fortran-window-create
). You can then continue editing.
M-x fortran-strip-sequence-nos
ā
Delete all text in column fortran-line-length
and beyond.
The command C-c C-r
(fortran-column-ruler
) shows a column ruler momentarily above the current line. The comment ruler is two lines of text that show you the locations of columns with special significance in Fortran programs. Square brackets show the limits of the columns for line numbers, and curly brackets show the limits of the columns for the statement body. Column numbers appear above them.
Note that the column numbers count from zero, as always in GNU Emacs (but customizing column-number-indicator-zero-based
can change column display to match that of Fortran; see Optional Mode Line.) As a result, the numbers may be one less than those you are familiar with; but the positions they indicate in the line are standard for Fortran.
The text used to display the column ruler depends on the value of the variable indent-tabs-mode
. If indent-tabs-mode
is nil
, then the value of the variable fortran-column-ruler-fixed
is used as the column ruler. Otherwise, the value of the variable fortran-column-ruler-tab
is displayed. By changing these variables, you can change the column ruler display.
C-c C-w
(fortran-window-create-momentarily
) temporarily splits the current window horizontally, making a window fortran-line-length
columns wide, so you can see any lines that are too long. Type a space to restore the normal width.
You can also split the window horizontally and continue editing with the split in place. To do this, use C-u C-c C-w
(M-x fortran-window-create
). By editing in this window you can immediately see when you make a line too wide to be correct Fortran.
The command M-x fortran-strip-sequence-nos
deletes all text in column fortran-line-length
and beyond, on all lines in the current buffer. This is the easiest way to get rid of old sequence numbers.