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