annotate lisp/modes/modula2.el @ 0:376386a54a3c r19-14

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