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