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