annotate lisp/progmodes/modula2.el @ 1156:2a92ddfaf6ba

entered into RCS
author Roland McGrath <roland@gnu.org>
date Thu, 17 Sep 1992 01:12:50 +0000
parents 2cdce064065f
children 10e417efb12a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 791
diff changeset
5 ;; Keywords: languages
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
6
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
7 ;; The authors distributed this without a copyright notice
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
8 ;; 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
9 ;; the following credit:
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
11 ;; Author Mick Jordan
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
12 ;; amended Peter Robinson
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
14 ;;; Code:
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
15
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 663
diff changeset
16 ;;; Added by Tom Perrine (TEP)
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 (defvar m2-mode-syntax-table nil
231
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
18 "Syntax table in use in Modula-2 buffers.")
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 (defvar m2-compile-command "m2c"
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 "Command to compile Modula-2 programs")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 (defvar m2-link-command "m2l"
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 "Command to link Modula-2 programs")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 (defvar m2-link-name nil
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 "Name of the executable.")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 (if m2-mode-syntax-table
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 (let ((table (make-syntax-table)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 (modify-syntax-entry ?\\ "\\" table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 (modify-syntax-entry ?\( ". 1" table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 (modify-syntax-entry ?\) ". 4" table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (modify-syntax-entry ?* ". 23" table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 (modify-syntax-entry ?+ "." table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 (modify-syntax-entry ?- "." table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (modify-syntax-entry ?= "." table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (modify-syntax-entry ?% "." table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 (modify-syntax-entry ?< "." table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 (modify-syntax-entry ?> "." table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (modify-syntax-entry ?\' "\"" table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (setq m2-mode-syntax-table table)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;;; Added by TEP
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (defvar m2-mode-map nil
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 "Keymap used in Modula-2 mode.")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (if m2-mode-map ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (let ((map (make-sparse-keymap)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 (define-key map "\^i" 'm2-tab)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (define-key map "\C-cb" 'm2-begin)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (define-key map "\C-cc" 'm2-case)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (define-key map "\C-cd" 'm2-definition)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (define-key map "\C-ce" 'm2-else)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (define-key map "\C-cf" 'm2-for)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (define-key map "\C-ch" 'm2-header)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (define-key map "\C-ci" 'm2-if)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (define-key map "\C-cm" 'm2-module)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (define-key map "\C-cl" 'm2-loop)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (define-key map "\C-co" 'm2-or)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (define-key map "\C-cp" 'm2-procedure)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (define-key map "\C-c\C-w" 'm2-with)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (define-key map "\C-cr" 'm2-record)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (define-key map "\C-cs" 'm2-stdio)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (define-key map "\C-ct" 'm2-type)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (define-key map "\C-cu" 'm2-until)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (define-key map "\C-cv" 'm2-var)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (define-key map "\C-cw" 'm2-while)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (define-key map "\C-cx" 'm2-export)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (define-key map "\C-cy" 'm2-import)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (define-key map "\C-c{" 'm2-begin-comment)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (define-key map "\C-c}" 'm2-end-comment)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (define-key map "\C-j" 'm2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (define-key map "\C-c\C-z" 'suspend-emacs)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (define-key map "\C-c\C-v" 'm2-visit)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (define-key map "\C-c\C-t" 'm2-toggle)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (define-key map "\C-c\C-l" 'm2-link)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (define-key map "\C-c\C-c" 'm2-compile)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (setq m2-mode-map map)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (defvar m2-indent 5 "*This variable gives the indentation in Modula-2-Mode")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
258
1e0bc00dca7a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 231
diff changeset
85 ;;;###autoload
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (defun modula-2-mode ()
231
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
87 "This is a mode intended to support program development in Modula-2.
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
88 All control constructs of Modula-2 can be reached by typing C-c
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
89 followed by the first character of the construct.
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
90 \\<m2-mode-map>
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
91 \\[m2-begin] begin \\[m2-case] case
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
92 \\[m2-definition] definition \\[m2-else] else
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
93 \\[m2-for] for \\[m2-header] header
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
94 \\[m2-if] if \\[m2-module] module
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
95 \\[m2-loop] loop \\[m2-or] or
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
96 \\[m2-procedure] procedure Control-c Control-w with
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
97 \\[m2-record] record \\[m2-stdio] stdio
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
98 \\[m2-type] type \\[m2-until] until
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
99 \\[m2-var] var \\[m2-while] while
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
100 \\[m2-export] export \\[m2-import] import
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
101 \\[m2-begin-comment] begin-comment \\[m2-end-comment] end-comment
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
102 \\[suspend-emacs] suspend Emacs \\[m2-toggle] toggle
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
103 \\[m2-compile] compile \\[m2-next-error] next-error
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
104 \\[m2-link] link
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
231
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
106 `m2-indent' controls the number of spaces for each indentation.
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
107 `m2-compile-command' holds the command to compile a Modula-2 program.
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
108 `m2-link-command' holds the command to link a Modula-2 program."
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (kill-all-local-variables)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (use-local-map m2-mode-map)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (setq major-mode 'modula-2-mode)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (setq mode-name "Modula-2")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (make-local-variable 'comment-column)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (setq comment-column 41)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (make-local-variable 'end-comment-column)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (setq end-comment-column 75)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (set-syntax-table m2-mode-syntax-table)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (make-local-variable 'paragraph-start)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (setq paragraph-start (concat "^$\\|" page-delimiter))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (make-local-variable 'paragraph-separate)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (setq paragraph-separate paragraph-start)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (make-local-variable 'paragraph-ignore-fill-prefix)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (setq paragraph-ignore-fill-prefix t)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ; (make-local-variable 'indent-line-function)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ; (setq indent-line-function 'c-indent-line)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (make-local-variable 'require-final-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (setq require-final-newline t)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (make-local-variable 'comment-start)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (setq comment-start "(* ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (make-local-variable 'comment-end)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (setq comment-end " *)")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (make-local-variable 'comment-column)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (setq comment-column 41)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (make-local-variable 'comment-start-skip)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (setq comment-start-skip "/\\*+ *")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (make-local-variable 'comment-indent-hook)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (setq comment-indent-hook 'c-comment-indent)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (make-local-variable 'parse-sexp-ignore-comments)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (setq parse-sexp-ignore-comments t)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (run-hooks 'm2-mode-hook))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (defun m2-newline ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 "Insert a newline and indent following line like previous line."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (let ((hpos (current-indentation)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (indent-to hpos)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (defun m2-tab ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 "Indent to next tab stop."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (indent-to (* (1+ (/ (current-indentation) m2-indent)) m2-indent)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (defun m2-begin ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 "Insert a BEGIN keyword and indent for the next line."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (insert "BEGIN")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (defun m2-case ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 "Build skeleton CASE statment, prompting for the <expression>."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (let ((name (read-string "Case-Expression: ")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (insert "CASE " name " OF")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (insert "END (* case " name " *);"))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (end-of-line 0)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (defun m2-definition ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 "Build skeleton DEFINITION MODULE, prompting for the <module name>."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (insert "DEFINITION MODULE ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (let ((name (read-string "Name: ")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (insert name ";\n\n\n\nEND " name ".\n"))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (previous-line 3))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (defun m2-else ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 "Insert ELSE keyword and indent for next line."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (backward-delete-char-untabify m2-indent ())
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (insert "ELSE")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (defun m2-for ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 "Build skeleton FOR loop statment, prompting for the loop parameters."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (insert "FOR ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (let ((name (read-string "Loop Initialiser: ")) limit by)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (insert name " TO ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (setq limit (read-string "Limit: "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (insert limit)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (setq by (read-string "Step: "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (if (not (string-equal by ""))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (insert " BY " by))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (insert " DO")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (insert "END (* for " name " to " limit " *);"))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (end-of-line 0)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (defun m2-header ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 "Insert a comment block containing the module title, author, etc."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (insert "(*\n Title: \t")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (insert (read-string "Title: "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (insert "\n Created:\t")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (insert (current-time-string))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (insert "\n Author: \t")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (insert (user-full-name))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (insert (concat "\n\t\t<" (user-login-name) "@" (system-name) ">\n"))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (insert "*)\n\n"))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (defun m2-if ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 "Insert skeleton IF statment, prompting for <boolean-expression>."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (insert "IF ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (let ((thecondition (read-string "<boolean-expression>: ")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (insert thecondition " THEN")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (insert "END (* if " thecondition " *);"))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (end-of-line 0)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (defun m2-loop ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 "Build skeleton LOOP (with END)."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (insert "LOOP")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (insert "END (* loop *);")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (end-of-line 0)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (defun m2-module ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 "Build skeleton IMPLEMENTATION MODULE, prompting for <module-name>."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (insert "IMPLEMENTATION MODULE ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (let ((name (read-string "Name: ")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (insert name ";\n\n\n\nEND " name ".\n")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (previous-line 3)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (m2-header)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (m2-type)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (m2-var)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (m2-begin)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (m2-begin-comment)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (insert " Module " name " Initialisation Code "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (m2-end-comment)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (defun m2-or ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (backward-delete-char-untabify m2-indent)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (insert "|")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (defun m2-procedure ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (insert "PROCEDURE ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (let ((name (read-string "Name: " ))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 args)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (insert name " (")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (insert (read-string "Arguments: ") ")")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (setq args (read-string "Result Type: "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (if (not (string-equal args ""))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (insert " : " args))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (insert ";")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (insert "BEGIN")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (insert "END ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (insert name)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (insert ";")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (end-of-line 0)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (m2-tab)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 (defun m2-with ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (insert "WITH ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (let ((name (read-string "Record-Type: ")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (insert name)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (insert " DO")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (insert "END (* with " name " *);"))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 (end-of-line 0)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (defun m2-record ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (insert "RECORD")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (insert "END (* record *);")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (end-of-line 0)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (defun m2-stdio ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (insert "
231
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
314 FROM TextIO IMPORT
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 WriteCHAR, ReadCHAR, WriteINTEGER, ReadINTEGER,
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 WriteCARDINAL, ReadCARDINAL, WriteBOOLEAN, ReadBOOLEAN,
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 WriteREAL, ReadREAL, WriteBITSET, ReadBITSET,
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 WriteBasedCARDINAL, ReadBasedCARDINAL, WriteChars, ReadChars,
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 WriteString, ReadString, WhiteSpace, EndOfLine;
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320
231
3c29c1b2d6a1 *** empty log message ***
Brian Preble <rassilon@gnu.org>
parents: 22
diff changeset
321 FROM SysStreams IMPORT sysIn, sysOut, sysErr;
22
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (defun m2-type ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (insert "TYPE")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (defun m2-until ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (insert "REPEAT")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (insert "UNTIL ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (insert (read-string "<boolean-expression>: ") ";")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (end-of-line 0)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (defun m2-var ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (insert "VAR")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 (defun m2-while ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (insert "WHILE ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (let ((name (read-string "<boolean-expression>: ")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (insert name " DO" )
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (m2-newline)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (insert "END (* while " name " *);"))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (end-of-line 0)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (m2-tab))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 (defun m2-export ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (insert "EXPORT QUALIFIED "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 (defun m2-import ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (insert "FROM ")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 (insert (read-string "Module: "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (insert " IMPORT "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (defun m2-begin-comment ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (if (not (bolp))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (indent-to comment-column 0))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (insert "(* "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (defun m2-end-comment ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (if (not (bolp))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (indent-to end-comment-column))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (insert "*)"))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (defun m2-compile ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (setq modulename (buffer-name))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (compile (concat m2-compile-command " " modulename)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 (defun m2-link ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (setq modulename (buffer-name))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (if m2-link-name
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (compile (concat m2-link-command " " m2-link-name))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (compile (concat m2-link-command " "
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (setq m2-link-name (read-string "Name of executable: "
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 modulename))))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (defun execute-monitor-command (command)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (let* ((shell shell-file-name)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (csh (equal (file-name-nondirectory shell) "csh")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (call-process shell nil t t "-cf" (concat "exec " command))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (defun m2-visit ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (let ((deffile nil)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (modfile nil)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 modulename)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (save-excursion
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (setq modulename
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (read-string "Module name: "))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (switch-to-buffer "*Command Execution*")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (execute-monitor-command (concat "m2whereis " modulename))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (goto-char (point-min))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (condition-case ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (progn (re-search-forward "\\(.*\\.def\\) *$")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (setq deffile (buffer-substring (match-beginning 1)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (match-end 1))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (search-failed ()))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (condition-case ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (progn (re-search-forward "\\(.*\\.mod\\) *$")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (setq modfile (buffer-substring (match-beginning 1)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (match-end 1))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (search-failed ()))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (if (not (or deffile modfile))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (error "I can find neither definition nor implementation of %s"
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 modulename)))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (cond (deffile
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (find-file deffile)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (if modfile
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (save-excursion
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (find-file modfile))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (modfile
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (find-file modfile)))))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (defun m2-toggle ()
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 "Toggle between .mod and .def files for the module."
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (interactive)
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (cond ((string-equal (substring (buffer-name) -4) ".def")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (find-file-other-window
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (concat (substring (buffer-name) 0 -4) ".mod")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 ((string-equal (substring (buffer-name) -4) ".mod")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (find-file-other-window
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (concat (substring (buffer-name) 0 -4) ".def")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 ((string-equal (substring (buffer-name) -3) ".mi")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (find-file-other-window
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (concat (substring (buffer-name) 0 -3) ".md")))
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ((string-equal (substring (buffer-name) -3) ".md")
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (find-file-other-window
dee6a680d1d7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (concat (substring (buffer-name) 0 -3) ".mi")))))
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
447
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
448 ;;; modula2.el ends here