Mercurial > emacs
annotate lisp/progmodes/modula2.el @ 19486:31fbf3a289c1
(display-time-hook): Minor doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 23 Aug 1997 17:01:03 +0000 |
parents | 11218164bc54 |
children | f3f9df46d008 |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
1 ;;; modula2.el --- Modula-2 editing support package |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
2 |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
3 ;; Author: Michael Schmidt <michael@pbinfo.UUCP> |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
4 ;; Tom Perrine <Perrin@LOGICON.ARPA> |
17996 | 5 ;; Maintainer: FSF |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
791
diff
changeset
|
6 ;; Keywords: languages |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
7 |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
8 ;; The authors distributed this without a copyright notice |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
9 ;; back in 1988, so it is in the public domain. The original included |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
10 ;; the following credit: |
22 | 11 |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
12 ;; Author Mick Jordan |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
13 ;; amended Peter Robinson |
22 | 14 |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
15 ;;; Commentary: |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
16 |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
17 ;; A major mode for editing Modula-2 code. It provides convenient abbrevs |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
18 ;; for Modula-2 keywords, knows about the standard layout rules, and supports |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
19 ;; a native compile command. |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
20 |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
21 ;;; Code: |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
22 |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
23 ;;; Added by Tom Perrine (TEP) |
22 | 24 (defvar m2-mode-syntax-table nil |
231 | 25 "Syntax table in use in Modula-2 buffers.") |
22 | 26 |
27 (defvar m2-compile-command "m2c" | |
28 "Command to compile Modula-2 programs") | |
29 | |
30 (defvar m2-link-command "m2l" | |
31 "Command to link Modula-2 programs") | |
32 | |
33 (defvar m2-link-name nil | |
34 "Name of the executable.") | |
35 | |
17532
5c77f95c5dd1
(m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17496
diff
changeset
|
36 (defvar m2-end-comment-column nil |
5c77f95c5dd1
(m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17496
diff
changeset
|
37 "*Column for aligning the end of a comment, in Modula-2.") |
22 | 38 |
39 (if m2-mode-syntax-table | |
40 () | |
41 (let ((table (make-syntax-table))) | |
42 (modify-syntax-entry ?\\ "\\" table) | |
43 (modify-syntax-entry ?\( ". 1" table) | |
44 (modify-syntax-entry ?\) ". 4" table) | |
45 (modify-syntax-entry ?* ". 23" table) | |
46 (modify-syntax-entry ?+ "." table) | |
47 (modify-syntax-entry ?- "." table) | |
48 (modify-syntax-entry ?= "." table) | |
49 (modify-syntax-entry ?% "." table) | |
50 (modify-syntax-entry ?< "." table) | |
51 (modify-syntax-entry ?> "." table) | |
52 (modify-syntax-entry ?\' "\"" table) | |
53 (setq m2-mode-syntax-table table))) | |
54 | |
55 ;;; Added by TEP | |
56 (defvar m2-mode-map nil | |
57 "Keymap used in Modula-2 mode.") | |
58 | |
59 (if m2-mode-map () | |
60 (let ((map (make-sparse-keymap))) | |
61 (define-key map "\^i" 'm2-tab) | |
62 (define-key map "\C-cb" 'm2-begin) | |
63 (define-key map "\C-cc" 'm2-case) | |
64 (define-key map "\C-cd" 'm2-definition) | |
65 (define-key map "\C-ce" 'm2-else) | |
66 (define-key map "\C-cf" 'm2-for) | |
67 (define-key map "\C-ch" 'm2-header) | |
68 (define-key map "\C-ci" 'm2-if) | |
69 (define-key map "\C-cm" 'm2-module) | |
70 (define-key map "\C-cl" 'm2-loop) | |
71 (define-key map "\C-co" 'm2-or) | |
72 (define-key map "\C-cp" 'm2-procedure) | |
73 (define-key map "\C-c\C-w" 'm2-with) | |
74 (define-key map "\C-cr" 'm2-record) | |
75 (define-key map "\C-cs" 'm2-stdio) | |
76 (define-key map "\C-ct" 'm2-type) | |
77 (define-key map "\C-cu" 'm2-until) | |
78 (define-key map "\C-cv" 'm2-var) | |
79 (define-key map "\C-cw" 'm2-while) | |
80 (define-key map "\C-cx" 'm2-export) | |
81 (define-key map "\C-cy" 'm2-import) | |
82 (define-key map "\C-c{" 'm2-begin-comment) | |
83 (define-key map "\C-c}" 'm2-end-comment) | |
84 (define-key map "\C-j" 'm2-newline) | |
85 (define-key map "\C-c\C-z" 'suspend-emacs) | |
86 (define-key map "\C-c\C-v" 'm2-visit) | |
87 (define-key map "\C-c\C-t" 'm2-toggle) | |
88 (define-key map "\C-c\C-l" 'm2-link) | |
89 (define-key map "\C-c\C-c" 'm2-compile) | |
90 (setq m2-mode-map map))) | |
91 | |
92 (defvar m2-indent 5 "*This variable gives the indentation in Modula-2-Mode") | |
93 | |
258 | 94 ;;;###autoload |
22 | 95 (defun modula-2-mode () |
231 | 96 "This is a mode intended to support program development in Modula-2. |
97 All control constructs of Modula-2 can be reached by typing C-c | |
98 followed by the first character of the construct. | |
99 \\<m2-mode-map> | |
100 \\[m2-begin] begin \\[m2-case] case | |
101 \\[m2-definition] definition \\[m2-else] else | |
102 \\[m2-for] for \\[m2-header] header | |
103 \\[m2-if] if \\[m2-module] module | |
104 \\[m2-loop] loop \\[m2-or] or | |
105 \\[m2-procedure] procedure Control-c Control-w with | |
106 \\[m2-record] record \\[m2-stdio] stdio | |
107 \\[m2-type] type \\[m2-until] until | |
108 \\[m2-var] var \\[m2-while] while | |
109 \\[m2-export] export \\[m2-import] import | |
110 \\[m2-begin-comment] begin-comment \\[m2-end-comment] end-comment | |
111 \\[suspend-emacs] suspend Emacs \\[m2-toggle] toggle | |
112 \\[m2-compile] compile \\[m2-next-error] next-error | |
113 \\[m2-link] link | |
22 | 114 |
231 | 115 `m2-indent' controls the number of spaces for each indentation. |
116 `m2-compile-command' holds the command to compile a Modula-2 program. | |
117 `m2-link-command' holds the command to link a Modula-2 program." | |
22 | 118 (interactive) |
119 (kill-all-local-variables) | |
120 (use-local-map m2-mode-map) | |
121 (setq major-mode 'modula-2-mode) | |
122 (setq mode-name "Modula-2") | |
123 (make-local-variable 'comment-column) | |
124 (setq comment-column 41) | |
17532
5c77f95c5dd1
(m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17496
diff
changeset
|
125 (make-local-variable 'm2-end-comment-column) |
5c77f95c5dd1
(m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17496
diff
changeset
|
126 (setq m2-end-comment-column 75) |
22 | 127 (set-syntax-table m2-mode-syntax-table) |
128 (make-local-variable 'paragraph-start) | |
10885
13ce3a71c223
(modula-2-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents:
2308
diff
changeset
|
129 (setq paragraph-start (concat "$\\|" page-delimiter)) |
22 | 130 (make-local-variable 'paragraph-separate) |
131 (setq paragraph-separate paragraph-start) | |
132 (make-local-variable 'paragraph-ignore-fill-prefix) | |
133 (setq paragraph-ignore-fill-prefix t) | |
134 ; (make-local-variable 'indent-line-function) | |
135 ; (setq indent-line-function 'c-indent-line) | |
136 (make-local-variable 'require-final-newline) | |
137 (setq require-final-newline t) | |
138 (make-local-variable 'comment-start) | |
139 (setq comment-start "(* ") | |
140 (make-local-variable 'comment-end) | |
141 (setq comment-end " *)") | |
142 (make-local-variable 'comment-column) | |
143 (setq comment-column 41) | |
144 (make-local-variable 'comment-start-skip) | |
145 (setq comment-start-skip "/\\*+ *") | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
146 (make-local-variable 'comment-indent-function) |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
147 (setq comment-indent-function 'c-comment-indent) |
22 | 148 (make-local-variable 'parse-sexp-ignore-comments) |
149 (setq parse-sexp-ignore-comments t) | |
17496 | 150 (make-local-variable 'font-lock-defaults) |
151 (setq font-lock-defaults | |
152 '((m3-font-lock-keywords | |
153 m3-font-lock-keywords-1 m3-font-lock-keywords-2) | |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
154 nil nil ((?_ . "w") (?. . "w") (?< . ". 1") (?> . ". 4")) nil |
17496 | 155 ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP. |
156 ;(font-lock-comment-start-regexp . "(\\*") | |
157 )) | |
22 | 158 (run-hooks 'm2-mode-hook)) |
17496 | 159 |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
160 ;; Regexps written with help from Ron Forrester <ron@orcad.com> |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
161 ;; and Spencer Allain <sallain@teknowledge.com>. |
17496 | 162 (defconst m3-font-lock-keywords-1 |
163 '( | |
164 ;; | |
165 ;; Module definitions. | |
166 ("\\<\\(INTERFACE\\|MODULE\\|PROCEDURE\\)\\>[ \t]*\\(\\sw+\\)?" | |
167 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) | |
168 ;; | |
169 ;; Import directives. | |
170 ("\\<\\(EXPORTS\\|FROM\\|IMPORT\\)\\>" | |
171 (1 font-lock-keyword-face) | |
172 (font-lock-match-c-style-declaration-item-and-skip-to-next | |
173 nil (goto-char (match-end 0)) | |
174 (1 font-lock-reference-face))) | |
175 ;; | |
176 ;; Pragmas as warnings. | |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
177 ;; Spencer Allain <sallain@teknowledge.com> says do them as comments... |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
178 ;; ("<\\*.*\\*>" . font-lock-warning-face) |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
179 ;; ... but instead we fontify the first word. |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
180 ("<\\*[ \t]*\\(\\sw+\\)" 1 font-lock-warning-face prepend) |
17496 | 181 ) |
182 "Subdued level highlighting for Modula-3 modes.") | |
183 | |
184 (defconst m3-font-lock-keywords-2 | |
185 (append m3-font-lock-keywords-1 | |
186 (eval-when-compile | |
187 (let ((m3-types | |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
188 (regexp-opt |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
189 '("INTEGER" "BITS" "BOOLEAN" "CARDINAL" "CHAR" "FLOAT" "REAL" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
190 "LONGREAL" "REFANY" "ADDRESS" "ARRAY" "SET" "TEXT" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
191 "MUTEX" "ROOT" "EXTENDED"))) |
17496 | 192 (m3-keywords |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
193 (regexp-opt |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
194 '("AND" "ANY" "AS" "BEGIN" "BRANDED" "BY" "CASE" "CONST" "DIV" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
195 "DO" "ELSE" "ELSIF" "EVAL" "EXCEPT" "EXIT" "FINALLY" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
196 "FOR" "GENERIC" "IF" "IN" "LOCK" "LOOP" "METHODS" "MOD" "NOT" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
197 "OBJECT" "OF" "OR" "OVERRIDES" "READONLY" "RECORD" "REF" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
198 "REPEAT" "RETURN" "REVEAL" "THEN" "TO" "TRY" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
199 "TYPE" "TYPECASE" "UNSAFE" "UNTIL" "UNTRACED" "VAR" "VALUE" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
200 "WHILE" "WITH"))) |
17496 | 201 (m3-builtins |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
202 (regexp-opt |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
203 '("ABS" "ADR" "ADRSIZE" "BITSIZE" "BYTESIZE" "CEILING" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
204 "DEC" "DISPOSE" "FIRST" "FLOOR" "INC" "ISTYPE" "LAST" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
205 "LOOPHOLE" "MAX" "MIN" "NARROW" "NEW" "NUMBER" "ORD" |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
206 "ROUND" "SUBARRAY" "TRUNC" "TYPECODE" "VAL"))) |
17496 | 207 ) |
208 (list | |
209 ;; | |
210 ;; Keywords except those fontified elsewhere. | |
211 (concat "\\<\\(" m3-keywords "\\)\\>") | |
212 ;; | |
213 ;; Builtins. | |
214 (cons (concat "\\<\\(" m3-builtins "\\)\\>") 'font-lock-builtin-face) | |
215 ;; | |
216 ;; Type names. | |
217 (cons (concat "\\<\\(" m3-types "\\)\\>") 'font-lock-type-face) | |
218 ;; | |
219 ;; Fontify tokens as function names. | |
220 '("\\<\\(END\\|EXCEPTION\\|RAISES?\\)\\>[ \t{]*" | |
221 (1 font-lock-keyword-face) | |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
222 (font-lock-match-c-style-declaration-item-and-skip-to-next |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
223 nil (goto-char (match-end 0)) |
17496 | 224 (1 font-lock-function-name-face))) |
225 ;; | |
226 ;; Fontify constants as references. | |
227 '("\\<\\(FALSE\\|NIL\\|NULL\\|TRUE\\)\\>" . font-lock-reference-face) | |
228 )))) | |
229 "Gaudy level highlighting for Modula-3 modes.") | |
230 | |
231 (defvar m3-font-lock-keywords m3-font-lock-keywords-1 | |
232 "Default expressions to highlight in Modula-3 modes.") | |
233 | |
234 ;; We don't actually have different keywords for Modula-2. Volunteers? | |
235 (defconst m2-font-lock-keywords-1 m3-font-lock-keywords-1 | |
236 "Subdued level highlighting for Modula-2 modes.") | |
237 | |
238 (defconst m2-font-lock-keywords-2 m3-font-lock-keywords-2 | |
239 "Gaudy level highlighting for Modula-2 modes.") | |
240 | |
241 (defvar m2-font-lock-keywords m2-font-lock-keywords-1 | |
242 "Default expressions to highlight in Modula-2 modes.") | |
243 | |
22 | 244 (defun m2-newline () |
245 "Insert a newline and indent following line like previous line." | |
246 (interactive) | |
247 (let ((hpos (current-indentation))) | |
248 (newline) | |
249 (indent-to hpos))) | |
250 | |
251 (defun m2-tab () | |
252 "Indent to next tab stop." | |
253 (interactive) | |
254 (indent-to (* (1+ (/ (current-indentation) m2-indent)) m2-indent))) | |
255 | |
256 (defun m2-begin () | |
257 "Insert a BEGIN keyword and indent for the next line." | |
258 (interactive) | |
259 (insert "BEGIN") | |
260 (m2-newline) | |
261 (m2-tab)) | |
262 | |
263 (defun m2-case () | |
13997
a56ed7721b43
(m2-case, m2-for, m2-if): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
12953
diff
changeset
|
264 "Build skeleton CASE statement, prompting for the <expression>." |
22 | 265 (interactive) |
266 (let ((name (read-string "Case-Expression: "))) | |
267 (insert "CASE " name " OF") | |
268 (m2-newline) | |
269 (m2-newline) | |
270 (insert "END (* case " name " *);")) | |
271 (end-of-line 0) | |
272 (m2-tab)) | |
273 | |
274 (defun m2-definition () | |
275 "Build skeleton DEFINITION MODULE, prompting for the <module name>." | |
276 (interactive) | |
277 (insert "DEFINITION MODULE ") | |
278 (let ((name (read-string "Name: "))) | |
279 (insert name ";\n\n\n\nEND " name ".\n")) | |
280 (previous-line 3)) | |
281 | |
282 (defun m2-else () | |
283 "Insert ELSE keyword and indent for next line." | |
284 (interactive) | |
285 (m2-newline) | |
286 (backward-delete-char-untabify m2-indent ()) | |
287 (insert "ELSE") | |
288 (m2-newline) | |
289 (m2-tab)) | |
290 | |
291 (defun m2-for () | |
13997
a56ed7721b43
(m2-case, m2-for, m2-if): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
12953
diff
changeset
|
292 "Build skeleton FOR loop statement, prompting for the loop parameters." |
22 | 293 (interactive) |
294 (insert "FOR ") | |
295 (let ((name (read-string "Loop Initialiser: ")) limit by) | |
296 (insert name " TO ") | |
297 (setq limit (read-string "Limit: ")) | |
298 (insert limit) | |
299 (setq by (read-string "Step: ")) | |
300 (if (not (string-equal by "")) | |
301 (insert " BY " by)) | |
302 (insert " DO") | |
303 (m2-newline) | |
304 (m2-newline) | |
305 (insert "END (* for " name " to " limit " *);")) | |
306 (end-of-line 0) | |
307 (m2-tab)) | |
308 | |
309 (defun m2-header () | |
310 "Insert a comment block containing the module title, author, etc." | |
311 (interactive) | |
312 (insert "(*\n Title: \t") | |
313 (insert (read-string "Title: ")) | |
314 (insert "\n Created:\t") | |
315 (insert (current-time-string)) | |
316 (insert "\n Author: \t") | |
317 (insert (user-full-name)) | |
318 (insert (concat "\n\t\t<" (user-login-name) "@" (system-name) ">\n")) | |
319 (insert "*)\n\n")) | |
320 | |
321 (defun m2-if () | |
13997
a56ed7721b43
(m2-case, m2-for, m2-if): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
12953
diff
changeset
|
322 "Insert skeleton IF statement, prompting for <boolean-expression>." |
22 | 323 (interactive) |
324 (insert "IF ") | |
325 (let ((thecondition (read-string "<boolean-expression>: "))) | |
326 (insert thecondition " THEN") | |
327 (m2-newline) | |
328 (m2-newline) | |
329 (insert "END (* if " thecondition " *);")) | |
330 (end-of-line 0) | |
331 (m2-tab)) | |
332 | |
333 (defun m2-loop () | |
334 "Build skeleton LOOP (with END)." | |
335 (interactive) | |
336 (insert "LOOP") | |
337 (m2-newline) | |
338 (m2-newline) | |
339 (insert "END (* loop *);") | |
340 (end-of-line 0) | |
341 (m2-tab)) | |
342 | |
343 (defun m2-module () | |
344 "Build skeleton IMPLEMENTATION MODULE, prompting for <module-name>." | |
345 (interactive) | |
346 (insert "IMPLEMENTATION MODULE ") | |
347 (let ((name (read-string "Name: "))) | |
348 (insert name ";\n\n\n\nEND " name ".\n") | |
349 (previous-line 3) | |
350 (m2-header) | |
351 (m2-type) | |
352 (newline) | |
353 (m2-var) | |
354 (newline) | |
355 (m2-begin) | |
356 (m2-begin-comment) | |
357 (insert " Module " name " Initialisation Code ")) | |
358 (m2-end-comment) | |
359 (newline) | |
360 (m2-tab)) | |
361 | |
362 (defun m2-or () | |
363 (interactive) | |
364 (m2-newline) | |
365 (backward-delete-char-untabify m2-indent) | |
366 (insert "|") | |
367 (m2-newline) | |
368 (m2-tab)) | |
369 | |
370 (defun m2-procedure () | |
371 (interactive) | |
372 (insert "PROCEDURE ") | |
373 (let ((name (read-string "Name: " )) | |
374 args) | |
375 (insert name " (") | |
376 (insert (read-string "Arguments: ") ")") | |
377 (setq args (read-string "Result Type: ")) | |
378 (if (not (string-equal args "")) | |
379 (insert " : " args)) | |
380 (insert ";") | |
381 (m2-newline) | |
382 (insert "BEGIN") | |
383 (m2-newline) | |
384 (m2-newline) | |
385 (insert "END ") | |
386 (insert name) | |
387 (insert ";") | |
388 (end-of-line 0) | |
389 (m2-tab))) | |
390 | |
391 (defun m2-with () | |
392 (interactive) | |
393 (insert "WITH ") | |
394 (let ((name (read-string "Record-Type: "))) | |
395 (insert name) | |
396 (insert " DO") | |
397 (m2-newline) | |
398 (m2-newline) | |
399 (insert "END (* with " name " *);")) | |
400 (end-of-line 0) | |
401 (m2-tab)) | |
402 | |
403 (defun m2-record () | |
404 (interactive) | |
405 (insert "RECORD") | |
406 (m2-newline) | |
407 (m2-newline) | |
408 (insert "END (* record *);") | |
409 (end-of-line 0) | |
410 (m2-tab)) | |
411 | |
412 (defun m2-stdio () | |
413 (interactive) | |
414 (insert " | |
231 | 415 FROM TextIO IMPORT |
22 | 416 WriteCHAR, ReadCHAR, WriteINTEGER, ReadINTEGER, |
417 WriteCARDINAL, ReadCARDINAL, WriteBOOLEAN, ReadBOOLEAN, | |
418 WriteREAL, ReadREAL, WriteBITSET, ReadBITSET, | |
419 WriteBasedCARDINAL, ReadBasedCARDINAL, WriteChars, ReadChars, | |
420 WriteString, ReadString, WhiteSpace, EndOfLine; | |
421 | |
231 | 422 FROM SysStreams IMPORT sysIn, sysOut, sysErr; |
22 | 423 |
424 ")) | |
425 | |
426 (defun m2-type () | |
427 (interactive) | |
428 (insert "TYPE") | |
429 (m2-newline) | |
430 (m2-tab)) | |
431 | |
432 (defun m2-until () | |
433 (interactive) | |
434 (insert "REPEAT") | |
435 (m2-newline) | |
436 (m2-newline) | |
437 (insert "UNTIL ") | |
438 (insert (read-string "<boolean-expression>: ") ";") | |
439 (end-of-line 0) | |
440 (m2-tab)) | |
441 | |
442 (defun m2-var () | |
443 (interactive) | |
444 (m2-newline) | |
445 (insert "VAR") | |
446 (m2-newline) | |
447 (m2-tab)) | |
448 | |
449 (defun m2-while () | |
450 (interactive) | |
451 (insert "WHILE ") | |
452 (let ((name (read-string "<boolean-expression>: "))) | |
453 (insert name " DO" ) | |
454 (m2-newline) | |
455 (m2-newline) | |
456 (insert "END (* while " name " *);")) | |
457 (end-of-line 0) | |
458 (m2-tab)) | |
459 | |
460 (defun m2-export () | |
461 (interactive) | |
462 (insert "EXPORT QUALIFIED ")) | |
463 | |
464 (defun m2-import () | |
465 (interactive) | |
466 (insert "FROM ") | |
467 (insert (read-string "Module: ")) | |
468 (insert " IMPORT ")) | |
469 | |
470 (defun m2-begin-comment () | |
471 (interactive) | |
472 (if (not (bolp)) | |
473 (indent-to comment-column 0)) | |
474 (insert "(* ")) | |
475 | |
476 (defun m2-end-comment () | |
477 (interactive) | |
478 (if (not (bolp)) | |
17532
5c77f95c5dd1
(m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17496
diff
changeset
|
479 (indent-to m2-end-comment-column)) |
22 | 480 (insert "*)")) |
481 | |
482 (defun m2-compile () | |
483 (interactive) | |
17532
5c77f95c5dd1
(m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17496
diff
changeset
|
484 (compile (concat m2-compile-command " " (buffer-name)))) |
22 | 485 |
486 (defun m2-link () | |
487 (interactive) | |
488 (if m2-link-name | |
489 (compile (concat m2-link-command " " m2-link-name)) | |
490 (compile (concat m2-link-command " " | |
491 (setq m2-link-name (read-string "Name of executable: " | |
17532
5c77f95c5dd1
(m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17496
diff
changeset
|
492 (buffer-name))))))) |
22 | 493 |
12953
e0db27f18a43
(m2-execute-monitor-command): Renamed from execute-monitor-command.
Richard M. Stallman <rms@gnu.org>
parents:
10885
diff
changeset
|
494 (defun m2-execute-monitor-command (command) |
22 | 495 (let* ((shell shell-file-name) |
496 (csh (equal (file-name-nondirectory shell) "csh"))) | |
497 (call-process shell nil t t "-cf" (concat "exec " command)))) | |
498 | |
499 (defun m2-visit () | |
500 (interactive) | |
501 (let ((deffile nil) | |
502 (modfile nil) | |
503 modulename) | |
504 (save-excursion | |
505 (setq modulename | |
506 (read-string "Module name: ")) | |
507 (switch-to-buffer "*Command Execution*") | |
12953
e0db27f18a43
(m2-execute-monitor-command): Renamed from execute-monitor-command.
Richard M. Stallman <rms@gnu.org>
parents:
10885
diff
changeset
|
508 (m2-execute-monitor-command (concat "m2whereis " modulename)) |
22 | 509 (goto-char (point-min)) |
510 (condition-case () | |
511 (progn (re-search-forward "\\(.*\\.def\\) *$") | |
512 (setq deffile (buffer-substring (match-beginning 1) | |
513 (match-end 1)))) | |
514 (search-failed ())) | |
515 (condition-case () | |
516 (progn (re-search-forward "\\(.*\\.mod\\) *$") | |
517 (setq modfile (buffer-substring (match-beginning 1) | |
518 (match-end 1)))) | |
519 (search-failed ())) | |
520 (if (not (or deffile modfile)) | |
521 (error "I can find neither definition nor implementation of %s" | |
522 modulename))) | |
523 (cond (deffile | |
524 (find-file deffile) | |
525 (if modfile | |
526 (save-excursion | |
527 (find-file modfile)))) | |
528 (modfile | |
529 (find-file modfile))))) | |
530 | |
531 (defun m2-toggle () | |
532 "Toggle between .mod and .def files for the module." | |
533 (interactive) | |
534 (cond ((string-equal (substring (buffer-name) -4) ".def") | |
535 (find-file-other-window | |
536 (concat (substring (buffer-name) 0 -4) ".mod"))) | |
537 ((string-equal (substring (buffer-name) -4) ".mod") | |
538 (find-file-other-window | |
539 (concat (substring (buffer-name) 0 -4) ".def"))) | |
540 ((string-equal (substring (buffer-name) -3) ".mi") | |
541 (find-file-other-window | |
542 (concat (substring (buffer-name) 0 -3) ".md"))) | |
543 ((string-equal (substring (buffer-name) -3) ".md") | |
544 (find-file-other-window | |
545 (concat (substring (buffer-name) 0 -3) ".mi"))))) | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
546 |
18383 | 547 (provide 'modula2) |
548 | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
549 ;;; modula2.el ends here |