annotate lisp/modes/f90.el @ 153:25f70ba0133c r20-3b3

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