Mercurial > emacs
annotate lisp/progmodes/simula.el @ 111473:1e95f3ea022d
Add const to array elements of font filter properties.
* font.c (font_filter_properties): Add const to array elements of properties args.
* font.h (font_filter_properties): Likewise.
* ftfont.c (ftfont_booleans, ftfont_non_booleans): Add const to array elements.
* w32font.c (w32font_booleans, w32font_non_booleans): Likewise.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Wed, 10 Nov 2010 18:02:54 +0900 |
parents | 249a1455856a |
children | b47e85affa59 |
rev | line source |
---|---|
805 | 1 ;;; simula.el --- SIMULA 87 code editing commands for Emacs |
2 | |
100545 | 3 ;; Copyright (C) 1992, 1994, 1996, 2001, 2002, 2003, 2004, 2005, 2006, |
106815 | 4 ;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
841 | 5 |
100545 | 6 ;; Author: Hans Henrik Eriksen <hhe@ifi.uio.no> |
7 ;; Maintainer: simula-mode@ifi.uio.no | |
8 ;; (above email addresses invalid as of April 2008) | |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
805
diff
changeset
|
9 ;; Adapted-By: ESR |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
805
diff
changeset
|
10 ;; Keywords: languages |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
805
diff
changeset
|
11 |
805 | 12 ;; This file is part of GNU Emacs. |
13 | |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94116
diff
changeset
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
805 | 15 ;; it under the terms of the GNU General Public License as published by |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94116
diff
changeset
|
16 ;; the Free Software Foundation, either version 3 of the License, or |
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94116
diff
changeset
|
17 ;; (at your option) any later version. |
805 | 18 |
19 ;; GNU Emacs is distributed in the hope that it will be useful, | |
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94116
diff
changeset
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
805 | 26 |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
805
diff
changeset
|
27 ;;; Commentary: |
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
805
diff
changeset
|
28 |
2315
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2024
diff
changeset
|
29 ;; A major mode for editing the Simula language. It knows about Simula |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2024
diff
changeset
|
30 ;; syntax and standard indentation commands. It also provides convenient |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2024
diff
changeset
|
31 ;; abbrevs for Simula keywords. |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2024
diff
changeset
|
32 ;; |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2024
diff
changeset
|
33 ;; Hans Henrik Eriksen (the author) may be reached at: |
805 | 34 ;; Institutt for informatikk, |
35 ;; Universitetet i Oslo | |
36 | |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
805
diff
changeset
|
37 ;;; Code: |
805 | 38 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
39 |
20960 | 40 (defgroup simula nil |
41 "Major mode for editing Simula code." | |
66963
a11fdee52c05
Add :link (custom-group-link font-lock-faces) to defgroup.
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
42 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) |
20960 | 43 :prefix "simula-" |
44 :group 'languages) | |
45 | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
46 (defconst simula-tab-always-indent-default nil |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
47 "Non-nil means TAB in SIMULA mode should always reindent the current line. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
48 Otherwise TAB indents only when point is within |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
49 the run of whitespace at the beginning of the line.") |
805 | 50 |
20960 | 51 (defcustom simula-tab-always-indent simula-tab-always-indent-default |
4664 | 52 "*Non-nil means TAB in SIMULA mode should always reindent the current line. |
53 Otherwise TAB indents only when point is within | |
20960 | 54 the run of whitespace at the beginning of the line." |
55 :type 'boolean | |
56 :group 'simula) | |
805 | 57 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
58 (defconst simula-indent-level-default 3 |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
59 "Indentation of SIMULA statements with respect to containing block.") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
60 |
20960 | 61 (defcustom simula-indent-level simula-indent-level-default |
62 "*Indentation of SIMULA statements with respect to containing block." | |
63 :type 'integer | |
64 :group 'simula) | |
65 | |
805 | 66 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
67 (defconst simula-substatement-offset-default 3 |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
68 "Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE.") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
69 |
20960 | 70 (defcustom simula-substatement-offset simula-substatement-offset-default |
71 "*Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE." | |
72 :type 'integer | |
73 :group 'simula) | |
805 | 74 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
75 (defconst simula-continued-statement-offset-default 3 |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
76 "Extra indentation for lines not starting a statement or substatement. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
77 If value is a list, each line in a multipleline continued statement |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
78 will have the car of the list extra indentation with respect to |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
79 the previous line of the statement.") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
80 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47024
diff
changeset
|
81 (defcustom simula-continued-statement-offset |
20960 | 82 simula-continued-statement-offset-default |
805 | 83 "*Extra indentation for lines not starting a statement or substatement. |
84 If value is a list, each line in a multipleline continued statement | |
85 will have the car of the list extra indentation with respect to | |
20960 | 86 the previous line of the statement." |
87 :type 'integer | |
88 :group 'simula) | |
805 | 89 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
90 (defconst simula-label-offset-default -4711 |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
91 "Offset of SIMULA label lines relative to usual indentation.") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
92 |
20960 | 93 (defcustom simula-label-offset simula-label-offset-default |
94 "*Offset of SIMULA label lines relative to usual indentation." | |
95 :type 'integer | |
96 :group 'simula) | |
805 | 97 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
98 (defconst simula-if-indent-default '(0 . 0) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
99 "Extra indentation of THEN and ELSE with respect to the starting IF. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
100 Value is a cons cell, the car is extra THEN indentation and the cdr |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
101 extra ELSE indentation. IF after ELSE is indented as the starting IF.") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
102 |
20960 | 103 (defcustom simula-if-indent simula-if-indent-default |
805 | 104 "*Extra indentation of THEN and ELSE with respect to the starting IF. |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2315
diff
changeset
|
105 Value is a cons cell, the car is extra THEN indentation and the cdr |
20960 | 106 extra ELSE indentation. IF after ELSE is indented as the starting IF." |
107 :type '(cons integer integer) | |
108 :group 'simula) | |
805 | 109 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
110 (defconst simula-inspect-indent-default '(0 . 0) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
111 "Extra indentation of WHEN and OTHERWISE with respect to the INSPECT. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
112 Value is a cons cell, the car is extra WHEN indentation |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
113 and the cdr extra OTHERWISE indentation.") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
114 |
20960 | 115 (defcustom simula-inspect-indent simula-inspect-indent-default |
4664 | 116 "*Extra indentation of WHEN and OTHERWISE with respect to the INSPECT. |
117 Value is a cons cell, the car is extra WHEN indentation | |
20960 | 118 and the cdr extra OTHERWISE indentation." |
119 :type '(cons integer integer) | |
120 :group 'simula) | |
805 | 121 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
122 (defconst simula-electric-indent-default nil |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
123 "Non-nil means `simula-indent-line' function may reindent previous line.") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
124 |
20960 | 125 (defcustom simula-electric-indent simula-electric-indent-default |
126 "*Non-nil means `simula-indent-line' function may reindent previous line." | |
127 :type 'boolean | |
128 :group 'simula) | |
805 | 129 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
130 (defconst simula-abbrev-keyword-default 'upcase |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
131 "Specify how to convert case for SIMULA keywords. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
132 Value is one of the symbols `upcase', `downcase', `capitalize', |
47024
15430c8d0eaa
* startup.el (normal-splash-screen): Ensure splash buffer is
John Paul Wallington <jpw@pobox.com>
parents:
42202
diff
changeset
|
133 \(as in) `abbrev-table' or nil if they should not be changed.") |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
134 |
20960 | 135 (defcustom simula-abbrev-keyword simula-abbrev-keyword-default |
4664 | 136 "*Specify how to convert case for SIMULA keywords. |
137 Value is one of the symbols `upcase', `downcase', `capitalize', | |
47024
15430c8d0eaa
* startup.el (normal-splash-screen): Ensure splash buffer is
John Paul Wallington <jpw@pobox.com>
parents:
42202
diff
changeset
|
138 \(as in) `abbrev-table' or nil if they should not be changed." |
20960 | 139 :type '(choice (const upcase) (const downcase) (const capitalize)(const nil)) |
140 :group 'simula) | |
805 | 141 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
142 (defconst simula-abbrev-stdproc-default 'abbrev-table |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
143 "Specify how to convert case for standard SIMULA procedure and class names. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
144 Value is one of the symbols `upcase', `downcase', `capitalize', |
47024
15430c8d0eaa
* startup.el (normal-splash-screen): Ensure splash buffer is
John Paul Wallington <jpw@pobox.com>
parents:
42202
diff
changeset
|
145 \(as in) `abbrev-table', or nil if they should not be changed.") |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
146 |
20960 | 147 (defcustom simula-abbrev-stdproc simula-abbrev-stdproc-default |
4664 | 148 "*Specify how to convert case for standard SIMULA procedure and class names. |
149 Value is one of the symbols `upcase', `downcase', `capitalize', | |
47024
15430c8d0eaa
* startup.el (normal-splash-screen): Ensure splash buffer is
John Paul Wallington <jpw@pobox.com>
parents:
42202
diff
changeset
|
150 \(as in) `abbrev-table', or nil if they should not be changed." |
20960 | 151 :type '(choice (const upcase) (const downcase) (const capitalize) |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
152 (const abbrev-table) (const nil)) |
20960 | 153 :group 'simula) |
805 | 154 |
20960 | 155 (defcustom simula-abbrev-file nil |
4664 | 156 "*File with extra abbrev definitions for use in SIMULA mode. |
157 These are used together with the standard abbrev definitions for SIMULA. | |
158 Please note that the standard definitions are required | |
20960 | 159 for SIMULA mode to function correctly." |
160 :type '(choice file (const nil)) | |
161 :group 'simula) | |
805 | 162 |
163 (defvar simula-mode-syntax-table nil | |
4664 | 164 "Syntax table in SIMULA mode buffers.") |
805 | 165 |
110305
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
166 (defconst simula-syntax-propertize-function |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
167 (syntax-propertize-rules |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
168 ;; `comment' directive. |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
169 ("\\<\\(c\\)omment\\>" (1 "<")) |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
170 ;; end comments |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
171 ((concat "\\<end\\>\\([^;\n]\\).*?\\(\n\\|\\(.\\)\\(;\\|" |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
172 (regexp-opt '("end" "else" "when" "otherwise")) |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
173 "\\)\\)") |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
174 (1 "< b") |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
175 (3 "> b")) |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
176 ;; non-quoted single-quote char. |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
177 ("'\\('\\)'" (1 ".")))) |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
178 |
16455
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
179 ;; Regexps written with help from Alf-Ivar Holm <alfh@ifi.uio.no>. |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
180 (defconst simula-font-lock-keywords-1 |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
181 '(;; |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
182 ;; Compiler directives. |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
183 ("^%\\([^ \t\n].*\\)" 1 font-lock-constant-face t) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
184 ;; |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
185 ;; Class and procedure names. |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
186 ("\\<\\(class\\|procedure\\)\\>[ \t]*\\(\\sw+\\)?" |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
187 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))) |
16455
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
188 "Subdued level highlighting for Simula mode.") |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
189 |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
190 (defconst simula-font-lock-keywords-2 |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
191 (append simula-font-lock-keywords-1 |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
192 (list |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
193 ;; |
20953
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
19786
diff
changeset
|
194 ;; Constants. |
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
19786
diff
changeset
|
195 '("\\<\\(false\\|none\\|notext\\|true\\)\\>" . font-lock-constant-face) |
16455
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
196 ;; |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
197 ;; Keywords. |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
198 (regexp-opt |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
199 '("activate" "after" "and" "at" "before" "begin" "delay" "do" |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
200 "else" "end" "eq" "eqv" "external" "for" "ge" "go" "goto" "gt" |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
201 "hidden" "if" "imp" "in" "inner" "inspect" "is" "label" "le" |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
202 "lt" "ne" "new" "not" "or" "otherwise" "prior" "protected" |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
203 "qua" "reactivate" "step" "switch" "then" "this" "to" "until" |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
204 "virtual" "when" "while") 'words) |
16455
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
205 ;; |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
206 ;; Types. |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
207 (cons (regexp-opt |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
208 '("array" "boolean" "character" "integer" |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
209 "long" "name" "real" "short" "text" "value" "ref") 'words) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
210 'font-lock-type-face))) |
16455
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
211 "Medium level highlighting for Simula mode.") |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
212 |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
213 (defconst simula-font-lock-keywords-3 |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
214 (append simula-font-lock-keywords-2 |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
215 (list |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
216 ;; |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
217 ;; Super-class names and super-slow. |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
218 '("\\<\\(\\sw+\\)[ \t]+class\\>" 1 font-lock-function-name-face) |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
219 ;; |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
220 ;; Types and their declarations. |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
221 (list (concat "\\<\\(array\\|boolean\\|character\\|integer\\|" |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
222 "long\\|name\\|real\\|short\\|text\\|value\\)\\>" |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
223 "\\([ \t]+\\sw+\\>\\)*") |
16582 | 224 '(font-lock-match-c-style-declaration-item-and-skip-to-next |
16455
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
225 ;; Start with point after all type specifiers. |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
226 (goto-char (or (match-beginning 2) (match-end 1))) |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
227 ;; Finish with point after first type specifier. |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
228 (goto-char (match-end 1)) |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
229 ;; Fontify as a variable name. |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
230 (1 font-lock-variable-name-face))) |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
231 ;; |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
232 ;; Object references and their declarations. |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
233 '("\\<\\(ref\\)\\>[ \t]*\\((\\(\\sw+\\))\\)?" |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
234 (3 font-lock-function-name-face nil t) |
16582 | 235 (font-lock-match-c-style-declaration-item-and-skip-to-next nil nil |
16455
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
236 (1 font-lock-variable-name-face))) |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
237 )) |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
238 "Gaudy level highlighting for Simula mode.") |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
239 |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
240 (defvar simula-font-lock-keywords simula-font-lock-keywords-1 |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
241 "Default expressions to highlight in Simula mode.") |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
242 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
243 ; The following function is taken from cc-mode.el, |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
244 ; it determines the flavor of the Emacs running |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
245 |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
246 (defvar simula-mode-menu |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
247 '(["Report Bug" simula-submit-bug-report t] |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
248 ["Indent Line" simula-indent-line t] |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
249 ["Backward Statement" simula-previous-statement t] |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
250 ["Forward Statement" simula-next-statement t] |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
251 ["Backward Up Level" simula-backward-up-level t] |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
252 ["Forward Down Statement" simula-forward-down-level t]) |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
253 "Lucid Emacs menu for SIMULA mode.") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
254 |
805 | 255 (if simula-mode-syntax-table |
256 () | |
4664 | 257 (setq simula-mode-syntax-table (copy-syntax-table (standard-syntax-table))) |
805 | 258 (modify-syntax-entry ?! "<" simula-mode-syntax-table) |
259 (modify-syntax-entry ?$ "." simula-mode-syntax-table) | |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
260 (modify-syntax-entry ?% "< b" simula-mode-syntax-table) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
261 (modify-syntax-entry ?\n "> b" simula-mode-syntax-table) |
805 | 262 (modify-syntax-entry ?' "\"" simula-mode-syntax-table) |
263 (modify-syntax-entry ?\( "()" simula-mode-syntax-table) | |
264 (modify-syntax-entry ?\) ")(" simula-mode-syntax-table) | |
265 (modify-syntax-entry ?\; ">" simula-mode-syntax-table) | |
266 (modify-syntax-entry ?\[ "." simula-mode-syntax-table) | |
267 (modify-syntax-entry ?\\ "." simula-mode-syntax-table) | |
268 (modify-syntax-entry ?\] "." simula-mode-syntax-table) | |
16455
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
269 (modify-syntax-entry ?_ "_" simula-mode-syntax-table) |
805 | 270 (modify-syntax-entry ?\| "." simula-mode-syntax-table) |
271 (modify-syntax-entry ?\{ "." simula-mode-syntax-table) | |
272 (modify-syntax-entry ?\} "." simula-mode-syntax-table)) | |
273 | |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
274 (defvar simula-mode-map |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
275 (let ((map (make-sparse-keymap))) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
276 (define-key map "\C-c\C-u" 'simula-backward-up-level) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
277 (define-key map "\C-c\C-p" 'simula-previous-statement) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
278 (define-key map "\C-c\C-d" 'simula-forward-down-level) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
279 (define-key map "\C-c\C-n" 'simula-next-statement) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
280 ;; (define-key map "\C-c\C-g" 'simula-goto-definition) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
281 ;; (define-key map "\C-c\C-h" 'simula-standard-help) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
282 (define-key map "\177" 'backward-delete-char-untabify) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
283 (define-key map ":" 'simula-electric-label) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
284 (define-key map "\e\C-q" 'simula-indent-exp) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
285 (define-key map "\t" 'simula-indent-command) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
286 ;; Emacs 19 defines menus in the mode map |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
287 (define-key map [menu-bar simula] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
288 (cons "SIMULA" (make-sparse-keymap "SIMULA"))) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
289 (define-key map [menu-bar simula bug-report] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
290 '("Submit Bug Report" . simula-submit-bug-report)) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
291 (define-key map [menu-bar simula separator-indent] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
292 '("--")) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
293 (define-key map [menu-bar simula indent-exp] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
294 '("Indent Expression" . simula-indent-exp)) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
295 (define-key map [menu-bar simula indent-line] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
296 '("Indent Line" . simula-indent-command)) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
297 (define-key map [menu-bar simula separator-navigate] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
298 '("--")) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
299 (define-key map [menu-bar simula backward-stmt] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
300 '("Previous Statement" . simula-previous-statement)) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
301 (define-key map [menu-bar simula forward-stmt] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
302 '("Next Statement" . simula-next-statement)) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
303 (define-key map [menu-bar simula backward-up] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
304 '("Backward Up Level" . simula-backward-up-level)) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
305 (define-key map [menu-bar simula forward-down] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
306 '("Forward Down Statement" . simula-forward-down-level)) |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
307 |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
308 (put 'simula-next-statement 'menu-enable '(not (eobp))) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
309 (put 'simula-previous-statement 'menu-enable '(not (bobp))) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
310 (put 'simula-forward-down-level 'menu-enable '(not (eobp))) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
311 (put 'simula-backward-up-level 'menu-enable '(not (bobp))) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
312 (put 'simula-indent-command 'menu-enable '(not buffer-read-only)) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
313 (put 'simula-indent-exp 'menu-enable '(not buffer-read-only)) |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
314 |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
315 ;; RMS: mouse-3 should not select this menu. mouse-3's global |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
316 ;; definition is useful in SIMULA mode and we should not interfere |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
317 ;; with that. The menu is mainly for beginners, and for them, |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
318 ;; the menubar requires less memory than a special click. |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
319 ;; in Lucid Emacs, we want the menu to popup when the 3rd button is |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
320 ;; hit. In 19.10 and beyond this is done automatically if we put |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
321 ;; the menu on mode-popup-menu variable, see c-common-init [cc-mode.el] |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
322 ;;(if (not (boundp 'mode-popup-menu)) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
323 ;; (define-key simula-mode-map 'button3 'simula-popup-menu)) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
324 map) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
325 "Keymap used in `simula-mode'.") |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
326 |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
327 ;; menus for Lucid |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
328 (defun simula-popup-menu (e) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
329 "Pops up the SIMULA menu." |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
330 (interactive "@e") |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
331 (popup-menu (cons (concat mode-name " Mode Commands") simula-mode-menu))) |
805 | 332 |
16455
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
333 ;;;###autoload |
109561
d7a517f1b312
Derive programming modes from prog-mode.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
334 (define-derived-mode simula-mode prog-mode "Simula" |
805 | 335 "Major mode for editing SIMULA code. |
336 \\{simula-mode-map} | |
337 Variables controlling indentation style: | |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
338 `simula-tab-always-indent' |
805 | 339 Non-nil means TAB in SIMULA mode should always reindent the current line, |
340 regardless of where in the line point is when the TAB command is used. | |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
341 `simula-indent-level' |
805 | 342 Indentation of SIMULA statements with respect to containing block. |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
343 `simula-substatement-offset' |
805 | 344 Extra indentation after DO, THEN, ELSE, WHEN and OTHERWISE. |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
345 `simula-continued-statement-offset' 3 |
805 | 346 Extra indentation for lines not starting a statement or substatement, |
4664 | 347 e.g. a nested FOR-loop. If value is a list, each line in a multiple- |
805 | 348 line continued statement will have the car of the list extra indentation |
349 with respect to the previous line of the statement. | |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
350 `simula-label-offset' -4711 |
4664 | 351 Offset of SIMULA label lines relative to usual indentation. |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
352 `simula-if-indent' '(0 . 0) |
805 | 353 Extra indentation of THEN and ELSE with respect to the starting IF. |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2315
diff
changeset
|
354 Value is a cons cell, the car is extra THEN indentation and the cdr |
4664 | 355 extra ELSE indentation. IF after ELSE is indented as the starting IF. |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
356 `simula-inspect-indent' '(0 . 0) |
805 | 357 Extra indentation of WHEN and OTHERWISE with respect to the |
4664 | 358 corresponding INSPECT. Value is a cons cell, the car is |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2315
diff
changeset
|
359 extra WHEN indentation and the cdr extra OTHERWISE indentation. |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
360 `simula-electric-indent' nil |
4664 | 361 If this variable is non-nil, `simula-indent-line' |
805 | 362 will check the previous line to see if it has to be reindented. |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
363 `simula-abbrev-keyword' 'upcase |
4664 | 364 Determine how SIMULA keywords will be expanded. Value is one of |
365 the symbols `upcase', `downcase', `capitalize', (as in) `abbrev-table', | |
366 or nil if they should not be changed. | |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
367 `simula-abbrev-stdproc' 'abbrev-table |
805 | 368 Determine how standard SIMULA procedure and class names will be |
4664 | 369 expanded. Value is one of the symbols `upcase', `downcase', `capitalize', |
370 (as in) `abbrev-table', or nil if they should not be changed. | |
805 | 371 |
372 Turning on SIMULA mode calls the value of the variable simula-mode-hook | |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
373 with no arguments, if that value is non-nil." |
805 | 374 (make-local-variable 'comment-column) |
375 (setq comment-column 40) | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
376 ; (make-local-variable 'end-comment-column) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
377 ; (setq end-comment-column 75) |
805 | 378 (make-local-variable 'paragraph-start) |
10895
27b6776dc562
(simula-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents:
7639
diff
changeset
|
379 (setq paragraph-start "[ \t]*$\\|\\f") |
805 | 380 (make-local-variable 'paragraph-separate) |
381 (setq paragraph-separate paragraph-start) | |
382 (make-local-variable 'indent-line-function) | |
383 (setq indent-line-function 'simula-indent-line) | |
384 (make-local-variable 'require-final-newline) | |
59252
2a058ed87066
(simula-mode): Use mode-require-final-newline.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
385 (setq require-final-newline mode-require-final-newline) |
805 | 386 (make-local-variable 'comment-start) |
387 (setq comment-start "! ") | |
388 (make-local-variable 'comment-end) | |
389 (setq comment-end " ;") | |
390 (make-local-variable 'comment-start-skip) | |
391 (setq comment-start-skip "!+ *") | |
392 (make-local-variable 'parse-sexp-ignore-comments) | |
393 (setq parse-sexp-ignore-comments nil) | |
394 (make-local-variable 'comment-multi-line) | |
395 (setq comment-multi-line t) | |
16455
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
396 (make-local-variable 'font-lock-defaults) |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
397 (setq font-lock-defaults |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
398 '((simula-font-lock-keywords simula-font-lock-keywords-1 |
0ea4c341ed0c
Add Font Lock support. Add mode command autoload cookie.
Simon Marshall <simon@gnu.org>
parents:
16072
diff
changeset
|
399 simula-font-lock-keywords-2 simula-font-lock-keywords-3) |
110305
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
400 nil t ((?_ . "w")))) |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
401 (set (make-local-variable 'syntax-propertize-function) |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
109561
diff
changeset
|
402 simula-syntax-propertize-function) |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
403 (abbrev-mode 1)) |
805 | 404 |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
405 (defun simula-indent-exp () |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
406 "Indent SIMULA expression following point." |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
407 (interactive) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
408 (let ((here (point)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
409 (simula-electric-indent nil) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
410 end) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
411 (simula-skip-comment-forward) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
412 (if (eobp) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
413 (goto-char here) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
414 (unwind-protect |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
415 (progn |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
416 (simula-next-statement 1) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
417 (setq end (point-marker)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
418 (simula-previous-statement 1) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
419 (beginning-of-line) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
420 (while (< (point) end) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
421 (if (not (looking-at "[ \t]*$")) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
422 (simula-indent-line)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
423 (forward-line 1))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
424 (and end (set-marker end nil)))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47024
diff
changeset
|
425 |
805 | 426 |
427 (defun simula-indent-line () | |
4664 | 428 "Indent this line as SIMULA code. |
429 If `simula-electric-indent' is non-nil, indent previous line if necessary." | |
805 | 430 (let ((origin (- (point-max) (point))) |
431 (indent (simula-calculate-indent)) | |
432 (case-fold-search t)) | |
433 (unwind-protect | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
434 (if simula-electric-indent |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
435 (progn |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
436 ;; |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
437 ;; manually expand abbrev on last line, if any |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
438 ;; |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
439 (end-of-line 0) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
440 (expand-abbrev) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
441 ;; now maybe we should reindent that line |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
442 (beginning-of-line) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
443 (skip-chars-forward " \t\f") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
444 (if (and |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
445 (looking-at |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
446 "\\(end\\|if\\|then\\|else\\|when\\|otherwise\\)\\>") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
447 (not (simula-context))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
448 ;; yes - reindent |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
449 (let ((post-indent (simula-calculate-indent))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
450 (if (eq (current-indentation) post-indent) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
451 () |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
452 (delete-horizontal-space) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
453 (indent-to post-indent)))))) |
805 | 454 (goto-char (- (point-max) origin)) |
455 (if (eq (current-indentation) indent) | |
456 (back-to-indentation) | |
457 (delete-horizontal-space) | |
458 (indent-to indent))))) | |
459 | |
460 | |
461 (defun simula-indent-command (&optional whole-exp) | |
462 "Indent current line as SIMULA code, or insert TAB character. | |
4664 | 463 If `simula-tab-always-indent' is non-nil, always indent current line. |
805 | 464 Otherwise, indent only if point is before any non-whitespace |
465 character on the line. | |
466 | |
467 A numeric argument, regardless of its value, means indent rigidly | |
468 all the lines of the SIMULA statement after point so that this line | |
469 becomes properly indented. | |
470 The relative indentation among the lines of the statement are preserved." | |
471 (interactive "P") | |
472 (let ((case-fold-search t)) | |
473 (if (or whole-exp simula-tab-always-indent | |
474 (save-excursion | |
475 (skip-chars-backward " \t\f") | |
476 (bolp))) | |
477 ;; reindent current line | |
478 (let ((indent (save-excursion | |
479 (beginning-of-line) | |
480 (simula-calculate-indent))) | |
481 (current (current-indentation)) | |
482 (origin (- (point-max) (point))) | |
483 (bol (save-excursion | |
484 (skip-chars-backward " \t\f") | |
485 (bolp))) | |
486 beg end) | |
487 (unwind-protect | |
488 (if (eq current indent) | |
489 (if (save-excursion | |
490 (skip-chars-backward " \t\f") | |
491 (bolp)) | |
492 (back-to-indentation)) | |
493 (beginning-of-line) | |
494 (delete-horizontal-space) | |
495 (indent-to indent)) | |
496 (if (not bol) | |
497 (goto-char (- (point-max) origin)))) | |
498 (setq origin (point)) | |
499 (if whole-exp | |
500 (save-excursion | |
501 (beginning-of-line 2) | |
502 (setq beg (point)) | |
503 (goto-char origin) | |
504 (simula-next-statement 1) | |
505 (setq end (point)) | |
506 (if (and (> end beg) (not (eq indent current))) | |
507 (indent-code-rigidly beg end (- indent current) "%"))))) | |
508 (insert-tab)))) | |
509 | |
510 | |
511 (defun simula-context () | |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
512 "Return value according to syntactic SIMULA context of point. |
4664 | 513 0 point inside COMMENT comment |
805 | 514 1 point on SIMULA-compiler directive line |
515 2 point inside END comment | |
516 3 point inside string | |
517 4 point inside character constant | |
518 nil otherwise." | |
519 ;; first, find out if this is a compiler directive line | |
520 (if (save-excursion | |
521 (beginning-of-line) | |
522 (eq (following-char) ?%)) | |
523 ;; YES - return 1 | |
524 1 | |
525 (save-excursion | |
526 ;; The current line is NOT a compiler directive line. | |
527 ;; Now, the strategy is to search backward to find a semicolon | |
528 ;; that is NOT inside a string. The point after semicolon MUST be | |
529 ;; outside a comment, since semicolons are comment-ending and | |
530 ;; comments are non-recursive. We take advantage of the fact | |
531 ;; that strings MUST end on the same line as they started, so | |
532 ;; that we can easily decide whether we are inside a string or not. | |
533 (let (return-value (origin (point))) | |
534 (skip-chars-backward "^;" (point-min)) | |
535 ;; found semicolon or beginning of buffer | |
536 (let (loopvalue (saved-point origin)) | |
537 (while (and (not (bobp)) | |
538 (if (progn | |
539 (beginning-of-line) | |
540 ;; compiler directive line? If so, cont searching.. | |
541 (eq (following-char) ?%)) | |
542 t | |
543 (while (< (point) saved-point) | |
544 (skip-chars-forward "^;\"'") | |
545 (forward-char 1) | |
546 (cond | |
547 ((eq (preceding-char) ?\;) | |
548 (setq saved-point (point))) | |
549 ((eq (preceding-char) ?\") | |
550 (skip-chars-forward "^\";") | |
551 (if (eq (following-char) ?\;) | |
552 (setq saved-point (point) loopvalue t) | |
553 (forward-char 1))) | |
554 (t | |
555 (if (eq (following-char) ?') | |
556 (forward-char 1)) | |
557 (skip-chars-forward "^';") | |
558 (if (eq (following-char) ?\;) | |
559 (setq saved-point (point) loopvalue t) | |
560 (forward-char 1))))) | |
561 loopvalue)) | |
562 (backward-char 1) | |
563 (skip-chars-backward "^;") | |
564 (setq saved-point (point) loopvalue nil))) | |
565 ;; Now we are CERTAIN that we are outside comments and strings. | |
566 ;; The job now is to search forward again towards the origin | |
567 ;; skipping directives, comments and strings correctly, | |
568 ;; so that we know what context we are in when we find the origin. | |
569 (while (and | |
570 (< (point) origin) | |
571 (re-search-forward | |
572 "\\<end\\>\\|!\\|\"\\|'\\|^%\\|\\<comment\\>" origin 'move)) | |
573 (cond | |
574 ((memq (preceding-char) '(?d ?D)) | |
575 (setq return-value 2) | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
576 (while (and (re-search-forward |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
577 ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>\\|^%" |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
578 origin 'move) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
579 ;; found another END? |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
580 (or (memq (preceding-char) '(?d ?D)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
581 ;; if directive, skip line |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
582 (and (eq (preceding-char) ?%) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
583 (beginning-of-line 2)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
584 ;; found other keyword, out of END comment |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
585 (setq return-value nil)))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
586 (if (and (eq (char-syntax (preceding-char)) ?w) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
587 (eq (char-syntax (following-char)) ?w)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
588 (save-excursion |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
589 (backward-word 1) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
590 (if (looking-at "end\\>\\|else\\>\\|otherwise\\>\\|when\\>") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
591 (setq return-value nil))))) |
805 | 592 ((memq (preceding-char) '(?! ?t ?T)) |
593 ; skip comment | |
594 (setq return-value 0) | |
595 (skip-chars-forward "^%;" origin) | |
596 (while (and return-value (< (point) origin)) | |
597 (if (eq (following-char) ?\;) | |
598 (setq return-value nil) | |
599 (if (bolp) | |
600 (beginning-of-line 2) ; skip directive inside comment | |
601 (forward-char 1)) ; or single '%' | |
602 (skip-chars-forward "^%;" origin)))) | |
603 ((eq (preceding-char) ?\") | |
604 (if (not (search-forward "\"" origin 'move)) | |
605 (setq return-value 3))) | |
606 ((eq (preceding-char) ?\') | |
607 (if (or (eq (point) origin) (eobp)) | |
608 (setq return-value 4) | |
609 (forward-char 1) | |
610 (if (not (search-forward "'" origin 'move)) | |
611 (setq return-value 4)))) | |
612 ;; compiler directive line - skip | |
613 (t (beginning-of-line 2)))) | |
614 return-value) | |
615 ))) | |
616 | |
617 | |
618 (defun simula-electric-label () | |
4664 | 619 "If this is a label that starts the line, reindent the line." |
805 | 620 (interactive) |
621 (expand-abbrev) | |
622 (insert ?:) | |
623 (let ((origin (- (point-max) (point))) | |
624 (case-fold-search t) | |
625 ;; don't mix a label with an assignment operator := :- | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
626 ;; therefore take a peek at next typed character... |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
627 (next-char (read-event))) |
805 | 628 (unwind-protect |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
629 (setq unread-command-events (append unread-command-events |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
630 (list next-char))) |
805 | 631 ;; Problem: find out if character just read is a command char |
632 ;; that would insert something after ':' making it a label. | |
633 ;; At least \n, \r (and maybe \t) falls into this category. | |
634 ;; This is a real crock, it depends on traditional keymap | |
635 ;; bindings, that is, printing characters doing self-insert, | |
636 ;; and no other command sequence inserting '-' or '='. | |
637 ;; simula-electric-label can be easily fooled... | |
638 (if (and (not (memq next-char '(?= ?-))) | |
639 (or (memq next-char '(?\n ?\r)) | |
640 (and (eq next-char ?\t) | |
641 simula-tab-always-indent) | |
642 (not (memq (following-char) '(?= ?-)))) | |
643 (not (simula-context)) | |
644 ;; label? | |
645 (progn | |
646 (backward-char 1) | |
647 (skip-chars-backward " \t\f") | |
648 (skip-chars-backward "a-zA-Z0-9_") | |
649 (if (looking-at "virtual\\>") | |
650 nil | |
651 (skip-chars-backward " \t\f") | |
652 (bolp)))) | |
653 (let ((amount (simula-calculate-indent))) | |
654 (delete-horizontal-space) | |
655 (indent-to amount))) | |
656 (goto-char (- (point-max) origin))))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47024
diff
changeset
|
657 |
805 | 658 |
659 (defun simula-backward-up-level (count) | |
660 "Move backward up COUNT block levels. | |
4664 | 661 If COUNT is negative, move forward up block level instead." |
805 | 662 (interactive "p") |
663 (let ((origin (point)) | |
664 (case-fold-search t)) | |
665 (condition-case () | |
666 (if (> count 0) | |
667 (while (> count 0) | |
668 (re-search-backward "\\<begin\\>\\|\\<end\\>") | |
669 (if (not (simula-context)) | |
670 (setq count (if (memq (following-char) '(?b ?B)) | |
671 (1- count) | |
672 (1+ count))))) | |
673 (while (< count 0) | |
674 (re-search-forward "\\<begin\\>\\|\\<end\\>") | |
675 (backward-word 1) | |
676 (if (not (simula-context)) | |
677 (setq count (if (memq (following-char) '(?e ?E)) | |
678 (1+ count) | |
679 (1- count)))) | |
680 (backward-word -1))) | |
681 ;; If block level not found, jump back to origin and signal an error | |
682 (error (progn | |
683 (goto-char origin) | |
684 (error "No higher block level"))) | |
685 (quit (progn | |
686 (goto-char origin) | |
687 (signal 'quit nil)))))) | |
688 | |
689 | |
690 (defun simula-forward-down-level (count) | |
691 "Move forward down COUNT block levels. | |
4664 | 692 If COUNT is negative, move backward down block level instead." |
805 | 693 (interactive "p") |
694 ;; When we search for a deeper block level, we must never | |
695 ;; get out of the block where we started -> count >= start-count | |
696 (let ((start-count count) | |
697 (origin (point)) | |
698 (case-fold-search t)) | |
699 (condition-case () | |
700 (if (< count 0) | |
701 (while (< count 0) | |
702 (re-search-backward "\\<begin\\>\\|\\<end\\>") | |
703 (if (not (simula-context)) | |
704 (setq count (if (memq (following-char) '(?e ?E)) | |
705 (1+ count) | |
706 (1- count)))) | |
707 (if (< count start-count) (signal 'error nil))) | |
708 (while (> count 0) | |
709 (re-search-forward "\\<begin\\>\\|\\<end\\>") | |
710 (backward-word 1) | |
711 (if (not (simula-context)) | |
712 (setq count (if (memq (following-char) '(?b ?B)) | |
713 (1- count) | |
714 (1+ count)))) | |
715 (backward-word -1) | |
716 ;; deeper level has to be found within starting block | |
717 (if (> count start-count) (signal 'error nil)))) | |
718 ;; If block level not found, jump back to origin and signal an error | |
719 (error (progn | |
720 (goto-char origin) | |
721 (error "No containing block level"))) | |
722 (quit (progn | |
723 (goto-char origin) | |
724 (signal 'quit nil)))))) | |
725 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47024
diff
changeset
|
726 |
805 | 727 (defun simula-previous-statement (count) |
728 "Move backward COUNT statements. | |
4664 | 729 If COUNT is negative, move forward instead." |
805 | 730 (interactive "p") |
731 (if (< count 0) | |
732 (simula-next-statement (- count)) | |
733 (let (status | |
734 (case-fold-search t) | |
735 (origin (point))) | |
736 (condition-case () | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47024
diff
changeset
|
737 ;; |
805 | 738 (progn |
739 (simula-skip-comment-backward) | |
740 (if (memq (preceding-char) '(?n ?N)) | |
741 (progn | |
742 (backward-word 1) | |
743 (if (not (looking-at "\\<begin\\>")) | |
744 (backward-word -1))) | |
745 (if (eq (preceding-char) ?\;) | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
746 (backward-char 1)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
747 ) |
805 | 748 (while (and (natnump (setq count (1- count))) |
749 (setq status (simula-search-backward | |
750 ";\\|\\<begin\\>" nil 'move)))) | |
751 (if status | |
752 (progn | |
753 (if (eq (following-char) ?\;) | |
754 (forward-char 1) | |
755 (backward-word -1)))) | |
756 (simula-skip-comment-forward)) | |
757 (error (progn (goto-char origin) | |
758 (error "Incomplete statement (too many ENDs)"))) | |
759 (quit (progn (goto-char origin) (signal 'quit nil))))))) | |
760 | |
761 | |
762 (defun simula-next-statement (count) | |
4664 | 763 "Move forward COUNT statements. |
764 If COUNT is negative, move backward instead." | |
805 | 765 (interactive "p") |
766 (if (< count 0) | |
767 (simula-previous-statement (- count)) | |
768 (let (status | |
769 (case-fold-search t) | |
770 (origin (point))) | |
771 (condition-case () | |
772 (progn | |
773 (simula-skip-comment-forward) | |
774 (if (looking-at "\\<end\\>") (forward-word 1)) | |
775 (while (and (natnump (setq count (1- count))) | |
776 (setq status (simula-search-forward | |
777 ";\\|\\<end\\>" (point-max) 'move)))) | |
778 (if (and status (/= (preceding-char) ?\;)) | |
779 (progn | |
780 (backward-word 1) | |
781 (simula-skip-comment-backward)))) | |
782 (error (progn (goto-char origin) | |
783 (error "Incomplete statement (too few ENDs)"))) | |
784 (quit (progn (goto-char origin) (signal 'quit nil))))))) | |
785 | |
786 | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
787 (defun simula-skip-comment-backward (&optional stop-at-end) |
4664 | 788 "Search towards bob to find first char that is outside a comment." |
805 | 789 (interactive) |
790 (catch 'simula-out | |
791 (let (context) | |
792 (while t | |
793 (skip-chars-backward " \t\n\f") | |
794 (if (eq (preceding-char) ?\;) | |
795 (save-excursion | |
796 (backward-char 1) | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
797 (setq context (simula-context)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
798 (if (and stop-at-end (eq context 2)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
799 (setq context nil))) |
805 | 800 (setq context (simula-context))) |
801 (cond | |
802 ((memq context '(nil 3 4)) | |
803 ;; check to see if we found a label | |
804 (if (and (eq (preceding-char) ?:) | |
805 (not (memq (following-char) '(?- ?=))) | |
806 (save-excursion | |
807 (skip-chars-backward ": \t\fa-zA-Z0-9_") | |
808 (not (looking-at "virtual\\>")))) | |
809 (skip-chars-backward ": \t\fa-zA-Z0-9_") | |
810 (throw 'simula-out nil))) | |
811 ((eq context 0) | |
812 ;; since we are inside a comment, it must start somewhere! | |
813 (while (and (re-search-backward "!\\|\\<comment\\>") | |
814 (memq (simula-context) '(0 1))))) | |
815 ((eq context 1) | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
816 (beginning-of-line) |
805 | 817 (if (bobp) |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
818 (throw 'simula-out nil) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
819 (backward-char))) |
805 | 820 ((eq context 2) |
821 ;; an END-comment must belong to an END | |
822 (re-search-backward "\\<end\\>") | |
823 (forward-word 1) | |
824 (throw 'simula-out nil)) | |
825 ;; should be impossible to get here.. | |
826 ))))) | |
827 | |
828 | |
829 (defun simula-skip-comment-forward () | |
4664 | 830 "Search towards eob to find first char that is outside a comment." |
805 | 831 ;; this function assumes we start with point .outside a comment |
832 (interactive) | |
833 (catch 'simula-out | |
834 (while t | |
835 (skip-chars-forward " \t\n\f") | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
836 ;; BUG: the following (0 2) branches don't take into account intermixing |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
837 ;; directive lines |
805 | 838 (cond |
839 ((looking-at "!\\|\\<comment\\>") | |
840 (search-forward ";" nil 'move)) | |
841 ((and (bolp) (eq (following-char) ?%)) | |
842 (beginning-of-line 2)) | |
843 ((and (looking-at "[a-z0-9_]*[ \t\f]*:[^-=]") | |
844 (not (looking-at "virtual\\>"))) | |
845 (skip-chars-forward "a-zA-Z0-9_ \t\f:")) | |
846 (t | |
847 (throw 'simula-out t)))))) | |
848 | |
849 | |
850 (defun simula-forward-up-level () | |
851 (let ((continue-loop t) | |
852 (origin (point)) | |
853 (case-fold-search t) | |
854 return-value | |
855 temp) | |
856 (while continue-loop | |
857 (if (re-search-backward "\\<begin\\>\\|\\<end\\>" (point-min) 'move) | |
858 (setq temp (simula-context) | |
859 return-value (and (memq (preceding-char) '(?d ?D)) | |
860 (memq temp '(nil 2))) | |
861 continue-loop (and (not return-value) | |
862 (simula-forward-up-level))) | |
863 (setq continue-loop nil))) | |
864 (if return-value | |
865 t | |
866 (goto-char origin) | |
867 nil))) | |
868 | |
869 | |
870 (defun simula-calculate-indent () | |
871 (save-excursion | |
872 (let ((where (simula-context)) | |
873 (origin (point)) | |
874 (indent 0) | |
875 continued | |
876 start-line | |
877 temp | |
878 found-end | |
879 prev-cont) | |
880 (cond | |
881 ((eq where 0) | |
882 ;; | |
883 ;; Comment. | |
884 ;; If comment started on previous non-blank line, indent to the | |
885 ;; column where the comment started, else indent as that line. | |
886 ;; | |
887 (skip-chars-backward " \t\n\f") | |
888 (while (and (not (bolp)) (eq (simula-context) 0)) | |
889 (re-search-backward "^\\|!\\|\\<comment\\>")) | |
890 (skip-chars-forward " \t\n\f") | |
891 (prog1 | |
892 (current-column) | |
893 (goto-char origin))) | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
894 ((eq where 1) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
895 ;; |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
896 ;; Directive. Always 0. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
897 ;; |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
898 0) |
805 | 899 ;; |
900 ;; Detect missing string delimiters | |
901 ;; | |
902 ((eq where 3) | |
903 (error "Inside string")) | |
904 ((eq where 4) | |
905 (error "Inside character constant")) | |
906 ;; | |
907 ;; check to see if inside ()'s | |
908 ;; | |
909 ((setq temp (simula-inside-parens)) | |
910 temp) | |
911 ;; | |
912 ;; Calculate non-comment indentation | |
913 (t | |
914 ;; first, find out if this line starts with something that needs | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2315
diff
changeset
|
915 ;; special indentation (END/IF/THEN/ELSE/WHEN/OTHERWISE or label) |
805 | 916 ;; |
917 (skip-chars-forward " \t\f") | |
918 (cond | |
919 ;; | |
920 ;; END | |
921 ;; | |
922 ((looking-at "end\\>") | |
923 (setq indent (- simula-indent-level) | |
924 found-end t)) | |
925 ;; | |
926 ;; IF/THEN/ELSE | |
927 ;; | |
928 ((looking-at "if\\>\\|then\\>\\|else\\>") | |
929 ;; search for the *starting* IF | |
930 (cond | |
931 ((memq (following-char) '(?T ?t)) | |
932 (setq indent (car simula-if-indent))) | |
933 ((memq (following-char) '(?E ?e)) | |
934 (setq indent (cdr simula-if-indent))) | |
935 (t | |
936 (forward-word 1) | |
937 (setq indent 0))) | |
938 (simula-find-if)) | |
939 ;; | |
940 ;; WHEN/OTHERWISE | |
941 ;; | |
942 ((looking-at "when\\>\\|otherwise\\>") | |
943 ;; search for corresponding INSPECT | |
944 (if (memq (following-char) '(?W ?w)) | |
945 (setq indent (car simula-inspect-indent)) | |
946 (setq indent (cdr simula-inspect-indent))) | |
947 (simula-find-inspect)) | |
948 ;; | |
949 ;; label: | |
950 ;; | |
951 ((and (not (looking-at "virtual\\>")) | |
952 (looking-at "[a-z0-9_]*[ \t\f]*:[^-=]")) | |
953 (setq indent simula-label-offset))) | |
954 ;; find line with non-comment text | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
955 (simula-skip-comment-backward 'dont-skip-end) |
805 | 956 (if (and found-end |
957 (not (eq (preceding-char) ?\;)) | |
958 (if (memq (preceding-char) '(?N ?n)) | |
959 (save-excursion | |
1621
ec2c000b8b69
* bytecomp.el: Declare unread-command-char an obsolete variable.
Jim Blandy <jimb@redhat.com>
parents:
841
diff
changeset
|
960 (backward-word 1) |
805 | 961 (not (looking-at "begin\\>"))) |
962 t)) | |
963 (progn | |
964 (simula-previous-statement 1) | |
965 (simula-skip-comment-backward))) | |
966 (setq start-line | |
111429
249a1455856a
Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents:
110305
diff
changeset
|
967 (line-beginning-position) |
805 | 968 ;; - perhaps this is a continued statement |
969 continued | |
970 (save-excursion | |
971 (and (not (bobp)) | |
972 ;; (not found-end) | |
973 (if (eq (char-syntax (preceding-char)) ?w) | |
974 (progn | |
975 (backward-word 1) | |
976 (not (looking-at | |
977 "begin\\|then\\|else\\|when\\|otherwise\\|do" | |
978 ))) | |
979 (not (memq (preceding-char) '(?: ?\;))))))) | |
980 ;; | |
981 ;; MAIN calculation loop - count BEGIN/DO etc. | |
982 ;; | |
983 (while (not (bolp)) | |
984 (if (re-search-backward | |
985 ";\\|\\<\\(begin\\|end\\|if\\|else\\|then\\|when\\|otherwise\\|do\\)\\>" | |
986 start-line 'move) | |
987 (if (simula-context) | |
988 ();; found something in a comment/string - ignore | |
989 (setq temp (following-char)) | |
990 (cond | |
991 ((eq temp ?\;) | |
992 (simula-previous-statement 1)) | |
993 ((looking-at "begin\\>") | |
994 (setq indent (+ indent simula-indent-level))) | |
995 ((looking-at "end\\>") | |
996 (forward-word 1) | |
997 (simula-previous-statement 1)) | |
998 ((looking-at "do\\>") | |
999 (setq indent (+ indent simula-substatement-offset)) | |
1000 (simula-find-do-match)) | |
1001 ((looking-at "\\(if\\|then\\|else\\)\\>") | |
1002 (if (memq temp '(?I ?i)) | |
1003 (forward-word 1) | |
1004 (setq indent (+ indent | |
1005 simula-substatement-offset | |
1006 (if (memq temp '(?T ?t)) | |
1007 (car simula-if-indent) | |
1008 (cdr simula-if-indent))))) | |
1009 (simula-find-if)) | |
1010 ((looking-at "\\<when\\>\\|\\<otherwise\\>") | |
1011 (setq indent (+ indent | |
1012 simula-substatement-offset | |
1013 (if (memq temp '(?W ?w)) | |
1014 (car simula-if-indent) | |
1015 (cdr simula-if-indent)))) | |
1016 (simula-find-inspect))) | |
1017 ;; found the start of a [sub]statement | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2315
diff
changeset
|
1018 ;; add indentation for continued statement |
805 | 1019 (if continued |
1020 (setq indent | |
1021 (+ indent | |
1022 (if (listp simula-continued-statement-offset) | |
1023 (car simula-continued-statement-offset) | |
1024 simula-continued-statement-offset)))) | |
1025 (setq start-line | |
111429
249a1455856a
Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents:
110305
diff
changeset
|
1026 (line-beginning-position) |
805 | 1027 continued nil)) |
1028 ;; search failed .. point is at beginning of line | |
1029 ;; determine if we should continue searching | |
1030 ;; (at or before comment or label) | |
1031 ;; temp = t means finished | |
1032 (setq temp | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47024
diff
changeset
|
1033 (and (not (simula-context)) |
805 | 1034 (save-excursion |
1035 (skip-chars-forward " \t\f") | |
1036 (or (looking-at "virtual") | |
1037 (not | |
1038 (looking-at | |
1039 "!\\|comment\\>\\|[a-z0-9_]*[ \t\f]*:[^-=]"))))) | |
1040 prev-cont continued) | |
1041 ;; if we are finished, find current line's indentation | |
1042 (if temp | |
1043 (setq indent (+ indent (current-indentation)))) | |
1044 ;; find next line with non-comment SIMULA text | |
1045 ;; maybe indent extra if statement continues | |
1046 (simula-skip-comment-backward) | |
1047 (setq continued | |
1048 (and (not (bobp)) | |
1049 (if (eq (char-syntax (preceding-char)) ?w) | |
1050 (save-excursion | |
1051 (backward-word 1) | |
1052 (not (looking-at | |
1053 "begin\\|then\\|else\\|when\\|otherwise\\|do"))) | |
1054 (not (memq (preceding-char) '(?: ?\;)))))) | |
1055 ;; if we the state of the continued-variable | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2315
diff
changeset
|
1056 ;; changed, add indentation for continued statement |
805 | 1057 (if (or (and prev-cont (not continued)) |
1058 (and continued | |
1059 (listp simula-continued-statement-offset))) | |
1060 (setq indent | |
1061 (+ indent | |
1062 (if (listp simula-continued-statement-offset) | |
1063 (car simula-continued-statement-offset) | |
1064 simula-continued-statement-offset)))) | |
1065 ;; while ends if point is at beginning of line at loop test | |
1066 (if (not temp) | |
111429
249a1455856a
Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents:
110305
diff
changeset
|
1067 (setq start-line (line-beginning-position)) |
805 | 1068 (beginning-of-line)))) |
1069 ;; | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2315
diff
changeset
|
1070 ;; return indentation |
805 | 1071 ;; |
1072 indent))))) | |
1073 | |
1074 | |
1075 (defun simula-find-if () | |
4664 | 1076 "Find starting IF of a IF-THEN[-ELSE[-IF-THEN...]] statement." |
805 | 1077 (catch 'simula-out |
1078 (while t | |
1079 (if (and (simula-search-backward "\\<if\\>\\|;\\|\\<begin\\>"nil t) | |
1080 (memq (following-char) '(?I ?i))) | |
1081 (save-excursion | |
1082 ;; | |
1083 ;; find out if this IF was really the start of the IF statement | |
1084 ;; | |
1085 (simula-skip-comment-backward) | |
1086 (if (and (eq (char-syntax (preceding-char)) ?w) | |
1087 (progn | |
1088 (backward-word 1) | |
1089 (looking-at "else\\>"))) | |
1090 () | |
1091 (throw 'simula-out t))) | |
1092 (if (not (looking-at "\\<if\\>")) | |
1093 (error "Missing IF or misplaced BEGIN or ';' (can't find IF)") | |
1094 ;; | |
1095 ;; we were at the starting IF in the first place.. | |
1096 ;; | |
1097 (throw 'simula-out t)))))) | |
1098 | |
1099 | |
1100 (defun simula-find-inspect () | |
4664 | 1101 "Find INSPECT matching WHEN or OTHERWISE." |
805 | 1102 (catch 'simula-out |
1103 (let ((level 0)) | |
1104 ;; | |
1105 ;; INSPECTs can be nested, have to find the corresponding one | |
1106 ;; | |
1107 (while t | |
1108 (if (and (simula-search-backward "\\<inspect\\>\\|\\<otherwise\\>\\|;" | |
1109 nil t) | |
1110 (/= (following-char) ?\;)) | |
1111 (if (memq (following-char) '(?O ?o)) | |
1112 (setq level (1+ level)) | |
1113 (if (zerop level) | |
1114 (throw 'simula-out t) | |
1115 (setq level (1- level)))) | |
1116 (error "Missing INSPECT or misplaced ';' (can't find INSPECT)")))))) | |
1117 | |
1118 | |
1119 (defun simula-find-do-match () | |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1120 "Find keyword matching DO: FOR, WHILE, INSPECT or WHEN." |
805 | 1121 (while (and (re-search-backward |
1122 "\\<\\(do\\|for\\|while\\|inspect\\|when\\|end\\|begin\\)\\>\\|;" | |
1123 nil 'move) | |
1124 (simula-context))) | |
1125 (if (and (looking-at "\\<\\(for\\|while\\|inspect\\|when\\)\\>") | |
1126 (not (simula-context))) | |
1127 () ;; found match | |
1128 (error "No matching FOR, WHILE or INSPECT for DO, or misplaced ';'"))) | |
1129 | |
1130 | |
1131 (defun simula-inside-parens () | |
4664 | 1132 "Return position after `(' on line if inside parentheses, nil otherwise." |
805 | 1133 (save-excursion |
1134 (let ((parlevel 0)) | |
1135 (catch 'simula-out | |
1136 (while t | |
1137 (if (re-search-backward "(\\|)\\|;" nil t) | |
1138 (if (eq (simula-context) nil) | |
1139 ;; found something - check it out | |
1140 (cond | |
1141 ((eq (following-char) ?\;) | |
1142 (if (zerop parlevel) | |
1143 (throw 'simula-out nil) | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2315
diff
changeset
|
1144 (error "Parenthesis mismatch or misplaced ';'"))) |
805 | 1145 ((eq (following-char) ?\() |
1146 (if (zerop parlevel) | |
1147 (throw 'simula-out (1+ (current-column))) | |
1148 (setq parlevel (1- parlevel)))) | |
1149 (t (setq parlevel (1+ parlevel)))) | |
1150 );; nothing - inside comment or string | |
1151 ;; search failed | |
1152 (throw 'simula-out nil))))))) | |
1153 | |
1154 | |
1155 (defun simula-goto-definition () | |
1156 "Goto point of definition of variable, procedure or class." | |
1157 (interactive)) | |
1158 | |
1159 | |
1160 (defun simula-expand-stdproc () | |
1161 (if (or (not simula-abbrev-stdproc) (simula-context)) | |
1162 (unexpand-abbrev) | |
1163 (cond | |
1164 ((eq simula-abbrev-stdproc 'upcase) (upcase-word -1)) | |
1165 ((eq simula-abbrev-stdproc 'downcase) (downcase-word -1)) | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1166 ((eq simula-abbrev-stdproc 'capitalize) (capitalize-word -1)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1167 ((eq simula-abbrev-stdproc 'abbrev-table) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1168 ;; If not in lowercase, expansions are always capitalized. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1169 ;; We then want to replace with the exact expansion. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1170 (if (equal (symbol-name last-abbrev) last-abbrev-text) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1171 () |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1172 (downcase-word -1) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1173 (expand-abbrev)))))) |
805 | 1174 |
1175 | |
1176 (defun simula-expand-keyword () | |
1177 (if (or (not simula-abbrev-keyword) (simula-context)) | |
1178 (unexpand-abbrev) | |
1179 (cond | |
1180 ((eq simula-abbrev-keyword 'upcase) (upcase-word -1)) | |
1181 ((eq simula-abbrev-keyword 'downcase) (downcase-word -1)) | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1182 ((eq simula-abbrev-keyword 'capitalize) (capitalize-word -1)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1183 ((eq simula-abbrev-stdproc 'abbrev-table) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1184 (if (equal (symbol-name last-abbrev) last-abbrev-text) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1185 () |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1186 (downcase-word -1) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1187 (expand-abbrev)))))) |
805 | 1188 |
1189 | |
1190 (defun simula-electric-keyword () | |
4664 | 1191 "Expand SIMULA keyword. If it starts the line, reindent." |
805 | 1192 ;; redisplay |
1193 (let ((show-char (eq this-command 'self-insert-command))) | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2315
diff
changeset
|
1194 ;; If the abbrev expansion results in reindentation, the user may have |
805 | 1195 ;; to wait some time before the character he typed is displayed |
1196 ;; (the char causing the expansion is inserted AFTER the hook function | |
1197 ;; is called). This is annoying in case of normal characters. | |
1198 ;; However, if the user pressed a key bound to newline, it is better | |
1199 ;; to have the line inserted after the begin-end match. | |
1200 (if show-char | |
1201 (progn | |
101002
3b3c7e10cd97
Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
1202 (insert-char last-command-event 1) |
805 | 1203 (sit-for 0) |
1204 (backward-char 1))) | |
1205 (if (let ((where (simula-context)) | |
1206 (case-fold-search t)) | |
1207 (if where | |
1208 (if (and (eq where 2) (eq (char-syntax (preceding-char)) ?w)) | |
1209 (save-excursion | |
1210 (backward-word 1) | |
1211 (not (looking-at "end\\>")))))) | |
1212 (unexpand-abbrev) | |
1213 (cond | |
1214 ((not simula-abbrev-keyword) (unexpand-abbrev)) | |
1215 ((eq simula-abbrev-keyword 'upcase) (upcase-word -1)) | |
1216 ((eq simula-abbrev-keyword 'downcase) (downcase-word -1)) | |
1217 ((eq simula-abbrev-keyword 'capitalize) (capitalize-word -1))) | |
1218 (let ((pos (- (point-max) (point))) | |
1219 (case-fold-search t) | |
1220 null) | |
1221 (condition-case null | |
1222 (progn | |
1223 ;; check if the expanded word is on the beginning of the line. | |
1224 (if (and (eq (char-syntax (preceding-char)) ?w) | |
1225 (progn | |
1226 (backward-word 1) | |
1227 (if (looking-at "end\\>") | |
1228 (save-excursion | |
1229 (simula-backward-up-level 1) | |
1230 (if (pos-visible-in-window-p) | |
1231 (sit-for 1) | |
14330
35a18ea09b7b
(simula-electric-keyword): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
1232 (message "Matches %s" |
805 | 1233 (buffer-substring |
1234 (point) | |
14330
35a18ea09b7b
(simula-electric-keyword): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
1235 (+ (point) (window-width))))))) |
805 | 1236 (skip-chars-backward " \t\f") |
1237 (bolp))) | |
1238 (let ((indent (simula-calculate-indent))) | |
1239 (if (eq indent (current-indentation)) | |
1240 () | |
1241 (delete-horizontal-space) | |
1242 (indent-to indent))) | |
1243 (skip-chars-forward " \t\f")) | |
1244 ;; check for END - blow whistles and ring bells | |
1245 | |
1246 (goto-char (- (point-max) pos)) | |
1247 (if show-char | |
1248 (delete-char 1))) | |
1249 (quit (goto-char (- (point-max) pos)))))))) | |
1250 | |
1251 | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1252 (defun simula-search-backward (regexp &optional bound noerror) |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1253 "Search backward from point for regular expression REGEXP, |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1254 ignoring matches found inside SIMULA comments, string literals, |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1255 and BEGIN..END blocks. |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1256 Set point to the end of the occurrence found, and return point. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1257 An optional second argument BOUND bounds the search, it is a buffer position. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1258 The match found must not extend after that position. Optional third argument |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1259 NOERROR, if t, means if fail just return nil (no error). |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1260 If not nil and not t, move to limit of search and return nil." |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1261 (let (begin end context (comb-regexp (concat regexp "\\|\\<end\\>")) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1262 match (start-point (point))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1263 (catch 'simula-backward |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1264 (while (re-search-backward comb-regexp bound 1) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1265 ;; We have a match, check SIMULA context at match-beginning |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1266 ;; to see if we are outside comments etc. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1267 ;; Set MATCH to t if we found a true match, |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1268 ;; set MATCH to 'BLOCK if we found a BEGIN..END block, |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1269 ;; else set MATCH to nil. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1270 (save-match-data |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1271 (setq context (simula-context)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1272 (cond |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1273 ((eq context nil) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1274 (setq match (if (looking-at regexp) t 'BLOCK))) |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1275 ;; A comment-ending `;' is part of the comment, and shouldn't match. |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1276 ;; ((eq context 0) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1277 ;; (setq match (if (eq (following-char) ?\;) t nil))) |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1278 ((eq context 2) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1279 (setq match (if (and (looking-at regexp) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1280 (looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>")) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1281 t |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1282 (if (looking-at "\\<end\\>") 'BLOCK nil)))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1283 (t (setq match nil)))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1284 ;; Exit if true match |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1285 (if (eq match t) (throw 'simula-backward (point))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1286 (if (eq match 'BLOCK) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1287 ;; We found the END of a block |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1288 (let ((level 0)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1289 (while (natnump level) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1290 (if (re-search-backward "\\<begin\\>\\|\\<end\\>" bound 1) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1291 (let ((context (simula-context))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1292 ;; We found a BEGIN -> decrease level count |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1293 (cond ((and (eq context nil) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1294 (memq (following-char) '(?b ?B))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1295 (setq level (1- level))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1296 ;; END -> increase level count |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1297 ((and (memq context '(nil 2)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1298 (memq (following-char) '(?e ?E))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1299 (setq level (1+ level))))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1300 ;; Block search failed. Action depends on noerror. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1301 (if (or (not noerror) (eq noerror t)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1302 (goto-char start-point)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1303 (if (not noerror) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1304 (signal 'search-failed (list regexp))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1305 (throw 'simula-backward nil)))))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1306 ;; Search failed. Action depends on noerror. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1307 (if (or (not noerror) (eq noerror t)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1308 (goto-char start-point)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1309 (if noerror |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1310 nil |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1311 (signal 'search-failed (list regexp)))))) |
805 | 1312 |
1313 | |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1314 (defun simula-search-forward (regexp &optional bound noerror) |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1315 "Search forward from point for regular expression REGEXP, |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1316 ignoring matches found inside SIMULA comments, string literals, |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1317 and BEGIN..END blocks. |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1318 Set point to the end of the occurrence found, and return point. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1319 An optional second argument BOUND bounds the search, it is a buffer position. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1320 The match found must not extend after that position. Optional third argument |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1321 NOERROR, if t, means if fail just return nil (no error). |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1322 If not nil and not t, move to limit of search and return nil." |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1323 (let (begin end context (comb-regexp (concat regexp "\\|\\<begin\\>")) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1324 match (start-point (point))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1325 (catch 'simula-forward |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1326 (while (re-search-forward comb-regexp bound 1) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1327 ;; We have a match, check SIMULA context at match-beginning |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1328 ;; to see if we are outside comments. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1329 ;; Set MATCH to t if we found a true match, |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1330 ;; set MATCH to 'BLOCK if we found a BEGIN..END block, |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1331 ;; else set MATCH to nil. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1332 (save-match-data |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1333 (save-excursion |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1334 (goto-char (match-beginning 0)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1335 (setq context (simula-context)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1336 (cond |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1337 ((not context) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1338 (setq match (if (looking-at regexp) t 'BLOCK))) |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1339 ;; Comment-ending `;' is part of the comment, and shouldn't match. |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1340 ;; ((eq context 0) |
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1341 ;; (setq match (if (eq (following-char) ?\;) t nil))) |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1342 ((eq context 2) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1343 (setq match (if (and (looking-at regexp) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1344 (looking-at ";\\|\\<end\\>\\|\\<else\\>\\|\\<otherwise\\>\\|\\<when\\>")) t nil))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1345 (t (setq match nil))))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1346 ;; Exit if true match |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1347 (if (eq match t) (throw 'simula-forward (point))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1348 (if (eq match 'BLOCK) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1349 ;; We found the BEGINning of a block |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1350 (let ((level 0)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1351 (while (natnump level) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1352 (if (re-search-forward "\\<begin\\>\\|\\<end\\>" bound 1) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1353 (let ((context (simula-context))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1354 ;; We found a BEGIN -> increase level count |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1355 (cond ((eq context nil) (setq level (1+ level))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1356 ;; END -> decrease level count |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1357 ((and (eq context 2) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1358 ;; Don't match BEGIN inside END comment |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1359 (memq (preceding-char) '(?d ?D))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1360 (setq level (1- level))))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1361 ;; Block search failed. Action depends on noerror. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1362 (if (or (not noerror) (eq noerror t)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1363 (goto-char start-point)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1364 (if (not noerror) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1365 (signal 'search-failed (list regexp))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1366 (throw 'simula-forward nil)))))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1367 ;; Search failed. Action depends on noerror. |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1368 (if (or (not noerror) (eq noerror t)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1369 (goto-char start-point)) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1370 (if noerror |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1371 nil |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1372 (signal 'search-failed (list regexp)))))) |
805 | 1373 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47024
diff
changeset
|
1374 |
805 | 1375 (defun simula-install-standard-abbrevs () |
4664 | 1376 "Define Simula keywords, procedures and classes in local abbrev table." |
805 | 1377 ;; procedure and class names are as of the SIMULA 87 standard. |
1378 (interactive) | |
49972
0b437aaddba5
Move abbrev loading to after the fun it uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49731
diff
changeset
|
1379 (dolist (args |
805 | 1380 '(("abs" "Abs" simula-expand-stdproc) |
1381 ("accum" "Accum" simula-expand-stdproc) | |
1382 ("activate" "ACTIVATE" simula-expand-keyword) | |
1383 ("addepsilon" "AddEpsilon" simula-expand-stdproc) | |
1384 ("after" "AFTER" simula-expand-keyword) | |
1385 ("and" "AND" simula-expand-keyword) | |
1386 ("arccos" "ArcCos" simula-expand-stdproc) | |
1387 ("arcsin" "ArcSin" simula-expand-stdproc) | |
1388 ("arctan" "ArcTan" simula-expand-stdproc) | |
1389 ("arctan2" "ArcTan2" simula-expand-stdproc) | |
1390 ("array" "ARRAY" simula-expand-keyword) | |
1391 ("at" "AT" simula-expand-keyword) | |
1392 ("before" "BEFORE" simula-expand-keyword) | |
1393 ("begin" "BEGIN" simula-expand-keyword) | |
1394 ("blanks" "Blanks" simula-expand-stdproc) | |
1395 ("boolean" "BOOLEAN" simula-expand-keyword) | |
1396 ("breakoutimage" "BreakOutImage" simula-expand-stdproc) | |
1397 ("bytefile" "ByteFile" simula-expand-stdproc) | |
1398 ("call" "Call" simula-expand-stdproc) | |
1399 ("cancel" "Cancel" simula-expand-stdproc) | |
1400 ("cardinal" "Cardinal" simula-expand-stdproc) | |
1401 ("char" "Char" simula-expand-stdproc) | |
1402 ("character" "CHARACTER" simula-expand-keyword) | |
1403 ("checkpoint" "CheckPoint" simula-expand-stdproc) | |
1404 ("class" "CLASS" simula-expand-keyword) | |
1405 ("clear" "Clear" simula-expand-stdproc) | |
1406 ("clocktime" "ClockTime" simula-expand-stdproc) | |
1407 ("close" "Close" simula-expand-stdproc) | |
1408 ("comment" "COMMENT" simula-expand-keyword) | |
1409 ("constant" "Constant" simula-expand-stdproc) | |
1410 ("copy" "Copy" simula-expand-stdproc) | |
1411 ("cos" "Cos" simula-expand-stdproc) | |
1412 ("cosh" "CosH" simula-expand-stdproc) | |
1413 ("cotan" "CoTan" simula-expand-stdproc) | |
1414 ("cputime" "CpuTime" simula-expand-stdproc) | |
1415 ("current" "Current" simula-expand-stdproc) | |
1416 ("datetime" "DateTime" simula-expand-stdproc) | |
1417 ("decimalmark" "DecimalMark" simula-expand-stdproc) | |
1418 ("delay" "DELAY" simula-expand-keyword) | |
1419 ("deleteimage" "DeleteImage" simula-expand-stdproc) | |
1420 ("detach" "Detach" simula-expand-stdproc) | |
1421 ("digit" "Digit" simula-expand-stdproc) | |
1422 ("directbytefile" "DirectByteFile" simula-expand-stdproc) | |
1423 ("directfile" "DirectFile" simula-expand-stdproc) | |
1424 ("discrete" "Discrete" simula-expand-stdproc) | |
1425 ("do" "DO" simula-expand-keyword) | |
1426 ("downcase" "Downcase" simula-expand-stdproc) | |
1427 ("draw" "Draw" simula-expand-stdproc) | |
1428 ("eject" "Eject" simula-expand-stdproc) | |
1429 ("else" "ELSE" simula-electric-keyword) | |
1430 ("empty" "Empty" simula-expand-stdproc) | |
1431 ("end" "END" simula-electric-keyword) | |
1432 ("endfile" "Endfile" simula-expand-stdproc) | |
1433 ("entier" "Entier" simula-expand-stdproc) | |
1434 ("eq" "EQ" simula-expand-keyword) | |
1435 ("eqv" "EQV" simula-expand-keyword) | |
1436 ("erlang" "Erlang" simula-expand-stdproc) | |
1437 ("error" "Error" simula-expand-stdproc) | |
1438 ("evtime" "EvTime" simula-expand-stdproc) | |
1439 ("exp" "Exp" simula-expand-stdproc) | |
1440 ("external" "EXTERNAL" simula-expand-keyword) | |
1441 ("false" "FALSE" simula-expand-keyword) | |
1442 ("field" "Field" simula-expand-stdproc) | |
1443 ("file" "File" simula-expand-stdproc) | |
1444 ("first" "First" simula-expand-stdproc) | |
1445 ("follow" "Follow" simula-expand-stdproc) | |
1446 ("for" "FOR" simula-expand-keyword) | |
1447 ("ge" "GE" simula-expand-keyword) | |
1448 ("getchar" "GetChar" simula-expand-stdproc) | |
1449 ("getfrac" "GetFrac" simula-expand-stdproc) | |
1450 ("getint" "GetInt" simula-expand-stdproc) | |
1451 ("getreal" "GetReal" simula-expand-stdproc) | |
1452 ("go" "GO" simula-expand-keyword) | |
1453 ("goto" "GOTO" simula-expand-keyword) | |
1454 ("gt" "GT" simula-expand-keyword) | |
1455 ("head" "Head" simula-expand-stdproc) | |
1456 ("hidden" "HIDDEN" simula-expand-keyword) | |
1457 ("histd" "HistD" simula-expand-stdproc) | |
1458 ("histo" "Histo" simula-expand-stdproc) | |
1459 ("hold" "Hold" simula-expand-stdproc) | |
1460 ("idle" "Idle" simula-expand-stdproc) | |
1461 ("if" "IF" simula-expand-keyword) | |
1462 ("image" "Image" simula-expand-stdproc) | |
1463 ("imagefile" "ImageFile" simula-expand-stdproc) | |
1464 ("imp" "IMP" simula-expand-keyword) | |
1465 ("in" "IN" simula-expand-keyword) | |
1466 ("inbyte" "InByte" simula-expand-stdproc) | |
1467 ("inbytefile" "InByteFile" simula-expand-stdproc) | |
1468 ("inchar" "InChar" simula-expand-stdproc) | |
1469 ("infile" "InFile" simula-expand-stdproc) | |
1470 ("infrac" "InFrac" simula-expand-stdproc) | |
1471 ("inimage" "InImage" simula-expand-stdproc) | |
1472 ("inint" "InInt" simula-expand-stdproc) | |
1473 ("inner" "INNER" simula-expand-keyword) | |
1474 ("inreal" "InReal" simula-expand-stdproc) | |
1475 ("inrecord" "InRecord" simula-expand-stdproc) | |
1476 ("inspect" "INSPECT" simula-expand-keyword) | |
1477 ("integer" "INTEGER" simula-expand-keyword) | |
1478 ("intext" "InText" simula-expand-stdproc) | |
1479 ("into" "Into" simula-expand-stdproc) | |
1480 ("is" "IS" simula-expand-keyword) | |
1481 ("isochar" "ISOChar" simula-expand-stdproc) | |
1482 ("isopen" "IsOpen" simula-expand-stdproc) | |
1483 ("isorank" "ISORank" simula-expand-stdproc) | |
1484 ("label" "LABEL" simula-expand-keyword) | |
1485 ("last" "Last" simula-expand-stdproc) | |
1486 ("lastitem" "LastItem" simula-expand-stdproc) | |
1487 ("lastloc" "LastLoc" simula-expand-stdproc) | |
1488 ("le" "LE" simula-expand-keyword) | |
1489 ("length" "Length" simula-expand-stdproc) | |
1490 ("letter" "Letter" simula-expand-stdproc) | |
1491 ("line" "Line" simula-expand-stdproc) | |
1492 ("linear" "Linear" simula-expand-stdproc) | |
1493 ("linesperpage" "LinesPerPage" simula-expand-stdproc) | |
1494 ("link" "Link" simula-expand-stdproc) | |
1495 ("linkage" "Linkage" simula-expand-stdproc) | |
1496 ("ln" "Ln" simula-expand-stdproc) | |
1497 ("locate" "Locate" simula-expand-stdproc) | |
1498 ("location" "Location" simula-expand-stdproc) | |
1499 ("lock" "Lock" simula-expand-stdproc) | |
1500 ("locked" "Locked" simula-expand-stdproc) | |
1501 ("log10" "Log10" simula-expand-stdproc) | |
1502 ("long" "LONG" simula-expand-keyword) | |
1503 ("lowcase" "LowCase" simula-expand-stdproc) | |
1504 ("lowerbound" "LowerBound" simula-expand-stdproc) | |
1505 ("lowten" "LowTen" simula-expand-stdproc) | |
1506 ("lt" "LT" simula-expand-keyword) | |
1507 ("main" "Main" simula-expand-stdproc) | |
1508 ("max" "Max" simula-expand-stdproc) | |
1509 ("maxint" "MaxInt" simula-expand-stdproc) | |
1510 ("maxlongreal" "MaxLongReal" simula-expand-stdproc) | |
1511 ("maxloc" "MaxLoc" simula-expand-stdproc) | |
1512 ("maxrank" "MaxRank" simula-expand-stdproc) | |
1513 ("maxreal" "MaxReal" simula-expand-stdproc) | |
1514 ("min" "Min" simula-expand-stdproc) | |
1515 ("minint" "MinInt" simula-expand-stdproc) | |
1516 ("minlongreal" "MinLongReal" simula-expand-stdproc) | |
1517 ("minrank" "MinRank" simula-expand-stdproc) | |
1518 ("minreal" "MinReal" simula-expand-stdproc) | |
1519 ("mod" "Mod" simula-expand-stdproc) | |
1520 ("more" "More" simula-expand-stdproc) | |
1521 ("name" "NAME" simula-expand-keyword) | |
1522 ("ne" "NE" simula-expand-keyword) | |
1523 ("negexp" "NegExp" simula-expand-stdproc) | |
1524 ("new" "NEW" simula-expand-keyword) | |
1525 ("nextev" "NextEv" simula-expand-stdproc) | |
1526 ("none" "NONE" simula-expand-keyword) | |
1527 ("normal" "Normal" simula-expand-stdproc) | |
1528 ("not" "NOT" simula-expand-keyword) | |
1529 ("notext" "NOTEXT" simula-expand-keyword) | |
1530 ("open" "Open" simula-expand-stdproc) | |
1531 ("or" "OR" simula-expand-keyword) | |
1532 ("otherwise" "OTHERWISE" simula-electric-keyword) | |
1533 ("out" "Out" simula-expand-stdproc) | |
1534 ("outbyte" "OutByte" simula-expand-stdproc) | |
1535 ("outbytefile" "OutByteFile" simula-expand-stdproc) | |
1536 ("outchar" "OutChar" simula-expand-stdproc) | |
1537 ("outfile" "OutFile" simula-expand-stdproc) | |
1538 ("outfix" "OutFix" simula-expand-stdproc) | |
1539 ("outfrac" "OutFrac" simula-expand-stdproc) | |
1540 ("outimage" "OutImage" simula-expand-stdproc) | |
1541 ("outint" "OutInt" simula-expand-stdproc) | |
1542 ("outreal" "OutReal" simula-expand-stdproc) | |
1543 ("outrecord" "OutRecord" simula-expand-stdproc) | |
1544 ("outtext" "OutText" simula-expand-stdproc) | |
1545 ("page" "Page" simula-expand-stdproc) | |
1546 ("passivate" "Passivate" simula-expand-stdproc) | |
1547 ("poisson" "Poisson" simula-expand-stdproc) | |
1548 ("pos" "Pos" simula-expand-stdproc) | |
1549 ("precede" "Precede" simula-expand-stdproc) | |
1550 ("pred" "Pred" simula-expand-stdproc) | |
1551 ("prev" "Prev" simula-expand-stdproc) | |
1552 ("printfile" "PrintFile" simula-expand-stdproc) | |
1553 ("prior" "PRIOR" simula-expand-keyword) | |
1554 ("procedure" "PROCEDURE" simula-expand-keyword) | |
1555 ("process" "Process" simula-expand-stdproc) | |
1556 ("protected" "PROTECTED" simula-expand-keyword) | |
1557 ("putchar" "PutChar" simula-expand-stdproc) | |
1558 ("putfix" "PutFix" simula-expand-stdproc) | |
1559 ("putfrac" "PutFrac" simula-expand-stdproc) | |
1560 ("putint" "PutInt" simula-expand-stdproc) | |
1561 ("putreal" "PutReal" simula-expand-stdproc) | |
1562 ("qua" "QUA" simula-expand-keyword) | |
1563 ("randint" "RandInt" simula-expand-stdproc) | |
1564 ("rank" "Rank" simula-expand-stdproc) | |
1565 ("reactivate" "REACTIVATE" simula-expand-keyword) | |
1566 ("real" "REAL" simula-expand-keyword) | |
1567 ("ref" "REF" simula-expand-keyword) | |
1568 ("resume" "Resume" simula-expand-stdproc) | |
1569 ("setaccess" "SetAccess" simula-expand-stdproc) | |
1570 ("setpos" "SetPos" simula-expand-stdproc) | |
1571 ("short" "SHORT" simula-expand-keyword) | |
1572 ("sign" "Sign" simula-expand-stdproc) | |
1573 ("simset" "SimSet" simula-expand-stdproc) | |
1574 ("simulaid" "SimulaId" simula-expand-stdproc) | |
1575 ("simulation" "Simulation" simula-expand-stdproc) | |
1576 ("sin" "Sin" simula-expand-stdproc) | |
1577 ("sinh" "SinH" simula-expand-stdproc) | |
1578 ("sourceline" "SourceLine" simula-expand-stdproc) | |
1579 ("spacing" "Spacing" simula-expand-stdproc) | |
1580 ("sqrt" "Sqrt" simula-expand-stdproc) | |
1581 ("start" "Start" simula-expand-stdproc) | |
1582 ("step" "STEP" simula-expand-keyword) | |
1583 ("strip" "Strip" simula-expand-stdproc) | |
1584 ("sub" "Sub" simula-expand-stdproc) | |
1585 ("subepsilon" "SubEpsilon" simula-expand-stdproc) | |
1586 ("suc" "Suc" simula-expand-stdproc) | |
1587 ("switch" "SWITCH" simula-expand-keyword) | |
1588 ("sysin" "SysIn" simula-expand-stdproc) | |
1589 ("sysout" "SysOut" simula-expand-stdproc) | |
1590 ("tan" "Tan" simula-expand-stdproc) | |
1591 ("tanh" "TanH" simula-expand-stdproc) | |
1592 ("terminate_program" "Terminate_Program" simula-expand-stdproc) | |
1593 ("terminated" "Terminated" simula-expand-stdproc) | |
1594 ("text" "TEXT" simula-expand-keyword) | |
1595 ("then" "THEN" simula-electric-keyword) | |
1596 ("this" "THIS" simula-expand-keyword) | |
1597 ("time" "Time" simula-expand-stdproc) | |
1598 ("to" "TO" simula-expand-keyword) | |
1599 ("true" "TRUE" simula-expand-keyword) | |
1600 ("uniform" "Uniform" simula-expand-stdproc) | |
1601 ("unlock" "Unlock" simula-expand-stdproc) | |
1602 ("until" "UNTIL" simula-expand-keyword) | |
1603 ("upcase" "Upcase" simula-expand-stdproc) | |
1604 ("upperbound" "UpperBound" simula-expand-stdproc) | |
1605 ("value" "VALUE" simula-expand-keyword) | |
1606 ("virtual" "VIRTUAL" simula-expand-keyword) | |
1607 ("wait" "Wait" simula-expand-stdproc) | |
1608 ("when" "WHEN" simula-electric-keyword) | |
49972
0b437aaddba5
Move abbrev loading to after the fun it uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49731
diff
changeset
|
1609 ("while" "WHILE" simula-expand-keyword))) |
0b437aaddba5
Move abbrev loading to after the fun it uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49731
diff
changeset
|
1610 (define-abbrev simula-mode-abbrev-table |
0b437aaddba5
Move abbrev loading to after the fun it uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49731
diff
changeset
|
1611 (nth 0 args) (nth 1 args) (nth 2 args) nil 'system))) |
0b437aaddba5
Move abbrev loading to after the fun it uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49731
diff
changeset
|
1612 |
0b437aaddba5
Move abbrev loading to after the fun it uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49731
diff
changeset
|
1613 (if simula-abbrev-file |
0b437aaddba5
Move abbrev loading to after the fun it uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49731
diff
changeset
|
1614 (read-abbrev-file simula-abbrev-file)) |
0b437aaddba5
Move abbrev loading to after the fun it uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49731
diff
changeset
|
1615 (let (abbrevs-changed) |
0b437aaddba5
Move abbrev loading to after the fun it uses.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49731
diff
changeset
|
1616 (simula-install-standard-abbrevs)) |
805 | 1617 |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1618 ;; Hilit mode support. |
85825
13163bbed0bf
* progmodes/mixal-mode.el (mixal-run, mixal-debug): Call mixvm
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78234
diff
changeset
|
1619 (when (fboundp 'hilit-set-mode-patterns) |
13163bbed0bf
* progmodes/mixal-mode.el (mixal-run, mixal-debug): Call mixvm
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78234
diff
changeset
|
1620 (when (and (boundp 'hilit-patterns-alist) |
13163bbed0bf
* progmodes/mixal-mode.el (mixal-run, mixal-debug): Call mixvm
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78234
diff
changeset
|
1621 (not (assoc 'simula-mode hilit-patterns-alist))) |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1622 (hilit-set-mode-patterns |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1623 'simula-mode |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1624 '( |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1625 ("^%\\([ \t\f].*\\)?$" nil comment) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1626 ("^%include\\>" nil include) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1627 ("\"[^\"\n]*\"\\|'.'\\|'![0-9]+!'" nil string) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1628 ("\\<\\(ACTIVATE\\|AFTER\\|AND\\|ARRAY\\|AT\\|BEFORE\\|BEGIN\\|BOOLEAN\\|CHARACTER\\|CLASS\\|DELAY\\|DO\\|ELSE\\|END\\|EQ\\|EQV\\|EXTERNAL\\|FALSE\\|FOR\\|GE\\|GO\\|GOTO\\|GT\\|HIDDEN\\|IF\\|IMP\\|IN\\|INNER\\|INSPECT\\|INTEGER\\|IS\\|LABEL\\|LE\\|LONG\\|LT\\|NAME\\|NE\\|NEW\\|NONE\\|NOT\\|NOTEXT\\|OR\\|OTHERWISE\\|PRIOR\\|PROCEDURE\\|PROTECTED\\|QUA\\|REACTIVATE\\|REAL\\|REF\\|SHORT\\|STEP\\|SWITCH\\|TEXT\\|THEN\\|THIS\\|TO\\|TRUE\\|UNTIL\\|VALUE\\|VIRTUAL\\|WHEN\\|WHILE\\)\\>" nil keyword) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1629 ("!\\|\\<COMMENT\\>" ";" comment)) |
85825
13163bbed0bf
* progmodes/mixal-mode.el (mixal-run, mixal-debug): Call mixvm
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78234
diff
changeset
|
1630 nil 'case-insensitive))) |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1631 |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1632 ;; defuns for submitting bug reports |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1633 |
94116
842d446b22d9
Cleanup the bug-report email addresses and make sure the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93975
diff
changeset
|
1634 (defconst simula-mode-help-address "bug-gnu-emacs@gnu.org" |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1635 "Address accepting submission of `simula-mode' bug reports.") |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1636 |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1637 (defun simula-submit-bug-report () |
49731
36beaccb197a
(simula-font-lock-syntactic-keywords): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1638 "Submit via mail a bug report on `simula-mode'." |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1639 (interactive) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1640 (and |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1641 (y-or-n-p "Do you want to submit a report on simula-mode? ") |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1642 (reporter-submit-bug-report |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1643 simula-mode-help-address |
15054
df34d8bec5fc
(simula-submit-bug-report): Use emacs-version.
Richard M. Stallman <rms@gnu.org>
parents:
15053
diff
changeset
|
1644 (concat "simula-mode from Emacs " emacs-version) |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1645 (list |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1646 ;; report only the vars that affect indentation |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1647 'simula-indent-level |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1648 'simula-substatement-offset |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1649 'simula-continued-statement-offset |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1650 'simula-label-offset |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1651 'simula-if-indent |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1652 'simula-inspect-indent |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1653 'simula-electric-indent |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1654 'simula-abbrev-keyword |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1655 'simula-abbrev-stdproc |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1656 'simula-abbrev-file |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1657 'simula-tab-always-indent |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1658 )))) |
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1659 |
25230
f4437b91a368
(simula): Provide `simula', not `simula-mode'.
Karl Heuer <kwzh@gnu.org>
parents:
21168
diff
changeset
|
1660 (provide 'simula) |
15053
68d9a01cfb23
(simula-tab-always-indent, simula-indent-level)
Richard M. Stallman <rms@gnu.org>
parents:
14330
diff
changeset
|
1661 |
805 | 1662 ;;; simula.el ends here |