Mercurial > emacs
annotate lisp/progmodes/fortran.el @ 10182:b80150d748d1
(indent-c-exp): Don't be fooled by else_ or while_.
(c-indent-line): Likewise.
(c-backward-to-start-of-if): Don't be fooled by if_ or else_.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 17 Dec 1994 00:40:24 +0000 |
parents | 59901c9aa208 |
children | b2d6d69b7707 |
rev | line source |
---|---|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
1 ;;; fortran.el --- Fortran mode for GNU Emacs |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
2 |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
3 ;;; Copyright (c) 1986, 1993, 1994 Free Software Foundation, Inc. |
845 | 4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
5 ;; Author: Michael D. Prange <prange@erl.mit.edu> |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
6 ;; Maintainer: bug-fortran-mode@erl.mit.edu |
7692
ce33fcd2ce22
(fortran-link-matching-do): Ignore DO statements with line numbers.
Richard M. Stallman <rms@gnu.org>
parents:
6731
diff
changeset
|
7 ;; Version 1.30.5 (May 20, 1994) |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
8 ;; Keywords: languages |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
9 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
11 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
15 ;; any later version. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
16 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
20 ;; GNU General Public License for more details. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
21 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
25 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
26 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
27 |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
28 ;; Fortran mode has been upgraded and is now maintained by Stephen A. Wood |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
29 ;; (saw@cebaf.gov). It now will use either fixed format continuation line |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
30 ;; markers (character in 6th column), or tab format continuation line style |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
31 ;; (digit after a TAB character.) A auto-fill mode has been added to |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
32 ;; automatically wrap fortran lines that get too long. |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
33 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
34 ;; We acknowledge many contributions and valuable suggestions by |
1548 | 35 ;; Lawrence R. Dodd, Ralf Fassel, Ralph Finch, Stephen Gildea, |
36 ;; Dr. Anil Gokhale, Ulrich Mueller, Mark Neale, Eric Prestemon, | |
37 ;; Gary Sabot and Richard Stallman. | |
38 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
39 ;;; This file may be used with GNU Emacs version 18.xx if the following |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
40 ;;; variable and function substitutions are made. |
1862
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
41 ;;; Replace: |
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
42 ;;; frame-width with screen-width |
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
43 ;;; auto-fill-function with auto-fill-hook |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
44 ;;; comment-indent-function with comment-indent-hook |
1862
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
45 ;;; (setq unread-command-events (list c)) with (setq unread-command-char c) |
332 | 46 |
47 ;;; Bugs to bug-fortran-mode@erl.mit.edu | |
48 | |
7692
ce33fcd2ce22
(fortran-link-matching-do): Ignore DO statements with line numbers.
Richard M. Stallman <rms@gnu.org>
parents:
6731
diff
changeset
|
49 (defconst fortran-mode-version "version 1.30.5") |
1548 | 50 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
51 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
52 |
332 | 53 ;;;###autoload |
54 (defvar fortran-tab-mode-default nil | |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
55 "*Default tabbing/carriage control style for empty files in Fortran mode. |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
56 A value of t specifies tab-digit style of continuation control. |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
57 A value of nil specifies that continuation lines are marked |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
58 with a character in column 6.") |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
59 |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
60 ;; Buffer local, used to display mode line. |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
61 (defvar fortran-tab-mode-string nil |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
62 "String to appear in mode line when TAB format mode is on.") |
332 | 63 |
64 (defvar fortran-do-indent 3 | |
1548 | 65 "*Extra indentation applied to DO blocks.") |
332 | 66 |
67 (defvar fortran-if-indent 3 | |
1548 | 68 "*Extra indentation applied to IF blocks.") |
69 | |
70 (defvar fortran-structure-indent 3 | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
71 "*Extra indentation applied to STRUCTURE, UNION, MAP and INTERFACE blocks.") |
332 | 72 |
73 (defvar fortran-continuation-indent 5 | |
1548 | 74 "*Extra indentation applied to Fortran continuation lines.") |
332 | 75 |
76 (defvar fortran-comment-indent-style 'fixed | |
77 "*nil forces comment lines not to be touched, | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
78 'fixed makes fixed comment indentation to `fortran-comment-line-extra-indent' |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
79 columns beyond `fortran-minimum-statement-indent-fixed' (for |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
80 `indent-tabs-mode' of nil) or `fortran-minimum-statement-indent-tab' (for |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
81 `indent-tabs-mode' of t), and 'relative indents to current |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
82 Fortran indentation plus `fortran-comment-line-extra-indent'.") |
332 | 83 |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
84 (defvar fortran-comment-line-extra-indent 0 |
1548 | 85 "*Amount of extra indentation for text within full-line comments.") |
332 | 86 |
87 (defvar comment-line-start nil | |
88 "*Delimiter inserted to start new full-line comment.") | |
89 | |
90 (defvar comment-line-start-skip nil | |
91 "*Regexp to match the start of a full-line comment.") | |
92 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
93 (defvar fortran-minimum-statement-indent-fixed 6 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
94 "*Minimum statement indentation for fixed format continuation style.") |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
95 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
96 (defvar fortran-minimum-statement-indent-tab (max tab-width 6) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
97 "*Minimum statement indentation for TAB format continuation style.") |
332 | 98 |
99 ;; Note that this is documented in the v18 manuals as being a string | |
100 ;; of length one rather than a single character. | |
101 ;; The code in this file accepts either format for compatibility. | |
102 (defvar fortran-comment-indent-char " " | |
103 "*Single-character string inserted for Fortran comment indentation. | |
104 Normally a space.") | |
105 | |
106 (defvar fortran-line-number-indent 1 | |
107 "*Maximum indentation for Fortran line numbers. | |
108 5 means right-justify them within their five-column field.") | |
109 | |
110 (defvar fortran-check-all-num-for-matching-do nil | |
1548 | 111 "*Non-nil causes all numbered lines to be treated as possible DO loop ends.") |
332 | 112 |
113 (defvar fortran-blink-matching-if nil | |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
114 "*From a Fortran ENDIF statement, blink the matching IF statement. |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
115 Also, from an ENDDO statement, blink on matching DO [WHILE] statement.") |
332 | 116 |
117 (defvar fortran-continuation-string "$" | |
1548 | 118 "*Single-character string used for Fortran continuation lines. |
332 | 119 In fixed format continuation style, this character is inserted in |
120 column 6 by \\[fortran-split-line] to begin a continuation line. | |
121 Also, if \\[fortran-indent-line] finds this at the beginning of a line, it will | |
122 convert the line into a continuation line of the appropriate style. | |
123 Normally $.") | |
124 | |
125 (defvar fortran-comment-region "c$$$" | |
126 "*String inserted by \\[fortran-comment-region]\ | |
127 at start of each line in region.") | |
128 | |
129 (defvar fortran-electric-line-number t | |
130 "*Non-nil causes line number digits to be moved to the correct column as\ | |
131 typed.") | |
132 | |
133 (defvar fortran-startup-message t | |
134 "*Non-nil displays a startup message when Fortran mode is first called.") | |
135 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
136 (defvar fortran-column-ruler-fixed |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
137 "0 4 6 10 20 30 40 5\ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
138 0 60 70\n\ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
139 [ ]|{ | | | | | | | | \ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
140 | | | | |}\n" |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
141 "*String displayed above current line by \\[fortran-column-ruler]. |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
142 This variable used in fixed format mode.") |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
143 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
144 (defvar fortran-column-ruler-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
145 "0 810 20 30 40 5\ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
146 0 60 70\n\ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
147 [ ]| { | | | | | | | | \ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
148 | | | | |}\n" |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
149 "*String displayed above current line by \\[fortran-column-ruler]. |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
150 This variable used in TAB format mode.") |
332 | 151 |
152 (defconst bug-fortran-mode "bug-fortran-mode@erl.mit.edu" | |
153 "Address of mailing list for Fortran mode bugs.") | |
154 | |
155 (defvar fortran-mode-syntax-table nil | |
156 "Syntax table in use in Fortran mode buffers.") | |
157 | |
158 (defvar fortran-analyze-depth 100 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
159 "Number of lines to scan to determine whether to use fixed or TAB format\ |
332 | 160 style.") |
161 | |
1548 | 162 (defvar fortran-break-before-delimiters t |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
163 "*Non-nil causes `fortran-do-auto-fill' to break lines before delimiters.") |
1548 | 164 |
332 | 165 (if fortran-mode-syntax-table |
166 () | |
167 (setq fortran-mode-syntax-table (make-syntax-table)) | |
168 (modify-syntax-entry ?\; "w" fortran-mode-syntax-table) | |
169 (modify-syntax-entry ?\r " " fortran-mode-syntax-table) | |
170 (modify-syntax-entry ?+ "." fortran-mode-syntax-table) | |
171 (modify-syntax-entry ?- "." fortran-mode-syntax-table) | |
172 (modify-syntax-entry ?= "." fortran-mode-syntax-table) | |
173 (modify-syntax-entry ?* "." fortran-mode-syntax-table) | |
174 (modify-syntax-entry ?/ "." fortran-mode-syntax-table) | |
175 (modify-syntax-entry ?\' "\"" fortran-mode-syntax-table) | |
176 (modify-syntax-entry ?\" "\"" fortran-mode-syntax-table) | |
177 (modify-syntax-entry ?\\ "/" fortran-mode-syntax-table) | |
178 (modify-syntax-entry ?. "w" fortran-mode-syntax-table) | |
1548 | 179 (modify-syntax-entry ?_ "w" fortran-mode-syntax-table) |
9476
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
180 (modify-syntax-entry ?\! "<" fortran-mode-syntax-table) |
332 | 181 (modify-syntax-entry ?\n ">" fortran-mode-syntax-table)) |
182 | |
9476
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
183 ;; Comments are real pain in Fortran because there is no way to represent the |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
184 ;; standard comment syntax in an Emacs syntax table (we can for VAX-style). |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
185 ;; Therefore an unmatched quote in a standard comment will throw fontification |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
186 ;; off on the wrong track. But to make it clear(er) to the programmer what is |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
187 ;; happening, we don't override string fontification when fontifying, by the |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
188 ;; keyword regexp, a standard comment. |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
189 |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
190 (defconst fortran-font-lock-keywords-1 |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
191 '(;; Fontify comments. |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
192 ; ("^[Cc*].*$" 0 font-lock-comment-face t) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
193 ("^[Cc*].*$" . font-lock-comment-face) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
194 ;; Program, subroutine and function declarations, plus calls. |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
195 ("\\<\\(call\\|function\\|program\\|subroutine\\)\\>[ \t]*\\(\\sw+\\)?" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
196 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
197 "For consideration as a value of `fortran-font-lock-keywords'. |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
198 This does fairly subdued highlighting.") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
199 |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
200 (defconst fortran-font-lock-keywords-2 |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
201 (append fortran-font-lock-keywords-1 |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
202 (let ((type-types |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
203 ; ("integer" "logical" "real" "complex" "dimension" "double" "map" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
204 ; "precision" "character" "parameter" "common" "save" "external" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
205 ; "implicit" "intrinsic" "data" "equivalence" "structure" "union") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
206 (concat "c\\(haracter\\|om\\(mon\\|plex\\)\\)\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
207 "d\\(ata\\|imension\\|ouble\\)\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
208 "e\\(quivalence\\|xternal\\)\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
209 "i\\(mplicit\\|nt\\(eger\\|rinsic\\)\\)\\|logical\\|map\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
210 "p\\(arameter\\|recision\\)\\|re\\(al\\|cord\\)\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
211 "s\\(ave\\|tructure\\)\\|union")) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
212 (fkeywords |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
213 ; ("continue" "format" "end" "enddo" "if" "then" "else" "endif" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
214 ; "elseif" "while" "inquire" "stop" "return" "include" "open" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
215 ; "close" "read" "write" "format" "print") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
216 (concat "c\\(lose\\|ontinue\\)\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
217 "e\\(lse\\(\\|if\\)\\|nd\\(\\|do\\|if\\)\\)\\|format\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
218 "i\\(f\\|n\\(clude\\|quire\\)\\)\\|open\\|print\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
219 "re\\(ad\\|turn\\)\\|stop\\|then\\|w\\(hile\\|rite\\)")) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
220 (flogicals |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
221 ; ("and" "or" "not" "lt" "le" "eq" "ge" "gt" "ne" "true" "false") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
222 "and\\|eq\\|false\\|g[et]\\|l[et]\\|n\\(e\\|ot\\)\\|or\\|true")) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
223 (list |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
224 ;; |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
225 ;; Fontify types and variable names (but not length specs or `/'s). |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
226 (list (concat "\\<\\(" type-types "\\)\\>[0-9 \t/*]*\\(\\sw+\\)?") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
227 '(1 font-lock-type-face) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
228 '(11 font-lock-variable-name-face nil t)) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
229 ;; |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
230 ;; Fontify all builtin keywords (except logical, do and goto; see below). |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
231 (concat "\\<\\(" fkeywords "\\)\\>") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
232 ;; |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
233 ;; Fontify all builtin operators. |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
234 (concat "\\.\\(" flogicals "\\)\\.") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
235 ;; |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
236 ;; Fontify do/goto keywords and targets, and goto tags. |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
237 (list "\\<\\(do\\|go[ \t]*to\\)\\>[ \t]*\\([0-9]+\\)?" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
238 '(1 font-lock-keyword-face) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
239 '(2 font-lock-reference-face nil t)) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
240 (cons "^[ \t]*\\([0-9]+\\)" 'font-lock-reference-face)))) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
241 "For consideration as a value of `fortran-font-lock-keywords'. |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
242 This does a lot more highlighting.") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
243 |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
244 (defconst fortran-font-lock-keywords fortran-font-lock-keywords-1 |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
245 "Additional expressions to highlight in Fortran mode.") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
246 |
332 | 247 (defvar fortran-mode-map () |
1548 | 248 "Keymap used in Fortran mode.") |
332 | 249 (if fortran-mode-map |
250 () | |
251 (setq fortran-mode-map (make-sparse-keymap)) | |
252 (define-key fortran-mode-map ";" 'fortran-abbrev-start) | |
253 (define-key fortran-mode-map "\C-c;" 'fortran-comment-region) | |
254 (define-key fortran-mode-map "\e\C-a" 'beginning-of-fortran-subprogram) | |
255 (define-key fortran-mode-map "\e\C-e" 'end-of-fortran-subprogram) | |
256 (define-key fortran-mode-map "\e;" 'fortran-indent-comment) | |
257 (define-key fortran-mode-map "\e\C-h" 'mark-fortran-subprogram) | |
258 (define-key fortran-mode-map "\e\n" 'fortran-split-line) | |
3567
2ca5f216e445
(fortran-indent-new-line): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
3400
diff
changeset
|
259 (define-key fortran-mode-map "\n" 'fortran-indent-new-line) |
332 | 260 (define-key fortran-mode-map "\e\C-q" 'fortran-indent-subprogram) |
261 (define-key fortran-mode-map "\C-c\C-w" 'fortran-window-create-momentarily) | |
262 (define-key fortran-mode-map "\C-c\C-r" 'fortran-column-ruler) | |
263 (define-key fortran-mode-map "\C-c\C-p" 'fortran-previous-statement) | |
264 (define-key fortran-mode-map "\C-c\C-n" 'fortran-next-statement) | |
265 (define-key fortran-mode-map "\t" 'fortran-indent-line) | |
266 (define-key fortran-mode-map "0" 'fortran-electric-line-number) | |
267 (define-key fortran-mode-map "1" 'fortran-electric-line-number) | |
268 (define-key fortran-mode-map "2" 'fortran-electric-line-number) | |
269 (define-key fortran-mode-map "3" 'fortran-electric-line-number) | |
270 (define-key fortran-mode-map "4" 'fortran-electric-line-number) | |
271 (define-key fortran-mode-map "5" 'fortran-electric-line-number) | |
272 (define-key fortran-mode-map "6" 'fortran-electric-line-number) | |
273 (define-key fortran-mode-map "7" 'fortran-electric-line-number) | |
274 (define-key fortran-mode-map "8" 'fortran-electric-line-number) | |
275 (define-key fortran-mode-map "9" 'fortran-electric-line-number)) | |
276 | |
277 (defvar fortran-mode-abbrev-table nil) | |
278 (if fortran-mode-abbrev-table | |
279 () | |
280 (let ((ac abbrevs-changed)) | |
281 (define-abbrev-table 'fortran-mode-abbrev-table ()) | |
282 (define-abbrev fortran-mode-abbrev-table ";au" "automatic" nil) | |
283 (define-abbrev fortran-mode-abbrev-table ";b" "byte" nil) | |
1548 | 284 (define-abbrev fortran-mode-abbrev-table ";bd" "block data" nil) |
332 | 285 (define-abbrev fortran-mode-abbrev-table ";ch" "character" nil) |
286 (define-abbrev fortran-mode-abbrev-table ";cl" "close" nil) | |
287 (define-abbrev fortran-mode-abbrev-table ";c" "continue" nil) | |
288 (define-abbrev fortran-mode-abbrev-table ";cm" "common" nil) | |
289 (define-abbrev fortran-mode-abbrev-table ";cx" "complex" nil) | |
290 (define-abbrev fortran-mode-abbrev-table ";df" "define" nil) | |
291 (define-abbrev fortran-mode-abbrev-table ";di" "dimension" nil) | |
292 (define-abbrev fortran-mode-abbrev-table ";do" "double" nil) | |
293 (define-abbrev fortran-mode-abbrev-table ";dc" "double complex" nil) | |
294 (define-abbrev fortran-mode-abbrev-table ";dp" "double precision" nil) | |
295 (define-abbrev fortran-mode-abbrev-table ";dw" "do while" nil) | |
296 (define-abbrev fortran-mode-abbrev-table ";e" "else" nil) | |
297 (define-abbrev fortran-mode-abbrev-table ";ed" "enddo" nil) | |
298 (define-abbrev fortran-mode-abbrev-table ";el" "elseif" nil) | |
299 (define-abbrev fortran-mode-abbrev-table ";en" "endif" nil) | |
300 (define-abbrev fortran-mode-abbrev-table ";eq" "equivalence" nil) | |
1548 | 301 (define-abbrev fortran-mode-abbrev-table ";ew" "endwhere" nil) |
332 | 302 (define-abbrev fortran-mode-abbrev-table ";ex" "external" nil) |
303 (define-abbrev fortran-mode-abbrev-table ";ey" "entry" nil) | |
304 (define-abbrev fortran-mode-abbrev-table ";f" "format" nil) | |
305 (define-abbrev fortran-mode-abbrev-table ";fa" ".false." nil) | |
306 (define-abbrev fortran-mode-abbrev-table ";fu" "function" nil) | |
307 (define-abbrev fortran-mode-abbrev-table ";g" "goto" nil) | |
308 (define-abbrev fortran-mode-abbrev-table ";im" "implicit" nil) | |
309 (define-abbrev fortran-mode-abbrev-table ";ib" "implicit byte" nil) | |
310 (define-abbrev fortran-mode-abbrev-table ";ic" "implicit complex" nil) | |
311 (define-abbrev fortran-mode-abbrev-table ";ich" "implicit character" nil) | |
312 (define-abbrev fortran-mode-abbrev-table ";ii" "implicit integer" nil) | |
313 (define-abbrev fortran-mode-abbrev-table ";il" "implicit logical" nil) | |
314 (define-abbrev fortran-mode-abbrev-table ";ir" "implicit real" nil) | |
315 (define-abbrev fortran-mode-abbrev-table ";inc" "include" nil) | |
316 (define-abbrev fortran-mode-abbrev-table ";in" "integer" nil) | |
317 (define-abbrev fortran-mode-abbrev-table ";intr" "intrinsic" nil) | |
318 (define-abbrev fortran-mode-abbrev-table ";l" "logical" nil) | |
319 (define-abbrev fortran-mode-abbrev-table ";n" "namelist" nil) | |
320 (define-abbrev fortran-mode-abbrev-table ";o" "open" nil) ; was ;op | |
321 (define-abbrev fortran-mode-abbrev-table ";pa" "parameter" nil) | |
322 (define-abbrev fortran-mode-abbrev-table ";pr" "program" nil) | |
323 (define-abbrev fortran-mode-abbrev-table ";ps" "pause" nil) | |
324 (define-abbrev fortran-mode-abbrev-table ";p" "print" nil) | |
325 (define-abbrev fortran-mode-abbrev-table ";rc" "record" nil) | |
326 (define-abbrev fortran-mode-abbrev-table ";re" "real" nil) | |
327 (define-abbrev fortran-mode-abbrev-table ";r" "read" nil) | |
328 (define-abbrev fortran-mode-abbrev-table ";rt" "return" nil) | |
329 (define-abbrev fortran-mode-abbrev-table ";rw" "rewind" nil) | |
330 (define-abbrev fortran-mode-abbrev-table ";s" "stop" nil) | |
331 (define-abbrev fortran-mode-abbrev-table ";sa" "save" nil) | |
332 (define-abbrev fortran-mode-abbrev-table ";st" "structure" nil) | |
333 (define-abbrev fortran-mode-abbrev-table ";sc" "static" nil) | |
334 (define-abbrev fortran-mode-abbrev-table ";su" "subroutine" nil) | |
335 (define-abbrev fortran-mode-abbrev-table ";tr" ".true." nil) | |
336 (define-abbrev fortran-mode-abbrev-table ";ty" "type" nil) | |
337 (define-abbrev fortran-mode-abbrev-table ";vo" "volatile" nil) | |
338 (define-abbrev fortran-mode-abbrev-table ";w" "write" nil) | |
1548 | 339 (define-abbrev fortran-mode-abbrev-table ";wh" "where" nil) |
332 | 340 (setq abbrevs-changed ac))) |
341 | |
342 ;;;###autoload | |
343 (defun fortran-mode () | |
1548 | 344 "Major mode for editing Fortran code. |
345 \\[fortran-indent-line] indents the current Fortran line correctly. | |
346 DO statements must not share a common CONTINUE. | |
332 | 347 |
1548 | 348 Type ;? or ;\\[help-command] to display a list of built-in\ |
332 | 349 abbrevs for Fortran keywords. |
350 | |
351 Key definitions: | |
352 \\{fortran-mode-map} | |
353 | |
354 Variables controlling indentation style and extra features: | |
355 | |
356 comment-start | |
357 Normally nil in Fortran mode. If you want to use comments | |
358 starting with `!', set this to the string \"!\". | |
359 fortran-do-indent | |
360 Extra indentation within do blocks. (default 3) | |
361 fortran-if-indent | |
362 Extra indentation within if blocks. (default 3) | |
1548 | 363 fortran-structure-indent |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
364 Extra indentation within structure, union, map and interface blocks. |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
365 (default 3) |
332 | 366 fortran-continuation-indent |
1548 | 367 Extra indentation applied to continuation statements. (default 5) |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
368 fortran-comment-line-extra-indent |
1548 | 369 Amount of extra indentation for text within full-line comments. (default 0) |
332 | 370 fortran-comment-indent-style |
371 nil means don't change indentation of text in full-line comments, | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
372 fixed means indent that text at `fortran-comment-line-extra-indent' beyond |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
373 the value of `fortran-minimum-statement-indent-fixed' (for fixed |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
374 format continuation style) or `fortran-minimum-statement-indent-tab' |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
375 (for TAB format continuation style). |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
376 relative means indent at `fortran-comment-line-extra-indent' beyond the |
332 | 377 indentation for a line of code. |
378 (default 'fixed) | |
379 fortran-comment-indent-char | |
1548 | 380 Single-character string to be inserted instead of space for |
332 | 381 full-line comment indentation. (default \" \") |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
382 fortran-minimum-statement-indent-fixed |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
383 Minimum indentation for Fortran statements in fixed format mode. (def.6) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
384 fortran-minimum-statement-indent-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
385 Minimum indentation for Fortran statements in TAB format mode. (default 9) |
332 | 386 fortran-line-number-indent |
387 Maximum indentation for line numbers. A line number will get | |
388 less than this much indentation if necessary to avoid reaching | |
389 column 5. (default 1) | |
390 fortran-check-all-num-for-matching-do | |
1548 | 391 Non-nil causes all numbered lines to be treated as possible \"continue\" |
332 | 392 statements. (default nil) |
393 fortran-blink-matching-if | |
1548 | 394 From a Fortran ENDIF statement, blink the matching IF statement. |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
395 Also, from an ENDDO statement, blink on matching DO [WHILE] statement. |
332 | 396 (default nil) |
397 fortran-continuation-string | |
398 Single-character string to be inserted in column 5 of a continuation | |
399 line. (default \"$\") | |
400 fortran-comment-region | |
401 String inserted by \\[fortran-comment-region] at start of each line in | |
402 region. (default \"c$$$\") | |
403 fortran-electric-line-number | |
404 Non-nil causes line number digits to be moved to the correct column | |
405 as typed. (default t) | |
1548 | 406 fortran-break-before-delimiters |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
407 Non-nil causes `fortran-do-auto-fill' breaks lines before delimiters. |
1548 | 408 (default t) |
332 | 409 fortran-startup-message |
410 Set to nil to inhibit message first time Fortran mode is used. | |
411 | |
1548 | 412 Turning on Fortran mode calls the value of the variable `fortran-mode-hook' |
332 | 413 with no args, if that value is non-nil." |
414 (interactive) | |
415 (kill-all-local-variables) | |
416 (if fortran-startup-message | |
1548 | 417 (message "Emacs Fortran mode %s. Bugs to %s" |
332 | 418 fortran-mode-version bug-fortran-mode)) |
419 (setq fortran-startup-message nil) | |
420 (setq local-abbrev-table fortran-mode-abbrev-table) | |
421 (set-syntax-table fortran-mode-syntax-table) | |
9476
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
422 (make-local-variable 'font-lock-defaults) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
423 (setq font-lock-defaults '(fortran-font-lock-keywords nil t)) |
1548 | 424 (make-local-variable 'fortran-break-before-delimiters) |
425 (setq fortran-break-before-delimiters t) | |
332 | 426 (make-local-variable 'indent-line-function) |
427 (setq indent-line-function 'fortran-indent-line) | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2028
diff
changeset
|
428 (make-local-variable 'comment-indent-function) |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2028
diff
changeset
|
429 (setq comment-indent-function 'fortran-comment-hook) |
332 | 430 (make-local-variable 'comment-line-start-skip) |
431 (setq comment-line-start-skip | |
1548 | 432 "^[Cc*]\\(\\([^ \t\n]\\)\\2\\2*\\)?[ \t]*\\|^#.*") |
332 | 433 (make-local-variable 'comment-line-start) |
434 (setq comment-line-start "c") | |
435 (make-local-variable 'comment-start-skip) | |
436 (setq comment-start-skip "![ \t]*") | |
437 (make-local-variable 'comment-start) | |
438 (setq comment-start nil) | |
439 (make-local-variable 'require-final-newline) | |
440 (setq require-final-newline t) | |
441 (make-local-variable 'abbrev-all-caps) | |
442 (setq abbrev-all-caps t) | |
443 (make-local-variable 'indent-tabs-mode) | |
444 (setq indent-tabs-mode nil) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
445 ;;;(setq abbrev-mode t) ; ?? (abbrev-mode 1) instead?? |
1548 | 446 (setq fill-column 72) ; Already local? |
332 | 447 (use-local-map fortran-mode-map) |
448 (setq mode-name "Fortran") | |
449 (setq major-mode 'fortran-mode) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
450 ;;;(make-local-variable 'fortran-tab-mode) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
451 (make-local-variable 'fortran-comment-line-extra-indent) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
452 (make-local-variable 'fortran-minimum-statement-indent-fixed) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
453 (make-local-variable 'fortran-minimum-statement-indent-tab) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
454 (make-local-variable 'fortran-column-ruler-fixed) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
455 (make-local-variable 'fortran-column-ruler-tab) |
332 | 456 (make-local-variable 'fortran-tab-mode-string) |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
457 (setq fortran-tab-mode-string " TAB-format") |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
458 (setq indent-tabs-mode (fortran-analyze-file-format)) |
332 | 459 (run-hooks 'fortran-mode-hook)) |
460 | |
461 (defun fortran-comment-hook () | |
462 (save-excursion | |
463 (skip-chars-backward " \t") | |
464 (max (+ 1 (current-column)) | |
465 comment-column))) | |
466 | |
467 (defun fortran-indent-comment () | |
468 "Align or create comment on current line. | |
469 Existing comments of all types are recognized and aligned. | |
470 If the line has no comment, a side-by-side comment is inserted and aligned | |
471 if the value of comment-start is not nil. | |
472 Otherwise, a separate-line comment is inserted, on this line | |
473 or on a new line inserted before this line if this line is not blank." | |
474 (interactive) | |
475 (beginning-of-line) | |
476 ;; Recognize existing comments of either kind. | |
477 (cond ((looking-at comment-line-start-skip) | |
478 (fortran-indent-line)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
479 ((fortran-find-comment-start-skip) ; catches any inline comment and |
1548 | 480 ; leaves point after comment-start-skip |
481 (if comment-start-skip | |
482 (progn (goto-char (match-beginning 0)) | |
483 (if (not (= (current-column) (fortran-comment-hook))) | |
484 (progn (delete-horizontal-space) | |
485 (indent-to (fortran-comment-hook))))) | |
486 (end-of-line))) ; otherwise goto end of line or sth else? | |
332 | 487 ;; No existing comment. |
488 ;; If side-by-side comments are defined, insert one, | |
489 ;; unless line is now blank. | |
490 ((and comment-start (not (looking-at "^[ \t]*$"))) | |
491 (end-of-line) | |
492 (delete-horizontal-space) | |
493 (indent-to (fortran-comment-hook)) | |
494 (insert comment-start)) | |
495 ;; Else insert separate-line comment, making a new line if nec. | |
496 (t | |
497 (if (looking-at "^[ \t]*$") | |
498 (delete-horizontal-space) | |
499 (beginning-of-line) | |
500 (insert "\n") | |
501 (forward-char -1)) | |
502 (insert comment-line-start) | |
503 (insert-char (if (stringp fortran-comment-indent-char) | |
504 (aref fortran-comment-indent-char 0) | |
1548 | 505 fortran-comment-indent-char) |
332 | 506 (- (calculate-fortran-indent) (current-column)))))) |
507 | |
508 (defun fortran-comment-region (beg-region end-region arg) | |
509 "Comments every line in the region. | |
510 Puts fortran-comment-region at the beginning of every line in the region. | |
511 BEG-REGION and END-REGION are args which specify the region boundaries. | |
512 With non-nil ARG, uncomments the region." | |
513 (interactive "*r\nP") | |
514 (let ((end-region-mark (make-marker)) (save-point (point-marker))) | |
515 (set-marker end-region-mark end-region) | |
516 (goto-char beg-region) | |
517 (beginning-of-line) | |
518 (if (not arg) ;comment the region | |
519 (progn (insert fortran-comment-region) | |
520 (while (and (= (forward-line 1) 0) | |
521 (< (point) end-region-mark)) | |
522 (insert fortran-comment-region))) | |
523 (let ((com (regexp-quote fortran-comment-region))) ;uncomment the region | |
524 (if (looking-at com) | |
525 (delete-region (point) (match-end 0))) | |
526 (while (and (= (forward-line 1) 0) | |
527 (< (point) end-region-mark)) | |
528 (if (looking-at com) | |
529 (delete-region (point) (match-end 0)))))) | |
530 (goto-char save-point) | |
531 (set-marker end-region-mark nil) | |
532 (set-marker save-point nil))) | |
533 | |
534 (defun fortran-abbrev-start () | |
1548 | 535 "Typing ;\\[help-command] or ;? lists all the Fortran abbrevs. |
332 | 536 Any other key combination is executed normally." |
537 (interactive) | |
538 (let (c) | |
539 (insert last-command-char) | |
2028
87f2d4cbbaf4
(fortran-abbrev-start): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1862
diff
changeset
|
540 (if (or (eq (setq c (read-event)) ??) ;insert char if not equal to `?' |
87f2d4cbbaf4
(fortran-abbrev-start): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1862
diff
changeset
|
541 (eq c help-char)) |
332 | 542 (fortran-abbrev-help) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1633
diff
changeset
|
543 (setq unread-command-events (list c))))) |
332 | 544 |
545 (defun fortran-abbrev-help () | |
546 "List the currently defined abbrevs in Fortran mode." | |
547 (interactive) | |
548 (message "Listing abbrev table...") | |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
549 (display-buffer (fortran-prepare-abbrev-list-buffer)) |
332 | 550 (message "Listing abbrev table...done")) |
551 | |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
552 (defun fortran-prepare-abbrev-list-buffer () |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
553 (save-excursion |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
554 (set-buffer (get-buffer-create "*Abbrevs*")) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
555 (erase-buffer) |
1862
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
556 (insert-abbrev-table-description 'fortran-mode-abbrev-table t) |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
557 (goto-char (point-min)) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
558 (set-buffer-modified-p nil) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
559 (edit-abbrevs-mode)) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
560 (get-buffer-create "*Abbrevs*")) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
561 |
332 | 562 (defun fortran-column-ruler () |
563 "Inserts a column ruler momentarily above current line, till next keystroke. | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
564 The ruler is defined by the value of `fortran-column-ruler-fixed' when in fixed |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
565 format mode, and `fortran-column-ruler-tab' when in TAB format mode. |
332 | 566 The key typed is executed unless it is SPC." |
567 (interactive) | |
568 (momentary-string-display | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
569 (if indent-tabs-mode |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
570 fortran-column-ruler-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
571 fortran-column-ruler-fixed) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
572 (save-excursion |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
573 (beginning-of-line) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
574 (if (eq (window-start (selected-window)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
575 (window-point (selected-window))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
576 (progn (forward-line) (point)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
577 (point))) |
332 | 578 nil "Type SPC or any command to erase ruler.")) |
579 | |
580 (defun fortran-window-create () | |
581 "Makes the window 72 columns wide. | |
1475 | 582 See also `fortran-window-create-momentarily'." |
332 | 583 (interactive) |
584 (condition-case error | |
585 (progn | |
586 (let ((window-min-width 2)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
587 (if (< (window-width) (frame-width)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
588 (enlarge-window-horizontally (- (frame-width) |
332 | 589 (window-width) 1))) |
590 (split-window-horizontally 73) | |
591 (other-window 1) | |
592 (switch-to-buffer " fortran-window-extra" t) | |
593 (select-window (previous-window)))) | |
1548 | 594 (error (message "No room for Fortran window.") |
332 | 595 'error))) |
596 | |
597 (defun fortran-window-create-momentarily (&optional arg) | |
598 "Momentarily makes the window 72 columns wide. | |
599 Optional ARG non-nil and non-unity disables the momentary feature. | |
1475 | 600 See also `fortran-window-create'." |
332 | 601 (interactive "p") |
602 (if (or (not arg) | |
603 (= arg 1)) | |
604 (save-window-excursion | |
605 (if (not (equal (fortran-window-create) 'error)) | |
606 (progn (message "Type SPC to continue editing.") | |
2028
87f2d4cbbaf4
(fortran-abbrev-start): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1862
diff
changeset
|
607 (let ((char (read-event))) |
332 | 608 (or (equal char (string-to-char " ")) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1633
diff
changeset
|
609 (setq unread-command-events (list char))))))) |
332 | 610 (fortran-window-create))) |
611 | |
612 (defun fortran-split-line () | |
613 "Break line at point and insert continuation marker and alignment." | |
614 (interactive) | |
615 (delete-horizontal-space) | |
616 (if (save-excursion (beginning-of-line) (looking-at comment-line-start-skip)) | |
617 (insert "\n" comment-line-start " ") | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
618 (if indent-tabs-mode |
332 | 619 (progn |
620 (insert "\n\t") | |
621 (insert-char (fortran-numerical-continuation-char) 1)) | |
1548 | 622 (insert "\n " fortran-continuation-string)));Space after \n important |
623 (fortran-indent-line)) ;when the cont string is C, c or *. | |
332 | 624 |
625 (defun fortran-numerical-continuation-char () | |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
626 "Return a digit for tab-digit style of continuation lines. |
332 | 627 If, previous line is a tab-digit continuation line, returns that digit |
628 plus one. Otherwise return 1. Zero not allowed." | |
629 (save-excursion | |
630 (forward-line -1) | |
631 (if (looking-at "\t[1-9]") | |
632 (+ ?1 (% (- (char-after (+ (point) 1)) ?0) 9)) | |
633 ?1))) | |
634 | |
635 (defun delete-horizontal-regexp (chars) | |
636 "Delete all characters in CHARS around point. | |
637 CHARS is like the inside of a [...] in a regular expression | |
638 except that ] is never special and \ quotes ^, - or \." | |
639 (interactive "*s") | |
640 (skip-chars-backward chars) | |
641 (delete-region (point) (progn (skip-chars-forward chars) (point)))) | |
642 | |
643 (defun fortran-electric-line-number (arg) | |
644 "Self insert, but if part of a Fortran line number indent it automatically. | |
645 Auto-indent does not happen if a numeric arg is used." | |
646 (interactive "P") | |
647 (if (or arg (not fortran-electric-line-number)) | |
648 (if arg | |
1548 | 649 (self-insert-command (prefix-numeric-value arg)) |
332 | 650 (self-insert-command 1)) |
651 (if (or (and (= 5 (current-column)) | |
652 (save-excursion | |
653 (beginning-of-line) | |
654 (looking-at " ")));In col 5 with only spaces to left. | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
655 (and (= (if indent-tabs-mode |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
656 fortran-minimum-statement-indent-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
657 fortran-minimum-statement-indent-fixed) (current-column)) |
332 | 658 (save-excursion |
659 (beginning-of-line) | |
660 (looking-at "\t"));In col 8 with a single tab to the left. | |
661 (not (or (eq last-command 'fortran-indent-line) | |
662 (eq last-command | |
3567
2ca5f216e445
(fortran-indent-new-line): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
3400
diff
changeset
|
663 'fortran-indent-new-line)))) |
332 | 664 (save-excursion |
665 (re-search-backward "[^ \t0-9]" | |
666 (save-excursion | |
667 (beginning-of-line) | |
668 (point)) | |
669 t)) ;not a line number | |
670 (looking-at "[0-9]") ;within a line number | |
671 ) | |
1548 | 672 (self-insert-command (prefix-numeric-value arg)) |
332 | 673 (skip-chars-backward " \t") |
674 (insert last-command-char) | |
675 (fortran-indent-line)))) | |
676 | |
677 (defun beginning-of-fortran-subprogram () | |
1548 | 678 "Moves point to the beginning of the current Fortran subprogram." |
332 | 679 (interactive) |
680 (let ((case-fold-search t)) | |
681 (beginning-of-line -1) | |
682 (re-search-backward "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]" nil 'move) | |
683 (if (looking-at "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]") | |
684 (forward-line 1)))) | |
685 | |
686 (defun end-of-fortran-subprogram () | |
1548 | 687 "Moves point to the end of the current Fortran subprogram." |
332 | 688 (interactive) |
689 (let ((case-fold-search t)) | |
690 (beginning-of-line 2) | |
691 (re-search-forward "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]" nil 'move) | |
692 (goto-char (match-beginning 0)) | |
693 (forward-line 1))) | |
694 | |
695 (defun mark-fortran-subprogram () | |
1548 | 696 "Put mark at end of Fortran subprogram, point at beginning. |
332 | 697 The marks are pushed." |
698 (interactive) | |
699 (end-of-fortran-subprogram) | |
700 (push-mark (point)) | |
701 (beginning-of-fortran-subprogram)) | |
1548 | 702 |
332 | 703 (defun fortran-previous-statement () |
1548 | 704 "Moves point to beginning of the previous Fortran statement. |
705 Returns `first-statement' if that statement is the first | |
332 | 706 non-comment Fortran statement in the file, and nil otherwise." |
707 (interactive) | |
708 (let (not-first-statement continue-test) | |
709 (beginning-of-line) | |
710 (setq continue-test | |
1548 | 711 (and |
712 (not (looking-at comment-line-start-skip)) | |
713 (or (looking-at | |
332 | 714 (concat "[ \t]*" (regexp-quote fortran-continuation-string))) |
1548 | 715 (or (looking-at " [^ 0\n]") |
716 (looking-at "\t[1-9]"))))) | |
332 | 717 (while (and (setq not-first-statement (= (forward-line -1) 0)) |
718 (or (looking-at comment-line-start-skip) | |
719 (looking-at "[ \t]*$") | |
720 (looking-at " [^ 0\n]") | |
721 (looking-at "\t[1-9]") | |
722 (looking-at (concat "[ \t]*" comment-start-skip))))) | |
723 (cond ((and continue-test | |
724 (not not-first-statement)) | |
725 (message "Incomplete continuation statement.")) | |
726 (continue-test | |
727 (fortran-previous-statement)) | |
728 ((not not-first-statement) | |
729 'first-statement)))) | |
730 | |
731 (defun fortran-next-statement () | |
1548 | 732 "Moves point to beginning of the next Fortran statement. |
332 | 733 Returns `last-statement' if that statement is the last |
734 non-comment Fortran statement in the file, and nil otherwise." | |
735 (interactive) | |
736 (let (not-last-statement) | |
737 (beginning-of-line) | |
1548 | 738 (while (and (setq not-last-statement |
739 (and (= (forward-line 1) 0) | |
740 (not (eobp)))) | |
332 | 741 (or (looking-at comment-line-start-skip) |
742 (looking-at "[ \t]*$") | |
743 (looking-at " [^ 0\n]") | |
744 (looking-at "\t[1-9]") | |
745 (looking-at (concat "[ \t]*" comment-start-skip))))) | |
746 (if (not not-last-statement) | |
747 'last-statement))) | |
748 | |
749 (defun fortran-blink-matching-if () | |
1548 | 750 "From a Fortran ENDIF statement, blink the matching IF statement." |
332 | 751 (let ((count 1) (top-of-window (window-start)) matching-if |
752 (endif-point (point)) message) | |
753 (if (save-excursion (beginning-of-line) | |
754 (skip-chars-forward " \t0-9") | |
755 (looking-at "end[ \t]*if\\b")) | |
756 (progn | |
757 (save-excursion | |
758 (while (and (not (= count 0)) | |
759 (not (eq (fortran-previous-statement) | |
760 'first-statement)) | |
761 (not (looking-at | |
762 "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]"))) | |
763 ; Keep local to subprogram | |
764 (skip-chars-forward " \t0-9") | |
765 (cond ((looking-at "if[ \t]*(") | |
1548 | 766 (save-excursion |
767 (if (or | |
768 (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t(=a-z0-9]") | |
769 (let (then-test);multi-line if-then | |
770 (while | |
771 (and (= (forward-line 1) 0) | |
332 | 772 ;search forward for then |
1548 | 773 (or (looking-at " [^ 0\n]") |
774 (looking-at "\t[1-9]")) | |
775 (not | |
776 (setq | |
777 then-test | |
778 (looking-at | |
779 ".*then\\b[ \t]*[^ \t(=a-z0-9]"))))) | |
780 then-test)) | |
781 (setq count (- count 1))))) | |
332 | 782 ((looking-at "end[ \t]*if\\b") |
783 (setq count (+ count 1))))) | |
784 (if (not (= count 0)) | |
785 (setq message "No matching if.") | |
786 (if (< (point) top-of-window) | |
787 (setq message (concat "Matches " (buffer-substring | |
788 (progn (beginning-of-line) | |
789 (point)) | |
790 (progn (end-of-line) | |
791 (point))))) | |
792 (setq matching-if (point))))) | |
793 (if message | |
1548 | 794 (message "%s" message) |
332 | 795 (goto-char matching-if) |
796 (sit-for 1) | |
797 (goto-char endif-point)))))) | |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
798 |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
799 (defun fortran-blink-matching-do () |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
800 ;; From a Fortran ENDDO statement, blink on the matching DO or DO WHILE |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
801 ;; statement. This is basically copied from fortran-blink-matching-if. |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
802 (let ((count 1) (top-of-window (window-start)) matching-do |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
803 (enddo-point (point)) message) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
804 (if (save-excursion (beginning-of-line) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
805 (skip-chars-forward " \t0-9") |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
806 (looking-at "end[ \t]*do\\b")) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
807 (progn |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
808 (save-excursion |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
809 (while (and (not (= count 0)) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
810 (not (eq (fortran-previous-statement) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
811 'first-statement)) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
812 (not (looking-at |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
813 "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]"))) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
814 ; Keep local to subprogram |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
815 (skip-chars-forward " \t0-9") |
7888
b26a8476561d
(fortran-blink-matching-do): When looking for do,
Richard M. Stallman <rms@gnu.org>
parents:
7692
diff
changeset
|
816 (cond ((looking-at "do[ \t]+[^0-9]") |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
817 (setq count (- count 1))) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
818 ((looking-at "end[ \t]*do\\b") |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
819 (setq count (+ count 1))))) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
820 (if (not (= count 0)) |
7888
b26a8476561d
(fortran-blink-matching-do): When looking for do,
Richard M. Stallman <rms@gnu.org>
parents:
7692
diff
changeset
|
821 (setq message "No matching do") |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
822 (if (< (point) top-of-window) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
823 (setq message (concat "Matches " (buffer-substring |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
824 (progn (beginning-of-line) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
825 (point)) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
826 (progn (end-of-line) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
827 (point))))) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
828 (setq matching-do (point))))) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
829 (if message |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
830 (message "%s" message) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
831 (goto-char matching-do) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
832 (sit-for 1) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
833 (goto-char enddo-point)))))) |
332 | 834 |
835 (defun fortran-indent-line () | |
1548 | 836 "Indents current Fortran line based on its contents and on previous lines." |
332 | 837 (interactive) |
838 (let ((cfi (calculate-fortran-indent))) | |
839 (save-excursion | |
840 (beginning-of-line) | |
841 (if (or (not (= cfi (fortran-current-line-indentation))) | |
842 (and (re-search-forward "^[ \t]*[0-9]+" (+ (point) 4) t) | |
843 (not (fortran-line-number-indented-correctly-p)))) | |
844 (fortran-indent-to-column cfi) | |
845 (beginning-of-line) | |
846 (if (and (not (looking-at comment-line-start-skip)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
847 (fortran-find-comment-start-skip)) |
332 | 848 (fortran-indent-comment)))) |
849 ;; Never leave point in left margin. | |
850 (if (< (current-column) cfi) | |
851 (move-to-column cfi)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
852 (if (and auto-fill-function |
1548 | 853 (> (save-excursion (end-of-line) (current-column)) fill-column)) |
854 (save-excursion | |
855 (end-of-line) | |
856 (fortran-do-auto-fill))) | |
332 | 857 (if fortran-blink-matching-if |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
858 (progn |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
859 (fortran-blink-matching-if) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
860 (fortran-blink-matching-do))))) |
332 | 861 |
3567
2ca5f216e445
(fortran-indent-new-line): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
3400
diff
changeset
|
862 (defun fortran-indent-new-line () |
1548 | 863 "Reindent the current Fortran line, insert a newline and indent the newline. |
864 An abbrev before point is expanded if `abbrev-mode' is non-nil." | |
332 | 865 (interactive) |
866 (if abbrev-mode (expand-abbrev)) | |
867 (save-excursion | |
868 (beginning-of-line) | |
869 (skip-chars-forward " \t") | |
870 (if (or (looking-at "[0-9]") ;Reindent only where it is most | |
871 (looking-at "end") ;likely to be necessary | |
872 (looking-at "else") | |
873 (looking-at (regexp-quote fortran-continuation-string))) | |
874 (fortran-indent-line))) | |
1548 | 875 (newline) |
332 | 876 (fortran-indent-line)) |
1548 | 877 |
332 | 878 (defun fortran-indent-subprogram () |
879 "Properly indents the Fortran subprogram which contains point." | |
880 (interactive) | |
881 (save-excursion | |
882 (mark-fortran-subprogram) | |
883 (message "Indenting subprogram...") | |
884 (indent-region (point) (mark) nil)) | |
885 (message "Indenting subprogram...done.")) | |
886 | |
887 (defun calculate-fortran-indent () | |
1548 | 888 "Calculates the Fortran indent column based on previous lines." |
332 | 889 (let (icol first-statement (case-fold-search t) |
890 (fortran-minimum-statement-indent | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
891 (if indent-tabs-mode |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
892 fortran-minimum-statement-indent-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
893 fortran-minimum-statement-indent-fixed))) |
332 | 894 (save-excursion |
895 (setq first-statement (fortran-previous-statement)) | |
896 (if first-statement | |
897 (setq icol fortran-minimum-statement-indent) | |
898 (progn | |
899 (if (= (point) (point-min)) | |
900 (setq icol fortran-minimum-statement-indent) | |
901 (setq icol (fortran-current-line-indentation))) | |
902 (skip-chars-forward " \t0-9") | |
903 (cond ((looking-at "if[ \t]*(") | |
1548 | 904 (if (or (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t_$(=a-z0-9]") |
332 | 905 (let (then-test) ;multi-line if-then |
906 (while (and (= (forward-line 1) 0) | |
1548 | 907 ;;search forward for then |
332 | 908 (or (looking-at " [^ 0\n]") |
909 (looking-at "\t[1-9]")) | |
910 (not (setq then-test (looking-at | |
1548 | 911 ".*then\\b[ \t]\ |
912 *[^ \t_$(=a-z0-9]"))))) | |
332 | 913 then-test)) |
914 (setq icol (+ icol fortran-if-indent)))) | |
915 ((looking-at "\\(else\\|elseif\\)\\b") | |
916 (setq icol (+ icol fortran-if-indent))) | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
917 ((looking-at "select[ \t]*case[ \t](.*)\\b") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
918 (setq icol (+ icol fortran-if-indent))) |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
919 ((looking-at "case[ \t]*(.*)[ \t]*\n") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
920 (setq icol (+ icol fortran-if-indent))) |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
921 ((looking-at "case[ \t]*default\\b") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
922 (setq icol (+ icol fortran-if-indent))) |
1548 | 923 ((looking-at "\\(otherwise\\|else[ \t]*where\\)\\b") |
924 (setq icol (+ icol fortran-if-indent))) | |
5065
cd3d59bc0b94
(calculate-fortran-indent): Fixup regexp for where statements.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
925 ((looking-at "where[ \t]*(.*)[ \t]*\n") |
1548 | 926 (setq icol (+ icol fortran-if-indent))) |
332 | 927 ((looking-at "do\\b") |
928 (setq icol (+ icol fortran-do-indent))) | |
1548 | 929 ((looking-at |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
930 "\\(structure\\|union\\|map\\|interface\\)\\b[ \t]*[^ \t=(a-z]") |
1548 | 931 (setq icol (+ icol fortran-structure-indent))) |
332 | 932 ((looking-at "end\\b[ \t]*[^ \t=(a-z]") |
1548 | 933 ;; Previous END resets indent to minimum |
332 | 934 (setq icol fortran-minimum-statement-indent)))))) |
935 (save-excursion | |
936 (beginning-of-line) | |
937 (cond ((looking-at "[ \t]*$")) | |
938 ((looking-at comment-line-start-skip) | |
939 (cond ((eq fortran-comment-indent-style 'relative) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
940 (setq icol (+ icol fortran-comment-line-extra-indent))) |
332 | 941 ((eq fortran-comment-indent-style 'fixed) |
1548 | 942 (setq icol (+ fortran-minimum-statement-indent |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
943 fortran-comment-line-extra-indent)))) |
1548 | 944 (setq fortran-minimum-statement-indent 0)) |
332 | 945 ((or (looking-at (concat "[ \t]*" |
1548 | 946 (regexp-quote |
947 fortran-continuation-string))) | |
332 | 948 (looking-at " [^ 0\n]") |
949 (looking-at "\t[1-9]")) | |
950 (setq icol (+ icol fortran-continuation-indent))) | |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
951 ((looking-at "[ \t]*#") ; Check for cpp directive. |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
952 (setq fortran-minimum-statement-indent 0 icol 0)) |
332 | 953 (first-statement) |
954 ((and fortran-check-all-num-for-matching-do | |
955 (looking-at "[ \t]*[0-9]+") | |
956 (fortran-check-for-matching-do)) | |
957 (setq icol (- icol fortran-do-indent))) | |
958 (t | |
959 (skip-chars-forward " \t0-9") | |
960 (cond ((looking-at "end[ \t]*if\\b") | |
961 (setq icol (- icol fortran-if-indent))) | |
962 ((looking-at "\\(else\\|elseif\\)\\b") | |
963 (setq icol (- icol fortran-if-indent))) | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
964 ((looking-at "case[ \t]*(.*)[ \t]*\n") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
965 (setq icol (- icol fortran-if-indent))) |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
966 ((looking-at "case[ \t]*default\\b") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
967 (setq icol (- icol fortran-if-indent))) |
1548 | 968 ((looking-at "\\(otherwise\\|else[ \t]*where\\)\\b") |
969 (setq icol (- icol fortran-if-indent))) | |
970 ((looking-at "end[ \t]*where\\b") | |
971 (setq icol (- icol fortran-if-indent))) | |
332 | 972 ((and (looking-at "continue\\b") |
973 (fortran-check-for-matching-do)) | |
974 (setq icol (- icol fortran-do-indent))) | |
975 ((looking-at "end[ \t]*do\\b") | |
976 (setq icol (- icol fortran-do-indent))) | |
1548 | 977 ((looking-at |
978 "end[ \t]*\ | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
979 \\(structure\\|union\\|map\\|interface\\)\\b[ \t]*[^ \t=(a-z]") |
1548 | 980 (setq icol (- icol fortran-structure-indent))) |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
981 ((looking-at |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
982 "end[ \t]*select\\b[ \t]*[^ \t=(a-z]") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
983 (setq icol (- icol fortran-if-indent))) |
332 | 984 ((and (looking-at "end\\b[ \t]*[^ \t=(a-z]") |
985 (not (= icol fortran-minimum-statement-indent))) | |
986 (message "Warning: `end' not in column %d. Probably\ | |
987 an unclosed block." fortran-minimum-statement-indent)))))) | |
988 (max fortran-minimum-statement-indent icol))) | |
989 | |
990 (defun fortran-current-line-indentation () | |
991 "Indentation of current line, ignoring Fortran line number or continuation. | |
992 This is the column position of the first non-whitespace character | |
993 aside from the line number and/or column 5/8 line-continuation character. | |
994 For comment lines, returns indentation of the first | |
995 non-indentation text within the comment." | |
996 (save-excursion | |
997 (beginning-of-line) | |
998 (cond ((looking-at comment-line-start-skip) | |
999 (goto-char (match-end 0)) | |
1000 (skip-chars-forward | |
1548 | 1001 (if (stringp fortran-comment-indent-char) |
1002 fortran-comment-indent-char | |
1003 (char-to-string fortran-comment-indent-char)))) | |
332 | 1004 ((or (looking-at " [^ 0\n]") |
1548 | 1005 (looking-at "\t[1-9]")) |
332 | 1006 (goto-char (match-end 0))) |
1007 (t | |
1008 ;; Move past line number. | |
1548 | 1009 (skip-chars-forward "[ \t0-9]");From Uli |
1010 )) | |
332 | 1011 ;; Move past whitespace. |
1012 (skip-chars-forward " \t") | |
1013 (current-column))) | |
1014 | |
1015 (defun fortran-indent-to-column (col) | |
1016 "Indents current line with spaces to column COL. | |
1017 notes: 1) A non-zero/non-blank character in column 5 indicates a continuation | |
1018 line, and this continuation character is retained on indentation; | |
1548 | 1019 2) If `fortran-continuation-string' is the first non-whitespace |
1020 character, this is a continuation line; | |
332 | 1021 3) A non-continuation line which has a number as the first |
1022 non-whitespace character is a numbered line. | |
1548 | 1023 4) A TAB followed by a digit indicates a continuation line." |
332 | 1024 (save-excursion |
1025 (beginning-of-line) | |
1026 (if (looking-at comment-line-start-skip) | |
1027 (if fortran-comment-indent-style | |
1028 (let ((char (if (stringp fortran-comment-indent-char) | |
1029 (aref fortran-comment-indent-char 0) | |
1548 | 1030 fortran-comment-indent-char))) |
332 | 1031 (goto-char (match-end 0)) |
1032 (delete-horizontal-regexp (concat " \t" (char-to-string char))) | |
1033 (insert-char char (- col (current-column))))) | |
1034 (if (looking-at "\t[1-9]") | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1035 (if indent-tabs-mode |
332 | 1036 (goto-char (match-end 0)) |
1037 (delete-char 2) | |
1038 (insert " ") | |
1039 (insert fortran-continuation-string)) | |
1040 (if (looking-at " [^ 0\n]") | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1041 (if indent-tabs-mode |
332 | 1042 (progn (delete-char 6) |
1043 (insert "\t") | |
1044 (insert-char (fortran-numerical-continuation-char) 1)) | |
1045 (forward-char 6)) | |
1046 (delete-horizontal-space) | |
1548 | 1047 ;; Put line number in columns 0-4 |
1048 ;; or put continuation character in column 5. | |
332 | 1049 (cond ((eobp)) |
1050 ((looking-at (regexp-quote fortran-continuation-string)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1051 (if indent-tabs-mode |
332 | 1052 (progn |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1053 (indent-to |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1054 (if indent-tabs-mode |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1055 fortran-minimum-statement-indent-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1056 fortran-minimum-statement-indent-fixed)) |
332 | 1057 (delete-char 1) |
1058 (insert-char (fortran-numerical-continuation-char) 1)) | |
1548 | 1059 (indent-to 5) |
1060 (forward-char 1))) | |
332 | 1061 ((looking-at "[0-9]+") |
1062 (let ((extra-space (- 5 (- (match-end 0) (point))))) | |
1063 (if (< extra-space 0) | |
1064 (message "Warning: line number exceeds 5-digit limit.") | |
1065 (indent-to (min fortran-line-number-indent extra-space)))) | |
1066 (skip-chars-forward "0-9"))))) | |
1067 ;; Point is now after any continuation character or line number. | |
1068 ;; Put body of statement where specified. | |
1069 (delete-horizontal-space) | |
1070 (indent-to col) | |
1071 ;; Indent any comment following code on the same line. | |
1072 (if (and comment-start-skip | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1073 (fortran-find-comment-start-skip)) |
332 | 1074 (progn (goto-char (match-beginning 0)) |
1075 (if (not (= (current-column) (fortran-comment-hook))) | |
1076 (progn (delete-horizontal-space) | |
1077 (indent-to (fortran-comment-hook))))))))) | |
1078 | |
1079 (defun fortran-line-number-indented-correctly-p () | |
1080 "Return t if current line's line number is correctly indented. | |
1081 Do not call if there is no line number." | |
1082 (save-excursion | |
1083 (beginning-of-line) | |
1084 (skip-chars-forward " \t") | |
1085 (and (<= (current-column) fortran-line-number-indent) | |
1086 (or (= (current-column) fortran-line-number-indent) | |
1087 (progn (skip-chars-forward "0-9") | |
1088 (= (current-column) 5)))))) | |
1089 | |
1090 (defun fortran-check-for-matching-do () | |
1548 | 1091 "When called from a numbered statement, returns t if matching DO is found. |
332 | 1092 Otherwise return a nil." |
1093 (let (charnum | |
1094 (case-fold-search t)) | |
1095 (save-excursion | |
1096 (beginning-of-line) | |
1097 (if (looking-at "[ \t]*[0-9]+") | |
1098 (progn | |
1099 (skip-chars-forward " \t") | |
1100 (skip-chars-forward "0") ;skip past leading zeros | |
1101 (setq charnum (buffer-substring (point) | |
1102 (progn (skip-chars-forward "0-9") | |
1103 (point)))) | |
1104 (beginning-of-line) | |
1105 (and (re-search-backward | |
1106 (concat | |
1548 | 1107 "\\(^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]\\)\\|\\(^[ \t0-9]*do\ |
1108 [ \t]*0*" | |
1109 charnum "\\b\\)\\|\\(^[ \t]*0*" charnum "\\b\\)") | |
332 | 1110 nil t) |
1111 (looking-at (concat "^[ \t0-9]*do[ \t]*0*" charnum)))))))) | |
1112 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1113 (defun fortran-find-comment-start-skip () |
1548 | 1114 "Move to past `comment-start-skip' found on current line. |
1115 Return t if `comment-start-skip' found, nil if not." | |
1116 ;;; In order to move point only if comment-start-skip is found, | |
1117 ;;; this one uses a lot of save-excursions. Note that re-search-forward | |
1118 ;;; moves point even if comment-start-skip is inside a string-constant. | |
1119 ;;; Some code expects certain values for match-beginning and end | |
1120 (interactive) | |
1121 (let ((save-match-beginning) (save-match-end)) | |
1122 (if (save-excursion | |
1123 (re-search-forward comment-start-skip | |
1124 (save-excursion (end-of-line) (point)) t)) | |
1125 (progn | |
1126 (setq save-match-beginning (match-beginning 0)) | |
1127 (setq save-match-end (match-end 0)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1128 (if (fortran-is-in-string-p (match-beginning 0)) |
1548 | 1129 (progn |
1130 (save-excursion | |
1131 (goto-char save-match-end) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1132 (fortran-find-comment-start-skip)) ; recurse for rest of line |
1548 | 1133 ) |
1134 (goto-char save-match-beginning) | |
1135 (re-search-forward comment-start-skip | |
1136 (save-excursion (end-of-line) (point)) t) | |
1137 (goto-char (match-end 0)) | |
1138 t)) | |
1139 nil))) | |
1140 | |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1141 ;;;From: ralf@up3aud1.gwdg.de (Ralf Fassel) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1142 ;;; Test if TAB format continuation lines work. |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1143 (defun fortran-is-in-string-p (where) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1144 "Return non-nil if POS (a buffer position) is inside a Fortran string, |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1145 nil else." |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1146 (save-excursion |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1147 (goto-char where) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1148 (cond |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1149 ((bolp) nil) ; bol is never inside a string |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1150 ((save-excursion ; comment lines too |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1151 (beginning-of-line)(looking-at comment-line-start-skip)) nil) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1152 (t (let (;; ok, serious now. Init some local vars: |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1153 (parse-state '(0 nil nil nil nil nil 0)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1154 (quoted-comment-start (if comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1155 (regexp-quote comment-start))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1156 (not-done t) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1157 parse-limit |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1158 end-of-line |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1159 ) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1160 ;; move to start of current statement |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1161 (fortran-next-statement) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1162 (fortran-previous-statement) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1163 ;; now parse up to WHERE |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1164 (while not-done |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1165 (if (or ;; skip to next line if: |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1166 ;; - comment line? |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1167 (looking-at comment-line-start-skip) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1168 ;; - at end of line? |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1169 (eolp) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1170 ;; - not in a string and after comment-start? |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1171 (and (not (nth 3 parse-state)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1172 comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1173 (equal comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1174 (char-to-string (preceding-char))))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1175 ;; get around a bug in forward-line in versions <= 18.57 |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1176 (if (or (> (forward-line 1) 0) (eobp)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1177 (setq not-done nil)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1178 ;; else: |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1179 ;; if we are at beginning of code line, skip any |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1180 ;; whitespace, labels and tab continuation markers. |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1181 (if (bolp) (skip-chars-forward " \t0-9")) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1182 ;; if we are in column <= 5 now, check for continuation char |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1183 (cond ((= 5 (current-column)) (forward-char 1)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1184 ((and (< (current-column) 5) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1185 (equal fortran-continuation-string |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1186 (char-to-string (following-char))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1187 (forward-char 1)))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1188 ;; find out parse-limit from here |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1189 (setq end-of-line (save-excursion (end-of-line)(point))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1190 (setq parse-limit (min where end-of-line)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1191 ;; parse max up to comment-start, if non-nil and in current line |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1192 (if comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1193 (save-excursion |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1194 (if (re-search-forward quoted-comment-start end-of-line t) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1195 (setq parse-limit (min (point) parse-limit))))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1196 ;; now parse if still in limits |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1197 (if (< (point) where) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1198 (setq parse-state (parse-partial-sexp |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1199 (point) parse-limit nil nil parse-state)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1200 (setq not-done nil)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1201 )) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1202 ;; result is |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1203 (nth 3 parse-state)))))) |
1548 | 1204 |
1205 (defun fortran-auto-fill-mode (arg) | |
1206 "Toggle fortran-auto-fill mode. | |
1207 With ARG, turn `fortran-auto-fill' mode on iff ARG is positive. | |
1208 In `fortran-auto-fill' mode, inserting a space at a column beyond `fill-column' | |
1209 automatically breaks the line at a previous space." | |
1210 (interactive "P") | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1211 (prog1 (setq auto-fill-function |
1548 | 1212 (if (if (null arg) |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1213 (not auto-fill-function) |
1548 | 1214 (> (prefix-numeric-value arg) 0)) |
1215 'fortran-indent-line | |
1216 nil)) | |
1217 ;; update mode-line | |
1218 (set-buffer-modified-p (buffer-modified-p)))) | |
1219 | |
1220 (defun fortran-do-auto-fill () | |
1221 (interactive) | |
1222 (let* ((opoint (point)) | |
1223 (bol (save-excursion (beginning-of-line) (point))) | |
1224 (eol (save-excursion (end-of-line) (point))) | |
1225 (bos (min eol (+ bol (fortran-current-line-indentation)))) | |
1226 (quote | |
1227 (save-excursion | |
1228 (goto-char bol) | |
1229 (if (looking-at comment-line-start-skip) | |
1230 nil ; OK to break quotes on comment lines. | |
1231 (move-to-column fill-column) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1232 (cond ((fortran-is-in-string-p (point)) |
1548 | 1233 (save-excursion (re-search-backward "[^']'[^']" bol t) |
1234 (if fortran-break-before-delimiters | |
1235 (point) | |
1236 (1+ (point))))) | |
1237 (t nil))))) | |
1238 ;; | |
1239 ;; decide where to split the line. If a position for a quoted | |
1240 ;; string was found above then use that, else break the line | |
1241 ;; before the last delimiter. | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
1242 ;; Delimiters are whitespace, commas, and operators. |
1548 | 1243 ;; Will break before a pair of *'s. |
1244 ;; | |
1245 (fill-point | |
1246 (or quote | |
1247 (save-excursion | |
1248 (move-to-column (1+ fill-column)) | |
1249 (skip-chars-backward "^ \t\n,'+-/*=)" | |
1250 ;;; (if fortran-break-before-delimiters | |
1251 ;;; "^ \t\n,'+-/*=" "^ \t\n,'+-/*=)") | |
1252 ) | |
1253 (if (<= (point) (1+ bos)) | |
1254 (progn | |
1255 (move-to-column (1+ fill-column)) | |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1256 ;;;what is this doing??? |
1548 | 1257 (if (not (re-search-forward "[\t\n,'+-/*)=]" eol t)) |
1258 (goto-char bol)))) | |
1259 (if (bolp) | |
1260 (re-search-forward "[ \t]" opoint t) | |
1261 (forward-char -1) | |
1262 (if (looking-at "'") | |
1263 (forward-char 1) | |
1264 (skip-chars-backward " \t\*"))) | |
1265 (if fortran-break-before-delimiters | |
1266 (point) | |
1267 (1+ (point)))))) | |
1268 ) | |
1269 ;; if we are in an in-line comment, don't break unless the | |
1270 ;; line of code is longer than it should be. Otherwise | |
1271 ;; break the line at the column computed above. | |
1272 ;; | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1273 ;; Need to use fortran-find-comment-start-skip to make sure that quoted !'s |
1548 | 1274 ;; don't prevent a break. |
1275 (if (not (or (save-excursion | |
1276 (if (and (re-search-backward comment-start-skip bol t) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1277 (not (fortran-is-in-string-p (point)))) |
1548 | 1278 (progn |
1279 (skip-chars-backward " \t") | |
1280 (< (current-column) (1+ fill-column))))) | |
1281 (save-excursion | |
1282 (goto-char fill-point) | |
1283 (bolp)))) | |
1284 (if (> (save-excursion | |
1285 (goto-char fill-point) (current-column)) | |
1286 (1+ fill-column)) | |
1287 (progn (goto-char fill-point) | |
1288 (fortran-break-line)) | |
1289 (save-excursion | |
1290 (if (> (save-excursion | |
1291 (goto-char fill-point) | |
1292 (current-column)) | |
1293 (+ (calculate-fortran-indent) fortran-continuation-indent)) | |
1294 (progn | |
1295 (goto-char fill-point) | |
1296 (fortran-break-line)))))) | |
1297 )) | |
1298 (defun fortran-break-line () | |
1299 (let ((opoint (point)) | |
1300 (bol (save-excursion (beginning-of-line) (point))) | |
1301 (eol (save-excursion (end-of-line) (point))) | |
1302 (comment-string nil)) | |
1303 | |
1304 (save-excursion | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1305 (if (and comment-start-skip (fortran-find-comment-start-skip)) |
1548 | 1306 (progn |
1307 (re-search-backward comment-start-skip bol t) | |
1308 (setq comment-string (buffer-substring (point) eol)) | |
1309 (delete-region (point) eol)))) | |
1310 ;;; Forward line 1 really needs to go to next non white line | |
1311 (if (save-excursion (forward-line 1) | |
1312 (or (looking-at " [^ 0\n]") | |
1313 (looking-at "\t[1-9]"))) | |
1314 (progn | |
1315 (forward-line 1) | |
1316 (delete-indentation) | |
1317 (delete-char 2) | |
1318 (delete-horizontal-space) | |
1319 (fortran-do-auto-fill)) | |
1320 (fortran-split-line)) | |
1321 (if comment-string | |
1322 (save-excursion | |
1323 (goto-char bol) | |
1324 (end-of-line) | |
1325 (delete-horizontal-space) | |
1326 (indent-to (fortran-comment-hook)) | |
1327 (insert comment-string))))) | |
1328 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1329 (defun fortran-analyze-file-format () |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1330 "Returns nil if fixed format is used, t if TAB formatting is used. |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1331 Use `fortran-tab-mode-default' if no non-comment statements are found in the |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1332 file before the end or the first `fortran-analyze-depth' lines." |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1333 (let ((i 0)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1334 (save-excursion |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1335 (goto-char (point-min)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1336 (setq i 0) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1337 (while (not (or |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1338 (eobp) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1339 (looking-at "\t") |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1340 (looking-at " ") |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1341 (> i fortran-analyze-depth))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1342 (forward-line) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1343 (setq i (1+ i))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1344 (cond |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1345 ((looking-at "\t") t) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1346 ((looking-at " ") nil) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1347 (fortran-tab-mode-default t) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1348 (t nil))))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1349 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1350 (or (assq 'fortran-tab-mode-string minor-mode-alist) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1351 (setq minor-mode-alist (cons |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1352 '(fortran-tab-mode-string |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1353 (indent-tabs-mode fortran-tab-mode-string)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1354 minor-mode-alist))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1355 |
584 | 1356 (provide 'fortran) |
1357 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1358 ;;; fortran.el ends here |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1359 |