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