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