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