Mercurial > emacs
annotate lisp/progmodes/fortran.el @ 11483:089f81a81ba6
(x_report_frame_params): Report value of `display' parm.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 18 Apr 1995 18:36:03 +0000 |
parents | 526ba0811e2e |
children | e7c26522b881 |
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 |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
7 ;; Version 1.30.5.1 (Sept 16, 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 | |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
49 (defconst fortran-mode-version "version 1.30.5.1") |
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 | |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
114 "*Non-nil causes \\[fortran-indent-line] on ENDIF statement to blink on matching IF. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
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 |
10787
a5e881c047ce
Turn of syntax fontification by default.
Simon Marshall <simon@gnu.org>
parents:
10189
diff
changeset
|
186 ;; off on the wrong track. To make it clear(er) to the programmer what is |
a5e881c047ce
Turn of syntax fontification by default.
Simon Marshall <simon@gnu.org>
parents:
10189
diff
changeset
|
187 ;; happening, we could override string fontification when fontifying, by the |
a5e881c047ce
Turn of syntax fontification by default.
Simon Marshall <simon@gnu.org>
parents:
10189
diff
changeset
|
188 ;; keyword regexp, a standard comment. But by default we turn off syntax |
a5e881c047ce
Turn of syntax fontification by default.
Simon Marshall <simon@gnu.org>
parents:
10189
diff
changeset
|
189 ;; fontification, and we don't put `!' as a comment-in-any-column in the |
a5e881c047ce
Turn of syntax fontification by default.
Simon Marshall <simon@gnu.org>
parents:
10189
diff
changeset
|
190 ;; regexp keywords as it would be recognised inside a string. |
9476
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
191 |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
192 (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
|
193 '(;; Fontify comments. |
10787
a5e881c047ce
Turn of syntax fontification by default.
Simon Marshall <simon@gnu.org>
parents:
10189
diff
changeset
|
194 ; ("^[Cc!*].*$" 0 font-lock-comment-face t) |
a5e881c047ce
Turn of syntax fontification by default.
Simon Marshall <simon@gnu.org>
parents:
10189
diff
changeset
|
195 ("^[Cc!*].*$" . font-lock-comment-face) |
9476
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
196 ;; 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
|
197 ("\\<\\(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
|
198 (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
|
199 "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
|
200 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
|
201 |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
202 (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
|
203 (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
|
204 (let ((type-types |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
205 ; ("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
|
206 ; "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
|
207 ; "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
|
208 (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
|
209 "d\\(ata\\|imension\\|ouble\\)\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
210 "e\\(quivalence\\|xternal\\)\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
211 "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
|
212 "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
|
213 "s\\(ave\\|tructure\\)\\|union")) |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
214 (fkeywords |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
215 ; ("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
|
216 ; "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
|
217 ; "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
|
218 (concat "c\\(lose\\|ontinue\\)\\|" |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
219 "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
|
220 "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
|
221 "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
|
222 (flogicals |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
223 ; ("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
|
224 "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
|
225 (list |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
226 ;; |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
227 ;; 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
|
228 (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
|
229 '(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
|
230 '(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
|
231 ;; |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
232 ;; 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
|
233 (concat "\\<\\(" fkeywords "\\)\\>") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
234 ;; |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
235 ;; Fontify all builtin operators. |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
236 (concat "\\.\\(" flogicals "\\)\\.") |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
237 ;; |
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
238 ;; 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
|
239 (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
|
240 '(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
|
241 '(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
|
242 (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
|
243 "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
|
244 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
|
245 |
10883
526ba0811e2e
Use font-lock-maximum-decoration when setting fortran-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
10787
diff
changeset
|
246 (defvar fortran-font-lock-keywords (if font-lock-maximum-decoration |
526ba0811e2e
Use font-lock-maximum-decoration when setting fortran-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
10787
diff
changeset
|
247 fortran-font-lock-keywords-2 |
526ba0811e2e
Use font-lock-maximum-decoration when setting fortran-font-lock-keywords.
Simon Marshall <simon@gnu.org>
parents:
10787
diff
changeset
|
248 fortran-font-lock-keywords-1) |
9476
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
249 "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
|
250 |
332 | 251 (defvar fortran-mode-map () |
1548 | 252 "Keymap used in Fortran mode.") |
332 | 253 (if fortran-mode-map |
254 () | |
255 (setq fortran-mode-map (make-sparse-keymap)) | |
256 (define-key fortran-mode-map ";" 'fortran-abbrev-start) | |
257 (define-key fortran-mode-map "\C-c;" 'fortran-comment-region) | |
258 (define-key fortran-mode-map "\e\C-a" 'beginning-of-fortran-subprogram) | |
259 (define-key fortran-mode-map "\e\C-e" 'end-of-fortran-subprogram) | |
260 (define-key fortran-mode-map "\e;" 'fortran-indent-comment) | |
261 (define-key fortran-mode-map "\e\C-h" 'mark-fortran-subprogram) | |
262 (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
|
263 (define-key fortran-mode-map "\n" 'fortran-indent-new-line) |
332 | 264 (define-key fortran-mode-map "\e\C-q" 'fortran-indent-subprogram) |
265 (define-key fortran-mode-map "\C-c\C-w" 'fortran-window-create-momentarily) | |
266 (define-key fortran-mode-map "\C-c\C-r" 'fortran-column-ruler) | |
267 (define-key fortran-mode-map "\C-c\C-p" 'fortran-previous-statement) | |
268 (define-key fortran-mode-map "\C-c\C-n" 'fortran-next-statement) | |
269 (define-key fortran-mode-map "\t" 'fortran-indent-line) | |
270 (define-key fortran-mode-map "0" 'fortran-electric-line-number) | |
271 (define-key fortran-mode-map "1" 'fortran-electric-line-number) | |
272 (define-key fortran-mode-map "2" 'fortran-electric-line-number) | |
273 (define-key fortran-mode-map "3" 'fortran-electric-line-number) | |
274 (define-key fortran-mode-map "4" 'fortran-electric-line-number) | |
275 (define-key fortran-mode-map "5" 'fortran-electric-line-number) | |
276 (define-key fortran-mode-map "6" 'fortran-electric-line-number) | |
277 (define-key fortran-mode-map "7" 'fortran-electric-line-number) | |
278 (define-key fortran-mode-map "8" 'fortran-electric-line-number) | |
279 (define-key fortran-mode-map "9" 'fortran-electric-line-number)) | |
280 | |
281 (defvar fortran-mode-abbrev-table nil) | |
282 (if fortran-mode-abbrev-table | |
283 () | |
284 (let ((ac abbrevs-changed)) | |
285 (define-abbrev-table 'fortran-mode-abbrev-table ()) | |
286 (define-abbrev fortran-mode-abbrev-table ";au" "automatic" nil) | |
287 (define-abbrev fortran-mode-abbrev-table ";b" "byte" nil) | |
1548 | 288 (define-abbrev fortran-mode-abbrev-table ";bd" "block data" nil) |
332 | 289 (define-abbrev fortran-mode-abbrev-table ";ch" "character" nil) |
290 (define-abbrev fortran-mode-abbrev-table ";cl" "close" nil) | |
291 (define-abbrev fortran-mode-abbrev-table ";c" "continue" nil) | |
292 (define-abbrev fortran-mode-abbrev-table ";cm" "common" nil) | |
293 (define-abbrev fortran-mode-abbrev-table ";cx" "complex" nil) | |
294 (define-abbrev fortran-mode-abbrev-table ";df" "define" nil) | |
295 (define-abbrev fortran-mode-abbrev-table ";di" "dimension" nil) | |
296 (define-abbrev fortran-mode-abbrev-table ";do" "double" nil) | |
297 (define-abbrev fortran-mode-abbrev-table ";dc" "double complex" nil) | |
298 (define-abbrev fortran-mode-abbrev-table ";dp" "double precision" nil) | |
299 (define-abbrev fortran-mode-abbrev-table ";dw" "do while" nil) | |
300 (define-abbrev fortran-mode-abbrev-table ";e" "else" nil) | |
301 (define-abbrev fortran-mode-abbrev-table ";ed" "enddo" nil) | |
302 (define-abbrev fortran-mode-abbrev-table ";el" "elseif" nil) | |
303 (define-abbrev fortran-mode-abbrev-table ";en" "endif" nil) | |
304 (define-abbrev fortran-mode-abbrev-table ";eq" "equivalence" nil) | |
1548 | 305 (define-abbrev fortran-mode-abbrev-table ";ew" "endwhere" nil) |
332 | 306 (define-abbrev fortran-mode-abbrev-table ";ex" "external" nil) |
307 (define-abbrev fortran-mode-abbrev-table ";ey" "entry" nil) | |
308 (define-abbrev fortran-mode-abbrev-table ";f" "format" nil) | |
309 (define-abbrev fortran-mode-abbrev-table ";fa" ".false." nil) | |
310 (define-abbrev fortran-mode-abbrev-table ";fu" "function" nil) | |
311 (define-abbrev fortran-mode-abbrev-table ";g" "goto" nil) | |
312 (define-abbrev fortran-mode-abbrev-table ";im" "implicit" nil) | |
313 (define-abbrev fortran-mode-abbrev-table ";ib" "implicit byte" nil) | |
314 (define-abbrev fortran-mode-abbrev-table ";ic" "implicit complex" nil) | |
315 (define-abbrev fortran-mode-abbrev-table ";ich" "implicit character" nil) | |
316 (define-abbrev fortran-mode-abbrev-table ";ii" "implicit integer" nil) | |
317 (define-abbrev fortran-mode-abbrev-table ";il" "implicit logical" nil) | |
318 (define-abbrev fortran-mode-abbrev-table ";ir" "implicit real" nil) | |
319 (define-abbrev fortran-mode-abbrev-table ";inc" "include" nil) | |
320 (define-abbrev fortran-mode-abbrev-table ";in" "integer" nil) | |
321 (define-abbrev fortran-mode-abbrev-table ";intr" "intrinsic" nil) | |
322 (define-abbrev fortran-mode-abbrev-table ";l" "logical" nil) | |
323 (define-abbrev fortran-mode-abbrev-table ";n" "namelist" nil) | |
324 (define-abbrev fortran-mode-abbrev-table ";o" "open" nil) ; was ;op | |
325 (define-abbrev fortran-mode-abbrev-table ";pa" "parameter" nil) | |
326 (define-abbrev fortran-mode-abbrev-table ";pr" "program" nil) | |
327 (define-abbrev fortran-mode-abbrev-table ";ps" "pause" nil) | |
328 (define-abbrev fortran-mode-abbrev-table ";p" "print" nil) | |
329 (define-abbrev fortran-mode-abbrev-table ";rc" "record" nil) | |
330 (define-abbrev fortran-mode-abbrev-table ";re" "real" nil) | |
331 (define-abbrev fortran-mode-abbrev-table ";r" "read" nil) | |
332 (define-abbrev fortran-mode-abbrev-table ";rt" "return" nil) | |
333 (define-abbrev fortran-mode-abbrev-table ";rw" "rewind" nil) | |
334 (define-abbrev fortran-mode-abbrev-table ";s" "stop" nil) | |
335 (define-abbrev fortran-mode-abbrev-table ";sa" "save" nil) | |
336 (define-abbrev fortran-mode-abbrev-table ";st" "structure" nil) | |
337 (define-abbrev fortran-mode-abbrev-table ";sc" "static" nil) | |
338 (define-abbrev fortran-mode-abbrev-table ";su" "subroutine" nil) | |
339 (define-abbrev fortran-mode-abbrev-table ";tr" ".true." nil) | |
340 (define-abbrev fortran-mode-abbrev-table ";ty" "type" nil) | |
341 (define-abbrev fortran-mode-abbrev-table ";vo" "volatile" nil) | |
342 (define-abbrev fortran-mode-abbrev-table ";w" "write" nil) | |
1548 | 343 (define-abbrev fortran-mode-abbrev-table ";wh" "where" nil) |
332 | 344 (setq abbrevs-changed ac))) |
345 | |
346 ;;;###autoload | |
347 (defun fortran-mode () | |
1548 | 348 "Major mode for editing Fortran code. |
349 \\[fortran-indent-line] indents the current Fortran line correctly. | |
350 DO statements must not share a common CONTINUE. | |
332 | 351 |
1548 | 352 Type ;? or ;\\[help-command] to display a list of built-in\ |
332 | 353 abbrevs for Fortran keywords. |
354 | |
355 Key definitions: | |
356 \\{fortran-mode-map} | |
357 | |
358 Variables controlling indentation style and extra features: | |
359 | |
360 comment-start | |
361 Normally nil in Fortran mode. If you want to use comments | |
362 starting with `!', set this to the string \"!\". | |
363 fortran-do-indent | |
364 Extra indentation within do blocks. (default 3) | |
365 fortran-if-indent | |
366 Extra indentation within if blocks. (default 3) | |
1548 | 367 fortran-structure-indent |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
368 Extra indentation within structure, union, map and interface blocks. |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
369 (default 3) |
332 | 370 fortran-continuation-indent |
1548 | 371 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
|
372 fortran-comment-line-extra-indent |
1548 | 373 Amount of extra indentation for text within full-line comments. (default 0) |
332 | 374 fortran-comment-indent-style |
375 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
|
376 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
|
377 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
|
378 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
|
379 (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
|
380 relative means indent at `fortran-comment-line-extra-indent' beyond the |
332 | 381 indentation for a line of code. |
382 (default 'fixed) | |
383 fortran-comment-indent-char | |
1548 | 384 Single-character string to be inserted instead of space for |
332 | 385 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
|
386 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
|
387 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
|
388 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
|
389 Minimum indentation for Fortran statements in TAB format mode. (default 9) |
332 | 390 fortran-line-number-indent |
391 Maximum indentation for line numbers. A line number will get | |
392 less than this much indentation if necessary to avoid reaching | |
393 column 5. (default 1) | |
394 fortran-check-all-num-for-matching-do | |
1548 | 395 Non-nil causes all numbered lines to be treated as possible \"continue\" |
332 | 396 statements. (default nil) |
397 fortran-blink-matching-if | |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
398 Non-nil causes \\[fortran-indent-line] on an ENDIF statement to blink on |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
399 matching IF. Also, from an ENDDO statement, blink on matching DO [WHILE] |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
400 statement. (default nil) |
332 | 401 fortran-continuation-string |
402 Single-character string to be inserted in column 5 of a continuation | |
403 line. (default \"$\") | |
404 fortran-comment-region | |
405 String inserted by \\[fortran-comment-region] at start of each line in | |
406 region. (default \"c$$$\") | |
407 fortran-electric-line-number | |
408 Non-nil causes line number digits to be moved to the correct column | |
409 as typed. (default t) | |
1548 | 410 fortran-break-before-delimiters |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
411 Non-nil causes `fortran-do-auto-fill' breaks lines before delimiters. |
1548 | 412 (default t) |
332 | 413 fortran-startup-message |
414 Set to nil to inhibit message first time Fortran mode is used. | |
415 | |
1548 | 416 Turning on Fortran mode calls the value of the variable `fortran-mode-hook' |
332 | 417 with no args, if that value is non-nil." |
418 (interactive) | |
419 (kill-all-local-variables) | |
420 (if fortran-startup-message | |
1548 | 421 (message "Emacs Fortran mode %s. Bugs to %s" |
332 | 422 fortran-mode-version bug-fortran-mode)) |
423 (setq fortran-startup-message nil) | |
424 (setq local-abbrev-table fortran-mode-abbrev-table) | |
425 (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
|
426 (make-local-variable 'font-lock-defaults) |
10787
a5e881c047ce
Turn of syntax fontification by default.
Simon Marshall <simon@gnu.org>
parents:
10189
diff
changeset
|
427 (setq font-lock-defaults '(fortran-font-lock-keywords t t)) |
1548 | 428 (make-local-variable 'fortran-break-before-delimiters) |
429 (setq fortran-break-before-delimiters t) | |
332 | 430 (make-local-variable 'indent-line-function) |
431 (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
|
432 (make-local-variable 'comment-indent-function) |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2028
diff
changeset
|
433 (setq comment-indent-function 'fortran-comment-hook) |
332 | 434 (make-local-variable 'comment-line-start-skip) |
435 (setq comment-line-start-skip | |
1548 | 436 "^[Cc*]\\(\\([^ \t\n]\\)\\2\\2*\\)?[ \t]*\\|^#.*") |
332 | 437 (make-local-variable 'comment-line-start) |
438 (setq comment-line-start "c") | |
439 (make-local-variable 'comment-start-skip) | |
440 (setq comment-start-skip "![ \t]*") | |
441 (make-local-variable 'comment-start) | |
442 (setq comment-start nil) | |
443 (make-local-variable 'require-final-newline) | |
444 (setq require-final-newline t) | |
445 (make-local-variable 'abbrev-all-caps) | |
446 (setq abbrev-all-caps t) | |
447 (make-local-variable 'indent-tabs-mode) | |
448 (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
|
449 ;;;(setq abbrev-mode t) ; ?? (abbrev-mode 1) instead?? |
1548 | 450 (setq fill-column 72) ; Already local? |
332 | 451 (use-local-map fortran-mode-map) |
452 (setq mode-name "Fortran") | |
453 (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
|
454 ;;;(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
|
455 (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
|
456 (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
|
457 (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
|
458 (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
|
459 (make-local-variable 'fortran-column-ruler-tab) |
332 | 460 (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
|
461 (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
|
462 (setq indent-tabs-mode (fortran-analyze-file-format)) |
332 | 463 (run-hooks 'fortran-mode-hook)) |
464 | |
465 (defun fortran-comment-hook () | |
466 (save-excursion | |
467 (skip-chars-backward " \t") | |
468 (max (+ 1 (current-column)) | |
469 comment-column))) | |
470 | |
471 (defun fortran-indent-comment () | |
472 "Align or create comment on current line. | |
473 Existing comments of all types are recognized and aligned. | |
474 If the line has no comment, a side-by-side comment is inserted and aligned | |
475 if the value of comment-start is not nil. | |
476 Otherwise, a separate-line comment is inserted, on this line | |
477 or on a new line inserted before this line if this line is not blank." | |
478 (interactive) | |
479 (beginning-of-line) | |
480 ;; Recognize existing comments of either kind. | |
481 (cond ((looking-at comment-line-start-skip) | |
482 (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
|
483 ((fortran-find-comment-start-skip) ; catches any inline comment and |
1548 | 484 ; leaves point after comment-start-skip |
485 (if comment-start-skip | |
486 (progn (goto-char (match-beginning 0)) | |
487 (if (not (= (current-column) (fortran-comment-hook))) | |
488 (progn (delete-horizontal-space) | |
489 (indent-to (fortran-comment-hook))))) | |
490 (end-of-line))) ; otherwise goto end of line or sth else? | |
332 | 491 ;; No existing comment. |
492 ;; If side-by-side comments are defined, insert one, | |
493 ;; unless line is now blank. | |
494 ((and comment-start (not (looking-at "^[ \t]*$"))) | |
495 (end-of-line) | |
496 (delete-horizontal-space) | |
497 (indent-to (fortran-comment-hook)) | |
498 (insert comment-start)) | |
499 ;; Else insert separate-line comment, making a new line if nec. | |
500 (t | |
501 (if (looking-at "^[ \t]*$") | |
502 (delete-horizontal-space) | |
503 (beginning-of-line) | |
504 (insert "\n") | |
505 (forward-char -1)) | |
506 (insert comment-line-start) | |
507 (insert-char (if (stringp fortran-comment-indent-char) | |
508 (aref fortran-comment-indent-char 0) | |
1548 | 509 fortran-comment-indent-char) |
332 | 510 (- (calculate-fortran-indent) (current-column)))))) |
511 | |
512 (defun fortran-comment-region (beg-region end-region arg) | |
513 "Comments every line in the region. | |
514 Puts fortran-comment-region at the beginning of every line in the region. | |
515 BEG-REGION and END-REGION are args which specify the region boundaries. | |
516 With non-nil ARG, uncomments the region." | |
517 (interactive "*r\nP") | |
518 (let ((end-region-mark (make-marker)) (save-point (point-marker))) | |
519 (set-marker end-region-mark end-region) | |
520 (goto-char beg-region) | |
521 (beginning-of-line) | |
522 (if (not arg) ;comment the region | |
523 (progn (insert fortran-comment-region) | |
524 (while (and (= (forward-line 1) 0) | |
525 (< (point) end-region-mark)) | |
526 (insert fortran-comment-region))) | |
527 (let ((com (regexp-quote fortran-comment-region))) ;uncomment the region | |
528 (if (looking-at com) | |
529 (delete-region (point) (match-end 0))) | |
530 (while (and (= (forward-line 1) 0) | |
531 (< (point) end-region-mark)) | |
532 (if (looking-at com) | |
533 (delete-region (point) (match-end 0)))))) | |
534 (goto-char save-point) | |
535 (set-marker end-region-mark nil) | |
536 (set-marker save-point nil))) | |
537 | |
538 (defun fortran-abbrev-start () | |
1548 | 539 "Typing ;\\[help-command] or ;? lists all the Fortran abbrevs. |
332 | 540 Any other key combination is executed normally." |
541 (interactive) | |
542 (let (c) | |
543 (insert last-command-char) | |
2028
87f2d4cbbaf4
(fortran-abbrev-start): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1862
diff
changeset
|
544 (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
|
545 (eq c help-char)) |
332 | 546 (fortran-abbrev-help) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1633
diff
changeset
|
547 (setq unread-command-events (list c))))) |
332 | 548 |
549 (defun fortran-abbrev-help () | |
550 "List the currently defined abbrevs in Fortran mode." | |
551 (interactive) | |
552 (message "Listing abbrev table...") | |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
553 (display-buffer (fortran-prepare-abbrev-list-buffer)) |
332 | 554 (message "Listing abbrev table...done")) |
555 | |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
556 (defun fortran-prepare-abbrev-list-buffer () |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
557 (save-excursion |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
558 (set-buffer (get-buffer-create "*Abbrevs*")) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
559 (erase-buffer) |
1862
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
560 (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
|
561 (goto-char (point-min)) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
562 (set-buffer-modified-p nil) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
563 (edit-abbrevs-mode)) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
564 (get-buffer-create "*Abbrevs*")) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
565 |
332 | 566 (defun fortran-column-ruler () |
567 "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
|
568 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
|
569 format mode, and `fortran-column-ruler-tab' when in TAB format mode. |
332 | 570 The key typed is executed unless it is SPC." |
571 (interactive) | |
572 (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
|
573 (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
|
574 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
|
575 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
|
576 (save-excursion |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
577 (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
|
578 (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
|
579 (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
|
580 (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
|
581 (point))) |
332 | 582 nil "Type SPC or any command to erase ruler.")) |
583 | |
584 (defun fortran-window-create () | |
585 "Makes the window 72 columns wide. | |
1475 | 586 See also `fortran-window-create-momentarily'." |
332 | 587 (interactive) |
588 (condition-case error | |
589 (progn | |
590 (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
|
591 (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
|
592 (enlarge-window-horizontally (- (frame-width) |
332 | 593 (window-width) 1))) |
594 (split-window-horizontally 73) | |
595 (other-window 1) | |
596 (switch-to-buffer " fortran-window-extra" t) | |
597 (select-window (previous-window)))) | |
1548 | 598 (error (message "No room for Fortran window.") |
332 | 599 'error))) |
600 | |
601 (defun fortran-window-create-momentarily (&optional arg) | |
602 "Momentarily makes the window 72 columns wide. | |
603 Optional ARG non-nil and non-unity disables the momentary feature. | |
1475 | 604 See also `fortran-window-create'." |
332 | 605 (interactive "p") |
606 (if (or (not arg) | |
607 (= arg 1)) | |
608 (save-window-excursion | |
609 (if (not (equal (fortran-window-create) 'error)) | |
610 (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
|
611 (let ((char (read-event))) |
332 | 612 (or (equal char (string-to-char " ")) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1633
diff
changeset
|
613 (setq unread-command-events (list char))))))) |
332 | 614 (fortran-window-create))) |
615 | |
616 (defun fortran-split-line () | |
617 "Break line at point and insert continuation marker and alignment." | |
618 (interactive) | |
619 (delete-horizontal-space) | |
620 (if (save-excursion (beginning-of-line) (looking-at comment-line-start-skip)) | |
621 (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
|
622 (if indent-tabs-mode |
332 | 623 (progn |
624 (insert "\n\t") | |
625 (insert-char (fortran-numerical-continuation-char) 1)) | |
1548 | 626 (insert "\n " fortran-continuation-string)));Space after \n important |
627 (fortran-indent-line)) ;when the cont string is C, c or *. | |
332 | 628 |
629 (defun fortran-numerical-continuation-char () | |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
630 "Return a digit for tab-digit style of continuation lines. |
332 | 631 If, previous line is a tab-digit continuation line, returns that digit |
632 plus one. Otherwise return 1. Zero not allowed." | |
633 (save-excursion | |
634 (forward-line -1) | |
635 (if (looking-at "\t[1-9]") | |
636 (+ ?1 (% (- (char-after (+ (point) 1)) ?0) 9)) | |
637 ?1))) | |
638 | |
639 (defun delete-horizontal-regexp (chars) | |
640 "Delete all characters in CHARS around point. | |
641 CHARS is like the inside of a [...] in a regular expression | |
642 except that ] is never special and \ quotes ^, - or \." | |
643 (interactive "*s") | |
644 (skip-chars-backward chars) | |
645 (delete-region (point) (progn (skip-chars-forward chars) (point)))) | |
646 | |
647 (defun fortran-electric-line-number (arg) | |
648 "Self insert, but if part of a Fortran line number indent it automatically. | |
649 Auto-indent does not happen if a numeric arg is used." | |
650 (interactive "P") | |
651 (if (or arg (not fortran-electric-line-number)) | |
652 (if arg | |
1548 | 653 (self-insert-command (prefix-numeric-value arg)) |
332 | 654 (self-insert-command 1)) |
655 (if (or (and (= 5 (current-column)) | |
656 (save-excursion | |
657 (beginning-of-line) | |
658 (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
|
659 (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
|
660 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
|
661 fortran-minimum-statement-indent-fixed) (current-column)) |
332 | 662 (save-excursion |
663 (beginning-of-line) | |
664 (looking-at "\t"));In col 8 with a single tab to the left. | |
665 (not (or (eq last-command 'fortran-indent-line) | |
666 (eq last-command | |
3567
2ca5f216e445
(fortran-indent-new-line): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
3400
diff
changeset
|
667 'fortran-indent-new-line)))) |
332 | 668 (save-excursion |
669 (re-search-backward "[^ \t0-9]" | |
670 (save-excursion | |
671 (beginning-of-line) | |
672 (point)) | |
673 t)) ;not a line number | |
674 (looking-at "[0-9]") ;within a line number | |
675 ) | |
1548 | 676 (self-insert-command (prefix-numeric-value arg)) |
332 | 677 (skip-chars-backward " \t") |
678 (insert last-command-char) | |
679 (fortran-indent-line)))) | |
680 | |
681 (defun beginning-of-fortran-subprogram () | |
1548 | 682 "Moves point to the beginning of the current Fortran subprogram." |
332 | 683 (interactive) |
684 (let ((case-fold-search t)) | |
685 (beginning-of-line -1) | |
686 (re-search-backward "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]" nil 'move) | |
687 (if (looking-at "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]") | |
688 (forward-line 1)))) | |
689 | |
690 (defun end-of-fortran-subprogram () | |
1548 | 691 "Moves point to the end of the current Fortran subprogram." |
332 | 692 (interactive) |
693 (let ((case-fold-search t)) | |
694 (beginning-of-line 2) | |
695 (re-search-forward "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]" nil 'move) | |
696 (goto-char (match-beginning 0)) | |
697 (forward-line 1))) | |
698 | |
699 (defun mark-fortran-subprogram () | |
1548 | 700 "Put mark at end of Fortran subprogram, point at beginning. |
332 | 701 The marks are pushed." |
702 (interactive) | |
703 (end-of-fortran-subprogram) | |
704 (push-mark (point)) | |
705 (beginning-of-fortran-subprogram)) | |
1548 | 706 |
332 | 707 (defun fortran-previous-statement () |
1548 | 708 "Moves point to beginning of the previous Fortran statement. |
709 Returns `first-statement' if that statement is the first | |
332 | 710 non-comment Fortran statement in the file, and nil otherwise." |
711 (interactive) | |
712 (let (not-first-statement continue-test) | |
713 (beginning-of-line) | |
714 (setq continue-test | |
1548 | 715 (and |
716 (not (looking-at comment-line-start-skip)) | |
717 (or (looking-at | |
332 | 718 (concat "[ \t]*" (regexp-quote fortran-continuation-string))) |
1548 | 719 (or (looking-at " [^ 0\n]") |
720 (looking-at "\t[1-9]"))))) | |
332 | 721 (while (and (setq not-first-statement (= (forward-line -1) 0)) |
722 (or (looking-at comment-line-start-skip) | |
723 (looking-at "[ \t]*$") | |
724 (looking-at " [^ 0\n]") | |
725 (looking-at "\t[1-9]") | |
726 (looking-at (concat "[ \t]*" comment-start-skip))))) | |
727 (cond ((and continue-test | |
728 (not not-first-statement)) | |
729 (message "Incomplete continuation statement.")) | |
730 (continue-test | |
731 (fortran-previous-statement)) | |
732 ((not not-first-statement) | |
733 'first-statement)))) | |
734 | |
735 (defun fortran-next-statement () | |
1548 | 736 "Moves point to beginning of the next Fortran statement. |
332 | 737 Returns `last-statement' if that statement is the last |
738 non-comment Fortran statement in the file, and nil otherwise." | |
739 (interactive) | |
740 (let (not-last-statement) | |
741 (beginning-of-line) | |
1548 | 742 (while (and (setq not-last-statement |
743 (and (= (forward-line 1) 0) | |
744 (not (eobp)))) | |
332 | 745 (or (looking-at comment-line-start-skip) |
746 (looking-at "[ \t]*$") | |
747 (looking-at " [^ 0\n]") | |
748 (looking-at "\t[1-9]") | |
749 (looking-at (concat "[ \t]*" comment-start-skip))))) | |
750 (if (not not-last-statement) | |
751 'last-statement))) | |
752 | |
753 (defun fortran-blink-matching-if () | |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
754 ;; From a Fortran ENDIF statement, blink the matching IF statement. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
755 (let ((top-of-window (window-start)) matching-if |
332 | 756 (endif-point (point)) message) |
757 (if (save-excursion (beginning-of-line) | |
758 (skip-chars-forward " \t0-9") | |
759 (looking-at "end[ \t]*if\\b")) | |
760 (progn | |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
761 (if (not (setq matching-if (fortran-beginning-if))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
762 (setq message "No matching if.") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
763 (if (< matching-if top-of-window) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
764 (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
765 (goto-char matching-if) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
766 (beginning-of-line) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
767 (setq message |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
768 (concat "Matches " |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
769 (buffer-substring |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
770 (point) (progn (end-of-line) (point)))))))) |
332 | 771 (if message |
1548 | 772 (message "%s" message) |
332 | 773 (goto-char matching-if) |
774 (sit-for 1) | |
775 (goto-char endif-point)))))) | |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
776 |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
777 (defun fortran-blink-matching-do () |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
778 ;; 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
|
779 ;; statement. This is basically copied from fortran-blink-matching-if. |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
780 (let ((top-of-window (window-start)) matching-do |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
781 (enddo-point (point)) message) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
782 (if (save-excursion (beginning-of-line) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
783 (skip-chars-forward " \t0-9") |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
784 (looking-at "end[ \t]*do\\b")) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
785 (progn |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
786 (if (not (setq matching-do (fortran-beginning-do))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
787 (setq message "No matching do.") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
788 (if (< matching-do top-of-window) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
789 (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
790 (goto-char matching-do) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
791 (beginning-of-line) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
792 (setq message |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
793 (concat "Matches " |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
794 (buffer-substring |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
795 (point) (progn (end-of-line) (point)))))))) |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
796 (if message |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
797 (message "%s" message) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
798 (goto-char matching-do) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
799 (sit-for 1) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
800 (goto-char enddo-point)))))) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
801 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
802 (defun fortran-mark-do () |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
803 "Put mark at end of Fortran DO [WHILE]-ENDDO construct, point at beginning. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
804 The marks are pushed." |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
805 (interactive) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
806 (let (enddo-point do-point) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
807 (if (setq enddo-point (fortran-end-do)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
808 (if (not (setq do-point (fortran-beginning-do))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
809 (message "No matching do.") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
810 ;; Set mark, move point. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
811 (goto-char enddo-point) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
812 (push-mark) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
813 (goto-char do-point))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
814 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
815 (defun fortran-end-do () |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
816 ;; Search forward for first unmatched ENDDO. Return point or nil. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
817 (if (save-excursion (beginning-of-line) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
818 (skip-chars-forward " \t0-9") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
819 (looking-at "end[ \t]*do\\b")) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
820 ;; Sitting on one. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
821 (match-beginning 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
822 ;; Search for one. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
823 (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
824 (let ((count 1)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
825 (while (and (not (= count 0)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
826 (not (eq (fortran-next-statement) 'last-statement)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
827 ;; Keep local to subprogram |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
828 (not (looking-at "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]"))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
829 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
830 (skip-chars-forward " \t0-9") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
831 (cond ((looking-at "end[ \t]*do\\b") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
832 (setq count (- count 1))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
833 ((looking-at "do[ \t]+[^0-9]") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
834 (setq count (+ count 1))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
835 (and (= count 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
836 ;; All pairs accounted for. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
837 (point)))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
838 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
839 (defun fortran-beginning-do () |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
840 ;; Search backwards for first unmatched DO [WHILE]. Return point or nil. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
841 (if (save-excursion (beginning-of-line) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
842 (skip-chars-forward " \t0-9") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
843 (looking-at "do[ \t]+")) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
844 ;; Sitting on one. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
845 (match-beginning 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
846 ;; Search for one. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
847 (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
848 (let ((count 1)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
849 (while (and (not (= count 0)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
850 (not (eq (fortran-previous-statement) 'first-statement)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
851 ;; Keep local to subprogram |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
852 (not (looking-at "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]"))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
853 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
854 (skip-chars-forward " \t0-9") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
855 (cond ((looking-at "do[ \t]+[^0-9]") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
856 (setq count (- count 1))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
857 ((looking-at "end[ \t]*do\\b") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
858 (setq count (+ count 1))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
859 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
860 (and (= count 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
861 ;; All pairs accounted for. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
862 (point)))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
863 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
864 (defun fortran-mark-if () |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
865 "Put mark at end of Fortran IF-ENDIF construct, point at beginning. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
866 The marks are pushed." |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
867 (interactive) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
868 (let (endif-point if-point) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
869 (if (setq endif-point (fortran-end-if)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
870 (if (not (setq if-point (fortran-beginning-if))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
871 (message "No matching if.") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
872 ;; Set mark, move point. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
873 (goto-char endif-point) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
874 (push-mark) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
875 (goto-char if-point))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
876 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
877 (defun fortran-end-if () |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
878 ;; Search forwards for first unmatched ENDIF. Return point or nil. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
879 (if (save-excursion (beginning-of-line) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
880 (skip-chars-forward " \t0-9") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
881 (looking-at "end[ \t]*if\\b")) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
882 ;; Sitting on one. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
883 (match-beginning 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
884 ;; Search for one. The point has been already been moved to first |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
885 ;; letter on line but this should not cause troubles. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
886 (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
887 (let ((count 1)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
888 (while (and (not (= count 0)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
889 (not (eq (fortran-next-statement) 'last-statement)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
890 ;; Keep local to subprogram. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
891 (not (looking-at |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
892 "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]"))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
893 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
894 (skip-chars-forward " \t0-9") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
895 (cond ((looking-at "end[ \t]*if\\b") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
896 (setq count (- count 1))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
897 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
898 ((looking-at "if[ \t]*(") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
899 (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
900 (if (or |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
901 (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t(=a-z0-9]") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
902 (let (then-test) ; Multi-line if-then. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
903 (while |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
904 (and (= (forward-line 1) 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
905 ;; Search forward for then. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
906 (or (looking-at " [^ 0\n]") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
907 (looking-at "\t[1-9]")) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
908 (not |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
909 (setq then-test |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
910 (looking-at |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
911 ".*then\\b[ \t]*[^ \t(=a-z0-9]"))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
912 then-test)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
913 (setq count (+ count 1))))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
914 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
915 (and (= count 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
916 ;; All pairs accounted for. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
917 (point)))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
918 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
919 (defun fortran-beginning-if () |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
920 ;; Search backwards for first unmatched IF-THEN. Return point or nil. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
921 (if (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
922 ;; May be sitting on multi-line if-then statement, first move to |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
923 ;; beginning of current statement. Note: `fortran-previous-statement' |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
924 ;; moves to previous statement *unless* current statement is first |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
925 ;; one. Only move forward if not first-statement. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
926 (if (not (eq (fortran-previous-statement) 'first-statement)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
927 (fortran-next-statement)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
928 (skip-chars-forward " \t0-9") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
929 (and |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
930 (looking-at "if[ \t]*(") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
931 (save-match-data |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
932 (or (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t(=a-z0-9]") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
933 ;; Multi-line if-then. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
934 (let (then-test) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
935 (while |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
936 (and (= (forward-line 1) 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
937 ;; Search forward for then. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
938 (or (looking-at " [^ 0\n]") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
939 (looking-at "\t[1-9]")) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
940 (not |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
941 (setq then-test |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
942 (looking-at |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
943 ".*then\\b[ \t]*[^ \t(=a-z0-9]"))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
944 then-test))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
945 ;; Sitting on one. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
946 (match-beginning 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
947 ;; Search for one. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
948 (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
949 (let ((count 1)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
950 (while (and (not (= count 0)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
951 (not (eq (fortran-previous-statement) 'first-statement)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
952 ;; Keep local to subprogram. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
953 (not (looking-at |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
954 "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]"))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
955 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
956 (skip-chars-forward " \t0-9") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
957 (cond ((looking-at "if[ \t]*(") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
958 (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
959 (if (or |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
960 (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t(=a-z0-9]") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
961 (let (then-test) ; Multi-line if-then. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
962 (while |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
963 (and (= (forward-line 1) 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
964 ;; Search forward for then. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
965 (or (looking-at " [^ 0\n]") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
966 (looking-at "\t[1-9]")) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
967 (not |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
968 (setq then-test |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
969 (looking-at |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
970 ".*then\\b[ \t]*[^ \t(=a-z0-9]"))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
971 then-test)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
972 (setq count (- count 1))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
973 ((looking-at "end[ \t]*if\\b") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
974 (setq count (+ count 1))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
975 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
976 (and (= count 0) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
977 ;; All pairs accounted for. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
978 (point)))))) |
332 | 979 |
980 (defun fortran-indent-line () | |
1548 | 981 "Indents current Fortran line based on its contents and on previous lines." |
332 | 982 (interactive) |
983 (let ((cfi (calculate-fortran-indent))) | |
984 (save-excursion | |
985 (beginning-of-line) | |
986 (if (or (not (= cfi (fortran-current-line-indentation))) | |
987 (and (re-search-forward "^[ \t]*[0-9]+" (+ (point) 4) t) | |
988 (not (fortran-line-number-indented-correctly-p)))) | |
989 (fortran-indent-to-column cfi) | |
990 (beginning-of-line) | |
991 (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
|
992 (fortran-find-comment-start-skip)) |
332 | 993 (fortran-indent-comment)))) |
994 ;; Never leave point in left margin. | |
995 (if (< (current-column) cfi) | |
996 (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
|
997 (if (and auto-fill-function |
1548 | 998 (> (save-excursion (end-of-line) (current-column)) fill-column)) |
999 (save-excursion | |
1000 (end-of-line) | |
1001 (fortran-do-auto-fill))) | |
332 | 1002 (if fortran-blink-matching-if |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1003 (progn |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1004 (fortran-blink-matching-if) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1005 (fortran-blink-matching-do))))) |
332 | 1006 |
3567
2ca5f216e445
(fortran-indent-new-line): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
3400
diff
changeset
|
1007 (defun fortran-indent-new-line () |
1548 | 1008 "Reindent the current Fortran line, insert a newline and indent the newline. |
1009 An abbrev before point is expanded if `abbrev-mode' is non-nil." | |
332 | 1010 (interactive) |
1011 (if abbrev-mode (expand-abbrev)) | |
1012 (save-excursion | |
1013 (beginning-of-line) | |
1014 (skip-chars-forward " \t") | |
1015 (if (or (looking-at "[0-9]") ;Reindent only where it is most | |
1016 (looking-at "end") ;likely to be necessary | |
1017 (looking-at "else") | |
1018 (looking-at (regexp-quote fortran-continuation-string))) | |
1019 (fortran-indent-line))) | |
1548 | 1020 (newline) |
332 | 1021 (fortran-indent-line)) |
1548 | 1022 |
332 | 1023 (defun fortran-indent-subprogram () |
1024 "Properly indents the Fortran subprogram which contains point." | |
1025 (interactive) | |
1026 (save-excursion | |
1027 (mark-fortran-subprogram) | |
1028 (message "Indenting subprogram...") | |
1029 (indent-region (point) (mark) nil)) | |
1030 (message "Indenting subprogram...done.")) | |
1031 | |
1032 (defun calculate-fortran-indent () | |
1548 | 1033 "Calculates the Fortran indent column based on previous lines." |
332 | 1034 (let (icol first-statement (case-fold-search t) |
1035 (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
|
1036 (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
|
1037 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
|
1038 fortran-minimum-statement-indent-fixed))) |
332 | 1039 (save-excursion |
1040 (setq first-statement (fortran-previous-statement)) | |
1041 (if first-statement | |
1042 (setq icol fortran-minimum-statement-indent) | |
1043 (progn | |
1044 (if (= (point) (point-min)) | |
1045 (setq icol fortran-minimum-statement-indent) | |
1046 (setq icol (fortran-current-line-indentation))) | |
1047 (skip-chars-forward " \t0-9") | |
1048 (cond ((looking-at "if[ \t]*(") | |
1548 | 1049 (if (or (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t_$(=a-z0-9]") |
332 | 1050 (let (then-test) ;multi-line if-then |
1051 (while (and (= (forward-line 1) 0) | |
1548 | 1052 ;;search forward for then |
332 | 1053 (or (looking-at " [^ 0\n]") |
1054 (looking-at "\t[1-9]")) | |
1055 (not (setq then-test (looking-at | |
1548 | 1056 ".*then\\b[ \t]\ |
1057 *[^ \t_$(=a-z0-9]"))))) | |
332 | 1058 then-test)) |
1059 (setq icol (+ icol fortran-if-indent)))) | |
1060 ((looking-at "\\(else\\|elseif\\)\\b") | |
1061 (setq icol (+ icol fortran-if-indent))) | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1062 ((looking-at "select[ \t]*case[ \t](.*)\\b") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1063 (setq icol (+ icol fortran-if-indent))) |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1064 ((looking-at "case[ \t]*(.*)[ \t]*\n") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1065 (setq icol (+ icol fortran-if-indent))) |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1066 ((looking-at "case[ \t]*default\\b") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1067 (setq icol (+ icol fortran-if-indent))) |
1548 | 1068 ((looking-at "\\(otherwise\\|else[ \t]*where\\)\\b") |
1069 (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
|
1070 ((looking-at "where[ \t]*(.*)[ \t]*\n") |
1548 | 1071 (setq icol (+ icol fortran-if-indent))) |
332 | 1072 ((looking-at "do\\b") |
1073 (setq icol (+ icol fortran-do-indent))) | |
1548 | 1074 ((looking-at |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1075 "\\(structure\\|union\\|map\\|interface\\)\\b[ \t]*[^ \t=(a-z]") |
1548 | 1076 (setq icol (+ icol fortran-structure-indent))) |
332 | 1077 ((looking-at "end\\b[ \t]*[^ \t=(a-z]") |
1548 | 1078 ;; Previous END resets indent to minimum |
332 | 1079 (setq icol fortran-minimum-statement-indent)))))) |
1080 (save-excursion | |
1081 (beginning-of-line) | |
1082 (cond ((looking-at "[ \t]*$")) | |
1083 ((looking-at comment-line-start-skip) | |
1084 (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
|
1085 (setq icol (+ icol fortran-comment-line-extra-indent))) |
332 | 1086 ((eq fortran-comment-indent-style 'fixed) |
1548 | 1087 (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
|
1088 fortran-comment-line-extra-indent)))) |
1548 | 1089 (setq fortran-minimum-statement-indent 0)) |
332 | 1090 ((or (looking-at (concat "[ \t]*" |
1548 | 1091 (regexp-quote |
1092 fortran-continuation-string))) | |
332 | 1093 (looking-at " [^ 0\n]") |
1094 (looking-at "\t[1-9]")) | |
1095 (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
|
1096 ((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
|
1097 (setq fortran-minimum-statement-indent 0 icol 0)) |
332 | 1098 (first-statement) |
1099 ((and fortran-check-all-num-for-matching-do | |
1100 (looking-at "[ \t]*[0-9]+") | |
1101 (fortran-check-for-matching-do)) | |
1102 (setq icol (- icol fortran-do-indent))) | |
1103 (t | |
1104 (skip-chars-forward " \t0-9") | |
1105 (cond ((looking-at "end[ \t]*if\\b") | |
1106 (setq icol (- icol fortran-if-indent))) | |
1107 ((looking-at "\\(else\\|elseif\\)\\b") | |
1108 (setq icol (- icol fortran-if-indent))) | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1109 ((looking-at "case[ \t]*(.*)[ \t]*\n") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1110 (setq icol (- icol fortran-if-indent))) |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1111 ((looking-at "case[ \t]*default\\b") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1112 (setq icol (- icol fortran-if-indent))) |
1548 | 1113 ((looking-at "\\(otherwise\\|else[ \t]*where\\)\\b") |
1114 (setq icol (- icol fortran-if-indent))) | |
1115 ((looking-at "end[ \t]*where\\b") | |
1116 (setq icol (- icol fortran-if-indent))) | |
332 | 1117 ((and (looking-at "continue\\b") |
1118 (fortran-check-for-matching-do)) | |
1119 (setq icol (- icol fortran-do-indent))) | |
1120 ((looking-at "end[ \t]*do\\b") | |
1121 (setq icol (- icol fortran-do-indent))) | |
1548 | 1122 ((looking-at |
1123 "end[ \t]*\ | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1124 \\(structure\\|union\\|map\\|interface\\)\\b[ \t]*[^ \t=(a-z]") |
1548 | 1125 (setq icol (- icol fortran-structure-indent))) |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1126 ((looking-at |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1127 "end[ \t]*select\\b[ \t]*[^ \t=(a-z]") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1128 (setq icol (- icol fortran-if-indent))) |
332 | 1129 ((and (looking-at "end\\b[ \t]*[^ \t=(a-z]") |
1130 (not (= icol fortran-minimum-statement-indent))) | |
1131 (message "Warning: `end' not in column %d. Probably\ | |
1132 an unclosed block." fortran-minimum-statement-indent)))))) | |
1133 (max fortran-minimum-statement-indent icol))) | |
1134 | |
1135 (defun fortran-current-line-indentation () | |
1136 "Indentation of current line, ignoring Fortran line number or continuation. | |
1137 This is the column position of the first non-whitespace character | |
1138 aside from the line number and/or column 5/8 line-continuation character. | |
1139 For comment lines, returns indentation of the first | |
1140 non-indentation text within the comment." | |
1141 (save-excursion | |
1142 (beginning-of-line) | |
1143 (cond ((looking-at comment-line-start-skip) | |
1144 (goto-char (match-end 0)) | |
1145 (skip-chars-forward | |
1548 | 1146 (if (stringp fortran-comment-indent-char) |
1147 fortran-comment-indent-char | |
1148 (char-to-string fortran-comment-indent-char)))) | |
332 | 1149 ((or (looking-at " [^ 0\n]") |
1548 | 1150 (looking-at "\t[1-9]")) |
332 | 1151 (goto-char (match-end 0))) |
1152 (t | |
1153 ;; Move past line number. | |
1548 | 1154 (skip-chars-forward "[ \t0-9]");From Uli |
1155 )) | |
332 | 1156 ;; Move past whitespace. |
1157 (skip-chars-forward " \t") | |
1158 (current-column))) | |
1159 | |
1160 (defun fortran-indent-to-column (col) | |
1161 "Indents current line with spaces to column COL. | |
1162 notes: 1) A non-zero/non-blank character in column 5 indicates a continuation | |
1163 line, and this continuation character is retained on indentation; | |
1548 | 1164 2) If `fortran-continuation-string' is the first non-whitespace |
1165 character, this is a continuation line; | |
332 | 1166 3) A non-continuation line which has a number as the first |
1167 non-whitespace character is a numbered line. | |
1548 | 1168 4) A TAB followed by a digit indicates a continuation line." |
332 | 1169 (save-excursion |
1170 (beginning-of-line) | |
1171 (if (looking-at comment-line-start-skip) | |
1172 (if fortran-comment-indent-style | |
1173 (let ((char (if (stringp fortran-comment-indent-char) | |
1174 (aref fortran-comment-indent-char 0) | |
1548 | 1175 fortran-comment-indent-char))) |
332 | 1176 (goto-char (match-end 0)) |
1177 (delete-horizontal-regexp (concat " \t" (char-to-string char))) | |
1178 (insert-char char (- col (current-column))))) | |
1179 (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
|
1180 (if indent-tabs-mode |
332 | 1181 (goto-char (match-end 0)) |
1182 (delete-char 2) | |
1183 (insert " ") | |
1184 (insert fortran-continuation-string)) | |
1185 (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
|
1186 (if indent-tabs-mode |
332 | 1187 (progn (delete-char 6) |
1188 (insert "\t") | |
1189 (insert-char (fortran-numerical-continuation-char) 1)) | |
1190 (forward-char 6)) | |
1191 (delete-horizontal-space) | |
1548 | 1192 ;; Put line number in columns 0-4 |
1193 ;; or put continuation character in column 5. | |
332 | 1194 (cond ((eobp)) |
1195 ((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
|
1196 (if indent-tabs-mode |
332 | 1197 (progn |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1198 (indent-to |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1199 (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
|
1200 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
|
1201 fortran-minimum-statement-indent-fixed)) |
332 | 1202 (delete-char 1) |
1203 (insert-char (fortran-numerical-continuation-char) 1)) | |
1548 | 1204 (indent-to 5) |
1205 (forward-char 1))) | |
332 | 1206 ((looking-at "[0-9]+") |
1207 (let ((extra-space (- 5 (- (match-end 0) (point))))) | |
1208 (if (< extra-space 0) | |
1209 (message "Warning: line number exceeds 5-digit limit.") | |
1210 (indent-to (min fortran-line-number-indent extra-space)))) | |
1211 (skip-chars-forward "0-9"))))) | |
1212 ;; Point is now after any continuation character or line number. | |
1213 ;; Put body of statement where specified. | |
1214 (delete-horizontal-space) | |
1215 (indent-to col) | |
1216 ;; Indent any comment following code on the same line. | |
1217 (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
|
1218 (fortran-find-comment-start-skip)) |
332 | 1219 (progn (goto-char (match-beginning 0)) |
1220 (if (not (= (current-column) (fortran-comment-hook))) | |
1221 (progn (delete-horizontal-space) | |
1222 (indent-to (fortran-comment-hook))))))))) | |
1223 | |
1224 (defun fortran-line-number-indented-correctly-p () | |
1225 "Return t if current line's line number is correctly indented. | |
1226 Do not call if there is no line number." | |
1227 (save-excursion | |
1228 (beginning-of-line) | |
1229 (skip-chars-forward " \t") | |
1230 (and (<= (current-column) fortran-line-number-indent) | |
1231 (or (= (current-column) fortran-line-number-indent) | |
1232 (progn (skip-chars-forward "0-9") | |
1233 (= (current-column) 5)))))) | |
1234 | |
1235 (defun fortran-check-for-matching-do () | |
1548 | 1236 "When called from a numbered statement, returns t if matching DO is found. |
332 | 1237 Otherwise return a nil." |
1238 (let (charnum | |
1239 (case-fold-search t)) | |
1240 (save-excursion | |
1241 (beginning-of-line) | |
1242 (if (looking-at "[ \t]*[0-9]+") | |
1243 (progn | |
1244 (skip-chars-forward " \t") | |
1245 (skip-chars-forward "0") ;skip past leading zeros | |
1246 (setq charnum (buffer-substring (point) | |
1247 (progn (skip-chars-forward "0-9") | |
1248 (point)))) | |
1249 (beginning-of-line) | |
1250 (and (re-search-backward | |
1251 (concat | |
1548 | 1252 "\\(^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]\\)\\|\\(^[ \t0-9]*do\ |
1253 [ \t]*0*" | |
1254 charnum "\\b\\)\\|\\(^[ \t]*0*" charnum "\\b\\)") | |
332 | 1255 nil t) |
1256 (looking-at (concat "^[ \t0-9]*do[ \t]*0*" charnum)))))))) | |
1257 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1258 (defun fortran-find-comment-start-skip () |
1548 | 1259 "Move to past `comment-start-skip' found on current line. |
1260 Return t if `comment-start-skip' found, nil if not." | |
1261 ;;; In order to move point only if comment-start-skip is found, | |
1262 ;;; this one uses a lot of save-excursions. Note that re-search-forward | |
1263 ;;; moves point even if comment-start-skip is inside a string-constant. | |
1264 ;;; Some code expects certain values for match-beginning and end | |
1265 (interactive) | |
1266 (let ((save-match-beginning) (save-match-end)) | |
1267 (if (save-excursion | |
1268 (re-search-forward comment-start-skip | |
1269 (save-excursion (end-of-line) (point)) t)) | |
1270 (progn | |
1271 (setq save-match-beginning (match-beginning 0)) | |
1272 (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
|
1273 (if (fortran-is-in-string-p (match-beginning 0)) |
1548 | 1274 (progn |
1275 (save-excursion | |
1276 (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
|
1277 (fortran-find-comment-start-skip)) ; recurse for rest of line |
1548 | 1278 ) |
1279 (goto-char save-match-beginning) | |
1280 (re-search-forward comment-start-skip | |
1281 (save-excursion (end-of-line) (point)) t) | |
1282 (goto-char (match-end 0)) | |
1283 t)) | |
1284 nil))) | |
1285 | |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1286 ;;;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
|
1287 ;;; 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
|
1288 (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
|
1289 "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
|
1290 nil else." |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1291 (save-excursion |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1292 (goto-char where) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1293 (cond |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1294 ((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
|
1295 ((save-excursion ; comment lines too |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1296 (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
|
1297 (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
|
1298 (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
|
1299 (quoted-comment-start (if comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1300 (regexp-quote comment-start))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1301 (not-done t) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1302 parse-limit |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1303 end-of-line |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1304 ) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1305 ;; move to start of current statement |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1306 (fortran-next-statement) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1307 (fortran-previous-statement) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1308 ;; now parse up to WHERE |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1309 (while not-done |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1310 (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
|
1311 ;; - comment line? |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1312 (looking-at comment-line-start-skip) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1313 ;; - at end of line? |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1314 (eolp) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1315 ;; - 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
|
1316 (and (not (nth 3 parse-state)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1317 comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1318 (equal comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1319 (char-to-string (preceding-char))))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1320 ;; 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
|
1321 (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
|
1322 (setq not-done nil)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1323 ;; else: |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1324 ;; 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
|
1325 ;; whitespace, labels and tab continuation markers. |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1326 (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
|
1327 ;; 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
|
1328 (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
|
1329 ((and (< (current-column) 5) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1330 (equal fortran-continuation-string |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1331 (char-to-string (following-char))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1332 (forward-char 1)))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1333 ;; find out parse-limit from here |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1334 (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
|
1335 (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
|
1336 ;; 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
|
1337 (if comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1338 (save-excursion |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1339 (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
|
1340 (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
|
1341 ;; now parse if still in limits |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1342 (if (< (point) where) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1343 (setq parse-state (parse-partial-sexp |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1344 (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
|
1345 (setq not-done nil)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1346 )) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1347 ;; result is |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1348 (nth 3 parse-state)))))) |
1548 | 1349 |
1350 (defun fortran-auto-fill-mode (arg) | |
1351 "Toggle fortran-auto-fill mode. | |
1352 With ARG, turn `fortran-auto-fill' mode on iff ARG is positive. | |
1353 In `fortran-auto-fill' mode, inserting a space at a column beyond `fill-column' | |
1354 automatically breaks the line at a previous space." | |
1355 (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
|
1356 (prog1 (setq auto-fill-function |
1548 | 1357 (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
|
1358 (not auto-fill-function) |
1548 | 1359 (> (prefix-numeric-value arg) 0)) |
1360 'fortran-indent-line | |
1361 nil)) | |
1362 ;; update mode-line | |
1363 (set-buffer-modified-p (buffer-modified-p)))) | |
1364 | |
1365 (defun fortran-do-auto-fill () | |
1366 (interactive) | |
1367 (let* ((opoint (point)) | |
1368 (bol (save-excursion (beginning-of-line) (point))) | |
1369 (eol (save-excursion (end-of-line) (point))) | |
1370 (bos (min eol (+ bol (fortran-current-line-indentation)))) | |
1371 (quote | |
1372 (save-excursion | |
1373 (goto-char bol) | |
1374 (if (looking-at comment-line-start-skip) | |
1375 nil ; OK to break quotes on comment lines. | |
1376 (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
|
1377 (cond ((fortran-is-in-string-p (point)) |
1548 | 1378 (save-excursion (re-search-backward "[^']'[^']" bol t) |
1379 (if fortran-break-before-delimiters | |
1380 (point) | |
1381 (1+ (point))))) | |
1382 (t nil))))) | |
1383 ;; | |
1384 ;; decide where to split the line. If a position for a quoted | |
1385 ;; string was found above then use that, else break the line | |
1386 ;; before the last delimiter. | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
1387 ;; Delimiters are whitespace, commas, and operators. |
1548 | 1388 ;; Will break before a pair of *'s. |
1389 ;; | |
1390 (fill-point | |
1391 (or quote | |
1392 (save-excursion | |
1393 (move-to-column (1+ fill-column)) | |
1394 (skip-chars-backward "^ \t\n,'+-/*=)" | |
1395 ;;; (if fortran-break-before-delimiters | |
1396 ;;; "^ \t\n,'+-/*=" "^ \t\n,'+-/*=)") | |
1397 ) | |
1398 (if (<= (point) (1+ bos)) | |
1399 (progn | |
1400 (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
|
1401 ;;;what is this doing??? |
1548 | 1402 (if (not (re-search-forward "[\t\n,'+-/*)=]" eol t)) |
1403 (goto-char bol)))) | |
1404 (if (bolp) | |
1405 (re-search-forward "[ \t]" opoint t) | |
1406 (forward-char -1) | |
1407 (if (looking-at "'") | |
1408 (forward-char 1) | |
1409 (skip-chars-backward " \t\*"))) | |
1410 (if fortran-break-before-delimiters | |
1411 (point) | |
1412 (1+ (point)))))) | |
1413 ) | |
1414 ;; if we are in an in-line comment, don't break unless the | |
1415 ;; line of code is longer than it should be. Otherwise | |
1416 ;; break the line at the column computed above. | |
1417 ;; | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1418 ;; Need to use fortran-find-comment-start-skip to make sure that quoted !'s |
1548 | 1419 ;; don't prevent a break. |
1420 (if (not (or (save-excursion | |
1421 (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
|
1422 (not (fortran-is-in-string-p (point)))) |
1548 | 1423 (progn |
1424 (skip-chars-backward " \t") | |
1425 (< (current-column) (1+ fill-column))))) | |
1426 (save-excursion | |
1427 (goto-char fill-point) | |
1428 (bolp)))) | |
1429 (if (> (save-excursion | |
1430 (goto-char fill-point) (current-column)) | |
1431 (1+ fill-column)) | |
1432 (progn (goto-char fill-point) | |
1433 (fortran-break-line)) | |
1434 (save-excursion | |
1435 (if (> (save-excursion | |
1436 (goto-char fill-point) | |
1437 (current-column)) | |
1438 (+ (calculate-fortran-indent) fortran-continuation-indent)) | |
1439 (progn | |
1440 (goto-char fill-point) | |
1441 (fortran-break-line)))))) | |
1442 )) | |
1443 (defun fortran-break-line () | |
1444 (let ((opoint (point)) | |
1445 (bol (save-excursion (beginning-of-line) (point))) | |
1446 (eol (save-excursion (end-of-line) (point))) | |
1447 (comment-string nil)) | |
1448 | |
1449 (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
|
1450 (if (and comment-start-skip (fortran-find-comment-start-skip)) |
1548 | 1451 (progn |
1452 (re-search-backward comment-start-skip bol t) | |
1453 (setq comment-string (buffer-substring (point) eol)) | |
1454 (delete-region (point) eol)))) | |
1455 ;;; Forward line 1 really needs to go to next non white line | |
1456 (if (save-excursion (forward-line 1) | |
1457 (or (looking-at " [^ 0\n]") | |
1458 (looking-at "\t[1-9]"))) | |
1459 (progn | |
1460 (forward-line 1) | |
1461 (delete-indentation) | |
1462 (delete-char 2) | |
1463 (delete-horizontal-space) | |
1464 (fortran-do-auto-fill)) | |
1465 (fortran-split-line)) | |
1466 (if comment-string | |
1467 (save-excursion | |
1468 (goto-char bol) | |
1469 (end-of-line) | |
1470 (delete-horizontal-space) | |
1471 (indent-to (fortran-comment-hook)) | |
1472 (insert comment-string))))) | |
1473 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1474 (defun fortran-analyze-file-format () |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1475 "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
|
1476 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
|
1477 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
|
1478 (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
|
1479 (save-excursion |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1480 (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
|
1481 (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
|
1482 (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
|
1483 (eobp) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1484 (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
|
1485 (looking-at " ") |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1486 (> 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
|
1487 (forward-line) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1488 (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
|
1489 (cond |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1490 ((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
|
1491 ((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
|
1492 (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
|
1493 (t nil))))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1494 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1495 (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
|
1496 (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
|
1497 '(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
|
1498 (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
|
1499 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
|
1500 |
584 | 1501 (provide 'fortran) |
1502 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1503 ;;; fortran.el ends here |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1504 |