Mercurial > emacs
annotate lisp/progmodes/ada-stmt.el @ 28052:8f5398ca032c
Don't depend on __STDC__ for volatile.
Add POINTER_TYPE, PTR, PROTOTYPES.
author | Dave Love <fx@gnu.org> |
---|---|
date | Wed, 08 Mar 2000 18:37:20 +0000 |
parents | b63d041c9108 |
children | a530830f8a3d |
rev | line source |
---|---|
23868 | 1 ;;; ada-stmt.el - An extension to Ada mode for inserting statement templates. |
2 | |
26226
b63d041c9108
Changed format of years in copyright notices.
Gerd Moellmann <gerd@gnu.org>
parents:
26000
diff
changeset
|
3 ;; Copyright(C) 1987, 1993-1994, 1996-1998, 1999 Free Software Foundation, Inc. |
23868 | 4 |
26226
b63d041c9108
Changed format of years in copyright notices.
Gerd Moellmann <gerd@gnu.org>
parents:
26000
diff
changeset
|
5 ;; Ada Core Technologies's version: $Revision: 1.10 $ |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
6 |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
7 ;; Authors: Daniel Pfeiffer, Markus Heritsch, Rolf Ebert <ebert@waporo.muc.de> |
23868 | 8 ;; Maintainer: Rolf Ebert <ebert@waporo.muc.de> |
9 ;; Keywords: languages, ada | |
10 ;; Rolf Ebert's version: 2.26 | |
11 | |
12 ;;; Commentary: | |
13 | |
14 ;; | |
15 ;; put the following statement in your .emacs: | |
16 ;; (require 'ada-stmt) | |
17 ;; | |
18 | |
19 ;;; History: | |
20 | |
21 ;; Created May 1987. | |
22 ;; Original version from V. Bowman as in ada.el of Emacs-18 | |
23 ;; (borrowed heavily from Mick Jordan's Modula-2 package for GNU, | |
24 ;; as modified by Peter Robinson, Michael Schmidt, and Tom Perrine.) | |
25 ;; | |
26 ;; Sep 1993. Daniel Pfeiffer <pfeiffer@cict.fr> (DP) | |
27 ;; Introduced statement.el for smaller code and user configurability. | |
28 ;; | |
29 ;; Nov 1993. Rolf Ebert <ebert@enpc.fr> (RE) Moved the | |
30 ;; skeleton generation into this separate file. The code still is | |
31 ;; essentially written by DP | |
32 ;; | |
33 ;; Adapted Jun 1994. Markus Heritsch | |
34 ;; <Markus.Heritsch@studbox.uni-stuttgart.de> (MH) | |
35 ;; added menu bar support for templates | |
36 ;; | |
37 ;; 1994/12/02 Christian Egli <cegli@hcsd.hac.com> | |
38 ;; General cleanup and bug fixes. | |
39 ;; | |
40 ;; 1995/12/20 John Hutchison <hutchiso@epi.syr.ge.com> | |
26226
b63d041c9108
Changed format of years in copyright notices.
Gerd Moellmann <gerd@gnu.org>
parents:
26000
diff
changeset
|
41 ;; made it work with skeleton.el from Emacs-19.30. Several |
23868 | 42 ;; enhancements and bug fixes. |
43 | |
44 ;; BUGS: | |
45 ;;;> I have the following suggestions for the function template: 1) I | |
46 ;;;> don't want it automatically assigning it a name for the return variable. I | |
47 ;;;> never want it to be called "Result" because that is nondescriptive. If you | |
48 ;;;> must define a variable, give me the ability to specify its name. | |
49 ;;;> | |
50 ;;;> 2) You do not provide a type for variable 'Result'. Its type is the same | |
51 ;;;> as the function's return type, which the template knows, so why force me | |
52 ;;;> to type it in? | |
53 ;;;> | |
54 | |
55 ;;;It would be nice if one could configure such layout details separately | |
56 ;;;without patching the LISP code. Maybe the metalanguage used in ada-stmt.el | |
57 ;;;could be taken even further, providing the user with some nice syntax | |
58 ;;;for describing layout. Then my own hacks would survive the next | |
59 ;;;update of the package :-) | |
60 | |
61 | |
62 ;;; Code: | |
63 | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
64 (eval-when-compile |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
65 (condition-case nil (require 'skeleton) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
66 (error nil))) |
23868 | 67 (require 'easymenu) |
68 | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
69 (defun ada-stmt-add-to-ada-menu () |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
70 "Add a new submenu to the Ada menu" |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
71 (interactive) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
72 (let ((menu '(["Header" ada-header t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
73 ["-" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
74 ["Package Body" ada-package-body t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
75 ["Package Spec" ada-package-spec t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
76 ["Function Spec" ada-function-spec t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
77 ["Procedure Spec" ada-procedure-spec t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
78 ["Proc/func Body" ada-subprogram-body t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
79 ["Task Body" ada-task-body t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
80 ["Task Spec" ada-task-spec t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
81 ["Declare Block" ada-declare-block t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
82 ["Exception Block" ada-exception-block t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
83 ["--" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
84 ["Entry" ada-entry t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
85 ["Entry family" ada-entry-family t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
86 ["Select" ada-select t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
87 ["Accept" ada-accept t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
88 ["Or accept" ada-or-accep t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
89 ["Or delay" ada-or-delay t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
90 ["Or terminate" ada-or-terminate t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
91 ["---" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
92 ["Type" ada-type t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
93 ["Private" ada-private t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
94 ["Subtype" ada-subtype t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
95 ["Record" ada-record t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
96 ["Array" ada-array t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
97 ["----" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
98 ["If" ada-if t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
99 ["Else" ada-else t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
100 ["Elsif" ada-elsif t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
101 ["Case" ada-case t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
102 ["-----" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
103 ["While Loop" ada-while-loop t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
104 ["For Loop" ada-for-loop t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
105 ["Loop" ada-loop t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
106 ["------" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
107 ["Exception" ada-exception t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
108 ["Exit" ada-exit t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
109 ["When" ada-when t]))) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
110 (if ada-xemacs |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
111 (progn |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
112 (add-to-list 'menu "Statements") |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
113 (add-submenu '("Ada") menu)) |
23868 | 114 |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
115 (define-key-after (lookup-key ada-mode-map [menu-bar Ada]) [Statements] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
116 (cons "Statements" (easy-menu-create-menu "Statements" menu)) t)) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
117 )) |
23868 | 118 |
119 | |
120 | |
121 | |
122 (defun ada-func-or-proc-name () | |
123 ;; Get the name of the current function or procedure." | |
124 (save-excursion | |
125 (let ((case-fold-search t)) | |
126 (if (re-search-backward ada-procedure-start-regexp nil t) | |
127 (buffer-substring (match-beginning 2) (match-end 2)) | |
128 "NAME?")))) | |
129 | |
130 (defvar ada-template-map nil | |
131 "Keymap used in Ada mode for smart template operations.") | |
132 | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
133 (define-key ada-mode-map "\C-cth" 'ada-header) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
134 (define-key ada-mode-map "\C-ct\C-a" 'ada-array) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
135 (define-key ada-mode-map "\C-ctb" 'ada-exception-block) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
136 (define-key ada-mode-map "\C-ctd" 'ada-declare-block) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
137 (define-key ada-mode-map "\C-ctc" 'ada-case) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
138 (define-key ada-mode-map "\C-ct\C-e" 'ada-elsif) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
139 (define-key ada-mode-map "\C-cte" 'ada-else) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
140 (define-key ada-mode-map "\C-ct\C-k" 'ada-package-spec) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
141 (define-key ada-mode-map "\C-ctk" 'ada-package-body) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
142 (define-key ada-mode-map "\C-ct\C-p" 'ada-procedure-spec) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
143 (define-key ada-mode-map "\C-ctp" 'ada-subprogram-body) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
144 (define-key ada-mode-map "\C-ct\C-f" 'ada-function-spec) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
145 (define-key ada-mode-map "\C-ctf" 'ada-for-loop) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
146 (define-key ada-mode-map "\C-cti" 'ada-if) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
147 (define-key ada-mode-map "\C-ctl" 'ada-loop) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
148 (define-key ada-mode-map "\C-ct\C-r" 'ada-record) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
149 (define-key ada-mode-map "\C-ct\C-s" 'ada-subtype) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
150 (define-key ada-mode-map "\C-ctS" 'ada-tabsize) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
151 (define-key ada-mode-map "\C-ct\C-t" 'ada-task-spec) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
152 (define-key ada-mode-map "\C-ctt" 'ada-task-body) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
153 (define-key ada-mode-map "\C-ct\C-y" 'ada-type) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
154 (define-key ada-mode-map "\C-ct\C-v" 'ada-private) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
155 (define-key ada-mode-map "\C-ctu" 'ada-use) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
156 (define-key ada-mode-map "\C-ct\C-u" 'ada-with) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
157 (define-key ada-mode-map "\C-ct\C-w" 'ada-when) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
158 (define-key ada-mode-map "\C-ctw" 'ada-while-loop) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
159 (define-key ada-mode-map "\C-ct\C-x" 'ada-exception) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
160 (define-key ada-mode-map "\C-ctx" 'ada-exit) |
23868 | 161 |
162 ;;; ---- statement skeletons ------------------------------------------ | |
163 | |
164 (define-skeleton ada-array | |
26000 | 165 "Insert array type definition. |
26226
b63d041c9108
Changed format of years in copyright notices.
Gerd Moellmann <gerd@gnu.org>
parents:
26000
diff
changeset
|
166 Prompt for component type and index subtypes." |
23868 | 167 () |
168 "array (" ("index definition: " str ", " ) -2 ") of " _ ?\;) | |
169 | |
170 | |
171 (define-skeleton ada-case | |
26000 | 172 "Build skeleton case statement. |
173 Prompt for the selector expression. Also builds the first when clause." | |
23868 | 174 "[selector expression]: " |
175 "case " str " is" \n | |
176 > "when " ("discrete choice: " str " | ") -3 " =>" \n | |
177 > _ \n | |
178 < < "end case;") | |
179 | |
180 | |
181 (define-skeleton ada-when | |
182 "Start a case statement alternative with a when clause." | |
183 () | |
184 < "when " ("discrete choice: " str " | ") -3 " =>" \n | |
185 >) | |
186 | |
187 | |
188 (define-skeleton ada-declare-block | |
189 "Insert a block with a declare part. | |
190 Indent for the first declaration." | |
191 "[block name]: " | |
192 < str & ?: & \n | |
193 > "declare" \n | |
194 > _ \n | |
195 < "begin" \n | |
196 > \n | |
197 < "end " str | -1 ?\;) | |
198 | |
199 | |
200 (define-skeleton ada-exception-block | |
201 "Insert a block with an exception part. | |
202 Indent for the first line of code." | |
203 "[block name]: " | |
204 < str & ?: & \n | |
205 > "begin" \n | |
206 > _ \n | |
207 < "exception" \n | |
208 > \n | |
209 < "end " str | -1 ?\;) | |
210 | |
211 | |
212 (define-skeleton ada-exception | |
213 "Insert an indented exception part into a block." | |
214 () | |
215 < "exception" \n | |
216 >) | |
217 | |
218 | |
219 (define-skeleton ada-exit-1 | |
220 "Insert then exit condition of the exit statement, prompting for condition." | |
221 "[exit condition]: " | |
222 "when " str | -5) | |
223 | |
224 | |
225 (define-skeleton ada-exit | |
226 "Insert an exit statement, prompting for loop name and condition." | |
227 "[name of loop to exit]: " | |
228 "exit " str & ?\ | |
229 (ada-exit-1) | |
230 | -1 ?\;) | |
231 | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
232 ;;;###autoload |
23868 | 233 (defun ada-header () |
234 "Insert a descriptive header at the top of the file." | |
235 (interactive "*") | |
236 (save-excursion | |
237 (goto-char (point-min)) | |
238 (if (fboundp 'make-header) | |
239 (make-header) | |
240 (ada-header-tmpl)))) | |
241 | |
242 | |
243 (define-skeleton ada-header-tmpl | |
244 "Insert a comment block containing the module title, author, etc." | |
245 "[Description]: " | |
246 "-- -*- Mode: Ada -*-" | |
247 "\n-- Filename : " (buffer-name) | |
248 "\n-- Description : " str | |
249 "\n-- Author : " (user-full-name) | |
250 "\n-- Created On : " (current-time-string) | |
251 "\n-- Last Modified By: ." | |
252 "\n-- Last Modified On: ." | |
253 "\n-- Update Count : 0" | |
254 "\n-- Status : Unknown, Use with caution!" | |
255 "\n") | |
256 | |
257 | |
258 (define-skeleton ada-display-comment | |
259 "Inserts three comment lines, making a display comment." | |
260 () | |
261 "--\n-- " _ "\n--") | |
262 | |
263 | |
264 (define-skeleton ada-if | |
265 "Insert skeleton if statment, prompting for a boolean-expression." | |
266 "[condition]: " | |
267 "if " str " then" \n | |
268 > _ \n | |
269 < "end if;") | |
270 | |
271 | |
272 (define-skeleton ada-elsif | |
273 "Add an elsif clause to an if statement, | |
274 prompting for the boolean-expression." | |
275 "[condition]: " | |
276 < "elsif " str " then" \n | |
277 >) | |
278 | |
279 | |
280 (define-skeleton ada-else | |
281 "Add an else clause inside an if-then-end-if clause." | |
282 () | |
283 < "else" \n | |
284 >) | |
285 | |
286 | |
287 (define-skeleton ada-loop | |
288 "Insert a skeleton loop statement. The exit statement is added by hand." | |
289 "[loop name]: " | |
290 < str & ?: & \n | |
291 > "loop" \n | |
292 > _ \n | |
293 < "end loop " str | -1 ?\;) | |
294 | |
295 | |
296 (define-skeleton ada-for-loop-prompt-variable | |
297 "Prompt for the loop variable." | |
298 "[loop variable]: " | |
299 str) | |
300 | |
301 | |
302 (define-skeleton ada-for-loop-prompt-range | |
303 "Prompt for the loop range." | |
304 "[loop range]: " | |
305 str) | |
306 | |
307 | |
308 (define-skeleton ada-for-loop | |
309 "Build a skeleton for-loop statement, prompting for the loop parameters." | |
310 "[loop name]: " | |
311 < str & ?: & \n | |
312 > "for " | |
313 (ada-for-loop-prompt-variable) | |
314 " in " | |
315 (ada-for-loop-prompt-range) | |
316 " loop" \n | |
317 > _ \n | |
318 < "end loop " str | -1 ?\;) | |
319 | |
320 | |
321 (define-skeleton ada-while-loop-prompt-entry-condition | |
322 "Prompt for the loop entry condition." | |
323 "[entry condition]: " | |
324 str) | |
325 | |
326 | |
327 (define-skeleton ada-while-loop | |
328 "Insert a skeleton while loop statement." | |
329 "[loop name]: " | |
330 < str & ?: & \n | |
331 > "while " | |
332 (ada-while-loop-prompt-entry-condition) | |
333 " loop" \n | |
334 > _ \n | |
335 < "end loop " str | -1 ?\;) | |
336 | |
337 | |
338 (define-skeleton ada-package-spec | |
339 "Insert a skeleton package specification." | |
340 "[package name]: " | |
341 "package " str " is" \n | |
342 > _ \n | |
343 < "end " str ?\;) | |
344 | |
345 | |
346 (define-skeleton ada-package-body | |
347 "Insert a skeleton package body -- includes a begin statement." | |
348 "[package name]: " | |
349 "package body " str " is" \n | |
350 > _ \n | |
351 ; < "begin" \n | |
352 < "end " str ?\;) | |
353 | |
354 | |
355 (define-skeleton ada-private | |
356 "Undent and start a private section of a package spec. Reindent." | |
357 () | |
358 < "private" \n | |
359 >) | |
360 | |
361 | |
362 (define-skeleton ada-function-spec-prompt-return | |
363 "Prompts for function result type." | |
364 "[result type]: " | |
365 str) | |
366 | |
367 | |
368 (define-skeleton ada-function-spec | |
369 "Insert a function specification. Prompts for name and arguments." | |
370 "[function name]: " | |
371 "function " str | |
372 " (" ("[parameter_specification]: " str "; " ) -2 ")" | |
373 " return " | |
374 (ada-function-spec-prompt-return) | |
375 ";" \n ) | |
376 | |
377 | |
378 (define-skeleton ada-procedure-spec | |
379 "Insert a procedure specification, prompting for its name and arguments." | |
380 "[procedure name]: " | |
381 "procedure " str | |
382 " (" ("[parameter_specification]: " str "; " ) -2 ")" | |
383 ";" \n ) | |
384 | |
385 | |
386 (define-skeleton ada-subprogram-body | |
387 "Insert frame for subprogram body. | |
388 Invoke right after `ada-function-spec' or `ada-procedure-spec'." | |
389 () | |
390 ;; Remove `;' from subprogram decl | |
391 (save-excursion | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
392 (let ((pos (1+ (point)))) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
393 (ada-search-ignore-string-comment ada-subprog-start-re t nil) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
394 (if (ada-search-ignore-string-comment "(" nil pos t 'search-forward) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
395 (progn |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
396 (backward-char 1) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
397 (forward-sexp 1))) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
398 ) |
23868 | 399 (if (looking-at ";") |
400 (delete-char 1))) | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
401 " is" \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
402 _ \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
403 < "begin" \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
404 \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
405 < "exception" \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
406 "when others => null;" \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
407 < < "end " |
23868 | 408 (ada-func-or-proc-name) |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
409 ";" \n) |
23868 | 410 |
411 | |
412 (define-skeleton ada-separate | |
413 "Finish a body stub with `separate'." | |
414 () | |
415 > "separate;" \n | |
416 <) | |
417 | |
418 | |
419 ;(define-skeleton ada-with | |
420 ; "Inserts a with clause, prompting for the list of units depended upon." | |
421 ; "[list of units depended upon]: " | |
422 ; "with " str ?\;) | |
423 | |
424 ;(define-skeleton ada-use | |
425 ; "Inserts a use clause, prompting for the list of packages used." | |
426 ; "[list of packages used]: " | |
427 ; "use " str ?\;) | |
428 | |
429 | |
430 (define-skeleton ada-record | |
431 "Insert a skeleton record type declaration." | |
432 () | |
433 "record" \n | |
434 > _ \n | |
435 < "end record;") | |
436 | |
437 | |
438 (define-skeleton ada-subtype | |
439 "Start insertion of a subtype declaration, prompting for the subtype name." | |
440 "[subtype name]: " | |
441 "subtype " str " is " _ ?\; | |
442 (not (message "insert subtype indication."))) | |
443 | |
444 | |
445 (define-skeleton ada-type | |
446 "Start insertion of a type declaration, prompting for the type name." | |
447 "[type name]: " | |
448 "type " str ?\( | |
449 ("[discriminant specs]: " str " ") | |
450 | (backward-delete-char 1) | ?\) | |
451 " is " | |
452 (not (message "insert type definition."))) | |
453 | |
454 | |
455 (define-skeleton ada-task-body | |
456 "Insert a task body, prompting for the task name." | |
457 "[task name]: " | |
458 "task body " str " is\n" | |
459 "begin\n" | |
460 > _ \n | |
461 < "end " str ";" ) | |
462 | |
463 | |
464 (define-skeleton ada-task-spec | |
465 "Insert a task specification, prompting for the task name." | |
466 "[task name]: " | |
467 "task " str | |
468 " (" ("[discriminant]: " str "; ") ") is\n" | |
469 > "entry " _ \n | |
470 <"end " str ";" ) | |
471 | |
472 | |
473 (define-skeleton ada-get-param1 | |
474 "Prompt for arguments and if any enclose them in brackets." | |
475 () | |
476 ("[parameter_specification]: " str "; " ) & -2 & ")" | |
477 ) | |
478 | |
479 | |
480 (define-skeleton ada-get-param | |
481 "Prompt for arguments and if any enclose them in brackets." | |
482 () | |
483 " (" | |
484 (ada-get-param1) | -2 | |
485 ) | |
486 | |
487 | |
488 (define-skeleton ada-entry | |
489 "Insert a task entry, prompting for the entry name." | |
490 "[entry name]: " | |
491 "entry " str | |
492 (ada-get-param) | |
493 ";" \n | |
494 ; (ada-indent-current) | |
495 ) | |
496 | |
497 | |
498 (define-skeleton ada-entry-family-prompt-discriminant | |
499 "Insert a entry specification, prompting for the entry name." | |
500 "[discriminant name]: " | |
501 str) | |
502 | |
503 | |
504 (define-skeleton ada-entry-family | |
505 "Insert a entry specification, prompting for the entry name." | |
506 "[entry name]: " | |
507 "entry " str | |
508 " (" (ada-entry-family-prompt-discriminant) ")" | |
509 (ada-get-param) | |
510 ";" \n | |
511 ;(ada-indent-current) | |
512 ) | |
513 | |
514 | |
515 (define-skeleton ada-select | |
516 "Insert a select block." | |
517 () | |
518 "select\n" | |
519 > _ \n | |
520 < "end select;") | |
521 | |
522 | |
523 (define-skeleton ada-accept-1 | |
524 "Insert a condition statement, prompting for the condition name." | |
525 "[condition]: " | |
526 "when " str | -5 ) | |
527 | |
528 | |
529 (define-skeleton ada-accept-2 | |
530 "Insert an accept statement, prompting for the name and arguments." | |
531 "[accept name]: " | |
532 > "accept " str | |
533 (ada-get-param) | |
534 ; " (" ("[parameter_specification]: " str "; ") -2 ")" | |
535 " do" \n | |
536 > _ \n | |
537 < "end " str ";" ) | |
538 | |
539 | |
540 (define-skeleton ada-accept | |
541 "Insert an accept statement (prompt for condition, name and arguments)." | |
542 () | |
543 > (ada-accept-1) & " =>\n" | |
544 (ada-accept-2) | |
545 ) | |
546 | |
547 | |
548 (define-skeleton ada-or-accept | |
549 "Insert a or statement, prompting for the condition name." | |
550 () | |
551 < "or\n" | |
552 (ada-accept) | |
553 ) | |
554 | |
555 | |
556 (define-skeleton ada-or-delay | |
557 "Insert a delay statement, prompting for the delay value." | |
558 "[delay value]: " | |
559 < "or\n" | |
560 > "delay " str ";") | |
561 | |
562 | |
563 (define-skeleton ada-or-terminate | |
564 "Insert a terminate statement." | |
565 () | |
566 < "or\n" | |
567 > "terminate;") | |
568 | |
569 | |
570 ;; ---- | |
571 (defun ada-adjust-case-skeleton () | |
572 "Adjusts the case of the text inserted by a skeleton." | |
573 (save-excursion | |
574 (let ((aa-end (point))) | |
575 (ada-adjust-case-region | |
576 (progn (goto-char beg) (forward-word -1) (point)) | |
577 (goto-char aa-end)) | |
578 ))) | |
579 (add-hook 'ada-mode-hook '(lambda () | |
580 (setq skeleton-further-elements | |
581 '((< '(backward-delete-char-untabify | |
582 (min ada-indent (current-column)))))) | |
583 (add-hook 'skeleton-end-hook | |
584 'ada-adjust-case-skeleton))) | |
585 | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
586 (add-hook 'ada-mode-hook 'ada-stmt-add-to-ada-menu) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
587 |
23868 | 588 (provide 'ada-stmt) |
589 | |
590 ;;; ada-stmt.el ends here |