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