Function: fortran-mode
fortran-mode is an autoloaded, interactive and byte-compiled function
defined in fortran.el.gz.
Signature
(fortran-mode)
Documentation
Major mode for editing Fortran code in fixed format.
For free format code, use f90-mode.
M-x fortran-indent-line (fortran-indent-line) indents the current Fortran line correctly.
Note that DO statements must not share a common CONTINUE.
Type ;? or ;<f1> (help-command) to display a list of built-in abbrevs for Fortran keywords.
Key definitions:
0 fortran-electric-line-number(var)/fortran-electric-line-number(fun)
1 fortran-electric-line-number(var)/fortran-electric-line-number(fun)
2 fortran-electric-line-number(var)/fortran-electric-line-number(fun)
3 fortran-electric-line-number(var)/fortran-electric-line-number(fun)
4 fortran-electric-line-number(var)/fortran-electric-line-number(fun)
5 fortran-electric-line-number(var)/fortran-electric-line-number(fun)
6 fortran-electric-line-number(var)/fortran-electric-line-number(fun)
7 fortran-electric-line-number(var)/fortran-electric-line-number(fun)
8 fortran-electric-line-number(var)/fortran-electric-line-number(fun)
9 fortran-electric-line-number(var)/fortran-electric-line-number(fun)
; fortran-abbrev-start
C-M-j fortran-split-line
C-M-n fortran-end-of-block
C-M-p fortran-beginning-of-block
C-M-q fortran-indent-subprogram
C-c ; fortran-comment-region(var)/fortran-comment-region(fun)
C-c C-d fortran-join-line
C-c C-n fortran-next-statement
C-c C-p fortran-previous-statement
C-c C-r fortran-column-ruler
C-c C-w fortran-window-create-momentarily
M-^ fortran-join-line
Variables controlling indentation style and extra features:
fortran-comment-line-start
To use comments starting with !, set this to the string "!".
fortran-do-indent
Extra indentation within DO blocks (default 3).
fortran-if-indent
Extra indentation within IF blocks (default 3).
fortran-structure-indent
Extra indentation within STRUCTURE, UNION, MAP and INTERFACE blocks.
(default 3)
fortran-continuation-indent
Extra indentation applied to continuation statements (default 5).
fortran-comment-line-extra-indent
Amount of extra indentation for text in full-line comments (default 0).
fortran-comment-indent-style
How to indent the text in full-line comments. Allowed values are:
nil don't change the indentation
fixed indent to fortran-comment-line-extra-indent beyond the
value of either
fortran-minimum-statement-indent-fixed (fixed format) or
fortran-minimum-statement-indent-tab (TAB format),
depending on the continuation format in use.
relative indent to fortran-comment-line-extra-indent beyond the
indentation for a line of code.
(default fixed)
fortran-comment-indent-char
Single-character string to be inserted instead of space for
full-line comment indentation (default " ").
fortran-minimum-statement-indent-fixed
Minimum indentation for statements in fixed format mode (default 6).
fortran-minimum-statement-indent-tab
Minimum indentation for statements in TAB format mode (default 9).
fortran-line-number-indent
Maximum indentation for line numbers (default 1). A line number will
get less than this much indentation if necessary to avoid reaching
column 5.
fortran-check-all-num-for-matching-do
Non-nil causes all numbered lines to be treated as possible "continue"
statements (default nil).
fortran-blink-matching-if(var)/fortran-blink-matching-if(fun)
Non-nil causes M-x fortran-indent-line (fortran-indent-line) on an ENDIF (or ENDDO) statement
to blink on the matching IF (or DO [WHILE]). (default nil)
fortran-continuation-string
Single-character string to be inserted in column 5 of a continuation
line (default "$").
fortran-comment-region(var)/fortran-comment-region(fun)
String inserted by M-x fortran-comment-region (fortran-comment-region) at start of each line in
the region (default "c$$$").
fortran-electric-line-number(var)/fortran-electric-line-number(fun)
Non-nil causes line number digits to be moved to the correct column
as typed (default t).
fortran-break-before-delimiters
Non-nil causes lines to be broken before delimiters (default t).
Turning on Fortran mode calls the value of the variable fortran-mode-hook
with no args, if that value is non-nil.
Probably introduced at or before Emacs version 18.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/fortran.el.gz
;;;###autoload
(define-derived-mode fortran-mode prog-mode "Fortran"
"Major mode for editing Fortran code in fixed format.
For free format code, use `f90-mode'.
\\[fortran-indent-line] indents the current Fortran line correctly.
Note that DO statements must not share a common CONTINUE.
Type ;? or ;\\[help-command] to display a list of built-in abbrevs for\
Fortran keywords.
Key definitions:
\\{fortran-mode-map}
Variables controlling indentation style and extra features:
`fortran-comment-line-start'
To use comments starting with `!', set this to the string \"!\".
`fortran-do-indent'
Extra indentation within DO blocks (default 3).
`fortran-if-indent'
Extra indentation within IF blocks (default 3).
`fortran-structure-indent'
Extra indentation within STRUCTURE, UNION, MAP and INTERFACE blocks.
(default 3)
`fortran-continuation-indent'
Extra indentation applied to continuation statements (default 5).
`fortran-comment-line-extra-indent'
Amount of extra indentation for text in full-line comments (default 0).
`fortran-comment-indent-style'
How to indent the text in full-line comments. Allowed values are:
nil don't change the indentation
`fixed' indent to `fortran-comment-line-extra-indent' beyond the
value of either
`fortran-minimum-statement-indent-fixed' (fixed format) or
`fortran-minimum-statement-indent-tab' (TAB format),
depending on the continuation format in use.
`relative' indent to `fortran-comment-line-extra-indent' beyond the
indentation for a line of code.
(default `fixed')
`fortran-comment-indent-char'
Single-character string to be inserted instead of space for
full-line comment indentation (default \" \").
`fortran-minimum-statement-indent-fixed'
Minimum indentation for statements in fixed format mode (default 6).
`fortran-minimum-statement-indent-tab'
Minimum indentation for statements in TAB format mode (default 9).
`fortran-line-number-indent'
Maximum indentation for line numbers (default 1). A line number will
get less than this much indentation if necessary to avoid reaching
column 5.
`fortran-check-all-num-for-matching-do'
Non-nil causes all numbered lines to be treated as possible \"continue\"
statements (default nil).
`fortran-blink-matching-if'
Non-nil causes \\[fortran-indent-line] on an ENDIF (or ENDDO) statement
to blink on the matching IF (or DO [WHILE]). (default nil)
`fortran-continuation-string'
Single-character string to be inserted in column 5 of a continuation
line (default \"$\").
`fortran-comment-region'
String inserted by \\[fortran-comment-region] at start of each line in
the region (default \"c$$$\").
`fortran-electric-line-number'
Non-nil causes line number digits to be moved to the correct column
as typed (default t).
`fortran-break-before-delimiters'
Non-nil causes lines to be broken before delimiters (default t).
Turning on Fortran mode calls the value of the variable `fortran-mode-hook'
with no args, if that value is non-nil."
:group 'fortran
:syntax-table fortran-mode-syntax-table
:abbrev-table fortran-mode-abbrev-table
(setq-local indent-line-function 'fortran-indent-line)
(setq-local indent-region-function
(lambda (start end)
(let (fortran-blink-matching-if ; avoid blinking delay
indent-region-function)
(indent-region start end nil))))
(setq-local require-final-newline mode-require-final-newline)
;; The syntax tables don't understand the column-0 comment-markers.
(setq-local comment-use-syntax nil)
(setq-local comment-padding "$$$")
(setq-local comment-start fortran-comment-line-start)
(setq-local comment-start-skip
;; We can't reuse `fortran-comment-line-start-skip' directly because
;; it contains backrefs whereas we need submatch-1 to end at the
;; beginning of the comment delimiter.
;; (concat "\\(\\)\\(![ \t]*\\|" fortran-comment-line-start-skip "\\)")
"\\(\\)\\(?:^[CcDd*]\\|!\\)\\(?:\\([^ \t\n]\\)\\2+\\)?[ \t]*")
(setq-local comment-indent-function 'fortran-comment-indent)
(setq-local comment-region-function 'fortran-comment-region)
(setq-local uncomment-region-function 'fortran-uncomment-region)
(setq-local comment-insert-comment-function 'fortran-indent-comment)
(setq-local abbrev-all-caps t)
(setq-local normal-auto-fill-function 'fortran-auto-fill)
(setq-local indent-tabs-mode (fortran-analyze-file-format))
(setq mode-line-process '(indent-tabs-mode fortran-tab-mode-string))
(setq-local fill-column fortran-line-length)
(setq-local fill-paragraph-function 'fortran-fill-paragraph)
(setq-local font-lock-defaults
'((fortran-font-lock-keywords
fortran-font-lock-keywords-1
fortran-font-lock-keywords-2
fortran-font-lock-keywords-3
fortran-font-lock-keywords-4)
nil t ((?/ . "$/") ("_$" . "w"))
fortran-beginning-of-subprogram))
(setq-local syntax-propertize-function
(fortran-make-syntax-propertize-function fortran-line-length))
(setq-local imenu-case-fold-search t)
(setq-local imenu-generic-expression fortran-imenu-generic-expression)
(setq-local imenu-syntax-alist '(("_$" . "w")))
(setq-local beginning-of-defun-function
#'fortran-beginning-of-subprogram)
(setq-local end-of-defun-function
#'fortran-end-of-subprogram)
(setq-local add-log-current-defun-function
#'fortran-current-defun)
(setq-local dabbrev-case-fold-search 'case-fold-search)
(setq-local gud-find-expr-function 'fortran-gud-find-expr)
(add-hook 'hack-local-variables-hook 'fortran-hack-local-variables nil t))