annotate lisp/=ada.el @ 7221:a2c7acc3be9c

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