annotate lisp/modes/fortran.el @ 172:a38aed19690b

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