Mercurial > emacs
annotate lisp/progmodes/ada-stmt.el @ 30583:c7e7209535ae
(Highlight Interactively): Document the hi-lock mode.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 04 Aug 2000 06:06:05 +0000 |
parents | a530830f8a3d |
children | 0f1f7e931493 |
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 |
30409
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
5 ;; Ada Core Technologies's version: $Revision: 1.16 $ |
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))) |
30409
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
67 |
23868 | 68 (require 'easymenu) |
69 | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
70 (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
|
71 "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
|
72 (interactive) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
73 (let ((menu '(["Header" ada-header t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
74 ["-" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
75 ["Package Body" ada-package-body t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
76 ["Package Spec" ada-package-spec t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
77 ["Function Spec" ada-function-spec t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
78 ["Procedure Spec" ada-procedure-spec t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
79 ["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
|
80 ["Task Body" ada-task-body t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
81 ["Task Spec" ada-task-spec t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
82 ["Declare Block" ada-declare-block t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
83 ["Exception Block" ada-exception-block t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
84 ["--" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
85 ["Entry" ada-entry t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
86 ["Entry family" ada-entry-family t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
87 ["Select" ada-select t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
88 ["Accept" ada-accept t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
89 ["Or accept" ada-or-accep t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
90 ["Or delay" ada-or-delay t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
91 ["Or terminate" ada-or-terminate t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
92 ["---" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
93 ["Type" ada-type t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
94 ["Private" ada-private t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
95 ["Subtype" ada-subtype t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
96 ["Record" ada-record t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
97 ["Array" ada-array t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
98 ["----" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
99 ["If" ada-if t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
100 ["Else" ada-else t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
101 ["Elsif" ada-elsif t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
102 ["Case" ada-case t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
103 ["-----" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
104 ["While Loop" ada-while-loop t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
105 ["For Loop" ada-for-loop t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
106 ["Loop" ada-loop t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
107 ["------" nil nil] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
108 ["Exception" ada-exception t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
109 ["Exit" ada-exit t] |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
110 ["When" ada-when t]))) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
111 (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
|
112 (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
|
113 '("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
|
114 :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
|
115 menu)) |
23868 | 116 |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
117 (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
|
118 (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
|
119 "Statements" |
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
120 (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
|
121 :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
|
122 t)) |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
123 )) |
23868 | 124 |
125 | |
126 | |
127 | |
128 (defun ada-func-or-proc-name () | |
129 ;; Get the name of the current function or procedure." | |
130 (save-excursion | |
131 (let ((case-fold-search t)) | |
132 (if (re-search-backward ada-procedure-start-regexp nil t) | |
133 (buffer-substring (match-beginning 2) (match-end 2)) | |
134 "NAME?")))) | |
135 | |
136 (defvar ada-template-map nil | |
137 "Keymap used in Ada mode for smart template operations.") | |
138 | |
25902
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-cth" 'ada-header) |
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-a" 'ada-array) |
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-ctb" 'ada-exception-block) |
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-ctd" 'ada-declare-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-ctc" 'ada-case) |
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-e" 'ada-elsif) |
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-cte" 'ada-else) |
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-ct\C-k" 'ada-package-spec) |
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-ctk" 'ada-package-body) |
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-p" 'ada-procedure-spec) |
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-ctp" 'ada-subprogram-body) |
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-ct\C-f" 'ada-function-spec) |
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-ctf" 'ada-for-loop) |
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-cti" 'ada-if) |
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-ctl" 'ada-loop) |
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-r" 'ada-record) |
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-s" 'ada-subtype) |
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-ctS" 'ada-tabsize) |
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-t" 'ada-task-spec) |
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-ctt" 'ada-task-body) |
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-y" 'ada-type) |
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-v" 'ada-private) |
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-ctu" 'ada-use) |
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-ct\C-u" 'ada-with) |
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-w" 'ada-when) |
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-ctw" 'ada-while-loop) |
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-ct\C-x" 'ada-exception) |
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-ctx" 'ada-exit) |
23868 | 167 |
168 ;;; ---- statement skeletons ------------------------------------------ | |
169 | |
170 (define-skeleton ada-array | |
26000 | 171 "Insert array type definition. |
26226
b63d041c9108
Changed format of years in copyright notices.
Gerd Moellmann <gerd@gnu.org>
parents:
26000
diff
changeset
|
172 Prompt for component type and index subtypes." |
23868 | 173 () |
174 "array (" ("index definition: " str ", " ) -2 ") of " _ ?\;) | |
175 | |
176 | |
177 (define-skeleton ada-case | |
26000 | 178 "Build skeleton case statement. |
179 Prompt for the selector expression. Also builds the first when clause." | |
23868 | 180 "[selector expression]: " |
181 "case " str " is" \n | |
182 > "when " ("discrete choice: " str " | ") -3 " =>" \n | |
183 > _ \n | |
184 < < "end case;") | |
185 | |
186 | |
187 (define-skeleton ada-when | |
188 "Start a case statement alternative with a when clause." | |
189 () | |
190 < "when " ("discrete choice: " str " | ") -3 " =>" \n | |
191 >) | |
192 | |
193 | |
194 (define-skeleton ada-declare-block | |
195 "Insert a block with a declare part. | |
196 Indent for the first declaration." | |
197 "[block name]: " | |
198 < str & ?: & \n | |
199 > "declare" \n | |
200 > _ \n | |
201 < "begin" \n | |
202 > \n | |
203 < "end " str | -1 ?\;) | |
204 | |
205 | |
206 (define-skeleton ada-exception-block | |
207 "Insert a block with an exception part. | |
208 Indent for the first line of code." | |
209 "[block name]: " | |
210 < str & ?: & \n | |
211 > "begin" \n | |
212 > _ \n | |
213 < "exception" \n | |
214 > \n | |
215 < "end " str | -1 ?\;) | |
216 | |
217 | |
218 (define-skeleton ada-exception | |
219 "Insert an indented exception part into a block." | |
220 () | |
221 < "exception" \n | |
222 >) | |
223 | |
224 | |
225 (define-skeleton ada-exit-1 | |
226 "Insert then exit condition of the exit statement, prompting for condition." | |
227 "[exit condition]: " | |
228 "when " str | -5) | |
229 | |
230 | |
231 (define-skeleton ada-exit | |
232 "Insert an exit statement, prompting for loop name and condition." | |
233 "[name of loop to exit]: " | |
234 "exit " str & ?\ | |
235 (ada-exit-1) | |
236 | -1 ?\;) | |
237 | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
238 ;;;###autoload |
23868 | 239 (defun ada-header () |
240 "Insert a descriptive header at the top of the file." | |
241 (interactive "*") | |
242 (save-excursion | |
243 (goto-char (point-min)) | |
244 (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
|
245 (funcall (symbol-function 'make-header)) |
23868 | 246 (ada-header-tmpl)))) |
247 | |
248 | |
249 (define-skeleton ada-header-tmpl | |
250 "Insert a comment block containing the module title, author, etc." | |
251 "[Description]: " | |
252 "-- -*- 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
|
253 "\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
|
254 "\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
|
255 "\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
|
256 "\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
|
257 "\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
|
258 "\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
|
259 "\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
|
260 "\n" ada-fill-comment-prefix "Status : Unknown, Use with caution!" |
23868 | 261 "\n") |
262 | |
263 | |
264 (define-skeleton ada-display-comment | |
265 "Inserts three comment lines, making a display comment." | |
266 () | |
30409
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
267 "--\n" ada-fill-comment-prefix _ "\n--") |
23868 | 268 |
269 | |
270 (define-skeleton ada-if | |
271 "Insert skeleton if statment, prompting for a boolean-expression." | |
272 "[condition]: " | |
273 "if " str " then" \n | |
274 > _ \n | |
275 < "end if;") | |
276 | |
277 | |
278 (define-skeleton ada-elsif | |
279 "Add an elsif clause to an if statement, | |
280 prompting for the boolean-expression." | |
281 "[condition]: " | |
282 < "elsif " str " then" \n | |
283 >) | |
284 | |
285 | |
286 (define-skeleton ada-else | |
287 "Add an else clause inside an if-then-end-if clause." | |
288 () | |
289 < "else" \n | |
290 >) | |
291 | |
292 | |
293 (define-skeleton ada-loop | |
294 "Insert a skeleton loop statement. The exit statement is added by hand." | |
295 "[loop name]: " | |
296 < str & ?: & \n | |
297 > "loop" \n | |
298 > _ \n | |
299 < "end loop " str | -1 ?\;) | |
300 | |
301 | |
302 (define-skeleton ada-for-loop-prompt-variable | |
303 "Prompt for the loop variable." | |
304 "[loop variable]: " | |
305 str) | |
306 | |
307 | |
308 (define-skeleton ada-for-loop-prompt-range | |
309 "Prompt for the loop range." | |
310 "[loop range]: " | |
311 str) | |
312 | |
313 | |
314 (define-skeleton ada-for-loop | |
315 "Build a skeleton for-loop statement, prompting for the loop parameters." | |
316 "[loop name]: " | |
317 < str & ?: & \n | |
318 > "for " | |
319 (ada-for-loop-prompt-variable) | |
320 " in " | |
321 (ada-for-loop-prompt-range) | |
322 " loop" \n | |
323 > _ \n | |
324 < "end loop " str | -1 ?\;) | |
325 | |
326 | |
327 (define-skeleton ada-while-loop-prompt-entry-condition | |
328 "Prompt for the loop entry condition." | |
329 "[entry condition]: " | |
330 str) | |
331 | |
332 | |
333 (define-skeleton ada-while-loop | |
334 "Insert a skeleton while loop statement." | |
335 "[loop name]: " | |
336 < str & ?: & \n | |
337 > "while " | |
338 (ada-while-loop-prompt-entry-condition) | |
339 " loop" \n | |
340 > _ \n | |
341 < "end loop " str | -1 ?\;) | |
342 | |
343 | |
344 (define-skeleton ada-package-spec | |
345 "Insert a skeleton package specification." | |
346 "[package name]: " | |
347 "package " str " is" \n | |
348 > _ \n | |
349 < "end " str ?\;) | |
350 | |
351 | |
352 (define-skeleton ada-package-body | |
353 "Insert a skeleton package body -- includes a begin statement." | |
354 "[package name]: " | |
355 "package body " str " is" \n | |
356 > _ \n | |
357 ; < "begin" \n | |
358 < "end " str ?\;) | |
359 | |
360 | |
361 (define-skeleton ada-private | |
362 "Undent and start a private section of a package spec. Reindent." | |
363 () | |
364 < "private" \n | |
365 >) | |
366 | |
367 | |
368 (define-skeleton ada-function-spec-prompt-return | |
369 "Prompts for function result type." | |
370 "[result type]: " | |
371 str) | |
372 | |
373 | |
374 (define-skeleton ada-function-spec | |
375 "Insert a function specification. Prompts for name and arguments." | |
376 "[function name]: " | |
377 "function " str | |
378 " (" ("[parameter_specification]: " str "; " ) -2 ")" | |
379 " return " | |
380 (ada-function-spec-prompt-return) | |
381 ";" \n ) | |
382 | |
383 | |
384 (define-skeleton ada-procedure-spec | |
385 "Insert a procedure specification, prompting for its name and arguments." | |
386 "[procedure name]: " | |
387 "procedure " str | |
388 " (" ("[parameter_specification]: " str "; " ) -2 ")" | |
389 ";" \n ) | |
390 | |
391 | |
392 (define-skeleton ada-subprogram-body | |
393 "Insert frame for subprogram body. | |
394 Invoke right after `ada-function-spec' or `ada-procedure-spec'." | |
395 () | |
396 ;; Remove `;' from subprogram decl | |
397 (save-excursion | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
398 (let ((pos (1+ (point)))) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
399 (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
|
400 (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
|
401 (progn |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
402 (backward-char 1) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
403 (forward-sexp 1))) |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
404 ) |
23868 | 405 (if (looking-at ";") |
406 (delete-char 1))) | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
407 " is" \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
408 _ \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
409 < "begin" \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
410 \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
411 < "exception" \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
412 "when others => null;" \n |
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
413 < < "end " |
23868 | 414 (ada-func-or-proc-name) |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
415 ";" \n) |
23868 | 416 |
417 | |
418 (define-skeleton ada-separate | |
419 "Finish a body stub with `separate'." | |
420 () | |
421 > "separate;" \n | |
422 <) | |
423 | |
424 | |
425 ;(define-skeleton ada-with | |
426 ; "Inserts a with clause, prompting for the list of units depended upon." | |
427 ; "[list of units depended upon]: " | |
428 ; "with " str ?\;) | |
429 | |
430 ;(define-skeleton ada-use | |
431 ; "Inserts a use clause, prompting for the list of packages used." | |
432 ; "[list of packages used]: " | |
433 ; "use " str ?\;) | |
434 | |
435 | |
436 (define-skeleton ada-record | |
437 "Insert a skeleton record type declaration." | |
438 () | |
439 "record" \n | |
440 > _ \n | |
441 < "end record;") | |
442 | |
443 | |
444 (define-skeleton ada-subtype | |
445 "Start insertion of a subtype declaration, prompting for the subtype name." | |
446 "[subtype name]: " | |
447 "subtype " str " is " _ ?\; | |
448 (not (message "insert subtype indication."))) | |
449 | |
450 | |
451 (define-skeleton ada-type | |
452 "Start insertion of a type declaration, prompting for the type name." | |
453 "[type name]: " | |
454 "type " str ?\( | |
455 ("[discriminant specs]: " str " ") | |
456 | (backward-delete-char 1) | ?\) | |
457 " is " | |
458 (not (message "insert type definition."))) | |
459 | |
460 | |
461 (define-skeleton ada-task-body | |
462 "Insert a task body, prompting for the task name." | |
463 "[task name]: " | |
464 "task body " str " is\n" | |
465 "begin\n" | |
466 > _ \n | |
467 < "end " str ";" ) | |
468 | |
469 | |
470 (define-skeleton ada-task-spec | |
471 "Insert a task specification, prompting for the task name." | |
472 "[task name]: " | |
473 "task " str | |
474 " (" ("[discriminant]: " str "; ") ") is\n" | |
475 > "entry " _ \n | |
476 <"end " str ";" ) | |
477 | |
478 | |
479 (define-skeleton ada-get-param1 | |
480 "Prompt for arguments and if any enclose them in brackets." | |
481 () | |
482 ("[parameter_specification]: " str "; " ) & -2 & ")" | |
483 ) | |
484 | |
485 | |
486 (define-skeleton ada-get-param | |
487 "Prompt for arguments and if any enclose them in brackets." | |
488 () | |
489 " (" | |
490 (ada-get-param1) | -2 | |
491 ) | |
492 | |
493 | |
494 (define-skeleton ada-entry | |
495 "Insert a task entry, prompting for the entry name." | |
496 "[entry name]: " | |
497 "entry " str | |
498 (ada-get-param) | |
499 ";" \n | |
500 ; (ada-indent-current) | |
501 ) | |
502 | |
503 | |
504 (define-skeleton ada-entry-family-prompt-discriminant | |
505 "Insert a entry specification, prompting for the entry name." | |
506 "[discriminant name]: " | |
507 str) | |
508 | |
509 | |
510 (define-skeleton ada-entry-family | |
511 "Insert a entry specification, prompting for the entry name." | |
512 "[entry name]: " | |
513 "entry " str | |
514 " (" (ada-entry-family-prompt-discriminant) ")" | |
515 (ada-get-param) | |
516 ";" \n | |
517 ;(ada-indent-current) | |
518 ) | |
519 | |
520 | |
521 (define-skeleton ada-select | |
522 "Insert a select block." | |
523 () | |
524 "select\n" | |
525 > _ \n | |
526 < "end select;") | |
527 | |
528 | |
529 (define-skeleton ada-accept-1 | |
530 "Insert a condition statement, prompting for the condition name." | |
531 "[condition]: " | |
532 "when " str | -5 ) | |
533 | |
534 | |
535 (define-skeleton ada-accept-2 | |
536 "Insert an accept statement, prompting for the name and arguments." | |
537 "[accept name]: " | |
538 > "accept " str | |
539 (ada-get-param) | |
540 ; " (" ("[parameter_specification]: " str "; ") -2 ")" | |
541 " do" \n | |
542 > _ \n | |
543 < "end " str ";" ) | |
544 | |
545 | |
546 (define-skeleton ada-accept | |
547 "Insert an accept statement (prompt for condition, name and arguments)." | |
548 () | |
549 > (ada-accept-1) & " =>\n" | |
550 (ada-accept-2) | |
551 ) | |
552 | |
553 | |
554 (define-skeleton ada-or-accept | |
555 "Insert a or statement, prompting for the condition name." | |
556 () | |
557 < "or\n" | |
558 (ada-accept) | |
559 ) | |
560 | |
561 | |
562 (define-skeleton ada-or-delay | |
563 "Insert a delay statement, prompting for the delay value." | |
564 "[delay value]: " | |
565 < "or\n" | |
566 > "delay " str ";") | |
567 | |
568 | |
569 (define-skeleton ada-or-terminate | |
570 "Insert a terminate statement." | |
571 () | |
572 < "or\n" | |
573 > "terminate;") | |
574 | |
575 | |
576 ;; ---- | |
577 (defun ada-adjust-case-skeleton () | |
578 "Adjusts the case of the text inserted by a skeleton." | |
579 (save-excursion | |
580 (let ((aa-end (point))) | |
581 (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
|
582 (progn (goto-char (symbol-value 'beg)) (forward-word -1) (point)) |
23868 | 583 (goto-char aa-end)) |
584 ))) | |
30409
a530830f8a3d
(ada-stmt-add-to-ada-menu): Hide the menu if not in
Gerd Moellmann <gerd@gnu.org>
parents:
26226
diff
changeset
|
585 |
23868 | 586 (add-hook 'ada-mode-hook '(lambda () |
587 (setq skeleton-further-elements | |
588 '((< '(backward-delete-char-untabify | |
589 (min ada-indent (current-column)))))) | |
590 (add-hook 'skeleton-end-hook | |
591 'ada-adjust-case-skeleton))) | |
592 | |
25902
92828b88cfcc
(ada-stmt-add-to-ada-menu): New function
Gerd Moellmann <gerd@gnu.org>
parents:
23869
diff
changeset
|
593 (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
|
594 |
23868 | 595 (provide 'ada-stmt) |
596 | |
597 ;;; ada-stmt.el ends here |