Mercurial > emacs
annotate lisp/progmodes/ada-stmt.el @ 59061:a7985894de81
Comment change.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Tue, 21 Dec 2004 11:50:52 +0000 |
| parents | e8824c4f5f7e |
| children | ad6e77659287 8e5779acd195 |
| rev | line source |
|---|---|
|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
34400
diff
changeset
|
1 ;;; ada-stmt.el --- an extension to Ada mode for inserting statement templates |
| 23868 | 2 |
|
50739
fbec4e6f73c8
(ada-stmt-add-to-ada-menu): Moved to ada-mode.el.
Juanma Barranquero <lekktu@gmail.com>
parents:
49598
diff
changeset
|
3 ;; Copyright(C) 1987, 93, 94, 96, 97, 98, 99, 2000 |
|
32301
0f1f7e931493
Fix header line, copyright notice.
Dave Love <fx@gnu.org>
parents:
30409
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
| 23868 | 5 |
|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
34400
diff
changeset
|
6 ;; This file is part of GNU Emacs. |
|
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
7 |
|
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
8 ;; Authors: Daniel Pfeiffer, Markus Heritsch, Rolf Ebert <ebert@waporo.muc.de> |
|
34400
a5fbe8c7b12d
Update `maintainer'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33823
diff
changeset
|
9 ;; Maintainer: Emmanuel Briot <briot@gnat.com> |
| 23868 | 10 ;; Keywords: languages, ada |
| 11 ;; Rolf Ebert's version: 2.26 | |
| 12 | |
| 13 ;;; Commentary: | |
|
44467
e34b692b2fa9
Menu changed from Statements to Templates.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
14 ;; This file is now automatically loaded from ada-mode.el, and creates a submenu |
|
e34b692b2fa9
Menu changed from Statements to Templates.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
15 ;; in Ada/ on the menu bar. |
| 23868 | 16 |
| 17 ;;; History: | |
| 18 | |
| 19 ;; Created May 1987. | |
| 20 ;; Original version from V. Bowman as in ada.el of Emacs-18 | |
| 21 ;; (borrowed heavily from Mick Jordan's Modula-2 package for GNU, | |
| 22 ;; as modified by Peter Robinson, Michael Schmidt, and Tom Perrine.) | |
| 23 ;; | |
| 24 ;; Sep 1993. Daniel Pfeiffer <pfeiffer@cict.fr> (DP) | |
| 25 ;; Introduced statement.el for smaller code and user configurability. | |
| 26 ;; | |
| 27 ;; Nov 1993. Rolf Ebert <ebert@enpc.fr> (RE) Moved the | |
| 28 ;; skeleton generation into this separate file. The code still is | |
| 29 ;; essentially written by DP | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47744
diff
changeset
|
30 ;; |
| 23868 | 31 ;; Adapted Jun 1994. Markus Heritsch |
| 32 ;; <Markus.Heritsch@studbox.uni-stuttgart.de> (MH) | |
| 33 ;; added menu bar support for templates | |
| 34 ;; | |
| 35 ;; 1994/12/02 Christian Egli <cegli@hcsd.hac.com> | |
| 36 ;; General cleanup and bug fixes. | |
| 37 ;; | |
| 38 ;; 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
|
39 ;; made it work with skeleton.el from Emacs-19.30. Several |
| 23868 | 40 ;; enhancements and bug fixes. |
| 41 | |
| 42 ;; BUGS: | |
| 43 ;;;> I have the following suggestions for the function template: 1) I | |
| 44 ;;;> don't want it automatically assigning it a name for the return variable. I | |
| 45 ;;;> never want it to be called "Result" because that is nondescriptive. If you | |
| 46 ;;;> must define a variable, give me the ability to specify its name. | |
| 47 ;;;> | |
| 48 ;;;> 2) You do not provide a type for variable 'Result'. Its type is the same | |
| 49 ;;;> as the function's return type, which the template knows, so why force me | |
| 50 ;;;> to type it in? | |
| 51 ;;;> | |
| 52 | |
| 53 ;;;It would be nice if one could configure such layout details separately | |
| 54 ;;;without patching the LISP code. Maybe the metalanguage used in ada-stmt.el | |
| 55 ;;;could be taken even further, providing the user with some nice syntax | |
| 56 ;;;for describing layout. Then my own hacks would survive the next | |
| 57 ;;;update of the package :-) | |
| 58 | |
| 59 | |
| 60 ;;; Code: | |
| 61 | |
|
50812
15929fed5553
(ada-xemacs): Variable removed, since it's better to use (featurep 'xemacs).
Juanma Barranquero <lekktu@gmail.com>
parents:
50739
diff
changeset
|
62 (require 'skeleton nil t) |
| 23868 | 63 (require 'easymenu) |
|
50812
15929fed5553
(ada-xemacs): Variable removed, since it's better to use (featurep 'xemacs).
Juanma Barranquero <lekktu@gmail.com>
parents:
50739
diff
changeset
|
64 (require 'ada-mode) |
| 23868 | 65 |
| 66 (defun ada-func-or-proc-name () | |
| 67 ;; Get the name of the current function or procedure." | |
| 68 (save-excursion | |
| 69 (let ((case-fold-search t)) | |
| 70 (if (re-search-backward ada-procedure-start-regexp nil t) | |
|
44467
e34b692b2fa9
Menu changed from Statements to Templates.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
71 (buffer-substring (match-beginning 3) (match-end 3)) |
| 23868 | 72 "NAME?")))) |
| 73 | |
| 74 ;;; ---- statement skeletons ------------------------------------------ | |
| 75 | |
| 76 (define-skeleton ada-array | |
| 26000 | 77 "Insert array type definition. |
|
26226
b63d041c9108
Changed format of years in copyright notices.
Gerd Moellmann <gerd@gnu.org>
parents:
26000
diff
changeset
|
78 Prompt for component type and index subtypes." |
| 23868 | 79 () |
| 80 "array (" ("index definition: " str ", " ) -2 ") of " _ ?\;) | |
| 81 | |
| 82 | |
| 83 (define-skeleton ada-case | |
| 26000 | 84 "Build skeleton case statement. |
| 85 Prompt for the selector expression. Also builds the first when clause." | |
| 23868 | 86 "[selector expression]: " |
| 87 "case " str " is" \n | |
| 88 > "when " ("discrete choice: " str " | ") -3 " =>" \n | |
| 89 > _ \n | |
| 90 < < "end case;") | |
| 91 | |
| 92 | |
| 93 (define-skeleton ada-when | |
| 94 "Start a case statement alternative with a when clause." | |
| 95 () | |
| 96 < "when " ("discrete choice: " str " | ") -3 " =>" \n | |
| 97 >) | |
| 98 | |
| 99 | |
| 100 (define-skeleton ada-declare-block | |
| 101 "Insert a block with a declare part. | |
| 102 Indent for the first declaration." | |
| 103 "[block name]: " | |
| 104 < str & ?: & \n | |
| 105 > "declare" \n | |
| 106 > _ \n | |
| 107 < "begin" \n | |
| 108 > \n | |
| 109 < "end " str | -1 ?\;) | |
| 110 | |
| 111 | |
| 112 (define-skeleton ada-exception-block | |
| 113 "Insert a block with an exception part. | |
| 114 Indent for the first line of code." | |
| 115 "[block name]: " | |
| 116 < str & ?: & \n | |
| 117 > "begin" \n | |
| 118 > _ \n | |
| 119 < "exception" \n | |
| 120 > \n | |
| 121 < "end " str | -1 ?\;) | |
| 122 | |
| 123 | |
| 124 (define-skeleton ada-exception | |
| 125 "Insert an indented exception part into a block." | |
| 126 () | |
| 127 < "exception" \n | |
| 128 >) | |
| 129 | |
| 130 | |
| 131 (define-skeleton ada-exit-1 | |
| 132 "Insert then exit condition of the exit statement, prompting for condition." | |
| 133 "[exit condition]: " | |
| 134 "when " str | -5) | |
| 135 | |
| 136 | |
| 137 (define-skeleton ada-exit | |
| 138 "Insert an exit statement, prompting for loop name and condition." | |
| 139 "[name of loop to exit]: " | |
|
44467
e34b692b2fa9
Menu changed from Statements to Templates.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
140 "exit " str & ?\ (ada-exit-1) | -1 ?\;) |
| 23868 | 141 |
|
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
142 ;;;###autoload |
| 23868 | 143 (defun ada-header () |
| 144 "Insert a descriptive header at the top of the file." | |
| 145 (interactive "*") | |
| 146 (save-excursion | |
| 147 (goto-char (point-min)) | |
| 148 (if (fboundp 'make-header) | |
|
30409
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
149 (funcall (symbol-function 'make-header)) |
| 23868 | 150 (ada-header-tmpl)))) |
| 151 | |
| 152 | |
| 153 (define-skeleton ada-header-tmpl | |
| 154 "Insert a comment block containing the module title, author, etc." | |
| 155 "[Description]: " | |
| 156 "-- -*- Mode: Ada -*-" | |
|
30409
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
157 "\n" ada-fill-comment-prefix "Filename : " (buffer-name) |
|
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
158 "\n" ada-fill-comment-prefix "Description : " str |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
159 "\n" ada-fill-comment-prefix "Author : " (user-full-name) |
|
30409
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
160 "\n" ada-fill-comment-prefix "Created On : " (current-time-string) |
|
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
161 "\n" ada-fill-comment-prefix "Last Modified By: ." |
|
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
162 "\n" ada-fill-comment-prefix "Last Modified On: ." |
|
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
163 "\n" ada-fill-comment-prefix "Update Count : 0" |
|
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
164 "\n" ada-fill-comment-prefix "Status : Unknown, Use with caution!" |
| 23868 | 165 "\n") |
| 166 | |
| 167 | |
| 168 (define-skeleton ada-display-comment | |
| 169 "Inserts three comment lines, making a display comment." | |
| 170 () | |
|
30409
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
171 "--\n" ada-fill-comment-prefix _ "\n--") |
| 23868 | 172 |
| 173 | |
| 174 (define-skeleton ada-if | |
| 175 "Insert skeleton if statment, prompting for a boolean-expression." | |
| 176 "[condition]: " | |
| 177 "if " str " then" \n | |
| 178 > _ \n | |
| 179 < "end if;") | |
| 180 | |
| 181 | |
| 182 (define-skeleton ada-elsif | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
183 "Add an elsif clause to an if statement, |
| 23868 | 184 prompting for the boolean-expression." |
| 185 "[condition]: " | |
| 186 < "elsif " str " then" \n | |
| 187 >) | |
| 188 | |
| 189 | |
| 190 (define-skeleton ada-else | |
| 191 "Add an else clause inside an if-then-end-if clause." | |
| 192 () | |
| 193 < "else" \n | |
| 194 >) | |
| 195 | |
| 196 | |
| 197 (define-skeleton ada-loop | |
| 198 "Insert a skeleton loop statement. The exit statement is added by hand." | |
| 199 "[loop name]: " | |
| 200 < str & ?: & \n | |
| 201 > "loop" \n | |
| 202 > _ \n | |
| 203 < "end loop " str | -1 ?\;) | |
| 204 | |
| 205 | |
| 206 (define-skeleton ada-for-loop-prompt-variable | |
| 207 "Prompt for the loop variable." | |
| 208 "[loop variable]: " | |
| 209 str) | |
| 210 | |
| 211 | |
| 212 (define-skeleton ada-for-loop-prompt-range | |
| 213 "Prompt for the loop range." | |
| 214 "[loop range]: " | |
| 215 str) | |
| 216 | |
| 217 | |
| 218 (define-skeleton ada-for-loop | |
| 219 "Build a skeleton for-loop statement, prompting for the loop parameters." | |
| 220 "[loop name]: " | |
| 221 < str & ?: & \n | |
| 222 > "for " | |
| 223 (ada-for-loop-prompt-variable) | |
| 224 " in " | |
| 225 (ada-for-loop-prompt-range) | |
| 226 " loop" \n | |
| 227 > _ \n | |
| 228 < "end loop " str | -1 ?\;) | |
| 229 | |
| 230 | |
| 231 (define-skeleton ada-while-loop-prompt-entry-condition | |
| 232 "Prompt for the loop entry condition." | |
| 233 "[entry condition]: " | |
| 234 str) | |
| 235 | |
| 236 | |
| 237 (define-skeleton ada-while-loop | |
| 238 "Insert a skeleton while loop statement." | |
| 239 "[loop name]: " | |
| 240 < str & ?: & \n | |
| 241 > "while " | |
| 242 (ada-while-loop-prompt-entry-condition) | |
| 243 " loop" \n | |
| 244 > _ \n | |
| 245 < "end loop " str | -1 ?\;) | |
| 246 | |
| 247 | |
| 248 (define-skeleton ada-package-spec | |
| 249 "Insert a skeleton package specification." | |
| 250 "[package name]: " | |
| 251 "package " str " is" \n | |
| 252 > _ \n | |
| 253 < "end " str ?\;) | |
| 254 | |
| 255 | |
| 256 (define-skeleton ada-package-body | |
| 257 "Insert a skeleton package body -- includes a begin statement." | |
| 258 "[package name]: " | |
| 259 "package body " str " is" \n | |
| 260 > _ \n | |
| 261 ; < "begin" \n | |
| 262 < "end " str ?\;) | |
| 263 | |
| 264 | |
| 265 (define-skeleton ada-private | |
| 266 "Undent and start a private section of a package spec. Reindent." | |
| 267 () | |
| 268 < "private" \n | |
| 269 >) | |
| 270 | |
| 271 | |
| 272 (define-skeleton ada-function-spec-prompt-return | |
| 273 "Prompts for function result type." | |
| 274 "[result type]: " | |
| 275 str) | |
| 276 | |
| 277 | |
| 278 (define-skeleton ada-function-spec | |
| 279 "Insert a function specification. Prompts for name and arguments." | |
| 280 "[function name]: " | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
281 "function " str |
| 23868 | 282 " (" ("[parameter_specification]: " str "; " ) -2 ")" |
| 283 " return " | |
| 284 (ada-function-spec-prompt-return) | |
| 285 ";" \n ) | |
| 286 | |
| 287 | |
| 288 (define-skeleton ada-procedure-spec | |
| 289 "Insert a procedure specification, prompting for its name and arguments." | |
| 290 "[procedure name]: " | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
291 "procedure " str |
| 23868 | 292 " (" ("[parameter_specification]: " str "; " ) -2 ")" |
| 293 ";" \n ) | |
| 294 | |
| 295 | |
| 296 (define-skeleton ada-subprogram-body | |
| 297 "Insert frame for subprogram body. | |
| 298 Invoke right after `ada-function-spec' or `ada-procedure-spec'." | |
| 299 () | |
| 300 ;; Remove `;' from subprogram decl | |
| 301 (save-excursion | |
|
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
302 (let ((pos (1+ (point)))) |
|
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
303 (ada-search-ignore-string-comment ada-subprog-start-re t nil) |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
304 (when (ada-search-ignore-string-comment "(" nil pos t 'search-forward) |
|
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
305 (backward-char 1) |
|
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
306 (forward-sexp 1))) |
| 23868 | 307 (if (looking-at ";") |
| 308 (delete-char 1))) | |
|
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
309 " is" \n |
|
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
310 _ \n |
|
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
311 < "begin" \n |
|
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
312 \n |
|
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
313 < "exception" \n |
|
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
314 "when others => null;" \n |
|
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
315 < < "end " |
| 23868 | 316 (ada-func-or-proc-name) |
|
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
317 ";" \n) |
| 23868 | 318 |
| 319 | |
| 320 (define-skeleton ada-separate | |
| 321 "Finish a body stub with `separate'." | |
| 322 () | |
| 323 > "separate;" \n | |
| 324 <) | |
| 325 | |
| 326 | |
| 327 ;(define-skeleton ada-with | |
| 328 ; "Inserts a with clause, prompting for the list of units depended upon." | |
| 329 ; "[list of units depended upon]: " | |
| 330 ; "with " str ?\;) | |
| 331 | |
| 332 ;(define-skeleton ada-use | |
| 333 ; "Inserts a use clause, prompting for the list of packages used." | |
| 334 ; "[list of packages used]: " | |
| 335 ; "use " str ?\;) | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47744
diff
changeset
|
336 |
| 23868 | 337 |
| 338 (define-skeleton ada-record | |
| 339 "Insert a skeleton record type declaration." | |
| 340 () | |
| 341 "record" \n | |
| 342 > _ \n | |
| 343 < "end record;") | |
| 344 | |
| 345 | |
| 346 (define-skeleton ada-subtype | |
| 347 "Start insertion of a subtype declaration, prompting for the subtype name." | |
| 348 "[subtype name]: " | |
| 349 "subtype " str " is " _ ?\; | |
| 350 (not (message "insert subtype indication."))) | |
| 351 | |
| 352 | |
| 353 (define-skeleton ada-type | |
| 354 "Start insertion of a type declaration, prompting for the type name." | |
| 355 "[type name]: " | |
| 356 "type " str ?\( | |
| 357 ("[discriminant specs]: " str " ") | |
| 358 | (backward-delete-char 1) | ?\) | |
| 359 " is " | |
| 360 (not (message "insert type definition."))) | |
| 361 | |
| 362 | |
| 363 (define-skeleton ada-task-body | |
| 364 "Insert a task body, prompting for the task name." | |
| 365 "[task name]: " | |
| 366 "task body " str " is\n" | |
| 367 "begin\n" | |
| 368 > _ \n | |
| 369 < "end " str ";" ) | |
| 370 | |
| 371 | |
| 372 (define-skeleton ada-task-spec | |
| 373 "Insert a task specification, prompting for the task name." | |
| 374 "[task name]: " | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
375 "task " str |
| 23868 | 376 " (" ("[discriminant]: " str "; ") ") is\n" |
| 377 > "entry " _ \n | |
| 378 <"end " str ";" ) | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47744
diff
changeset
|
379 |
| 23868 | 380 |
| 381 (define-skeleton ada-get-param1 | |
| 382 "Prompt for arguments and if any enclose them in brackets." | |
| 383 () | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
384 ("[parameter_specification]: " str "; " ) & -2 & ")") |
| 23868 | 385 |
| 386 | |
| 387 (define-skeleton ada-get-param | |
| 388 "Prompt for arguments and if any enclose them in brackets." | |
| 389 () | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
390 " (" |
|
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
391 (ada-get-param1) | -2) |
| 23868 | 392 |
| 393 | |
| 394 (define-skeleton ada-entry | |
| 395 "Insert a task entry, prompting for the entry name." | |
| 396 "[entry name]: " | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
397 "entry " str |
| 23868 | 398 (ada-get-param) |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
399 ";" \n) |
| 23868 | 400 |
| 401 | |
| 402 (define-skeleton ada-entry-family-prompt-discriminant | |
| 403 "Insert a entry specification, prompting for the entry name." | |
| 404 "[discriminant name]: " | |
| 405 str) | |
| 406 | |
| 407 | |
| 408 (define-skeleton ada-entry-family | |
| 409 "Insert a entry specification, prompting for the entry name." | |
| 410 "[entry name]: " | |
| 411 "entry " str | |
| 412 " (" (ada-entry-family-prompt-discriminant) ")" | |
| 413 (ada-get-param) | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
414 ";" \n) |
| 23868 | 415 |
| 416 | |
| 417 (define-skeleton ada-select | |
| 418 "Insert a select block." | |
| 419 () | |
| 420 "select\n" | |
| 421 > _ \n | |
| 422 < "end select;") | |
| 423 | |
| 424 | |
| 425 (define-skeleton ada-accept-1 | |
| 426 "Insert a condition statement, prompting for the condition name." | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
427 "[condition]: " |
| 23868 | 428 "when " str | -5 ) |
| 429 | |
| 430 | |
| 431 (define-skeleton ada-accept-2 | |
| 432 "Insert an accept statement, prompting for the name and arguments." | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
433 "[accept name]: " |
|
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
434 > "accept " str |
| 23868 | 435 (ada-get-param) |
| 436 " do" \n | |
| 437 > _ \n | |
| 438 < "end " str ";" ) | |
| 439 | |
| 440 | |
| 441 (define-skeleton ada-accept | |
| 442 "Insert an accept statement (prompt for condition, name and arguments)." | |
| 443 () | |
| 444 > (ada-accept-1) & " =>\n" | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
445 (ada-accept-2)) |
| 23868 | 446 |
| 447 | |
| 448 (define-skeleton ada-or-accept | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
449 "Insert an or statement, prompting for the condition name." |
| 23868 | 450 () |
| 451 < "or\n" | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
452 (ada-accept)) |
| 23868 | 453 |
| 454 | |
| 455 (define-skeleton ada-or-delay | |
| 456 "Insert a delay statement, prompting for the delay value." | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
457 "[delay value]: " |
| 23868 | 458 < "or\n" |
| 459 > "delay " str ";") | |
|
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47744
diff
changeset
|
460 |
| 23868 | 461 |
| 462 (define-skeleton ada-or-terminate | |
| 463 "Insert a terminate statement." | |
| 464 () | |
| 465 < "or\n" | |
| 466 > "terminate;") | |
| 467 | |
| 468 | |
| 469 (defun ada-adjust-case-skeleton () | |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
470 "Adjust the case of the text inserted by a skeleton." |
|
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
471 (save-excursion |
| 23868 | 472 (let ((aa-end (point))) |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
473 (ada-adjust-case-region |
|
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
474 (progn (goto-char (symbol-value 'beg)) (forward-word -1) (point)) |
|
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
475 (goto-char aa-end))))) |
|
30409
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
476 |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
477 (defun ada-stmt-mode-hook () |
|
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
478 (set (make-local-variable 'skeleton-further-elements) |
|
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
479 '((< '(backward-delete-char-untabify |
|
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
480 (min ada-indent (current-column)))))) |
|
50739
fbec4e6f73c8
(ada-stmt-add-to-ada-menu): Moved to ada-mode.el.
Juanma Barranquero <lekktu@gmail.com>
parents:
49598
diff
changeset
|
481 (add-hook 'skeleton-end-hook 'ada-adjust-case-skeleton nil t)) |
| 23868 | 482 |
|
33823
d29063c1c480
(ada-template-map): Initialize and bind it to C-c t in ada-mode-map.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32301
diff
changeset
|
483 (add-hook 'ada-mode-hook 'ada-stmt-mode-hook) |
|
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
484 |
| 23868 | 485 (provide 'ada-stmt) |
| 486 | |
| 52401 | 487 ;;; arch-tag: 94f51555-cc0e-44e5-8865-8788aae8ecd3 |
| 23868 | 488 ;;; ada-stmt.el ends here |
