Mercurial > emacs
annotate lisp/progmodes/fortran.el @ 25526:8f312684d6ec
(make_shadow_gcs): Call
x_alloc_nearest_color_for_widget.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 03 Sep 1999 18:49:53 +0000 |
parents | ec613559ec18 |
children | edf06ac56d1f |
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 |
25054
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
3 ;; Copyright (c) 1986, 93, 94, 95, 97, 98, 1999 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> |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
6 ;; Maintainer: Dave Love <fx@gnu.org> |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: languages |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
8 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
10 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
11 ;; 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
|
12 ;; 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
|
13 ;; 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
|
14 ;; any later version. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
15 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
16 ;; 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
|
17 ;; 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
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
19 ;; GNU General Public License for more details. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
20 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
807
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 |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
28 ;; This mode is documented in the Emacs manual. |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
29 ;; |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
30 ;; Note that it is for editing Fortran77 or Fortran90 fixed source |
23754 | 31 ;; form. For editing Fortran 90 free format source, use `f90-mode' |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
32 ;; (f90.el). |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
33 |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
34 ;;; History: |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
35 |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
36 ;; Fortran mode was upgraded by Stephen A. Wood (saw@cebaf.gov). |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
37 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
38 ;; We acknowledge many contributions and valuable suggestions by |
1548 | 39 ;; Lawrence R. Dodd, Ralf Fassel, Ralph Finch, Stephen Gildea, |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
40 ;; Dr. Anil Gokhale, Ulrich Mueller, Mark Neale, Eric Prestemon, |
1548 | 41 ;; Gary Sabot and Richard Stallman. |
42 | |
14169 | 43 ;;; Code: |
332 | 44 |
23754 | 45 ;; Todo: |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
46 |
23754 | 47 ;; * Tidy it all up! (including renaming non-`fortran' prefixed |
48 ;; functions). | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
49 ;; * Implement insertion and removal of statement continuations in |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
50 ;; mixed f77/f90 style, with the first `&' past column 72 and the |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
51 ;; second in column 6. |
23754 | 52 ;; * Support any other extensions to f77 grokked by GNU Fortran. |
53 ;; * Change fontification to use font-lock-syntactic-keywords for | |
54 ;; fixed-form comments. (Done, but doesn't work properly with | |
55 ;; lazy-lock in pre-20.4.) | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
56 |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
57 (require 'easymenu) |
1548 | 58 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
59 (defgroup fortran nil |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
60 "Fortran mode for Emacs" |
24800 | 61 :link '(custom-manual "(emacs)Fortran") |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
62 :group 'languages) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
63 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
64 (defgroup fortran-indent nil |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
65 "Indentation variables in Fortran mode" |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
66 :prefix "fortran-" |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
67 :group 'fortran) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
68 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
69 (defgroup fortran-comment nil |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
70 "Comment-handling variables in Fortran mode" |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
71 :prefix "fortran-" |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
72 :group 'fortran) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
73 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
74 |
332 | 75 ;;;###autoload |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
76 (defcustom fortran-tab-mode-default nil |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
77 "*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
|
78 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
|
79 A value of nil specifies that continuation lines are marked |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
80 with a character in column 6." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
81 :type 'boolean |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
82 :group 'fortran-indent) |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
83 |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
84 ;; Buffer local, used to display mode line. |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
85 (defcustom fortran-tab-mode-string nil |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
86 "String to appear in mode line when TAB format mode is on." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
87 :type '(choice (const nil) string) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
88 :group 'fortran-indent) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
89 (make-variable-buffer-local 'fortran-tab-mode-string) |
332 | 90 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
91 (defcustom fortran-do-indent 3 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
92 "*Extra indentation applied to DO blocks." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
93 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
94 :group 'fortran-indent) |
332 | 95 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
96 (defcustom fortran-if-indent 3 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
97 "*Extra indentation applied to IF blocks." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
98 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
99 :group 'fortran-indent) |
1548 | 100 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
101 (defcustom fortran-structure-indent 3 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
102 "*Extra indentation applied to STRUCTURE, UNION, MAP and INTERFACE blocks." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
103 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
104 :group 'fortran-indent) |
332 | 105 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
106 (defcustom fortran-continuation-indent 5 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
107 "*Extra indentation applied to Fortran continuation lines." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
108 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
109 :group 'fortran-indent) |
332 | 110 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
111 (defcustom fortran-comment-indent-style 'fixed |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
112 "*How to indent comments. |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
113 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
|
114 '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
|
115 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
|
116 `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
|
117 `indent-tabs-mode' of t), and 'relative indents to current |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
118 Fortran indentation plus `fortran-comment-line-extra-indent'." |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
119 :type '(radio (const :tag "Untouched" nil) (const fixed) (const relative)) |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
120 :group 'fortran-indent) |
332 | 121 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
122 (defcustom fortran-comment-line-extra-indent 0 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
123 "*Amount of extra indentation for text within full-line comments." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
124 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
125 :group 'fortran-indent |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
126 :group 'fortran-comment) |
332 | 127 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
128 (defcustom comment-line-start nil |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
129 "*Delimiter inserted to start new full-line comment." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
130 :type '(choice string (const nil)) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
131 :group 'fortran-comment) |
332 | 132 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
133 (defcustom comment-line-start-skip nil |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
134 "*Regexp to match the start of a full-line comment." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
135 :type '(choice string (const nil)) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
136 :group 'fortran-comment) |
332 | 137 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
138 (defcustom fortran-minimum-statement-indent-fixed 6 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
139 "*Minimum statement indentation for fixed format continuation style." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
140 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
141 :group 'fortran-indent) |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
142 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
143 (defcustom fortran-minimum-statement-indent-tab (max tab-width 6) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
144 "*Minimum statement indentation for TAB format continuation style." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
145 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
146 :group 'fortran-indent) |
332 | 147 |
148 ;; Note that this is documented in the v18 manuals as being a string | |
149 ;; of length one rather than a single character. | |
150 ;; The code in this file accepts either format for compatibility. | |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
151 (defcustom fortran-comment-indent-char " " |
332 | 152 "*Single-character string inserted for Fortran comment indentation. |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
153 Normally a space." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
154 :type 'string |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
155 :group 'fortran-comment) |
332 | 156 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
157 (defcustom fortran-line-number-indent 1 |
332 | 158 "*Maximum indentation for Fortran line numbers. |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
159 5 means right-justify them within their five-column field." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
160 :type 'integer |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
161 :group 'fortran-indent) |
332 | 162 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
163 (defcustom fortran-check-all-num-for-matching-do nil |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
164 "*Non-nil causes all numbered lines to be treated as possible DO loop ends." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
165 :type 'boolean |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
166 :group 'fortran) |
332 | 167 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
168 (defcustom fortran-blink-matching-if nil |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
169 "*Non-nil causes \\[fortran-indent-line] on ENDIF statement to blink on matching IF. |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
170 Also, from an ENDDO statement blink on matching DO [WHILE] statement." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
171 :type 'boolean |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
172 :group 'fortran) |
332 | 173 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
174 (defcustom fortran-continuation-string "$" |
1548 | 175 "*Single-character string used for Fortran continuation lines. |
332 | 176 In fixed format continuation style, this character is inserted in |
177 column 6 by \\[fortran-split-line] to begin a continuation line. | |
178 Also, if \\[fortran-indent-line] finds this at the beginning of a line, it will | |
179 convert the line into a continuation line of the appropriate style. | |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
180 Normally $." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
181 :type 'string |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
182 :group 'fortran) |
332 | 183 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
184 (defcustom fortran-comment-region "c$$$" |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
185 "*String inserted by \\[fortran-comment-region] at start of each \ |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
186 line in region." |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
187 :type 'string |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
188 :group 'fortran-comment) |
332 | 189 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
190 (defcustom fortran-electric-line-number t |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
191 "*Non-nil causes line number digits to be moved to the correct \ |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
192 column as typed." |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
193 :type 'boolean |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
194 :group 'fortran) |
332 | 195 |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
196 (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
|
197 "0 4 6 10 20 30 40 5\ |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
198 0 60 70\n\ |
11516
e7c26522b881
Use new fortran-match-!-comment to do !-style fontification; do rest in regexps
Simon Marshall <simon@gnu.org>
parents:
10883
diff
changeset
|
199 \[ ]|{ | | | | | | | | \ |
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" |
21079 | 201 "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
|
202 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
|
203 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
204 (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
|
205 "0 810 20 30 40 5\ |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
206 0 60 70\n\ |
11516
e7c26522b881
Use new fortran-match-!-comment to do !-style fontification; do rest in regexps
Simon Marshall <simon@gnu.org>
parents:
10883
diff
changeset
|
207 \[ ]| { | | | | | | | | \ |
e7c26522b881
Use new fortran-match-!-comment to do !-style fontification; do rest in regexps
Simon Marshall <simon@gnu.org>
parents:
10883
diff
changeset
|
208 \| | | | |}\n" |
21079 | 209 "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
|
210 This variable used in TAB format mode.") |
332 | 211 |
212 (defvar fortran-mode-syntax-table nil | |
213 "Syntax table in use in Fortran mode buffers.") | |
214 | |
215 (defvar fortran-analyze-depth 100 | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
216 "Number of lines to scan to determine whether to use fixed or TAB \ |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
217 format style.") |
332 | 218 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
219 (defcustom fortran-break-before-delimiters t |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
220 "*Non-nil causes filling to break lines before delimiters." |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
221 :type 'boolean |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16581
diff
changeset
|
222 :group 'fortran) |
1548 | 223 |
332 | 224 (if fortran-mode-syntax-table |
225 () | |
226 (setq fortran-mode-syntax-table (make-syntax-table)) | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
227 ;; We might like `;' to be punctuation (g77 multi-statement lines), |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
228 ;; but that screws abbrevs. |
332 | 229 (modify-syntax-entry ?\; "w" fortran-mode-syntax-table) |
230 (modify-syntax-entry ?\r " " fortran-mode-syntax-table) | |
231 (modify-syntax-entry ?+ "." fortran-mode-syntax-table) | |
232 (modify-syntax-entry ?- "." fortran-mode-syntax-table) | |
233 (modify-syntax-entry ?= "." fortran-mode-syntax-table) | |
234 (modify-syntax-entry ?* "." fortran-mode-syntax-table) | |
235 (modify-syntax-entry ?/ "." fortran-mode-syntax-table) | |
236 (modify-syntax-entry ?\' "\"" fortran-mode-syntax-table) | |
237 (modify-syntax-entry ?\" "\"" fortran-mode-syntax-table) | |
25054
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
238 (modify-syntax-entry ?\\ "\\" fortran-mode-syntax-table) |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
239 ;; This might be better as punctuation, as for C, but this way you |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
240 ;; can treat floating-point numbers as symbols. |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
241 (modify-syntax-entry ?. "_" fortran-mode-syntax-table) ; e.g. `a.ne.b' |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
242 (modify-syntax-entry ?_ "_" fortran-mode-syntax-table) |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
243 (modify-syntax-entry ?$ "_" fortran-mode-syntax-table) ; esp. VMSisms |
9476
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
244 (modify-syntax-entry ?\! "<" fortran-mode-syntax-table) |
332 | 245 (modify-syntax-entry ?\n ">" fortran-mode-syntax-table)) |
246 | |
25054
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
247 ;; Comments are real pain in Fortran because there is no way to |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
248 ;; represent the standard comment syntax in an Emacs syntax table. |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
249 ;; (We can do so for F90-style). Therefore an unmatched quote in a |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
250 ;; standard comment will throw fontification off on the wrong track. |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
251 ;; So we do syntactic fontification with regexps. |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
252 |
11516
e7c26522b881
Use new fortran-match-!-comment to do !-style fontification; do rest in regexps
Simon Marshall <simon@gnu.org>
parents:
10883
diff
changeset
|
253 ;; 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
|
254 ;; 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
|
255 |
13300
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
256 (defconst fortran-font-lock-keywords-1 nil |
12386
ceccff3df349
Specify all Font Lock keywords in font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
11801
diff
changeset
|
257 "Subdued level highlighting for Fortran mode.") |
9476
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
258 |
13300
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
259 (defconst fortran-font-lock-keywords-2 nil |
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
260 "Medium level highlighting for Fortran mode.") |
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
261 |
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
262 (defconst fortran-font-lock-keywords-3 nil |
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
263 "Gaudy level highlighting for Fortran mode.") |
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
264 |
25054
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
265 (defconst fortran-font-lock-syntactic-keywords nil |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
266 "`font-lock-syntactic-keywords' for Fortran. |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
267 These get fixed-format comments fontified.") |
23616
17ebfb12712f
Fix for fontification of strings lost
Dave Love <fx@gnu.org>
parents:
23607
diff
changeset
|
268 |
25054
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
269 (let ((comment-chars "cd") ; `d' for `debugging' comments |
21575
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
270 (fortran-type-types |
24125
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
271 (eval-when-compile |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
272 (let ((re (regexp-opt |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
273 (let ((simple-types |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
274 '("character" "byte" "integer" "logical" |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
275 "none" "real" "complex" |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
276 "double precision" "double complex")) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
277 (structured-types '("structure" "union" "map")) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
278 (other-types '("record" "dimension" |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
279 "parameter" "common" "save" |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
280 "external" "intrinsic" "data" |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
281 "equivalence"))) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
282 (append |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
283 (mapcar (lambda (x) (concat "implicit " x)) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
284 simple-types) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
285 simple-types |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
286 (mapcar (lambda (x) (concat "end " x)) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
287 structured-types) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
288 structured-types |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
289 other-types))))) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
290 ;; In the optimized regexp above, replace spaces by regexp |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
291 ;; for optional whitespace, which regexp-opt would have |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
292 ;; escaped. |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
293 (mapconcat #'identity (split-string re) "[ \t]*")))) |
21575
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
294 (fortran-keywords |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
295 (eval-when-compile |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
296 (regexp-opt '("continue" "format" "end" "enddo" "if" "then" |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
297 "else" "endif" "elseif" "while" "inquire" "stop" |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
298 "return" "include" "open" "close" "read" "write" |
23463 | 299 "format" "print" "select" "case" "cycle" "exit")))) |
21575
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
300 (fortran-logicals |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
301 (eval-when-compile |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
302 (regexp-opt '("and" "or" "not" "lt" "le" "eq" "ge" "gt" "ne" |
21575
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
303 "true" "false"))))) |
9476
59901c9aa208
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
Simon Marshall <simon@gnu.org>
parents:
7888
diff
changeset
|
304 |
25054
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
305 (setq fortran-font-lock-syntactic-keywords |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
306 ;; Fixed format comments. (!-style handled normally.) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
307 (list |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
308 (list (concat "^[" comment-chars "]") 0 '(11)) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
309 (list (concat "^[^" comment-chars "\t\n]" (make-string 71 ?.) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
310 "\\([^\n]+\\)") |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
311 1 '(11)))) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
312 |
21575
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
313 (setq fortran-font-lock-keywords-1 |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
314 (list |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
315 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
316 ;; Program, subroutine and function declarations, plus calls. |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
317 (list (concat "\\<\\(block[ \t]*data\\|call\\|entry\\|function\\|" |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
318 "program\\|subroutine\\)\\>[ \t]*\\(\\sw+\\)?") |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
319 '(1 font-lock-keyword-face) |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
320 '(2 font-lock-function-name-face nil t)))) |
13300
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
321 |
21575
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
322 (setq fortran-font-lock-keywords-2 |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
323 (append fortran-font-lock-keywords-1 |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
324 (list |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
325 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
326 ;; Fontify all type specifiers (must be first; see below). |
23754 | 327 (cons (concat "\\<\\(" fortran-type-types "\\)\\>") |
21575
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
328 'font-lock-type-face) |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
329 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
330 ;; Fontify all builtin keywords (except logical, do |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
331 ;; and goto; see below). |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
332 (concat "\\<\\(" fortran-keywords "\\)\\>") |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
333 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
334 ;; Fontify all builtin operators. |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
335 (concat "\\.\\(" fortran-logicals "\\)\\.") |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
336 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
337 ;; Fontify do/goto keywords and targets, and goto tags. |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
338 (list "\\<\\(do\\|go *to\\)\\>[ \t]*\\([0-9]+\\)?" |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
339 '(1 font-lock-keyword-face) |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
340 '(2 font-lock-constant-face nil t)) |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
341 (cons "^ *\\([0-9]+\\)" 'font-lock-constant-face)))) |
13300
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
342 |
21575
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
343 (setq fortran-font-lock-keywords-3 |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
344 (append |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
345 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
346 ;; The list `fortran-font-lock-keywords-1'. |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
347 fortran-font-lock-keywords-1 |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
348 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
349 ;; Fontify all type specifiers plus their declared items. |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
350 (list |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
351 (list (concat "\\<\\(" fortran-type-types "\\)\\>[ \t(/]*\\(*\\)?") |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
352 ;; Fontify the type specifier. |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
353 '(1 font-lock-type-face) |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
354 ;; Fontify each declaration item (or just the /.../ block name). |
24125
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
355 `(font-lock-match-c-style-declaration-item-and-skip-to-next |
21575
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
356 ;; Start after any *(...) expression. |
24125
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
357 (condition-case nil |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
358 (and (and (match-beginning ,(+ 2 (regexp-opt-depth |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
359 fortran-type-types))) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
360 (forward-sexp)) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
361 (forward-sexp)) |
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
362 (error nil)) |
21575
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
363 ;; No need to clean up. |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
364 nil |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
365 ;; Fontify as a variable name, functions are |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
366 ;; fontified elsewhere. |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
367 (1 font-lock-variable-name-face nil t)))) |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
368 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
369 ;; Things extra to `fortran-font-lock-keywords-3' |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
370 ;; (must be done first). |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
371 (list |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
372 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
373 ;; Fontify goto-like `err=label'/`end=label' in read/write |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
374 ;; statements. |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
375 '(", *\\(e\\(nd\\|rr\\)\\)\\> *\\(= *\\([0-9]+\\)\\)?" |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
376 (1 font-lock-keyword-face) (4 font-lock-constant-face nil t)) |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
377 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
378 ;; Highlight standard continuation character and in a |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
379 ;; TAB-formatted line. |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
380 '("^ \\([^ 0]\\)" 1 font-lock-string-face) |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
381 '("^\t\\([1-9]\\)" 1 font-lock-string-face)) |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
382 ;; |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
383 ;; The list `fortran-font-lock-keywords-2' less that for types |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
384 ;; (see above). |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
385 (cdr (nthcdr (length fortran-font-lock-keywords-1) |
6300c1c645da
Move eval-when-compile off top level.
Dave Love <fx@gnu.org>
parents:
21538
diff
changeset
|
386 fortran-font-lock-keywords-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
|
387 |
12386
ceccff3df349
Specify all Font Lock keywords in font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
11801
diff
changeset
|
388 (defvar fortran-font-lock-keywords fortran-font-lock-keywords-1 |
ceccff3df349
Specify all Font Lock keywords in font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
11801
diff
changeset
|
389 "Default expressions to highlight in Fortran mode.") |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
390 |
20205
cdaddfc03fe8
(fortran-imenu-generic-expression): New variable.
Dave Love <fx@gnu.org>
parents:
17413
diff
changeset
|
391 (defvar fortran-imenu-generic-expression |
20277
b7f5af6127d5
(fortran-imenu-generic-expression): Match
Dave Love <fx@gnu.org>
parents:
20207
diff
changeset
|
392 ;; These patterns could be confused by sequence nos. in cols 72+ and |
b7f5af6127d5
(fortran-imenu-generic-expression): Match
Dave Love <fx@gnu.org>
parents:
20207
diff
changeset
|
393 ;; don't allow continuations everywhere. |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
394 (list |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
395 (list |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
396 nil |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
397 ;; Lines below are: 1. leading whitespace; 2. function |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
398 ;; declaration with optional type, e.g. `real', `real*4', |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
399 ;; character(*), `double precision' and possible statement |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
400 ;; continuation; 3. untyped declarations; 4. the variable to |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
401 ;; index. [This will be fooled by `end function' allowed by G77. |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
402 ;; Also, it assumes sensible whitespace is employed.] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
403 (concat "^\\s-+\\(\ |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
404 \\(\\sw\\|\\s-\\|[*()+]\\)*\ |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
405 \\<function\\|subroutine\\|entry\\|block\\s-*data\\|program\\)\ |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
406 [ \t" fortran-continuation-string "]+\ |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
407 \\(\\sw+\\)") |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
408 3) |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
409 ;; Un-named block data |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
410 (list nil "^\\s-+\\(block\\s-*data\\)\\s-*$" 1)) |
23754 | 411 "Imenu generic expression for `imenu-default-create-index-function'.") |
13300
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
412 |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
413 (defvar fortran-mode-map () |
1548 | 414 "Keymap used in Fortran mode.") |
332 | 415 (if fortran-mode-map |
416 () | |
417 (setq fortran-mode-map (make-sparse-keymap)) | |
418 (define-key fortran-mode-map ";" 'fortran-abbrev-start) | |
419 (define-key fortran-mode-map "\C-c;" 'fortran-comment-region) | |
21804
7f5f52632d41
(fortran-mode-map): Bind M-^. Use \M-, not \e elsewhere.
Dave Love <fx@gnu.org>
parents:
21575
diff
changeset
|
420 (define-key fortran-mode-map "\M-\C-a" 'beginning-of-fortran-subprogram) |
7f5f52632d41
(fortran-mode-map): Bind M-^. Use \M-, not \e elsewhere.
Dave Love <fx@gnu.org>
parents:
21575
diff
changeset
|
421 (define-key fortran-mode-map "\M-\C-e" 'end-of-fortran-subprogram) |
7f5f52632d41
(fortran-mode-map): Bind M-^. Use \M-, not \e elsewhere.
Dave Love <fx@gnu.org>
parents:
21575
diff
changeset
|
422 (define-key fortran-mode-map "\M-;" 'fortran-indent-comment) |
7f5f52632d41
(fortran-mode-map): Bind M-^. Use \M-, not \e elsewhere.
Dave Love <fx@gnu.org>
parents:
21575
diff
changeset
|
423 (define-key fortran-mode-map "\M-\C-h" 'mark-fortran-subprogram) |
7f5f52632d41
(fortran-mode-map): Bind M-^. Use \M-, not \e elsewhere.
Dave Love <fx@gnu.org>
parents:
21575
diff
changeset
|
424 (define-key fortran-mode-map "\M-\n" 'fortran-split-line) |
3567
2ca5f216e445
(fortran-indent-new-line): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
3400
diff
changeset
|
425 (define-key fortran-mode-map "\n" 'fortran-indent-new-line) |
21804
7f5f52632d41
(fortran-mode-map): Bind M-^. Use \M-, not \e elsewhere.
Dave Love <fx@gnu.org>
parents:
21575
diff
changeset
|
426 (define-key fortran-mode-map "\M-\C-q" 'fortran-indent-subprogram) |
332 | 427 (define-key fortran-mode-map "\C-c\C-w" 'fortran-window-create-momentarily) |
428 (define-key fortran-mode-map "\C-c\C-r" 'fortran-column-ruler) | |
429 (define-key fortran-mode-map "\C-c\C-p" 'fortran-previous-statement) | |
430 (define-key fortran-mode-map "\C-c\C-n" 'fortran-next-statement) | |
21804
7f5f52632d41
(fortran-mode-map): Bind M-^. Use \M-, not \e elsewhere.
Dave Love <fx@gnu.org>
parents:
21575
diff
changeset
|
431 (define-key fortran-mode-map "\C-c\C-d" 'fortran-join-line) ; like f90 |
22663
54d865200af8
(fortran-mode-map) <menu>: Tweak the imenu
Dave Love <fx@gnu.org>
parents:
22377
diff
changeset
|
432 (define-key fortran-mode-map "\M-^" 'fortran-join-line) ; subvert delete-indentation |
21079 | 433 (define-key fortran-mode-map "\C-xnd" 'fortran-narrow-to-subprogram) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
434 ;(define-key fortran-mode-map "\t" 'fortran-indent-line) |
332 | 435 (define-key fortran-mode-map "0" 'fortran-electric-line-number) |
436 (define-key fortran-mode-map "1" 'fortran-electric-line-number) | |
437 (define-key fortran-mode-map "2" 'fortran-electric-line-number) | |
438 (define-key fortran-mode-map "3" 'fortran-electric-line-number) | |
439 (define-key fortran-mode-map "4" 'fortran-electric-line-number) | |
440 (define-key fortran-mode-map "5" 'fortran-electric-line-number) | |
441 (define-key fortran-mode-map "6" 'fortran-electric-line-number) | |
442 (define-key fortran-mode-map "7" 'fortran-electric-line-number) | |
443 (define-key fortran-mode-map "8" 'fortran-electric-line-number) | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
444 (define-key fortran-mode-map "9" 'fortran-electric-line-number) |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
445 |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
446 ;; Menu |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
447 (unless (boundp 'fortran-mode-menu) |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
448 (easy-menu-define |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
449 fortran-mode-menu fortran-mode-map "" |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
450 '("Fortran" |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
451 ["Toggle Auto-fill" fortran-auto-fill-mode :style toggle |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
452 :selected (eq auto-fill-function 'fortran-do-auto-fill)] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
453 ["Toggle abbrev-mode" abbrev-mode :style toggle :selected abbrev-mode] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
454 "----" |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
455 ["Comment-out Region" fortran-comment-region mark-active] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
456 ["Uncomment-out region" |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
457 (fortran-comment-region (region-beginning) (region-end) 1) |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
458 mark-active] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
459 ["Indent Region" indent-region mark-active] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
460 ["Indent Subprogram" fortran-indent-subprogram t] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
461 "----" |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
462 ["Beginning of Subprogram" beginning-of-fortran-subprogram t] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
463 ["End of Subprogram" end-of-fortran-subprogram t] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
464 ("Mark" |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
465 ["Subprogram" mark-fortran-subprogram t] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
466 ["IF Block" fortran-mark-if t] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
467 ["DO Block" fortran-mark-do t]) |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
468 ["Narrow to Subprogram" fortran-narrow-to-subprogram t] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
469 ["Widen" widen t] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
470 "----" |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
471 ["Temporary column ruler" fortran-column-ruler t] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
472 ["72-column window" fortran-window-create t] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
473 ["Full Width Window" |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
474 (enlarge-window-horizontally (- (frame-width) (window-width))) |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
475 (< (window-width) (frame-width))] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
476 ["Momentary 72-column window" fortran-window-create-momentarily t] |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
477 "----" |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
478 ["Break Line at Point" fortran-split-line t] |
23463 | 479 ["Join Line" fortran-join-line t] |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
480 ["Fill Statement/Comment" fill-paragraph t] |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
481 "----" |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
482 ["Add imenu menu" |
22663
54d865200af8
(fortran-mode-map) <menu>: Tweak the imenu
Dave Love <fx@gnu.org>
parents:
22377
diff
changeset
|
483 (progn (imenu-add-menubar-index) |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
484 ;; Prod menu bar to update -- is this the right way? |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
485 (menu-bar-mode 1)) |
22663
54d865200af8
(fortran-mode-map) <menu>: Tweak the imenu
Dave Love <fx@gnu.org>
parents:
22377
diff
changeset
|
486 (not (and (boundp 'imenu--index-alist) |
54d865200af8
(fortran-mode-map) <menu>: Tweak the imenu
Dave Love <fx@gnu.org>
parents:
22377
diff
changeset
|
487 imenu--index-alist))])))) |
332 | 488 |
489 (defvar fortran-mode-abbrev-table nil) | |
490 (if fortran-mode-abbrev-table | |
491 () | |
492 (let ((ac abbrevs-changed)) | |
493 (define-abbrev-table 'fortran-mode-abbrev-table ()) | |
494 (define-abbrev fortran-mode-abbrev-table ";au" "automatic" nil) | |
495 (define-abbrev fortran-mode-abbrev-table ";b" "byte" nil) | |
1548 | 496 (define-abbrev fortran-mode-abbrev-table ";bd" "block data" nil) |
332 | 497 (define-abbrev fortran-mode-abbrev-table ";ch" "character" nil) |
498 (define-abbrev fortran-mode-abbrev-table ";cl" "close" nil) | |
499 (define-abbrev fortran-mode-abbrev-table ";c" "continue" nil) | |
500 (define-abbrev fortran-mode-abbrev-table ";cm" "common" nil) | |
501 (define-abbrev fortran-mode-abbrev-table ";cx" "complex" nil) | |
502 (define-abbrev fortran-mode-abbrev-table ";df" "define" nil) | |
503 (define-abbrev fortran-mode-abbrev-table ";di" "dimension" nil) | |
504 (define-abbrev fortran-mode-abbrev-table ";do" "double" nil) | |
505 (define-abbrev fortran-mode-abbrev-table ";dc" "double complex" nil) | |
506 (define-abbrev fortran-mode-abbrev-table ";dp" "double precision" nil) | |
507 (define-abbrev fortran-mode-abbrev-table ";dw" "do while" nil) | |
508 (define-abbrev fortran-mode-abbrev-table ";e" "else" nil) | |
509 (define-abbrev fortran-mode-abbrev-table ";ed" "enddo" nil) | |
510 (define-abbrev fortran-mode-abbrev-table ";el" "elseif" nil) | |
511 (define-abbrev fortran-mode-abbrev-table ";en" "endif" nil) | |
512 (define-abbrev fortran-mode-abbrev-table ";eq" "equivalence" nil) | |
1548 | 513 (define-abbrev fortran-mode-abbrev-table ";ew" "endwhere" nil) |
332 | 514 (define-abbrev fortran-mode-abbrev-table ";ex" "external" nil) |
515 (define-abbrev fortran-mode-abbrev-table ";ey" "entry" nil) | |
516 (define-abbrev fortran-mode-abbrev-table ";f" "format" nil) | |
517 (define-abbrev fortran-mode-abbrev-table ";fa" ".false." nil) | |
518 (define-abbrev fortran-mode-abbrev-table ";fu" "function" nil) | |
519 (define-abbrev fortran-mode-abbrev-table ";g" "goto" nil) | |
520 (define-abbrev fortran-mode-abbrev-table ";im" "implicit" nil) | |
521 (define-abbrev fortran-mode-abbrev-table ";ib" "implicit byte" nil) | |
522 (define-abbrev fortran-mode-abbrev-table ";ic" "implicit complex" nil) | |
523 (define-abbrev fortran-mode-abbrev-table ";ich" "implicit character" nil) | |
524 (define-abbrev fortran-mode-abbrev-table ";ii" "implicit integer" nil) | |
525 (define-abbrev fortran-mode-abbrev-table ";il" "implicit logical" nil) | |
526 (define-abbrev fortran-mode-abbrev-table ";ir" "implicit real" nil) | |
527 (define-abbrev fortran-mode-abbrev-table ";inc" "include" nil) | |
528 (define-abbrev fortran-mode-abbrev-table ";in" "integer" nil) | |
529 (define-abbrev fortran-mode-abbrev-table ";intr" "intrinsic" nil) | |
530 (define-abbrev fortran-mode-abbrev-table ";l" "logical" nil) | |
531 (define-abbrev fortran-mode-abbrev-table ";n" "namelist" nil) | |
532 (define-abbrev fortran-mode-abbrev-table ";o" "open" nil) ; was ;op | |
533 (define-abbrev fortran-mode-abbrev-table ";pa" "parameter" nil) | |
534 (define-abbrev fortran-mode-abbrev-table ";pr" "program" nil) | |
535 (define-abbrev fortran-mode-abbrev-table ";ps" "pause" nil) | |
536 (define-abbrev fortran-mode-abbrev-table ";p" "print" nil) | |
537 (define-abbrev fortran-mode-abbrev-table ";rc" "record" nil) | |
538 (define-abbrev fortran-mode-abbrev-table ";re" "real" nil) | |
539 (define-abbrev fortran-mode-abbrev-table ";r" "read" nil) | |
540 (define-abbrev fortran-mode-abbrev-table ";rt" "return" nil) | |
541 (define-abbrev fortran-mode-abbrev-table ";rw" "rewind" nil) | |
542 (define-abbrev fortran-mode-abbrev-table ";s" "stop" nil) | |
543 (define-abbrev fortran-mode-abbrev-table ";sa" "save" nil) | |
544 (define-abbrev fortran-mode-abbrev-table ";st" "structure" nil) | |
545 (define-abbrev fortran-mode-abbrev-table ";sc" "static" nil) | |
546 (define-abbrev fortran-mode-abbrev-table ";su" "subroutine" nil) | |
547 (define-abbrev fortran-mode-abbrev-table ";tr" ".true." nil) | |
548 (define-abbrev fortran-mode-abbrev-table ";ty" "type" nil) | |
549 (define-abbrev fortran-mode-abbrev-table ";vo" "volatile" nil) | |
550 (define-abbrev fortran-mode-abbrev-table ";w" "write" nil) | |
1548 | 551 (define-abbrev fortran-mode-abbrev-table ";wh" "where" nil) |
332 | 552 (setq abbrevs-changed ac))) |
553 | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
554 (eval-when-compile ; silence compiler |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
555 (defvar imenu-case-fold-search) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
556 (defvar imenu-syntax-alist)) |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
557 |
332 | 558 ;;;###autoload |
559 (defun fortran-mode () | |
1548 | 560 "Major mode for editing Fortran code. |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
561 \\[fortran-indent-line] indents the current Fortran line correctly. |
1548 | 562 DO statements must not share a common CONTINUE. |
332 | 563 |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
564 Type ;? or ;\\[help-command] to display a list of built-in abbrevs for |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
565 Fortran keywords. |
332 | 566 |
567 Key definitions: | |
568 \\{fortran-mode-map} | |
569 | |
570 Variables controlling indentation style and extra features: | |
571 | |
23754 | 572 `comment-start' |
332 | 573 Normally nil in Fortran mode. If you want to use comments |
574 starting with `!', set this to the string \"!\". | |
23754 | 575 `fortran-do-indent' |
332 | 576 Extra indentation within do blocks. (default 3) |
23754 | 577 `fortran-if-indent' |
332 | 578 Extra indentation within if blocks. (default 3) |
23754 | 579 `fortran-structure-indent' |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
580 Extra indentation within structure, union, map and interface blocks. |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
581 (default 3) |
23754 | 582 `fortran-continuation-indent' |
1548 | 583 Extra indentation applied to continuation statements. (default 5) |
23754 | 584 `fortran-comment-line-extra-indent' |
585 Amount of extra indentation for text within full-line comments. (default 0) | |
586 `fortran-comment-indent-style' | |
332 | 587 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
|
588 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
|
589 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
|
590 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
|
591 (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
|
592 relative means indent at `fortran-comment-line-extra-indent' beyond the |
332 | 593 indentation for a line of code. |
594 (default 'fixed) | |
23754 | 595 `fortran-comment-indent-char' |
1548 | 596 Single-character string to be inserted instead of space for |
332 | 597 full-line comment indentation. (default \" \") |
23754 | 598 `fortran-minimum-statement-indent-fixed' |
599 Minimum indentation for Fortran statements in fixed format mode. (def.6) | |
600 `fortran-minimum-statement-indent-tab' | |
601 Minimum indentation for Fortran statements in TAB format mode. (default 9) | |
602 `fortran-line-number-indent' | |
332 | 603 Maximum indentation for line numbers. A line number will get |
604 less than this much indentation if necessary to avoid reaching | |
605 column 5. (default 1) | |
23754 | 606 `fortran-check-all-num-for-matching-do' |
1548 | 607 Non-nil causes all numbered lines to be treated as possible \"continue\" |
332 | 608 statements. (default nil) |
23754 | 609 `fortran-blink-matching-if' |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
610 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
|
611 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
|
612 statement. (default nil) |
23754 | 613 `fortran-continuation-string' |
332 | 614 Single-character string to be inserted in column 5 of a continuation |
615 line. (default \"$\") | |
23754 | 616 `fortran-comment-region' |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
617 String inserted by \\[fortran-comment-region] at start of each line in |
332 | 618 region. (default \"c$$$\") |
23754 | 619 `fortran-electric-line-number' |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
620 Non-nil causes line number digits to be moved to the correct column |
332 | 621 as typed. (default t) |
23754 | 622 `fortran-break-before-delimiters' |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
623 Non-nil causes `fortran-fill' to break lines before delimiters. |
1548 | 624 (default t) |
332 | 625 |
1548 | 626 Turning on Fortran mode calls the value of the variable `fortran-mode-hook' |
332 | 627 with no args, if that value is non-nil." |
628 (interactive) | |
629 (kill-all-local-variables) | |
630 (setq local-abbrev-table fortran-mode-abbrev-table) | |
631 (set-syntax-table fortran-mode-syntax-table) | |
12386
ceccff3df349
Specify all Font Lock keywords in font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
11801
diff
changeset
|
632 ;; Font Lock mode support. |
13300
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
633 (make-local-variable 'font-lock-defaults) |
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
634 (setq font-lock-defaults '((fortran-font-lock-keywords |
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
635 fortran-font-lock-keywords-1 |
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
636 fortran-font-lock-keywords-2 |
73b7a6396cbe
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
Simon Marshall <simon@gnu.org>
parents:
12814
diff
changeset
|
637 fortran-font-lock-keywords-3) |
25054
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
638 nil t ((?/ . "$/") ("_$" . "w")) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
639 beginning-of-fortran-subprogram)) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
640 (set (make-local-variable 'font-lock-syntactic-keywords) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
641 fortran-font-lock-syntactic-keywords) |
1548 | 642 (make-local-variable 'fortran-break-before-delimiters) |
643 (setq fortran-break-before-delimiters t) | |
332 | 644 (make-local-variable 'indent-line-function) |
645 (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
|
646 (make-local-variable 'comment-indent-function) |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2028
diff
changeset
|
647 (setq comment-indent-function 'fortran-comment-hook) |
332 | 648 (make-local-variable 'comment-line-start-skip) |
649 (setq comment-line-start-skip | |
1548 | 650 "^[Cc*]\\(\\([^ \t\n]\\)\\2\\2*\\)?[ \t]*\\|^#.*") |
332 | 651 (make-local-variable 'comment-line-start) |
652 (setq comment-line-start "c") | |
653 (make-local-variable 'comment-start-skip) | |
654 (setq comment-start-skip "![ \t]*") | |
655 (make-local-variable 'comment-start) | |
656 (setq comment-start nil) | |
657 (make-local-variable 'require-final-newline) | |
658 (setq require-final-newline t) | |
659 (make-local-variable 'abbrev-all-caps) | |
660 (setq abbrev-all-caps t) | |
661 (make-local-variable 'indent-tabs-mode) | |
662 (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
|
663 ;;;(setq abbrev-mode t) ; ?? (abbrev-mode 1) instead?? |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
664 (set (make-local-variable 'fill-column) 72) |
332 | 665 (use-local-map fortran-mode-map) |
666 (setq mode-name "Fortran") | |
667 (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
|
668 (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
|
669 (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
|
670 (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
|
671 (make-local-variable 'fortran-column-ruler-fixed) |
23754 | 672 (make-local-variable 'fortran-column-ruler-tab) |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
673 (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
|
674 (setq indent-tabs-mode (fortran-analyze-file-format)) |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
675 (setq imenu-case-fold-search t) |
20205
cdaddfc03fe8
(fortran-imenu-generic-expression): New variable.
Dave Love <fx@gnu.org>
parents:
17413
diff
changeset
|
676 (make-local-variable 'imenu-generic-expression) |
cdaddfc03fe8
(fortran-imenu-generic-expression): New variable.
Dave Love <fx@gnu.org>
parents:
17413
diff
changeset
|
677 (setq imenu-generic-expression fortran-imenu-generic-expression) |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
678 (setq imenu-syntax-alist '(("_$" . "w"))) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
679 (set (make-local-variable 'fill-paragraph-function) 'fortran-fill-paragraph) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
680 (set (make-local-variable 'indent-line-function) 'fortran-indent-line) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
681 (set (make-local-variable 'indent-region-function) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
682 (lambda (start end) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
683 (let (fortran-blink-matching-if ; avoid blinking delay |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
684 indent-region-function) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
685 (indent-region start end nil)))) |
332 | 686 (run-hooks 'fortran-mode-hook)) |
687 | |
688 (defun fortran-comment-hook () | |
689 (save-excursion | |
690 (skip-chars-backward " \t") | |
691 (max (+ 1 (current-column)) | |
692 comment-column))) | |
693 | |
694 (defun fortran-indent-comment () | |
695 "Align or create comment on current line. | |
696 Existing comments of all types are recognized and aligned. | |
697 If the line has no comment, a side-by-side comment is inserted and aligned | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
698 if the value of `comment-start' is not nil. |
332 | 699 Otherwise, a separate-line comment is inserted, on this line |
700 or on a new line inserted before this line if this line is not blank." | |
701 (interactive) | |
702 (beginning-of-line) | |
703 ;; Recognize existing comments of either kind. | |
704 (cond ((looking-at comment-line-start-skip) | |
705 (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
|
706 ((fortran-find-comment-start-skip) ; catches any inline comment and |
1548 | 707 ; leaves point after comment-start-skip |
708 (if comment-start-skip | |
709 (progn (goto-char (match-beginning 0)) | |
710 (if (not (= (current-column) (fortran-comment-hook))) | |
711 (progn (delete-horizontal-space) | |
712 (indent-to (fortran-comment-hook))))) | |
713 (end-of-line))) ; otherwise goto end of line or sth else? | |
332 | 714 ;; No existing comment. |
715 ;; If side-by-side comments are defined, insert one, | |
716 ;; unless line is now blank. | |
717 ((and comment-start (not (looking-at "^[ \t]*$"))) | |
718 (end-of-line) | |
719 (delete-horizontal-space) | |
720 (indent-to (fortran-comment-hook)) | |
721 (insert comment-start)) | |
722 ;; Else insert separate-line comment, making a new line if nec. | |
723 (t | |
724 (if (looking-at "^[ \t]*$") | |
725 (delete-horizontal-space) | |
726 (beginning-of-line) | |
727 (insert "\n") | |
728 (forward-char -1)) | |
729 (insert comment-line-start) | |
730 (insert-char (if (stringp fortran-comment-indent-char) | |
731 (aref fortran-comment-indent-char 0) | |
1548 | 732 fortran-comment-indent-char) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
733 (- (fortran-calculate-indent) (current-column)))))) |
332 | 734 |
735 (defun fortran-comment-region (beg-region end-region arg) | |
736 "Comments every line in the region. | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
737 Puts `fortran-comment-region' at the beginning of every line in the region. |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
738 BEG-REGION and END-REGION are args which specify the region boundaries. |
332 | 739 With non-nil ARG, uncomments the region." |
740 (interactive "*r\nP") | |
741 (let ((end-region-mark (make-marker)) (save-point (point-marker))) | |
742 (set-marker end-region-mark end-region) | |
743 (goto-char beg-region) | |
744 (beginning-of-line) | |
745 (if (not arg) ;comment the region | |
746 (progn (insert fortran-comment-region) | |
747 (while (and (= (forward-line 1) 0) | |
748 (< (point) end-region-mark)) | |
749 (insert fortran-comment-region))) | |
750 (let ((com (regexp-quote fortran-comment-region))) ;uncomment the region | |
751 (if (looking-at com) | |
752 (delete-region (point) (match-end 0))) | |
753 (while (and (= (forward-line 1) 0) | |
754 (< (point) end-region-mark)) | |
755 (if (looking-at com) | |
756 (delete-region (point) (match-end 0)))))) | |
757 (goto-char save-point) | |
758 (set-marker end-region-mark nil) | |
759 (set-marker save-point nil))) | |
760 | |
761 (defun fortran-abbrev-start () | |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
762 "Typing ;\\[help-command] or ;? lists all the Fortran abbrevs. |
332 | 763 Any other key combination is executed normally." |
764 (interactive) | |
765 (let (c) | |
766 (insert last-command-char) | |
2028
87f2d4cbbaf4
(fortran-abbrev-start): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1862
diff
changeset
|
767 (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
|
768 (eq c help-char)) |
332 | 769 (fortran-abbrev-help) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1633
diff
changeset
|
770 (setq unread-command-events (list c))))) |
332 | 771 |
772 (defun fortran-abbrev-help () | |
773 "List the currently defined abbrevs in Fortran mode." | |
774 (interactive) | |
775 (message "Listing abbrev table...") | |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
776 (display-buffer (fortran-prepare-abbrev-list-buffer)) |
332 | 777 (message "Listing abbrev table...done")) |
778 | |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
779 (defun fortran-prepare-abbrev-list-buffer () |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
780 (save-excursion |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
781 (set-buffer (get-buffer-create "*Abbrevs*")) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
782 (erase-buffer) |
1862
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
783 (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
|
784 (goto-char (point-min)) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
785 (set-buffer-modified-p nil) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
786 (edit-abbrevs-mode)) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
787 (get-buffer-create "*Abbrevs*")) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
788 |
332 | 789 (defun fortran-column-ruler () |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
790 "Insert 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
|
791 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
|
792 format mode, and `fortran-column-ruler-tab' when in TAB format mode. |
332 | 793 The key typed is executed unless it is SPC." |
794 (interactive) | |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
795 (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
|
796 (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
|
797 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
|
798 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
|
799 (save-excursion |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
800 (beginning-of-line) |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
801 (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
|
802 (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
|
803 (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
|
804 (point))) |
332 | 805 nil "Type SPC or any command to erase ruler.")) |
806 | |
807 (defun fortran-window-create () | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
808 "Make the window 72 columns wide. |
1475 | 809 See also `fortran-window-create-momentarily'." |
332 | 810 (interactive) |
811 (condition-case error | |
812 (progn | |
813 (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
|
814 (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
|
815 (enlarge-window-horizontally (- (frame-width) |
332 | 816 (window-width) 1))) |
24012
c41f8acc111c
(fortran-window-create): Account for scroll
Dave Love <fx@gnu.org>
parents:
23861
diff
changeset
|
817 (let* ((window-edges (window-edges)) |
c41f8acc111c
(fortran-window-create): Account for scroll
Dave Love <fx@gnu.org>
parents:
23861
diff
changeset
|
818 (scroll-bar-width (- (nth 2 window-edges) |
c41f8acc111c
(fortran-window-create): Account for scroll
Dave Love <fx@gnu.org>
parents:
23861
diff
changeset
|
819 (car window-edges) |
c41f8acc111c
(fortran-window-create): Account for scroll
Dave Love <fx@gnu.org>
parents:
23861
diff
changeset
|
820 (window-width)))) |
c41f8acc111c
(fortran-window-create): Account for scroll
Dave Love <fx@gnu.org>
parents:
23861
diff
changeset
|
821 (split-window-horizontally (+ 72 scroll-bar-width))) |
332 | 822 (other-window 1) |
823 (switch-to-buffer " fortran-window-extra" t) | |
824 (select-window (previous-window)))) | |
1548 | 825 (error (message "No room for Fortran window.") |
332 | 826 'error))) |
827 | |
828 (defun fortran-window-create-momentarily (&optional arg) | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
829 "Momentarily make the window 72 columns wide. |
332 | 830 Optional ARG non-nil and non-unity disables the momentary feature. |
1475 | 831 See also `fortran-window-create'." |
332 | 832 (interactive "p") |
833 (if (or (not arg) | |
834 (= arg 1)) | |
835 (save-window-excursion | |
836 (if (not (equal (fortran-window-create) 'error)) | |
837 (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
|
838 (let ((char (read-event))) |
332 | 839 (or (equal char (string-to-char " ")) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1633
diff
changeset
|
840 (setq unread-command-events (list char))))))) |
332 | 841 (fortran-window-create))) |
842 | |
843 (defun fortran-split-line () | |
844 "Break line at point and insert continuation marker and alignment." | |
845 (interactive) | |
846 (delete-horizontal-space) | |
847 (if (save-excursion (beginning-of-line) (looking-at comment-line-start-skip)) | |
848 (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
|
849 (if indent-tabs-mode |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
850 (insert "\n\t" (fortran-numerical-continuation-char)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
851 (insert "\n " fortran-continuation-string))) ; Space after \n important |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
852 (fortran-indent-line)) ; when the cont string is C, c or *. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
853 |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
854 (defun fortran-remove-continuation () |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
855 (if (looking-at "\\( [^ 0\n]\\|\t[1-9]\\|&\\)") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
856 (progn (replace-match "") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
857 (delete-indentation) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
858 t))) |
332 | 859 |
23463 | 860 (defun fortran-join-line (arg) |
861 "Join current line to the previous one and re-indent. | |
862 With a prefix argument, repeat this operation that many times. | |
863 If the prefix argument ARG is negative, join the next -ARG lines. | |
864 Continuation lines are correctly handled." | |
865 (interactive "*p") | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
866 (save-excursion |
23463 | 867 (when (> 0 arg) |
868 (setq arg (- arg)) | |
869 (forward-line arg)) | |
870 (while (not (zerop arg)) | |
871 (beginning-of-line) | |
872 (or (fortran-remove-continuation) | |
873 (delete-indentation)) | |
874 (setq arg (1- arg))) | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
875 (fortran-indent-line))) |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
876 |
332 | 877 (defun fortran-numerical-continuation-char () |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
878 "Return a digit for tab-digit style of continuation lines. |
332 | 879 If, previous line is a tab-digit continuation line, returns that digit |
880 plus one. Otherwise return 1. Zero not allowed." | |
881 (save-excursion | |
882 (forward-line -1) | |
883 (if (looking-at "\t[1-9]") | |
884 (+ ?1 (% (- (char-after (+ (point) 1)) ?0) 9)) | |
885 ?1))) | |
886 | |
887 (defun delete-horizontal-regexp (chars) | |
888 "Delete all characters in CHARS around point. | |
889 CHARS is like the inside of a [...] in a regular expression | |
890 except that ] is never special and \ quotes ^, - or \." | |
891 (interactive "*s") | |
892 (skip-chars-backward chars) | |
893 (delete-region (point) (progn (skip-chars-forward chars) (point)))) | |
894 | |
22377
24999a02843d
(fortran-electric-line-number): Add delete-selection property.
Richard M. Stallman <rms@gnu.org>
parents:
21804
diff
changeset
|
895 (put 'fortran-electric-line-number 'delete-selection t) |
332 | 896 (defun fortran-electric-line-number (arg) |
897 "Self insert, but if part of a Fortran line number indent it automatically. | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
898 Auto-indent does not happen if a numeric ARG is used." |
332 | 899 (interactive "P") |
900 (if (or arg (not fortran-electric-line-number)) | |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
901 (if arg |
1548 | 902 (self-insert-command (prefix-numeric-value arg)) |
332 | 903 (self-insert-command 1)) |
904 (if (or (and (= 5 (current-column)) | |
905 (save-excursion | |
906 (beginning-of-line) | |
907 (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
|
908 (and (= (if indent-tabs-mode |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
909 fortran-minimum-statement-indent-tab |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
910 fortran-minimum-statement-indent-fixed) (current-column)) |
332 | 911 (save-excursion |
912 (beginning-of-line) | |
913 (looking-at "\t"));In col 8 with a single tab to the left. | |
914 (not (or (eq last-command 'fortran-indent-line) | |
915 (eq last-command | |
3567
2ca5f216e445
(fortran-indent-new-line): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
3400
diff
changeset
|
916 'fortran-indent-new-line)))) |
332 | 917 (save-excursion |
918 (re-search-backward "[^ \t0-9]" | |
919 (save-excursion | |
920 (beginning-of-line) | |
921 (point)) | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
922 t)) ;not a line number |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
923 (looking-at "[0-9]")) ;within a line number |
1548 | 924 (self-insert-command (prefix-numeric-value arg)) |
332 | 925 (skip-chars-backward " \t") |
926 (insert last-command-char) | |
927 (fortran-indent-line)))) | |
928 | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
929 (defvar fortran-end-prog-re1 |
23607
6b2444d06348
(fortran-end-prog-re1): Fix the regexp.
Dave Love <fx@gnu.org>
parents:
23463
diff
changeset
|
930 "end\ |
23711 | 931 \\([ \t]*\\(program\\|subroutine\\|function\\|block[ \t]*data\\)\\>\ |
932 \\([ \t]*\\(\\sw\\|\\s_\\)+\\)?\\)?") | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
933 (defvar fortran-end-prog-re |
23732 | 934 (concat "^[ \t0-9]*" fortran-end-prog-re1) |
935 "Regexp possibly marking subprogram end.") | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
936 |
23711 | 937 (defun fortran-check-end-prog-re () |
938 "Check a preliminary match against `fortran-end-prog-re'." | |
939 ;; Having got a possible match for the subprogram end, we need a | |
940 ;; match of whitespace, avoiding possible column 73+ stuff. | |
941 (save-match-data | |
23838
e494267843f7
(fortran-check-end-prog-re): Allow trailing
Dave Love <fx@gnu.org>
parents:
23754
diff
changeset
|
942 (string-match "^\\s-*\\(\\'\\|\\s<\\)" |
23711 | 943 (buffer-substring (match-end 0) |
944 (min (line-end-position) | |
945 (+ 72 (line-beginning-position))))))) | |
946 | |
947 ;; Note that you can't just check backwards for `subroutine' &c in | |
948 ;; case of un-marked main programs not at the start of the file. | |
332 | 949 (defun beginning-of-fortran-subprogram () |
1548 | 950 "Moves point to the beginning of the current Fortran subprogram." |
332 | 951 (interactive) |
25054
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
952 (save-match-data |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
953 (let ((case-fold-search t)) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
954 (beginning-of-line -1) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
955 (if (catch 'ok |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
956 (while (re-search-backward fortran-end-prog-re nil 'move) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
957 (if (fortran-check-end-prog-re) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
958 (throw 'ok t)))) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
959 (forward-line))))) |
332 | 960 |
961 (defun end-of-fortran-subprogram () | |
1548 | 962 "Moves point to the end of the current Fortran subprogram." |
332 | 963 (interactive) |
25054
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
964 (save-match-data |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
965 (let ((case-fold-search t)) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
966 (if (save-excursion ; on END |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
967 (beginning-of-line) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
968 (and (looking-at fortran-end-prog-re) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
969 (fortran-check-end-prog-re))) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
970 (forward-line) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
971 (beginning-of-line 2) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
972 (catch 'ok |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
973 (while (re-search-forward fortran-end-prog-re nil 'move) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
974 (if (fortran-check-end-prog-re) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
975 (throw 'ok t)))) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
976 (goto-char (match-beginning 0)) |
888326cb8ffb
(fortran-mode-syntax-table): Change `\' to `\'
Dave Love <fx@gnu.org>
parents:
24800
diff
changeset
|
977 (forward-line))))) |
332 | 978 |
979 (defun mark-fortran-subprogram () | |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
980 "Put mark at end of Fortran subprogram, point at beginning. |
332 | 981 The marks are pushed." |
982 (interactive) | |
983 (end-of-fortran-subprogram) | |
24254
93993abff564
(mark-fortran-subprogram): Activate mark
Dave Love <fx@gnu.org>
parents:
24125
diff
changeset
|
984 (push-mark (point) nil t) |
332 | 985 (beginning-of-fortran-subprogram)) |
1548 | 986 |
332 | 987 (defun fortran-previous-statement () |
1548 | 988 "Moves point to beginning of the previous Fortran statement. |
989 Returns `first-statement' if that statement is the first | |
332 | 990 non-comment Fortran statement in the file, and nil otherwise." |
991 (interactive) | |
992 (let (not-first-statement continue-test) | |
993 (beginning-of-line) | |
994 (setq continue-test | |
1548 | 995 (and |
996 (not (looking-at comment-line-start-skip)) | |
997 (or (looking-at | |
332 | 998 (concat "[ \t]*" (regexp-quote fortran-continuation-string))) |
1548 | 999 (or (looking-at " [^ 0\n]") |
1000 (looking-at "\t[1-9]"))))) | |
332 | 1001 (while (and (setq not-first-statement (= (forward-line -1) 0)) |
1002 (or (looking-at comment-line-start-skip) | |
1003 (looking-at "[ \t]*$") | |
1004 (looking-at " [^ 0\n]") | |
1005 (looking-at "\t[1-9]") | |
1006 (looking-at (concat "[ \t]*" comment-start-skip))))) | |
1007 (cond ((and continue-test | |
1008 (not not-first-statement)) | |
1009 (message "Incomplete continuation statement.")) | |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
1010 (continue-test |
332 | 1011 (fortran-previous-statement)) |
1012 ((not not-first-statement) | |
1013 'first-statement)))) | |
1014 | |
1015 (defun fortran-next-statement () | |
1548 | 1016 "Moves point to beginning of the next Fortran statement. |
332 | 1017 Returns `last-statement' if that statement is the last |
1018 non-comment Fortran statement in the file, and nil otherwise." | |
1019 (interactive) | |
1020 (let (not-last-statement) | |
1021 (beginning-of-line) | |
1548 | 1022 (while (and (setq not-last-statement |
1023 (and (= (forward-line 1) 0) | |
1024 (not (eobp)))) | |
332 | 1025 (or (looking-at comment-line-start-skip) |
1026 (looking-at "[ \t]*$") | |
1027 (looking-at " [^ 0\n]") | |
1028 (looking-at "\t[1-9]") | |
1029 (looking-at (concat "[ \t]*" comment-start-skip))))) | |
1030 (if (not not-last-statement) | |
1031 'last-statement))) | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1032 |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1033 (defun fortran-narrow-to-subprogram () |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1034 "Make text outside the current subprogram invisible. |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1035 The subprogram visible is the one that contains or follows point." |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1036 (interactive) |
24125
5c8305dd352f
(fortran-narrow-to-subprogram): Ensure mark
Dave Love <fx@gnu.org>
parents:
24012
diff
changeset
|
1037 (save-excursion |
24254
93993abff564
(mark-fortran-subprogram): Activate mark
Dave Love <fx@gnu.org>
parents:
24125
diff
changeset
|
1038 (mark-fortran-subprogram) |
93993abff564
(mark-fortran-subprogram): Activate mark
Dave Love <fx@gnu.org>
parents:
24125
diff
changeset
|
1039 (narrow-to-region (point) (mark)))) |
23754 | 1040 |
1041 (defmacro fortran-with-subprogram-narrowing (&rest forms) | |
1042 "Execute FORMS with buffer temporarily narrowed to current subprogram. | |
1043 Doesn't push a mark." | |
1044 `(save-restriction | |
1045 (save-excursion | |
1046 (narrow-to-region (progn | |
1047 (beginning-of-fortran-subprogram) | |
1048 (point)) | |
1049 (progn | |
1050 (end-of-fortran-subprogram) | |
1051 (point)))) | |
1052 ,@forms)) | |
332 | 1053 |
1054 (defun fortran-blink-matching-if () | |
23754 | 1055 "From an ENDIF statement, blink the matching IF statement." |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1056 (let ((top-of-window (window-start)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1057 (endif-point (point)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1058 (case-fold-search t) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1059 matching-if |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1060 message) |
332 | 1061 (if (save-excursion (beginning-of-line) |
1062 (skip-chars-forward " \t0-9") | |
24800 | 1063 (looking-at "e\\(nd[ \t]*if\\|lse\\([ \t]*if\\)?\\)\\b")) |
332 | 1064 (progn |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1065 (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
|
1066 (setq message "No matching if.") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1067 (if (< matching-if top-of-window) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1068 (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1069 (goto-char matching-if) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1070 (beginning-of-line) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1071 (setq message |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1072 (concat "Matches " |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1073 (buffer-substring |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1074 (point) (progn (end-of-line) (point)))))))) |
332 | 1075 (if message |
1548 | 1076 (message "%s" message) |
332 | 1077 (goto-char matching-if) |
1078 (sit-for 1) | |
1079 (goto-char endif-point)))))) | |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1080 |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1081 (defun fortran-blink-matching-do () |
23754 | 1082 "From an ENDDO statement, blink the matching DO or DO WHILE statement." |
1083 ;; This is basically copied from fortran-blink-matching-if. | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1084 (let ((top-of-window (window-start)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1085 (enddo-point (point)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1086 (case-fold-search t) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1087 matching-do |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1088 message) |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1089 (if (save-excursion (beginning-of-line) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1090 (skip-chars-forward " \t0-9") |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1091 (looking-at "end[ \t]*do\\b")) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1092 (progn |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1093 (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
|
1094 (setq message "No matching do.") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1095 (if (< matching-do top-of-window) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1096 (save-excursion |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1097 (goto-char matching-do) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1098 (beginning-of-line) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1099 (setq message |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1100 (concat "Matches " |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1101 (buffer-substring |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1102 (point) (progn (end-of-line) (point)))))))) |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1103 (if message |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1104 (message "%s" message) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1105 (goto-char matching-do) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1106 (sit-for 1) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1107 (goto-char enddo-point)))))) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1108 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1109 (defun fortran-mark-do () |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
1110 "Put mark at end of Fortran DO [WHILE]-ENDDO construct, point at beginning. |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1111 The marks are pushed." |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1112 (interactive) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1113 (let (enddo-point do-point) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1114 (if (setq enddo-point (fortran-end-do)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1115 (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
|
1116 (message "No matching do.") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1117 ;; Set mark, move point. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1118 (goto-char enddo-point) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1119 (push-mark) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1120 (goto-char do-point))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1121 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1122 (defun fortran-end-do () |
23754 | 1123 "Search forward for first unmatched ENDDO. |
1124 Return point or nil." | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1125 (let ((case-fold-search t)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1126 (if (save-excursion (beginning-of-line) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1127 (skip-chars-forward " \t0-9") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1128 (looking-at "end[ \t]*do\\b")) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1129 ;; Sitting on one. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1130 (match-beginning 0) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1131 ;; Search for one. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1132 (save-excursion |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1133 (let ((count 1)) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1134 (while (and (not (= count 0)) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1135 (not (eq (fortran-next-statement) 'last-statement)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1136 ;; Keep local to subprogram |
23754 | 1137 (not (and (looking-at fortran-end-prog-re) |
1138 (fortran-check-end-prog-re)))) | |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1139 |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1140 (skip-chars-forward " \t0-9") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1141 (cond ((looking-at "end[ \t]*do\\b") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1142 (setq count (1- count))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1143 ((looking-at "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+[^0-9]") |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1144 (setq count (+ count 1))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1145 (and (= count 0) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1146 ;; All pairs accounted for. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1147 (point))))))) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1148 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1149 (defun fortran-beginning-do () |
23754 | 1150 "Search backwards for first unmatched DO [WHILE]. |
1151 Return point or nil." | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1152 (let ((case-fold-search t)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1153 (if (save-excursion (beginning-of-line) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1154 (skip-chars-forward " \t0-9") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1155 (looking-at "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+")) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1156 ;; Sitting on one. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1157 (match-beginning 0) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1158 ;; Search for one. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1159 (save-excursion |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1160 (let ((count 1)) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1161 (while (and (not (= count 0)) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1162 (not (eq (fortran-previous-statement) 'first-statement)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1163 ;; Keep local to subprogram |
23754 | 1164 (not (and (looking-at fortran-end-prog-re) |
1165 (fortran-check-end-prog-re)))) | |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1166 |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1167 (skip-chars-forward " \t0-9") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1168 (cond ((looking-at "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+[^0-9]") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1169 (setq count (1- count))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1170 ((looking-at "end[ \t]*do\\b") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1171 (setq count (1+ count))))) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1172 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1173 (and (= count 0) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1174 ;; All pairs accounted for. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1175 (point))))))) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1176 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1177 (defun fortran-mark-if () |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1178 "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
|
1179 The marks are pushed." |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1180 (interactive) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1181 (let (endif-point if-point) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1182 (if (setq endif-point (fortran-end-if)) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1183 (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
|
1184 (message "No matching if.") |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1185 ;; Set mark, move point. |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1186 (goto-char endif-point) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1187 (push-mark) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1188 (goto-char if-point))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1189 |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1190 (defvar fortran-if-start-re "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?if[ \t]*(") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1191 |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1192 (defun fortran-end-if () |
23754 | 1193 "Search forwards for first unmatched ENDIF. |
1194 Return point or nil." | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1195 (let ((case-fold-search t)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1196 (if (save-excursion (beginning-of-line) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1197 (skip-chars-forward " \t0-9") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1198 (looking-at "end[ \t]*if\\b")) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1199 ;; Sitting on one. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1200 (match-beginning 0) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1201 ;; Search for one. The point has been already been moved to first |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1202 ;; letter on line but this should not cause troubles. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1203 (save-excursion |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1204 (let ((count 1)) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1205 (while (and (not (= count 0)) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1206 (not (eq (fortran-next-statement) 'last-statement)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1207 ;; Keep local to subprogram. |
23754 | 1208 (not (and (looking-at fortran-end-prog-re) |
1209 (fortran-check-end-prog-re)))) | |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1210 |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1211 (skip-chars-forward " \t0-9") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1212 (cond ((looking-at "end[ \t]*if\\b") |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1213 (setq count (- count 1))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1214 |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1215 ((looking-at fortran-if-start-re) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1216 (save-excursion |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1217 (if (or |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1218 (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t(=a-z0-9]") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1219 (let (then-test) ; Multi-line if-then. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1220 (while |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1221 (and (= (forward-line 1) 0) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1222 ;; Search forward for then. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1223 (or (looking-at " [^ 0\n]") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1224 (looking-at "\t[1-9]")) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1225 (not |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1226 (setq then-test |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1227 (looking-at |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1228 ".*then\\b[ \t]*[^ \t(=a-z0-9]"))))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1229 then-test)) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1230 (setq count (+ count 1))))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1231 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1232 (and (= count 0) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1233 ;; All pairs accounted for. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1234 (point))))))) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1235 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1236 (defun fortran-beginning-if () |
23754 | 1237 "Search backwards for first unmatched IF-THEN. |
1238 Return point or nil." | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1239 (let ((case-fold-search t)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1240 (if (save-excursion |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1241 ;; May be sitting on multi-line if-then statement, first move to |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1242 ;; beginning of current statement. Note: `fortran-previous-statement' |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1243 ;; moves to previous statement *unless* current statement is first |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1244 ;; one. Only move forward if not first-statement. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1245 (if (not (eq (fortran-previous-statement) 'first-statement)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1246 (fortran-next-statement)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1247 (skip-chars-forward " \t0-9") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1248 (and |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1249 (looking-at fortran-if-start-re) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1250 (save-match-data |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1251 (or (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t(=a-z0-9]") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1252 ;; Multi-line if-then. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1253 (let (then-test) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1254 (while |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1255 (and (= (forward-line 1) 0) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1256 ;; Search forward for then. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1257 (or (looking-at " [^ 0\n]") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1258 (looking-at "\t[1-9]")) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1259 (not |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1260 (setq then-test |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1261 (looking-at |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1262 ".*then\\b[ \t]*[^ \t(=a-z0-9]"))))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1263 then-test))))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1264 ;; Sitting on one. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1265 (match-beginning 0) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1266 ;; Search for one. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1267 (save-excursion |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1268 (let ((count 1)) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1269 (while (and (not (= count 0)) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1270 (not (eq (fortran-previous-statement) 'first-statement)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1271 ;; Keep local to subprogram. |
23754 | 1272 (not (and (looking-at fortran-end-prog-re) |
1273 (fortran-check-end-prog-re)))) | |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1274 |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1275 (skip-chars-forward " \t0-9") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1276 (cond ((looking-at fortran-if-start-re) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1277 (save-excursion |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1278 (if (or |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1279 (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t(=a-z0-9]") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1280 (let (then-test) ; Multi-line if-then. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1281 (while |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1282 (and (= (forward-line 1) 0) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1283 ;; Search forward for then. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1284 (or (looking-at " [^ 0\n]") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1285 (looking-at "\t[1-9]")) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1286 (not |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1287 (setq then-test |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1288 (looking-at |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1289 ".*then\\b[ \t]*[^ \t(=a-z0-9]"))))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1290 then-test)) |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1291 (setq count (- count 1))))) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1292 ((looking-at "end[ \t]*if\\b") |
10189
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1293 (setq count (+ count 1))))) |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1294 |
b2d6d69b7707
(fortran-end-if, fortran-end-do,
Richard M. Stallman <rms@gnu.org>
parents:
9476
diff
changeset
|
1295 (and (= count 0) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1296 ;; All pairs accounted for. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1297 (point))))))) |
332 | 1298 |
1299 (defun fortran-indent-line () | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1300 "Indent current Fortran line based on its contents and on previous lines." |
332 | 1301 (interactive) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1302 (let ((cfi (fortran-calculate-indent))) |
332 | 1303 (save-excursion |
1304 (beginning-of-line) | |
1305 (if (or (not (= cfi (fortran-current-line-indentation))) | |
1306 (and (re-search-forward "^[ \t]*[0-9]+" (+ (point) 4) t) | |
1307 (not (fortran-line-number-indented-correctly-p)))) | |
1308 (fortran-indent-to-column cfi) | |
1309 (beginning-of-line) | |
1310 (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
|
1311 (fortran-find-comment-start-skip)) |
332 | 1312 (fortran-indent-comment)))) |
1313 ;; Never leave point in left margin. | |
1314 (if (< (current-column) cfi) | |
1315 (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
|
1316 (if (and auto-fill-function |
1548 | 1317 (> (save-excursion (end-of-line) (current-column)) fill-column)) |
1318 (save-excursion | |
1319 (end-of-line) | |
12772
f4b2913b7f58
(fortran-auto-fill-mode, fortran-do-auto-fill, fortran-fill):
Richard M. Stallman <rms@gnu.org>
parents:
12715
diff
changeset
|
1320 (fortran-fill))) |
332 | 1321 (if fortran-blink-matching-if |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1322 (progn |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1323 (fortran-blink-matching-if) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
1324 (fortran-blink-matching-do))))) |
332 | 1325 |
25162
ec613559ec18
(fortran-indent-new-line): Make it an alias
Dave Love <fx@gnu.org>
parents:
25054
diff
changeset
|
1326 ;; Historically this was a separate function which advertised itself |
ec613559ec18
(fortran-indent-new-line): Make it an alias
Dave Love <fx@gnu.org>
parents:
25054
diff
changeset
|
1327 ;; as reindenting but only did so where `most likely to be necessary'. |
ec613559ec18
(fortran-indent-new-line): Make it an alias
Dave Love <fx@gnu.org>
parents:
25054
diff
changeset
|
1328 (defalias 'fortran-indent-new-line 'reindent-then-newline-and-indent) |
1548 | 1329 |
332 | 1330 (defun fortran-indent-subprogram () |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1331 "Properly indent the Fortran subprogram which contains point." |
332 | 1332 (interactive) |
1333 (save-excursion | |
24254
93993abff564
(mark-fortran-subprogram): Activate mark
Dave Love <fx@gnu.org>
parents:
24125
diff
changeset
|
1334 (mark-fortran-subprogram) |
93993abff564
(mark-fortran-subprogram): Activate mark
Dave Love <fx@gnu.org>
parents:
24125
diff
changeset
|
1335 (message "Indenting subprogram...") |
93993abff564
(mark-fortran-subprogram): Activate mark
Dave Love <fx@gnu.org>
parents:
24125
diff
changeset
|
1336 (indent-region (point) (mark) nil)) |
332 | 1337 (message "Indenting subprogram...done.")) |
1338 | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1339 (defun fortran-calculate-indent () |
1548 | 1340 "Calculates the Fortran indent column based on previous lines." |
332 | 1341 (let (icol first-statement (case-fold-search t) |
1342 (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
|
1343 (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
|
1344 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
|
1345 fortran-minimum-statement-indent-fixed))) |
332 | 1346 (save-excursion |
1347 (setq first-statement (fortran-previous-statement)) | |
1348 (if first-statement | |
1349 (setq icol fortran-minimum-statement-indent) | |
1350 (progn | |
1351 (if (= (point) (point-min)) | |
1352 (setq icol fortran-minimum-statement-indent) | |
1353 (setq icol (fortran-current-line-indentation))) | |
1354 (skip-chars-forward " \t0-9") | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1355 (cond ((looking-at "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?if[ \t]*(") |
1548 | 1356 (if (or (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t_$(=a-z0-9]") |
332 | 1357 (let (then-test) ;multi-line if-then |
1358 (while (and (= (forward-line 1) 0) | |
1548 | 1359 ;;search forward for then |
332 | 1360 (or (looking-at " [^ 0\n]") |
1361 (looking-at "\t[1-9]")) | |
1362 (not (setq then-test (looking-at | |
1548 | 1363 ".*then\\b[ \t]\ |
1364 *[^ \t_$(=a-z0-9]"))))) | |
332 | 1365 then-test)) |
1366 (setq icol (+ icol fortran-if-indent)))) | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1367 ((looking-at "else\\(if\\)?\\b") |
332 | 1368 (setq icol (+ icol fortran-if-indent))) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1369 ((looking-at "select[ \t]*case[ \t](.*)") |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1370 (setq icol (+ icol fortran-if-indent))) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1371 ((looking-at "case[ \t]*(.*)") |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1372 (setq icol (+ icol fortran-if-indent))) |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1373 ((looking-at "case[ \t]*default\\b") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1374 (setq icol (+ icol fortran-if-indent))) |
1548 | 1375 ((looking-at "\\(otherwise\\|else[ \t]*where\\)\\b") |
1376 (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
|
1377 ((looking-at "where[ \t]*(.*)[ \t]*\n") |
1548 | 1378 (setq icol (+ icol fortran-if-indent))) |
332 | 1379 ((looking-at "do\\b") |
1380 (setq icol (+ icol fortran-do-indent))) | |
1548 | 1381 ((looking-at |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1382 "\\(structure\\|union\\|map\\|interface\\)\\b[ \t]*[^ \t=(a-z]") |
1548 | 1383 (setq icol (+ icol fortran-structure-indent))) |
23754 | 1384 ((and (looking-at fortran-end-prog-re1) |
1385 (fortran-check-end-prog-re)) | |
1548 | 1386 ;; Previous END resets indent to minimum |
332 | 1387 (setq icol fortran-minimum-statement-indent)))))) |
1388 (save-excursion | |
1389 (beginning-of-line) | |
1390 (cond ((looking-at "[ \t]*$")) | |
1391 ((looking-at comment-line-start-skip) | |
1392 (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
|
1393 (setq icol (+ icol fortran-comment-line-extra-indent))) |
332 | 1394 ((eq fortran-comment-indent-style 'fixed) |
1548 | 1395 (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
|
1396 fortran-comment-line-extra-indent)))) |
1548 | 1397 (setq fortran-minimum-statement-indent 0)) |
332 | 1398 ((or (looking-at (concat "[ \t]*" |
1548 | 1399 (regexp-quote |
1400 fortran-continuation-string))) | |
332 | 1401 (looking-at " [^ 0\n]") |
1402 (looking-at "\t[1-9]")) | |
1403 (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
|
1404 ((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
|
1405 (setq fortran-minimum-statement-indent 0 icol 0)) |
332 | 1406 (first-statement) |
1407 ((and fortran-check-all-num-for-matching-do | |
1408 (looking-at "[ \t]*[0-9]+") | |
1409 (fortran-check-for-matching-do)) | |
1410 (setq icol (- icol fortran-do-indent))) | |
1411 (t | |
1412 (skip-chars-forward " \t0-9") | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1413 (cond ((looking-at "end[ \t]*\\(if\\|select\\|where\\)\\b") |
332 | 1414 (setq icol (- icol fortran-if-indent))) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1415 ((looking-at "else\\(if\\)?\\b") |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1416 (setq icol (- icol fortran-if-indent))) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1417 ((looking-at "case[ \t]*\\((.*)\\|default\\>\\)") |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1418 (setq icol (- icol fortran-if-indent))) |
1548 | 1419 ((looking-at "\\(otherwise\\|else[ \t]*where\\)\\b") |
1420 (setq icol (- icol fortran-if-indent))) | |
332 | 1421 ((and (looking-at "continue\\b") |
1422 (fortran-check-for-matching-do)) | |
1423 (setq icol (- icol fortran-do-indent))) | |
1424 ((looking-at "end[ \t]*do\\b") | |
1425 (setq icol (- icol fortran-do-indent))) | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1426 ((looking-at "end[ \t]*\ |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1427 \\(structure\\|union\\|map\\|interface\\)\\b[ \t]*[^ \t=(a-z]") |
1548 | 1428 (setq icol (- icol fortran-structure-indent))) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1429 ((and (looking-at fortran-end-prog-re1) |
23754 | 1430 (fortran-check-end-prog-re) |
332 | 1431 (not (= icol fortran-minimum-statement-indent))) |
1432 (message "Warning: `end' not in column %d. Probably\ | |
1433 an unclosed block." fortran-minimum-statement-indent)))))) | |
1434 (max fortran-minimum-statement-indent icol))) | |
1435 | |
1436 (defun fortran-current-line-indentation () | |
1437 "Indentation of current line, ignoring Fortran line number or continuation. | |
1438 This is the column position of the first non-whitespace character | |
1439 aside from the line number and/or column 5/8 line-continuation character. | |
1440 For comment lines, returns indentation of the first | |
1441 non-indentation text within the comment." | |
1442 (save-excursion | |
1443 (beginning-of-line) | |
1444 (cond ((looking-at comment-line-start-skip) | |
1445 (goto-char (match-end 0)) | |
1446 (skip-chars-forward | |
1548 | 1447 (if (stringp fortran-comment-indent-char) |
1448 fortran-comment-indent-char | |
1449 (char-to-string fortran-comment-indent-char)))) | |
332 | 1450 ((or (looking-at " [^ 0\n]") |
1548 | 1451 (looking-at "\t[1-9]")) |
332 | 1452 (goto-char (match-end 0))) |
1453 (t | |
1454 ;; Move past line number. | |
1548 | 1455 (skip-chars-forward "[ \t0-9]");From Uli |
1456 )) | |
332 | 1457 ;; Move past whitespace. |
1458 (skip-chars-forward " \t") | |
1459 (current-column))) | |
1460 | |
1461 (defun fortran-indent-to-column (col) | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1462 "Indent current line with spaces to column COL. |
332 | 1463 notes: 1) A non-zero/non-blank character in column 5 indicates a continuation |
1464 line, and this continuation character is retained on indentation; | |
1548 | 1465 2) If `fortran-continuation-string' is the first non-whitespace |
1466 character, this is a continuation line; | |
332 | 1467 3) A non-continuation line which has a number as the first |
1468 non-whitespace character is a numbered line. | |
1548 | 1469 4) A TAB followed by a digit indicates a continuation line." |
332 | 1470 (save-excursion |
1471 (beginning-of-line) | |
1472 (if (looking-at comment-line-start-skip) | |
1473 (if fortran-comment-indent-style | |
1474 (let ((char (if (stringp fortran-comment-indent-char) | |
1475 (aref fortran-comment-indent-char 0) | |
1548 | 1476 fortran-comment-indent-char))) |
332 | 1477 (goto-char (match-end 0)) |
1478 (delete-horizontal-regexp (concat " \t" (char-to-string char))) | |
1479 (insert-char char (- col (current-column))))) | |
1480 (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
|
1481 (if indent-tabs-mode |
332 | 1482 (goto-char (match-end 0)) |
1483 (delete-char 2) | |
1484 (insert " ") | |
1485 (insert fortran-continuation-string)) | |
1486 (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
|
1487 (if indent-tabs-mode |
332 | 1488 (progn (delete-char 6) |
1489 (insert "\t") | |
1490 (insert-char (fortran-numerical-continuation-char) 1)) | |
1491 (forward-char 6)) | |
1492 (delete-horizontal-space) | |
1548 | 1493 ;; Put line number in columns 0-4 |
1494 ;; or put continuation character in column 5. | |
332 | 1495 (cond ((eobp)) |
1496 ((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
|
1497 (if indent-tabs-mode |
332 | 1498 (progn |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
1499 (indent-to |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1500 (if 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
|
1501 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
|
1502 fortran-minimum-statement-indent-fixed)) |
332 | 1503 (delete-char 1) |
1504 (insert-char (fortran-numerical-continuation-char) 1)) | |
1548 | 1505 (indent-to 5) |
1506 (forward-char 1))) | |
332 | 1507 ((looking-at "[0-9]+") |
1508 (let ((extra-space (- 5 (- (match-end 0) (point))))) | |
1509 (if (< extra-space 0) | |
1510 (message "Warning: line number exceeds 5-digit limit.") | |
1511 (indent-to (min fortran-line-number-indent extra-space)))) | |
1512 (skip-chars-forward "0-9"))))) | |
1513 ;; Point is now after any continuation character or line number. | |
1514 ;; Put body of statement where specified. | |
1515 (delete-horizontal-space) | |
1516 (indent-to col) | |
1517 ;; Indent any comment following code on the same line. | |
1518 (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
|
1519 (fortran-find-comment-start-skip)) |
332 | 1520 (progn (goto-char (match-beginning 0)) |
1521 (if (not (= (current-column) (fortran-comment-hook))) | |
1522 (progn (delete-horizontal-space) | |
1523 (indent-to (fortran-comment-hook))))))))) | |
1524 | |
1525 (defun fortran-line-number-indented-correctly-p () | |
1526 "Return t if current line's line number is correctly indented. | |
1527 Do not call if there is no line number." | |
1528 (save-excursion | |
1529 (beginning-of-line) | |
1530 (skip-chars-forward " \t") | |
1531 (and (<= (current-column) fortran-line-number-indent) | |
1532 (or (= (current-column) fortran-line-number-indent) | |
1533 (progn (skip-chars-forward "0-9") | |
1534 (= (current-column) 5)))))) | |
1535 | |
1536 (defun fortran-check-for-matching-do () | |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1537 "When called from a numbered statement, return t if matching DO is found. |
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1538 Otherwise return nil." |
332 | 1539 (let (charnum |
1540 (case-fold-search t)) | |
1541 (save-excursion | |
1542 (beginning-of-line) | |
1543 (if (looking-at "[ \t]*[0-9]+") | |
1544 (progn | |
1545 (skip-chars-forward " \t") | |
1546 (skip-chars-forward "0") ;skip past leading zeros | |
1547 (setq charnum (buffer-substring (point) | |
1548 (progn (skip-chars-forward "0-9") | |
1549 (point)))) | |
1550 (beginning-of-line) | |
23754 | 1551 (fortran-with-subprogram-narrowing |
1552 (and (re-search-backward | |
1553 (concat "\\(^[ \t0-9]*do[ \t]*0*" charnum "\\b\\)\\|" | |
1554 "\\(^[ \t]*0*" charnum "\\b\\)") | |
1555 nil t) | |
1556 (looking-at (concat "^[ \t0-9]*do[ \t]*0*" charnum))))))))) | |
332 | 1557 |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1558 (defun fortran-find-comment-start-skip () |
1548 | 1559 "Move to past `comment-start-skip' found on current line. |
1560 Return t if `comment-start-skip' found, nil if not." | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1561 ;; In order to move point only if comment-start-skip is found, this |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1562 ;; one uses a lot of save-excursions. Note that re-search-forward |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1563 ;; moves point even if comment-start-skip is inside a string-constant. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1564 ;; Some code expects certain values for match-beginning and end |
1548 | 1565 (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
|
1566 (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
|
1567 (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
|
1568 (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
|
1569 (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
|
1570 (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
|
1571 (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
|
1572 (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
|
1573 (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
|
1574 (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
|
1575 (goto-char save-match-beginning) |
1548 | 1576 (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
|
1577 (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
|
1578 (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
|
1579 t)) |
e7c26522b881
Use new fortran-match-!-comment to do !-style fontification; do rest in regexps
Simon Marshall <simon@gnu.org>
parents:
10883
diff
changeset
|
1580 nil)) |
e7c26522b881
Use new fortran-match-!-comment to do !-style fontification; do rest in regexps
Simon Marshall <simon@gnu.org>
parents:
10883
diff
changeset
|
1581 |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1582 ;;From: ralf@up3aud1.gwdg.de (Ralf Fassel) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1583 ;; Test if TAB format continuation lines work. |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1584 (defun fortran-is-in-string-p (where) |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1585 "Return non-nil iff WHERE (a buffer position) is inside a Fortran string." |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1586 (save-excursion |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1587 (goto-char where) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1588 (cond |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1589 ((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
|
1590 ((save-excursion ; comment lines too |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1591 (beginning-of-line) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1592 (looking-at comment-line-start-skip)) nil) |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1593 (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
|
1594 (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
|
1595 (quoted-comment-start (if comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1596 (regexp-quote comment-start))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1597 (not-done t) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1598 parse-limit |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1599 end-of-line |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1600 ) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1601 ;; move to start of current statement |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1602 (fortran-next-statement) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1603 (fortran-previous-statement) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1604 ;; now parse up to WHERE |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1605 (while not-done |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1606 (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
|
1607 ;; - comment line? |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1608 (looking-at comment-line-start-skip) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1609 ;; - at end of line? |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1610 (eolp) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1611 ;; - 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
|
1612 (and (not (nth 3 parse-state)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1613 comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1614 (equal comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1615 (char-to-string (preceding-char))))) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1616 (if (> (forward-line) 0) |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1617 (setq not-done nil)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1618 ;; else: |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1619 ;; 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
|
1620 ;; whitespace, labels and tab continuation markers. |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1621 (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
|
1622 ;; 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
|
1623 (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
|
1624 ((and (< (current-column) 5) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1625 (equal fortran-continuation-string |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1626 (char-to-string (following-char))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1627 (forward-char 1)))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1628 ;; find out parse-limit from here |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1629 (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
|
1630 (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
|
1631 ;; 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
|
1632 (if comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1633 (save-excursion |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1634 (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
|
1635 (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
|
1636 ;; now parse if still in limits |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1637 (if (< (point) where) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1638 (setq parse-state (parse-partial-sexp |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1639 (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
|
1640 (setq not-done nil)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1641 )) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1642 ;; result is |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1643 (nth 3 parse-state)))))) |
1548 | 1644 |
1645 (defun fortran-auto-fill-mode (arg) | |
1646 "Toggle fortran-auto-fill mode. | |
1647 With ARG, turn `fortran-auto-fill' mode on iff ARG is positive. | |
1648 In `fortran-auto-fill' mode, inserting a space at a column beyond `fill-column' | |
1649 automatically breaks the line at a previous space." | |
1650 (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
|
1651 (prog1 (setq auto-fill-function |
1548 | 1652 (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
|
1653 (not auto-fill-function) |
1548 | 1654 (> (prefix-numeric-value arg) 0)) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1655 #'fortran-do-auto-fill |
1548 | 1656 nil)) |
11584
3391bf365efa
(fortran-auto-fill-mode): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
11516
diff
changeset
|
1657 (force-mode-line-update))) |
1548 | 1658 |
1659 (defun fortran-do-auto-fill () | |
12772
f4b2913b7f58
(fortran-auto-fill-mode, fortran-do-auto-fill, fortran-fill):
Richard M. Stallman <rms@gnu.org>
parents:
12715
diff
changeset
|
1660 (if (> (current-column) fill-column) |
f4b2913b7f58
(fortran-auto-fill-mode, fortran-do-auto-fill, fortran-fill):
Richard M. Stallman <rms@gnu.org>
parents:
12715
diff
changeset
|
1661 (fortran-indent-line))) |
f4b2913b7f58
(fortran-auto-fill-mode, fortran-do-auto-fill, fortran-fill):
Richard M. Stallman <rms@gnu.org>
parents:
12715
diff
changeset
|
1662 |
f4b2913b7f58
(fortran-auto-fill-mode, fortran-do-auto-fill, fortran-fill):
Richard M. Stallman <rms@gnu.org>
parents:
12715
diff
changeset
|
1663 (defun fortran-fill () |
1548 | 1664 (interactive) |
24800 | 1665 (let* ((auto-fill-function #'fortran-do-auto-fill) |
1666 (opoint (point)) | |
1548 | 1667 (bol (save-excursion (beginning-of-line) (point))) |
1668 (eol (save-excursion (end-of-line) (point))) | |
1669 (bos (min eol (+ bol (fortran-current-line-indentation)))) | |
1670 (quote | |
1671 (save-excursion | |
1672 (goto-char bol) | |
1673 (if (looking-at comment-line-start-skip) | |
1674 nil ; OK to break quotes on comment lines. | |
1675 (move-to-column fill-column) | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1676 (if (fortran-is-in-string-p (point)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1677 (save-excursion (re-search-backward "\\S\"\\s\"\\S\"" bol t) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1678 (if fortran-break-before-delimiters |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1679 (point) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1680 (1+ (point)))))))) |
1548 | 1681 ;; decide where to split the line. If a position for a quoted |
1682 ;; string was found above then use that, else break the line | |
1683 ;; before the last delimiter. | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
1684 ;; Delimiters are whitespace, commas, and operators. |
1548 | 1685 ;; Will break before a pair of *'s. |
1686 (fill-point | |
1687 (or quote | |
1688 (save-excursion | |
1689 (move-to-column (1+ fill-column)) | |
1690 (skip-chars-backward "^ \t\n,'+-/*=)" | |
1691 ;;; (if fortran-break-before-delimiters | |
1692 ;;; "^ \t\n,'+-/*=" "^ \t\n,'+-/*=)") | |
1693 ) | |
1694 (if (<= (point) (1+ bos)) | |
1695 (progn | |
1696 (move-to-column (1+ fill-column)) | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1697 ;;what is this doing??? |
1548 | 1698 (if (not (re-search-forward "[\t\n,'+-/*)=]" eol t)) |
1699 (goto-char bol)))) | |
1700 (if (bolp) | |
1701 (re-search-forward "[ \t]" opoint t) | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1702 (backward-char) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1703 (if (looking-at "\\s\"") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1704 (forward-char) |
1548 | 1705 (skip-chars-backward " \t\*"))) |
1706 (if fortran-break-before-delimiters | |
1707 (point) | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1708 (1+ (point))))))) |
1548 | 1709 ;; if we are in an in-line comment, don't break unless the |
1710 ;; line of code is longer than it should be. Otherwise | |
1711 ;; break the line at the column computed above. | |
1712 ;; | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1713 ;; Need to use fortran-find-comment-start-skip to make sure that quoted !'s |
1548 | 1714 ;; don't prevent a break. |
1715 (if (not (or (save-excursion | |
1716 (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
|
1717 (not (fortran-is-in-string-p (point)))) |
1548 | 1718 (progn |
1719 (skip-chars-backward " \t") | |
1720 (< (current-column) (1+ fill-column))))) | |
1721 (save-excursion | |
1722 (goto-char fill-point) | |
1723 (bolp)))) | |
1724 (if (> (save-excursion | |
1725 (goto-char fill-point) (current-column)) | |
1726 (1+ fill-column)) | |
1727 (progn (goto-char fill-point) | |
1728 (fortran-break-line)) | |
1729 (save-excursion | |
1730 (if (> (save-excursion | |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
1731 (goto-char fill-point) |
1548 | 1732 (current-column)) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1733 (+ (fortran-calculate-indent) fortran-continuation-indent)) |
1548 | 1734 (progn |
1735 (goto-char fill-point) | |
1736 (fortran-break-line)))))) | |
1737 )) | |
1738 (defun fortran-break-line () | |
1739 (let ((opoint (point)) | |
1740 (bol (save-excursion (beginning-of-line) (point))) | |
1741 (eol (save-excursion (end-of-line) (point))) | |
1742 (comment-string nil)) | |
20207
38616c4cf58c
(fortran-imenu-generic-expression): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20205
diff
changeset
|
1743 |
1548 | 1744 (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
|
1745 (if (and comment-start-skip (fortran-find-comment-start-skip)) |
1548 | 1746 (progn |
1747 (re-search-backward comment-start-skip bol t) | |
1748 (setq comment-string (buffer-substring (point) eol)) | |
1749 (delete-region (point) eol)))) | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1750 ;; Forward line 1 really needs to go to next non white line |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1751 (if (save-excursion (forward-line) |
1548 | 1752 (or (looking-at " [^ 0\n]") |
1753 (looking-at "\t[1-9]"))) | |
1754 (progn | |
12715
ad18c3ad23b3
(fortran-break-line): Fixed a bug that sometimes
Richard M. Stallman <rms@gnu.org>
parents:
12386
diff
changeset
|
1755 (end-of-line) |
ad18c3ad23b3
(fortran-break-line): Fixed a bug that sometimes
Richard M. Stallman <rms@gnu.org>
parents:
12386
diff
changeset
|
1756 (delete-region (point) (match-end 0)) |
1548 | 1757 (delete-horizontal-space) |
12772
f4b2913b7f58
(fortran-auto-fill-mode, fortran-do-auto-fill, fortran-fill):
Richard M. Stallman <rms@gnu.org>
parents:
12715
diff
changeset
|
1758 (fortran-fill)) |
1548 | 1759 (fortran-split-line)) |
1760 (if comment-string | |
1761 (save-excursion | |
1762 (goto-char bol) | |
1763 (end-of-line) | |
1764 (delete-horizontal-space) | |
1765 (indent-to (fortran-comment-hook)) | |
1766 (insert comment-string))))) | |
1767 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1768 (defun fortran-analyze-file-format () |
20805
918448e5d294
Various docstring and commentary fixes, including
Dave Love <fx@gnu.org>
parents:
20277
diff
changeset
|
1769 "Return 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
|
1770 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
|
1771 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
|
1772 (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
|
1773 (save-excursion |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1774 (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
|
1775 (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
|
1776 (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
|
1777 (eobp) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1778 (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
|
1779 (looking-at " ") |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1780 (> 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
|
1781 (forward-line) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1782 (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
|
1783 (cond |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1784 ((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
|
1785 ((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
|
1786 (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
|
1787 (t nil))))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1788 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1789 (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
|
1790 (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
|
1791 '(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
|
1792 (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
|
1793 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
|
1794 |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1795 (defun fortran-fill-paragraph (&optional justify) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1796 "Fill surrounding comment block as paragraphs, else fill statement. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1797 |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1798 Intended as the value of `fill-paragraph-function'." |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1799 (interactive "P") |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1800 (save-excursion |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1801 (beginning-of-line) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1802 (if (not (looking-at "[Cc*]")) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1803 (fortran-fill-statement) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1804 ;; We're in a comment block. Find the start and end of a |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1805 ;; paragraph, delimited either by non-comment lines or empty |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1806 ;; comments. (Get positions as markers, since the |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1807 ;; `indent-region' below can shift the block's end). |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1808 (let* ((non-empty-comment (concat "\\(" comment-line-start-skip |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1809 "\\)" "[^ \t\n]")) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1810 (start (save-excursion |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1811 ;; Find (start of) first line. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1812 (while (and (zerop (forward-line -1)) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1813 (looking-at non-empty-comment))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1814 (or (looking-at non-empty-comment) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1815 (forward-line)) ; overshot |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1816 (point-marker))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1817 (end (save-excursion |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1818 ;; Find start of first line past region to fill. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1819 (while (progn (forward-line) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1820 (looking-at non-empty-comment))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1821 (point-marker)))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1822 ;; Indent the block, find the string comprising the effective |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1823 ;; comment start skip and use that as a fill-prefix for |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1824 ;; filling the region. |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1825 (indent-region start end nil) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1826 (let ((paragraph-ignore-fill-prefix nil) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1827 (fill-prefix (progn (beginning-of-line) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1828 (looking-at comment-line-start-skip) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1829 (match-string 0)))) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1830 (let (fill-paragraph-function) |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1831 (fill-region start end justify))) ; with normal `fill-paragraph' |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1832 (set-marker start nil) |
21432
79711f0f4079
(fortran-fill-paragraph): This is the one
Dave Love <fx@gnu.org>
parents:
21410
diff
changeset
|
1833 (set-marker end nil)))) |
79711f0f4079
(fortran-fill-paragraph): This is the one
Dave Love <fx@gnu.org>
parents:
21410
diff
changeset
|
1834 t) |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1835 |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1836 (defun fortran-fill-statement () |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1837 "Fill a fortran statement up to `fill-column'." |
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1838 (interactive) |
24800 | 1839 (let ((auto-fill-function #'fortran-do-auto-fill)) |
1840 (if (not (save-excursion | |
1841 (beginning-of-line) | |
1842 (or (looking-at "[ \t]*$") | |
1843 (looking-at comment-line-start-skip) | |
1844 (and comment-start-skip | |
1845 (looking-at (concat "[ \t]*" comment-start-skip)))))) | |
1846 (save-excursion | |
1847 ;; Find beginning of statement. | |
1848 (fortran-next-statement) | |
1849 (fortran-previous-statement) | |
1850 ;; Re-indent initially. | |
1851 (fortran-indent-line) | |
1852 ;; Replace newline plus continuation field plus indentation with | |
1853 ;; single space. | |
1854 (while (progn | |
1855 (forward-line) | |
1856 (fortran-remove-continuation))) | |
1857 (fortran-previous-statement))) | |
1858 (fortran-indent-line))) | |
21410
d68f866455c6
Use regexp-opt and eval-and-compile to
Dave Love <fx@gnu.org>
parents:
21167
diff
changeset
|
1859 |
584 | 1860 (provide 'fortran) |
1861 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1862 ;;; fortran.el ends here |