annotate lisp/modes/f90.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
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 ;;; f90.el --- Fortran-90 mode (free format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Torbj\"orn Einarsson <T.Einarsson@clab.ericsson.se>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Created: Apr. 18, 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: fortran, f90, languages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2 of the License, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; Smart mode for editing F90 programs in FREE FORMAT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; Knows about continuation lines, named structured statements, and other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; new features in F90 including HPF (High Performance Fortran) structures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; The basic feature is to provide an accurate indentation of F90 programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; In addition, there are many more features like automatic matching of all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; end statements, an auto-fill function to break long lines, a join-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; function which joins continued lines etc etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; To facilitate typing, a fairly complete list of abbreviations is provided.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; For example, `i is short-hand for integer (if abbrev-mode is on).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; There are two separate features for highlighting the code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; 1) Upcasing or capitalizing of all keywords.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; 2) Colors/fonts using font-lock-mode. (only when using X-windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; Automatic upcase of downcase of keywords is controlled by the parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; f90-auto-keyword-case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; The indentations of lines starting with ! is determined by the first of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; following matches (the values in the left column are the default values):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; start-string/regexp indent variable holding start-string/regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; !!! 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; !hpf\\$ (re) 0 f90-directive-comment-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; !!$ 0 f90-comment-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; ! (re) as code f90-indented-comment-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; default comment-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; Ex: Here is the result of 3 different settings of f90-indented-comment-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; f90-indented-comment-re !-indentation !!-indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; ! as code as code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; !! comment-column as code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; ![^!] as code comment-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; Trailing comments are indented to comment-column with indent-for-comment M-;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; f90-comment-region (C-c;) toggles insertion of f90-comment-region in region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; One common convention for free vs. fixed format is that free-format files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; have the ending .f90 while the fixed format files have the ending .f.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; To make f90-mode work, put this file in, for example, your directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; ~/lisp, and be sure that you have the following in your .emacs-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; (setq load-path (append load-path '("~/lisp")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; (autoload 'f90-mode "f90"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; "Major mode for editing Fortran 90 code in free format." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; (setq auto-mode-alist (append auto-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; (list '("\\.f90$" . f90-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; Once you have entered f90-mode, you may get more info by using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; the command describe-mode (C-h m). For online help describing various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; functions use C-h f <Name of function you want described>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; To customize the f90-mode for your taste, use, for example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; (you don't have to specify values for all the parameters below)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;(setq f90-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; '(lambda () (setq f90-do-indent 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; f90-if-indent 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; f90-type-indent 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; f90-program-indent 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; f90-continuation-indent 5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; f90-comment-region "!!$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; f90-directive-comment-re "!hpf\\$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; f90-indented-comment-re "!"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; f90-break-delimiters "[-+\\*/,><=% \t]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; f90-break-before-delimiters t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; f90-beginning-ampersand t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; f90-smart-end 'blink
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; f90-auto-keyword-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; f90-leave-line-no nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; f90-startup-message t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; indent-tabs-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; ;;The rest is not default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; (abbrev-mode 1) ; turn on abbreviation mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; (f90-auto-fill-mode 1) ; turn on auto-filling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; (turn-on-font-lock) ; for highlighting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; (if f90-auto-keyword-case ; change case of all keywords on startup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; (f90-change-keywords f90-auto-keyword-case))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; in your .emacs file (the shown values are the defaults). You can also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; change the values of the lists f90-keywords etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; The auto-fill and abbreviation minor modes are accessible from the menu,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; or by using M-x f90-auto-fill-mode and M-x abbrev-mode, respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; Remarks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; 1) Line numbers are by default left-justified. If f90-leave-line-no is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; non-nil, the line numbers are never touched.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; 2) Multi-; statements like > do i=1,20 ; j=j+i ; end do < are not handled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; correctly, but I imagine them to be rare.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; 3) Regexps for hilit19 are no longer supported.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; 4) For FIXED FORMAT code, use the ordinary fortran mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; 5) This mode does not work under emacs-18.x.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; 6) Preprocessor directives, i.e., lines starting with # are left-justified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; and are untouched by all case-changing commands. There is, at present, no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; mechanism for treating multi-line directives (continued by \ ).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; 7) f77 do-loops do 10 i=.. ; ; 10 continue are not correctly indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; You are urged to use f90-do loops (with labels if you wish).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; List of user commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; f90-previous-statement f90-next-statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; f90-beginning-of-subprogram f90-end-of-subprogram f90-mark-subprogram
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; f90-comment-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; f90-indent-line f90-indent-new-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; f90-indent-region (can be called by calling indent-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; f90-indent-subprogram
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; f90-break-line f90-join-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; f90-auto-fill-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; f90-fill-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; f90-insert-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; f90-upcase-keywords f90-upcase-region-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; f90-downcase-keywords f90-downcase-region-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; f90-capitalize-keywords f90-capitalize-region-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;; Thanks to all the people who have tested the mode. Special thanks to Jens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; Bloch Helmers for encouraging me to write this code, for creative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; suggestions as well as for the lists of hpf-commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; Also thanks to the authors of the fortran and pascal modes, on which some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; of this code is built.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (defconst bug-f90-mode "T.Einarsson@clab.ericsson.se"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 "Address of mailing list for F90 mode bugs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; User options
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defvar f90-do-indent 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 "*Extra indentation applied to DO blocks.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defvar f90-if-indent 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 "*Extra indentation applied to IF, SELECT CASE, WHERE and FORALL blocks.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defvar f90-type-indent 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 "*Extra indentation applied to TYPE, INTERFACE and BLOCK DATA blocks.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defvar f90-program-indent 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "*Extra indentation applied to PROGRAM/MODULE/SUBROUTINE/FUNCTION blocks.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (defvar f90-continuation-indent 5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 "*Extra indentation applied to F90 continuation lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defvar f90-comment-region "!!$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 "*String inserted by \\[f90-comment-region]\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 at start of each line in region.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defvar f90-indented-comment-re "!"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "*Regexp saying which comments to be indented like code.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defvar f90-directive-comment-re "!hpf\\$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 "*Regexp of comment-like directive like \"!HPF\\\\$\", not to be indented.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defvar f90-beginning-ampersand t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "*t makes automatic insertion of \& at beginning of continuation line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defvar f90-smart-end 'blink
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "*From an END statement, check and fill the end using matching block start.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 Allowed values are 'blink, 'no-blink, and nil, which determine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 whether to blink the matching beginning.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (defvar f90-break-delimiters "[-+\\*/><=,% \t]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 "*Regexp holding list of delimiters at which lines may be broken.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (defvar f90-break-before-delimiters t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 "*Non-nil causes `f90-do-auto-fill' to break lines before delimiters.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (defvar f90-auto-keyword-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 "*Automatic case conversion of keywords.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 The options are 'downcase-word, 'upcase-word, 'capitalize-word and nil")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defvar f90-leave-line-no nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 "*If nil, left-justify linenumbers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defvar f90-startup-message t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "*Non-nil displays a startup message when F90 mode is first called.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (defconst f90-keywords-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;("allocate" "allocatable" "assign" "assignment" "backspace" "block"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;"call" "case" "character" "close" "common" "complex" "contains"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;"continue" "cycle" "data" "deallocate" "dimension" "do" "double" "else"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;"elseif" "elsewhere" "end" "enddo" "endfile" "endif" "entry" "equivalence"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;"exit" "external" "forall" "format" "function" "goto" "if" "implicit"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;"include" "inquire" "integer" "intent" "interface" "intrinsic" "logical"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;"module" "namelist" "none" "nullify" "only" "open" "operator" "optional" "parameter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;"pause" "pointer" "precision" "print" "private" "procedure" "program"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;"public" "read" "real" "recursive" "result" "return" "rewind" "save" "select"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;"sequence" "stop" "subroutine" "target" "then" "type" "use" "where"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;"while" "write")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 "\\<\\(a\\(llocat\\(able\\|e\\)\\|ssign\\(\\|ment\\)\\)\\|b\\(ackspace\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 "lock\\)\\|c\\(a\\(ll\\|se\\)\\|haracter\\|lose\\|o\\(m\\(mon\\|plex\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 "nt\\(ains\\|inue\\)\\)\\|ycle\\)\\|d\\(ata\\|eallocate\\|imension\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "o\\(\\|uble\\)\\)\\|e\\(lse\\(\\|if\\|where\\)\\|n\\(d\\(\\|do\\|file\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 "if\\)\\|try\\)\\|quivalence\\|x\\(it\\|ternal\\)\\)\\|f\\(or\\(all\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "mat\\)\\|unction\\)\\|goto\\|i\\(f\\|mplicit\\|n\\(clude\\|quire\\|t\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 "e\\(ger\\|nt\\|rface\\)\\|rinsic\\)\\)\\)\\|logical\\|module\\|n\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 "amelist\\|one\\|ullify\\)\\|o\\(nly\\|p\\(en\\|erator\\|tional\\)\\)\\|p\\(a\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "rameter\\|use\\)\\|ointer\\|r\\(ecision\\|i\\(nt\\|vate\\)\\|o\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "cedure\\|gram\\)\\)\\|ublic\\)\\|re\\(a[dl]\\|cursive\\|sult\\|turn\\|wind\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 "s\\(ave\\|e\\(lect\\|quence\\)\\|top\\|ubroutine\\)\\|t\\(arget\\|hen\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "ype\\)\\|use\\|w\\(h\\(ere\\|ile\\)\\|rite\\)\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 "Regexp for F90 keywords.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defconst f90-keywords-level-3-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; ("allocate" "allocatable" "assign" "assignment" "backspace" "close"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; "deallocate" "dimension" "endfile" "entry" "equivalence" "external"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; "inquire" "intent" "intrinsic" "nullify" "only" "open" "operator"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;; "optional" "parameter" "pause" "pointer" "print" "private" "public"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; "read" "recursive" "result" "rewind" "save" "select" "sequence"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; "target" "write")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 "\\<\\(a\\(llocat\\(able\\|e\\)\\|ssign\\(\\|ment\\)\\)\\|backspace\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 "close\\|d\\(eallocate\\|imension\\)\\|e\\(n\\(dfile\\|try\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 "quivalence\\|xternal\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 "in\\(quire\\|t\\(ent\\|rinsic\\)\\)\\|nullify\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 "o\\(nly\\|p\\(en\\|erator\\|tional\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 "p\\(a\\(rameter\\|use\\)\\|ointer\\|ri\\(nt\\|vate\\)\\|ublic\\)\\|re\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 "ad\\|cursive\\|sult\\|wind\\)\\|s\\(ave\\|e\\(lect\\|quence\\)\\)\\|target\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 "write\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 "Keyword-regexp for font-lock level >= 3.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defconst f90-procedures-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; ("abs" "achar" "acos" "adjustl" "adjustr" "aimag" "aint" "all" "allocated"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;; "anint" "any" "asin" "associated" "atan" "atan2" "bit_size" "btest"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; "ceiling" "char" "cmplx" "conjg" "cos" "cosh" "count" "cshift"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; "date_and_time" "dble" "digits" "dim" "dot_product" "dprod" "eoshift"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; "epsilon" "exp" "exponent" "floor" "fraction" "huge" "iachar" "iand"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; "ibclr" "ibits" "ibset" "ichar" "ieor" "index" "int" "ior" "ishft"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;; "ishftc" "kind" "lbound" "len" "len_trim" "lge" "lgt" "lle" "llt" "log"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;; "logical" "log10" "matmul" "max" "maxexponent" "maxloc" "maxval" "merge"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;; "min" "minexponent" "minloc" "minval" "mod" "modulo" "mvbits" "nearest"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; "nint" "not" "pack" "precision" "present" "product" "radix"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;; "random_number" "random_seed" "range" "real" "repeat" "reshape"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;; "rrspacing" "scale" "scan" "selected_int_kind" "selected_real_kind"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;; "set_exponent" "shape" "sign" "sin" "sinh" "size" "spacing" "spread"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; "sqrt" "sum" "system_clock" "tan" "tanh" "tiny" "transfer" "transpose"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; "trim" "ubound" "unpack" "verify")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; A left paranthesis to avoid highlighting non-procedures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; Real is taken out here to avoid highlighting declarations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 "\\<\\(a\\(bs\\|c\\(har\\|os\\)\\|djust[lr]\\|i\\(mag\\|nt\\)\\|ll\\(\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 "ocated\\)\\|n\\(int\\|y\\)\\|s\\(in\\|sociated\\)\\|tan2?\\)\\|b\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "it_size\\|test\\)\\|c\\(eiling\\|har\\|mplx\\|o\\(njg\\|sh?\\|unt\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "shift\\)\\|d\\(ate_and_time\\|ble\\|i\\(gits\\|m\\)\\|ot_product\\|prod"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 "\\)\\|e\\(oshift\\|psilon\\|xp\\(\\|onent\\)\\)\\|f\\(loor\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 "raction\\)\\|huge\\|i\\(a\\(char\\|nd\\)\\|b\\(clr\\|its\\|set\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 "char\\|eor\\|n\\(dex\\|t\\)\\|or\\|shftc?\\)\\|kind\\|l\\(bound\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 "en\\(\\|_trim\\)\\|g[et]\\|l[et]\\|og\\(\\|10\\|ical\\)\\)\\|m\\(a\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 "tmul\\|x\\(\\|exponent\\|loc\\|val\\)\\)\\|erge\\|in\\(\\|exponent\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "loc\\|val\\)\\|od\\(\\|ulo\\)\\|vbits\\)\\|n\\(earest\\|int\\|ot\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "p\\(ack\\|r\\(e\\(cision\\|sent\\)\\|oduct\\)\\)\\|r\\(a\\(dix\\|n\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 "dom_\\(number\\|seed\\)\\|ge\\)\\)\\|e\\(peat\\|shape\\)\\|rspacing\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 "s\\(ca\\(le\\|n\\)\\|e\\(lected_\\(int_kind\\|real_kind\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "t_exponent\\)\\|hape\\|i\\(gn\\|nh?\\|ze\\)\\|p\\(acing\\|read\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 "qrt\\|um\\|ystem_clock\\)\\|t\\(anh?\\|iny\\|r\\(ans\\(fer\\|pose\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 "im\\)\\)\\|u\\(bound\\|npack\\)\\|verify\\)[ \t]*(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 "Regexp whose first part matches F90 intrinsic procedures.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (defconst f90-operators-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;; "and" "or" "not" "eqv" "neqv" "eq" "ne" "lt" "le" "gt" "ge" "true" "false"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "\\.\\(and\\|eqv?\\|false\\|g[et]\\|l[et]\\|n\\(e\\(\\|qv\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 "ot\\)\\|or\\|true\\)\\.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 "Regexp matching intrinsic operators.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (defconst f90-hpf-keywords-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;; Intrinsic procedures
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;; ("all_prefix" "all_scatter" "all_suffix" "any_prefix" "any_scatter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; "any_suffix" "copy_prefix" "copy_scatter" "copy_suffix" "count_prefix"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;; "count_scatter" "count_suffix" "grade_down" "grade_up" "hpf_alignment"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;; "hpf_template" "hpf_distribution" "iall" "iall_prefix" "iall_scatter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;; "iall_suffix" "iany" "iany_prefix" "iany_scatter" "iany_suffix" "iparity"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; "iparity_prefix" "iparity_scatter" "iparity_suffix" "leadz"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; "maxval_prefix" "maxval_scatter" "maxval_suffix" "minval_prefix"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; "minval_scatter" "minval_suffix" "parity" "parity_prefix"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; "parity_scatter" "parity_suffix" "popcnt" "poppar" "product_prefix"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;; "product_scatter" "product_suffix" "sum_prefix" "sum_scatter"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;; "sum_suffix" "ilen" "number_of_processors" "processors_shape")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; Directives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; ("align" "distribute" "dynamic" "inherit" "template" "processors"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; "realign" "redistribute" "independent")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; Keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; ("pure" "extrinsic" "new" "with" "onto" "block" "cyclic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "\\<\\(a\\(l\\(ign\\|l_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|ny_\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 "prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|block\\|c\\(o\\(py_\\(prefix\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "s\\(catter\\|uffix\\)\\)\\|unt_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 "yclic\\)\\|d\\(istribute\\|ynamic\\)\\|extrinsic\\|grade_\\(down\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 "up\\)\\|hpf_\\(alignment\\|distribution\\|template\\)\\|i\\(a\\(ll\\(\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|ny\\(\\|_\\(prefix\\|s\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 "catter\\|uffix\\)\\)\\)\\)\\|len\\|n\\(dependent\\|herit\\)\\|parity\\(\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 "_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\)\\|leadz\\|m\\(axval_\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 "prefix\\|s\\(catter\\|uffix\\)\\)\\|inval_\\(prefix\\|s\\(catter\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 "uffix\\)\\)\\)\\|n\\(ew\\|umber_of_processors\\)\\|onto\\|p\\(arity\\(\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 "_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|op\\(cnt\\|par\\)\\|ro\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "cessors\\(\\|_shape\\)\\|duct_\\(prefix\\|s\\(catter\\|uffix\\)\\)\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 "ure\\)\\|re\\(align\\|distribute\\)\\|sum_\\(prefix\\|s\\(catter\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 "uffix\\)\\)\\|template\\|with\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 "Regexp for all HPF keywords, procedures and directives.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;; Highlighting patterns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (defvar f90-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (list ; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 '("\\<\\(end[ \t]*\\(program\\|module\\|function\\|subroutine\\|type\\)\\)\\>"
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 '("\\<\\(end[ \t]*\\(program\\|module\\|function\\|subroutine\\|type\\)\\)\\>[ \t]*\\(\\sw+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 3 font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 '("\\<\\(program\\|call\\|module\\|subroutine\\|function\\|use\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 1 font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 '("\\<\\(program\\|call\\|module\\|subroutine\\|function\\|use\\)\\>[ \t]*\\(\\sw+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 2 font-lock-function-name-face nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; Special highlighting of "module procedure foo-list"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 '("\\<\\(module[ \t]*procedure\\)\\>" 1 font-lock-keyword-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; Highlight definition of new type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 '("\\<\\(type\\)[ \t]*\\(,.*::[ \t]*\\|[ \t]+\\)\\(\\sw+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 1 font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 '("\\<\\(type\\)[ \t]*\\(,.*::[ \t]*\\|[ \t]+\\)\\(\\sw+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 3 font-lock-function-name-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 "\\<\\(\\(end[ \t]*\\)?\\(interface\\|block[ \t]*data\\)\\|contains\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (list ; Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 '("\\<\\(end[ \t]*\\(program\\|module\\|function\\|subroutine\\|type\\)\\)\\>[ \t]*\\(\\sw+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 '("\\<\\(program\\|call\\|module\\|subroutine\\|function\\|use\\)\\>[ \t]*\\(\\sw+\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; Special highlighting of "module procedure foo-list"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 '("\\<\\(module[ \t]*procedure\\)\\>" (1 font-lock-keyword-face t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;; Highlight definition of new type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 '("\\<\\(type\\)[ \t]*\\(,.*::[ \t]*\\|[ \t]+\\)\\(\\sw+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (1 font-lock-keyword-face) (3 font-lock-function-name-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 "\\<\\(\\(end[ \t]*\\)?\\(interface\\|block[ \t]*data\\)\\|contains\\)\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 "This does fairly subdued highlighting of comments and function calls.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (defvar f90-font-lock-keywords-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (append f90-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (list ; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;; Variable declarations (avoid the real function call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 '("^[ \t0-9]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 1 font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 '("^[ \t0-9]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\)\\(.*::\\|[ \t]*(.*)\\)?\\(.*\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 4 font-lock-doc-string-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;; do, if and select constructs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 '("\\<\\(end[ \t]*\\(do\\|if\\|select\\)\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 1 font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 '("\\<\\(end[ \t]*\\(do\\|if\\|select\\)\\)\\>\\([ \t]+\\(\\sw+\\)\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 3 font-lock-doc-string-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 '("^[ \t0-9]*\\(\\(\\sw+\\)[ \t]*:[ \t]*\\)\\(\\(if\\|do\\([ \t]*while\\)?\\|select[ \t]*case\\)\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 2 font-lock-doc-string-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 '("^[ \t0-9]*\\(\\(\\sw+\\)[ \t]*:[ \t]*\\)?\\(\\(if\\|do\\([ \t]*while\\)?\\|select[ \t]*case\\)\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 3 font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ;; implicit declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 '("\\<\\(implicit\\)[ \t]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\|none\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 1 font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 '("\\<\\(implicit\\)[ \t]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\|none\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 2 font-lock-type-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 '("\\<\\(namelist\\|common\\)[ \t]*\/\\(\\sw+\\)?\/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 1 font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 '("\\<\\(namelist\\|common\\)[ \t]*\/\\(\\sw+\\)\/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 2 font-lock-doc-string-face nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 '("\\<\\(where\\|forall\\)[ \t]*(" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "\\<e\\(lse\\([ \t]*if\\|where\\)?\\|nd[ \t]*\\(where\\|forall\\)\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 "\\<\\(then\\|continue\\|format\\|include\\|stop\\|return\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 '("\\<\\(exit\\|cycle\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 1 font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 '("\\<\\(exit\\|cycle\\)[ \t]*\\(\\sw+\\)2\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 2 font-lock-doc-string-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 '("\\<\\(case\\)[ \t]*\\(default\\|(\\)" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 '("\\<\\(do\\|go *to\\)\\>[ \t]*\\([0-9]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 1 font-lock-keyword-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 '("\\<\\(do\\|go *to\\)\\>[ \t]*\\([0-9]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 2 font-lock-doc-string-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 '("^[ \t]*\\([0-9]+\\)" 1 font-lock-doc-string-face t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (list ; Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ;; Variable declarations (avoid the real function call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 '("^[ \t0-9]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\)\\(.*::\\|[ \t]*(.*)\\)?\\(.*\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (1 font-lock-type-face) (4 font-lock-variable-name-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;; do, if and select constructs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 '("\\<\\(end[ \t]*\\(do\\|if\\|select\\)\\)\\>\\([ \t]+\\(\\sw+\\)\\)?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (1 font-lock-keyword-face) (3 font-lock-reference-face nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 '("^[ \t0-9]*\\(\\(\\sw+\\)[ \t]*:[ \t]*\\)?\\(\\(if\\|do\\([ \t]*while\\)?\\|select[ \t]*case\\)\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (2 font-lock-reference-face nil t) (3 font-lock-keyword-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ;; implicit declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 '("\\<\\(implicit\\)[ \t]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\|none\\)\\>" (1 font-lock-keyword-face) (2 font-lock-type-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 '("\\<\\(namelist\\|common\\)[ \t]*\/\\(\\sw+\\)?\/" (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 '("\\<\\(where\\|forall\\)[ \t]*(" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 "\\<e\\(lse\\([ \t]*if\\|where\\)?\\|nd[ \t]*\\(where\\|forall\\)\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 "\\<\\(then\\|continue\\|format\\|include\\|stop\\|return\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 '("\\<\\(exit\\|cycle\\)[ \t]*\\(\\sw+\\)?\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 '("\\<\\(case\\)[ \t]*\\(default\\|(\\)" . 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 '("\\<\\(do\\|go *to\\)\\>[ \t]*\\([0-9]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (1 font-lock-keyword-face) (2 font-lock-reference-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 '("^[ \t]*\\([0-9]+\\)" (1 font-lock-reference-face t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 "Highlights declarations, do-loops and other constructions")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (defvar f90-font-lock-keywords-3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (append f90-font-lock-keywords-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 f90-keywords-level-3-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 f90-operators-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (append (list f90-procedures-re) '(1 font-lock-keyword-face t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (list f90-procedures-re '(1 font-lock-keyword-face t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 "\\<real\\>" ; Avoid overwriting real defs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 "Highlights all F90 keywords and intrinsic procedures.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (defvar f90-font-lock-keywords-4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (append f90-font-lock-keywords-3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (list f90-hpf-keywords-re))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 "Highlights all F90 and HPF keywords.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (defvar f90-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 f90-font-lock-keywords-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 "*Default expressions to highlight in F90 mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ;; syntax table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (defvar f90-mode-syntax-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 "Syntax table in use in F90 mode buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (if f90-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (setq f90-mode-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (modify-syntax-entry ?\! "<" f90-mode-syntax-table) ; beg. comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (modify-syntax-entry ?\n ">" f90-mode-syntax-table) ; end comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (modify-syntax-entry ?_ "w" f90-mode-syntax-table) ; underscore in names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (modify-syntax-entry ?\' "\"" f90-mode-syntax-table) ; string quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (modify-syntax-entry ?\" "\"" f90-mode-syntax-table) ; string quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (modify-syntax-entry ?\` "w" f90-mode-syntax-table) ; for abbrevs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (modify-syntax-entry ?\r " " f90-mode-syntax-table) ; return is whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (modify-syntax-entry ?+ "." f90-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (modify-syntax-entry ?- "." f90-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (modify-syntax-entry ?= "." f90-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (modify-syntax-entry ?* "." f90-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (modify-syntax-entry ?/ "." f90-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (modify-syntax-entry ?\\ "/" f90-mode-syntax-table)) ; escape chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;; keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (defvar f90-mode-map ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 "Keymap used in F90 mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (if f90-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (setq f90-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (define-key f90-mode-map "`" 'f90-abbrev-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (define-key f90-mode-map "\C-c;" 'f90-comment-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (define-key f90-mode-map "\C-\M-a" 'f90-beginning-of-subprogram)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (define-key f90-mode-map "\C-\M-e" 'f90-end-of-subprogram)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (define-key f90-mode-map "\C-\M-h" 'f90-mark-subprogram)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (define-key f90-mode-map "\C-\M-q" 'f90-indent-subprogram)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (define-key f90-mode-map "\C-j" 'f90-indent-new-line) ; LFD equals C-j
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (define-key f90-mode-map "\r" 'newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (define-key f90-mode-map "\C-c\r" 'f90-break-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;; (define-key f90-mode-map [M-return] 'f90-break-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (define-key f90-mode-map "\C-c\C-d" 'f90-join-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (define-key f90-mode-map "\C-c\C-f" 'f90-fill-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (define-key f90-mode-map "\C-c\C-p" 'f90-previous-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (define-key f90-mode-map "\C-c\C-n" 'f90-next-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (define-key f90-mode-map "\C-c\C-w" 'f90-insert-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (define-key f90-mode-map "\t" 'f90-indent-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (defvar f90-xemacs-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 '("F90"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ["Indent Subprogram" f90-indent-subprogram t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ["Mark Subprogram" f90-mark-subprogram t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ["Beginning of Subprogram" f90-beginning-of-subprogram t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ["End of Subprogram" f90-end-of-subprogram t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 "-----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ["(Un)Comment Region" f90-comment-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ["Indent Region" indent-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ["Fill Region" f90-fill-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 "-----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ["Break Line at Point" f90-break-line t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ["Join with Next Line" f90-join-lines t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ["Insert Newline" newline t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ["Insert End" f90-insert-end t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 "-----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ["Upcase Keywords (buffer)" f90-upcase-keywords t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ["Upcase Keywords (region)" f90-upcase-region-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 ["Capitalize Keywords (buffer)" f90-capitalize-keywords t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 ["Capitalize Keywords (region)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 f90-capitalize-region-keywords t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ["Downcase Keywords (buffer)" f90-downcase-keywords t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ["Downcase Keywords (region)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 f90-downcase-region-keywords t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 "-----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ["Toggle abbrev-mode" abbrev-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ["Toggle auto-fill" f90-auto-fill-mode t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 "XEmacs menu for F90 mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 ;; Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (define-key f90-mode-map [menu-bar] (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (define-key f90-mode-map [menu-bar f90]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (cons "F90" (make-sparse-keymap "f90")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (define-key f90-mode-map [menu-bar f90 abbrev-mode]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 '("Toggle abbrev-mode" . abbrev-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (define-key f90-mode-map [menu-bar f90 f90-auto-fill-mode]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 '("Toggle auto-fill" . f90-auto-fill-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (define-key f90-mode-map [menu-bar f90 f90-downcase-region-keywords]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 '("Downcase Keywords (region)" . f90-downcase-region-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (define-key f90-mode-map [menu-bar f90 f90-downcase-keywords]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 '("Downcase Keywords (buffer)" . f90-downcase-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (define-key f90-mode-map [menu-bar f90 f90-capitalize-keywords]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 '("Capitalize Keywords (region)" . f90-capitalize-region-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (define-key f90-mode-map [menu-bar f90 f90-capitalize-region-keywords]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 '("Capitalize Keywords (buffer)" . f90-capitalize-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (define-key f90-mode-map [menu-bar f90 f90-upcase-region-keywords]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 '("Upcase Keywords (region)" . f90-upcase-region-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (define-key f90-mode-map [menu-bar f90 f90-upcase-keywords]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 '("Upcase Keywords (buffer)" . f90-upcase-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (define-key f90-mode-map [menu-bar f90 f90-insert-end]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 '("Insert end" . f90-insert-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (define-key f90-mode-map [menu-bar f90 f90-join-lines]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 '("Join with Next Line" . f90-join-lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (define-key f90-mode-map [menu-bar f90 f90-break-line]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 '("Break Line at Point" . f90-break-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (define-key f90-mode-map [menu-bar f90 f90-fill-region]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 '("Fill Region" . f90-fill-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (define-key f90-mode-map [menu-bar f90 indent-region]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 '("Indent Region" . indent-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (define-key f90-mode-map [menu-bar f90 f90-comment-region]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 '("(Un)Comment Region" . f90-comment-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (define-key f90-mode-map [menu-bar f90 f90-end-of-subprogram]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 '("End of Subprogram" . f90-end-of-subprogram))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (define-key f90-mode-map [menu-bar f90 f90-beginning-of-subprogram]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 '("Beginning of Subprogram" . f90-beginning-of-subprogram))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (define-key f90-mode-map [menu-bar f90 f90-mark-subprogram]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 '("Mark Subprogram" . f90-mark-subprogram))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (define-key f90-mode-map [menu-bar f90 f90-indent-subprogram]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 '("Indent Subprogram" . f90-indent-subprogram)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ;; Regexps for finding program structures.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (defconst f90-blocks-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 "\\(block[ \t]*data\\|do\\|if\\|interface\\|function\\|module\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 program\\|select\\|subroutine\\|type\\|where\\|forall\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (defconst f90-program-block-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 "\\(program\\|module\\|subroutine\\|function\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (defconst f90-else-like-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 "\\(else\\([ \t]*if\\|where\\)?\\|case[ \t]*\\(default\\|(\\)\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (defconst f90-end-if-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 "end[ \t]*\\(if\\|select\\|where\\|forall\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (defconst f90-end-type-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 "end[ \t]*\\(type\\|interface\\|block[ \t]*data\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defconst f90-type-def-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 "\\<\\(type\\)[ \t]*\\(,.*::[ \t]*\\|[ \t]+\\)\\(\\sw+\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (defconst f90-no-break-re "\\(\\*\\*\\|//\\|=>\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;; A temporary position to make region operators faster
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (defvar f90-cache-position nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (make-variable-buffer-local 'f90-cache-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ;; Imenu support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (defvar f90-imenu-generic-expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 "^[ \t0-9]*\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 "program[ \t]+\\(\\sw+\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 "module[ \t]+\\(\\sw+\\)[ \t]*\\(!\\|$\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 "\\(pure\\|recursive\\|extrinsic([^)]+)\\)?[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 "subroutine[ \t]+\\(\\sw+\\)\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ; avoid end function, but allow for most other things
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 "\\([^!]*\\([^e!].[^ \t!]\\|.[^n!][^ \t!]\\|..[^d \t!]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 "\\|[^!]?[^!]?\\)[ \t]*function[ \t]+\\(\\sw+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 "\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (list 2 3 6 9))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 "imenu generic expression for F90 mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;; When compiling under GNU Emacs, load imenu during compilation. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; you have 19.22 or earlier, comment this out, or get imenu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (and (fboundp 'eval-when-compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (if (not (string-match "XEmacs" emacs-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (require 'imenu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 ;; abbrevs have generally two letters, except standard types `c, `i, `r, `t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (defvar f90-mode-abbrev-table nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (if f90-mode-abbrev-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (let ((ac abbrevs-changed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (define-abbrev-table 'f90-mode-abbrev-table ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (define-abbrev f90-mode-abbrev-table "`al" "allocate" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (define-abbrev f90-mode-abbrev-table "`ab" "allocatable" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (define-abbrev f90-mode-abbrev-table "`as" "assignment" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (define-abbrev f90-mode-abbrev-table "`ba" "backspace" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (define-abbrev f90-mode-abbrev-table "`bd" "block data" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (define-abbrev f90-mode-abbrev-table "`c" "character" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (define-abbrev f90-mode-abbrev-table "`cl" "close" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (define-abbrev f90-mode-abbrev-table "`cm" "common" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (define-abbrev f90-mode-abbrev-table "`cx" "complex" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (define-abbrev f90-mode-abbrev-table "`cn" "contains" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (define-abbrev f90-mode-abbrev-table "`cy" "cycle" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (define-abbrev f90-mode-abbrev-table "`de" "deallocate" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (define-abbrev f90-mode-abbrev-table "`df" "define" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (define-abbrev f90-mode-abbrev-table "`di" "dimension" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (define-abbrev f90-mode-abbrev-table "`dw" "do while" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (define-abbrev f90-mode-abbrev-table "`el" "else" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (define-abbrev f90-mode-abbrev-table "`eli" "else if" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (define-abbrev f90-mode-abbrev-table "`elw" "elsewhere" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (define-abbrev f90-mode-abbrev-table "`eq" "equivalence" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (define-abbrev f90-mode-abbrev-table "`ex" "external" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (define-abbrev f90-mode-abbrev-table "`ey" "entry" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (define-abbrev f90-mode-abbrev-table "`fl" "forall" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (define-abbrev f90-mode-abbrev-table "`fo" "format" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (define-abbrev f90-mode-abbrev-table "`fu" "function" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (define-abbrev f90-mode-abbrev-table "`fa" ".false." nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (define-abbrev f90-mode-abbrev-table "`im" "implicit none" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (define-abbrev f90-mode-abbrev-table "`in " "include" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (define-abbrev f90-mode-abbrev-table "`i" "integer" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (define-abbrev f90-mode-abbrev-table "`it" "intent" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (define-abbrev f90-mode-abbrev-table "`if" "interface" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (define-abbrev f90-mode-abbrev-table "`lo" "logical" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (define-abbrev f90-mode-abbrev-table "`mo" "module" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (define-abbrev f90-mode-abbrev-table "`na" "namelist" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (define-abbrev f90-mode-abbrev-table "`nu" "nullify" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (define-abbrev f90-mode-abbrev-table "`op" "optional" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (define-abbrev f90-mode-abbrev-table "`pa" "parameter" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (define-abbrev f90-mode-abbrev-table "`po" "pointer" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (define-abbrev f90-mode-abbrev-table "`pr" "print" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (define-abbrev f90-mode-abbrev-table "`pi" "private" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (define-abbrev f90-mode-abbrev-table "`pm" "program" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (define-abbrev f90-mode-abbrev-table "`pu" "public" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (define-abbrev f90-mode-abbrev-table "`r" "real" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (define-abbrev f90-mode-abbrev-table "`rc" "recursive" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (define-abbrev f90-mode-abbrev-table "`rt" "return" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (define-abbrev f90-mode-abbrev-table "`rw" "rewind" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (define-abbrev f90-mode-abbrev-table "`se" "select" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (define-abbrev f90-mode-abbrev-table "`sq" "sequence" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (define-abbrev f90-mode-abbrev-table "`su" "subroutine" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (define-abbrev f90-mode-abbrev-table "`ta" "target" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (define-abbrev f90-mode-abbrev-table "`tr" ".true." nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (define-abbrev f90-mode-abbrev-table "`t" "type" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (define-abbrev f90-mode-abbrev-table "`wh" "where" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (define-abbrev f90-mode-abbrev-table "`wr" "write" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (setq abbrevs-changed ac)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (defun f90-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 "Major mode for editing Fortran 90 code in free format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 \\[f90-indent-new-line] corrects current indentation and creates new\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 indented line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 \\[f90-indent-line] indents the current line correctly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 \\[f90-indent-subprogram] indents the current subprogram.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 Type `? or `\\[help-command] to display a list of built-in\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 abbrevs for F90 keywords.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 Key definitions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 \\{f90-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 Variables controlling indentation style and extra features:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 f90-do-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 Extra indentation within do blocks. (default 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 f90-if-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 Extra indentation within if/select case/where/forall blocks. (default 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 f90-type-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 Extra indentation within type/interface/block-data blocks. (default 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 f90-program-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 Extra indentation within program/module/subroutine/function blocks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (default 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 f90-continuation-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 Extra indentation applied to continuation lines. (default 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 f90-comment-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 String inserted by \\[f90-comment-region] at start of each line in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 region. (default \"!!!$\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 f90-indented-comment-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 Regexp determining the type of comment to be intended like code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (default \"!\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 f90-directive-comment-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 Regexp of comment-like directive like \"!HPF\\\\$\", not to be indented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (default \"!hpf\\\\$\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 f90-break-delimiters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 Regexp holding list of delimiters at which lines may be broken.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (default \"[-+*/><=,% \\t]\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 f90-break-before-delimiters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 Non-nil causes `f90-do-auto-fill' to break lines before delimiters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (default t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 f90-beginning-ampersand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 Automatic insertion of \& at beginning of continuation lines. (default t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 f90-smart-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 From an END statement, check and fill the end using matching block start.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 Allowed values are 'blink, 'no-blink, and nil, which determine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 whether to blink the matching beginning.) (default 'blink)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 f90-auto-keyword-case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 Automatic change of case of keywords. (default nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 The possibilities are 'downcase-word, 'upcase-word, 'capitalize-word.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 f90-leave-line-no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 Do not left-justify line numbers. (default nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 f90-startup-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 Set to nil to inhibit message first time F90 mode is used. (default t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 f90-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 List of keywords used for highlighting/upcase-keywords etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 Turning on F90 mode calls the value of the variable `f90-mode-hook'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 with no args, if that value is non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (setq major-mode 'f90-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (setq mode-name "F90")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (setq local-abbrev-table f90-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (set-syntax-table f90-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (use-local-map f90-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (make-local-variable 'indent-line-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (setq indent-line-function 'f90-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (make-local-variable 'indent-region-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (setq indent-region-function 'f90-indent-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (make-local-variable 'require-final-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (setq require-final-newline t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (make-local-variable 'comment-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (setq comment-start "!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (make-local-variable 'comment-start-skip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (setq comment-start-skip "!+ *")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (make-local-variable 'comment-indent-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (setq comment-indent-function 'f90-comment-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (make-local-variable 'abbrev-all-caps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (setq abbrev-all-caps t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (setq indent-tabs-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ;; Setting up things for font-lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (if (and current-menubar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (not (assoc "F90" current-menubar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (set-buffer-menubar (copy-sequence current-menubar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (add-submenu nil f90-xemacs-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ;; XEmacs now does things like FSF Emacs -- ben
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (make-local-variable 'font-lock-defaults)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (setq font-lock-defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 '((f90-font-lock-keywords f90-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 f90-font-lock-keywords-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 f90-font-lock-keywords-3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 f90-font-lock-keywords-4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ;; Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (make-local-variable 'font-lock-defaults)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (setq font-lock-defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 '((f90-font-lock-keywords f90-font-lock-keywords-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 f90-font-lock-keywords-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 f90-font-lock-keywords-3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 f90-font-lock-keywords-4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ;; Tell imenu how to handle f90.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (make-local-variable 'imenu-generic-expression)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (setq imenu-generic-expression f90-imenu-generic-expression))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (run-hooks 'f90-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (if f90-startup-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (message "Emacs F90 mode; please report bugs to %s" bug-f90-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (setq f90-startup-message nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 ;; inline-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (defsubst f90-get-beg-of-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (defsubst f90-get-end-of-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (save-excursion (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (defsubst f90-in-string ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (let ((beg-pnt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (if (and f90-cache-position (> (point) f90-cache-position))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 f90-cache-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (nth 3 (parse-partial-sexp beg-pnt (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (defsubst f90-in-comment ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (let ((beg-pnt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (if (and f90-cache-position (> (point) f90-cache-position))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 f90-cache-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (nth 4 (parse-partial-sexp beg-pnt (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (defsubst f90-line-continued ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (let ((bol (f90-get-beg-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (while (f90-in-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (search-backward "!" bol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (skip-chars-backward "!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (= (preceding-char) ?&))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (defsubst f90-current-indentation ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 "Return indentation of current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 Line-numbers are considered whitespace characters."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (beginning-of-line) (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (defsubst f90-indent-to (col &optional no-line-number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 "Indent current line to column COL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 If no-line-number nil, jump over a possible line-number."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (if (not no-line-number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (skip-chars-forward " \t0-9"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (if (zerop (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (indent-to col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (indent-to col 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (defsubst f90-match-piece (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (if (match-beginning arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (buffer-substring (match-beginning arg) (match-end arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (defsubst f90-get-present-comment-type ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (let ((type nil) (eol (f90-get-end-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (if (f90-in-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (re-search-forward "[!]+" eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (while (f90-in-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (re-search-forward "[!]+" eol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (setq type (buffer-substring (match-beginning 0) (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (defsubst f90-equal-symbols (a b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 "Compare strings neglecting case and allowing for nil value."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (let ((a-local (if a (downcase a) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (b-local (if b (downcase b) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (equal a-local b-local)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ;; XEmacs 19.11 & 19.12 gives back a single char when matching an empty regular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 ;; expression. Therefore, the next 2 functions are longer than necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (defsubst f90-looking-at-do ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 "Return (\"do\" name) if a do statement starts after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 Name is nil if the statement has no label."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(do\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (let (label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (struct (f90-match-piece 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (if (looking-at "\\(\\sw+\\)[ \t]*\:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (setq label (f90-match-piece 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (list struct label))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (defsubst f90-looking-at-select-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 "Return (\"select\" name) if a select-case statement starts after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 Name is nil if the statement has no label."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(select\\)[ \t]*case[ \t]*(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (let (label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (struct (f90-match-piece 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (if (looking-at "\\(\\sw+\\)[ \t]*\:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (setq label (f90-match-piece 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (list struct label))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (defsubst f90-looking-at-if-then ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 "Return (\"if\" name) if an if () then statement starts after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 Name is nil if the statement has no label."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (let (struct (label nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(if\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (setq struct (f90-match-piece 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (if (looking-at "\\(\\sw+\\)[ \t]*\:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (setq label (f90-match-piece 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (goto-char (scan-lists (point) 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (if (or (looking-at "then\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (if (f90-line-continued)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (f90-next-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (skip-chars-forward " \t0-9&")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (looking-at "then\\>"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (list struct label)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (defsubst f90-looking-at-where-or-forall ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 "Return (kind nil) if where/forall...end starts after point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (let (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (if (looking-at "\\(where\\|forall\\)[ \t]*(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (setq command (list (f90-match-piece 1) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (goto-char (scan-lists (point) 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (if (looking-at "\\(!\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 command))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (defsubst f90-looking-at-type-like ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 "Return (kind name) at the start of a type/interface/block-data block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 Name is non-nil only for type."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 ((looking-at f90-type-def-re)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (list (f90-match-piece 1) (f90-match-piece 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 ((looking-at "\\(interface\\|block[\t]*data\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (list (f90-match-piece 1) nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (defsubst f90-looking-at-program-block-start ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 "Return (kind name) if a program block with name name starts after point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ((looking-at "\\(program\\)[ \t]+\\(\\sw+\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (list (f90-match-piece 1) (f90-match-piece 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ((and (not (looking-at "module[ \t]*procedure\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (looking-at "\\(module\\)[ \t]+\\(\\sw+\\)\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (list (f90-match-piece 1) (f90-match-piece 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 ((looking-at (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 "\\(pure\\|recursive\\|extrinsic([^)]+)\\)?[ \t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 "\\(subroutine\\)[ \t]+\\(\\sw+\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (list (f90-match-piece 2) (f90-match-piece 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 ((and (not (looking-at "end[ \t]*function"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (looking-at "[^!\"\&\\n]*\\(function\\)[ \t]+\\(\\sw+\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (list (f90-match-piece 1) (f90-match-piece 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (defsubst f90-looking-at-program-block-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 "Return list of type and name of end of block."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (if (looking-at (concat "end[ \t]*" f90-blocks-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 "?\\([ \t]+\\(\\sw+\\)\\)?\\>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (list (f90-match-piece 1) (f90-match-piece 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (defsubst f90-comment-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (cond ((looking-at "!!!") 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 ((and f90-directive-comment-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (looking-at f90-directive-comment-re)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 ((looking-at (regexp-quote f90-comment-region)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 ((looking-at f90-indented-comment-re)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (f90-calculate-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (t (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (max (if (bolp) 0 (1+ (current-column))) comment-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (defsubst f90-present-statement-cont ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 "Return continuation properties of present statement."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (let (pcont cont)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (setq pcont (if (f90-previous-statement) (f90-line-continued) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (setq cont (f90-line-continued))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (cond ((and (not pcont) (not cont)) 'single)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ((and (not pcont) cont) 'begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 ((and pcont (not cont)) 'end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 ((and pcont cont) 'middle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (t (error)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (defsubst f90-indent-line-no ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (if f90-leave-line-no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (if (and (not (zerop (skip-chars-forward " \t")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (looking-at "[0-9]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (delete-horizontal-space)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (skip-chars-forward " \t0-9"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (defsubst f90-no-block-limit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (let ((eol (f90-get-end-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (not (or (looking-at "end")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (looking-at "\\(do\\|if\\|else\\|select[ \t]*case\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 case\\|where\\|forall\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (looking-at "\\(program\\|module\\|interface\\|\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 block[ \t]*data\\)\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (looking-at "\\(contains\\|\\sw+[ \t]*:\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (looking-at f90-type-def-re)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (re-search-forward "\\(function\\|subroutine\\)" eol t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (defsubst f90-update-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (let (bol eol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (if f90-auto-keyword-case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (progn (setq bol (f90-get-beg-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 eol (f90-get-end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (if f90-auto-keyword-case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (f90-change-keywords f90-auto-keyword-case bol eol))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (defun f90-get-correct-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 "Get correct indent for a line starting with line number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 Does not check type and subprogram indentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (let ((epnt (f90-get-end-of-line)) icol cont)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (while (and (f90-previous-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (or (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (setq cont (f90-present-statement-cont))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (or (eq cont 'end) (eq cont 'middle)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (looking-at "[ \t]*[0-9]"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (setq icol (current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (if (re-search-forward "\\(if\\|do\\|select\\|where\\|forall\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (f90-get-end-of-line) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (beginning-of-line) (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (cond ((f90-looking-at-do)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (setq icol (+ icol f90-do-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ((or (f90-looking-at-if-then)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (f90-looking-at-where-or-forall)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (f90-looking-at-select-case))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (setq icol (+ icol f90-if-indent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (end-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 "\\(if\\|do\\|select\\|where\\|forall\\)" epnt t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (beginning-of-line) (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (cond ((f90-looking-at-do)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (setq icol (+ icol f90-do-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 ((or (f90-looking-at-if-then)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (f90-looking-at-where-or-forall)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (f90-looking-at-select-case))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (setq icol (+ icol f90-if-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 ((looking-at f90-end-if-re)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (setq icol (- icol f90-if-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 ((looking-at "end[ \t]*do\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (setq icol (- icol f90-do-indent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 icol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (defun f90-calculate-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 "Calculate the indent column based on previous statements."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (let (icol cont (case-fold-search t) (pnt (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (if (not (f90-previous-statement))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (setq icol 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (setq cont (f90-present-statement-cont))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (if (eq cont 'end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (while (not (eq 'begin (f90-present-statement-cont)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (f90-previous-statement)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (cond ((eq cont 'begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (setq icol (+ (f90-current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 f90-continuation-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 ((eq cont 'middle) (setq icol(current-indentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (t (setq icol (f90-current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (if (looking-at "[0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (setq icol (f90-get-correct-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (cond ((or (f90-looking-at-if-then)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (f90-looking-at-where-or-forall)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (f90-looking-at-select-case)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (looking-at f90-else-like-re))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (setq icol (+ icol f90-if-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 ((f90-looking-at-do)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (setq icol (+ icol f90-do-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 ((f90-looking-at-type-like)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (setq icol (+ icol f90-type-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 ((or (f90-looking-at-program-block-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (looking-at "contains[ \t]*\\($\\|!\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (setq icol (+ icol f90-program-indent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (goto-char pnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (cond ((looking-at "[ \t]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 ((looking-at "[ \t]*#") ; Check for cpp directive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (setq icol 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (cond ((or (looking-at f90-else-like-re)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (looking-at f90-end-if-re))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (setq icol (- icol f90-if-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 ((looking-at "end[ \t]*do\\>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (setq icol (- icol f90-do-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 ((looking-at f90-end-type-re)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (setq icol (- icol f90-type-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 ((or (looking-at "contains[ \t]*\\(!\\|$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (f90-looking-at-program-block-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (setq icol (- icol f90-program-indent))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 icol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 ;; Statement = statement line, a line which is neither blank, nor a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (defun f90-previous-statement ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 "Move point to beginning of the previous F90 statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 Return nil if no previous statement is found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (let (not-first-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (while (and (setq not-first-statement (zerop (forward-line -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (looking-at "[ \t0-9]*\\(!\\|$\\|#\\)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 not-first-statement))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (defun f90-next-statement ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 "Move point to beginning of the next F90 statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 Return nil if no later statement is found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (let (not-last-statement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (while (and (setq not-last-statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (and (zerop (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (not (eobp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (looking-at "[ \t0-9]*\\(!\\|$\\)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 not-last-statement))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (defun f90-beginning-of-subprogram ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 "Move point to the beginning of subprogram.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 Return (type name) or nil if not found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (let ((count 1) (case-fold-search t) matching-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (beginning-of-line) (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (if (setq matching-beg (f90-looking-at-program-block-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (setq count (- count 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (while (and (not (zerop count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (re-search-backward f90-program-block-re nil 'move))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (beginning-of-line) (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 ((setq matching-beg (f90-looking-at-program-block-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (setq count (- count 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 ((f90-looking-at-program-block-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (setq count (+ count 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (if (zerop count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 matching-beg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (message "No beginning-found.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (defun f90-end-of-subprogram ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 "Move point to the end of subprogram.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 Return (type name) or nil if not found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (let ((count 1) (case-fold-search t) matching-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (beginning-of-line) (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (if (setq matching-end (f90-looking-at-program-block-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (setq count (1- count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (while (and (not (zerop count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (re-search-forward f90-program-block-re nil 'move))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (beginning-of-line) (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (cond ((f90-looking-at-program-block-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (setq count (+ count 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 ((setq matching-end (f90-looking-at-program-block-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (setq count (1- count ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (if (zerop count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 matching-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (message "No end found.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (defun f90-mark-subprogram ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 "Put mark at end of F90 subprogram, point at beginning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 Marks are pushed and highlight (grey shadow) is turned on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (let ((pos (point)) program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (f90-end-of-subprogram)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (push-mark (point) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (goto-char pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (setq program (f90-beginning-of-subprogram))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 ;; The keywords in the preceding lists assume case-insensitivity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (zmacs-activate-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (setq mark-active t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (setq deactivate-mark nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 program))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (defun f90-comment-region (beg-region end-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 "Comment/uncomment every line in the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 Insert f90-comment-region at the beginning of every line in the region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 or, if already present, remove it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (let ((end (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (set-marker end end-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (goto-char beg-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (if (looking-at (regexp-quote f90-comment-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (delete-region (point) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (insert f90-comment-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (while (and (zerop (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (< (point) (marker-position end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (if (looking-at (regexp-quote f90-comment-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (delete-region (point) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (insert f90-comment-region)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (set-marker end nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (defun f90-indent-line (&optional no-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 "Indent current line as F90 code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (let (indent (no-line-number nil) (pos (make-marker)) (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (set-marker pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (beginning-of-line) ; Digits after & \n are not line-no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (if (save-excursion (and (f90-previous-statement) (f90-line-continued)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (progn (setq no-line-number t) (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (f90-indent-line-no))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (if (looking-at "!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (setq indent (f90-comment-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (if (and (looking-at "end") f90-smart-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (f90-match-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (setq indent (f90-calculate-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (if (zerop (- indent (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (f90-indent-to indent no-line-number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 ;; If initial point was within line's indentation,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ;; position after the indentation. Else stay at same point in text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (if (< (point) (marker-position pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (goto-char (marker-position pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (if (not no-update) (f90-update-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (if (and auto-fill-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (> (save-excursion (end-of-line) (current-column)) fill-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (save-excursion (f90-do-auto-fill)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (set-marker pos nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (defun f90-indent-new-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 "Reindent the current F90 line, insert a newline and indent the newline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 An abbrev before point is expanded if `abbrev-mode' is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 If run in the middle of a line, the line is not broken."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (let (string cont (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (if abbrev-mode (expand-abbrev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (beginning-of-line) ; Reindent where likely to be needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (f90-indent-line-no)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (if (or (looking-at "\\(end\\|else\\|!\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (f90-indent-line 'no-update))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (delete-horizontal-space) ;Destroy trailing whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (setq string (f90-in-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (setq cont (f90-line-continued))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (if (and string (not cont)) (insert "&"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (f90-update-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (if (or string (and cont f90-beginning-ampersand)) (insert "&"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (f90-indent-line 'no-update)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (defun f90-indent-region (beg-region end-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 "Indent every line in region by forward parsing."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (let ((end-region-mark (make-marker)) (save-point (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (block-list nil) ind-lev ind-curr ind-b cont
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 struct beg-struct end-struct)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (set-marker end-region-mark end-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (goto-char beg-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ;; first find a line which is not a continuation line or comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (while (and (looking-at "[ \t]*[0-9]*\\(!\\|#\\|[ \t]*$\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (progn (f90-indent-line 'no-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (zerop (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (< (point) end-region-mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (setq cont (f90-present-statement-cont))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (while (and (or (eq cont 'middle) (eq cont 'end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (f90-previous-statement))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (setq cont (f90-present-statement-cont)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 ;; process present line for beginning of block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (setq f90-cache-position (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (f90-indent-line 'no-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (setq ind-lev (f90-current-indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (setq ind-curr ind-lev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (beginning-of-line) (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (setq struct nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (setq ind-b (cond ((setq struct (f90-looking-at-do)) f90-do-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 ((or (setq struct (f90-looking-at-if-then))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (setq struct (f90-looking-at-select-case))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (setq struct (f90-looking-at-where-or-forall))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (looking-at f90-else-like-re))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 f90-if-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 ((setq struct (f90-looking-at-type-like))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 f90-type-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 ((or(setq struct (f90-looking-at-program-block-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (looking-at "contains[ \t]*\\($\\|!\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 f90-program-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (if ind-b (setq ind-lev (+ ind-lev ind-b)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (if struct (setq block-list (cons struct block-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (while (and (f90-line-continued) (zerop (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (< (point) end-region-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (if (not (zerop (- (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (+ ind-curr f90-continuation-indent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (f90-indent-to (+ ind-curr f90-continuation-indent) 'no-line-no)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 ;; process all following lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (while (and (zerop (forward-line 1)) (< (point) end-region-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (f90-indent-line-no)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (setq f90-cache-position (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (cond ((looking-at "[ \t]*$") (setq ind-curr 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 ((looking-at "[ \t]*#") (setq ind-curr 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 ((looking-at "!") (setq ind-curr (f90-comment-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 ((f90-no-block-limit) (setq ind-curr ind-lev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 ((looking-at f90-else-like-re) (setq ind-curr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (- ind-lev f90-if-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 ((looking-at "contains[ \t]*\\($\\|!\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (setq ind-curr (- ind-lev f90-program-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 ((setq ind-b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (cond ((setq struct (f90-looking-at-do)) f90-do-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 ((or (setq struct (f90-looking-at-if-then))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (setq struct (f90-looking-at-select-case))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (setq struct (f90-looking-at-where-or-forall)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 f90-if-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 ((setq struct (f90-looking-at-type-like))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 f90-type-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 ((setq struct (f90-looking-at-program-block-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 f90-program-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (setq ind-curr ind-lev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (if ind-b (setq ind-lev (+ ind-lev ind-b)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (setq block-list (cons struct block-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 ((setq end-struct (f90-looking-at-program-block-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (setq beg-struct (car block-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 block-list (cdr block-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (if f90-smart-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (f90-block-match (car beg-struct)(car (cdr beg-struct))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (car end-struct)(car (cdr end-struct)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (setq ind-b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (cond ((looking-at f90-end-if-re) f90-if-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 ((looking-at "end[ \t]*do\\>") f90-do-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 ((looking-at f90-end-type-re) f90-type-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 ((f90-looking-at-program-block-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 f90-program-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (if ind-b (setq ind-lev (- ind-lev ind-b)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (setq ind-curr ind-lev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (t (setq ind-curr ind-lev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 ;; do the indentation if necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (if (not (zerop (- ind-curr (current-column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (f90-indent-to ind-curr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (while (and (f90-line-continued) (zerop (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (< (point) end-region-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (if (not (zerop (- (current-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (+ ind-curr f90-continuation-indent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (f90-indent-to (+ ind-curr f90-continuation-indent) 'no-line-no))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 ;; restore point etc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (setq f90-cache-position nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (goto-char save-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (set-marker end-region-mark nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (set-marker save-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (zmacs-deactivate-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (deactivate-mark))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (defun f90-indent-subprogram ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 "Properly indent the subprogram which contains point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (let (program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (setq program (f90-mark-subprogram))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (if program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (message (concat "Indenting " (car program) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (car (cdr program))"."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (f90-indent-region (point) (mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (message (concat "Indenting " (car program) " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (car (cdr program)) "...done.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (message "Indenting the whole file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (f90-indent-region (point) (mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (message (concat "Indenting the whole file...done."))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 ;; autofill and break-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (defun f90-break-line (&optional no-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 "Break line at point, insert continuation marker(s) and indent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (let (ctype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (cond ((f90-in-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (insert "&") (newline) (insert "&"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 ((f90-in-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (setq ctype (f90-get-present-comment-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (newline) (insert (concat ctype " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (t (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (insert "&")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (if (not no-update) (f90-update-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (if f90-beginning-ampersand (insert "& ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (if (not no-update) (f90-indent-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (defun f90-find-breakpoint ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 "From fill-column, search backward for break-delimiter."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (let ((bol (f90-get-beg-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (re-search-backward f90-break-delimiters bol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (if f90-break-before-delimiters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (progn (backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (if (not (looking-at f90-no-break-re))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (forward-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (if (looking-at f90-no-break-re)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (forward-char)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (defun f90-auto-fill-mode (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 "Toggle f90-auto-fill mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 With ARG, turn `f90-auto-fill' mode on iff ARG is positive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 In `f90-auto-fill' mode, inserting a space at a column beyond `fill-column'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 automatically breaks the line at a previous space."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (prog1 (setq auto-fill-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (if (if (null arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (not auto-fill-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (> (prefix-numeric-value arg) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 'f90-do-auto-fill))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (force-mode-line-update)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (defun f90-do-auto-fill ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 "Break line if non-white characters beyond fill-column."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 ;; Break the line before or after the last delimiter (non-word char).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 ;; Will not break **, //, or => (specified by f90-no-break-re).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 ;; Start by checking that line is longer than fill-column.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (if (> (save-excursion (end-of-line) (current-column)) fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (move-to-column fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (if (and (looking-at "[ \t]*$") (not (f90-in-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (f90-find-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (f90-break-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (end-of-line)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (defun f90-join-lines ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 "Join present line with next line, if this line ends with \&."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (let (pos (oldpos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (cond ((= (preceding-char) ?&)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (setq pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (if (looking-at "\&") (delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (delete-region pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (if (not (f90-in-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (progn (delete-horizontal-space) (insert " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (if (and auto-fill-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (> (save-excursion (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 fill-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (f90-do-auto-fill))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (goto-char oldpos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (defun f90-fill-region (beg-region end-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 "Fill every line in region by forward parsing. Join lines if possible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (let ((end-region-mark (make-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (f90-smart-end nil) (f90-auto-keyword-case nil) indent (go-on t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (af-function auto-fill-function) (auto-fill-function nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (set-marker end-region-mark end-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (goto-char beg-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (while go-on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 ;; join as much as possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (while (f90-join-lines));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (setq indent (+ (f90-current-indentation) f90-continuation-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 ;; chop the line if necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (while (> (save-excursion (end-of-line) (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (move-to-column fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (if (and (looking-at "[ \t]*$") (not (f90-in-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (f90-find-breakpoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (f90-break-line 'no-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (f90-indent-to indent 'no-line-no)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (setq go-on (and (< (point) (marker-position end-region-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (zerop (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (setq f90-cache-position (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (setq auto-fill-function af-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (setq f90-cache-position nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (zmacs-deactivate-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (deactivate-mark))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (defun f90-block-match (beg-block beg-name end-block end-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 "Match end-struct with beg-struct and complete end-block if possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 Leave point at the end of line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (search-forward "end" (f90-get-end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (catch 'no-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (if (not (f90-equal-symbols beg-block end-block))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (if end-block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (message "END %s does not match %s." end-block beg-block)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (throw 'no-match nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (message "Inserting %s." beg-block)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (insert (concat " " beg-block)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (search-forward end-block))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (if (not (f90-equal-symbols beg-name end-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (cond ((and beg-name (not end-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (message "Inserting %s." beg-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (insert (concat " " beg-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 ((and beg-name end-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (message "Replacing %s with %s." end-name beg-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (search-forward end-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (replace-match beg-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 ((and (not beg-name) end-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (message "Deleting %s." end-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (search-forward end-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (replace-match "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (if end-name (search-forward end-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (if (not (looking-at "[ \t]*!")) (delete-horizontal-space))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (defun f90-match-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 "From an end foo statement, find the corresponding foo including name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (let ((count 1) (top-of-window (window-start)) (matching-beg nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (end-point (point)) (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 beg-name end-name beg-block end-block end-struct)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (if (save-excursion (beginning-of-line) (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (setq end-struct (f90-looking-at-program-block-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (setq end-block (car end-struct))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (setq end-name (car (cdr end-struct)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (and (not (zerop count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (let ((stop nil) notexist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (while (not stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (setq notexist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (not (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (concat "\\(" f90-blocks-re "\\)") nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (if notexist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (setq stop t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (setq stop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (not (or (f90-in-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (f90-in-comment))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (not notexist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (beginning-of-line) (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (cond ((setq matching-beg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ((f90-looking-at-do))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 ((f90-looking-at-if-then))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 ((f90-looking-at-where-or-forall))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 ((f90-looking-at-select-case))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 ((f90-looking-at-type-like))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 ((f90-looking-at-program-block-start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (setq count (- count 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 ((looking-at (concat "end[ \t]*" f90-blocks-re "\\b"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (setq count (+ count 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (if (not (zerop count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (message "No matching beginning.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (f90-update-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (if (eq f90-smart-end 'blink)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (if (< (point) top-of-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (message (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 "Matches " (what-line) ": "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (progn (end-of-line) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (sit-for 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (setq beg-block (car matching-beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 (setq beg-name (car (cdr matching-beg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (goto-char end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (f90-block-match beg-block beg-name end-block end-name)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (defun f90-insert-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 "Inserts an complete end statement matching beginning of present block."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (let ((f90-smart-end (if f90-smart-end f90-smart-end 'blink)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (insert "end")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (f90-indent-new-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 ;; abbrevs and keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (defun f90-abbrev-start ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 "Typing `\\[help-command] or `? lists all the F90 abbrevs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 Any other key combination is executed normally."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (let (e c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (setq e (next-command-event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (setq c (event-to-character e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (setq c (read-event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 ;; insert char if not equal to `?'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (if (or (= c ??) (eq c help-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (f90-abbrev-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (setq unread-command-event e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (setq unread-command-events (list c))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (defun f90-abbrev-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 "List the currently defined abbrevs in F90 mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (message "Listing abbrev table...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (display-buffer (f90-prepare-abbrev-list-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (message "Listing abbrev table...done"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (defun f90-prepare-abbrev-list-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (set-buffer (get-buffer-create "*Abbrevs*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (insert-abbrev-table-description 'f90-mode-abbrev-table t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (edit-abbrevs-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (get-buffer-create "*Abbrevs*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (defun f90-upcase-keywords ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 "Upcase all F90 keywords in the buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (f90-change-keywords 'upcase-word))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (defun f90-capitalize-keywords ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 "Capitalize all F90 keywords in the buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (f90-change-keywords 'capitalize-word))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (defun f90-downcase-keywords ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 "Downcase all F90 keywords in the buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (f90-change-keywords 'downcase-word))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (defun f90-upcase-region-keywords (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 "Upcase all F90 keywords in the region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (f90-change-keywords 'upcase-word beg end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (defun f90-capitalize-region-keywords (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 "Capitalize all F90 keywords in the region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (f90-change-keywords 'capitalize-word beg end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (defun f90-downcase-region-keywords (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 "Downcase all F90 keywords in the region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (f90-change-keywords 'downcase-word beg end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 ;; Change the keywords according to argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (defun f90-change-keywords (change-word &optional beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (setq beg (if beg beg (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (setq end (if end end (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (let ((keyword-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (concat "\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 f90-keywords-re "\\|" f90-procedures-re "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 f90-hpf-keywords-re "\\|" f90-operators-re "\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (ref-point (point-min)) state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (modified (buffer-modified-p)) saveword back-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (while (re-search-forward keyword-re end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (if (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (setq state (parse-partial-sexp ref-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (or (nth 3 state) (nth 4 state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (save-excursion ; Check for cpp directive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (skip-chars-forward " \t0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 (looking-at "#"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (setq ref-point (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 back-point (save-excursion (backward-word 1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (setq saveword (buffer-substring back-point ref-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (funcall change-word -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (or (string= saveword (buffer-substring back-point ref-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (setq modified t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (or modified (set-buffer-modified-p nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (provide 'f90)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 ;;; f90.el ends here