Mercurial > emacs
annotate lisp/progmodes/ada-mode.el @ 14315:ab041898078d
(forms--help, forms-search-forward, forms-search-backward): Pass proper format string to message.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 25 Jan 1996 00:54:17 +0000 |
parents | 83f275dcd93a |
children | c819273fe29c |
rev | line source |
---|---|
13337 | 1 ;;; ada-mode.el --- An Emacs major-mode for editing Ada source. |
11231 | 2 ;;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. |
10705 | 3 |
4 ;;; Authors: Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de> | |
5 ;;; Rolf Ebert <ebert@inf.enst.fr> | |
6 | |
7 ;;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
14169 | 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
10705 | 23 |
24 ;;; This mode is a complete rewrite of a major mode for editing Ada 83 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
25 ;;; and Ada 95 source code under Emacs-19. It contains completely new |
10705 | 26 ;;; indenting code and support for code browsing (see ada-xref). |
27 | |
28 | |
29 ;;; USAGE | |
30 ;;; ===== | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
31 ;;; Emacs should enter ada-mode when you load an ada source (*.ad[abs]). |
10705 | 32 ;;; |
33 ;;; When you have entered ada-mode, you may get more info by pressing | |
34 ;;; C-h m. You may also get online help describing various functions by: | |
35 ;;; C-h d <Name of function you want described> | |
36 | |
37 | |
38 ;;; HISTORY | |
39 ;;; ======= | |
11199 | 40 ;;; The first Ada mode for GNU Emacs was written by V. Broman in |
41 ;;; 1985. He based his work on the already existing Modula-2 mode. | |
42 ;;; This was distributed as ada.el in versions of Emacs prior to 19.29. | |
10705 | 43 ;;; |
44 ;;; Lynn Slater wrote an extensive Ada mode in 1989. It consisted of | |
45 ;;; several files with support for dired commands and other nice | |
46 ;;; things. It is currently available from the PAL | |
47 ;;; (wuarchive.wustl.edu:/languages/ada) as ada-mode-1.06a.tar.Z. | |
48 ;;; | |
49 ;;; The probably very first Ada mode (called electric-ada.el) was | |
50 ;;; written by Steven D. Litvintchouk and Steven M. Rosen for the | |
51 ;;; Gosling Emacs. L. Slater based his development on ada.el and | |
52 ;;; electric-ada.el. | |
53 ;;; | |
54 ;;; The current Ada mode is a complete rewrite by M. Heritsch and | |
55 ;;; R. Ebert. Some ideas from the ada-mode mailing list have been | |
56 ;;; added. Some of the functionality of L. Slater's mode has not | |
57 ;;; (yet) been recoded in this new mode. Perhaps you prefer sticking | |
58 ;;; to his version. | |
59 | |
60 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
61 ;;; KNOWN BUGS |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
62 ;;; ========== |
10705 | 63 ;;; |
64 ;;; In the presence of comments and/or incorrect syntax | |
65 ;;; ada-format-paramlist produces weird results. | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
66 ;;; ------------------- |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
67 ;;; Indenting of some tasking constructs is still buggy. |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
68 ;;; ------------------- |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
69 ;;; package Test is |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
70 ;;; -- If I hit return on the "type" line it will indent the next line |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
71 ;;; -- in another 3 space instead of heading out to the "(". If I hit |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
72 ;;; -- tab or return it reindents the line correctly but does not initially. |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
73 ;;; type Wait_Return is (Read_Success, Read_Timeout, Wait_Timeout, |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
74 ;;; Nothing_To_Wait_For_In_Wait_List); |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
75 ;;; ------------------- |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
76 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
77 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
78 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
79 ;;; CREDITS |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
80 ;;; ======= |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
81 ;;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
82 ;;; Many thanks to |
13963
a62c62ac5102
(ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
83 ;;; Philippe Waroquiers (PW) <philippe@cfmu.eurocontrol.be> in particular, |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
84 ;;; woodruff@stc.llnl.gov (John Woodruff) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
85 ;;; jj@ddci.dk (Jesper Joergensen) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
86 ;;; gse@ocsystems.com (Scott Evans) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
87 ;;; comar@LANG8.CS.NYU.EDU (Cyrille Comar) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
88 ;;; and others for their valuable hints. |
10705 | 89 |
90 ;;;-------------------- | |
91 ;;; USER OPTIONS | |
92 ;;;-------------------- | |
93 | |
94 ;; ---- configure indentation | |
95 | |
96 (defvar ada-indent 3 | |
97 "*Defines the size of Ada indentation.") | |
98 | |
99 (defvar ada-broken-indent 2 | |
100 "*# of columns to indent the continuation of a broken line.") | |
101 | |
102 (defvar ada-label-indent -4 | |
103 "*# of columns to indent a label.") | |
104 | |
105 (defvar ada-stmt-end-indent 0 | |
106 "*# of columns to indent a statement end keyword in a separate line. | |
107 Examples are 'is', 'loop', 'record', ...") | |
108 | |
109 (defvar ada-when-indent 3 | |
110 "*Defines the indentation for 'when' relative to 'exception' or 'case'.") | |
111 | |
112 (defvar ada-indent-record-rel-type 3 | |
113 "*Defines the indentation for 'record' relative to 'type' or 'use'.") | |
114 | |
115 (defvar ada-indent-comment-as-code t | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
116 "*If non-nil, comment-lines get indented as Ada code.") |
10705 | 117 |
118 (defvar ada-indent-is-separate t | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
119 "*If non-nil, 'is separate' or 'is abstract' on a single line are indented.") |
10705 | 120 |
121 (defvar ada-indent-to-open-paren t | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
122 "*If non-nil, indent according to the innermost open parenthesis.") |
10705 | 123 |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
124 (defvar ada-search-paren-char-count-limit 3000 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
125 "*Search that many characters for an open parenthesis.") |
10705 | 126 |
127 | |
128 ;; ---- other user options | |
129 | |
130 (defvar ada-tab-policy 'indent-auto | |
131 "*Control behaviour of the TAB key. | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
132 Must be one of `indent-rigidly', `indent-auto', `gei', `indent-af' |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
133 or `always-tab'. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
134 |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
135 `indent-rigidly' : always adds ada-indent blanks at the beginning of the line. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
136 `indent-auto' : use indentation functions in this file. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
137 `gei' : use David Kågedal's Generic Indentation Engine. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
138 `indent-af' : use Gary E. Barnes' ada-format.el |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
139 `always-tab' : do indent-relative.") |
10705 | 140 |
141 (defvar ada-move-to-declaration nil | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
142 "*If non-nil, `ada-move-to-start' moves point to the subprog declaration, |
10705 | 143 not to 'begin'.") |
144 | |
145 (defvar ada-spec-suffix ".ads" | |
146 "*Suffix of Ada specification files.") | |
147 | |
148 (defvar ada-body-suffix ".adb" | |
149 "*Suffix of Ada body files.") | |
150 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
151 (defvar ada-language-version 'ada95 |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
152 "*Do we program in `ada83' or `ada95'?") |
10705 | 153 |
154 (defvar ada-case-keyword 'downcase-word | |
13963
a62c62ac5102
(ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
155 "*Function to call to adjust the case of Ada keywords. |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
156 It may be `downcase-word', `upcase-word', `ada-loose-case-word' or |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
157 `capitalize-word'.") |
10705 | 158 |
159 (defvar ada-case-identifier 'ada-loose-case-word | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
160 "*Function to call to adjust the case of an Ada identifier. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
161 It may be `downcase-word', `upcase-word', `ada-loose-case-word' or |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
162 `capitalize-word'.") |
10705 | 163 |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
164 (defvar ada-case-attribute 'capitalize-word |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
165 "*Function to call to adjust the case of Ada attributes. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
166 It may be `downcase-word', `upcase-word', `ada-loose-case-word' or |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
167 `capitalize-word'.") |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
168 |
10705 | 169 (defvar ada-auto-case t |
13963
a62c62ac5102
(ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
170 "*Non-nil automatically changes case of preceding word while typing. |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
171 Casing is done according to `ada-case-keyword', `ada-case-identifier' |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
172 and `ada-cacse-attribute'.") |
10705 | 173 |
174 (defvar ada-clean-buffer-before-saving nil | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
175 "*If non-nil, `remove-trailing-spaces' and `untabify' buffer before saving.") |
10705 | 176 |
177 (defvar ada-mode-hook nil | |
178 "*List of functions to call when Ada Mode is invoked. | |
179 This is a good place to add Ada environment specific bindings.") | |
180 | |
181 (defvar ada-external-pretty-print-program "aimap" | |
182 "*External pretty printer to call from within Ada Mode.") | |
183 | |
184 (defvar ada-tmp-directory "/tmp/" | |
185 "*Directory to store the temporary file for the Ada pretty printer.") | |
186 | |
187 (defvar ada-fill-comment-prefix "-- " | |
188 "*This is inserted in the first columns when filling a comment paragraph.") | |
189 | |
190 (defvar ada-fill-comment-postfix " --" | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
191 "*This is inserted at the end of each line when filling a comment paragraph. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
192 with `ada-fill-comment-paragraph-postfix'.") |
10705 | 193 |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
194 (defvar ada-krunch-args "0" |
10705 | 195 "*Argument of gnatk8, a string containing the max number of characters. |
13963
a62c62ac5102
(ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
196 Set to 0, if you don't use crunched filenames.") |
10705 | 197 |
198 ;;; ---- end of user configurable variables | |
199 | |
200 | |
201 (defvar ada-mode-abbrev-table nil | |
202 "Abbrev table used in Ada mode.") | |
203 (define-abbrev-table 'ada-mode-abbrev-table ()) | |
204 | |
205 (defvar ada-mode-map () | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
206 "Local keymap used for Ada Mode.") |
10705 | 207 |
208 (defvar ada-mode-syntax-table nil | |
209 "Syntax table to be used for editing Ada source code.") | |
210 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
211 (defvar ada-mode-symbol-syntax-table nil |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
212 "Syntax table for Ada, where `_' is a word constituent.") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
213 |
10705 | 214 (defconst ada-83-keywords |
215 "\\<\\(abort\\|abs\\|accept\\|access\\|all\\|and\\|array\\|\ | |
216 at\\|begin\\|body\\|case\\|constant\\|declare\\|delay\\|delta\\|\ | |
217 digits\\|do\\|else\\|elsif\\|end\\|entry\\|exception\\|exit\\|for\\|\ | |
218 function\\|generic\\|goto\\|if\\|in\\|is\\|limited\\|loop\\|mod\\|\ | |
219 new\\|not\\|null\\|of\\|or\\|others\\|out\\|package\\|pragma\\|\ | |
220 private\\|procedure\\|raise\\|range\\|record\\|rem\\|renames\\|\ | |
221 return\\|reverse\\|select\\|separate\\|subtype\\|task\\|terminate\\|\ | |
222 then\\|type\\|use\\|when\\|while\\|with\\|xor\\)\\>" | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
223 ; "\\<\\(a\\(b\\(ort\\|s\\)\\|cce\\(pt\\|ss\\)\\|ll\\|nd\\|rray\\|t\\)\\|\ |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
224 ;b\\(egin\\|ody\\)\\|c\\(ase\\|onstant\\)\\|\ |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
225 ;d\\(e\\(clare\\|l\\(ay\\|ta\\)\\)\\|igits\\|o\\)\\|\ |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
226 ;e\\(ls\\(e\\|if\\)\\|n\\(d\\|try\\)\\|x\\(ception\\|it\\)\\)\\|\ |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
227 ;f\\(or\\|unction\\)\\|g\\(eneric\\|oto\\)\\|i[fns]\\|l\\(imited\\|oop\\)\\|\ |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
228 ;mod\\|n\\(ew\\|ot\\|ull\\)\\|o\\([fr]\\|thers\\|ut\\)\\|\ |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
229 ;p\\(ackage\\|r\\(agma\\|ivate\\|ocedure\\)\\)\\|\ |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
230 ;r\\(a\\(ise\\|nge\\)\\|e\\(cord\\|m\\|names\\|turn\\|verse\\)\\)\\|\ |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
231 ;s\\(e\\(lect\\|parate\\)\\|ubtype\\)\\|use\\| |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
232 ;t\\(ask\\|erminate\\|hen\\|ype\\)\\|w\\(h\\(en\\|ile\\)\\|ith\\)\\|xor\\)\\>" |
10705 | 233 "regular expression for looking at Ada83 keywords.") |
234 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
235 (defconst ada-95-keywords |
10705 | 236 "\\<\\(abort\\|abs\\|abstract\\|accept\\|access\\|aliased\\|\ |
237 all\\|and\\|array\\|at\\|begin\\|body\\|case\\|constant\\|declare\\|\ | |
238 delay\\|delta\\|digits\\|do\\|else\\|elsif\\|end\\|entry\\|\ | |
239 exception\\|exit\\|for\\|function\\|generic\\|goto\\|if\\|in\\|\ | |
240 is\\|limited\\|loop\\|mod\\|new\\|not\\|null\\|of\\|or\\|others\\|\ | |
241 out\\|package\\|pragma\\|private\\|procedure\\|protected\\|raise\\|\ | |
242 range\\|record\\|rem\\|renames\\|requeue\\|return\\|reverse\\|\ | |
243 select\\|separate\\|subtype\\|tagged\\|task\\|terminate\\|then\\|\ | |
244 type\\|until\\|use\\|when\\|while\\|with\\|xor\\)\\>" | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
245 "regular expression for looking at Ada95 keywords.") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
246 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
247 (defvar ada-keywords ada-95-keywords |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
248 "Regular expression for looking at Ada keywords.") |
10705 | 249 |
250 (defvar ada-ret-binding nil | |
251 "Variable to save key binding of RET when casing is activated.") | |
252 | |
253 (defvar ada-lfd-binding nil | |
254 "Variable to save key binding of LFD when casing is activated.") | |
255 | |
256 ;;; ---- Regexps to find procedures/functions/packages | |
257 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
258 (defconst ada-ident-re |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
259 "[a-zA-Z0-9_\\.]+" |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
260 "Regexp matching Ada (qualified) identifiers.") |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
261 |
10705 | 262 (defvar ada-procedure-start-regexp |
263 "^[ \t]*\\(procedure\\|function\\|task\\)[ \t\n]+\\([a-zA-Z0-9_\\.]+\\)" | |
264 "Regexp used to find Ada procedures/functions.") | |
265 | |
266 (defvar ada-package-start-regexp | |
267 "^[ \t]*\\(package\\)" | |
268 "Regexp used to find Ada packages") | |
269 | |
270 | |
271 ;;; ---- regexps for indentation functions | |
272 | |
273 (defvar ada-block-start-re | |
274 "\\<\\(begin\\|select\\|declare\\|private\\|or\\|generic\\|\ | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
275 exception\\|loop\\|else\\|\ |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
276 \\(\\(limited\\|abstract\\|tagged\\)[ \t]+\\)*record\\)\\>" |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
277 "Regexp for keywords starting Ada blocks.") |
10705 | 278 |
279 (defvar ada-end-stmt-re | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
280 "\\(;\\|=>\\|^[ \t]*separate[ \t]+([a-zA-Z0-9_\\.]+)\\|\ |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
281 \\<\\(begin\\|else\\|record\\|loop\\|select\\|do\\|\ |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
282 declare\\|generic\\|private\\)\\>\\|\ |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
283 ^[ \t]*\\(package\\|procedure\\|function\\)[ \ta-zA-Z0-9_\\.]+is\\|\ |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
284 ^[ \t]*exception\\>\\)" |
10705 | 285 "Regexp of possible ends for a non-broken statement. |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
286 A new statement starts after these.") |
10705 | 287 |
288 (defvar ada-loop-start-re | |
289 "\\<\\(for\\|while\\|loop\\)\\>" | |
290 "Regexp for the start of a loop.") | |
291 | |
292 (defvar ada-subprog-start-re | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
293 "\\<\\(procedure\\|protected\\|package\\|function\\|\ |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
294 task\\|accept\\|entry\\)\\>" |
10705 | 295 "Regexp for the start of a subprogram.") |
296 | |
297 | |
12702
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
298 ;; Written by Christian Egli <Christian.Egli@hcsd.hac.com> |
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
299 ;; |
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
300 (defvar ada-imenu-generic-expression |
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
301 '((nil "^\\s-*\\(procedure\\|function\\)\\s-+\\([A-Za-z0-9_]+\\)" 2) |
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
302 ("Type Defs" "^\\s-*\\(sub\\)?type\\s-+\\([A-Za-z0-9_]+\\)" 2)) |
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
303 |
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
304 "Imenu generic expression for Ada mode. See `imenu-generic-expression'.") |
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
305 |
10705 | 306 ;;;------------- |
307 ;;; functions | |
308 ;;;------------- | |
309 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
310 (defun ada-xemacs () |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
311 (or (string-match "Lucid" emacs-version) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
312 (string-match "XEmacs" emacs-version))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
313 |
10705 | 314 (defun ada-create-syntax-table () |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
315 "Create the syntax table for Ada Mode." |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
316 ;; There are two different syntax-tables. The standard one declares |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
317 ;; `_' as a symbol constituent, in the second one, it is a word |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
318 ;; constituent. For some search and replacing routines we |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
319 ;; temporarily switch between the two. |
10705 | 320 (setq ada-mode-syntax-table (make-syntax-table)) |
321 (set-syntax-table ada-mode-syntax-table) | |
322 | |
323 ;; define string brackets (% is alternative string bracket) | |
324 (modify-syntax-entry ?% "\"" ada-mode-syntax-table) | |
325 (modify-syntax-entry ?\" "\"" ada-mode-syntax-table) | |
326 | |
327 (modify-syntax-entry ?\# "$" ada-mode-syntax-table) | |
328 | |
329 (modify-syntax-entry ?: "." ada-mode-syntax-table) | |
330 (modify-syntax-entry ?\; "." ada-mode-syntax-table) | |
331 (modify-syntax-entry ?& "." ada-mode-syntax-table) | |
332 (modify-syntax-entry ?\| "." ada-mode-syntax-table) | |
333 (modify-syntax-entry ?+ "." ada-mode-syntax-table) | |
334 (modify-syntax-entry ?* "." ada-mode-syntax-table) | |
335 (modify-syntax-entry ?/ "." ada-mode-syntax-table) | |
336 (modify-syntax-entry ?= "." ada-mode-syntax-table) | |
337 (modify-syntax-entry ?< "." ada-mode-syntax-table) | |
338 (modify-syntax-entry ?> "." ada-mode-syntax-table) | |
339 (modify-syntax-entry ?$ "." ada-mode-syntax-table) | |
340 (modify-syntax-entry ?\[ "." ada-mode-syntax-table) | |
341 (modify-syntax-entry ?\] "." ada-mode-syntax-table) | |
342 (modify-syntax-entry ?\{ "." ada-mode-syntax-table) | |
343 (modify-syntax-entry ?\} "." ada-mode-syntax-table) | |
344 (modify-syntax-entry ?. "." ada-mode-syntax-table) | |
345 (modify-syntax-entry ?\\ "." ada-mode-syntax-table) | |
346 (modify-syntax-entry ?\' "." ada-mode-syntax-table) | |
347 | |
348 ;; a single hyphen is punctuation, but a double hyphen starts a comment | |
349 (modify-syntax-entry ?- ". 12" ada-mode-syntax-table) | |
350 | |
351 ;; and \f and \n end a comment | |
352 (modify-syntax-entry ?\f "> " ada-mode-syntax-table) | |
353 (modify-syntax-entry ?\n "> " ada-mode-syntax-table) | |
354 | |
355 ;; define what belongs in ada symbols | |
356 (modify-syntax-entry ?_ "_" ada-mode-syntax-table) | |
357 | |
358 ;; define parentheses to match | |
359 (modify-syntax-entry ?\( "()" ada-mode-syntax-table) | |
360 (modify-syntax-entry ?\) ")(" ada-mode-syntax-table) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
361 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
362 (setq ada-mode-symbol-syntax-table (copy-syntax-table ada-mode-syntax-table)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
363 (modify-syntax-entry ?_ "w" ada-mode-symbol-syntax-table) |
10705 | 364 ) |
365 | |
366 | |
10707 | 367 ;;;###autoload |
10705 | 368 (defun ada-mode () |
369 "Ada Mode is the major mode for editing Ada code. | |
370 | |
371 Bindings are as follows: (Note: 'LFD' is control-j.) | |
372 | |
373 Indent line '\\[ada-tab]' | |
374 Indent line, insert newline and indent the new line. '\\[newline-and-indent]' | |
375 | |
376 Re-format the parameter-list point is in '\\[ada-format-paramlist]' | |
377 Indent all lines in region '\\[ada-indent-region]' | |
378 Call external pretty printer program '\\[ada-call-pretty-printer]' | |
379 | |
380 Adjust case of identifiers and keywords in region '\\[ada-adjust-case-region]' | |
381 Adjust case of identifiers and keywords in buffer '\\[ada-adjust-case-buffer]' | |
382 | |
383 Call EXTERNAL pretty printer (if you have one) '\\[ada-call-pretty-printer]' | |
384 | |
385 Fill comment paragraph '\\[ada-fill-comment-paragraph]' | |
386 Fill comment paragraph and justify each line '\\[ada-fill-comment-paragraph-justify]' | |
387 Fill comment paragraph, justify and append postfix '\\[ada-fill-comment-paragraph-postfix]' | |
388 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
389 Next func/proc/task '\\[ada-next-procedure]' Previous func/proc/task '\\[ada-previous-procedure]' |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
390 Next package '\\[ada-next-package]' Previous package '\\[ada-previous-package]' |
10705 | 391 |
392 Goto matching start of current 'end ...;' '\\[ada-move-to-start]' | |
393 Goto end of current block '\\[ada-move-to-end]' | |
394 | |
395 Comments are handled using standard GNU Emacs conventions, including: | |
396 Start a comment '\\[indent-for-comment]' | |
397 Comment region '\\[comment-region]' | |
398 Uncomment region '\\[ada-uncomment-region]' | |
399 Continue comment on next line '\\[indent-new-comment-line]' | |
400 | |
401 If you use imenu.el: | |
402 Display index-menu of functions & procedures '\\[imenu]' | |
403 | |
404 If you use find-file.el: | |
405 Switch to other file (Body <-> Spec) '\\[ff-find-other-file]' | |
406 or '\\[ff-mouse-find-other-file] | |
407 Switch to other file in other window '\\[ada-ff-other-window]' | |
408 or '\\[ff-mouse-find-other-file-other-window] | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
409 If you use this function in a spec and no body is available, it gets created |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
410 with body stubs. |
10705 | 411 |
412 If you use ada-xref.el: | |
413 Goto declaration: '\\[ada-point-and-xref]' on the identifier | |
414 or '\\[ada-goto-declaration]' with point on the identifier | |
415 Complete identifier: '\\[ada-complete-identifier]' | |
416 Execute Gnatf: '\\[ada-gnatf-current]'" | |
417 | |
418 (interactive) | |
419 (kill-all-local-variables) | |
420 | |
421 (make-local-variable 'require-final-newline) | |
422 (setq require-final-newline t) | |
423 | |
424 (make-local-variable 'comment-start) | |
425 (setq comment-start "-- ") | |
426 | |
427 ;; comment end must be set because it may hold a wrong value if | |
428 ;; this buffer had been in another mode before. RE | |
429 (make-local-variable 'comment-end) | |
430 (setq comment-end "") | |
431 | |
432 (make-local-variable 'comment-start-skip) ;; used by autofill | |
433 (setq comment-start-skip "--+[ \t]*") | |
434 | |
435 (make-local-variable 'indent-line-function) | |
436 (setq indent-line-function 'ada-indent-current-function) | |
437 | |
438 (make-local-variable 'fill-column) | |
439 (setq fill-column 75) | |
440 | |
441 (make-local-variable 'comment-column) | |
442 (setq comment-column 40) | |
443 | |
444 (make-local-variable 'parse-sexp-ignore-comments) | |
445 (setq parse-sexp-ignore-comments t) | |
446 | |
447 (make-local-variable 'case-fold-search) | |
448 (setq case-fold-search t) | |
449 | |
10707 | 450 (make-local-variable 'fill-paragraph-function) |
451 (setq fill-paragraph-function 'ada-fill-comment-paragraph) | |
452 | |
12702
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
453 (make-local-variable 'imenu-generic-expression) |
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
454 (setq imenu-generic-expression ada-imenu-generic-expression) |
b0355a012c1d
(ada-imenu-generic-expression): Var defined.
Karl Heuer <kwzh@gnu.org>
parents:
12586
diff
changeset
|
455 |
10705 | 456 (make-local-variable 'font-lock-defaults) |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
457 (setq font-lock-defaults '((ada-font-lock-keywords |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
458 ada-font-lock-keywords-1 |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
459 ada-font-lock-keywords-2) |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
460 nil t |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
461 ((?\_ . "w")) |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
462 beginning-of-line)) |
10705 | 463 |
464 (setq major-mode 'ada-mode) | |
465 (setq mode-name "Ada") | |
466 | |
467 (setq blink-matching-paren t) | |
468 | |
469 (use-local-map ada-mode-map) | |
470 | |
471 (if ada-mode-syntax-table | |
472 (set-syntax-table ada-mode-syntax-table) | |
473 (ada-create-syntax-table)) | |
474 | |
475 (if ada-clean-buffer-before-saving | |
476 (progn | |
477 ;; remove all spaces at the end of lines in the whole buffer. | |
478 (add-hook 'local-write-file-hooks 'ada-remove-trailing-spaces) | |
479 ;; convert all tabs to the correct number of spaces. | |
480 (add-hook 'local-write-file-hooks 'ada-untabify-buffer))) | |
481 | |
482 | |
483 ;; add menu 'Ada' to the menu bar | |
484 (ada-add-ada-menu) | |
485 | |
486 (run-hooks 'ada-mode-hook) | |
487 | |
488 ;; the following has to be done after running the ada-mode-hook | |
489 ;; because users might want to set the values of these variable | |
490 ;; inside the hook (MH) | |
491 | |
492 (cond ((eq ada-language-version 'ada83) | |
493 (setq ada-keywords ada-83-keywords)) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
494 ((eq ada-language-version 'ada95) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
495 (setq ada-keywords ada-95-keywords))) |
10705 | 496 |
497 (if ada-auto-case | |
498 (ada-activate-keys-for-case))) | |
499 | |
500 | |
501 ;;;-------------------------- | |
502 ;;; Fill Comment Paragraph | |
503 ;;;-------------------------- | |
504 | |
505 (defun ada-fill-comment-paragraph-justify () | |
506 "Fills current comment paragraph and justifies each line as well." | |
507 (interactive) | |
508 (ada-fill-comment-paragraph t)) | |
509 | |
510 | |
511 (defun ada-fill-comment-paragraph-postfix () | |
512 "Fills current comment paragraph and justifies each line as well. | |
513 Prompts for a postfix to be appended to each line." | |
514 (interactive) | |
515 (ada-fill-comment-paragraph t t)) | |
516 | |
517 | |
518 (defun ada-fill-comment-paragraph (&optional justify postfix) | |
519 "Fills the current comment paragraph. | |
520 If JUSTIFY is non-nil, each line is justified as well. | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
521 If POSTFIX and JUSTIFY are non-nil, `ada-fill-comment-postfix' is appended |
10705 | 522 to each filled and justified line. |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
523 If `ada-indent-comment-as-code' is non-nil, the paragraph is idented." |
10705 | 524 (interactive "P") |
525 (let ((opos (point-marker)) | |
526 (begin nil) | |
527 (end nil) | |
528 (end-2 nil) | |
529 (indent nil) | |
530 (ada-fill-comment-old-postfix "") | |
531 (fill-prefix nil)) | |
532 | |
533 ;; check if inside comment | |
534 (if (not (ada-in-comment-p)) | |
535 (error "not inside comment")) | |
536 | |
537 ;; prompt for postfix if wanted | |
538 (if (and justify | |
539 postfix) | |
540 (setq ada-fill-comment-postfix | |
541 (read-from-minibuffer "enter new postfix string: " | |
542 ada-fill-comment-postfix))) | |
543 | |
544 ;; prompt for old postfix to remove if necessary | |
545 (if (and justify | |
546 postfix) | |
547 (setq ada-fill-comment-old-postfix | |
548 (read-from-minibuffer "enter already existing postfix string: " | |
549 ada-fill-comment-postfix))) | |
550 | |
551 ;; | |
552 ;; find limits of paragraph | |
553 ;; | |
554 (message "filling comment paragraph ...") | |
555 (save-excursion | |
556 (back-to-indentation) | |
557 ;; find end of paragraph | |
558 (while (and (looking-at "--.*$") | |
559 (not (looking-at "--[ \t]*$"))) | |
560 (forward-line 1) | |
561 (back-to-indentation)) | |
562 (beginning-of-line) | |
563 (setq end (point-marker)) | |
564 (goto-char opos) | |
565 ;; find begin of paragraph | |
566 (back-to-indentation) | |
567 (while (and (looking-at "--.*$") | |
568 (not (looking-at "--[ \t]*$"))) | |
569 (forward-line -1) | |
570 (back-to-indentation)) | |
571 (forward-line 1) | |
572 ;; get indentation to calculate width for filling | |
573 (ada-indent-current) | |
574 (back-to-indentation) | |
575 (setq indent (current-column)) | |
576 (setq begin (point-marker))) | |
577 | |
578 ;; delete old postfix if necessary | |
579 (if (and justify | |
580 postfix) | |
581 (save-excursion | |
582 (goto-char begin) | |
583 (while (re-search-forward (concat ada-fill-comment-old-postfix | |
584 "\n") | |
585 end t) | |
586 (replace-match "\n")))) | |
587 | |
588 ;; delete leading whitespace and uncomment | |
589 (save-excursion | |
590 (goto-char begin) | |
591 (beginning-of-line) | |
592 (while (re-search-forward "^[ \t]*--[ \t]*" end t) | |
593 (replace-match ""))) | |
594 | |
595 ;; calculate fill width | |
596 (setq fill-column (- fill-column indent | |
597 (length ada-fill-comment-prefix) | |
598 (if postfix | |
599 (length ada-fill-comment-postfix) | |
600 0))) | |
601 ;; fill paragraph | |
602 (fill-region begin (1- end) justify) | |
603 (setq fill-column (+ fill-column indent | |
604 (length ada-fill-comment-prefix) | |
605 (if postfix | |
606 (length ada-fill-comment-postfix) | |
607 0))) | |
608 ;; find end of second last line | |
609 (save-excursion | |
610 (goto-char end) | |
611 (forward-line -2) | |
612 (end-of-line) | |
613 (setq end-2 (point-marker))) | |
614 | |
615 ;; re-comment and re-indent region | |
616 (save-excursion | |
617 (goto-char begin) | |
618 (indent-to indent) | |
619 (insert ada-fill-comment-prefix) | |
620 (while (re-search-forward "\n" (1- end-2) t) | |
621 (replace-match (concat "\n" ada-fill-comment-prefix)) | |
622 (beginning-of-line) | |
623 (indent-to indent))) | |
624 | |
625 ;; append postfix if wanted | |
626 (if (and justify | |
627 postfix | |
628 ada-fill-comment-postfix) | |
629 (progn | |
630 ;; append postfix up to there | |
631 (save-excursion | |
632 (goto-char begin) | |
633 (while (re-search-forward "\n" (1- end-2) t) | |
634 (replace-match (concat ada-fill-comment-postfix "\n"))) | |
635 | |
636 ;; fill last line and append postfix | |
637 (end-of-line) | |
638 (insert-char ? | |
639 (- fill-column | |
640 (current-column) | |
641 (length ada-fill-comment-postfix))) | |
642 (insert ada-fill-comment-postfix)))) | |
643 | |
644 ;; delete the extra line that gets inserted somehow(??) | |
645 (save-excursion | |
646 (goto-char (1- end)) | |
647 (end-of-line) | |
648 (delete-char 1)) | |
649 | |
650 (message "filling comment paragraph ... done") | |
10707 | 651 (goto-char opos)) |
652 t) | |
10705 | 653 |
654 | |
655 ;;;--------------------------------;;; | |
656 ;;; Call External Pretty Printer ;;; | |
657 ;;;--------------------------------;;; | |
658 | |
659 (defun ada-call-pretty-printer () | |
660 "Calls the external Pretty Printer. | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
661 The name is specified in `ada-external-pretty-print-program'. Saves the |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
662 current buffer in a directory specified by `ada-tmp-directory', |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
663 starts the pretty printer as external process on that file and then |
13963
a62c62ac5102
(ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
664 reloads the beautified program in the buffer and cleans up |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
665 `ada-tmp-directory'." |
10705 | 666 (interactive) |
667 (let ((filename-with-path buffer-file-name) | |
668 (curbuf (current-buffer)) | |
669 (orgpos (point)) | |
670 (mesgbuf nil) ;; for byte-compiling | |
671 (file-path (file-name-directory buffer-file-name)) | |
672 (filename-without-path (file-name-nondirectory buffer-file-name)) | |
673 (tmp-file-with-directory | |
674 (concat ada-tmp-directory | |
675 (file-name-nondirectory buffer-file-name)))) | |
676 ;; | |
677 ;; save buffer in temporary file | |
678 ;; | |
679 (message "saving current buffer to temporary file ...") | |
680 (write-file tmp-file-with-directory) | |
681 (auto-save-mode nil) | |
682 (message "saving current buffer to temporary file ... done") | |
683 ;; | |
684 ;; call external pretty printer program | |
685 ;; | |
686 | |
687 (message "running external pretty printer ...") | |
688 ;; create a temporary buffer for messages of pretty printer | |
689 (setq mesgbuf (get-buffer-create "Pretty Printer Messages")) | |
690 ;; execute pretty printer on temporary file | |
691 (call-process ada-external-pretty-print-program | |
692 nil mesgbuf t | |
693 tmp-file-with-directory) | |
694 ;; display messages if there are some | |
695 (if (buffer-modified-p mesgbuf) | |
696 ;; show the message buffer | |
697 (display-buffer mesgbuf t) | |
698 ;; kill the message buffer | |
699 (kill-buffer mesgbuf)) | |
700 (message "running external pretty printer ... done") | |
701 ;; | |
702 ;; kill current buffer and load pretty printer output | |
703 ;; or restore old buffer | |
704 ;; | |
705 (if (y-or-n-p | |
706 "Really replace current buffer with pretty printer output ? ") | |
707 (progn | |
708 (set-buffer-modified-p nil) | |
709 (kill-buffer curbuf) | |
710 (find-file tmp-file-with-directory)) | |
711 (message "old buffer contents restored")) | |
712 ;; | |
713 ;; delete temporary file and restore information of current buffer | |
714 ;; | |
715 (delete-file tmp-file-with-directory) | |
716 (set-visited-file-name filename-with-path) | |
717 (auto-save-mode t) | |
718 (goto-char orgpos))) | |
719 | |
720 | |
721 ;;;--------------- | |
722 ;;; auto-casing | |
723 ;;;--------------- | |
724 | |
725 ;; from Philippe Waroquiers <philippe@cfmu.eurocontrol.be> | |
726 ;; modifiedby RE and MH | |
727 | |
728 (defun ada-after-keyword-p () | |
729 ;; returns t if cursor is after a keyword. | |
730 (save-excursion | |
731 (forward-word -1) | |
732 (and (save-excursion | |
733 (or | |
734 (= (point) (point-min)) | |
735 (backward-char 1)) | |
736 (not (looking-at "_"))) ; (MH) | |
737 (looking-at (concat ada-keywords "[^_]"))))) | |
738 | |
739 (defun ada-after-char-p () | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
740 ;; returns t if after ada character "'". This is interpreted as being |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
741 ;; in a character constant. |
10705 | 742 (save-excursion |
743 (if (> (point) 2) | |
744 (progn | |
745 (forward-char -2) | |
746 (looking-at "'")) | |
747 nil))) | |
748 | |
749 | |
750 (defun ada-adjust-case (&optional force-identifier) | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
751 "Adjust the case of the word before the just typed character. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
752 Respect options `ada-case-keyword', `ada-case-identifier', and |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
753 `ada-case-attribute'. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
754 If FORCE-IDENTIFIER is non-nil then also adjust keyword as identifier." ; (MH) |
10705 | 755 (forward-char -1) |
756 (if (and (> (point) 1) (not (or (ada-in-string-p) | |
757 (ada-in-comment-p) | |
758 (ada-after-char-p)))) | |
759 (if (eq (char-syntax (char-after (1- (point)))) ?w) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
760 (if (save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
761 (forward-word -1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
762 (or (= (point) (point-min)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
763 (backward-char 1)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
764 (looking-at "'")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
765 (funcall ada-case-attribute -1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
766 (if (and |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
767 (not force-identifier) ; (MH) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
768 (ada-after-keyword-p)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
769 (funcall ada-case-keyword -1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
770 (funcall ada-case-identifier -1))))) |
10705 | 771 (forward-char 1)) |
772 | |
773 | |
774 (defun ada-adjust-case-interactive (arg) | |
775 (interactive "P") | |
776 (let ((lastk last-command-char)) | |
777 (cond ((or (eq lastk ?\n) | |
778 (eq lastk ?\r)) | |
779 ;; horrible kludge | |
780 (insert " ") | |
781 (ada-adjust-case) | |
782 ;; horrible dekludge | |
783 (delete-backward-char 1) | |
784 ;; some special keys and their bindings | |
785 (cond | |
786 ((eq lastk ?\n) | |
787 (funcall ada-lfd-binding)) | |
788 ((eq lastk ?\r) | |
789 (funcall ada-ret-binding)))) | |
790 ((eq lastk ?\C-i) (ada-tab)) | |
791 ((self-insert-command (prefix-numeric-value arg)))) | |
792 ;; if there is a keyword in front of the underscore | |
793 ;; then it should be part of an identifier (MH) | |
794 (if (eq lastk ?_) | |
795 (ada-adjust-case t) | |
796 (ada-adjust-case)))) | |
797 | |
798 | |
799 (defun ada-activate-keys-for-case () | |
800 ;; save original keybindings to allow swapping ret/lfd | |
801 ;; when casing is activated | |
802 ;; the 'or ...' is there to be sure that the value will not | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
803 ;; be changed again when Ada Mode is called more than once (MH) |
10705 | 804 (or ada-ret-binding |
805 (setq ada-ret-binding (key-binding "\C-M"))) | |
806 (or ada-lfd-binding | |
807 (setq ada-lfd-binding (key-binding "\C-j"))) | |
808 ;; call case modifying function after certain keys. | |
809 (mapcar (function (lambda(key) (define-key | |
810 ada-mode-map | |
811 (char-to-string key) | |
812 'ada-adjust-case-interactive))) | |
813 '( ?` ?~ ?! ?@ ?# ?$ ?% ?^ ?& ?* ?( ?) ?- ?= ?+ ?[ ?{ ?] ?} | |
814 ?_ ?\\ ?| ?\; ?: ?' ?\" ?< ?, ?. ?> ?? ?/ ?\n 32 ?\r ))) | |
815 ;; deleted ?\t from above list | |
816 | |
817 ;; | |
818 ;; added by MH | |
819 ;; | |
820 (defun ada-loose-case-word (&optional arg) | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
821 "Capitalizes the first letter and the letters following `_'. |
10705 | 822 ARG is ignored, it's there to fit the standard casing functions' style." |
823 (let ((pos (point)) | |
824 (first t)) | |
825 (skip-chars-backward "a-zA-Z0-9_") | |
826 (while (or first | |
827 (search-forward "_" pos t)) | |
828 (and first | |
829 (setq first nil)) | |
830 (insert-char (upcase (following-char)) 1) | |
831 (delete-char 1)) | |
832 (goto-char pos))) | |
833 | |
834 | |
835 ;; | |
836 ;; added by MH | |
837 ;; | |
838 (defun ada-adjust-case-region (from to) | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
839 "Adjusts the case of all words in the region. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
840 Attention: This function might take very long for big regions !" |
10705 | 841 (interactive "*r") |
842 (let ((begin nil) | |
843 (end nil) | |
844 (keywordp nil) | |
845 (reldiff nil)) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
846 (unwind-protect |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
847 (save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
848 (set-syntax-table ada-mode-symbol-syntax-table) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
849 (goto-char to) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
850 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
851 ;; loop: look for all identifiers and keywords |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
852 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
853 (while (re-search-backward |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
854 "[^a-zA-Z0-9_]\\([a-zA-Z0-9_]+\\)[^a-zA-Z0-9_]" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
855 from |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
856 t) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
857 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
858 ;; print status message |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
859 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
860 (setq reldiff (- (point) from)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
861 (message (format "adjusting case ... %5d characters left" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
862 (- (point) from))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
863 (forward-char 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
864 (or |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
865 ;; do nothing if it is a string or comment |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
866 (ada-in-string-or-comment-p) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
867 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
868 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
869 ;; get the identifier or keyword |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
870 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
871 (setq begin (point)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
872 (setq keywordp (looking-at (concat ada-keywords "[^_]"))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
873 (skip-chars-forward "a-zA-Z0-9_") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
874 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
875 ;; casing according to user-option |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
876 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
877 (if keywordp |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
878 (funcall ada-case-keyword -1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
879 (funcall ada-case-identifier -1)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
880 (goto-char begin)))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
881 (message "adjusting case ... done")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
882 (set-syntax-table ada-mode-syntax-table)))) |
10705 | 883 |
884 | |
885 ;; | |
886 ;; added by MH | |
887 ;; | |
888 (defun ada-adjust-case-buffer () | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
889 "Adjusts the case of all words in the whole buffer. |
10705 | 890 ATTENTION: This function might take very long for big buffers !" |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
891 (interactive "*") |
10705 | 892 (ada-adjust-case-region (point-min) (point-max))) |
893 | |
894 | |
895 ;;;------------------------;;; | |
896 ;;; Format Parameter Lists ;;; | |
897 ;;;------------------------;;; | |
898 | |
899 (defun ada-format-paramlist () | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
900 "Reformats a parameter list. |
10705 | 901 ATTENTION: 1) Comments inside the list are killed ! |
902 2) If the syntax is not correct (especially, if there are | |
903 semicolons missing), it can get totally confused ! | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
904 In such a case, use `undo', correct the syntax and try again." |
10705 | 905 |
906 (interactive) | |
907 (let ((begin nil) | |
908 (end nil) | |
909 (delend nil) | |
910 (paramlist nil)) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
911 (unwind-protect |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
912 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
913 (set-syntax-table ada-mode-symbol-syntax-table) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
914 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
915 ;; check if really inside parameter list |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
916 (or (ada-in-paramlist-p) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
917 (error "not in parameter list")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
918 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
919 ;; find start of current parameter-list |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
920 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
921 (ada-search-ignore-string-comment |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
922 (concat ada-subprog-start-re "\\|\\<body\\>" ) t nil) |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
923 (ada-search-ignore-string-comment "(" nil nil t) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
924 (backward-char 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
925 (setq begin (point)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
926 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
927 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
928 ;; find end of parameter-list |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
929 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
930 (forward-sexp 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
931 (setq delend (point)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
932 (delete-char -1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
933 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
934 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
935 ;; find end of last parameter-declaration |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
936 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
937 (ada-search-ignore-string-comment "[^ \t\n]" t nil t) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
938 (forward-char 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
939 (setq end (point)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
940 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
941 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
942 ;; build a list of all elements of the parameter-list |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
943 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
944 (setq paramlist (ada-scan-paramlist (1+ begin) end)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
945 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
946 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
947 ;; delete the original parameter-list |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
948 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
949 (delete-region begin (1- delend)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
950 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
951 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
952 ;; insert the new parameter-list |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
953 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
954 (goto-char begin) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
955 (ada-insert-paramlist paramlist)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
956 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
957 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
958 ;; restore syntax-table |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
959 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
960 (set-syntax-table ada-mode-syntax-table) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
961 ))) |
10705 | 962 |
963 | |
964 (defun ada-scan-paramlist (begin end) | |
965 ;; Scans a parameter-list between BEGIN and END and returns a list | |
966 ;; of its contents. | |
967 ;; The list has the following format: | |
968 ;; | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
969 ;; Name of Param in? out? access? Name of Type Default-Exp or nil |
10705 | 970 ;; |
971 ;; ( ('Name_Param_1' t nil t Type_Param_1 ':= expression') | |
972 ;; ('Name_Param_2' nil nil t Type_Param_2 nil) ) | |
973 | |
974 (let ((paramlist (list)) | |
975 (param (list)) | |
976 (notend t) | |
977 (apos nil) | |
978 (epos nil) | |
979 (semipos nil) | |
980 (match-cons nil)) | |
981 | |
982 (goto-char begin) | |
983 ;; | |
984 ;; loop until end of last parameter | |
985 ;; | |
986 (while notend | |
987 | |
988 ;; | |
989 ;; find first character of parameter-declaration | |
990 ;; | |
991 (ada-goto-next-non-ws) | |
992 (setq apos (point)) | |
993 | |
994 ;; | |
995 ;; find last character of parameter-declaration | |
996 ;; | |
997 (if (setq match-cons | |
998 (ada-search-ignore-string-comment "[ \t\n]*;" nil end t)) | |
999 (progn | |
1000 (setq epos (car match-cons)) | |
1001 (setq semipos (cdr match-cons))) | |
1002 (setq epos end)) | |
1003 | |
1004 ;; | |
1005 ;; read name(s) of parameter(s) | |
1006 ;; | |
1007 (goto-char apos) | |
1008 (looking-at "\\([a-zA-Z0-9_, \t\n]*[a-zA-Z0-9_]\\)[ \t\n]*:[^=]") | |
1009 | |
1010 (setq param (list (buffer-substring (match-beginning 1) | |
1011 (match-end 1)))) | |
1012 (ada-search-ignore-string-comment ":" nil epos t) | |
1013 | |
1014 ;; | |
1015 ;; look for 'in' | |
1016 ;; | |
1017 (setq apos (point)) | |
1018 (setq param | |
1019 (append param | |
1020 (list | |
1021 (consp | |
1022 (ada-search-ignore-string-comment "\\<in\\>" | |
1023 nil | |
1024 epos | |
1025 t))))) | |
1026 | |
1027 ;; | |
1028 ;; look for 'out' | |
1029 ;; | |
1030 (goto-char apos) | |
1031 (setq param | |
1032 (append param | |
1033 (list | |
1034 (consp | |
1035 (ada-search-ignore-string-comment "\\<out\\>" | |
1036 nil | |
1037 epos | |
1038 t))))) | |
1039 | |
1040 ;; | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1041 ;; look for 'access' |
10705 | 1042 ;; |
1043 (goto-char apos) | |
1044 (setq param | |
1045 (append param | |
1046 (list | |
1047 (consp | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1048 (ada-search-ignore-string-comment "\\<access\\>" |
10705 | 1049 nil |
1050 epos | |
1051 t))))) | |
1052 | |
1053 ;; | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1054 ;; skip 'in'/'out'/'access' |
10705 | 1055 ;; |
1056 (goto-char apos) | |
1057 (ada-goto-next-non-ws) | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1058 (while (looking-at "\\<\\(in\\|out\\|access\\)\\>") |
10705 | 1059 (forward-word 1) |
1060 (ada-goto-next-non-ws)) | |
1061 | |
1062 ;; | |
1063 ;; read type of parameter | |
1064 ;; | |
1065 (looking-at "\\<[a-zA-Z0-9_\\.]+\\>") | |
1066 (setq param | |
1067 (append param | |
1068 (list | |
1069 (buffer-substring (match-beginning 0) | |
1070 (match-end 0))))) | |
1071 | |
1072 ;; | |
1073 ;; read default-expression, if there is one | |
1074 ;; | |
1075 (goto-char (setq apos (match-end 0))) | |
1076 (setq param | |
1077 (append param | |
1078 (list | |
1079 (if (setq match-cons | |
1080 (ada-search-ignore-string-comment ":=" | |
1081 nil | |
1082 epos | |
1083 t)) | |
1084 (buffer-substring (car match-cons) | |
1085 epos) | |
1086 nil)))) | |
1087 ;; | |
1088 ;; add this parameter-declaration to the list | |
1089 ;; | |
1090 (setq paramlist (append paramlist (list param))) | |
1091 | |
1092 ;; | |
1093 ;; check if it was the last parameter | |
1094 ;; | |
1095 (if (eq epos end) | |
1096 (setq notend nil) | |
1097 (goto-char semipos)) | |
1098 | |
1099 ) ; end of loop | |
1100 | |
1101 (reverse paramlist))) | |
1102 | |
1103 | |
1104 (defun ada-insert-paramlist (paramlist) | |
1105 ;; Inserts a formatted PARAMLIST in the buffer. | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1106 ;; See doc of `ada-scan-paramlist' for the format. |
10705 | 1107 (let ((i (length paramlist)) |
1108 (parlen 0) | |
1109 (typlen 0) | |
1110 (temp 0) | |
1111 (inp nil) | |
1112 (outp nil) | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1113 (accessp nil) |
10705 | 1114 (column nil) |
1115 (orgpoint 0) | |
1116 (firstcol nil)) | |
1117 | |
1118 ;; | |
1119 ;; loop until last parameter | |
1120 ;; | |
1121 (while (not (zerop i)) | |
1122 (setq i (1- i)) | |
1123 | |
1124 ;; | |
1125 ;; get max length of parameter-name | |
1126 ;; | |
1127 (setq parlen | |
1128 (if (<= parlen (setq temp | |
1129 (length (nth 0 (nth i paramlist))))) | |
1130 temp | |
1131 parlen)) | |
1132 | |
1133 ;; | |
1134 ;; get max length of type-name | |
1135 ;; | |
1136 (setq typlen | |
1137 (if (<= typlen (setq temp | |
1138 (length (nth 4 (nth i paramlist))))) | |
1139 temp | |
1140 typlen)) | |
1141 | |
1142 ;; | |
1143 ;; is there any 'in' ? | |
1144 ;; | |
1145 (setq inp | |
1146 (or inp | |
1147 (nth 1 (nth i paramlist)))) | |
1148 | |
1149 ;; | |
1150 ;; is there any 'out' ? | |
1151 ;; | |
1152 (setq outp | |
1153 (or outp | |
1154 (nth 2 (nth i paramlist)))) | |
1155 | |
1156 ;; | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1157 ;; is there any 'access' ? |
10705 | 1158 ;; |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1159 (setq accessp |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1160 (or accessp |
10705 | 1161 (nth 3 (nth i paramlist))))) ; end of loop |
1162 | |
1163 ;; | |
1164 ;; does paramlist already start on a separate line ? | |
1165 ;; | |
1166 (if (save-excursion | |
1167 (re-search-backward "^.\\|[^ \t]" nil t) | |
1168 (looking-at "^.")) | |
1169 ;; yes => re-indent it | |
1170 (ada-indent-current) | |
1171 ;; | |
1172 ;; no => insert newline and indent it | |
1173 ;; | |
1174 (progn | |
1175 (ada-indent-current) | |
1176 (newline) | |
1177 (delete-horizontal-space) | |
1178 (setq orgpoint (point)) | |
1179 (setq column (save-excursion | |
1180 (funcall (ada-indent-function) orgpoint))) | |
1181 (indent-to column) | |
1182 )) | |
1183 | |
1184 (insert "(") | |
1185 | |
1186 (setq firstcol (current-column)) | |
1187 (setq i (length paramlist)) | |
1188 | |
1189 ;; | |
1190 ;; loop until last parameter | |
1191 ;; | |
1192 (while (not (zerop i)) | |
1193 (setq i (1- i)) | |
1194 (setq column firstcol) | |
1195 | |
1196 ;; | |
1197 ;; insert parameter-name, space and colon | |
1198 ;; | |
1199 (insert (nth 0 (nth i paramlist))) | |
1200 (indent-to (+ column parlen 1)) | |
1201 (insert ": ") | |
1202 (setq column (current-column)) | |
1203 | |
1204 ;; | |
1205 ;; insert 'in' or space | |
1206 ;; | |
1207 (if (nth 1 (nth i paramlist)) | |
1208 (insert "in ") | |
1209 (if (and | |
1210 (or inp | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1211 accessp) |
10705 | 1212 (not (nth 3 (nth i paramlist)))) |
1213 (insert " "))) | |
1214 | |
1215 ;; | |
1216 ;; insert 'out' or space | |
1217 ;; | |
1218 (if (nth 2 (nth i paramlist)) | |
1219 (insert "out ") | |
1220 (if (and | |
1221 (or outp | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1222 accessp) |
10705 | 1223 (not (nth 3 (nth i paramlist)))) |
1224 (insert " "))) | |
1225 | |
1226 ;; | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1227 ;; insert 'access' |
10705 | 1228 ;; |
1229 (if (nth 3 (nth i paramlist)) | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1230 (insert "access ")) |
10705 | 1231 |
1232 (setq column (current-column)) | |
1233 | |
1234 ;; | |
1235 ;; insert type-name and, if necessary, space and default-expression | |
1236 ;; | |
1237 (insert (nth 4 (nth i paramlist))) | |
1238 (if (nth 5 (nth i paramlist)) | |
1239 (progn | |
1240 (indent-to (+ column typlen 1)) | |
1241 (insert (nth 5 (nth i paramlist))))) | |
1242 | |
1243 ;; | |
1244 ;; check if it was the last parameter | |
1245 ;; | |
1246 (if (not (zerop i)) | |
1247 ;; no => insert ';' and newline and indent | |
1248 (progn | |
1249 (insert ";") | |
1250 (newline) | |
1251 (indent-to firstcol)) | |
1252 ;; yes | |
1253 (insert ")")) | |
1254 | |
1255 ) ; end of loop | |
1256 | |
1257 ;; | |
1258 ;; if anything follows, except semicolon: | |
1259 ;; put it in a new line and indent it | |
1260 ;; | |
1261 (if (not (looking-at "[ \t]*[;\n]")) | |
1262 (ada-indent-newline-indent)) | |
1263 | |
1264 )) | |
1265 | |
1266 | |
1267 ;;;----------------------------;;; | |
1268 ;;; Move To Matching Start/End ;;; | |
1269 ;;;----------------------------;;; | |
1270 | |
1271 (defun ada-move-to-start () | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1272 "Moves point to the matching start of the current Ada structure." |
10705 | 1273 (interactive) |
1274 (let ((pos (point))) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1275 (unwind-protect |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1276 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1277 (set-syntax-table ada-mode-symbol-syntax-table) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1278 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1279 (message "searching for block start ...") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1280 (save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1281 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1282 ;; do nothing if in string or comment or not on 'end ...;' |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1283 ;; or if an error occurs during processing |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1284 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1285 (or |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1286 (ada-in-string-or-comment-p) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1287 (and (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1288 (or (looking-at "[ \t]*\\<end\\>") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1289 (backward-word 1)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1290 (or (looking-at "[ \t]*\\<end\\>") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1291 (backward-word 1)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1292 (or (looking-at "[ \t]*\\<end\\>") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1293 (error "not on end ...;"))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1294 (ada-goto-matching-start 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1295 (setq pos (point)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1296 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1297 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1298 ;; on 'begin' => go on, according to user option |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1299 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1300 ada-move-to-declaration |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1301 (looking-at "\\<begin\\>") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1302 (ada-goto-matching-decl-start) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1303 (setq pos (point)))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1304 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1305 ) ; end of save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1306 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1307 ;; now really move to the found position |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1308 (goto-char pos) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1309 (message "searching for block start ... done")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1310 |
10705 | 1311 ;; |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1312 ;; restore syntax-table |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1313 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1314 (set-syntax-table ada-mode-syntax-table)))) |
10705 | 1315 |
1316 | |
1317 (defun ada-move-to-end () | |
1318 "Moves point to the matching end of the current block around point. | |
1319 Moves to 'begin' if in a declarative part." | |
1320 (interactive) | |
1321 (let ((pos (point)) | |
1322 (decstart nil) | |
1323 (packdecl nil)) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1324 (unwind-protect |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1325 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1326 (set-syntax-table ada-mode-symbol-syntax-table) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1327 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1328 (message "searching for block end ...") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1329 (save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1330 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1331 (forward-char 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1332 (cond |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1333 ;; directly on 'begin' |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1334 ((save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1335 (ada-goto-previous-word) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1336 (looking-at "\\<begin\\>")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1337 (ada-goto-matching-end 1)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1338 ;; on first line of defun declaration |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1339 ((save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1340 (and (ada-goto-stmt-start) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1341 (looking-at "\\<function\\>\\|\\<procedure\\>" ))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1342 (ada-search-ignore-string-comment "\\<begin\\>")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1343 ;; on first line of task declaration |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1344 ((save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1345 (and (ada-goto-stmt-start) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1346 (looking-at "\\<task\\>" ) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1347 (forward-word 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1348 (ada-search-ignore-string-comment "[^ \n\t]") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1349 (not (backward-char 1)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1350 (looking-at "\\<body\\>"))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1351 (ada-search-ignore-string-comment "\\<begin\\>")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1352 ;; accept block start |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1353 ((save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1354 (and (ada-goto-stmt-start) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1355 (looking-at "\\<accept\\>" ))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1356 (ada-goto-matching-end 0)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1357 ;; package start |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1358 ((save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1359 (and (ada-goto-matching-decl-start t) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1360 (looking-at "\\<package\\>"))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1361 (ada-goto-matching-end 1)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1362 ;; inside a 'begin' ... 'end' block |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1363 ((save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1364 (ada-goto-matching-decl-start t)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1365 (ada-search-ignore-string-comment "\\<begin\\>")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1366 ;; (hopefully ;-) everything else |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1367 (t |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1368 (ada-goto-matching-end 1))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1369 (setq pos (point)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1370 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1371 ) ; end of save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1372 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1373 ;; now really move to the found position |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1374 (goto-char pos) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1375 (message "searching for block end ... done")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1376 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1377 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1378 ;; restore syntax-table |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1379 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1380 (set-syntax-table ada-mode-syntax-table)))) |
10705 | 1381 |
1382 | |
1383 ;;;-----------------------------;;; | |
1384 ;;; Functions For Indentation ;;; | |
1385 ;;;-----------------------------;;; | |
1386 | |
1387 ;; ---- main functions for indentation | |
1388 | |
1389 (defun ada-indent-region (beg end) | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1390 "Indents the region using `ada-indent-current' on each line." |
10705 | 1391 (interactive "*r") |
1392 (goto-char beg) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1393 (let ((block-done 0) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1394 (lines-remaining (count-lines beg end)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1395 (msg (format "indenting %4d lines %%4d lines remaining ..." |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1396 (count-lines beg end))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1397 (endmark (copy-marker end))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1398 ;; catch errors while indenting |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1399 (condition-case err |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1400 (while (< (point) endmark) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1401 (if (> block-done 9) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1402 (progn (message (format msg lines-remaining)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1403 (setq block-done 0))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1404 (if (looking-at "^$") nil |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1405 (ada-indent-current)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1406 (forward-line 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1407 (setq block-done (1+ block-done)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1408 (setq lines-remaining (1- lines-remaining))) |
13963
a62c62ac5102
(ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
1409 ;; show line number where the error occurred |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1410 (error |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1411 (error (format "line %d: %s" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1412 (1+ (count-lines (point-min) (point))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1413 err) nil))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1414 (message "indenting ... done"))) |
10705 | 1415 |
1416 | |
1417 (defun ada-indent-newline-indent () | |
1418 "Indents the current line, inserts a newline and then indents the new line." | |
1419 (interactive "*") | |
1420 (let ((column) | |
1421 (orgpoint)) | |
1422 | |
1423 (ada-indent-current) | |
1424 (newline) | |
1425 (delete-horizontal-space) | |
1426 (setq orgpoint (point)) | |
1427 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1428 (unwind-protect |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1429 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1430 (set-syntax-table ada-mode-symbol-syntax-table) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1431 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1432 (setq column (save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1433 (funcall (ada-indent-function) orgpoint)))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1434 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1435 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1436 ;; restore syntax-table |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1437 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1438 (set-syntax-table ada-mode-syntax-table)) |
10705 | 1439 |
1440 (indent-to column) | |
1441 | |
1442 ;; The following is needed to ensure that indentation will still be | |
1443 ;; correct if something follows behind point when typing LFD | |
1444 ;; For example: Imagine point to be there (*) when LFD is typed: | |
1445 ;; while cond loop | |
1446 ;; null; *end loop; | |
1447 ;; Result without the following statement would be: | |
1448 ;; while cond loop | |
1449 ;; null; | |
1450 ;; *end loop; | |
1451 ;; You would then have to type TAB to correct it. | |
1452 ;; If that doesn't bother you, you can comment out the following | |
1453 ;; statement to speed up indentation a LITTLE bit. | |
1454 | |
1455 (if (not (looking-at "[ \t]*$")) | |
1456 (ada-indent-current)) | |
1457 )) | |
1458 | |
1459 | |
1460 (defun ada-indent-current () | |
1461 "Indents current line as Ada code. | |
1462 This works by two steps: | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
1463 1) It moves point to the end of the previous code line. |
10705 | 1464 Then it calls the function to calculate the indentation for the |
1465 following line as if a newline would be inserted there. | |
1466 The calculated column # is saved and the old position of point | |
1467 is restored. | |
1468 2) Then another function is called to calculate the indentation for | |
1469 the current line, based on the previously calculated column #." | |
1470 | |
1471 (interactive) | |
1472 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1473 (unwind-protect |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1474 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1475 (set-syntax-table ada-mode-symbol-syntax-table) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1476 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1477 (let ((line-end) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1478 (orgpoint (point-marker)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1479 (cur-indent) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1480 (prev-indent) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1481 (prevline t)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1482 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1483 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1484 ;; first step |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1485 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1486 (save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1487 (if (ada-goto-prev-nonblank-line t) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1488 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1489 ;; we are not in the first accessible line in the buffer |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1490 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1491 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1492 ;;(end-of-line) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1493 ;;(forward-char 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1494 ;; we are already at the BOL |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1495 (forward-line 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1496 (setq line-end (point)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1497 (setq prev-indent |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1498 (save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1499 (funcall (ada-indent-function) line-end)))) |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
1500 (progn ; first line of buffer -> set indent |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
1501 (beginning-of-line) ; to 0 |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
1502 (delete-horizontal-space) |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
1503 (setq prevline nil)))) |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1504 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1505 (if prevline |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1506 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1507 ;; we are not in the first accessible line in the buffer |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1508 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1509 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1510 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1511 ;; second step |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1512 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1513 (back-to-indentation) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1514 (setq cur-indent (ada-get-current-indent prev-indent)) |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
1515 ;; only reindent if indentation is different then the current |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
1516 (if (= (current-column) cur-indent) |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
1517 nil |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1518 (delete-horizontal-space) |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
1519 (indent-to cur-indent)) |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1520 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1521 ;; restore position of point |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1522 ;; |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1523 (goto-char orgpoint) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1524 (if (< (current-column) (current-indentation)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1525 (back-to-indentation)))))) |
10705 | 1526 |
1527 ;; | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1528 ;; restore syntax-table |
10705 | 1529 ;; |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1530 (set-syntax-table ada-mode-syntax-table))) |
10705 | 1531 |
1532 | |
1533 (defun ada-get-current-indent (prev-indent) | |
1534 ;; Returns the column # to indent the current line to. | |
1535 ;; PREV-INDENT is the indentation resulting from the previous lines. | |
1536 (let ((column nil) | |
1537 (pos nil) | |
1538 (match-cons nil)) | |
1539 | |
1540 (cond | |
1541 ;; | |
1542 ;; in open parenthesis, but not in parameter-list | |
1543 ;; | |
1544 ((and | |
1545 ada-indent-to-open-paren | |
1546 (not (ada-in-paramlist-p)) | |
1547 (setq column (ada-in-open-paren-p))) | |
1548 ;; check if we have something like this (Table_Component_Type => | |
1549 ;; Source_File_Record,) | |
1550 (save-excursion | |
1551 (if (and (ada-search-ignore-string-comment "[^ \t]" t nil) | |
1552 (looking-at "\n") | |
1553 (ada-search-ignore-string-comment "[^ \t\n]" t nil) | |
1554 (looking-at ">")) | |
1555 (setq column (+ ada-broken-indent column)))) | |
1556 column) | |
1557 | |
1558 ;; | |
1559 ;; end | |
1560 ;; | |
1561 ((looking-at "\\<end\\>") | |
1562 (save-excursion | |
1563 (ada-goto-matching-start 1) | |
1564 | |
1565 ;; | |
1566 ;; found 'loop' => skip back to 'while' or 'for' | |
1567 ;; if 'loop' is not on a separate line | |
1568 ;; | |
1569 (if (and | |
1570 (looking-at "\\<loop\\>") | |
1571 (save-excursion | |
1572 (back-to-indentation) | |
1573 (not (looking-at "\\<loop\\>")))) | |
1574 (if (save-excursion | |
1575 (and | |
1576 (setq match-cons | |
1577 (ada-search-ignore-string-comment | |
1578 ada-loop-start-re t nil)) | |
1579 (not (looking-at "\\<loop\\>")))) | |
1580 (goto-char (car match-cons)))) | |
1581 | |
1582 (current-indentation))) | |
1583 ;; | |
1584 ;; exception | |
1585 ;; | |
1586 ((looking-at "\\<exception\\>") | |
1587 (save-excursion | |
1588 (ada-goto-matching-start 1) | |
1589 (current-indentation))) | |
1590 ;; | |
1591 ;; when | |
1592 ;; | |
1593 ((looking-at "\\<when\\>") | |
1594 (save-excursion | |
1595 (ada-goto-matching-start 1) | |
1596 (+ (current-indentation) ada-when-indent))) | |
1597 ;; | |
1598 ;; else | |
1599 ;; | |
1600 ((looking-at "\\<else\\>") | |
1601 (if (save-excursion | |
1602 (ada-goto-previous-word) | |
1603 (looking-at "\\<or\\>")) | |
1604 prev-indent | |
1605 (save-excursion | |
1606 (ada-goto-matching-start 1 nil t) | |
1607 (current-indentation)))) | |
1608 ;; | |
1609 ;; elsif | |
1610 ;; | |
1611 ((looking-at "\\<elsif\\>") | |
1612 (save-excursion | |
1613 (ada-goto-matching-start 1 nil t) | |
1614 (current-indentation))) | |
1615 ;; | |
1616 ;; then | |
1617 ;; | |
1618 ((looking-at "\\<then\\>") | |
1619 (if (save-excursion | |
1620 (ada-goto-previous-word) | |
1621 (looking-at "\\<and\\>")) | |
1622 prev-indent | |
1623 (save-excursion | |
1624 (ada-search-ignore-string-comment "\\<elsif\\>\\|\\<if\\>" t nil) | |
1625 (+ (current-indentation) ada-stmt-end-indent)))) | |
1626 ;; | |
1627 ;; loop | |
1628 ;; | |
1629 ((looking-at "\\<loop\\>") | |
1630 (setq pos (point)) | |
1631 (save-excursion | |
1632 (goto-char (match-end 0)) | |
1633 (ada-goto-stmt-start) | |
1634 (if (looking-at "\\<loop\\>\\|\\<if\\>") | |
1635 prev-indent | |
1636 (progn | |
1637 (if (not (looking-at ada-loop-start-re)) | |
1638 (ada-search-ignore-string-comment ada-loop-start-re | |
1639 nil pos)) | |
1640 (if (looking-at "\\<loop\\>") | |
1641 prev-indent | |
1642 (+ (current-indentation) ada-stmt-end-indent)))))) | |
1643 ;; | |
1644 ;; begin | |
1645 ;; | |
1646 ((looking-at "\\<begin\\>") | |
1647 (save-excursion | |
1648 (if (ada-goto-matching-decl-start t) | |
1649 (current-indentation) | |
1650 (progn | |
1651 (message "no matching declaration start") | |
1652 prev-indent)))) | |
1653 ;; | |
1654 ;; is | |
1655 ;; | |
1656 ((looking-at "\\<is\\>") | |
1657 (if (and | |
1658 ada-indent-is-separate | |
1659 (save-excursion | |
1660 (goto-char (match-end 0)) | |
1661 (ada-goto-next-non-ws (save-excursion | |
1662 (end-of-line) | |
1663 (point))) | |
1664 (looking-at "\\<abstract\\>\\|\\<separate\\>"))) | |
1665 (save-excursion | |
1666 (ada-goto-stmt-start) | |
1667 (+ (current-indentation) ada-indent)) | |
1668 (save-excursion | |
1669 (ada-goto-stmt-start) | |
1670 (+ (current-indentation) ada-stmt-end-indent)))) | |
1671 ;; | |
1672 ;; record | |
1673 ;; | |
1674 ((looking-at "\\<record\\>") | |
1675 (save-excursion | |
1676 (ada-search-ignore-string-comment | |
1677 "\\<\\(type\\|use\\)\\>" t nil) | |
1678 (if (looking-at "\\<use\\>") | |
1679 (ada-search-ignore-string-comment "\\<for\\>" t nil)) | |
1680 (+ (current-indentation) ada-indent-record-rel-type))) | |
1681 ;; | |
1682 ;; or as statement-start | |
1683 ;; | |
1684 ((ada-looking-at-semi-or) | |
1685 (save-excursion | |
1686 (ada-goto-matching-start 1) | |
1687 (current-indentation))) | |
1688 ;; | |
1689 ;; private as statement-start | |
1690 ;; | |
1691 ((ada-looking-at-semi-private) | |
1692 (save-excursion | |
1693 (ada-goto-matching-decl-start) | |
1694 (current-indentation))) | |
1695 ;; | |
1696 ;; new/abstract/separate | |
1697 ;; | |
1698 ((looking-at "\\<\\(new\\|abstract\\|separate\\)\\>") | |
1699 (- prev-indent ada-indent (- ada-broken-indent))) | |
1700 ;; | |
1701 ;; return | |
1702 ;; | |
1703 ((looking-at "\\<return\\>") | |
1704 (save-excursion | |
1705 (forward-sexp -1) | |
1706 (if (and (looking-at "(") | |
1707 (save-excursion | |
1708 (backward-sexp 2) | |
1709 (looking-at "\\<function\\>"))) | |
1710 (1+ (current-column)) | |
1711 prev-indent))) | |
1712 ;; | |
1713 ;; do | |
1714 ;; | |
1715 ((looking-at "\\<do\\>") | |
1716 (save-excursion | |
1717 (ada-goto-stmt-start) | |
1718 (+ (current-indentation) ada-stmt-end-indent))) | |
1719 ;; | |
1720 ;; package/function/procedure | |
1721 ;; | |
1722 ((and (looking-at "\\<\\(package\\|function\\|procedure\\)\\>") | |
1723 (save-excursion | |
1724 (forward-char 1) | |
1725 (ada-goto-stmt-start) | |
1726 (looking-at "\\<\\(package\\|function\\|procedure\\)\\>"))) | |
1727 (save-excursion | |
1728 ;; look for 'generic' | |
1729 (if (and (ada-goto-matching-decl-start t) | |
1730 (looking-at "generic")) | |
1731 (current-column) | |
1732 prev-indent))) | |
1733 ;; | |
1734 ;; label | |
1735 ;; | |
1736 ((looking-at "\\<[a-zA-Z0-9_]+[ \t\n]*:[^=]") | |
1737 (if (ada-in-decl-p) | |
1738 prev-indent | |
1739 (+ prev-indent ada-label-indent))) | |
1740 ;; | |
1741 ;; identifier and other noindent-statements | |
1742 ;; | |
1743 ((looking-at "\\<[a-zA-Z0-9_]+[ \t\n]*") | |
1744 prev-indent) | |
1745 ;; | |
1746 ;; beginning of a parameter list | |
1747 ;; | |
1748 ((looking-at "(") | |
1749 prev-indent) | |
1750 ;; | |
1751 ;; end of a parameter list | |
1752 ;; | |
1753 ((looking-at ")") | |
1754 (save-excursion | |
1755 (forward-char 1) | |
1756 (backward-sexp 1) | |
1757 (current-column))) | |
1758 ;; | |
1759 ;; comment | |
1760 ;; | |
1761 ((looking-at "--") | |
1762 (if ada-indent-comment-as-code | |
1763 prev-indent | |
1764 (current-indentation))) | |
1765 ;; | |
1766 ;; unknown syntax - maybe this should signal an error ? | |
1767 ;; | |
1768 (t | |
1769 prev-indent)))) | |
1770 | |
1771 | |
1772 (defun ada-indent-function (&optional nomove) | |
1773 ;; Returns the function to calculate the indentation for the current | |
1774 ;; line according to the previous statement, ignoring the contents | |
1775 ;; of the current line after point. Moves point to the beginning of | |
1776 ;; the current statement, if NOMOVE is nil. | |
1777 | |
1778 (let ((orgpoint (point)) | |
1779 (func nil) | |
1780 (stmt-start nil)) | |
1781 ;; | |
1782 ;; inside a parameter-list | |
1783 ;; | |
1784 (if (ada-in-paramlist-p) | |
1785 (setq func 'ada-get-indent-paramlist) | |
1786 (progn | |
1787 ;; | |
1788 ;; move to beginning of current statement | |
1789 ;; | |
1790 (if (not nomove) | |
1791 (setq stmt-start (ada-goto-stmt-start))) | |
1792 ;; | |
1793 ;; no beginning found => don't change indentation | |
1794 ;; | |
1795 (if (and | |
1796 (eq orgpoint (point)) | |
1797 (not nomove)) | |
1798 (setq func 'ada-get-indent-nochange) | |
1799 | |
1800 (cond | |
1801 ;; | |
1802 ((and | |
1803 ada-indent-to-open-paren | |
1804 (ada-in-open-paren-p)) | |
1805 (setq func 'ada-get-indent-open-paren)) | |
1806 ;; | |
1807 ((looking-at "\\<end\\>") | |
1808 (setq func 'ada-get-indent-end)) | |
1809 ;; | |
1810 ((looking-at ada-loop-start-re) | |
1811 (setq func 'ada-get-indent-loop)) | |
1812 ;; | |
1813 ((looking-at ada-subprog-start-re) | |
1814 (setq func 'ada-get-indent-subprog)) | |
1815 ;; | |
1816 ((looking-at "\\<package\\>") | |
1817 (setq func 'ada-get-indent-subprog)) ; maybe it needs a | |
1818 ; special function | |
1819 ; sometimes ? | |
1820 ;; | |
1821 ((looking-at ada-block-start-re) | |
1822 (setq func 'ada-get-indent-block-start)) | |
1823 ;; | |
1824 ((looking-at "\\<type\\>") | |
1825 (setq func 'ada-get-indent-type)) | |
1826 ;; | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1827 ((looking-at "\\<\\(els\\)?if\\>") |
10705 | 1828 (setq func 'ada-get-indent-if)) |
1829 ;; | |
1830 ((looking-at "\\<case\\>") | |
1831 (setq func 'ada-get-indent-case)) | |
1832 ;; | |
1833 ((looking-at "\\<when\\>") | |
1834 (setq func 'ada-get-indent-when)) | |
1835 ;; | |
1836 ((looking-at "--") | |
1837 (setq func 'ada-get-indent-comment)) | |
1838 ;; | |
1839 ((looking-at "[a-zA-Z0-9_]+[ \t\n]*:[^=]") | |
1840 (setq func 'ada-get-indent-label)) | |
1841 ;; | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1842 ((looking-at "\\<separate\\>") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1843 (setq func 'ada-get-indent-nochange)) |
10705 | 1844 (t |
1845 (setq func 'ada-get-indent-noindent)))))) | |
1846 | |
1847 func)) | |
1848 | |
1849 | |
1850 ;; ---- functions to return indentation for special cases | |
1851 | |
1852 (defun ada-get-indent-open-paren (orgpoint) | |
1853 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
13963
a62c62ac5102
(ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
1854 ;; Assumes point to be behind an open parenthesis not yet closed. |
10705 | 1855 (ada-in-open-paren-p)) |
1856 | |
1857 | |
1858 (defun ada-get-indent-nochange (orgpoint) | |
1859 ;; Returns the indentation (column #) of the current line. | |
1860 (save-excursion | |
1861 (forward-line -1) | |
1862 (current-indentation))) | |
1863 | |
1864 | |
1865 (defun ada-get-indent-paramlist (orgpoint) | |
1866 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
1867 ;; Assumes point to be inside a parameter-list. | |
1868 (save-excursion | |
1869 (ada-search-ignore-string-comment "[^ \t\n]" t nil t) | |
1870 (cond | |
1871 ;; | |
1872 ;; in front of the first parameter | |
1873 ;; | |
1874 ((looking-at "(") | |
1875 (goto-char (match-end 0)) | |
1876 (current-column)) | |
1877 ;; | |
1878 ;; in front of another parameter | |
1879 ;; | |
1880 ((looking-at ";") | |
1881 (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t))) | |
1882 (ada-goto-next-non-ws) | |
1883 (current-column)) | |
1884 ;; | |
1885 ;; inside a parameter declaration | |
1886 ;; | |
1887 (t | |
1888 (goto-char (cdr (ada-search-ignore-string-comment "(\\|;" t nil t))) | |
1889 (ada-goto-next-non-ws) | |
1890 (+ (current-column) ada-broken-indent))))) | |
1891 | |
1892 | |
1893 (defun ada-get-indent-end (orgpoint) | |
1894 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
1895 ;; Assumes point to be at the beginning of an end-statement. | |
1896 ;; Therefore it has to find the corresponding start. This can be a little | |
1897 ;; slow, if it has to search through big files with many nested blocks. | |
1898 ;; Signals an error if the corresponding block-start doesn't match. | |
1899 (let ((defun-name nil) | |
1900 (indent nil)) | |
1901 ;; | |
1902 ;; is the line already terminated by ';' ? | |
1903 ;; | |
1904 (if (save-excursion | |
1905 (ada-search-ignore-string-comment ";" nil orgpoint)) | |
1906 ;; | |
1907 ;; yes, look what's following 'end' | |
1908 ;; | |
1909 (progn | |
1910 (forward-word 1) | |
1911 (ada-goto-next-non-ws) | |
1912 (cond | |
1913 ;; | |
1914 ;; loop/select/if/case/record/select | |
1915 ;; | |
1916 ((looking-at "\\<\\(loop\\|select\\|if\\|case\\|record\\)\\>") | |
1917 (save-excursion | |
1918 (ada-check-matching-start | |
1919 (buffer-substring (match-beginning 0) | |
1920 (match-end 0))) | |
1921 (if (looking-at "\\<\\(loop\\|record\\)\\>") | |
1922 (progn | |
1923 (forward-word 1) | |
1924 (ada-goto-stmt-start))) | |
1925 ;; a label ? => skip it | |
1926 (if (looking-at "[a-zA-Z0-9_]+[ \n\t]+:") | |
1927 (progn | |
1928 (goto-char (match-end 0)) | |
1929 (ada-goto-next-non-ws))) | |
1930 ;; really looking-at the right thing ? | |
1931 (or (looking-at (concat "\\<\\(" | |
1932 "loop\\|select\\|if\\|case\\|" | |
1933 "record\\|while\\|type\\)\\>")) | |
1934 (progn | |
1935 (ada-search-ignore-string-comment | |
1936 (concat "\\<\\(" | |
1937 "loop\\|select\\|if\\|case\\|" | |
1938 "record\\|while\\|type\\)\\>"))) | |
1939 (backward-word 1)) | |
1940 (current-indentation))) | |
1941 ;; | |
1942 ;; a named block end | |
1943 ;; | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
1944 ((looking-at ada-ident-re) |
10705 | 1945 (setq defun-name (buffer-substring (match-beginning 0) |
1946 (match-end 0))) | |
1947 (save-excursion | |
1948 (ada-goto-matching-start 0) | |
1949 (ada-check-defun-name defun-name) | |
1950 (current-indentation))) | |
1951 ;; | |
1952 ;; a block-end without name | |
1953 ;; | |
1954 ((looking-at ";") | |
1955 (save-excursion | |
1956 (ada-goto-matching-start 0) | |
1957 (if (looking-at "\\<begin\\>") | |
1958 (progn | |
1959 (setq indent (current-column)) | |
1960 (if (ada-goto-matching-decl-start t) | |
1961 (current-indentation) | |
1962 indent))))) | |
1963 ;; | |
1964 ;; anything else - should maybe signal an error ? | |
1965 ;; | |
1966 (t | |
1967 (+ (current-indentation) ada-broken-indent)))) | |
1968 | |
1969 (+ (current-indentation) ada-broken-indent)))) | |
1970 | |
1971 | |
1972 (defun ada-get-indent-case (orgpoint) | |
1973 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
1974 ;; Assumes point to be at the beginning of an case-statement. | |
1975 (let ((cur-indent (current-indentation)) | |
1976 (match-cons nil) | |
1977 (opos (point))) | |
1978 (cond | |
1979 ;; | |
1980 ;; case..is..when..=> | |
1981 ;; | |
1982 ((save-excursion | |
1983 (setq match-cons (ada-search-ignore-string-comment | |
1984 "[ \t\n]+=>" nil orgpoint))) | |
1985 (save-excursion | |
1986 (goto-char (car match-cons)) | |
1987 (if (not (ada-search-ignore-string-comment "\\<when\\>" t opos)) | |
1988 (error "missing 'when' between 'case' and '=>'")) | |
1989 (+ (current-indentation) ada-indent))) | |
1990 ;; | |
1991 ;; case..is..when | |
1992 ;; | |
1993 ((save-excursion | |
1994 (setq match-cons (ada-search-ignore-string-comment | |
1995 "\\<when\\>" nil orgpoint))) | |
1996 (goto-char (cdr match-cons)) | |
1997 (+ (current-indentation) ada-broken-indent)) | |
1998 ;; | |
1999 ;; case..is | |
2000 ;; | |
2001 ((save-excursion | |
2002 (setq match-cons (ada-search-ignore-string-comment | |
2003 "\\<is\\>" nil orgpoint))) | |
2004 (+ (current-indentation) ada-when-indent)) | |
2005 ;; | |
2006 ;; incomplete case | |
2007 ;; | |
2008 (t | |
2009 (+ (current-indentation) ada-broken-indent))))) | |
2010 | |
2011 | |
2012 (defun ada-get-indent-when (orgpoint) | |
2013 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
2014 ;; Assumes point to be at the beginning of an when-statement. | |
2015 (let ((cur-indent (current-indentation))) | |
2016 (if (ada-search-ignore-string-comment | |
2017 "[ \t\n]+=>" nil orgpoint) | |
2018 (+ cur-indent ada-indent) | |
2019 (+ cur-indent ada-broken-indent)))) | |
2020 | |
2021 | |
2022 (defun ada-get-indent-if (orgpoint) | |
2023 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
2024 ;; Assumes point to be at the beginning of an if-statement. | |
2025 (let ((cur-indent (current-indentation)) | |
2026 (match-cons nil)) | |
2027 ;; | |
2028 ;; if..then ? | |
2029 ;; | |
2030 (if (ada-search-but-not | |
2031 "\\<then\\>" "\\<and\\>[ \t\n]+\\<then\\>" nil orgpoint) | |
2032 | |
2033 (progn | |
2034 ;; | |
2035 ;; 'then' first in separate line ? | |
2036 ;; => indent according to 'then' | |
2037 ;; | |
2038 (if (save-excursion | |
2039 (back-to-indentation) | |
2040 (looking-at "\\<then\\>")) | |
2041 (setq cur-indent (current-indentation))) | |
2042 (forward-word 1) | |
2043 ;; | |
2044 ;; something follows 'then' ? | |
2045 ;; | |
2046 (if (setq match-cons | |
2047 (ada-search-ignore-string-comment | |
2048 "[^ \t\n]" nil orgpoint)) | |
2049 (progn | |
2050 (goto-char (car match-cons)) | |
2051 (+ ada-indent | |
2052 (- cur-indent (current-indentation)) | |
2053 (funcall (ada-indent-function t) orgpoint))) | |
2054 | |
2055 (+ cur-indent ada-indent))) | |
2056 | |
2057 (+ cur-indent ada-broken-indent)))) | |
2058 | |
2059 | |
2060 (defun ada-get-indent-block-start (orgpoint) | |
2061 ;; Returns the indentation (column #) for the new line after | |
2062 ;; ORGPOINT. Assumes point to be at the beginning of a block start | |
2063 ;; keyword. | |
2064 (let ((cur-indent (current-indentation)) | |
2065 (pos nil)) | |
2066 (cond | |
2067 ((save-excursion | |
2068 (forward-word 1) | |
2069 (setq pos (car (ada-search-ignore-string-comment | |
2070 "[^ \t\n]" nil orgpoint)))) | |
2071 (goto-char pos) | |
2072 (save-excursion | |
2073 (funcall (ada-indent-function t) orgpoint))) | |
2074 ;; | |
2075 ;; nothing follows the block-start | |
2076 ;; | |
2077 (t | |
2078 (+ (current-indentation) ada-indent))))) | |
2079 | |
2080 | |
2081 (defun ada-get-indent-subprog (orgpoint) | |
2082 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
2083 ;; Assumes point to be at the beginning of a subprog-/package-declaration. | |
2084 (let ((match-cons nil) | |
2085 (cur-indent (current-indentation)) | |
2086 (foundis nil) | |
2087 (addind 0) | |
2088 (fstart (point))) | |
2089 ;; | |
2090 ;; is there an 'is' in front of point ? | |
2091 ;; | |
2092 (if (save-excursion | |
2093 (setq match-cons | |
2094 (ada-search-ignore-string-comment | |
2095 "\\<is\\>\\|\\<do\\>" nil orgpoint))) | |
2096 ;; | |
2097 ;; yes, then skip to its end | |
2098 ;; | |
2099 (progn | |
2100 (setq foundis t) | |
2101 (goto-char (cdr match-cons))) | |
2102 ;; | |
2103 ;; no, then goto next non-ws, if there is one in front of point | |
2104 ;; | |
2105 (progn | |
2106 (if (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint) | |
2107 (ada-goto-next-non-ws) | |
2108 (goto-char orgpoint)))) | |
2109 | |
2110 (cond | |
2111 ;; | |
2112 ;; nothing follows 'is' | |
2113 ;; | |
2114 ((and | |
2115 foundis | |
2116 (save-excursion | |
2117 (not (ada-search-ignore-string-comment | |
2118 "[^ \t\n]" nil orgpoint t)))) | |
2119 (+ cur-indent ada-indent)) | |
2120 ;; | |
2121 ;; is abstract/separate/new ... | |
2122 ;; | |
2123 ((and | |
2124 foundis | |
2125 (save-excursion | |
2126 (setq match-cons | |
2127 (ada-search-ignore-string-comment | |
2128 "\\<\\(separate\\|new\\|abstract\\)\\>" | |
2129 nil orgpoint)))) | |
2130 (goto-char (car match-cons)) | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2131 (ada-search-ignore-string-comment ada-subprog-start-re t) |
10705 | 2132 (ada-get-indent-noindent orgpoint)) |
2133 ;; | |
2134 ;; something follows 'is' | |
2135 ;; | |
2136 ((and | |
2137 foundis | |
2138 (save-excursion | |
2139 (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint)) | |
2140 (ada-goto-next-non-ws) | |
2141 (funcall (ada-indent-function t) orgpoint))) | |
2142 ;; | |
2143 ;; no 'is' but ';' | |
2144 ;; | |
2145 ((save-excursion | |
2146 (ada-search-ignore-string-comment ";" nil orgpoint)) | |
2147 cur-indent) | |
2148 ;; | |
2149 ;; no 'is' or ';' | |
2150 ;; | |
2151 (t | |
2152 (+ cur-indent ada-broken-indent))))) | |
2153 | |
2154 | |
2155 (defun ada-get-indent-noindent (orgpoint) | |
2156 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
2157 ;; Assumes point to be at the beginning of a 'noindent statement'. | |
2158 (if (save-excursion | |
2159 (ada-search-ignore-string-comment ";" nil orgpoint)) | |
2160 (current-indentation) | |
2161 (+ (current-indentation) ada-broken-indent))) | |
2162 | |
2163 | |
2164 (defun ada-get-indent-label (orgpoint) | |
2165 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
2166 ;; Assumes point to be at the beginning of a label or variable declaration. | |
2167 ;; Checks the context to decide if it's a label or a variable declaration. | |
2168 ;; This check might be a bit slow. | |
2169 (let ((match-cons nil) | |
2170 (cur-indent (current-indentation))) | |
2171 (goto-char (cdr (ada-search-ignore-string-comment ":"))) | |
2172 (cond | |
2173 ;; | |
2174 ;; loop label | |
2175 ;; | |
2176 ((save-excursion | |
2177 (setq match-cons (ada-search-ignore-string-comment | |
2178 ada-loop-start-re nil orgpoint))) | |
2179 (goto-char (car match-cons)) | |
2180 (ada-get-indent-loop orgpoint)) | |
2181 ;; | |
2182 ;; declare label | |
2183 ;; | |
2184 ((save-excursion | |
2185 (setq match-cons (ada-search-ignore-string-comment | |
2186 "\\<declare\\>" nil orgpoint))) | |
2187 (save-excursion | |
2188 (goto-char (car match-cons)) | |
2189 (+ (current-indentation) ada-indent))) | |
2190 ;; | |
2191 ;; complete statement following colon | |
2192 ;; | |
2193 ((save-excursion | |
2194 (ada-search-ignore-string-comment ";" nil orgpoint)) | |
2195 (if (ada-in-decl-p) | |
2196 cur-indent ; variable-declaration | |
2197 (- cur-indent ada-label-indent))) ; label | |
2198 ;; | |
2199 ;; broken statement | |
2200 ;; | |
2201 ((save-excursion | |
2202 (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint)) | |
2203 (if (ada-in-decl-p) | |
2204 (+ cur-indent ada-broken-indent) | |
2205 (+ cur-indent ada-broken-indent (- ada-label-indent)))) | |
2206 ;; | |
2207 ;; nothing follows colon | |
2208 ;; | |
2209 (t | |
2210 (if (ada-in-decl-p) | |
2211 (+ cur-indent ada-broken-indent) ; variable-declaration | |
2212 (- cur-indent ada-label-indent)))))) ; label | |
2213 | |
2214 | |
2215 (defun ada-get-indent-loop (orgpoint) | |
2216 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
2217 ;; Assumes point to be at the beginning of a loop statement | |
2218 ;; or (unfortunately) also a for ... use statement. | |
2219 (let ((match-cons nil) | |
2220 (pos (point))) | |
2221 (cond | |
2222 | |
2223 ;; | |
2224 ;; statement complete | |
2225 ;; | |
2226 ((save-excursion | |
2227 (ada-search-ignore-string-comment ";" nil orgpoint)) | |
2228 (current-indentation)) | |
2229 ;; | |
2230 ;; simple loop | |
2231 ;; | |
2232 ((looking-at "loop\\>") | |
2233 (ada-get-indent-block-start orgpoint)) | |
2234 | |
2235 ;; | |
2236 ;; 'for'- loop (or also a for ... use statement) | |
2237 ;; | |
2238 ((looking-at "for\\>") | |
2239 (cond | |
2240 ;; | |
2241 ;; for ... use | |
2242 ;; | |
2243 ((save-excursion | |
2244 (and | |
2245 (goto-char (match-end 0)) | |
2246 (ada-search-ignore-string-comment "[^ /n/t]" nil orgpoint) | |
2247 (not (backward-char 1)) | |
2248 (not (zerop (skip-chars-forward "_a-zA-Z0-9'"))) | |
2249 (ada-search-ignore-string-comment "[^ /n/t]" nil orgpoint) | |
2250 (not (backward-char 1)) | |
2251 (looking-at "\\<use\\>") | |
2252 ;; | |
2253 ;; check if there is a 'record' before point | |
2254 ;; | |
2255 (progn | |
2256 (setq match-cons (ada-search-ignore-string-comment | |
2257 "\\<record\\>" nil orgpoint)) | |
2258 t))) | |
2259 (if match-cons | |
2260 (goto-char (car match-cons))) | |
2261 (+ (current-indentation) ada-indent)) | |
2262 ;; | |
2263 ;; for..loop | |
2264 ;; | |
2265 ((save-excursion | |
2266 (setq match-cons (ada-search-ignore-string-comment | |
2267 "\\<loop\\>" nil orgpoint))) | |
2268 (goto-char (car match-cons)) | |
2269 ;; | |
2270 ;; indent according to 'loop', if it's first in the line; | |
2271 ;; otherwise to 'for' | |
2272 ;; | |
2273 (if (not (save-excursion | |
2274 (back-to-indentation) | |
2275 (looking-at "\\<loop\\>"))) | |
2276 (goto-char pos)) | |
2277 (+ (current-indentation) ada-indent)) | |
2278 ;; | |
2279 ;; for-statement is broken | |
2280 ;; | |
2281 (t | |
2282 (+ (current-indentation) ada-broken-indent)))) | |
2283 | |
2284 ;; | |
2285 ;; 'while'-loop | |
2286 ;; | |
2287 ((looking-at "while\\>") | |
2288 ;; | |
2289 ;; while..loop ? | |
2290 ;; | |
2291 (if (save-excursion | |
2292 (setq match-cons (ada-search-ignore-string-comment | |
2293 "\\<loop\\>" nil orgpoint))) | |
2294 | |
2295 (progn | |
2296 (goto-char (car match-cons)) | |
2297 ;; | |
2298 ;; indent according to 'loop', if it's first in the line; | |
2299 ;; otherwise to 'while'. | |
2300 ;; | |
2301 (if (not (save-excursion | |
2302 (back-to-indentation) | |
2303 (looking-at "\\<loop\\>"))) | |
2304 (goto-char pos)) | |
2305 (+ (current-indentation) ada-indent)) | |
2306 | |
2307 (+ (current-indentation) ada-broken-indent)))))) | |
2308 | |
2309 | |
2310 (defun ada-get-indent-type (orgpoint) | |
2311 ;; Returns the indentation (column #) for the new line after ORGPOINT. | |
2312 ;; Assumes point to be at the beginning of a type statement. | |
2313 (let ((match-dat nil)) | |
2314 (cond | |
2315 ;; | |
2316 ;; complete record declaration | |
2317 ;; | |
2318 ((save-excursion | |
2319 (and | |
2320 (setq match-dat (ada-search-ignore-string-comment "\\<end\\>" | |
2321 nil | |
2322 orgpoint)) | |
2323 (ada-goto-next-non-ws) | |
2324 (looking-at "\\<record\\>") | |
2325 (forward-word 1) | |
2326 (ada-goto-next-non-ws) | |
2327 (looking-at ";"))) | |
2328 (goto-char (car match-dat)) | |
2329 (current-indentation)) | |
2330 ;; | |
2331 ;; record type | |
2332 ;; | |
2333 ((save-excursion | |
2334 (setq match-dat (ada-search-ignore-string-comment "\\<record\\>" | |
2335 nil | |
2336 orgpoint))) | |
2337 (goto-char (car match-dat)) | |
2338 (+ (current-indentation) ada-indent)) | |
2339 ;; | |
2340 ;; complete type declaration | |
2341 ;; | |
2342 ((save-excursion | |
2343 (ada-search-ignore-string-comment ";" nil orgpoint)) | |
2344 (current-indentation)) | |
2345 ;; | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2346 ;; "type ... is", but not "type ... is ...", which is broken |
10705 | 2347 ;; |
2348 ((save-excursion | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2349 (and |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2350 (ada-search-ignore-string-comment "\\<is\\>" nil orgpoint) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2351 (not (ada-search-ignore-string-comment "[^ \t\n]" nil orgpoint)))) |
10705 | 2352 (+ (current-indentation) ada-indent)) |
2353 ;; | |
2354 ;; broken statement | |
2355 ;; | |
2356 (t | |
2357 (+ (current-indentation) ada-broken-indent))))) | |
2358 | |
2359 | |
2360 ;;; ---- support-functions for indentation | |
2361 | |
2362 ;;; ---- searching and matching | |
2363 | |
2364 (defun ada-goto-stmt-start (&optional limit) | |
2365 ;; Moves point to the beginning of the statement that point is in or | |
2366 ;; after. Returns the new position of point. Beginnings are found | |
2367 ;; by searching for 'ada-end-stmt-re' and then moving to the | |
2368 ;; following non-ws that is not a comment. LIMIT is actually not | |
2369 ;; used by the indentation functions. | |
2370 (let ((match-dat nil) | |
2371 (orgpoint (point))) | |
2372 | |
2373 (setq match-dat (ada-search-prev-end-stmt limit)) | |
2374 (if match-dat | |
2375 ;; | |
2376 ;; found a previous end-statement => check if anything follows | |
2377 ;; | |
2378 (progn | |
2379 (if (not | |
2380 (save-excursion | |
2381 (goto-char (cdr match-dat)) | |
2382 (ada-search-ignore-string-comment | |
2383 "[^ \t\n]" nil orgpoint))) | |
2384 ;; | |
2385 ;; nothing follows => it's the end-statement directly in | |
2386 ;; front of point => search again | |
2387 ;; | |
2388 (setq match-dat (ada-search-prev-end-stmt limit))) | |
2389 ;; | |
13963
a62c62ac5102
(ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
2390 ;; if found the correct end-statement => goto next non-ws |
10705 | 2391 ;; |
2392 (if match-dat | |
2393 (goto-char (cdr match-dat))) | |
2394 (ada-goto-next-non-ws)) | |
2395 | |
2396 ;; | |
2397 ;; no previous end-statement => we are at the beginning of the | |
2398 ;; accessible part of the buffer | |
2399 ;; | |
2400 (progn | |
2401 (goto-char (point-min)) | |
2402 ;; | |
2403 ;; skip to the very first statement, if there is one | |
2404 ;; | |
2405 (if (setq match-dat | |
2406 (ada-search-ignore-string-comment | |
2407 "[^ \t\n]" nil orgpoint)) | |
2408 (goto-char (car match-dat)) | |
2409 (goto-char orgpoint)))) | |
2410 | |
2411 | |
2412 (point))) | |
2413 | |
2414 | |
2415 (defun ada-search-prev-end-stmt (&optional limit) | |
2416 ;; Moves point to previous end-statement. Returns a cons cell whose | |
2417 ;; car is the beginning and whose cdr the end of the match. | |
2418 ;; End-statements are defined by 'ada-end-stmt-re'. Checks for | |
2419 ;; certain keywords if they follow 'end', which means they are no | |
2420 ;; end-statement there. | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2421 (interactive) ;; DEBUG |
10705 | 2422 (let ((match-dat nil) |
2423 (pos nil) | |
2424 (found nil)) | |
2425 ;; | |
2426 ;; search until found or beginning-of-buffer | |
2427 ;; | |
2428 (while | |
2429 (and | |
2430 (not found) | |
2431 (setq match-dat (ada-search-ignore-string-comment ada-end-stmt-re | |
2432 t | |
2433 limit))) | |
2434 | |
2435 (goto-char (car match-dat)) | |
2436 | |
2437 (if (not (ada-in-open-paren-p)) | |
2438 ;; | |
2439 ;; check if there is an 'end' in front of the match | |
2440 ;; | |
2441 (if (not (and | |
2442 (looking-at "\\<\\(record\\|loop\\|select\\)\\>") | |
2443 (save-excursion | |
2444 (ada-goto-previous-word) | |
2445 (looking-at "\\<end\\>")))) | |
2446 (setq found t) | |
2447 | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2448 (forward-word -1)))) ; end of loop |
10705 | 2449 |
2450 (if found | |
2451 match-dat | |
2452 nil))) | |
2453 | |
2454 | |
2455 (defun ada-goto-next-non-ws (&optional limit) | |
2456 ;; Skips whitespaces, newlines and comments to next non-ws | |
2457 ;; character. Signals an error if there is no more such character | |
2458 ;; and limit is nil. | |
2459 (let ((match-cons nil)) | |
2460 (setq match-cons (ada-search-ignore-string-comment | |
2461 "[^ \t\n]" nil limit t)) | |
2462 (if match-cons | |
2463 (goto-char (car match-cons)) | |
2464 (if (not limit) | |
2465 (error "no more non-ws") | |
2466 nil)))) | |
2467 | |
2468 | |
2469 (defun ada-goto-stmt-end (&optional limit) | |
2470 ;; Moves point to the end of the statement that point is in or | |
2471 ;; before. Returns the new position of point or nil if not found. | |
2472 (if (ada-search-ignore-string-comment ada-end-stmt-re nil limit) | |
2473 (point) | |
2474 nil)) | |
2475 | |
2476 | |
2477 (defun ada-goto-previous-word () | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2478 ;; Moves point to the beginning of the previous word of Ada code. |
10705 | 2479 ;; Returns the new position of point or nil if not found. |
2480 (let ((match-cons nil) | |
2481 (orgpoint (point))) | |
2482 (if (setq match-cons | |
2483 (ada-search-ignore-string-comment "[^ \t\n]" t nil t)) | |
2484 ;; | |
2485 ;; move to the beginning of the word found | |
2486 ;; | |
2487 (progn | |
2488 (goto-char (cdr match-cons)) | |
2489 (skip-chars-backward "_a-zA-Z0-9") | |
2490 (point)) | |
2491 ;; | |
2492 ;; if not found, restore old position of point | |
2493 ;; | |
2494 (progn | |
2495 (goto-char orgpoint) | |
2496 'nil)))) | |
2497 | |
2498 | |
2499 (defun ada-check-matching-start (keyword) | |
2500 ;; Signals an error if matching block start is not KEYWORD. | |
2501 ;; Moves point to the matching block start. | |
2502 (ada-goto-matching-start 0) | |
2503 (if (not (looking-at (concat "\\<" keyword "\\>"))) | |
2504 (error (concat | |
2505 "matching start is not '" | |
2506 keyword "'")))) | |
2507 | |
2508 | |
2509 (defun ada-check-defun-name (defun-name) | |
2510 ;; Checks if the name of the matching defun really is DEFUN-NAME. | |
2511 ;; Assumes point to be already positioned by 'ada-goto-matching-start'. | |
2512 ;; Moves point to the beginning of the declaration. | |
2513 | |
2514 ;; | |
2515 ;; 'accept' or 'package' ? | |
2516 ;; | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2517 (if (not (looking-at "\\<\\(accept\\|package\\|task\\|protected\\)\\>")) |
10705 | 2518 (ada-goto-matching-decl-start)) |
2519 ;; | |
2520 ;; 'begin' of 'procedure'/'function'/'task' or 'declare' | |
2521 ;; | |
2522 (save-excursion | |
2523 ;; | |
2524 ;; a named 'declare'-block ? | |
2525 ;; | |
2526 (if (looking-at "\\<declare\\>") | |
2527 (ada-goto-stmt-start) | |
2528 ;; | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2529 ;; no, => 'procedure'/'function'/'task'/'protected' |
10705 | 2530 ;; |
2531 (progn | |
2532 (forward-word 2) | |
2533 (backward-word 1) | |
2534 ;; | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2535 ;; skip 'body' 'protected' 'type' |
10705 | 2536 ;; |
2537 (if (looking-at "\\<\\(body\\|type\\)\\>") | |
2538 (forward-word 1)) | |
2539 (forward-sexp 1) | |
2540 (backward-sexp 1))) | |
2541 ;; | |
2542 ;; should be looking-at the correct name | |
2543 ;; | |
2544 (if (not (looking-at (concat "\\<" defun-name "\\>"))) | |
2545 (error | |
2546 (concat | |
2547 "matching defun has different name: " | |
2548 (buffer-substring | |
2549 (point) | |
2550 (progn | |
2551 (forward-sexp 1) | |
2552 (point)))))))) | |
2553 | |
2554 | |
2555 (defun ada-goto-matching-decl-start (&optional noerror nogeneric) | |
2556 ;; Moves point to the matching declaration start of the current 'begin'. | |
2557 ;; If NOERROR is non-nil, it only returns nil if no match was found. | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2558 (interactive) ;; DEBUG |
10705 | 2559 (let ((nest-count 1) |
2560 (pos nil) | |
2561 (first t) | |
2562 (flag nil)) | |
2563 ;; | |
2564 ;; search backward for interesting keywords | |
2565 ;; | |
2566 (while (and | |
2567 (not (zerop nest-count)) | |
2568 (ada-search-ignore-string-comment | |
2569 (concat "\\<\\(" | |
2570 "is\\|separate\\|end\\|declare\\|new\\|begin\\|generic" | |
2571 "\\)\\>") t)) | |
2572 ;; | |
2573 ;; calculate nest-depth | |
2574 ;; | |
2575 (cond | |
2576 ;; | |
2577 ((looking-at "end") | |
2578 (ada-goto-matching-start 1 noerror) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2579 (if (looking-at "begin") |
10705 | 2580 (setq nest-count (1+ nest-count)))) |
2581 ;; | |
2582 ((looking-at "declare\\|generic") | |
2583 (setq nest-count (1- nest-count)) | |
2584 (setq first nil)) | |
2585 ;; | |
2586 ((looking-at "is") | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2587 ;; check if it is only a type definition, but not a protected |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2588 ;; type definition, which should be handled like a procedure. |
10705 | 2589 (if (save-excursion |
2590 (ada-goto-previous-word) | |
2591 (skip-chars-backward "a-zA-Z0-9_.'") | |
2592 (if (save-excursion | |
2593 (backward-char 1) | |
2594 (looking-at ")")) | |
2595 (progn | |
2596 (forward-char 1) | |
2597 (backward-sexp 1) | |
2598 (skip-chars-backward "a-zA-Z0-9_.'") | |
2599 )) | |
2600 (ada-goto-previous-word) | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2601 (and |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2602 (looking-at "\\<type\\>") |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2603 (save-match-data |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2604 (ada-goto-previous-word) |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2605 (not (looking-at "\\<protected\\>")))) |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2606 ); end of save-excursion |
10705 | 2607 (goto-char (match-beginning 0)) |
2608 (progn | |
2609 (setq nest-count (1- nest-count)) | |
2610 (setq first nil)))) | |
2611 | |
2612 ;; | |
2613 ((looking-at "new") | |
2614 (if (save-excursion | |
2615 (ada-goto-previous-word) | |
2616 (looking-at "is")) | |
2617 (goto-char (match-beginning 0)))) | |
2618 ;; | |
2619 ((and first | |
2620 (looking-at "begin")) | |
2621 (setq nest-count 0) | |
2622 (setq flag t)) | |
2623 ;; | |
2624 (t | |
2625 (setq nest-count (1+ nest-count)) | |
2626 (setq first nil))) | |
2627 | |
2628 ) ;; end of loop | |
2629 | |
2630 ;; check if declaration-start is really found | |
2631 (if (not | |
2632 (and | |
2633 (zerop nest-count) | |
2634 (not flag) | |
2635 (progn | |
2636 (if (looking-at "is") | |
2637 (ada-search-ignore-string-comment | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2638 ada-subprog-start-re t) |
10705 | 2639 (looking-at "declare\\|generic"))))) |
2640 (if noerror nil | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
2641 (error "no matching proc/func/task/declare/package/protected")) |
10705 | 2642 t))) |
2643 | |
2644 | |
2645 (defun ada-goto-matching-start (&optional nest-level noerror gotothen) | |
2646 ;; Moves point to the beginning of a block-start. Which block | |
2647 ;; depends on the value of NEST-LEVEL, which defaults to zero. If | |
2648 ;; NOERROR is non-nil, it only returns nil if no matching start was | |
2649 ;; found. If GOTOTHEN is non-nil, point moves to the 'then' | |
2650 ;; following 'if'. | |
2651 (let ((nest-count (if nest-level nest-level 0)) | |
2652 (found nil) | |
2653 (pos nil)) | |
2654 | |
2655 ;; | |
2656 ;; search backward for interesting keywords | |
2657 ;; | |
2658 (while (and | |
2659 (not found) | |
2660 (ada-search-ignore-string-comment | |
2661 (concat "\\<\\(" | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2662 "end\\|loop\\|select\\|begin\\|case\\|do\\|" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2663 "if\\|task\\|package\\|record\\|protected\\)\\>") |
10705 | 2664 t)) |
2665 | |
2666 ;; | |
2667 ;; calculate nest-depth | |
2668 ;; | |
2669 (cond | |
2670 ;; found block end => increase nest depth | |
2671 ((looking-at "end") | |
2672 (setq nest-count (1+ nest-count))) | |
2673 ;; found loop/select/record/case/if => check if it starts or | |
2674 ;; ends a block | |
2675 ((looking-at "loop\\|select\\|record\\|case\\|if") | |
2676 (setq pos (point)) | |
2677 (save-excursion | |
2678 ;; | |
2679 ;; check if keyword follows 'end' | |
2680 ;; | |
2681 (ada-goto-previous-word) | |
2682 (if (looking-at "\\<end\\>") | |
2683 ;; it ends a block => increase nest depth | |
2684 (progn | |
2685 (setq nest-count (1+ nest-count)) | |
2686 (setq pos (point))) | |
2687 ;; it starts a block => decrease nest depth | |
2688 (setq nest-count (1- nest-count)))) | |
2689 (goto-char pos)) | |
2690 ;; found package start => check if it really is a block | |
2691 ((looking-at "package") | |
2692 (save-excursion | |
2693 (ada-search-ignore-string-comment "\\<is\\>") | |
2694 (ada-goto-next-non-ws) | |
2695 ;; ignore it if it is only a declaration with 'new' | |
2696 (if (not (looking-at "\\<new\\>")) | |
2697 (setq nest-count (1- nest-count))))) | |
2698 ;; found task start => check if it has a body | |
2699 ((looking-at "task") | |
2700 (save-excursion | |
2701 (forward-word 1) | |
2702 (ada-goto-next-non-ws) | |
2703 ;; ignore it if it has no body | |
2704 (if (not (looking-at "\\<body\\>")) | |
2705 (setq nest-count (1- nest-count))))) | |
2706 ;; all the other block starts | |
2707 (t | |
2708 (setq nest-count (1- nest-count)))) ; end of 'cond' | |
2709 | |
2710 ;; match is found, if nest-depth is zero | |
2711 ;; | |
2712 (setq found (zerop nest-count))) ; end of loop | |
2713 | |
2714 (if found | |
2715 ;; | |
2716 ;; match found => is there anything else to do ? | |
2717 ;; | |
2718 (progn | |
2719 (cond | |
2720 ;; | |
2721 ;; found 'if' => skip to 'then', if it's on a separate line | |
2722 ;; and GOTOTHEN is non-nil | |
2723 ;; | |
2724 ((and | |
2725 gotothen | |
2726 (looking-at "if") | |
2727 (save-excursion | |
2728 (ada-search-ignore-string-comment "\\<then\\>" nil nil) | |
2729 (back-to-indentation) | |
2730 (looking-at "\\<then\\>"))) | |
2731 (goto-char (match-beginning 0))) | |
2732 ;; | |
2733 ;; found 'do' => skip back to 'accept' | |
2734 ;; | |
2735 ((looking-at "do") | |
2736 (if (not (ada-search-ignore-string-comment "\\<accept\\>" t nil)) | |
2737 (error "missing 'accept' in front of 'do'")))) | |
2738 (point)) | |
2739 | |
2740 (if noerror | |
2741 nil | |
2742 (error "no matching start"))))) | |
2743 | |
2744 | |
2745 (defun ada-goto-matching-end (&optional nest-level noerror) | |
2746 ;; Moves point to the end of a block. Which block depends on the | |
2747 ;; value of NEST-LEVEL, which defaults to zero. If NOERROR is | |
2748 ;; non-nil, it only returns nil if found no matching start. | |
2749 (let ((nest-count (if nest-level nest-level 0)) | |
2750 (found nil)) | |
2751 | |
2752 ;; | |
2753 ;; search forward for interesting keywords | |
2754 ;; | |
2755 (while (and | |
2756 (not found) | |
2757 (ada-search-ignore-string-comment | |
2758 (concat "\\<\\(end\\|loop\\|select\\|begin\\|case\\|" | |
2759 "if\\|task\\|package\\|record\\|do\\)\\>"))) | |
2760 | |
2761 ;; | |
2762 ;; calculate nest-depth | |
2763 ;; | |
2764 (backward-word 1) | |
2765 (cond | |
2766 ;; found block end => decrease nest depth | |
2767 ((looking-at "\\<end\\>") | |
2768 (setq nest-count (1- nest-count)) | |
2769 ;; skip the following keyword | |
2770 (if (progn | |
2771 (skip-chars-forward "end") | |
2772 (ada-goto-next-non-ws) | |
2773 (looking-at "\\<\\(loop\\|select\\|record\\|case\\|if\\)\\>")) | |
2774 (forward-word 1))) | |
2775 ;; found package start => check if it really starts a block | |
2776 ((looking-at "\\<package\\>") | |
2777 (ada-search-ignore-string-comment "\\<is\\>") | |
2778 (ada-goto-next-non-ws) | |
2779 ;; ignore and skip it if it is only a 'new' package | |
2780 (if (not (looking-at "\\<new\\>")) | |
2781 (setq nest-count (1+ nest-count)) | |
2782 (skip-chars-forward "new"))) | |
2783 ;; all the other block starts | |
2784 (t | |
2785 (setq nest-count (1+ nest-count)) | |
2786 (forward-word 1))) ; end of 'cond' | |
2787 | |
2788 ;; match is found, if nest-depth is zero | |
2789 ;; | |
2790 (setq found (zerop nest-count))) ; end of loop | |
2791 | |
2792 (if (not found) | |
2793 (if noerror | |
2794 nil | |
2795 (error "no matching end")) | |
2796 t))) | |
2797 | |
2798 | |
2799 (defun ada-forward-sexp-ignore-comment () | |
2800 ;; Skips one sexp forward, ignoring comments. | |
2801 (while (looking-at "[ \t\n]*--") | |
2802 (skip-chars-forward "[ \t\n]") | |
2803 (end-of-line)) | |
2804 (forward-sexp 1)) | |
2805 | |
2806 | |
2807 (defun ada-search-ignore-string-comment | |
2808 (search-re &optional backward limit paramlists) | |
2809 ;; Regexp-Search for SEARCH-RE, ignoring comments, strings and | |
2810 ;; parameter lists, if PARAMLISTS is nil. Returns a cons cell of | |
2811 ;; begin and end of match data or nil, if not found. | |
2812 (let ((found nil) | |
2813 (begin nil) | |
2814 (end nil) | |
2815 (pos nil) | |
2816 (search-func | |
2817 (if backward 're-search-backward | |
2818 're-search-forward))) | |
2819 | |
2820 ;; | |
2821 ;; search until found or end-of-buffer | |
2822 ;; | |
2823 (while (and (not found) | |
2824 (funcall search-func search-re limit 1)) | |
2825 (setq begin (match-beginning 0)) | |
2826 (setq end (match-end 0)) | |
2827 | |
2828 (cond | |
2829 ;; | |
2830 ;; found in comment => skip it | |
2831 ;; | |
2832 ((ada-in-comment-p) | |
2833 (if backward | |
2834 (progn | |
2835 (re-search-backward "--" nil 1) | |
2836 (goto-char (match-beginning 0))) | |
2837 (progn | |
2838 (forward-line 1) | |
2839 (beginning-of-line)))) | |
2840 ;; | |
2841 ;; found in string => skip it | |
2842 ;; | |
2843 ((ada-in-string-p) | |
2844 (if backward | |
2845 (progn | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2846 (re-search-backward "\"" nil 1) ; "\"\\|#" don't treat # |
10705 | 2847 (goto-char (match-beginning 0)))) |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2848 (re-search-forward "\"" nil 1)) |
10705 | 2849 ;; |
2850 ;; found character constant => ignore it | |
2851 ;; | |
2852 ((save-excursion | |
2853 (setq pos (- (point) (if backward 1 2))) | |
2854 (and (char-after pos) | |
2855 (= (char-after pos) ?') | |
2856 (= (char-after (+ pos 2)) ?'))) | |
2857 ()) | |
2858 ;; | |
2859 ;; found a parameter-list but should ignore it => skip it | |
2860 ;; | |
2861 ((and (not paramlists) | |
2862 (ada-in-paramlist-p)) | |
2863 (if backward | |
2864 (ada-search-ignore-string-comment "(" t nil t))) | |
2865 ;; | |
2866 ;; directly in front of a comment => skip it, if searching forward | |
2867 ;; | |
2868 ((save-excursion | |
2869 (goto-char begin) | |
2870 (looking-at "--")) | |
2871 (if (not backward) | |
2872 (progn | |
2873 (forward-line 1) | |
2874 (beginning-of-line)))) | |
2875 ;; | |
2876 ;; found what we were looking for | |
2877 ;; | |
2878 (t | |
2879 (setq found t)))) ; end of loop | |
2880 | |
2881 (if found | |
2882 (cons begin end) | |
2883 nil))) | |
2884 | |
2885 | |
2886 (defun ada-search-but-not (search-re not-search-re &optional backward limit) | |
2887 ;; Searches SEARCH-RE, ignoring parts of NOT-SEARCH-RE, strings, | |
2888 ;; comments and parameter-lists. | |
2889 (let ((begin nil) | |
2890 (end nil) | |
2891 (begin-not nil) | |
2892 (begin-end nil) | |
2893 (end-not nil) | |
2894 (ret-cons nil) | |
2895 (found nil)) | |
2896 | |
2897 ;; | |
2898 ;; search until found or end-of-buffer | |
2899 ;; | |
2900 (while (and | |
2901 (not found) | |
2902 (save-excursion | |
2903 (setq ret-cons | |
2904 (ada-search-ignore-string-comment search-re | |
2905 backward limit)) | |
2906 (if (consp ret-cons) | |
2907 (progn | |
2908 (setq begin (car ret-cons)) | |
2909 (setq end (cdr ret-cons)) | |
2910 t) | |
2911 nil))) | |
2912 | |
2913 (if (or | |
2914 ;; | |
2915 ;; if no NO-SEARCH-RE was found | |
2916 ;; | |
2917 (not | |
2918 (save-excursion | |
2919 (setq ret-cons | |
2920 (ada-search-ignore-string-comment not-search-re | |
2921 backward nil)) | |
2922 (if (consp ret-cons) | |
2923 (progn | |
2924 (setq begin-not (car ret-cons)) | |
2925 (setq end-not (cdr ret-cons)) | |
2926 t) | |
2927 nil))) | |
2928 ;; | |
2929 ;; or this NO-SEARCH-RE is not a part of the SEARCH-RE | |
2930 ;; found before. | |
2931 ;; | |
2932 (or | |
2933 (<= end-not begin) | |
2934 (>= begin-not end))) | |
2935 | |
2936 (setq found t) | |
2937 | |
2938 ;; | |
2939 ;; not found the correct match => skip this match | |
2940 ;; | |
2941 (goto-char (if backward | |
2942 begin | |
2943 end)))) ; end of loop | |
2944 | |
2945 (if found | |
2946 (progn | |
2947 (goto-char begin) | |
2948 (cons begin end)) | |
2949 nil))) | |
2950 | |
2951 | |
2952 (defun ada-goto-prev-nonblank-line ( &optional ignore-comment) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2953 ;; Moves point to the beginning of previous non-blank line, |
10705 | 2954 ;; ignoring comments if IGNORE-COMMENT is non-nil. |
2955 ;; It returns t if a matching line was found. | |
2956 (let ((notfound t) | |
2957 (newpoint nil)) | |
2958 | |
2959 (save-excursion | |
2960 ;; | |
2961 ;; backward one line, if there is one | |
2962 ;; | |
2963 (if (zerop (forward-line -1)) | |
2964 ;; | |
2965 ;; there is some kind of previous line | |
2966 ;; | |
2967 (progn | |
2968 (beginning-of-line) | |
2969 (setq newpoint (point)) | |
2970 | |
2971 ;; | |
2972 ;; search until found or beginning-of-buffer | |
2973 ;; | |
2974 (while (and (setq notfound | |
2975 (or (looking-at "[ \t]*$") | |
2976 (and (looking-at "[ \t]*--") | |
2977 ignore-comment))) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2978 (not (ada-in-limit-line-p))) |
10705 | 2979 (forward-line -1) |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
2980 ;;(beginning-of-line) |
10705 | 2981 (setq newpoint (point))) ; end of loop |
2982 | |
2983 )) ; end of if | |
2984 | |
2985 ) ; end of save-excursion | |
2986 | |
2987 (if notfound nil | |
2988 (progn | |
2989 (goto-char newpoint) | |
2990 t)))) | |
2991 | |
2992 | |
2993 (defun ada-goto-next-nonblank-line ( &optional ignore-comment) | |
2994 ;; Moves point to next non-blank line, | |
2995 ;; ignoring comments if IGNORE-COMMENT is non-nil. | |
2996 ;; It returns t if a matching line was found. | |
2997 (let ((notfound t) | |
2998 (newpoint nil)) | |
2999 | |
3000 (save-excursion | |
3001 ;; | |
3002 ;; forward one line | |
3003 ;; | |
3004 (if (zerop (forward-line 1)) | |
3005 ;; | |
3006 ;; there is some kind of previous line | |
3007 ;; | |
3008 (progn | |
3009 (beginning-of-line) | |
3010 (setq newpoint (point)) | |
3011 | |
3012 ;; | |
3013 ;; search until found or end-of-buffer | |
3014 ;; | |
3015 (while (and (setq notfound | |
3016 (or (looking-at "[ \t]*$") | |
3017 (and (looking-at "[ \t]*--") | |
3018 ignore-comment))) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3019 (not (ada-in-limit-line-p))) |
10705 | 3020 (forward-line 1) |
3021 (beginning-of-line) | |
3022 (setq newpoint (point))) ; end of loop | |
3023 | |
3024 )) ; end of if | |
3025 | |
3026 ) ; end of save-excursion | |
3027 | |
3028 (if notfound nil | |
3029 (progn | |
3030 (goto-char newpoint) | |
3031 t)))) | |
3032 | |
3033 | |
3034 ;; ---- boolean functions for indentation | |
3035 | |
3036 (defun ada-in-decl-p () | |
3037 ;; Returns t if point is inside a declarative part. | |
3038 ;; Assumes point to be at the end of a statement. | |
3039 (or | |
3040 (ada-in-paramlist-p) | |
3041 (save-excursion | |
3042 (ada-goto-matching-decl-start t)))) | |
3043 | |
3044 | |
3045 (defun ada-looking-at-semi-or () | |
3046 ;; Returns t if looking-at an 'or' following a semicolon. | |
3047 (save-excursion | |
3048 (and (looking-at "\\<or\\>") | |
3049 (progn | |
3050 (forward-word 1) | |
3051 (ada-goto-stmt-start) | |
3052 (looking-at "\\<or\\>"))))) | |
3053 | |
3054 | |
3055 (defun ada-looking-at-semi-private () | |
3056 ;; Returns t if looking-at an 'private' following a semicolon. | |
3057 (save-excursion | |
3058 (and (looking-at "\\<private\\>") | |
3059 (progn | |
3060 (forward-word 1) | |
3061 (ada-goto-stmt-start) | |
3062 (looking-at "\\<private\\>"))))) | |
3063 | |
3064 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3065 ;;; make a faster??? ada-in-limit-line-p not using count-lines |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3066 (defun ada-in-limit-line-p () |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3067 ;; return t if point is in first or last accessible line. |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3068 (or (save-excursion (beginning-of-line) (= (point-min) (point))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3069 (save-excursion (end-of-line) (= (point-max) (point))))) |
10705 | 3070 |
3071 | |
3072 (defun ada-in-comment-p () | |
3073 ;; Returns t if inside a comment. | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3074 ;; (save-excursion (and (re-search-backward "\\(--\\|\n\\)" nil 1) |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3075 ;; (looking-at "-")))) |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3076 (nth 4 (parse-partial-sexp |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3077 (save-excursion (beginning-of-line) (point)) |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3078 (point)))) |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3079 |
10705 | 3080 |
3081 | |
3082 (defun ada-in-string-p () | |
3083 ;; Returns t if point is inside a string | |
3084 ;; (Taken from pascal-mode.el, modified by MH). | |
3085 (save-excursion | |
3086 (and | |
3087 (nth 3 (parse-partial-sexp | |
3088 (save-excursion | |
3089 (beginning-of-line) | |
3090 (point)) (point))) | |
3091 ;; check if 'string quote' is only a character constant | |
3092 (progn | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3093 (re-search-backward "\"" nil t) ; # not a string delimiter anymore |
10705 | 3094 (not (= (char-after (1- (point))) ?')))))) |
3095 | |
3096 | |
3097 (defun ada-in-string-or-comment-p () | |
3098 ;; Returns t if point is inside a string or a comment. | |
3099 (or (ada-in-comment-p) | |
3100 (ada-in-string-p))) | |
3101 | |
3102 | |
3103 (defun ada-in-paramlist-p () | |
3104 ;; Returns t if point is inside a parameter-list | |
3105 ;; following 'function'/'procedure'/'package'. | |
3106 (save-excursion | |
3107 (and | |
3108 (re-search-backward "(\\|)" nil t) | |
3109 ;; inside parentheses ? | |
3110 (looking-at "(") | |
3111 (backward-word 2) | |
13963
a62c62ac5102
(ada-case-keyword, ada-auto-case, ada-krunch-args,
Karl Heuer <kwzh@gnu.org>
parents:
13337
diff
changeset
|
3112 ;; right keyword before parenthesis ? |
10705 | 3113 (looking-at (concat "\\<\\(" |
3114 "procedure\\|function\\|body\\|package\\|" | |
3115 "task\\|entry\\|accept\\)\\>")) | |
3116 (re-search-forward ")\\|:" nil t) | |
3117 ;; at least one ':' inside the parentheses ? | |
3118 (not (backward-char 1)) | |
3119 (looking-at ":")))) | |
3120 | |
3121 | |
3122 ;; not really a boolean function ... | |
3123 (defun ada-in-open-paren-p () | |
3124 ;; If point is somewhere behind an open parenthesis not yet closed, | |
3125 ;; it returns the column # of the first non-ws behind this open | |
3126 ;; parenthesis, otherwise nil." | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3127 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3128 (let ((start (if (< (point) ada-search-paren-char-count-limit) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3129 1 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3130 (- (point) ada-search-paren-char-count-limit))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3131 parse-result |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3132 (col nil)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3133 (setq parse-result (parse-partial-sexp start (point))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3134 (if (nth 1 parse-result) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3135 (save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3136 (goto-char (1+ (nth 1 parse-result))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3137 (if (save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3138 (re-search-forward "[^ \t]" nil 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3139 (backward-char 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3140 (and |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3141 (not (looking-at "\n")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3142 (setq col (current-column)))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3143 col |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3144 (current-column))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3145 nil))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3146 |
10705 | 3147 |
3148 | |
3149 ;;;----------------------;;; | |
3150 ;;; Behaviour Of TAB Key ;;; | |
3151 ;;;----------------------;;; | |
3152 | |
3153 (defun ada-tab () | |
3154 "Do indenting or tabbing according to `ada-tab-policy'." | |
3155 (interactive) | |
3156 (cond ((eq ada-tab-policy 'indent-and-tab) (error "not implemented")) | |
3157 ;; ada-indent-and-tab | |
3158 ((eq ada-tab-policy 'indent-rigidly) (ada-tab-hard)) | |
3159 ((eq ada-tab-policy 'indent-auto) (ada-indent-current)) | |
3160 ((eq ada-tab-policy 'gei) (ada-tab-gei)) | |
3161 ((eq ada-tab-policy 'indent-af) (af-indent-line)) ; GEB | |
3162 ((eq ada-tab-policy 'always-tab) (error "not implemented")) | |
3163 )) | |
3164 | |
3165 | |
3166 (defun ada-untab (arg) | |
3167 "Delete leading indenting according to `ada-tab-policy'." | |
3168 (interactive "P") | |
3169 (cond ((eq ada-tab-policy 'indent-rigidly) (ada-untab-hard)) | |
3170 ((eq ada-tab-policy 'indent-af) (backward-delete-char-untabify ; GEB | |
3171 (prefix-numeric-value arg) ; GEB | |
3172 arg)) ; GEB | |
3173 ((eq ada-tab-policy 'indent-auto) (error "not implemented")) | |
3174 ((eq ada-tab-policy 'always-tab) (error "not implemented")) | |
3175 )) | |
3176 | |
3177 | |
3178 (defun ada-indent-current-function () | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3179 "Ada Mode version of the indent-line-function." |
10705 | 3180 (interactive "*") |
3181 (let ((starting-point (point-marker))) | |
3182 (ada-beginning-of-line) | |
3183 (ada-tab) | |
3184 (if (< (point) starting-point) | |
3185 (goto-char starting-point)) | |
3186 (set-marker starting-point nil) | |
3187 )) | |
3188 | |
3189 | |
3190 (defun ada-tab-hard () | |
3191 "Indent current line to next tab stop." | |
3192 (interactive) | |
3193 (save-excursion | |
3194 (beginning-of-line) | |
3195 (insert-char ? ada-indent)) | |
3196 (if (save-excursion (= (point) (progn (beginning-of-line) (point)))) | |
3197 (forward-char ada-indent))) | |
3198 | |
3199 | |
3200 (defun ada-untab-hard () | |
3201 "indent current line to previous tab stop." | |
3202 (interactive) | |
3203 (let ((bol (save-excursion (progn (beginning-of-line) (point)))) | |
3204 (eol (save-excursion (progn (end-of-line) (point))))) | |
3205 (indent-rigidly bol eol (- 0 ada-indent)))) | |
3206 | |
3207 | |
3208 | |
3209 ;;;---------------;;; | |
3210 ;;; Miscellaneous ;;; | |
3211 ;;;---------------;;; | |
3212 | |
3213 (defun ada-remove-trailing-spaces () | |
3214 "remove trailing spaces in the whole buffer." | |
3215 (interactive) | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
3216 (save-match-data |
10705 | 3217 (save-excursion |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
3218 (save-restriction |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
3219 (widen) |
10705 | 3220 (goto-char (point-min)) |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
3221 (while (re-search-forward "[ \t]+$" (point-max) t) |
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
3222 (replace-match "" nil nil)))))) |
10705 | 3223 |
3224 | |
3225 (defun ada-untabify-buffer () | |
3226 ;; change all tabs to spaces | |
3227 (save-excursion | |
3228 (untabify (point-min) (point-max)))) | |
3229 | |
3230 | |
3231 (defun ada-uncomment-region (beg end) | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3232 "delete `comment-start' at the beginning of a line in the region." |
10705 | 3233 (interactive "r") |
3234 (comment-region beg end -1)) | |
3235 | |
3236 | |
3237 ;; define a function to support find-file.el if loaded | |
3238 (defun ada-ff-other-window () | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3239 "Find other file in other window using `ff-find-other-file'." |
10705 | 3240 (interactive) |
3241 (and (fboundp 'ff-find-other-file) | |
3242 (ff-find-other-file t))) | |
3243 | |
3244 | |
3245 ;;;-------------------------------;;; | |
3246 ;;; Moving To Procedures/Packages ;;; | |
3247 ;;;-------------------------------;;; | |
3248 | |
3249 (defun ada-next-procedure () | |
3250 "Moves point to next procedure." | |
3251 (interactive) | |
3252 (end-of-line) | |
3253 (if (re-search-forward ada-procedure-start-regexp nil t) | |
3254 (goto-char (match-beginning 1)) | |
3255 (error "No more functions/procedures/tasks"))) | |
3256 | |
3257 (defun ada-previous-procedure () | |
3258 "Moves point to previous procedure." | |
3259 (interactive) | |
3260 (beginning-of-line) | |
3261 (if (re-search-backward ada-procedure-start-regexp nil t) | |
3262 (goto-char (match-beginning 1)) | |
3263 (error "No more functions/procedures/tasks"))) | |
3264 | |
3265 (defun ada-next-package () | |
3266 "Moves point to next package." | |
3267 (interactive) | |
3268 (end-of-line) | |
3269 (if (re-search-forward ada-package-start-regexp nil t) | |
3270 (goto-char (match-beginning 1)) | |
3271 (error "No more packages"))) | |
3272 | |
3273 (defun ada-previous-package () | |
3274 "Moves point to previous package." | |
3275 (interactive) | |
3276 (beginning-of-line) | |
3277 (if (re-search-backward ada-package-start-regexp nil t) | |
3278 (goto-char (match-beginning 1)) | |
3279 (error "No more packages"))) | |
3280 | |
3281 | |
3282 ;;;----------------------- | |
3283 ;;; define keymap for Ada | |
3284 ;;;----------------------- | |
3285 | |
3286 (if (not ada-mode-map) | |
3287 (progn | |
3288 (setq ada-mode-map (make-sparse-keymap)) | |
3289 | |
3290 ;; Indentation and Formatting | |
3291 (define-key ada-mode-map "\C-j" 'ada-indent-newline-indent) | |
3292 (define-key ada-mode-map "\t" 'ada-tab) | |
3293 (define-key ada-mode-map "\C-c\C-l" 'ada-indent-region) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3294 (if (ada-xemacs) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3295 (define-key ada-mode-map '(shift tab) 'ada-untab) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3296 (define-key ada-mode-map [S-tab] 'ada-untab)) |
10705 | 3297 (define-key ada-mode-map "\C-c\C-f" 'ada-format-paramlist) |
3298 (define-key ada-mode-map "\C-c\C-p" 'ada-call-pretty-printer) | |
10707 | 3299 ;;; We don't want to make meta-characters case-specific. |
3300 ;;; (define-key ada-mode-map "\M-Q" 'ada-fill-comment-paragraph-justify) | |
10705 | 3301 (define-key ada-mode-map "\M-\C-q" 'ada-fill-comment-paragraph-postfix) |
3302 | |
3303 ;; Movement | |
10707 | 3304 ;;; It isn't good to redefine these. What should be done instead? -- rms. |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3305 ;;; (define-key ada-mode-map "\M-e" 'ada-next-package) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3306 ;;; (define-key ada-mode-map "\M-a" 'ada-previous-package) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3307 (define-key ada-mode-map "\M-\C-e" 'ada-next-procedure) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3308 (define-key ada-mode-map "\M-\C-a" 'ada-previous-procedure) |
10705 | 3309 (define-key ada-mode-map "\C-c\C-a" 'ada-move-to-start) |
3310 (define-key ada-mode-map "\C-c\C-e" 'ada-move-to-end) | |
3311 | |
3312 ;; Compilation | |
3313 (define-key ada-mode-map "\C-c\C-c" 'compile) | |
3314 | |
3315 ;; Casing | |
3316 (define-key ada-mode-map "\C-c\C-r" 'ada-adjust-case-region) | |
3317 (define-key ada-mode-map "\C-c\C-b" 'ada-adjust-case-buffer) | |
3318 | |
3319 (define-key ada-mode-map "\177" 'backward-delete-char-untabify) | |
3320 | |
3321 ;; Use predefined function of emacs19 for comments (RE) | |
3322 (define-key ada-mode-map "\C-c;" 'comment-region) | |
3323 (define-key ada-mode-map "\C-c:" 'ada-uncomment-region) | |
3324 | |
3325 ;; Change basic functionality | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3326 |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3327 ;; `substitute-key-definition' is not defined equally in GNU Emacs |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3328 ;; and XEmacs, you cannot put in an optional 4th parameter in |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3329 ;; XEmacs. I don't think it's necessary, so I leave it out for |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3330 ;; GNU Emacs as well. If you encounter any problems with the |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3331 ;; following three functions, please tell me. RE |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3332 (mapcar (function (lambda (pair) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3333 (substitute-key-definition (car pair) (cdr pair) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3334 ada-mode-map))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3335 '((beginning-of-line . ada-beginning-of-line) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3336 (end-of-line . ada-end-of-line) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3337 (forward-to-indentation . ada-forward-to-indentation) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3338 )) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3339 ;; else GNU Emacs |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3340 ;;(mapcar (lambda (pair) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3341 ;; (substitute-key-definition (car pair) (cdr pair) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3342 ;; ada-mode-map global-map)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3343 |
10705 | 3344 )) |
3345 | |
3346 | |
3347 ;;;------------------- | |
3348 ;;; define menu 'Ada' | |
3349 ;;;------------------- | |
3350 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3351 (require 'easymenu) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3352 |
10705 | 3353 (defun ada-add-ada-menu () |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3354 "Adds the menu 'Ada' to the menu bar in Ada Mode." |
11869
ab2739454f2a
(ada-add-ada-menu): Fix args to easy-menu-define.
Karl Heuer <kwzh@gnu.org>
parents:
11231
diff
changeset
|
3355 (easy-menu-define ada-mode-menu ada-mode-map "Menu keymap for Ada mode." |
10705 | 3356 '("Ada" |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3357 ["Next Package" ada-next-package t] |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3358 ["Previous Package" ada-previous-package t] |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3359 ["Next Procedure" ada-next-procedure t] |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3360 ["Previous Procedure" ada-previous-procedure t] |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3361 ["Goto Start" ada-move-to-start t] |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3362 ["Goto End" ada-move-to-end t] |
10705 | 3363 ["------------------" nil nil] |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3364 ["Indent Current Line (TAB)" |
10705 | 3365 ada-indent-current-function t] |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3366 ["Indent Lines in Region" ada-indent-region t] |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3367 ["Format Parameter List" ada-format-paramlist t] |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3368 ["Pretty Print Buffer" ada-call-pretty-printer t] |
10705 | 3369 ["------------" nil nil] |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3370 ["Fill Comment Paragraph" |
10705 | 3371 ada-fill-comment-paragraph t] |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3372 ["Justify Comment Paragraph" |
10705 | 3373 ada-fill-comment-paragraph-justify t] |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3374 ["Postfix Comment Paragraph" |
10705 | 3375 ada-fill-comment-paragraph-postfix t] |
3376 ["------------" nil nil] | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3377 ["Adjust Case Region" ada-adjust-case-region t] |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3378 ["Adjust Case Buffer" ada-adjust-case-buffer t] |
10705 | 3379 ["----------" nil nil] |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3380 ["Comment Region" comment-region t] |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3381 ["Uncomment Region" ada-uncomment-region t] |
10705 | 3382 ["----------------" nil nil] |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3383 ["Compile" compile (fboundp 'compile)] |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3384 ["Next Error" next-error (fboundp 'next-error)] |
10705 | 3385 ["---------------" nil nil] |
3386 ["Index" imenu (fboundp 'imenu)] | |
3387 ["--------------" nil nil] | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3388 ["Other File Other Window" ada-ff-other-window |
10705 | 3389 (fboundp 'ff-find-other-file)] |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3390 ["Other File" ff-find-other-file |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3391 (fboundp 'ff-find-other-file)])) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3392 (if (ada-xemacs) (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3393 (easy-menu-add ada-mode-menu) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3394 (setq mode-popup-menu (cons "Ada Mode" ada-mode-menu))))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3395 |
10705 | 3396 |
3397 | |
3398 ;;;------------------------------- | |
3399 ;;; Define Some Support Functions | |
3400 ;;;------------------------------- | |
3401 | |
3402 (defun ada-beginning-of-line (&optional arg) | |
3403 (interactive "P") | |
3404 (cond | |
3405 ((eq ada-tab-policy 'indent-af) (af-beginning-of-line arg)) | |
3406 (t (beginning-of-line arg)) | |
3407 )) | |
3408 | |
3409 (defun ada-end-of-line (&optional arg) | |
3410 (interactive "P") | |
3411 (cond | |
3412 ((eq ada-tab-policy 'indent-af) (af-end-of-line arg)) | |
3413 (t (end-of-line arg)) | |
3414 )) | |
3415 | |
3416 (defun ada-current-column () | |
3417 (cond | |
3418 ((eq ada-tab-policy 'indent-af) (af-current-column)) | |
3419 (t (current-column)) | |
3420 )) | |
3421 | |
3422 (defun ada-forward-to-indentation (&optional arg) | |
3423 (interactive "P") | |
3424 (cond | |
3425 ((eq ada-tab-policy 'indent-af) (af-forward-to-indentation arg)) | |
3426 (t (forward-to-indentation arg)) | |
3427 )) | |
3428 | |
3429 ;;;--------------------------------------------------- | |
3430 ;;; support for find-file | |
3431 ;;;--------------------------------------------------- | |
3432 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3433 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3434 ;;;###autoload |
10705 | 3435 (defun ada-make-filename-from-adaname (adaname) |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3436 "Determine the filename of a package/procedure from its own Ada name." |
10705 | 3437 ;; this is done simply by calling gkrunch, when we work with GNAT. It |
3438 ;; must be a more complex function in other compiler environments. | |
3439 (interactive "s") | |
3440 | |
3441 ;; things that should really be done by the external process | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3442 ;; since gnat-2.0, gnatk8 can do these things. If you still use a |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3443 ;; previous version, just uncomment the following lines. |
10705 | 3444 (let (krunch-buf) |
3445 (setq krunch-buf (generate-new-buffer "*gkrunch*")) | |
3446 (save-excursion | |
3447 (set-buffer krunch-buf) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3448 ; (insert (downcase adaname)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3449 ; (goto-char (point-min)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3450 ; (while (search-forward "." nil t) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3451 ; (replace-match "-" nil t)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3452 ; (setq adaname (buffer-substring (point-min) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3453 ; (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3454 ; (goto-char (point-min)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3455 ; (end-of-line) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3456 ; (point)))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3457 ; ;; clean the buffer |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3458 ; (delete-region (point-min) (point-max)) |
10705 | 3459 ;; send adaname to external process "gnatk8" |
3460 (call-process "gnatk8" nil krunch-buf nil | |
3461 adaname ada-krunch-args) | |
3462 ;; fetch output of that process | |
3463 (setq adaname (buffer-substring | |
3464 (point-min) | |
3465 (progn | |
3466 (goto-char (point-min)) | |
3467 (end-of-line) | |
3468 (point)))) | |
3469 (kill-buffer krunch-buf))) | |
3470 (setq adaname adaname) ;; can I avoid this statement? | |
3471 ) | |
3472 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3473 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3474 ;;; functions for placing the cursor on the corresponding subprogram |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3475 (defun ada-which-function-are-we-in () |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3476 "Determine whether we are on a function definition/declaration. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3477 If that is the case remember the name of that function." |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3478 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3479 (setq ff-function-name nil) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3480 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3481 (save-excursion |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3482 (if (re-search-backward ada-procedure-start-regexp nil t) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3483 (setq ff-function-name (buffer-substring (match-beginning 0) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3484 (match-end 0))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3485 ; we didn't find a procedure start, perhaps there is a package |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3486 (if (re-search-backward ada-package-start-regexp nil t) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3487 (setq ff-function-name (buffer-substring (match-beginning 0) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3488 (match-end 0))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3489 )))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3490 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3491 |
10705 | 3492 ;;;--------------------------------------------------- |
3493 ;;; support for imenu | |
3494 ;;;--------------------------------------------------- | |
3495 | |
3496 (defun imenu-create-ada-index (&optional regexp) | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3497 "Create index alist for Ada files." |
10705 | 3498 (let ((index-alist '()) |
3499 prev-pos char) | |
3500 (goto-char (point-min)) | |
3501 ;(imenu-progress-message prev-pos 0) | |
3502 ;; Search for functions/procedures | |
3503 (save-match-data | |
3504 (while (re-search-forward | |
3505 (or regexp ada-procedure-start-regexp) | |
3506 nil t) | |
3507 ;(imenu-progress-message prev-pos) | |
3508 ;; do not store forward definitions | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3509 ;; right now we store them. We want to avoid them only in |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3510 ;; package bodies, not in the specs!! ???RE??? |
10705 | 3511 (save-match-data |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3512 ; (if (not (looking-at (concat |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3513 ; "[ \t\n]*" ; WS |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3514 ; "\([^)]+\)" ; parameterlist |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3515 ; "\\([ \n\t]+return[ \n\t]+"; potential return |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3516 ; "[a-zA-Z0-9_\\.]+\\)?" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3517 ; "[ \t]*" ; WS |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3518 ; ";" ;; THIS is what we really look for |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3519 ; ))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3520 ; ; (push (imenu-example--name-and-position) index-alist) |
10705 | 3521 (setq index-alist (cons (imenu-example--name-and-position) |
3522 index-alist)) | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3523 ; ) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3524 ) |
10705 | 3525 ;(imenu-progress-message 100) |
3526 )) | |
3527 (nreverse index-alist))) | |
3528 | |
3529 ;;;--------------------------------------------------- | |
3530 ;;; support for font-lock | |
3531 ;;;--------------------------------------------------- | |
3532 | |
3533 ;; Strings are a real pain in Ada because both ' and " can appear in a | |
3534 ;; non-string quote context (the former as an operator, the latter as | |
3535 ;; a character string). We follow the least losing solution, in which | |
3536 ;; only " is a string quote. Therefore a character string of the form | |
3537 ;; '"' will throw fontification off on the wrong track. | |
3538 | |
3539 (defconst ada-font-lock-keywords-1 | |
3540 (list | |
3541 ;; | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3542 ;; accept, entry, function, package (body), protected (body|type), |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3543 ;; pragma, procedure, task (body) plus name. |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3544 (list (concat |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3545 "\\<\\(" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3546 "accept\\|" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3547 "entry\\|" |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3548 "function\\|" |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3549 "package[ \t]+body\\|" |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3550 "package\\|" |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3551 "pragma\\|" |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3552 "procedure\\|" |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3553 "protected[ \t]+body\\|" |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3554 "protected[ \t]+type\\|" |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3555 "protected\\|" |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3556 ;; "p\\(\\(ackage\\|rotected\\)\\(\\|[ \t]+\\(body\\|type\\)\\)\ |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3557 ;;\\|r\\(agma\\|ocedure\\)\\)\\|" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3558 "task\\|" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3559 "task[ \t]+body\\|" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3560 "task[ \t]+type" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3561 ;; "task\\(\\|[ \t]+body\\)" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3562 "\\)\\>[ \t]*" |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3563 "\\(\\sw+\\(\\.\\sw*\\)*\\)?") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3564 '(1 font-lock-keyword-face) '(2 font-lock-function-name-face nil t))) |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3565 "Subdued level highlighting for Ada mode.") |
10705 | 3566 |
3567 (defconst ada-font-lock-keywords-2 | |
3568 (append ada-font-lock-keywords-1 | |
3569 (list | |
3570 ;; | |
3571 ;; Main keywords, except those treated specially below. | |
3572 (concat "\\<\\(" | |
3573 ; ("abort" "abs" "abstract" "accept" "access" "aliased" "all" | |
3574 ; "and" "array" "at" "begin" "case" "declare" "delay" "delta" | |
3575 ; "digits" "do" "else" "elsif" "entry" "exception" "exit" "for" | |
3576 ; "generic" "if" "in" "is" "limited" "loop" "mod" "not" | |
3577 ; "null" "or" "others" "private" "protected" | |
3578 ; "range" "record" "rem" "renames" "requeue" "return" "reverse" | |
3579 ; "select" "separate" "tagged" "task" "terminate" "then" "until" | |
3580 ; "while" "xor") | |
3581 "a\\(b\\(ort\\|s\\(\\|tract\\)\\)\\|cce\\(pt\\|ss\\)\\|" | |
3582 "l\\(iased\\|l\\)\\|nd\\|rray\\|t\\)\\|begin\\|case\\|" | |
3583 "d\\(e\\(clare\\|l\\(ay\\|ta\\)\\)\\|igits\\|o\\)\\|" | |
3584 "e\\(ls\\(e\\|if\\)\\|ntry\\|x\\(ception\\|it\\)\\)\\|for\\|" | |
3585 "generic\\|i[fns]\\|l\\(imited\\|oop\\)\\|mod\\|n\\(ot\\|ull\\)\\|" | |
3586 "o\\(r\\|thers\\|ut\\)\\|pr\\(ivate\\|otected\\)\\|" | |
3587 "r\\(ange\\|e\\(cord\\|m\\|names\\|queue\\|turn\\|verse\\)\\)\\|" | |
3588 "se\\(lect\\|parate\\)\\|" | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3589 "t\\(agged\\|erminate\\|hen\\)\\|until\\|" ; task removed |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3590 "wh\\(ile\\|en\\)\\|xor" ; "when" added |
10705 | 3591 "\\)\\>") |
3592 ;; | |
3593 ;; Anything following end and not already fontified is a body name. | |
12586
f8bbc7a3b87a
(ada-ident-re): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
12053
diff
changeset
|
3594 '("\\<\\(end\\)\\>[ \t]+\\([a-zA-Z0-9_\\.]+\\)?" |
10705 | 3595 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) |
3596 ;; | |
3597 ;; Variable name plus optional keywords followed by a type name. Slow. | |
3598 ; (list (concat "\\<\\(\\sw+\\)\\>[ \t]*:?[ \t]*" | |
3599 ; "\\(access\\|constant\\|in\\|in[ \t]+out\\|out\\)?[ \t]*" | |
3600 ; "\\(\\sw+\\)?") | |
3601 ; '(1 font-lock-variable-name-face) | |
3602 ; '(2 font-lock-keyword-face nil t) '(3 font-lock-type-face nil t)) | |
3603 ;; | |
3604 ;; Optional keywords followed by a type name. | |
3605 (list (concat ; ":[ \t]*" | |
3606 "\\<\\(access\\|constant\\|in\\|in[ \t]+out\\|out\\)\\>" | |
3607 "[ \t]*" | |
3608 "\\(\\sw+\\)?") | |
3609 '(1 font-lock-keyword-face nil t) '(2 font-lock-type-face nil t)) | |
3610 ;; | |
3611 ;; Keywords followed by a type or function name. | |
3612 (list (concat "\\<\\(" | |
3613 "new\\|of\\|subtype\\|type" | |
3614 "\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*\\((\\)?") | |
3615 '(1 font-lock-keyword-face) | |
3616 '(2 (if (match-beginning 4) | |
3617 font-lock-function-name-face | |
3618 font-lock-type-face) nil t)) | |
3619 ;; | |
3620 ;; Keywords followed by a (comma separated list of) reference. | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3621 (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)\\>" ; "when" removed |
10705 | 3622 ; "[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?") ; RE |
3623 "[ \t]*\\([a-zA-Z0-9_\\.\\|, ]+\\)\\W") | |
3624 '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t)) | |
3625 ;; | |
3626 ;; Goto tags. | |
3627 '("<<\\(\\sw+\\)>>" 1 font-lock-reference-face) | |
3628 )) | |
13231
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3629 "Gaudy level highlighting for Ada mode.") |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3630 |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3631 (defvar ada-font-lock-keywords ada-font-lock-keywords-2 |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3632 "Default Expressions to highlight in Ada mode. |
fb78cec8e440
All doc strings changed to comply with standard Emacs conventions.
Richard M. Stallman <rms@gnu.org>
parents:
13160
diff
changeset
|
3633 See the doc to `font-lock-maximum-decoration' for user configuration.") |
10705 | 3634 |
3635 ;;; | |
3636 ;;; ???? | |
3637 ;;; | |
3638 (defun ada-gen-comment-until-proc () | |
3639 ;; comment until spec of a procedure or a function. | |
3640 (forward-line 1) | |
3641 (set-mark-command (point)) | |
3642 (if (re-search-forward ada-procedure-start-regexp nil t) | |
3643 (progn (goto-char (match-beginning 1)) | |
3644 (comment-region (mark) (point))) | |
3645 (error "No more functions/procedures"))) | |
3646 | |
3647 | |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3648 (defun ada-gen-treat-proc (match) |
10705 | 3649 ;; make dummy body of a procedure/function specification. |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3650 ;; MATCH is a cons cell containing the start and end location of the |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3651 ;; last search for ada-procedure-start-regexp. |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3652 (goto-char (car match)) |
13160
1b2a4a45f089
(ada-gen-treat-proc): Bind `procname' and `functype'.
Erik Naggum <erik@naggum.no>
parents:
12702
diff
changeset
|
3653 (let (proc-found func-found procname functype) |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3654 (cond |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3655 ((or (setq proc-found (looking-at "^[ \t]*procedure")) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3656 (setq func-found (looking-at "^[ \t]*function"))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3657 ;; treat it as a proc/func |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3658 (forward-word 2) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3659 (forward-word -1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3660 (setq procname (buffer-substring (point) (cdr match))) ; store proc name |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3661 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3662 ;; goto end of procname |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3663 (goto-char (cdr match)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3664 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3665 ;; skip over parameterlist |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3666 (forward-sexp) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3667 ;; if function, skip over 'return' and result type. |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3668 (if func-found |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3669 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3670 (forward-word 1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3671 (skip-chars-forward " \t\n") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3672 (setq functype (buffer-substring (point) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3673 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3674 (skip-chars-forward |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3675 "a-zA-Z0-9_\.") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3676 (point)))))) |
10705 | 3677 ;; look for next non WS |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3678 (cond |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3679 ((looking-at "[ \t]*;") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3680 (delete-region (match-beginning 0) (match-end 0)) ;; delete the ';' |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3681 (ada-indent-newline-indent) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3682 (insert " is") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3683 (ada-indent-newline-indent) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3684 (if func-found |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3685 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3686 (insert "Result : ") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3687 (insert functype) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3688 (insert ";") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3689 (ada-indent-newline-indent))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3690 (insert "begin -- ") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3691 (insert procname) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3692 (ada-indent-newline-indent) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3693 (insert "null;") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3694 (ada-indent-newline-indent) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3695 (if func-found |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3696 (progn |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3697 (insert "return Result;") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3698 (ada-indent-newline-indent))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3699 (insert "end ") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3700 (insert procname) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3701 (insert ";") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3702 (ada-indent-newline-indent) |
10705 | 3703 ) |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3704 ;; else |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3705 ((looking-at "[ \t\n]*is") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3706 ;; do nothing |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3707 ) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3708 ((looking-at "[ \t\n]*rename") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3709 ;; do nothing |
10705 | 3710 ) |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3711 (t |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3712 (message "unknown syntax"))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3713 )))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3714 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3715 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3716 (defun ada-make-body () |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3717 "Create an Ada package body in the current buffer. |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3718 The potential old buffer contents is deleted first, then we copy the |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3719 spec buffer in here and modify it to make it a body. |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3720 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3721 This function typically is to be hooked into `ff-file-created-hooks'." |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3722 (interactive) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3723 (delete-region (point-min) (point-max)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3724 (insert-buffer (car (cdr (buffer-list)))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3725 (ada-mode) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3726 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3727 (let (found) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3728 (if (setq found |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3729 (ada-search-ignore-string-comment ada-package-start-regexp)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3730 (progn (goto-char (cdr found)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3731 (insert " body") |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3732 ;; (forward-line -1) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3733 ;;(comment-region (point-min) (point)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3734 ) |
10705 | 3735 (error "No package")) |
12039
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3736 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3737 ;; (comment-until-proc) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3738 ;; does not work correctly |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3739 ;; must be done by hand |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3740 |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3741 (while (setq found |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3742 (ada-search-ignore-string-comment ada-procedure-start-regexp)) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3743 (ada-gen-treat-proc found)))) |
a75524689022
(initial comments): Copyright 1995; don't speak
Karl Heuer <kwzh@gnu.org>
parents:
11869
diff
changeset
|
3744 |
10705 | 3745 |
3746 ;;; provide ourself | |
3747 | |
3748 (provide 'ada-mode) | |
3749 | |
10707 | 3750 ;;; ada-mode.el ends here |