Mercurial > emacs
annotate lisp/progmodes/modula2.el @ 111061:f1c96313c1a4
Fix format of old lib-src/ChangeLog entry.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 19 Oct 2010 20:53:34 -0700 |
parents | cc035ccb9275 |
children | d9d916379aff |
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 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38412
diff
changeset
|
3 ;; Author: Michael Schmidt <michael@pbinfo.UUCP> |
791
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 |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
20960
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
20960
diff
changeset
|
9 |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
10 ;; The authors distributed this without a copyright notice |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
11 ;; 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
|
12 ;; the following credit: |
22 | 13 |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
14 ;; Author Mick Jordan |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
15 ;; amended Peter Robinson |
22 | 16 |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
17 ;;; Commentary: |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
18 |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
19 ;; 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
|
20 ;; 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
|
21 ;; a native compile command. |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
22 |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
23 ;;; Code: |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
24 |
20960 | 25 (defgroup modula2 nil |
26 "Major mode for editing Modula-2 code." | |
66963
a11fdee52c05
Add :link (custom-group-link font-lock-faces) to defgroup.
Juri Linkov <juri@jurta.org>
parents:
63522
diff
changeset
|
27 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) |
20960 | 28 :prefix "m2-" |
29 :group 'languages) | |
30 | |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
663
diff
changeset
|
31 ;;; Added by Tom Perrine (TEP) |
22 | 32 (defvar m2-mode-syntax-table nil |
231 | 33 "Syntax table in use in Modula-2 buffers.") |
22 | 34 |
20960 | 35 (defcustom m2-compile-command "m2c" |
36 "Command to compile Modula-2 programs." | |
37 :type 'string | |
38 :group 'modula2) | |
22 | 39 |
20960 | 40 (defcustom m2-link-command "m2l" |
41 "Command to link Modula-2 programs." | |
42 :type 'string | |
43 :group 'modula2) | |
22 | 44 |
20960 | 45 (defcustom m2-link-name nil |
46 "Name of the Modula-2 executable." | |
47 :type '(choice (const nil) string) | |
48 :group 'modula2) | |
22 | 49 |
20960 | 50 (defcustom m2-end-comment-column 75 |
51 "*Column for aligning the end of a comment, in Modula-2." | |
52 :type 'integer | |
53 :group 'modula2) | |
22 | 54 |
55 (if m2-mode-syntax-table | |
56 () | |
57 (let ((table (make-syntax-table))) | |
58 (modify-syntax-entry ?\\ "\\" table) | |
59 (modify-syntax-entry ?\( ". 1" table) | |
60 (modify-syntax-entry ?\) ". 4" table) | |
61 (modify-syntax-entry ?* ". 23" table) | |
62 (modify-syntax-entry ?+ "." table) | |
63 (modify-syntax-entry ?- "." table) | |
64 (modify-syntax-entry ?= "." table) | |
65 (modify-syntax-entry ?% "." table) | |
66 (modify-syntax-entry ?< "." table) | |
67 (modify-syntax-entry ?> "." table) | |
68 (modify-syntax-entry ?\' "\"" table) | |
69 (setq m2-mode-syntax-table table))) | |
70 | |
71 ;;; Added by TEP | |
110909
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93975
diff
changeset
|
72 (defvar m2-mode-map |
22 | 73 (let ((map (make-sparse-keymap))) |
74 (define-key map "\^i" 'm2-tab) | |
75 (define-key map "\C-cb" 'm2-begin) | |
76 (define-key map "\C-cc" 'm2-case) | |
77 (define-key map "\C-cd" 'm2-definition) | |
78 (define-key map "\C-ce" 'm2-else) | |
79 (define-key map "\C-cf" 'm2-for) | |
80 (define-key map "\C-ch" 'm2-header) | |
81 (define-key map "\C-ci" 'm2-if) | |
82 (define-key map "\C-cm" 'm2-module) | |
83 (define-key map "\C-cl" 'm2-loop) | |
84 (define-key map "\C-co" 'm2-or) | |
85 (define-key map "\C-cp" 'm2-procedure) | |
86 (define-key map "\C-c\C-w" 'm2-with) | |
87 (define-key map "\C-cr" 'm2-record) | |
88 (define-key map "\C-cs" 'm2-stdio) | |
89 (define-key map "\C-ct" 'm2-type) | |
90 (define-key map "\C-cu" 'm2-until) | |
91 (define-key map "\C-cv" 'm2-var) | |
92 (define-key map "\C-cw" 'm2-while) | |
93 (define-key map "\C-cx" 'm2-export) | |
94 (define-key map "\C-cy" 'm2-import) | |
95 (define-key map "\C-c{" 'm2-begin-comment) | |
96 (define-key map "\C-c}" 'm2-end-comment) | |
97 (define-key map "\C-j" 'm2-newline) | |
98 (define-key map "\C-c\C-z" 'suspend-emacs) | |
99 (define-key map "\C-c\C-v" 'm2-visit) | |
100 (define-key map "\C-c\C-t" 'm2-toggle) | |
101 (define-key map "\C-c\C-l" 'm2-link) | |
102 (define-key map "\C-c\C-c" 'm2-compile) | |
110909
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93975
diff
changeset
|
103 map) |
cc035ccb9275
Declare and define in one step various mode maps.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93975
diff
changeset
|
104 "Keymap used in Modula-2 mode.") |
22 | 105 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38412
diff
changeset
|
106 (defcustom m2-indent 5 |
20960 | 107 "*This variable gives the indentation in Modula-2-Mode." |
108 :type 'integer | |
109 :group 'modula2) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38412
diff
changeset
|
110 |
258 | 111 ;;;###autoload |
22 | 112 (defun modula-2-mode () |
231 | 113 "This is a mode intended to support program development in Modula-2. |
114 All control constructs of Modula-2 can be reached by typing C-c | |
115 followed by the first character of the construct. | |
116 \\<m2-mode-map> | |
117 \\[m2-begin] begin \\[m2-case] case | |
118 \\[m2-definition] definition \\[m2-else] else | |
119 \\[m2-for] for \\[m2-header] header | |
120 \\[m2-if] if \\[m2-module] module | |
121 \\[m2-loop] loop \\[m2-or] or | |
122 \\[m2-procedure] procedure Control-c Control-w with | |
123 \\[m2-record] record \\[m2-stdio] stdio | |
124 \\[m2-type] type \\[m2-until] until | |
125 \\[m2-var] var \\[m2-while] while | |
126 \\[m2-export] export \\[m2-import] import | |
127 \\[m2-begin-comment] begin-comment \\[m2-end-comment] end-comment | |
128 \\[suspend-emacs] suspend Emacs \\[m2-toggle] toggle | |
129 \\[m2-compile] compile \\[m2-next-error] next-error | |
130 \\[m2-link] link | |
22 | 131 |
231 | 132 `m2-indent' controls the number of spaces for each indentation. |
133 `m2-compile-command' holds the command to compile a Modula-2 program. | |
134 `m2-link-command' holds the command to link a Modula-2 program." | |
22 | 135 (interactive) |
136 (kill-all-local-variables) | |
137 (use-local-map m2-mode-map) | |
138 (setq major-mode 'modula-2-mode) | |
139 (setq mode-name "Modula-2") | |
140 (make-local-variable 'comment-column) | |
141 (setq comment-column 41) | |
17532
5c77f95c5dd1
(m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17496
diff
changeset
|
142 (make-local-variable 'm2-end-comment-column) |
22 | 143 (set-syntax-table m2-mode-syntax-table) |
144 (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
|
145 (setq paragraph-start (concat "$\\|" page-delimiter)) |
22 | 146 (make-local-variable 'paragraph-separate) |
147 (setq paragraph-separate paragraph-start) | |
148 (make-local-variable 'paragraph-ignore-fill-prefix) | |
149 (setq paragraph-ignore-fill-prefix t) | |
150 ; (make-local-variable 'indent-line-function) | |
151 ; (setq indent-line-function 'c-indent-line) | |
152 (make-local-variable 'require-final-newline) | |
59248
376983f62602
(modula-2-mode): Use mode-require-final-newline.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
153 (setq require-final-newline mode-require-final-newline) |
22 | 154 (make-local-variable 'comment-start) |
155 (setq comment-start "(* ") | |
156 (make-local-variable 'comment-end) | |
157 (setq comment-end " *)") | |
158 (make-local-variable 'comment-column) | |
159 (setq comment-column 41) | |
160 (make-local-variable 'comment-start-skip) | |
161 (setq comment-start-skip "/\\*+ *") | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
162 (make-local-variable 'comment-indent-function) |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
163 (setq comment-indent-function 'c-comment-indent) |
22 | 164 (make-local-variable 'parse-sexp-ignore-comments) |
165 (setq parse-sexp-ignore-comments t) | |
17496 | 166 (make-local-variable 'font-lock-defaults) |
167 (setq font-lock-defaults | |
168 '((m3-font-lock-keywords | |
169 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
|
170 nil nil ((?_ . "w") (?. . "w") (?< . ". 1") (?> . ". 4")) nil |
17496 | 171 ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP. |
172 ;(font-lock-comment-start-regexp . "(\\*") | |
173 )) | |
62772
f2892faa87d4
* progmodes/ada-mode.el (ada-mode):
Lute Kamstra <lute@gnu.org>
parents:
59248
diff
changeset
|
174 (run-mode-hooks 'm2-mode-hook)) |
17496 | 175 |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
176 ;; 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
|
177 ;; and Spencer Allain <sallain@teknowledge.com>. |
17496 | 178 (defconst m3-font-lock-keywords-1 |
179 '( | |
180 ;; | |
181 ;; Module definitions. | |
182 ("\\<\\(INTERFACE\\|MODULE\\|PROCEDURE\\)\\>[ \t]*\\(\\sw+\\)?" | |
183 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) | |
184 ;; | |
185 ;; Import directives. | |
186 ("\\<\\(EXPORTS\\|FROM\\|IMPORT\\)\\>" | |
187 (1 font-lock-keyword-face) | |
188 (font-lock-match-c-style-declaration-item-and-skip-to-next | |
189 nil (goto-char (match-end 0)) | |
20953
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
18383
diff
changeset
|
190 (1 font-lock-constant-face))) |
17496 | 191 ;; |
192 ;; Pragmas as warnings. | |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
193 ;; 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
|
194 ;; ("<\\*.*\\*>" . font-lock-warning-face) |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
195 ;; ... 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
|
196 ("<\\*[ \t]*\\(\\sw+\\)" 1 font-lock-warning-face prepend) |
17496 | 197 ) |
198 "Subdued level highlighting for Modula-3 modes.") | |
199 | |
200 (defconst m3-font-lock-keywords-2 | |
201 (append m3-font-lock-keywords-1 | |
202 (eval-when-compile | |
203 (let ((m3-types | |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
204 (regexp-opt |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
205 '("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
|
206 "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
|
207 "MUTEX" "ROOT" "EXTENDED"))) |
17496 | 208 (m3-keywords |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
209 (regexp-opt |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
210 '("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
|
211 "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
|
212 "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
|
213 "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
|
214 "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
|
215 "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
|
216 "WHILE" "WITH"))) |
17496 | 217 (m3-builtins |
18333
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
218 (regexp-opt |
ff12edf576bf
Do <* *> via syntax table not regexps; use regexp-opt.
Simon Marshall <simon@gnu.org>
parents:
17996
diff
changeset
|
219 '("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
|
220 "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
|
221 "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
|
222 "ROUND" "SUBARRAY" "TRUNC" "TYPECODE" "VAL"))) |
17496 | 223 ) |
224 (list | |
225 ;; | |
226 ;; Keywords except those fontified elsewhere. | |
227 (concat "\\<\\(" m3-keywords "\\)\\>") | |
228 ;; | |
229 ;; Builtins. | |
230 (cons (concat "\\<\\(" m3-builtins "\\)\\>") 'font-lock-builtin-face) | |
231 ;; | |
232 ;; Type names. | |
233 (cons (concat "\\<\\(" m3-types "\\)\\>") 'font-lock-type-face) | |
234 ;; | |
235 ;; Fontify tokens as function names. | |
236 '("\\<\\(END\\|EXCEPTION\\|RAISES?\\)\\>[ \t{]*" | |
237 (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
|
238 (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
|
239 nil (goto-char (match-end 0)) |
17496 | 240 (1 font-lock-function-name-face))) |
241 ;; | |
242 ;; Fontify constants as references. | |
20953
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
18383
diff
changeset
|
243 '("\\<\\(FALSE\\|NIL\\|NULL\\|TRUE\\)\\>" . font-lock-constant-face) |
17496 | 244 )))) |
245 "Gaudy level highlighting for Modula-3 modes.") | |
246 | |
247 (defvar m3-font-lock-keywords m3-font-lock-keywords-1 | |
248 "Default expressions to highlight in Modula-3 modes.") | |
249 | |
250 ;; We don't actually have different keywords for Modula-2. Volunteers? | |
251 (defconst m2-font-lock-keywords-1 m3-font-lock-keywords-1 | |
252 "Subdued level highlighting for Modula-2 modes.") | |
253 | |
254 (defconst m2-font-lock-keywords-2 m3-font-lock-keywords-2 | |
255 "Gaudy level highlighting for Modula-2 modes.") | |
256 | |
257 (defvar m2-font-lock-keywords m2-font-lock-keywords-1 | |
258 "Default expressions to highlight in Modula-2 modes.") | |
259 | |
22 | 260 (defun m2-newline () |
261 "Insert a newline and indent following line like previous line." | |
262 (interactive) | |
263 (let ((hpos (current-indentation))) | |
264 (newline) | |
265 (indent-to hpos))) | |
266 | |
267 (defun m2-tab () | |
268 "Indent to next tab stop." | |
269 (interactive) | |
270 (indent-to (* (1+ (/ (current-indentation) m2-indent)) m2-indent))) | |
271 | |
272 (defun m2-begin () | |
273 "Insert a BEGIN keyword and indent for the next line." | |
274 (interactive) | |
275 (insert "BEGIN") | |
276 (m2-newline) | |
277 (m2-tab)) | |
278 | |
279 (defun m2-case () | |
13997
a56ed7721b43
(m2-case, m2-for, m2-if): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
12953
diff
changeset
|
280 "Build skeleton CASE statement, prompting for the <expression>." |
22 | 281 (interactive) |
282 (let ((name (read-string "Case-Expression: "))) | |
283 (insert "CASE " name " OF") | |
284 (m2-newline) | |
285 (m2-newline) | |
286 (insert "END (* case " name " *);")) | |
287 (end-of-line 0) | |
288 (m2-tab)) | |
289 | |
290 (defun m2-definition () | |
291 "Build skeleton DEFINITION MODULE, prompting for the <module name>." | |
292 (interactive) | |
293 (insert "DEFINITION MODULE ") | |
294 (let ((name (read-string "Name: "))) | |
295 (insert name ";\n\n\n\nEND " name ".\n")) | |
78683
96cf59afcbbc
(m2-definition, m2-module): Don't use previous-line.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
66963
diff
changeset
|
296 (forward-line -3)) |
22 | 297 |
298 (defun m2-else () | |
299 "Insert ELSE keyword and indent for next line." | |
300 (interactive) | |
301 (m2-newline) | |
302 (backward-delete-char-untabify m2-indent ()) | |
303 (insert "ELSE") | |
304 (m2-newline) | |
305 (m2-tab)) | |
306 | |
307 (defun m2-for () | |
13997
a56ed7721b43
(m2-case, m2-for, m2-if): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
12953
diff
changeset
|
308 "Build skeleton FOR loop statement, prompting for the loop parameters." |
22 | 309 (interactive) |
310 (insert "FOR ") | |
63522
96b14b14568b
(m2-for): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents:
62772
diff
changeset
|
311 (let ((name (read-string "Loop Initializer: ")) limit by) |
22 | 312 (insert name " TO ") |
313 (setq limit (read-string "Limit: ")) | |
314 (insert limit) | |
315 (setq by (read-string "Step: ")) | |
316 (if (not (string-equal by "")) | |
317 (insert " BY " by)) | |
318 (insert " DO") | |
319 (m2-newline) | |
320 (m2-newline) | |
321 (insert "END (* for " name " to " limit " *);")) | |
322 (end-of-line 0) | |
323 (m2-tab)) | |
324 | |
325 (defun m2-header () | |
326 "Insert a comment block containing the module title, author, etc." | |
327 (interactive) | |
328 (insert "(*\n Title: \t") | |
329 (insert (read-string "Title: ")) | |
330 (insert "\n Created:\t") | |
331 (insert (current-time-string)) | |
332 (insert "\n Author: \t") | |
333 (insert (user-full-name)) | |
334 (insert (concat "\n\t\t<" (user-login-name) "@" (system-name) ">\n")) | |
335 (insert "*)\n\n")) | |
336 | |
337 (defun m2-if () | |
13997
a56ed7721b43
(m2-case, m2-for, m2-if): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
12953
diff
changeset
|
338 "Insert skeleton IF statement, prompting for <boolean-expression>." |
22 | 339 (interactive) |
340 (insert "IF ") | |
341 (let ((thecondition (read-string "<boolean-expression>: "))) | |
342 (insert thecondition " THEN") | |
343 (m2-newline) | |
344 (m2-newline) | |
345 (insert "END (* if " thecondition " *);")) | |
346 (end-of-line 0) | |
347 (m2-tab)) | |
348 | |
349 (defun m2-loop () | |
350 "Build skeleton LOOP (with END)." | |
351 (interactive) | |
352 (insert "LOOP") | |
353 (m2-newline) | |
354 (m2-newline) | |
355 (insert "END (* loop *);") | |
356 (end-of-line 0) | |
357 (m2-tab)) | |
358 | |
359 (defun m2-module () | |
360 "Build skeleton IMPLEMENTATION MODULE, prompting for <module-name>." | |
361 (interactive) | |
362 (insert "IMPLEMENTATION MODULE ") | |
363 (let ((name (read-string "Name: "))) | |
364 (insert name ";\n\n\n\nEND " name ".\n") | |
78683
96cf59afcbbc
(m2-definition, m2-module): Don't use previous-line.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
66963
diff
changeset
|
365 (forward-line -3) |
22 | 366 (m2-header) |
367 (m2-type) | |
368 (newline) | |
369 (m2-var) | |
370 (newline) | |
371 (m2-begin) | |
372 (m2-begin-comment) | |
373 (insert " Module " name " Initialisation Code ")) | |
374 (m2-end-comment) | |
375 (newline) | |
376 (m2-tab)) | |
377 | |
378 (defun m2-or () | |
379 (interactive) | |
380 (m2-newline) | |
381 (backward-delete-char-untabify m2-indent) | |
382 (insert "|") | |
383 (m2-newline) | |
384 (m2-tab)) | |
385 | |
386 (defun m2-procedure () | |
387 (interactive) | |
388 (insert "PROCEDURE ") | |
389 (let ((name (read-string "Name: " )) | |
390 args) | |
391 (insert name " (") | |
392 (insert (read-string "Arguments: ") ")") | |
393 (setq args (read-string "Result Type: ")) | |
394 (if (not (string-equal args "")) | |
395 (insert " : " args)) | |
396 (insert ";") | |
397 (m2-newline) | |
398 (insert "BEGIN") | |
399 (m2-newline) | |
400 (m2-newline) | |
401 (insert "END ") | |
402 (insert name) | |
403 (insert ";") | |
404 (end-of-line 0) | |
405 (m2-tab))) | |
406 | |
407 (defun m2-with () | |
408 (interactive) | |
409 (insert "WITH ") | |
410 (let ((name (read-string "Record-Type: "))) | |
411 (insert name) | |
412 (insert " DO") | |
413 (m2-newline) | |
414 (m2-newline) | |
415 (insert "END (* with " name " *);")) | |
416 (end-of-line 0) | |
417 (m2-tab)) | |
418 | |
419 (defun m2-record () | |
420 (interactive) | |
421 (insert "RECORD") | |
422 (m2-newline) | |
423 (m2-newline) | |
424 (insert "END (* record *);") | |
425 (end-of-line 0) | |
426 (m2-tab)) | |
427 | |
428 (defun m2-stdio () | |
429 (interactive) | |
430 (insert " | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38412
diff
changeset
|
431 FROM TextIO IMPORT |
22 | 432 WriteCHAR, ReadCHAR, WriteINTEGER, ReadINTEGER, |
433 WriteCARDINAL, ReadCARDINAL, WriteBOOLEAN, ReadBOOLEAN, | |
434 WriteREAL, ReadREAL, WriteBITSET, ReadBITSET, | |
435 WriteBasedCARDINAL, ReadBasedCARDINAL, WriteChars, ReadChars, | |
436 WriteString, ReadString, WhiteSpace, EndOfLine; | |
437 | |
231 | 438 FROM SysStreams IMPORT sysIn, sysOut, sysErr; |
22 | 439 |
440 ")) | |
441 | |
442 (defun m2-type () | |
443 (interactive) | |
444 (insert "TYPE") | |
445 (m2-newline) | |
446 (m2-tab)) | |
447 | |
448 (defun m2-until () | |
449 (interactive) | |
450 (insert "REPEAT") | |
451 (m2-newline) | |
452 (m2-newline) | |
453 (insert "UNTIL ") | |
454 (insert (read-string "<boolean-expression>: ") ";") | |
455 (end-of-line 0) | |
456 (m2-tab)) | |
457 | |
458 (defun m2-var () | |
459 (interactive) | |
460 (m2-newline) | |
461 (insert "VAR") | |
462 (m2-newline) | |
463 (m2-tab)) | |
464 | |
465 (defun m2-while () | |
466 (interactive) | |
467 (insert "WHILE ") | |
468 (let ((name (read-string "<boolean-expression>: "))) | |
469 (insert name " DO" ) | |
470 (m2-newline) | |
471 (m2-newline) | |
472 (insert "END (* while " name " *);")) | |
473 (end-of-line 0) | |
474 (m2-tab)) | |
475 | |
476 (defun m2-export () | |
477 (interactive) | |
478 (insert "EXPORT QUALIFIED ")) | |
479 | |
480 (defun m2-import () | |
481 (interactive) | |
482 (insert "FROM ") | |
483 (insert (read-string "Module: ")) | |
484 (insert " IMPORT ")) | |
485 | |
486 (defun m2-begin-comment () | |
487 (interactive) | |
488 (if (not (bolp)) | |
489 (indent-to comment-column 0)) | |
490 (insert "(* ")) | |
491 | |
492 (defun m2-end-comment () | |
493 (interactive) | |
494 (if (not (bolp)) | |
17532
5c77f95c5dd1
(m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17496
diff
changeset
|
495 (indent-to m2-end-comment-column)) |
22 | 496 (insert "*)")) |
497 | |
498 (defun m2-compile () | |
499 (interactive) | |
17532
5c77f95c5dd1
(m2-end-comment-column): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
17496
diff
changeset
|
500 (compile (concat m2-compile-command " " (buffer-name)))) |
22 | 501 |
502 (defun m2-link () | |
503 (interactive) | |
504 (if m2-link-name | |
505 (compile (concat m2-link-command " " m2-link-name)) | |
506 (compile (concat m2-link-command " " | |
507 (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
|
508 (buffer-name))))))) |
22 | 509 |
12953
e0db27f18a43
(m2-execute-monitor-command): Renamed from execute-monitor-command.
Richard M. Stallman <rms@gnu.org>
parents:
10885
diff
changeset
|
510 (defun m2-execute-monitor-command (command) |
22 | 511 (let* ((shell shell-file-name) |
512 (csh (equal (file-name-nondirectory shell) "csh"))) | |
513 (call-process shell nil t t "-cf" (concat "exec " command)))) | |
514 | |
515 (defun m2-visit () | |
516 (interactive) | |
517 (let ((deffile nil) | |
518 (modfile nil) | |
519 modulename) | |
520 (save-excursion | |
521 (setq modulename | |
522 (read-string "Module name: ")) | |
523 (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
|
524 (m2-execute-monitor-command (concat "m2whereis " modulename)) |
22 | 525 (goto-char (point-min)) |
526 (condition-case () | |
527 (progn (re-search-forward "\\(.*\\.def\\) *$") | |
528 (setq deffile (buffer-substring (match-beginning 1) | |
529 (match-end 1)))) | |
530 (search-failed ())) | |
531 (condition-case () | |
532 (progn (re-search-forward "\\(.*\\.mod\\) *$") | |
533 (setq modfile (buffer-substring (match-beginning 1) | |
534 (match-end 1)))) | |
535 (search-failed ())) | |
536 (if (not (or deffile modfile)) | |
537 (error "I can find neither definition nor implementation of %s" | |
538 modulename))) | |
539 (cond (deffile | |
540 (find-file deffile) | |
541 (if modfile | |
542 (save-excursion | |
543 (find-file modfile)))) | |
544 (modfile | |
545 (find-file modfile))))) | |
546 | |
547 (defun m2-toggle () | |
548 "Toggle between .mod and .def files for the module." | |
549 (interactive) | |
550 (cond ((string-equal (substring (buffer-name) -4) ".def") | |
551 (find-file-other-window | |
552 (concat (substring (buffer-name) 0 -4) ".mod"))) | |
553 ((string-equal (substring (buffer-name) -4) ".mod") | |
554 (find-file-other-window | |
555 (concat (substring (buffer-name) 0 -4) ".def"))) | |
556 ((string-equal (substring (buffer-name) -3) ".mi") | |
557 (find-file-other-window | |
558 (concat (substring (buffer-name) 0 -3) ".md"))) | |
559 ((string-equal (substring (buffer-name) -3) ".md") | |
560 (find-file-other-window | |
561 (concat (substring (buffer-name) 0 -3) ".mi"))))) | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
562 |
18383 | 563 (provide 'modula2) |
564 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78683
diff
changeset
|
565 ;; arch-tag: a21df1cb-5ece-4709-9219-1e7cd2d85d90 |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
566 ;;; modula2.el ends here |