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