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