diff options
| author | Karl Heuer | 1998-12-14 03:18:06 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-12-14 03:18:06 +0000 |
| commit | fb98fa17e403a5e30d219cc17842d981f667ddbf (patch) | |
| tree | 2cbb6b5b96316b98c4df717a0c0ecb071670fde6 | |
| parent | ae212837e69553ef7a6dcf072911de9d0881927a (diff) | |
| download | emacs-fb98fa17e403a5e30d219cc17842d981f667ddbf.tar.gz emacs-fb98fa17e403a5e30d219cc17842d981f667ddbf.zip | |
Initial revision
| -rw-r--r-- | lisp/progmodes/ada-stmt.el | 640 |
1 files changed, 640 insertions, 0 deletions
diff --git a/lisp/progmodes/ada-stmt.el b/lisp/progmodes/ada-stmt.el new file mode 100644 index 00000000000..8bf50cfb096 --- /dev/null +++ b/lisp/progmodes/ada-stmt.el | |||
| @@ -0,0 +1,640 @@ | |||
| 1 | ;;; ada-stmt.el - An extension to Ada mode for inserting statement templates. | ||
| 2 | |||
| 3 | ;; Copyright (C) 1987, 1993, 1994, 1996, 1997 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Authors: Daniel Pfeiffer, Markus Heritsch, Rolf Ebert <ebert@waporo.muc.de> | ||
| 6 | ;; Maintainer: Rolf Ebert <ebert@waporo.muc.de> | ||
| 7 | ;; Keywords: languages, ada | ||
| 8 | ;; Rolf Ebert's version: 2.26 | ||
| 9 | |||
| 10 | ;;; Commentary: | ||
| 11 | |||
| 12 | ;; | ||
| 13 | ;; put the following statement in your .emacs: | ||
| 14 | ;; (require 'ada-stmt) | ||
| 15 | ;; | ||
| 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 | ||
| 30 | ;; | ||
| 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> | ||
| 39 | ;; made it work with skeleton.el from emacs-19.30. Several | ||
| 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 | |||
| 62 | (require 'ada-mode) | ||
| 63 | (require 'skeleton) | ||
| 64 | (require 'easymenu) | ||
| 65 | |||
| 66 | (defgroup ada-stmt nil | ||
| 67 | "Extension to Ada mode for inserting statement templates" | ||
| 68 | :group 'ada) | ||
| 69 | |||
| 70 | (defcustom ada-stmt-use-debug t | ||
| 71 | "*Toggle to insert ada debug code parts." | ||
| 72 | :type 'boolean | ||
| 73 | :group 'ada-stmt) | ||
| 74 | |||
| 75 | |||
| 76 | (defcustom ada-debug-call-str "pragma Debug (%s);" | ||
| 77 | "*Debug call code to insert." | ||
| 78 | :type 'string | ||
| 79 | :group 'ada-stmt) | ||
| 80 | |||
| 81 | |||
| 82 | (defcustom ada-debug-exception-str "pragma Debug (%s);" | ||
| 83 | "*Debug exception code to insert." | ||
| 84 | :type 'string | ||
| 85 | :group 'ada-stmt) | ||
| 86 | |||
| 87 | |||
| 88 | |||
| 89 | (defun ada-func-or-proc-name () | ||
| 90 | ;; Get the name of the current function or procedure." | ||
| 91 | (save-excursion | ||
| 92 | (let ((case-fold-search t)) | ||
| 93 | (if (re-search-backward ada-procedure-start-regexp nil t) | ||
| 94 | (buffer-substring (match-beginning 2) (match-end 2)) | ||
| 95 | "NAME?")))) | ||
| 96 | |||
| 97 | |||
| 98 | (defun ada-toggle-debugging () | ||
| 99 | "Toggles behaviour of `ada-debug-info-insertion'." | ||
| 100 | (interactive) | ||
| 101 | (setq ada-stmt-use-debug (not ada-stmt-use-debug)) | ||
| 102 | (if ada-stmt-use-debug | ||
| 103 | (message "Debugging enabled") | ||
| 104 | (message "Debugging disabled"))) | ||
| 105 | |||
| 106 | |||
| 107 | (defvar ada-template-map nil | ||
| 108 | "Keymap used in Ada mode for smart template operations.") | ||
| 109 | |||
| 110 | |||
| 111 | (let ((ada-mp (make-sparse-keymap))) | ||
| 112 | (define-key ada-mp "h" 'ada-header) | ||
| 113 | ; (define-key ada-mp "p" 'ada-toggle-prompt-pseudo) | ||
| 114 | (define-key ada-mp "(" 'insert-parentheses) | ||
| 115 | (define-key ada-mp "\C-a" 'ada-array) | ||
| 116 | (define-key ada-mp "b" 'ada-exception-block) | ||
| 117 | (define-key ada-mp "d" 'ada-declare-block) | ||
| 118 | (define-key ada-mp "c" 'ada-case) | ||
| 119 | (define-key ada-mp "\C-e" 'ada-elsif) | ||
| 120 | (define-key ada-mp "e" 'ada-else) | ||
| 121 | (define-key ada-mp "\C-k" 'ada-package-spec) | ||
| 122 | (define-key ada-mp "k" 'ada-package-body) | ||
| 123 | (define-key ada-mp "\C-p" 'ada-procedure-spec) | ||
| 124 | (define-key ada-mp "\C-f" 'ada-function-spec) | ||
| 125 | (define-key ada-mp "p" 'ada-subprogram-body) | ||
| 126 | (define-key ada-mp "f" 'ada-for-loop) | ||
| 127 | (define-key ada-mp "i" 'ada-if) | ||
| 128 | (define-key ada-mp "l" 'ada-loop) | ||
| 129 | (define-key ada-mp "\C-r" 'ada-record) | ||
| 130 | (define-key ada-mp "\C-s" 'ada-subtype) | ||
| 131 | (define-key ada-mp "S" 'ada-tabsize) | ||
| 132 | (define-key ada-mp "\C-t" 'ada-task-spec) | ||
| 133 | (define-key ada-mp "t" 'ada-task-body) | ||
| 134 | (define-key ada-mp "\C-y" 'ada-type) | ||
| 135 | (define-key ada-mp "\C-v" 'ada-private) | ||
| 136 | (define-key ada-mp "u" 'ada-use) | ||
| 137 | (define-key ada-mp "\C-u" 'ada-with) | ||
| 138 | (define-key ada-mp "\C-w" 'ada-when) | ||
| 139 | (define-key ada-mp "w" 'ada-while-loop) | ||
| 140 | (define-key ada-mp "\C-x" 'ada-exception) | ||
| 141 | (define-key ada-mp "x" 'ada-exit) | ||
| 142 | (setq ada-template-map ada-mp)) | ||
| 143 | |||
| 144 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 145 | ;; Place the templates into Ada Mode. They may be inserted under any key. | ||
| 146 | ;; C-c C-t will be the default. If you use templates alot, you | ||
| 147 | ;; may want to consider moving the binding to another key in your .emacs | ||
| 148 | ;; file. Be sure to (require 'ada-stmt) first. | ||
| 149 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 150 | ;(define-key ada-mode-map "\C-ct" ada-template-map) | ||
| 151 | (define-key ada-mode-map "\C-c\C-t" ada-template-map) | ||
| 152 | |||
| 153 | ;;; ---- statement skeletons ------------------------------------------ | ||
| 154 | |||
| 155 | (define-skeleton ada-array | ||
| 156 | "Insert array type definition. Uses the minibuffer to prompt | ||
| 157 | for component type and index subtypes." | ||
| 158 | () | ||
| 159 | "array (" ("index definition: " str ", " ) -2 ") of " _ ?\;) | ||
| 160 | |||
| 161 | |||
| 162 | (define-skeleton ada-case | ||
| 163 | "Build skeleton case statement, prompting for the selector expression. | ||
| 164 | Also builds the first when clause." | ||
| 165 | "[selector expression]: " | ||
| 166 | "case " str " is" \n | ||
| 167 | > "when " ("discrete choice: " str " | ") -3 " =>" \n | ||
| 168 | > _ \n | ||
| 169 | < < "end case;") | ||
| 170 | |||
| 171 | |||
| 172 | (define-skeleton ada-when | ||
| 173 | "Start a case statement alternative with a when clause." | ||
| 174 | () | ||
| 175 | < "when " ("discrete choice: " str " | ") -3 " =>" \n | ||
| 176 | >) | ||
| 177 | |||
| 178 | |||
| 179 | (define-skeleton ada-declare-block | ||
| 180 | "Insert a block with a declare part. | ||
| 181 | Indent for the first declaration." | ||
| 182 | "[block name]: " | ||
| 183 | < str & ?: & \n | ||
| 184 | > "declare" \n | ||
| 185 | > _ \n | ||
| 186 | < "begin" \n | ||
| 187 | > \n | ||
| 188 | < "end " str | -1 ?\;) | ||
| 189 | |||
| 190 | |||
| 191 | (define-skeleton ada-exception-block | ||
| 192 | "Insert a block with an exception part. | ||
| 193 | Indent for the first line of code." | ||
| 194 | "[block name]: " | ||
| 195 | < str & ?: & \n | ||
| 196 | > "begin" \n | ||
| 197 | > _ \n | ||
| 198 | < "exception" \n | ||
| 199 | > \n | ||
| 200 | < "end " str | -1 ?\;) | ||
| 201 | |||
| 202 | |||
| 203 | (define-skeleton ada-exception | ||
| 204 | "Insert an indented exception part into a block." | ||
| 205 | () | ||
| 206 | < "exception" \n | ||
| 207 | >) | ||
| 208 | |||
| 209 | |||
| 210 | (define-skeleton ada-exit-1 | ||
| 211 | "Insert then exit condition of the exit statement, prompting for condition." | ||
| 212 | "[exit condition]: " | ||
| 213 | "when " str | -5) | ||
| 214 | |||
| 215 | |||
| 216 | (define-skeleton ada-exit | ||
| 217 | "Insert an exit statement, prompting for loop name and condition." | ||
| 218 | "[name of loop to exit]: " | ||
| 219 | "exit " str & ?\ | ||
| 220 | (ada-exit-1) | ||
| 221 | | -1 ?\;) | ||
| 222 | |||
| 223 | |||
| 224 | (defun ada-header () | ||
| 225 | "Insert a descriptive header at the top of the file." | ||
| 226 | (interactive "*") | ||
| 227 | (save-excursion | ||
| 228 | (goto-char (point-min)) | ||
| 229 | (if (fboundp 'make-header) | ||
| 230 | (make-header) | ||
| 231 | (ada-header-tmpl)))) | ||
| 232 | |||
| 233 | |||
| 234 | (define-skeleton ada-header-tmpl | ||
| 235 | "Insert a comment block containing the module title, author, etc." | ||
| 236 | "[Description]: " | ||
| 237 | "-- -*- Mode: Ada -*-" | ||
| 238 | "\n-- Filename : " (buffer-name) | ||
| 239 | "\n-- Description : " str | ||
| 240 | "\n-- Author : " (user-full-name) | ||
| 241 | "\n-- Created On : " (current-time-string) | ||
| 242 | "\n-- Last Modified By: ." | ||
| 243 | "\n-- Last Modified On: ." | ||
| 244 | "\n-- Update Count : 0" | ||
| 245 | "\n-- Status : Unknown, Use with caution!" | ||
| 246 | "\n") | ||
| 247 | |||
| 248 | |||
| 249 | (define-skeleton ada-display-comment | ||
| 250 | "Inserts three comment lines, making a display comment." | ||
| 251 | () | ||
| 252 | "--\n-- " _ "\n--") | ||
| 253 | |||
| 254 | |||
| 255 | (define-skeleton ada-if | ||
| 256 | "Insert skeleton if statment, prompting for a boolean-expression." | ||
| 257 | "[condition]: " | ||
| 258 | "if " str " then" \n | ||
| 259 | > _ \n | ||
| 260 | < "end if;") | ||
| 261 | |||
| 262 | |||
| 263 | (define-skeleton ada-elsif | ||
| 264 | "Add an elsif clause to an if statement, | ||
| 265 | prompting for the boolean-expression." | ||
| 266 | "[condition]: " | ||
| 267 | < "elsif " str " then" \n | ||
| 268 | >) | ||
| 269 | |||
| 270 | |||
| 271 | (define-skeleton ada-else | ||
| 272 | "Add an else clause inside an if-then-end-if clause." | ||
| 273 | () | ||
| 274 | < "else" \n | ||
| 275 | >) | ||
| 276 | |||
| 277 | |||
| 278 | (define-skeleton ada-loop | ||
| 279 | "Insert a skeleton loop statement. The exit statement is added by hand." | ||
| 280 | "[loop name]: " | ||
| 281 | < str & ?: & \n | ||
| 282 | > "loop" \n | ||
| 283 | > _ \n | ||
| 284 | < "end loop " str | -1 ?\;) | ||
| 285 | |||
| 286 | |||
| 287 | (define-skeleton ada-for-loop-prompt-variable | ||
| 288 | "Prompt for the loop variable." | ||
| 289 | "[loop variable]: " | ||
| 290 | str) | ||
| 291 | |||
| 292 | |||
| 293 | (define-skeleton ada-for-loop-prompt-range | ||
| 294 | "Prompt for the loop range." | ||
| 295 | "[loop range]: " | ||
| 296 | str) | ||
| 297 | |||
| 298 | |||
| 299 | (define-skeleton ada-for-loop | ||
| 300 | "Build a skeleton for-loop statement, prompting for the loop parameters." | ||
| 301 | "[loop name]: " | ||
| 302 | < str & ?: & \n | ||
| 303 | > "for " | ||
| 304 | (ada-for-loop-prompt-variable) | ||
| 305 | " in " | ||
| 306 | (ada-for-loop-prompt-range) | ||
| 307 | " loop" \n | ||
| 308 | > _ \n | ||
| 309 | < "end loop " str | -1 ?\;) | ||
| 310 | |||
| 311 | |||
| 312 | (define-skeleton ada-while-loop-prompt-entry-condition | ||
| 313 | "Prompt for the loop entry condition." | ||
| 314 | "[entry condition]: " | ||
| 315 | str) | ||
| 316 | |||
| 317 | |||
| 318 | (define-skeleton ada-while-loop | ||
| 319 | "Insert a skeleton while loop statement." | ||
| 320 | "[loop name]: " | ||
| 321 | < str & ?: & \n | ||
| 322 | > "while " | ||
| 323 | (ada-while-loop-prompt-entry-condition) | ||
| 324 | " loop" \n | ||
| 325 | > _ \n | ||
| 326 | < "end loop " str | -1 ?\;) | ||
| 327 | |||
| 328 | |||
| 329 | (define-skeleton ada-package-spec | ||
| 330 | "Insert a skeleton package specification." | ||
| 331 | "[package name]: " | ||
| 332 | "package " str " is" \n | ||
| 333 | > _ \n | ||
| 334 | < "end " str ?\;) | ||
| 335 | |||
| 336 | |||
| 337 | (define-skeleton ada-package-body | ||
| 338 | "Insert a skeleton package body -- includes a begin statement." | ||
| 339 | "[package name]: " | ||
| 340 | "package body " str " is" \n | ||
| 341 | > _ \n | ||
| 342 | ; < "begin" \n | ||
| 343 | < "end " str ?\;) | ||
| 344 | |||
| 345 | |||
| 346 | (define-skeleton ada-private | ||
| 347 | "Undent and start a private section of a package spec. Reindent." | ||
| 348 | () | ||
| 349 | < "private" \n | ||
| 350 | >) | ||
| 351 | |||
| 352 | |||
| 353 | (define-skeleton ada-function-spec-prompt-return | ||
| 354 | "Prompts for function result type." | ||
| 355 | "[result type]: " | ||
| 356 | str) | ||
| 357 | |||
| 358 | |||
| 359 | (define-skeleton ada-function-spec | ||
| 360 | "Insert a function specification. Prompts for name and arguments." | ||
| 361 | "[function name]: " | ||
| 362 | "function " str | ||
| 363 | " (" ("[parameter_specification]: " str "; " ) -2 ")" | ||
| 364 | " return " | ||
| 365 | (ada-function-spec-prompt-return) | ||
| 366 | ";" \n ) | ||
| 367 | |||
| 368 | |||
| 369 | (define-skeleton ada-procedure-spec | ||
| 370 | "Insert a procedure specification, prompting for its name and arguments." | ||
| 371 | "[procedure name]: " | ||
| 372 | "procedure " str | ||
| 373 | " (" ("[parameter_specification]: " str "; " ) -2 ")" | ||
| 374 | ";" \n ) | ||
| 375 | |||
| 376 | |||
| 377 | (define-skeleton ada-subprogram-body | ||
| 378 | "Insert frame for subprogram body. | ||
| 379 | Invoke right after `ada-function-spec' or `ada-procedure-spec'." | ||
| 380 | () | ||
| 381 | ;; Remove `;' from subprogram decl | ||
| 382 | (save-excursion | ||
| 383 | (ada-search-ignore-string-comment ada-subprog-start-re t nil) | ||
| 384 | (ada-search-ignore-string-comment "(" nil nil t) | ||
| 385 | (backward-char 1) | ||
| 386 | (forward-sexp 1) | ||
| 387 | (if (looking-at ";") | ||
| 388 | (delete-char 1))) | ||
| 389 | < "is" \n | ||
| 390 | > _ \n | ||
| 391 | < "begin" \n | ||
| 392 | > (if ada-stmt-use-debug | ||
| 393 | (format ada-debug-call-str (ada-func-or-proc-name))) \n | ||
| 394 | > \n | ||
| 395 | < (if ada-stmt-use-debug | ||
| 396 | "exception") & \n | ||
| 397 | > (if ada-stmt-use-debug | ||
| 398 | "when others =>") & \n | ||
| 399 | > (if ada-stmt-use-debug | ||
| 400 | (format ada-debug-exception-str (ada-func-or-proc-name))) \n | ||
| 401 | < < "end " | ||
| 402 | (ada-func-or-proc-name) | ||
| 403 | ?\;) | ||
| 404 | |||
| 405 | |||
| 406 | (define-skeleton ada-separate | ||
| 407 | "Finish a body stub with `separate'." | ||
| 408 | () | ||
| 409 | > "separate;" \n | ||
| 410 | <) | ||
| 411 | |||
| 412 | |||
| 413 | ;(define-skeleton ada-with | ||
| 414 | ; "Inserts a with clause, prompting for the list of units depended upon." | ||
| 415 | ; "[list of units depended upon]: " | ||
| 416 | ; "with " str ?\;) | ||
| 417 | |||
| 418 | ;(define-skeleton ada-use | ||
| 419 | ; "Inserts a use clause, prompting for the list of packages used." | ||
| 420 | ; "[list of packages used]: " | ||
| 421 | ; "use " str ?\;) | ||
| 422 | |||
| 423 | |||
| 424 | (define-skeleton ada-record | ||
| 425 | "Insert a skeleton record type declaration." | ||
| 426 | () | ||
| 427 | "record" \n | ||
| 428 | > _ \n | ||
| 429 | < "end record;") | ||
| 430 | |||
| 431 | |||
| 432 | (define-skeleton ada-subtype | ||
| 433 | "Start insertion of a subtype declaration, prompting for the subtype name." | ||
| 434 | "[subtype name]: " | ||
| 435 | "subtype " str " is " _ ?\; | ||
| 436 | (not (message "insert subtype indication."))) | ||
| 437 | |||
| 438 | |||
| 439 | (define-skeleton ada-type | ||
| 440 | "Start insertion of a type declaration, prompting for the type name." | ||
| 441 | "[type name]: " | ||
| 442 | "type " str ?\( | ||
| 443 | ("[discriminant specs]: " str " ") | ||
| 444 | | (backward-delete-char 1) | ?\) | ||
| 445 | " is " | ||
| 446 | (not (message "insert type definition."))) | ||
| 447 | |||
| 448 | |||
| 449 | (define-skeleton ada-task-body | ||
| 450 | "Insert a task body, prompting for the task name." | ||
| 451 | "[task name]: " | ||
| 452 | "task body " str " is\n" | ||
| 453 | "begin\n" | ||
| 454 | > _ \n | ||
| 455 | < "end " str ";" ) | ||
| 456 | |||
| 457 | |||
| 458 | (define-skeleton ada-task-spec | ||
| 459 | "Insert a task specification, prompting for the task name." | ||
| 460 | "[task name]: " | ||
| 461 | "task " str | ||
| 462 | " (" ("[discriminant]: " str "; ") ") is\n" | ||
| 463 | > "entry " _ \n | ||
| 464 | <"end " str ";" ) | ||
| 465 | |||
| 466 | |||
| 467 | (define-skeleton ada-get-param1 | ||
| 468 | "Prompt for arguments and if any enclose them in brackets." | ||
| 469 | () | ||
| 470 | ("[parameter_specification]: " str "; " ) & -2 & ")" | ||
| 471 | ) | ||
| 472 | |||
| 473 | |||
| 474 | (define-skeleton ada-get-param | ||
| 475 | "Prompt for arguments and if any enclose them in brackets." | ||
| 476 | () | ||
| 477 | " (" | ||
| 478 | (ada-get-param1) | -2 | ||
| 479 | ) | ||
| 480 | |||
| 481 | |||
| 482 | (define-skeleton ada-entry | ||
| 483 | "Insert a task entry, prompting for the entry name." | ||
| 484 | "[entry name]: " | ||
| 485 | "entry " str | ||
| 486 | (ada-get-param) | ||
| 487 | ";" \n | ||
| 488 | ; (ada-indent-current) | ||
| 489 | ) | ||
| 490 | |||
| 491 | |||
| 492 | (define-skeleton ada-entry-family-prompt-discriminant | ||
| 493 | "Insert a entry specification, prompting for the entry name." | ||
| 494 | "[discriminant name]: " | ||
| 495 | str) | ||
| 496 | |||
| 497 | |||
| 498 | (define-skeleton ada-entry-family | ||
| 499 | "Insert a entry specification, prompting for the entry name." | ||
| 500 | "[entry name]: " | ||
| 501 | "entry " str | ||
| 502 | " (" (ada-entry-family-prompt-discriminant) ")" | ||
| 503 | (ada-get-param) | ||
| 504 | ";" \n | ||
| 505 | ;(ada-indent-current) | ||
| 506 | ) | ||
| 507 | |||
| 508 | |||
| 509 | (define-skeleton ada-select | ||
| 510 | "Insert a select block." | ||
| 511 | () | ||
| 512 | "select\n" | ||
| 513 | > _ \n | ||
| 514 | < "end select;") | ||
| 515 | |||
| 516 | |||
| 517 | (define-skeleton ada-accept-1 | ||
| 518 | "Insert a condition statement, prompting for the condition name." | ||
| 519 | "[condition]: " | ||
| 520 | "when " str | -5 ) | ||
| 521 | |||
| 522 | |||
| 523 | (define-skeleton ada-accept-2 | ||
| 524 | "Insert an accept statement, prompting for the name and arguments." | ||
| 525 | "[accept name]: " | ||
| 526 | > "accept " str | ||
| 527 | (ada-get-param) | ||
| 528 | ; " (" ("[parameter_specification]: " str "; ") -2 ")" | ||
| 529 | " do" \n | ||
| 530 | > _ \n | ||
| 531 | < "end " str ";" ) | ||
| 532 | |||
| 533 | |||
| 534 | (define-skeleton ada-accept | ||
| 535 | "Insert an accept statement (prompt for condition, name and arguments)." | ||
| 536 | () | ||
| 537 | > (ada-accept-1) & " =>\n" | ||
| 538 | (ada-accept-2) | ||
| 539 | ) | ||
| 540 | |||
| 541 | |||
| 542 | (define-skeleton ada-or-accept | ||
| 543 | "Insert a or statement, prompting for the condition name." | ||
| 544 | () | ||
| 545 | < "or\n" | ||
| 546 | (ada-accept) | ||
| 547 | ) | ||
| 548 | |||
| 549 | |||
| 550 | (define-skeleton ada-or-delay | ||
| 551 | "Insert a delay statement, prompting for the delay value." | ||
| 552 | "[delay value]: " | ||
| 553 | < "or\n" | ||
| 554 | > "delay " str ";") | ||
| 555 | |||
| 556 | |||
| 557 | (define-skeleton ada-or-terminate | ||
| 558 | "Insert a terminate statement." | ||
| 559 | () | ||
| 560 | < "or\n" | ||
| 561 | > "terminate;") | ||
| 562 | |||
| 563 | |||
| 564 | ;; ---- | ||
| 565 | (defun ada-adjust-case-skeleton () | ||
| 566 | "Adjusts the case of the text inserted by a skeleton." | ||
| 567 | (save-excursion | ||
| 568 | (let ((aa-end (point))) | ||
| 569 | (ada-adjust-case-region | ||
| 570 | (progn (goto-char beg) (forward-word -1) (point)) | ||
| 571 | (goto-char aa-end)) | ||
| 572 | ))) | ||
| 573 | |||
| 574 | |||
| 575 | ;; ---- add menu 'Statements' in Ada mode (MH) | ||
| 576 | (defun ada-add-statement-menu () | ||
| 577 | "Adds the menu 'Statements' to the menu bar in Ada mode." | ||
| 578 | (easy-menu-define ada-stmt-menu ada-mode-map | ||
| 579 | "Menu for statement templates in Ada." | ||
| 580 | '("Statements" | ||
| 581 | ; ["Toggle Prompt/Pseudo Code" toggle-skeleton-no-prompt t] | ||
| 582 | ["Toggle: Debugging" ada-toggle-debugging t] | ||
| 583 | ; ["-------" nil nil] | ||
| 584 | ["Header" (ada-header) t] | ||
| 585 | ["-------" nil nil] | ||
| 586 | ["package Body" (ada-package-body) t] | ||
| 587 | ["package Spec" (ada-package-spec) t] | ||
| 588 | ["function Spec" (ada-function-spec) t] | ||
| 589 | ["procedure Spec" (ada-procedure-spec) t] | ||
| 590 | ["proc/func Body" (ada-subprogram-body) t] | ||
| 591 | ["task Body" (ada-task-body) t] | ||
| 592 | ["task Spec" (ada-task-spec) t] | ||
| 593 | ["declare Block" (ada-declare-block) t] | ||
| 594 | ["exception Block" (ada-exception-block) t] | ||
| 595 | ["------" nil nil] | ||
| 596 | ["entry" (ada-entry) t] | ||
| 597 | ["entry family" (ada-entry-family) t] | ||
| 598 | ["select" (ada-select) t] | ||
| 599 | ["accept" (ada-accept) t] | ||
| 600 | ["or accept" (ada-or-accept) t] | ||
| 601 | ["or delay" (ada-or-delay) t] | ||
| 602 | ["or terminate" (ada-or-terminate) t] | ||
| 603 | ["-----" nil nil] | ||
| 604 | ["type" (ada-type) t] | ||
| 605 | ["private" (ada-private) t] | ||
| 606 | ["subtype" (ada-subtype) t] | ||
| 607 | ["record" (ada-record) t] | ||
| 608 | ["array" (ada-array) t] | ||
| 609 | ["------" nil nil] | ||
| 610 | ["if" (ada-if) t] | ||
| 611 | ["else" (ada-else) t] | ||
| 612 | ["elsif" (ada-elsif) t] | ||
| 613 | ["case" (ada-case) t] | ||
| 614 | ["-----" nil nil] | ||
| 615 | ["while Loop" (ada-while-loop) t] | ||
| 616 | ["for Loop" (ada-for-loop) t] | ||
| 617 | ["loop" (ada-loop) t] | ||
| 618 | ["---" nil nil] | ||
| 619 | ["exception" (ada-exception) t] | ||
| 620 | ["exit" (ada-exit) t] | ||
| 621 | ["when" (ada-when) t] | ||
| 622 | )) | ||
| 623 | (if (ada-xemacs) | ||
| 624 | (progn | ||
| 625 | (easy-menu-add ada-stmt-menu) | ||
| 626 | (setq mode-popup-menu (cons "Ada Mode" ada-stmt-menu))))) | ||
| 627 | |||
| 628 | |||
| 629 | |||
| 630 | (add-hook 'ada-mode-hook 'ada-add-statement-menu) | ||
| 631 | (add-hook 'ada-mode-hook '(lambda () | ||
| 632 | (setq skeleton-further-elements | ||
| 633 | '((< '(backward-delete-char-untabify | ||
| 634 | (min ada-indent (current-column)))))) | ||
| 635 | (add-hook 'skeleton-end-hook | ||
| 636 | 'ada-adjust-case-skeleton))) | ||
| 637 | |||
| 638 | (provide 'ada-stmt) | ||
| 639 | |||
| 640 | ;;; ada-stmt.el ends here | ||