Fix wording in TUTORIAL.ru. Suggested by Igor Potseluev <4eppelin@gmail.com>.
[bpt/emacs.git] / doc / emacs / fortran-xtra.texi
index 3a46837..43e2e63 100644 (file)
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+@c Copyright (C) 2004-2012 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
@@ -9,11 +9,40 @@
 @cindex Fortran mode
 @cindex mode, Fortran
 
+@cindex Fortran fixed form and free form
+@cindex Fortran 77 and Fortran 90, 95, 2003, 2008
+@findex f90-mode
+@findex fortran-mode
+  Fortran mode is meant for editing ``fixed form'' (and also ``tab
+format'') source code (normally Fortran 77).  For editing more modern
+``free form'' source code (Fortran 90, 95, 2003, 2008), use F90 mode
+(@code{f90-mode}).  Emacs normally uses Fortran mode for files with
+extension @samp{.f}, @samp{.F} or @samp{.for}, and F90 mode for the
+extensions @samp{.f90}, @samp{.f95}, @samp{.f03} and @samp{.f08}.
+Customize @code{auto-mode-alist} to add more extensions.  GNU Fortran
+supports both free and fixed form.  This manual mainly documents Fortran
+mode, but the corresponding F90 mode features are mentioned when
+relevant.
+
   Fortran mode provides special motion commands for Fortran statements
 and subprograms, and indentation commands that understand Fortran
 conventions of nesting, line numbers and continuation statements.
 Fortran mode has support for Auto Fill mode that breaks long lines into
-proper Fortran continuation lines.
+proper Fortran continuation lines.  Fortran mode also supports Hideshow
+minor mode
+@iftex
+(@pxref{Hideshow,,, emacs, the Emacs Manual}),
+@end iftex
+@ifnottex
+(@pxref{Hideshow}),
+@end ifnottex
+and Imenu
+@iftex
+(@pxref{Imenu,,, emacs, the Emacs Manual}).
+@end iftex
+@ifnottex
+(@pxref{Imenu}).
+@end ifnottex
 
   Special commands for comments are provided because Fortran comments
 are unlike those of other languages.  Built-in abbrevs optionally save
@@ -28,32 +57,23 @@ command runs the hook @code{fortran-mode-hook}.
 @xref{Hooks}.
 @end ifnottex
 
-@cindex Fortran77 and Fortran90
-@findex f90-mode
-@findex fortran-mode
-  Fortran mode is meant for editing Fortran77 ``fixed format'' (and also
-``tab format'') source code.  For editing the modern Fortran90/95/2003
-``free format'' source code, use F90 mode (@code{f90-mode}).
-Emacs normally uses Fortran mode for files with extension @samp{.f},
-@samp{.F} or @samp{.for}, and F90 mode for the extension @samp{.f90} and
-@samp{.f95}.  GNU Fortran supports both kinds of format.
-
 @menu
-* Motion: Fortran Motion.       Moving point by statements or subprograms.
-* Indent: Fortran Indent.       Indentation commands for Fortran.
-* Comments: Fortran Comments.   Inserting and aligning comments.
-* Autofill: Fortran Autofill.   Auto fill support for Fortran.
-* Columns: Fortran Columns.     Measuring columns for valid Fortran.
-* Abbrev: Fortran Abbrev.       Built-in abbrevs for Fortran keywords.
+* Motion: Fortran Motion.        Moving point by statements or subprograms.
+* Indent: Fortran Indent.        Indentation commands for Fortran.
+* Comments: Fortran Comments.    Inserting and aligning comments.
+* Autofill: Fortran Autofill.    Auto fill support for Fortran.
+* Columns: Fortran Columns.      Measuring columns for valid Fortran.
+* Abbrev: Fortran Abbrev.        Built-in abbrevs for Fortran keywords.
 @end menu
 
 @node Fortran Motion
 @subsection Motion Commands
 
   In addition to the normal commands for moving by and operating on
-``defuns'' (Fortran subprograms---functions and subroutines, as well as
-modules for F90 mode), Fortran mode provides special commands to move by
-statements and other program units.
+``defuns'' (Fortran subprograms---functions and subroutines, as well
+as modules for F90 mode, using the commands @code{fortran-end-of-subprogram}
+and @code{fortran-beginning-of-subprogram}), Fortran mode provides
+special commands to move by statements and other program units.
 
 @table @kbd
 @kindex C-c C-n @r{(Fortran mode)}
@@ -75,16 +95,16 @@ statement in the buffer), move to the start of the buffer.
 @kindex C-c C-e @r{(F90 mode)}
 @findex f90-next-block
 @item C-c C-e
-Move point forward to the start of the next code block
-(@code{f90-next-block}).  A code block is a subroutine,
-@code{if}--@code{endif} statement, and so forth.  This command exists
-for F90 mode only, not Fortran mode.  With a numeric argument, this
-moves forward that many blocks.
+Move point forward to the start of the next code block, or the end of
+the current one, whichever comes first (@code{f90-next-block}).
+A code block is a subroutine, @code{if}--@code{endif} statement, and
+so forth.  This command exists for F90 mode only, not Fortran mode.
+With a numeric argument, it moves forward that many blocks.
 
 @kindex C-c C-a @r{(F90 mode)}
 @findex f90-previous-block
 @item C-c C-a
-Move point backward to the previous code block
+Move point backward to the previous block
 (@code{f90-previous-block}).  This is like @code{f90-next-block}, but
 moves backwards.
 
@@ -108,13 +128,20 @@ Move to the start of the current code block
 is like @code{fortran-end-of-block}, but moves backwards.
 @end table
 
+The commands @code{fortran-beginning-of-subprogram} and
+@code{fortran-end-of-subprogram} move to the start or end of the
+current subprogram, respectively.  The commands @code{fortran-mark-do}
+and @code{fortran-mark-if} mark the end of the current @code{do} or
+@code{if} block, and move point to the start.
+
+
 @node Fortran Indent
 @subsection Fortran Indentation
 
-  Special commands and features are needed for indenting Fortran code in
-order to make sure various syntactic entities (line numbers, comment line
-indicators and continuation line flags) appear in the columns that are
-required for standard, fixed (or tab) format Fortran.
+  Special commands and features are needed for indenting fixed (or tab)
+form Fortran code in order to make sure various syntactic entities (line
+numbers, comment line indicators and continuation line flags) appear in
+the required columns.
 
 @menu
 * Commands: ForIndent Commands.  Commands for indenting and filling Fortran.
@@ -134,10 +161,11 @@ Break the current line at point and set up a continuation line
 @item M-^
 Join this line to the previous line (@code{fortran-join-line}).
 @item C-M-q
-Indent all the lines of the subprogram point is in
+Indent all the lines of the subprogram that point is in
 (@code{fortran-indent-subprogram}).
 @item M-q
-Fill a comment block or statement.
+Fill a comment block or statement (using @code{fortran-fill-paragraph}
+or @code{fortran-fill-statement}).
 @end table
 
 @kindex C-M-q @r{(Fortran mode)}
@@ -171,15 +199,15 @@ point is in.  This removes any excess statement continuations.
 @cindex Fortran continuation lines
 
 @vindex fortran-continuation-string
-  Most Fortran77 compilers allow two ways of writing continuation lines.
+  Most Fortran 77 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 @dfn{fixed
-format}.  (In GNU Emacs we always count columns from 0; but note that
+form}.  (In GNU Emacs we always count columns from 0; but note that
 the Fortran standard counts from 1.)  The variable
 @code{fortran-continuation-string} specifies what character to put in
 column 5.  A line that starts with a tab character followed by any digit
 except @samp{0} is also a continuation line.  We call this style of
-continuation @dfn{tab format}.  (Fortran90 introduced ``free format,''
+continuation @dfn{tab format}.  (Fortran 90 introduced ``free form'',
 with another style of continuation lines).
 
 @vindex indent-tabs-mode @r{(Fortran mode)}
@@ -192,10 +220,11 @@ automatically from the buffer contents.  It does this by scanning up to
 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
-@code{fortran-tab-mode-default} (@code{nil} for fixed format, and
-non-@code{nil} for tab format) is used.  @samp{/t} in the mode line
-indicates tab format is selected.  Fortran mode sets the value of
-@code{indent-tabs-mode} accordingly.
+@code{fortran-tab-mode-default} (@code{nil} for fixed form, and
+non-@code{nil} for tab format) is used.  @samp{/t}
+(@code{fortran-tab-mode-string}) in the mode line indicates tab format
+is selected.  Fortran mode sets the value of @code{indent-tabs-mode}
+accordingly.
 
   If the text on a line starts with the Fortran continuation marker
 @samp{$}, or if it begins with any non-whitespace character in column
@@ -206,19 +235,19 @@ continuation style.  When you split a Fortran statement with
 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
+editing in Fortran mode.  In fixed form 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
+blocks that are indented to larger column numbers must 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.
+column 8 must consist of one tab character.
 
 @node ForIndent Num
 @subsubsection Line Numbers
 
   If a number is the first non-whitespace in the line, Fortran
 indentation assumes it is a line number and moves it to columns 0
-through 4.  (Columns always count from 0 in GNU Emacs.)
+through 4.  (Columns always count from 0 in Emacs.)
 
 @vindex fortran-line-number-indent
   Line numbers of four digits or less are normally indented one space.
@@ -291,14 +320,14 @@ Extra indentation within each level of @samp{structure}, @samp{union},
 Extra indentation for bodies of continuation lines (default 5).
 
 @item fortran-check-all-num-for-matching-do
-In Fortran77, a numbered @samp{do} statement is ended by any statement
+In Fortran 77, a numbered @samp{do} statement is ended by any statement
 with a matching line number.  It is common (but not compulsory) to use a
 @samp{continue} statement for this purpose.  If this variable has a
 non-@code{nil} value, indenting any numbered statement must check for a
 @samp{do} that ends there.  If you always end @samp{do} statements with
 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}.
+@code{nil} (the default).
 
 @item fortran-blink-matching-if
 If this is @code{t}, indenting an @samp{endif} (or @samp{enddo}
@@ -306,53 +335,54 @@ statement moves the cursor momentarily to the matching @samp{if} (or
 @samp{do}) statement to show where it is.  The default is @code{nil}.
 
 @item fortran-minimum-statement-indent-fixed
-Minimum indentation for Fortran statements when using fixed format
-continuation line style.  Statement bodies are never indented less than
-this much.  The default is 6.
+Minimum indentation for Fortran statements when using fixed form
+continuation line style.  Statement bodies are never indented by less than
+this.  The default is 6.
 
 @item fortran-minimum-statement-indent-tab
 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 by less than this.  The
 default is 8.
 @end table
 
-The variables controlling the indentation of comments are described in
-the following section.
+The following section describes the variables controlling the
+indentation of comments.
 
 @node Fortran Comments
 @subsection Fortran Comments
 
   The usual Emacs comment commands assume that a comment can follow a
-line of code.  In Fortran77, the standard comment syntax requires an
+line of code.  In Fortran 77, the standard comment syntax requires an
 entire line to be just a comment.  Therefore, Fortran mode replaces the
 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
-start with @samp{!} and can follow other text.  Because only some Fortran77
-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
-@code{fortran-comment-line-start} to @samp{"!"}.
+  Fortran mode can also handle the Fortran 90 comment syntax where
+comments start with @samp{!} and can follow other text.  Because only
+some Fortran 77 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 @code{fortran-comment-line-start} to @samp{"!"}.
+If you use an unusual value, you may need to change
+@code{fortran-comment-line-start-skip}.
+
 
 @table @kbd
 @item M-;
-Align comment or insert new comment (@code{fortran-indent-comment}).
+Align comment or insert new comment (@code{comment-dwim}).
 
 @item C-x ;
-Applies to nonstandard @samp{!} comments only.
+Applies to nonstandard @samp{!} comments only (@code{comment-set-column}).
 
 @item C-c ;
 Turn all lines of the region into comments, or (with argument) turn them back
 into real code (@code{fortran-comment-region}).
 @end table
 
-@findex fortran-indent-comment
-  @kbd{M-;} in Fortran mode is redefined as the command
-@code{fortran-indent-comment}.  Like the usual @kbd{M-;} command, this
-recognizes any kind of existing comment and aligns its text appropriately;
-if there is no existing comment, a comment is inserted and aligned.  But
-inserting and aligning comments are not the same in Fortran mode as in
-other modes.
+  @kbd{M-;} in Fortran mode runs the standard @code{comment-dwim}.
+This recognizes any kind of existing comment and aligns its text
+appropriately; if there is no existing comment, a comment is inserted
+and aligned.  Inserting and aligning comments are not the same in
+Fortran mode as in other modes.
 
   When a new comment must be inserted, if the current line is blank, a
 full-line comment is inserted.  On a non-blank line, a nonstandard @samp{!}
@@ -374,10 +404,10 @@ Align the text at a fixed column, which is the sum of
 @code{fortran-comment-line-extra-indent} and the minimum statement
 indentation.  This is the default.
 
-The minimum statement indentation is
-@code{fortran-minimum-statement-indent-fixed} for fixed format
-continuation line style and @code{fortran-minimum-statement-indent-tab}
-for tab format style.
+The minimum indentation is
+@code{fortran-minimum-statement-indent-tab} for tab format
+continuation line style and @code{fortran-minimum-statement-indent-fixed}
+for fixed form style.
 
 @item relative
 Align the text as if it were a line of code, but with an additional
@@ -402,17 +432,17 @@ never be indented at all, no matter what the value of
 lines are directives.  Matching lines are never indented, and receive
 distinctive font-locking.
 
-  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
-it is useless in Fortran mode.
+  The normal Emacs comment command @kbd{C-x ;} (@code{comment-set-column})
+has not been redefined.  If you use @samp{!} comments, this command
+can be used with them.  Otherwise it is useless in Fortran mode.
 
 @kindex C-c ; @r{(Fortran mode)}
 @findex fortran-comment-region
 @vindex fortran-comment-region
   The command @kbd{C-c ;} (@code{fortran-comment-region}) turns all the
-lines of the region into comments by inserting the string @samp{C$$$} at
+lines of the region into comments by inserting the string @samp{c$$$} at
 the front of each one.  With a numeric argument, it turns the region
-back into live code by deleting @samp{C$$$} from the front of each line
+back into live code by deleting @samp{c$$$} from the front of each line
 in it.  The string used for these comments can be controlled by setting
 the variable @code{fortran-comment-region}.  Note that here we have an
 example of a command and a variable with the same name; these two uses
@@ -447,7 +477,7 @@ variable @code{fortran-break-before-delimiters} is @code{nil}.
 Otherwise (and by default), the break comes before the delimiter.
 
   To enable Auto Fill in all Fortran buffers, add
-@code{turn-on-auto-fill} to @code{fortran-mode-hook}.
+@code{auto-fill-mode} to @code{fortran-mode-hook}.
 @iftex
 @xref{Hooks,,, emacs, the Emacs Manual}.
 @end iftex
@@ -463,6 +493,9 @@ In standard Fortran 77, anything beyond column 72 is ignored.
 Most compilers provide an option to change this (for example,
 @samp{-ffixed-line-length-N} in gfortran).  Customize the variable
 @code{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 @code{fortran-line-length}
+will confuse font-lock.)
 
 @table @kbd
 @item C-c C-r
@@ -472,8 +505,7 @@ Display a ``column ruler'' momentarily above the current line
 Split the current window horizontally temporarily so that it is
 @code{fortran-line-length} columns wide
 (@code{fortran-window-create-momentarily}).  This may help you avoid
-making lines longer than the character limit imposed by your Fortran
-compiler.
+making lines longer than the limit imposed by your Fortran compiler.
 @item C-u C-c C-w
 Split the current window horizontally so that it is
 @code{fortran-line-length} columns wide (@code{fortran-window-create}).
@@ -540,18 +572,10 @@ yourself.  To use them, you must turn on Abbrev mode.
 @end ifnottex
 
   The built-in abbrevs are unusual in one way: they all start with a
-semicolon.  You cannot normally use semicolon in an abbrev, but Fortran
-mode makes this possible by changing the syntax of semicolon to ``word
-constituent.''
-
-  For example, one built-in Fortran abbrev is @samp{;c} for
+semicolon.  For example, one built-in Fortran abbrev is @samp{;c} for
 @samp{continue}.  If you insert @samp{;c} and then insert a punctuation
 character such as a space or a newline, the @samp{;c} expands automatically
 to @samp{continue}, provided Abbrev mode is enabled.@refill
 
   Type @samp{;?} or @samp{;C-h} to display a list of all the built-in
 Fortran abbrevs and what they stand for.
-
-@ignore
-   arch-tag: 23ed7c36-1517-4646-9235-2d5ade5f06f6
-@end ignore