annotate lisp/progmodes/fortran.el @ 88571:1ecb13ff569a

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