Commit 40279251 authored by Glenn Morris's avatar Glenn Morris
Browse files

Reformat and update copyright years.

(Fortran): Update section.
parent 91878d2b
@c This is part of the Emacs manual. @c This is part of the Emacs manual.
@c Copyright (C) 1985,86,87,93,94,95,97,99,00,2001 Free Software Foundation, Inc. @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1999, 2000,
@c 2001, 2005 Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions. @c See file emacs.texi for copying conditions.
@node Programs, Building, Text, Top @node Programs, Building, Text, Top
@chapter Editing Programs @chapter Editing Programs
...@@ -1801,11 +1802,11 @@ names. ...@@ -1801,11 +1802,11 @@ names.
@cindex Fortran mode @cindex Fortran mode
@cindex mode, Fortran @cindex mode, Fortran
Fortran mode provides special motion commands for Fortran statements and Fortran mode provides special motion commands for Fortran statements
subprograms, and indentation commands that understand Fortran conventions and subprograms, and indentation commands that understand Fortran
of nesting, line numbers and continuation statements. Fortran mode has conventions of nesting, line numbers and continuation statements.
its own Auto Fill mode that breaks long lines into proper Fortran Fortran mode has support for Auto Fill mode that breaks long lines into
continuation lines. proper Fortran continuation lines.
Special commands for comments are provided because Fortran comments Special commands for comments are provided because Fortran comments
are unlike those of other languages. Built-in abbrevs optionally save are unlike those of other languages. Built-in abbrevs optionally save
...@@ -1817,18 +1818,18 @@ runs the hook @code{fortran-mode-hook} (@pxref{Hooks}). ...@@ -1817,18 +1818,18 @@ runs the hook @code{fortran-mode-hook} (@pxref{Hooks}).
@cindex Fortran77 and Fortran90 @cindex Fortran77 and Fortran90
@findex f90-mode @findex f90-mode
@findex fortran-mode @findex fortran-mode
Fortran mode is meant for editing Fortran77 ``fixed format'' source Fortran mode is meant for editing Fortran77 ``fixed format'' (and also
code. For editing the modern Fortran90 ``free format'' source code, ``tab format'') source code. For editing the modern Fortran90 or
use F90 mode (@code{f90-mode}). Emacs normally uses Fortran mode for Fortran95 ``free format'' source code, use F90 mode (@code{f90-mode}).
files with extension @samp{.f}, @samp{.F} or @samp{.for}, and F90 mode Emacs normally uses Fortran mode for files with extension @samp{.f},
for the extension @samp{.f90}. GNU Fortran supports both kinds of @samp{.F} or @samp{.for}, and F90 mode for the extension @samp{.f90} and
format. @samp{.f95}. GNU Fortran supports both kinds of format.
@menu @menu
* Motion: Fortran Motion. Moving point by statements or subprograms. * Motion: Fortran Motion. Moving point by statements or subprograms.
* Indent: Fortran Indent. Indentation commands for Fortran. * Indent: Fortran Indent. Indentation commands for Fortran.
* Comments: Fortran Comments. Inserting and aligning comments. * Comments: Fortran Comments. Inserting and aligning comments.
* Autofill: Fortran Autofill. Auto fill minor mode for Fortran. * Autofill: Fortran Autofill. Auto fill support for Fortran.
* Columns: Fortran Columns. Measuring columns for valid Fortran. * Columns: Fortran Columns. Measuring columns for valid Fortran.
* Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords. * Abbrev: Fortran Abbrev. Built-in abbrevs for Fortran keywords.
@end menu @end menu
...@@ -1837,8 +1838,9 @@ format. ...@@ -1837,8 +1838,9 @@ format.
@subsection Motion Commands @subsection Motion Commands
In addition to the normal commands for moving by and operating on In addition to the normal commands for moving by and operating on
``defuns'' (Fortran subprograms---functions and subroutines), Fortran ``defuns'' (Fortran subprograms---functions and subroutines, as well as
mode provides special commands to move by statements. modules for F90 mode), Fortran mode provides special commands to move by
statements.
@table @kbd @table @kbd
@kindex C-c C-n @r{(Fortran mode)} @kindex C-c C-n @r{(Fortran mode)}
...@@ -1896,7 +1898,7 @@ but moves backwards. ...@@ -1896,7 +1898,7 @@ but moves backwards.
Special commands and features are needed for indenting Fortran code in Special commands and features are needed for indenting Fortran code in
order to make sure various syntactic entities (line numbers, comment line order to make sure various syntactic entities (line numbers, comment line
indicators and continuation line flags) appear in the columns that are indicators and continuation line flags) appear in the columns that are
required for standard Fortran. required for standard, fixed (or tab) format Fortran.
@menu @menu
* Commands: ForIndent Commands. Commands for indenting and filling Fortran. * Commands: ForIndent Commands. Commands for indenting and filling Fortran.
...@@ -1911,7 +1913,7 @@ required for standard Fortran. ...@@ -1911,7 +1913,7 @@ required for standard Fortran.
@table @kbd @table @kbd
@item C-M-j @item C-M-j
Break the current line and set up a continuation line Break the current line at point and set up a continuation line
(@code{fortran-split-line}). (@code{fortran-split-line}).
@item M-^ @item M-^
Join this line to the previous line (@code{fortran-join-line}). Join this line to the previous line (@code{fortran-join-line}).
...@@ -1953,30 +1955,42 @@ point is in. This removes any excess statement continuations. ...@@ -1953,30 +1955,42 @@ point is in. This removes any excess statement continuations.
@cindex Fortran continuation lines @cindex Fortran continuation lines
@vindex fortran-continuation-string @vindex fortran-continuation-string
Most modern Fortran compilers allow two ways of writing continuation Most Fortran77 compilers allow two ways of writing continuation lines.
lines. If the first non-space character on a line is in column 5, then If the first non-space character on a line is in column 5, then that
that line is a continuation of the previous line. We call this line is a continuation of the previous line. We call this @dfn{fixed
@dfn{fixed format}. (In GNU Emacs we always count columns from 0.) The format}. (In GNU Emacs we always count columns from 0; but note that
variable @code{fortran-continuation-string} specifies what character to the Fortran standard counts from 1.) The variable
put on column 5. A line that starts with a tab character followed by @code{fortran-continuation-string} specifies what character to put in
any digit except @samp{0} is also a continuation line. We call this column 5. A line that starts with a tab character followed by any digit
style of continuation @dfn{tab format}. except @samp{0} is also a continuation line. We call this style of
continuation @dfn{tab format}. (Fortran90 introduced ``free format'',
with another style of continuation lines).
@vindex indent-tabs-mode @r{(Fortran mode)} @vindex indent-tabs-mode @r{(Fortran mode)}
Fortran mode can make either style of continuation line, but you @vindex fortran-analyze-depth
must specify which one you prefer. The value of the variable @vindex fortran-tab-mode-default
@code{indent-tabs-mode} controls the choice: @code{nil} for fixed @vindex fortran-tab-mode-string
format, and non-@code{nil} for tab format. You can tell which style Fortran mode can use either style of continuation line. When you
is presently in effect by the presence or absence of the string enter Fortran mode, it tries to deduce the proper continuation style
@samp{Tab} in the mode line. automatically from the buffer contents. It does this by scanning up to
@code{fortran-analyze-depth} (default 100) lines from the start of the
If the text on a line starts with the conventional Fortran buffer. The first line that begins with either a tab character or six
continuation marker @samp{$}, or if it begins with any non-whitespace spaces determines the choice. If the scan fails (for example, if the
character in column 5, Fortran mode treats it as a continuation line. buffer is new and therefore empty), the value of
When you indent a continuation line with @key{TAB}, it converts the line @code{fortran-tab-mode-default} (@code{nil} for fixed format, and
to the current continuation style. When you split a Fortran statement non-@code{nil} for tab format) is used. You can tell which style is
with @kbd{C-M-j}, the continuation marker on the newline is created presently in effect by the presence or absence of the string specified
according to the continuation style. by @code{fortran-tab-mode-string} (default @samp{/t}) in the mode line.
@vindex fortran-continuation-string
If the text on a line starts with the Fortran continuation marker
specified by @code{fortran-continuation-string} (conventionally
@samp{$}), 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 @key{TAB}, it converts the line to the current
continuation style. When you split a Fortran statement with
@kbd{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 The setting of continuation style affects several other aspects of
editing in Fortran mode. In fixed format mode, the minimum column editing in Fortran mode. In fixed format mode, the minimum column
...@@ -1986,17 +2000,6 @@ space character for whitespace. In tab format mode, the minimum ...@@ -1986,17 +2000,6 @@ space character for whitespace. In tab format mode, the minimum
column number for the statement body is 8, and the whitespace before column number for the statement body is 8, and the whitespace before
column 8 must always consist of one tab character. column 8 must always consist of one tab character.
@vindex fortran-tab-mode-default
@vindex fortran-analyze-depth
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 @code{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 @code{fortran-tab-mode-default}
specifies the style. If it is @code{nil}, that specifies fixed format, and
non-@code{nil} specifies tab format.
@node ForIndent Num @node ForIndent Num
@subsubsection Line Numbers @subsubsection Line Numbers
...@@ -2007,9 +2010,11 @@ through 4. (Columns always count from 0 in GNU Emacs.) ...@@ -2007,9 +2010,11 @@ through 4. (Columns always count from 0 in GNU Emacs.)
@vindex fortran-line-number-indent @vindex fortran-line-number-indent
Line numbers of four digits or less are normally indented one space. Line numbers of four digits or less are normally indented one space.
The variable @code{fortran-line-number-indent} controls this; it The variable @code{fortran-line-number-indent} controls this; it
specifies the maximum indentation a line number can have. Line numbers specifies the maximum indentation a line number can have. The default
are right-justified to end in column 4 unless that would require more value of the variable is 1. Fortran mode tries to prevent line number
than this maximum indentation. The default value of the variable is 1. digits passing column 4, reducing the indentation below the specified
maximum if necessary. If @code{fortran-line-number-indent} has the
value 5, line numbers are right-justified to end in column 4.
@vindex fortran-electric-line-number @vindex fortran-electric-line-number
Simply inserting a line number is enough to indent it according to Simply inserting a line number is enough to indent it according to
...@@ -2063,53 +2068,58 @@ Extra indentation within each level of @samp{do} statement (default 3). ...@@ -2063,53 +2068,58 @@ Extra indentation within each level of @samp{do} statement (default 3).
@item fortran-if-indent @item fortran-if-indent
Extra indentation within each level of @samp{if} statement (default 3). Extra indentation within each level of @samp{if} statement (default 3).
This value is also used for extra indentation within each level of the
Fortran 90 @samp{where} statement.
@item fortran-structure-indent @item fortran-structure-indent
Extra indentation within each level of @samp{structure}, @samp{union}, or Extra indentation within each level of @samp{structure}, @samp{union},
@samp{map} statements (default 3). @samp{map}, or @samp{interface} statements (default 3).
@item fortran-continuation-indent @item fortran-continuation-indent
Extra indentation for bodies of continuation lines (default 5). Extra indentation for bodies of continuation lines (default 5).
@item fortran-check-all-num-for-matching-do @item fortran-check-all-num-for-matching-do
If this is @code{nil}, indentation assumes that each @samp{do} statement In Fortran77, a numbered @samp{do} statement is ended by any statement
ends on a @samp{continue} statement. Therefore, when computing with a matching line number. It is common (but not compulsory) to use a
indentation for a statement other than @samp{continue}, it can save time @samp{continue} statement for this purpose. If this variable has a
by not checking for a @samp{do} statement ending there. If this is non-@code{nil} value, indenting any numbered statement must check for a
non-@code{nil}, indenting any numbered statement must check for a @samp{do} that ends there. If you always end @samp{do} statements with
@samp{do} that ends there. The default is @code{nil}. a @samp{continue} line (or if you use the more modern @samp{enddo}),
then you can speed up indentation by setting this variable to
@code{nil}. The default is @code{nil}.
@item fortran-blink-matching-if @item fortran-blink-matching-if
If this is @code{t}, indenting an @samp{endif} statement moves the If this is @code{t}, indenting an @samp{endif} (or @samp{enddo}
cursor momentarily to the matching @samp{if} statement to show where it statement moves the cursor momentarily to the matching @samp{if} (or
is. The default is @code{nil}. @samp{do}) statement to show where it is. The default is @code{nil}.
@item fortran-minimum-statement-indent-fixed @item fortran-minimum-statement-indent-fixed
Minimum indentation for fortran statements when using fixed format Minimum indentation for Fortran statements when using fixed format
continuation line style. Statement bodies are never indented less than continuation line style. Statement bodies are never indented less than
this much. The default is 6. this much. The default is 6.
@item fortran-minimum-statement-indent-tab @item fortran-minimum-statement-indent-tab
Minimum indentation for fortran statements for tab format continuation line Minimum indentation for Fortran statements for tab format continuation line
style. Statement bodies are never indented less than this much. The style. Statement bodies are never indented less than this much. The
default is 8. default is 8.
@end table @end table
The variables controlling the indentation of comments are described in
a separate section (@pxref{Fortran Comments}).
@node Fortran Comments @node Fortran Comments
@subsection Fortran Comments @subsection Fortran Comments
The usual Emacs comment commands assume that a comment can follow a line The usual Emacs comment commands assume that a comment can follow a
of code. In Fortran, the standard comment syntax requires an entire line line of code. In Fortran77, the standard comment syntax requires an
to be just a comment. Therefore, Fortran mode replaces the standard Emacs entire line to be just a comment. Therefore, Fortran mode replaces the
comment commands and defines some new variables. standard Emacs comment commands and defines some new variables.
@vindex fortran-comment-line-start
Fortran mode can also handle the Fortran90 comment syntax where comments Fortran mode can also handle the Fortran90 comment syntax where comments
start with @samp{!} and can follow other text. Because only some Fortran77 start with @samp{!} and can follow other text. Because only some Fortran77
compilers accept this syntax, Fortran mode will not insert such comments compilers accept this syntax, Fortran mode will not insert such comments
unless you have said in advance to do so. To do this, set the variable unless you have said in advance to do so. To do this, set the variable
@code{comment-start} to @samp{"!"} (@pxref{Variables}). @code{fortran-comment-line-start} to @samp{"!"}.
@table @kbd @table @kbd
@item M-; @item M-;
...@@ -2123,6 +2133,7 @@ Turn all lines of the region into comments, or (with argument) turn them back ...@@ -2123,6 +2133,7 @@ Turn all lines of the region into comments, or (with argument) turn them back
into real code (@code{fortran-comment-region}). into real code (@code{fortran-comment-region}).
@end table @end table
@findex fortran-indent-comment
@kbd{M-;} in Fortran mode is redefined as the command @kbd{M-;} in Fortran mode is redefined as the command
@code{fortran-indent-comment}. Like the usual @kbd{M-;} command, this @code{fortran-indent-comment}. Like the usual @kbd{M-;} command, this
recognizes any kind of existing comment and aligns its text appropriately; recognizes any kind of existing comment and aligns its text appropriately;
...@@ -2178,14 +2189,6 @@ never be indented at all, no matter what the value of ...@@ -2178,14 +2189,6 @@ never be indented at all, no matter what the value of
lines are directives. Matching lines are never indented, and receive lines are directives. Matching lines are never indented, and receive
distinctive font-locking. distinctive font-locking.
@vindex comment-line-start
@vindex comment-line-start-skip
Fortran mode introduces two variables @code{comment-line-start} and
@code{comment-line-start-skip}, which play for full-line comments the same
roles played by @code{comment-start} and @code{comment-start-skip} for
ordinary text-following comments. Normally these are set properly by
Fortran mode, so you do not need to change them.
The normal Emacs comment command @kbd{C-x ;} has not been redefined. If The normal Emacs comment command @kbd{C-x ;} has not been redefined. If
you use @samp{!} comments, this command can be used with them. Otherwise you use @samp{!} comments, this command can be used with them. Otherwise
it is useless in Fortran mode. it is useless in Fortran mode.
...@@ -2204,34 +2207,28 @@ of the name never conflict because in Lisp and in Emacs it is always ...@@ -2204,34 +2207,28 @@ of the name never conflict because in Lisp and in Emacs it is always
clear from the context which one is meant. clear from the context which one is meant.
@node Fortran Autofill @node Fortran Autofill
@subsection Fortran Auto Fill Mode @subsection Auto Fill in Fortran Mode
Fortran Auto Fill mode is a minor mode which automatically splits Fortran mode has specialized support for Auto Fill mode, which is a
Fortran statements as you insert them when they become too wide. minor mode that automatically splits statements as you insert them when
Splitting a statement involves making continuation lines using they become too wide. Splitting a statement involves making
@code{fortran-continuation-string} (@pxref{ForIndent Cont}). This continuation lines using @code{fortran-continuation-string}
splitting happens when you type @key{SPC}, @key{RET}, or @key{TAB}, and (@pxref{ForIndent Cont}). This splitting happens when you type
also in the Fortran indentation commands. @key{SPC}, @key{RET}, or @key{TAB}, and also in the Fortran indentation
commands. You activate Auto Fill in Fortran mode in the normal way
@findex fortran-auto-fill-mode (@pxref{Auto Fill}).
@kbd{M-x fortran-auto-fill-mode} toggles Fortran Auto Fill mode,
which is a variant of normal Auto Fill mode (@pxref{Filling}) designed
for Fortran programs. Fortran Auto Fill mode is a buffer-local minor
mode (@pxref{Minor Modes}). When Fortran Auto Fill mode is in effect,
the word @samp{Fill} appears in the mode line inside the parentheses.
@vindex fortran-break-before-delimiters @vindex fortran-break-before-delimiters
Fortran Auto Fill mode breaks lines at spaces or delimiters when the Auto Fill breaks lines at spaces or delimiters when the lines get
lines get longer than the desired width (the value of @code{fill-column}). longer than the desired width (the value of @code{fill-column}). The
The delimiters that Fortran Auto Fill mode may break at are @samp{,}, delimiters (besides whitespace) that Auto Fill may break at are
@samp{'}, @samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, and @samp{)}. @samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, @samp{<}, @samp{>},
The line break comes after the delimiter if the variable and @samp{,}. The line break comes after the delimiter if the variable
@code{fortran-break-before-delimiters} is @code{nil}. Otherwise (and by @code{fortran-break-before-delimiters} is @code{nil}. Otherwise (and by
default), the break comes before the delimiter. default), the break comes before the delimiter.
To enable this mode permanently, add a hook function to To enable Auto Fill in all Fortran buffers, add
@code{fortran-mode-hook} to execute @code{(fortran-auto-fill-mode 1)}. @code{turn-on-auto-fill} to @code{fortran-mode-hook}. @xref{Hooks}.
@xref{Hooks}.
@node Fortran Columns @node Fortran Columns
@subsection Checking Columns in Fortran @subsection Checking Columns in Fortran
...@@ -2280,7 +2277,7 @@ display. ...@@ -2280,7 +2277,7 @@ display.
@findex fortran-window-create-momentarily @findex fortran-window-create-momentarily
@kbd{C-c C-w} (@code{fortran-window-create-momentarily}) temporarily @kbd{C-c C-w} (@code{fortran-window-create-momentarily}) temporarily
splits the current window horizontally, making a window 72 columns splits the current window horizontally, making a window 72 columns
wide, so you can see which lines that is too long. Type a space to wide, so you can see any lines that are too long. Type a space to
restore the normal width. restore the normal width.
@kindex C-u C-c C-w @r{(Fortran mode)} @kindex C-u C-c C-w @r{(Fortran mode)}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment