annotate lisp/progmodes/fortran.el @ 23630:1b9560809c6e

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