annotate lisp/progmodes/fortran.el @ 21167:1d2bd6adba38

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