annotate lisp/progmodes/f90.el @ 13009:a418156c25ea

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