/[emacs]/emacs/man/programs.texi
ViewVC logotype

Diff of /emacs/man/programs.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.90 by rms, Mon Mar 21 19:02:02 2005 UTC revision 1.91 by gm, Sun Mar 27 17:16:31 2005 UTC
# Line 1  Line 1 
1  @c This is part of the Emacs manual.  @c This is part of the Emacs manual.
2  @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,
3    @c               2001, 2005  Free Software Foundation, Inc.
4  @c See file emacs.texi for copying conditions.  @c See file emacs.texi for copying conditions.
5  @node Programs, Building, Text, Top  @node Programs, Building, Text, Top
6  @chapter Editing Programs  @chapter Editing Programs
# Line 1801  names. Line 1802  names.
1802  @cindex Fortran mode  @cindex Fortran mode
1803  @cindex mode, Fortran  @cindex mode, Fortran
1804    
1805    Fortran mode provides special motion commands for Fortran statements and    Fortran mode provides special motion commands for Fortran statements
1806  subprograms, and indentation commands that understand Fortran conventions  and subprograms, and indentation commands that understand Fortran
1807  of nesting, line numbers and continuation statements.  Fortran mode has  conventions of nesting, line numbers and continuation statements.
1808  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
1809  continuation lines.  proper Fortran continuation lines.
1810    
1811    Special commands for comments are provided because Fortran comments    Special commands for comments are provided because Fortran comments
1812  are unlike those of other languages.  Built-in abbrevs optionally save  are unlike those of other languages.  Built-in abbrevs optionally save
# Line 1817  runs the hook @code{fortran-mode-hook} ( Line 1818  runs the hook @code{fortran-mode-hook} (
1818  @cindex Fortran77 and Fortran90  @cindex Fortran77 and Fortran90
1819  @findex f90-mode  @findex f90-mode
1820  @findex fortran-mode  @findex fortran-mode
1821    Fortran mode is meant for editing Fortran77 ``fixed format'' source    Fortran mode is meant for editing Fortran77 ``fixed format'' (and also
1822  code.  For editing the modern Fortran90 ``free format'' source code,  ``tab format'') source code.  For editing the modern Fortran90 or
1823  use F90 mode (@code{f90-mode}).  Emacs normally uses Fortran mode for  Fortran95 ``free format'' source code, use F90 mode (@code{f90-mode}).
1824  files with extension @samp{.f}, @samp{.F} or @samp{.for}, and F90 mode  Emacs normally uses Fortran mode for files with extension @samp{.f},
1825  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
1826  format.  @samp{.f95}.  GNU Fortran supports both kinds of format.
1827    
1828  @menu  @menu
1829  * Motion: Fortran Motion.        Moving point by statements or subprograms.  * Motion: Fortran Motion.        Moving point by statements or subprograms.
1830  * Indent: Fortran Indent.        Indentation commands for Fortran.  * Indent: Fortran Indent.        Indentation commands for Fortran.
1831  * Comments: Fortran Comments.    Inserting and aligning comments.  * Comments: Fortran Comments.    Inserting and aligning comments.
1832  * Autofill: Fortran Autofill.    Auto fill minor mode for Fortran.  * Autofill: Fortran Autofill.    Auto fill support for Fortran.
1833  * Columns: Fortran Columns.      Measuring columns for valid Fortran.  * Columns: Fortran Columns.      Measuring columns for valid Fortran.
1834  * Abbrev: Fortran Abbrev.        Built-in abbrevs for Fortran keywords.  * Abbrev: Fortran Abbrev.        Built-in abbrevs for Fortran keywords.
1835  @end menu  @end menu
# Line 1837  format. Line 1838  format.
1838  @subsection Motion Commands  @subsection Motion Commands
1839    
1840    In addition to the normal commands for moving by and operating on    In addition to the normal commands for moving by and operating on
1841  ``defuns'' (Fortran subprograms---functions and subroutines), Fortran  ``defuns'' (Fortran subprograms---functions and subroutines, as well as
1842  mode provides special commands to move by statements.  modules for F90 mode), Fortran mode provides special commands to move by
1843    statements.
1844    
1845  @table @kbd  @table @kbd
1846  @kindex C-c C-n @r{(Fortran mode)}  @kindex C-c C-n @r{(Fortran mode)}
# Line 1896  but moves backwards. Line 1898  but moves backwards.
1898    Special commands and features are needed for indenting Fortran code in    Special commands and features are needed for indenting Fortran code in
1899  order to make sure various syntactic entities (line numbers, comment line  order to make sure various syntactic entities (line numbers, comment line
1900  indicators and continuation line flags) appear in the columns that are  indicators and continuation line flags) appear in the columns that are
1901  required for standard Fortran.  required for standard, fixed (or tab) format Fortran.
1902    
1903  @menu  @menu
1904  * Commands: ForIndent Commands.  Commands for indenting and filling Fortran.  * Commands: ForIndent Commands.  Commands for indenting and filling Fortran.
# Line 1911  required for standard Fortran. Line 1913  required for standard Fortran.
1913    
1914  @table @kbd  @table @kbd
1915  @item C-M-j  @item C-M-j
1916  Break the current line and set up a continuation line  Break the current line at point and set up a continuation line
1917  (@code{fortran-split-line}).  (@code{fortran-split-line}).
1918  @item M-^  @item M-^
1919  Join this line to the previous line (@code{fortran-join-line}).  Join this line to the previous line (@code{fortran-join-line}).
# Line 1953  point is in.  This removes any excess st Line 1955  point is in.  This removes any excess st
1955  @cindex Fortran continuation lines  @cindex Fortran continuation lines
1956    
1957  @vindex fortran-continuation-string  @vindex fortran-continuation-string
1958    Most modern Fortran compilers allow two ways of writing continuation    Most Fortran77 compilers allow two ways of writing continuation lines.
1959  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
1960  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
1961  @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
1962  variable @code{fortran-continuation-string} specifies what character to  the Fortran standard counts from 1.)  The variable
1963  put on column 5.  A line that starts with a tab character followed by  @code{fortran-continuation-string} specifies what character to put in
1964  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
1965  style of continuation @dfn{tab format}.  except @samp{0} is also a continuation line.  We call this style of
1966    continuation @dfn{tab format}.  (Fortran90 introduced ``free format'',
1967    with another style of continuation lines).
1968    
1969  @vindex indent-tabs-mode @r{(Fortran mode)}  @vindex indent-tabs-mode @r{(Fortran mode)}
1970    Fortran mode can make either style of continuation line, but you  @vindex fortran-analyze-depth
1971  must specify which one you prefer.  The value of the variable  @vindex fortran-tab-mode-default
1972  @code{indent-tabs-mode} controls the choice: @code{nil} for fixed  @vindex fortran-tab-mode-string
1973  format, and non-@code{nil} for tab format.  You can tell which style    Fortran mode can use either style of continuation line.  When you
1974  is presently in effect by the presence or absence of the string  enter Fortran mode, it tries to deduce the proper continuation style
1975  @samp{Tab} in the mode line.  automatically from the buffer contents.  It does this by scanning up to
1976    @code{fortran-analyze-depth} (default 100) lines from the start of the
1977    If the text on a line starts with the conventional Fortran  buffer.  The first line that begins with either a tab character or six
1978  continuation marker @samp{$}, or if it begins with any non-whitespace  spaces determines the choice.  If the scan fails (for example, if the
1979  character in column 5, Fortran mode treats it as a continuation line.  buffer is new and therefore empty), the value of
1980  When you indent a continuation line with @key{TAB}, it converts the line  @code{fortran-tab-mode-default} (@code{nil} for fixed format, and
1981  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
1982  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
1983  according to the continuation style.  by @code{fortran-tab-mode-string} (default @samp{/t}) in the mode line.
1984    
1985    @vindex fortran-continuation-string
1986      If the text on a line starts with the Fortran continuation marker
1987    specified by @code{fortran-continuation-string} (conventionally
1988    @samp{$}), or if it begins with any non-whitespace character in column
1989    5, Fortran mode treats it as a continuation line.  When you indent a
1990    continuation line with @key{TAB}, it converts the line to the current
1991    continuation style.  When you split a Fortran statement with
1992    @kbd{C-M-j}, the continuation marker on the newline is created according
1993    to the continuation style.
1994    
1995    The setting of continuation style affects several other aspects of    The setting of continuation style affects several other aspects of
1996  editing in Fortran mode.  In fixed format mode, the minimum column  editing in Fortran mode.  In fixed format mode, the minimum column
# Line 1986  space character for whitespace.  In tab Line 2000  space character for whitespace.  In tab
2000  column number for the statement body is 8, and the whitespace before  column number for the statement body is 8, and the whitespace before
2001  column 8 must always consist of one tab character.  column 8 must always consist of one tab character.
2002    
 @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.  
   
2003  @node ForIndent Num  @node ForIndent Num
2004  @subsubsection Line Numbers  @subsubsection Line Numbers
2005    
# Line 2007  through 4.  (Columns always count from 0 Line 2010  through 4.  (Columns always count from 0
2010  @vindex fortran-line-number-indent  @vindex fortran-line-number-indent
2011    Line numbers of four digits or less are normally indented one space.    Line numbers of four digits or less are normally indented one space.
2012  The variable @code{fortran-line-number-indent} controls this; it  The variable @code{fortran-line-number-indent} controls this; it
2013  specifies the maximum indentation a line number can have.  Line numbers  specifies the maximum indentation a line number can have.  The default
2014  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
2015  than this maximum indentation.  The default value of the variable is 1.  digits passing column 4, reducing the indentation below the specified
2016    maximum if necessary.  If @code{fortran-line-number-indent} has the
2017    value 5, line numbers are right-justified to end in column 4.
2018    
2019  @vindex fortran-electric-line-number  @vindex fortran-electric-line-number
2020    Simply inserting a line number is enough to indent it according to    Simply inserting a line number is enough to indent it according to
# Line 2063  Extra indentation within each level of @ Line 2068  Extra indentation within each level of @
2068    
2069  @item fortran-if-indent  @item fortran-if-indent
2070  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.  
2071    
2072  @item fortran-structure-indent  @item fortran-structure-indent
2073  Extra indentation within each level of @samp{structure}, @samp{union}, or  Extra indentation within each level of @samp{structure}, @samp{union},
2074  @samp{map} statements (default 3).  @samp{map}, or @samp{interface} statements (default 3).
2075    
2076  @item fortran-continuation-indent  @item fortran-continuation-indent
2077  Extra indentation for bodies of continuation lines (default 5).  Extra indentation for bodies of continuation lines (default 5).
2078    
2079  @item fortran-check-all-num-for-matching-do  @item fortran-check-all-num-for-matching-do
2080  If this is @code{nil}, indentation assumes that each @samp{do} statement  In Fortran77, a numbered @samp{do} statement is ended by any statement
2081  ends on a @samp{continue} statement.  Therefore, when computing  with a matching line number.  It is common (but not compulsory) to use a
2082  indentation for a statement other than @samp{continue}, it can save time  @samp{continue} statement for this purpose.  If this variable has a
2083  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
2084  non-@code{nil}, indenting any numbered statement must check for a  @samp{do} that ends there.  If you always end @samp{do} statements with
2085  @samp{do} that ends there.  The default is @code{nil}.  a @samp{continue} line (or if you use the more modern @samp{enddo}),
2086    then you can speed up indentation by setting this variable to
2087    @code{nil}.  The default is @code{nil}.
2088    
2089  @item fortran-blink-matching-if  @item fortran-blink-matching-if
2090  If this is @code{t}, indenting an @samp{endif} statement moves the  If this is @code{t}, indenting an @samp{endif} (or @samp{enddo}
2091  cursor momentarily to the matching @samp{if} statement to show where it  statement moves the cursor momentarily to the matching @samp{if} (or
2092  is.  The default is @code{nil}.  @samp{do}) statement to show where it is.  The default is @code{nil}.
2093    
2094  @item fortran-minimum-statement-indent-fixed  @item fortran-minimum-statement-indent-fixed
2095  Minimum indentation for fortran statements when using fixed format  Minimum indentation for Fortran statements when using fixed format
2096  continuation line style.  Statement bodies are never indented less than  continuation line style.  Statement bodies are never indented less than
2097  this much.  The default is 6.  this much.  The default is 6.
2098    
2099  @item fortran-minimum-statement-indent-tab  @item fortran-minimum-statement-indent-tab
2100  Minimum indentation for fortran statements for tab format continuation line  Minimum indentation for Fortran statements for tab format continuation line
2101  style.  Statement bodies are never indented less than this much.  The  style.  Statement bodies are never indented less than this much.  The
2102  default is 8.  default is 8.
2103  @end table  @end table
2104    
2105    The variables controlling the indentation of comments are described in
2106    a separate section (@pxref{Fortran Comments}).
2107    
2108    
2109  @node Fortran Comments  @node Fortran Comments
2110  @subsection Fortran Comments  @subsection Fortran Comments
2111    
2112    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
2113  of code.  In Fortran, the standard comment syntax requires an entire line  line of code.  In Fortran77, the standard comment syntax requires an
2114  to be just a comment.  Therefore, Fortran mode replaces the standard Emacs  entire line to be just a comment.  Therefore, Fortran mode replaces the
2115  comment commands and defines some new variables.  standard Emacs comment commands and defines some new variables.
2116    
2117    @vindex fortran-comment-line-start
2118    Fortran mode can also handle the Fortran90 comment syntax where comments    Fortran mode can also handle the Fortran90 comment syntax where comments
2119  start with @samp{!} and can follow other text.  Because only some Fortran77  start with @samp{!} and can follow other text.  Because only some Fortran77
2120  compilers accept this syntax, Fortran mode will not insert such comments  compilers accept this syntax, Fortran mode will not insert such comments
2121  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
2122  @code{comment-start} to @samp{"!"} (@pxref{Variables}).  @code{fortran-comment-line-start} to @samp{"!"}.
2123    
2124  @table @kbd  @table @kbd
2125  @item M-;  @item M-;
# Line 2123  Turn all lines of the region into commen Line 2133  Turn all lines of the region into commen
2133  into real code (@code{fortran-comment-region}).  into real code (@code{fortran-comment-region}).
2134  @end table  @end table
2135    
2136    @findex fortran-indent-comment
2137    @kbd{M-;} in Fortran mode is redefined as the command    @kbd{M-;} in Fortran mode is redefined as the command
2138  @code{fortran-indent-comment}.  Like the usual @kbd{M-;} command, this  @code{fortran-indent-comment}.  Like the usual @kbd{M-;} command, this
2139  recognizes any kind of existing comment and aligns its text appropriately;  recognizes any kind of existing comment and aligns its text appropriately;
# Line 2178  never be indented at all, no matter what Line 2189  never be indented at all, no matter what
2189  lines are directives.  Matching lines are never indented, and receive  lines are directives.  Matching lines are never indented, and receive
2190  distinctive font-locking.  distinctive font-locking.
2191    
 @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.  
   
2192    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
2193  you use @samp{!} comments, this command can be used with them.  Otherwise  you use @samp{!} comments, this command can be used with them.  Otherwise
2194  it is useless in Fortran mode.  it is useless in Fortran mode.
# Line 2204  of the name never conflict because in Li Line 2207  of the name never conflict because in Li
2207  clear from the context which one is meant.  clear from the context which one is meant.
2208    
2209  @node Fortran Autofill  @node Fortran Autofill
2210  @subsection Fortran Auto Fill Mode  @subsection Auto Fill in Fortran Mode
2211    
2212    Fortran Auto Fill mode is a minor mode which automatically splits    Fortran mode has specialized support for Auto Fill mode, which is a
2213  Fortran statements as you insert them when they become too wide.  minor mode that automatically splits statements as you insert them when
2214  Splitting a statement involves making continuation lines using  they become too wide.  Splitting a statement involves making
2215  @code{fortran-continuation-string} (@pxref{ForIndent Cont}).  This  continuation lines using @code{fortran-continuation-string}
2216  splitting happens when you type @key{SPC}, @key{RET}, or @key{TAB}, and  (@pxref{ForIndent Cont}).  This splitting happens when you type
2217  also in the Fortran indentation commands.  @key{SPC}, @key{RET}, or @key{TAB}, and also in the Fortran indentation
2218    commands.  You activate Auto Fill in Fortran mode in the normal way
2219  @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.  
2220    
2221  @vindex fortran-break-before-delimiters  @vindex fortran-break-before-delimiters
2222     Fortran Auto Fill mode breaks lines at spaces or delimiters when the     Auto Fill breaks lines at spaces or delimiters when the lines get
2223  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
2224  The delimiters that Fortran Auto Fill mode may break at are @samp{,},  delimiters (besides whitespace) that Auto Fill may break at are
2225  @samp{'}, @samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, and @samp{)}.  @samp{+}, @samp{-}, @samp{/}, @samp{*}, @samp{=}, @samp{<}, @samp{>},
2226  The line break comes after the delimiter if the variable  and @samp{,}.  The line break comes after the delimiter if the variable
2227  @code{fortran-break-before-delimiters} is @code{nil}.  Otherwise (and by  @code{fortran-break-before-delimiters} is @code{nil}.  Otherwise (and by
2228  default), the break comes before the delimiter.  default), the break comes before the delimiter.
2229    
2230    To enable this mode permanently, add a hook function to    To enable Auto Fill in all Fortran buffers, add
2231  @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}.  
2232    
2233  @node Fortran Columns  @node Fortran Columns
2234  @subsection Checking Columns in Fortran  @subsection Checking Columns in Fortran
# Line 2280  display. Line 2277  display.
2277  @findex fortran-window-create-momentarily  @findex fortran-window-create-momentarily
2278    @kbd{C-c C-w} (@code{fortran-window-create-momentarily}) temporarily    @kbd{C-c C-w} (@code{fortran-window-create-momentarily}) temporarily
2279  splits the current window horizontally, making a window 72 columns  splits the current window horizontally, making a window 72 columns
2280  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
2281  restore the normal width.  restore the normal width.
2282    
2283  @kindex C-u C-c C-w @r{(Fortran mode)}  @kindex C-u C-c C-w @r{(Fortran mode)}

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.91

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26