Mercurial > emacs
annotate lisp/=ada.el @ 680:f99c8512cd41
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 03 Jun 1992 20:43:49 +0000 |
parents | 8a533acedb77 |
children | 4f28bd14272c |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
178
diff
changeset
|
1 ;;; ada.el --- Ada editing support package in GNUlisp. v1.0 |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
178
diff
changeset
|
2 |
39 | 3 ; Author: Vincent Broman <broman@bugs.nosc.mil> May 1987. |
4 ; (borrows heavily from Mick Jordan's Modula-2 package for GNU, | |
5 ; as modified by Peter Robinson, Michael Schmidt, and Tom Perrine.) | |
6 | |
7 ;; Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc. | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 1, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
25 (setq auto-mode-alist (cons (cons "\\.ada$" 'ada-mode) auto-mode-alist)) | |
26 | |
27 (defvar ada-mode-syntax-table nil | |
28 "Syntax table in use in Ada-mode buffers.") | |
29 | |
30 (let ((table (make-syntax-table))) | |
31 (modify-syntax-entry ?_ "_" table) | |
32 (modify-syntax-entry ?\# "_" table) | |
33 (modify-syntax-entry ?\( "()" table) | |
34 (modify-syntax-entry ?\) ")(" table) | |
35 (modify-syntax-entry ?$ "." table) | |
36 (modify-syntax-entry ?* "." table) | |
37 (modify-syntax-entry ?/ "." table) | |
38 (modify-syntax-entry ?+ "." table) | |
39 (modify-syntax-entry ?- "." table) | |
40 (modify-syntax-entry ?= "." table) | |
41 (modify-syntax-entry ?\& "." table) | |
42 (modify-syntax-entry ?\| "." table) | |
43 (modify-syntax-entry ?< "." table) | |
44 (modify-syntax-entry ?> "." table) | |
45 (modify-syntax-entry ?\[ "." table) | |
46 (modify-syntax-entry ?\] "." table) | |
47 (modify-syntax-entry ?\{ "." table) | |
48 (modify-syntax-entry ?\} "." table) | |
49 (modify-syntax-entry ?. "." table) | |
50 (modify-syntax-entry ?\\ "." table) | |
51 (modify-syntax-entry ?: "." table) | |
52 (modify-syntax-entry ?\; "." table) | |
53 (modify-syntax-entry ?\' "." table) | |
54 (modify-syntax-entry ?\" "\"" table) | |
55 (setq ada-mode-syntax-table table)) | |
56 | |
57 (defvar ada-mode-map nil | |
58 "Keymap used in Ada mode.") | |
59 | |
60 (let ((map (make-sparse-keymap))) | |
61 (define-key map "\C-m" 'ada-newline) | |
62 (define-key map "\C-?" 'backward-delete-char-untabify) | |
63 (define-key map "\C-i" 'ada-tab) | |
64 (define-key map "\C-c\C-i" 'ada-untab) | |
65 (define-key map "\C-c<" 'ada-backward-to-same-indent) | |
66 (define-key map "\C-c>" 'ada-forward-to-same-indent) | |
67 (define-key map "\C-ch" 'ada-header) | |
68 (define-key map "\C-c(" 'ada-paired-parens) | |
69 (define-key map "\C-c-" 'ada-inline-comment) | |
70 (define-key map "\C-c\C-a" 'ada-array) | |
71 (define-key map "\C-cb" 'ada-exception-block) | |
72 (define-key map "\C-cd" 'ada-declare-block) | |
73 (define-key map "\C-c\C-e" 'ada-exception) | |
74 (define-key map "\C-cc" 'ada-case) | |
75 (define-key map "\C-c\C-k" 'ada-package-spec) | |
76 (define-key map "\C-ck" 'ada-package-body) | |
77 (define-key map "\C-c\C-p" 'ada-procedure-spec) | |
78 (define-key map "\C-cp" 'ada-subprogram-body) | |
79 (define-key map "\C-c\C-f" 'ada-function-spec) | |
80 (define-key map "\C-cf" 'ada-for-loop) | |
81 (define-key map "\C-cl" 'ada-loop) | |
82 (define-key map "\C-ci" 'ada-if) | |
83 (define-key map "\C-cI" 'ada-elsif) | |
84 (define-key map "\C-ce" 'ada-else) | |
85 (define-key map "\C-c\C-v" 'ada-private) | |
86 (define-key map "\C-c\C-r" 'ada-record) | |
87 (define-key map "\C-c\C-s" 'ada-subtype) | |
88 (define-key map "\C-cs" 'ada-separate) | |
89 (define-key map "\C-c\C-t" 'ada-type) | |
90 (define-key map "\C-ct" 'ada-tabsize) | |
91 ;; (define-key map "\C-c\C-u" 'ada-use) | |
92 ;; (define-key map "\C-c\C-w" 'ada-with) | |
93 (define-key map "\C-cw" 'ada-while-loop) | |
94 (define-key map "\C-c\C-w" 'ada-when) | |
95 (define-key map "\C-cx" 'ada-exit) | |
96 (define-key map "\C-cC" 'ada-compile) | |
97 (define-key map "\C-cB" 'ada-bind) | |
98 (define-key map "\C-cE" 'ada-find-listing) | |
99 (define-key map "\C-cL" 'ada-library-name) | |
100 (define-key map "\C-cO" 'ada-options-for-bind) | |
101 (setq ada-mode-map map)) | |
102 | |
103 (defvar ada-indent 4 "*Value is the number of columns to indent in Ada-Mode.") | |
104 | |
105 (defun ada-mode () | |
106 "This is a mode intended to support program development in Ada. | |
107 Most control constructs and declarations of Ada can be inserted in the buffer | |
108 by typing Control-C followed by a character mnemonic for the construct. | |
109 | |
178 | 110 \\<ada-mode-map>\\[ada-array] array \\[ada-exception-block] exception block |
111 \\[ada-exception] exception \\[ada-declare-block] declare block | |
112 \\[ada-package-spec] package spec \\[ada-package-body] package body | |
113 \\[ada-procedure-spec] procedure spec \\[ada-subprogram-body] proc/func body | |
114 \\[ada-function-spec] func spec \\[ada-for-loop] for loop | |
115 \\[ada-if] if | |
116 \\[ada-elsif] elsif | |
117 \\[ada-else] else | |
118 \\[ada-private] private \\[ada-loop] loop | |
119 \\[ada-record] record \\[ada-case] case | |
120 \\[ada-subtype] subtype \\[ada-separate] separate | |
121 \\[ada-type] type \\[ada-tabsize] tab spacing for indents | |
122 \\[ada-when] when \\[ada-while] while | |
123 \\[ada-exit] exit | |
124 \\[ada-paired-parens] paired parens \\[ada-inline-comment] inline comment | |
125 \\[ada-header] header spec | |
126 \\[ada-compile] compile \\[ada-bind] bind | |
127 \\[ada-find-listing] find error list | |
128 \\[ada-library-name] name library \\[ada-options-for-bind] options for bind | |
39 | 129 |
178 | 130 \\[ada-backward-to-same-indent] and \\[ada-forward-to-same-indent] move backward and forward respectively to the next line |
39 | 131 having the same (or lesser) level of indentation. |
132 | |
178 | 133 Variable `ada-indent' controls the number of spaces for indent/undent." |
39 | 134 (interactive) |
135 (kill-all-local-variables) | |
136 (use-local-map ada-mode-map) | |
137 (setq major-mode 'ada-mode) | |
138 (setq mode-name "Ada") | |
139 (make-local-variable 'comment-column) | |
140 (setq comment-column 41) | |
141 (make-local-variable 'end-comment-column) | |
142 (setq end-comment-column 72) | |
143 (set-syntax-table ada-mode-syntax-table) | |
144 (make-local-variable 'paragraph-start) | |
145 (setq paragraph-start (concat "^$\\|" page-delimiter)) | |
146 (make-local-variable 'paragraph-separate) | |
147 (setq paragraph-separate paragraph-start) | |
148 (make-local-variable 'paragraph-ignore-fill-prefix) | |
149 (setq paragraph-ignore-fill-prefix t) | |
150 ; (make-local-variable 'indent-line-function) | |
151 ; (setq indent-line-function 'c-indent-line) | |
152 (make-local-variable 'require-final-newline) | |
153 (setq require-final-newline t) | |
154 (make-local-variable 'comment-start) | |
155 (setq comment-start "--") | |
156 (make-local-variable 'comment-end) | |
157 (setq comment-end "") | |
158 (make-local-variable 'comment-column) | |
159 (setq comment-column 41) | |
160 (make-local-variable 'comment-start-skip) | |
161 (setq comment-start-skip "--+ *") | |
162 (make-local-variable 'comment-indent-hook) | |
163 (setq comment-indent-hook 'c-comment-indent) | |
164 (make-local-variable 'parse-sexp-ignore-comments) | |
165 (setq parse-sexp-ignore-comments t) | |
166 (run-hooks 'ada-mode-hook)) | |
167 | |
168 (defun ada-tabsize (s) | |
171 | 169 "Changes spacing used for indentation. |
178 | 170 The prefix argument is used as the new spacing." |
171 (interactive "p") | |
39 | 172 (setq ada-indent s)) |
173 | |
174 (defun ada-newline () | |
175 "Start new line and indent to current tab stop." | |
176 (interactive) | |
177 (let ((ada-cc (current-indentation))) | |
178 (newline) | |
179 (indent-to ada-cc))) | |
180 | |
181 (defun ada-tab () | |
182 "Indent to next tab stop." | |
183 (interactive) | |
184 (indent-to (* (1+ (/ (current-indentation) ada-indent)) ada-indent))) | |
185 | |
186 (defun ada-untab () | |
187 "Delete backwards to previous tab stop." | |
188 (interactive) | |
189 (backward-delete-char-untabify ada-indent nil)) | |
190 | |
191 (defun ada-go-to-this-indent (step indent-level) | |
171 | 192 "Move point repeatedly by STEP lines until the current line has |
193 given INDENT-LEVEL or less, or the start or end of the buffer is reached. | |
194 Ignore blank lines, statement labels and block or loop names." | |
39 | 195 (while (and |
196 (zerop (forward-line step)) | |
197 (or (looking-at "^[ ]*$") | |
198 (looking-at "^[ ]*--") | |
199 (looking-at "^<<[A-Za-z0-9_]+>>") | |
200 (looking-at "^[A-Za-z0-9_]+:") | |
201 (> (current-indentation) indent-level))) | |
202 nil)) | |
203 | |
204 (defun ada-backward-to-same-indent () | |
205 "Move point backwards to nearest line with same indentation or less. | |
171 | 206 If not found, point is left at the top of the buffer." |
39 | 207 (interactive) |
208 (ada-go-to-this-indent -1 (current-indentation)) | |
209 (back-to-indentation)) | |
210 | |
211 (defun ada-forward-to-same-indent () | |
212 "Move point forwards to nearest line with same indentation or less. | |
171 | 213 If not found, point is left at the start of the last line in the buffer." |
39 | 214 (interactive) |
215 (ada-go-to-this-indent 1 (current-indentation)) | |
216 (back-to-indentation)) | |
217 | |
218 (defun ada-array () | |
171 | 219 "Insert array type definition. Uses the minibuffer to prompt |
220 for component type and index subtypes." | |
39 | 221 (interactive) |
222 (insert "array ()") | |
223 (backward-char) | |
224 (insert (read-string "index subtype[s]: ")) | |
225 (end-of-line) | |
226 (insert " of ;") | |
227 (backward-char) | |
228 (insert (read-string "component-type: ")) | |
229 (end-of-line)) | |
230 | |
231 (defun ada-case () | |
171 | 232 "Build skeleton case statement. |
233 Uses the minibuffer to prompt for the selector expression. | |
234 Also builds the first when clause." | |
39 | 235 (interactive) |
236 (insert "case ") | |
237 (insert (read-string "selector expression: ") " is") | |
238 (ada-newline) | |
239 (ada-newline) | |
240 (insert "end case;") | |
241 (end-of-line 0) | |
242 (ada-tab) | |
243 (ada-tab) | |
244 (ada-when)) | |
245 | |
246 (defun ada-declare-block () | |
171 | 247 "Insert a block with a declare part. |
248 Indent for the first declaration." | |
39 | 249 (interactive) |
250 (let ((ada-block-name (read-string "[block name]: "))) | |
251 (insert "declare") | |
252 (cond | |
171 | 253 ( (not (string-equal ada-block-name "")) |
254 (beginning-of-line) | |
255 (open-line 1) | |
256 (insert ada-block-name ":") | |
257 (next-line 1) | |
258 (end-of-line))) | |
39 | 259 (ada-newline) |
260 (ada-newline) | |
261 (insert "begin") | |
262 (ada-newline) | |
263 (ada-newline) | |
264 (if (string-equal ada-block-name "") | |
171 | 265 (insert "end;") |
39 | 266 (insert "end " ada-block-name ";")) |
171 | 267 ) |
39 | 268 (end-of-line -2) |
269 (ada-tab)) | |
270 | |
271 (defun ada-exception-block () | |
171 | 272 "Insert a block with an exception part. |
273 Indent for the first line of code." | |
39 | 274 (interactive) |
275 (let ((block-name (read-string "[block name]: "))) | |
276 (insert "begin") | |
277 (cond | |
171 | 278 ( (not (string-equal block-name "")) |
279 (beginning-of-line) | |
280 (open-line 1) | |
281 (insert block-name ":") | |
282 (next-line 1) | |
283 (end-of-line))) | |
39 | 284 (ada-newline) |
285 (ada-newline) | |
286 (insert "exception") | |
287 (ada-newline) | |
288 (ada-newline) | |
289 (cond | |
171 | 290 ( (string-equal block-name "") |
291 (insert "end;")) | |
292 ( t | |
293 (insert "end " block-name ";"))) | |
294 ) | |
39 | 295 (end-of-line -2) |
296 (ada-tab)) | |
297 | |
298 (defun ada-exception () | |
171 | 299 "Insert an indented exception part into a block." |
39 | 300 (interactive) |
301 (ada-untab) | |
302 (insert "exception") | |
303 (ada-newline) | |
304 (ada-tab)) | |
305 | |
306 (defun ada-else () | |
307 "Add an else clause inside an if-then-end-if clause." | |
308 (interactive) | |
309 (ada-untab) | |
310 (insert "else") | |
311 (ada-newline) | |
312 (ada-tab)) | |
313 | |
314 (defun ada-exit () | |
315 "Insert an exit statement, prompting for loop name and condition." | |
316 (interactive) | |
317 (insert "exit") | |
318 (let ((ada-loop-name (read-string "[name of loop to exit]: "))) | |
319 (if (not (string-equal ada-loop-name "")) (insert " " ada-loop-name))) | |
320 (let ((ada-exit-condition (read-string "[exit condition]: "))) | |
321 (if (not (string-equal ada-exit-condition "")) | |
322 (if (string-match "^ *[Ww][Hh][Ee][Nn] +" ada-exit-condition) | |
323 (insert " " ada-exit-condition) | |
324 (insert " when " ada-exit-condition)))) | |
325 (insert ";")) | |
326 | |
327 (defun ada-when () | |
328 "Start a case statement alternative with a when clause." | |
329 (interactive) | |
330 (ada-untab) ; we were indented in code for the last alternative. | |
331 (insert "when ") | |
332 (insert (read-string "'|'-delimited choice list: ") " =>") | |
333 (ada-newline) | |
334 (ada-tab)) | |
335 | |
336 (defun ada-for-loop () | |
337 "Build a skeleton for-loop statement, prompting for the loop parameters." | |
338 (interactive) | |
339 (insert "for ") | |
340 (let* ((ada-loop-name (read-string "[loop name]: ")) | |
341 (ada-loop-is-named (not (string-equal ada-loop-name "")))) | |
342 (if ada-loop-is-named | |
343 (progn | |
344 (beginning-of-line) | |
345 (open-line 1) | |
346 (insert ada-loop-name ":") | |
347 (next-line 1) | |
348 (end-of-line 1))) | |
349 (insert (read-string "loop variable: ") " in ") | |
350 (insert (read-string "range: ") " loop") | |
351 (ada-newline) | |
352 (ada-newline) | |
353 (insert "end loop") | |
354 (if ada-loop-is-named (insert " " ada-loop-name)) | |
355 (insert ";")) | |
356 (end-of-line 0) | |
357 (ada-tab)) | |
358 | |
359 (defun ada-header () | |
360 "Insert a comment block containing the module title, author, etc." | |
361 (interactive) | |
362 (insert "--\n-- Title: \t") | |
363 (insert (read-string "Title: ")) | |
364 (insert "\n-- Created:\t" (current-time-string)) | |
365 (insert "\n-- Author: \t" (user-full-name)) | |
366 (insert "\n--\t\t<" (user-login-name) "@" (system-name) ">\n--\n")) | |
367 | |
368 (defun ada-if () | |
369 "Insert skeleton if statment, prompting for a boolean-expression." | |
370 (interactive) | |
371 (insert "if ") | |
372 (insert (read-string "condition: ") " then") | |
373 (ada-newline) | |
374 (ada-newline) | |
375 (insert "end if;") | |
376 (end-of-line 0) | |
377 (ada-tab)) | |
378 | |
379 (defun ada-elsif () | |
380 "Add an elsif clause to an if statement, prompting for the boolean-expression." | |
381 (interactive) | |
382 (ada-untab) | |
383 (insert "elsif ") | |
384 (insert (read-string "condition: ") " then") | |
385 (ada-newline) | |
386 (ada-tab)) | |
387 | |
388 (defun ada-loop () | |
171 | 389 "Insert a skeleton loop statement. exit statement added by hand." |
39 | 390 (interactive) |
391 (insert "loop ") | |
392 (let* ((ada-loop-name (read-string "[loop name]: ")) | |
393 (ada-loop-is-named (not (string-equal ada-loop-name "")))) | |
394 (if ada-loop-is-named | |
395 (progn | |
396 (beginning-of-line) | |
397 (open-line 1) | |
398 (insert ada-loop-name ":") | |
399 (forward-line 1) | |
400 (end-of-line 1))) | |
401 (ada-newline) | |
402 (ada-newline) | |
403 (insert "end loop") | |
404 (if ada-loop-is-named (insert " " ada-loop-name)) | |
405 (insert ";")) | |
406 (end-of-line 0) | |
407 (ada-tab)) | |
408 | |
409 (defun ada-package-spec () | |
410 "Insert a skeleton package specification." | |
411 (interactive) | |
412 (insert "package ") | |
413 (let ((ada-package-name (read-string "package name: " ))) | |
414 (insert ada-package-name " is") | |
415 (ada-newline) | |
416 (ada-newline) | |
417 (insert "end " ada-package-name ";") | |
418 (end-of-line 0) | |
419 (ada-tab))) | |
420 | |
421 (defun ada-package-body () | |
422 "Insert a skeleton package body -- includes a begin statement." | |
423 (interactive) | |
424 (insert "package body ") | |
425 (let ((ada-package-name (read-string "package name: " ))) | |
426 (insert ada-package-name " is") | |
427 (ada-newline) | |
428 (ada-newline) | |
429 (insert "begin") | |
430 (ada-newline) | |
431 (insert "end " ada-package-name ";") | |
432 (end-of-line -1) | |
433 (ada-tab))) | |
434 | |
435 (defun ada-private () | |
436 "Undent and start a private section of a package spec. Reindent." | |
437 (interactive) | |
438 (ada-untab) | |
439 (insert "private") | |
440 (ada-newline) | |
441 (ada-tab)) | |
442 | |
443 (defun ada-get-arg-list () | |
171 | 444 "Read from the user a procedure or function argument list. |
39 | 445 Add parens unless arguments absent, and insert into buffer. |
171 | 446 Individual arguments are arranged vertically if entered one at a time. |
447 Arguments ending with `;' are presumed single and stacked." | |
39 | 448 (insert " (") |
449 (let ((ada-arg-indent (current-column)) | |
450 (ada-args (read-string "[arguments]: "))) | |
451 (if (string-equal ada-args "") | |
452 (backward-delete-char 2) | |
453 (progn | |
454 (while (string-match ";$" ada-args) | |
455 (insert ada-args) | |
456 (newline) | |
457 (indent-to ada-arg-indent) | |
458 (setq ada-args (read-string "next argument: "))) | |
459 (insert ada-args ")"))))) | |
460 | |
461 (defun ada-function-spec () | |
462 "Insert a function specification. Prompts for name and arguments." | |
463 (interactive) | |
464 (insert "function ") | |
465 (insert (read-string "function name: ")) | |
466 (ada-get-arg-list) | |
467 (insert " return ") | |
468 (insert (read-string "result type: "))) | |
469 | |
470 (defun ada-procedure-spec () | |
471 "Insert a procedure specification, prompting for its name and arguments." | |
472 (interactive) | |
473 (insert "procedure ") | |
474 (insert (read-string "procedure name: " )) | |
475 (ada-get-arg-list)) | |
476 | |
477 (defun get-ada-subprogram-name () | |
171 | 478 "Return (without moving point or mark) a pair whose CAR is the name of |
479 the function or procedure whose spec immediately precedes point, and whose | |
480 CDR is the column number where the procedure/function keyword was found." | |
39 | 481 (save-excursion |
482 (let ((ada-proc-indent 0)) | |
483 (if (re-search-backward | |
484 ;;;; Unfortunately, comments are not ignored in this string search. | |
485 "[PpFf][RrUu][OoNn][Cc][EeTt][DdIi][UuOo][RrNn]" nil t) | |
486 (if (or (looking-at "\\<[Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee]\\>") | |
487 (looking-at "\\<[Ff][Uu][Nn][Cc][Tt][Ii][Oo][Nn]\\>")) | |
488 (progn | |
489 (setq ada-proc-indent (current-column)) | |
490 (forward-word 2) | |
491 (let ((p2 (point))) | |
492 (forward-word -1) | |
493 (cons (buffer-substring (point) p2) ada-proc-indent))) | |
494 (get-ada-subprogram-name)) | |
495 (cons "NAME?" ada-proc-indent))))) | |
496 | |
497 (defun ada-subprogram-body () | |
498 "Insert frame for subprogram body. | |
171 | 499 Invoke right after `ada-function-spec' or `ada-procedure-spec'." |
39 | 500 (interactive) |
501 (insert " is") | |
502 (let ((ada-subprogram-name-col (get-ada-subprogram-name))) | |
503 (newline) | |
504 (indent-to (cdr ada-subprogram-name-col)) | |
505 (ada-newline) | |
506 (insert "begin") | |
507 (ada-newline) | |
508 (ada-newline) | |
509 (insert "end " (car ada-subprogram-name-col) ";")) | |
510 (end-of-line -2) | |
511 (ada-tab)) | |
512 | |
513 (defun ada-separate () | |
171 | 514 "Finish a body stub with `is separate'." |
39 | 515 (interactive) |
516 (insert " is") | |
517 (ada-newline) | |
518 (ada-tab) | |
519 (insert "separate;") | |
520 (ada-newline) | |
521 (ada-untab)) | |
522 | |
523 ;(defun ada-with () | |
524 ; "Inserts a with clause, prompting for the list of units depended upon." | |
525 ; (interactive) | |
526 ; (insert "with ") | |
527 ; (insert (read-string "list of units depended upon: ") ";")) | |
528 ; | |
529 ;(defun ada-use () | |
530 ; "Inserts a use clause, prompting for the list of packages used." | |
531 ; (interactive) | |
532 ; (insert "use ") | |
533 ; (insert (read-string "list of packages to use: ") ";")) | |
534 | |
535 (defun ada-record () | |
536 "Insert a skeleton record type declaration." | |
537 (interactive) | |
538 (insert "record") | |
539 (ada-newline) | |
540 (ada-newline) | |
541 (insert "end record;") | |
542 (end-of-line 0) | |
543 (ada-tab)) | |
544 | |
545 (defun ada-subtype () | |
546 "Start insertion of a subtype declaration, prompting for the subtype name." | |
547 (interactive) | |
548 (insert "subtype " (read-string "subtype name: ") " is ;") | |
549 (backward-char) | |
550 (message "insert subtype indication.")) | |
551 | |
552 (defun ada-type () | |
553 "Start insertion of a type declaration, prompting for the type name." | |
554 (interactive) | |
555 (insert "type " (read-string "type name: ")) | |
556 (let ((disc-part (read-string "discriminant specs: "))) | |
557 (if (not (string-equal disc-part "")) | |
558 (insert "(" disc-part ")"))) | |
559 (insert " is ") | |
560 (message "insert type definition.")) | |
561 | |
562 (defun ada-while-loop () | |
563 (interactive) | |
564 (insert "while ") | |
565 (let* ((ada-loop-name (read-string "loop name: ")) | |
566 (ada-loop-is-named (not (string-equal ada-loop-name "")))) | |
567 (if ada-loop-is-named | |
568 (progn | |
569 (beginning-of-line) | |
570 (open-line 1) | |
571 (insert ada-loop-name ":") | |
572 (next-line 1) | |
573 (end-of-line 1))) | |
574 (insert (read-string "entry condition: ") " loop") | |
575 (ada-newline) | |
576 (ada-newline) | |
577 (insert "end loop") | |
578 (if ada-loop-is-named (insert " " ada-loop-name)) | |
579 (insert ";")) | |
580 (end-of-line 0) | |
581 (ada-tab)) | |
582 | |
583 (defun ada-paired-parens () | |
584 "Insert a pair of round parentheses, placing point between them." | |
585 (interactive) | |
586 (insert "()") | |
587 (backward-char)) | |
588 | |
589 (defun ada-inline-comment () | |
171 | 590 "Start a comment after the end of the line, indented at least |
591 `comment-column' spaces. If starting after `end-comment-column', | |
592 start a new line." | |
39 | 593 (interactive) |
594 (end-of-line) | |
595 (if (> (current-column) end-comment-column) (newline)) | |
596 (if (< (current-column) comment-column) (indent-to comment-column)) | |
597 (insert " -- ")) | |
598 | |
599 (defun ada-display-comment () | |
171 | 600 "Inserts three comment lines, making a display comment." |
39 | 601 (interactive) |
602 (insert "--\n-- \n--") | |
603 (end-of-line 0)) | |
604 | |
605 ;; Much of this is specific to Ada-Ed | |
606 | |
171 | 607 (defvar ada-lib-dir-name "lib" "*Current Ada program library directory.") |
39 | 608 (defvar ada-bind-opts "" "*Options to supply for binding.") |
609 | |
610 (defun ada-library-name (ada-lib-name) | |
171 | 611 "Specify name of Ada library directory for later compilations." |
612 (interactive "DName of Ada library directory: ") | |
39 | 613 (setq ada-lib-dir-name ada-lib-name)) |
614 | |
615 (defun ada-options-for-bind () | |
171 | 616 "Specify options, such as -m and -i, needed for `ada-bind'." |
617 (setq ada-bind-opts (read-string "-m and -i options for `ada-bind': "))) | |
39 | 618 |
171 | 619 (defun ada-compile (arg) |
39 | 620 "Save the current buffer and compile it into the current program library. |
621 Initialize the library if a prefix arg is given." | |
622 (interactive "P") | |
171 | 623 (let* ((ada-init (if (null arg) "" "-n ")) |
39 | 624 (ada-source-file (buffer-name))) |
625 (compile | |
626 (concat "adacomp " ada-init "-l " ada-lib-dir-name " " ada-source-file)))) | |
627 | |
628 (defun ada-find-listing () | |
629 "Find listing file for ada source in current buffer, using other window." | |
630 (interactive) | |
631 (find-file-other-window (concat (substring (buffer-name) 0 -4) ".lis")) | |
632 (search-forward "*** ERROR")) | |
633 | |
634 (defun ada-bind () | |
635 "Bind the current program library, using the current binding options." | |
636 (interactive) | |
637 (compile (concat "adabind " ada-bind-opts " " ada-lib-dir-name))) | |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
178
diff
changeset
|
638 |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
178
diff
changeset
|
639 ;;; ada.el ends here |