annotate lisp/modes/f90.el @ 134:34a5b81f86ba r20-2b1

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