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